Compare commits
2 Commits
89ab0f3b6a
...
249e6ad2c8
Author | SHA1 | Date | |
---|---|---|---|
249e6ad2c8 | |||
e156e528c1 |
@ -12,7 +12,6 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.AnnotationTools;
|
import org.kar.archidata.annotation.AnnotationTools;
|
||||||
@ -21,7 +20,6 @@ import org.kar.archidata.annotation.checker.CollectionItemNotNull;
|
|||||||
import org.kar.archidata.annotation.checker.CollectionItemUnique;
|
import org.kar.archidata.annotation.checker.CollectionItemUnique;
|
||||||
import org.kar.archidata.annotation.checker.CollectionNotEmpty;
|
import org.kar.archidata.annotation.checker.CollectionNotEmpty;
|
||||||
import org.kar.archidata.dataAccess.DBAccess;
|
import org.kar.archidata.dataAccess.DBAccess;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
import org.kar.archidata.dataAccess.QueryOptions;
|
import org.kar.archidata.dataAccess.QueryOptions;
|
||||||
import org.kar.archidata.dataAccess.options.CheckFunctionInterface;
|
import org.kar.archidata.dataAccess.options.CheckFunctionInterface;
|
||||||
@ -224,31 +222,6 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
final ManyToOne annotationManyToOne = AnnotationTools.getManyToOne(field);
|
|
||||||
if (annotationManyToOne != null && annotationManyToOne.targetEntity() != null) {
|
|
||||||
add(fieldName,
|
|
||||||
(
|
|
||||||
final DBAccess ioDb,
|
|
||||||
final String baseName,
|
|
||||||
final T data,
|
|
||||||
final List<String> modifiedValue,
|
|
||||||
final QueryOptions options) -> {
|
|
||||||
final Object elem = field.get(data);
|
|
||||||
if (elem == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final List<ConditionChecker> condCheckers = options.get(ConditionChecker.class);
|
|
||||||
final Condition conditionCheck = condCheckers.isEmpty() ? null
|
|
||||||
: condCheckers.get(0).toCondition();
|
|
||||||
final long count = DataAccess.count(annotationManyToOne.targetEntity(), elem,
|
|
||||||
conditionCheck);
|
|
||||||
if (count == 0) {
|
|
||||||
throw new InputException(baseName + fieldName,
|
|
||||||
"Foreign element does not exist in the DB:" + elem);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (type == Integer.class || type == int.class) {
|
} else if (type == Integer.class || type == int.class) {
|
||||||
final DecimalMax maxValueDecimal = AnnotationTools.getConstraintsDecimalMax(field);
|
final DecimalMax maxValueDecimal = AnnotationTools.getConstraintsDecimalMax(field);
|
||||||
if (maxValueDecimal != null) {
|
if (maxValueDecimal != null) {
|
||||||
@ -347,47 +320,6 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
final ManyToOne annotationManyToOne = AnnotationTools.getManyToOne(field);
|
|
||||||
if (annotationManyToOne != null && annotationManyToOne.targetEntity() != null) {
|
|
||||||
add(fieldName,
|
|
||||||
(
|
|
||||||
final DBAccess ioDb,
|
|
||||||
final String baseName,
|
|
||||||
final T data,
|
|
||||||
final List<String> modifiedValue,
|
|
||||||
final QueryOptions options) -> {
|
|
||||||
final Object elem = field.get(data);
|
|
||||||
if (elem == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final long count = DataAccess.count(annotationManyToOne.targetEntity(), elem);
|
|
||||||
if (count == 0) {
|
|
||||||
throw new InputException(baseName + fieldName,
|
|
||||||
"Foreign element does not exist in the DB:" + elem);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (type == UUID.class) {
|
|
||||||
final ManyToOne annotationManyToOne = AnnotationTools.getManyToOne(field);
|
|
||||||
if (annotationManyToOne != null && annotationManyToOne.targetEntity() != null) {
|
|
||||||
add(fieldName,
|
|
||||||
(
|
|
||||||
final DBAccess ioDb,
|
|
||||||
final String baseName,
|
|
||||||
final T data,
|
|
||||||
final List<String> modifiedValue,
|
|
||||||
final QueryOptions options) -> {
|
|
||||||
final Object elem = field.get(data);
|
|
||||||
if (elem == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final long count = DataAccess.count(annotationManyToOne.targetEntity(), elem);
|
|
||||||
if (count == 0) {
|
|
||||||
throw new InputException(baseName + fieldName,
|
|
||||||
"Foreign element does not exist in the DB:" + elem);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (type == Boolean.class || type == boolean.class) {
|
} else if (type == Boolean.class || type == boolean.class) {
|
||||||
|
|
||||||
} else if (type == Float.class || type == float.class) {
|
} else if (type == Float.class || type == float.class) {
|
||||||
@ -733,6 +665,29 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
final ManyToOne annotationManyToOne = AnnotationTools.getManyToOne(field);
|
||||||
|
if (annotationManyToOne != null && annotationManyToOne.targetEntity() != null) {
|
||||||
|
add(fieldName,
|
||||||
|
(
|
||||||
|
final DBAccess ioDb,
|
||||||
|
final String baseName,
|
||||||
|
final T data,
|
||||||
|
final List<String> modifiedValue,
|
||||||
|
final QueryOptions options) -> {
|
||||||
|
final Object elem = field.get(data);
|
||||||
|
if (elem == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final List<ConditionChecker> condCheckers = options.get(ConditionChecker.class);
|
||||||
|
final Condition conditionCheck = condCheckers.isEmpty() ? null
|
||||||
|
: condCheckers.get(0).toCondition();
|
||||||
|
final long count = ioDb.count(annotationManyToOne.targetEntity(), elem, conditionCheck);
|
||||||
|
if (count == 0) {
|
||||||
|
throw new InputException(baseName + fieldName,
|
||||||
|
"Foreign element does not exist in the DB:" + elem);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
final CollectionItemUnique collectionUnique = AnnotationTools.getCollectionItemUnique(field);
|
final CollectionItemUnique collectionUnique = AnnotationTools.getCollectionItemUnique(field);
|
||||||
if (collectionUnique != null) {
|
if (collectionUnique != null) {
|
||||||
if (!Collection.class.isAssignableFrom(field.getType())) {
|
if (!Collection.class.isAssignableFrom(field.getType())) {
|
||||||
@ -822,10 +777,10 @@ public class CheckJPA<T> implements CheckFunctionInterface {
|
|||||||
final List<ConditionChecker> condCheckers = options.get(ConditionChecker.class);
|
final List<ConditionChecker> condCheckers = options.get(ConditionChecker.class);
|
||||||
Object other = null;
|
Object other = null;
|
||||||
if (condCheckers.isEmpty()) {
|
if (condCheckers.isEmpty()) {
|
||||||
other = DataAccess.getWhere(this.clazz,
|
other = ioDb.getWhere(this.clazz,
|
||||||
new Condition(new QueryCondition(fieldName, "==", field.get(data))));
|
new Condition(new QueryCondition(fieldName, "==", field.get(data))));
|
||||||
} else {
|
} else {
|
||||||
other = DataAccess.getWhere(this.clazz,
|
other = ioDb.getWhere(this.clazz,
|
||||||
new Condition(new QueryCondition(fieldName, "==", field.get(data))),
|
new Condition(new QueryCondition(fieldName, "==", field.get(data))),
|
||||||
condCheckers.get(0).toCondition());
|
condCheckers.get(0).toCondition());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user