-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
synapticloop
committed
Dec 30, 2015
1 parent
3b6c899
commit f19ad9d
Showing
11 changed files
with
135 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Fri Nov 06 16:01:55 GMT 2015 | ||
#Wed Nov 25 10:24:41 GMT 2015 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package synapticloop.h2zero.util; | ||
|
||
import java.util.Iterator; | ||
import java.util.Set; | ||
|
||
import org.json.JSONObject; | ||
|
||
import synapticloop.h2zero.model.BaseSchemaObject; | ||
import synapticloop.h2zero.util.SimpleLogger.LoggerType; | ||
|
||
public class KeyHelper { | ||
|
||
public static void findMissingKeys(BaseSchemaObject baseSchemaObject, JSONObject jsonObject, Set<String> allowableKeys) { | ||
Iterator<String> keys = jsonObject.keys(); | ||
while (keys.hasNext()) { | ||
String key = (String) keys.next(); | ||
if(!allowableKeys.contains(key)) { | ||
SimpleLogger.logWarn(LoggerType.PARSE, baseSchemaObject.getClass(), "Found a key with name '" + key + "', which is not utilised."); | ||
} | ||
} | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/synapticloop/h2zero/validator/field/FieldNotNullLengthValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package synapticloop.h2zero.validator.field; | ||
|
||
import java.util.List; | ||
|
||
import synapticloop.h2zero.model.Database; | ||
import synapticloop.h2zero.model.Options; | ||
import synapticloop.h2zero.model.Table; | ||
import synapticloop.h2zero.model.field.BaseField; | ||
import synapticloop.h2zero.validator.BaseValidator; | ||
|
||
/** | ||
* This validator checks to see whether there are some fields which are marked | ||
* as nullable, however do not have a minimum length set on them | ||
* | ||
* @author synapticloop | ||
* | ||
*/ | ||
public class FieldNotNullLengthValidator extends BaseValidator { | ||
|
||
@Override | ||
public void validate(Database database, Options options) { | ||
List<Table> tables = database.getTables(); | ||
for (Table table : tables) { | ||
List<BaseField> fields = table.getFields(); | ||
for (BaseField baseField : fields) { | ||
if(!baseField.getNullable() && baseField.getMinLength() == 0 && "String".equals(baseField.getJavaType())) { | ||
addWarnMessage("Table field '" + table.getName() + "." + baseField.getName() + "' is not allowed to be null, but has a minimum length of 0"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters