private void validateEntityValueTypes(Entity entity, ValidationResource validationResource) { // entity attributes validation Set<ConstraintViolation> attrViolations = entityAttributesValidator.validate(entity, getEntityType()); if (attrViolations != null && !attrViolations.isEmpty()) { attrViolations.forEach(validationResource::addViolation); } }
private void initRequiredValueValidation(ValidationResource validationResource) { if (!getCapabilities().contains(VALIDATE_NOTNULL_CONSTRAINT)) { List<Attribute> requiredValueAttrs = stream(getEntityType().getAtomicAttributes().spliterator(), false) .filter(attr -> !attr.isNillable() && attr.getExpression() == null) .collect(toList()); validationResource.setRequiredValueAttrs(requiredValueAttrs); } }
private void initReadonlyValidation(ValidationResource validationResource) { if (!getCapabilities().contains(VALIDATE_READONLY_CONSTRAINT)) { String idAttrName = getEntityType().getIdAttribute().getName(); List<Attribute> readonlyAttrs = stream(getEntityType().getAtomicAttributes().spliterator(), false) .filter( attr -> attr.isReadOnly() && attr.getExpression() == null && !attr.isMappedBy() && !attr.getName().equals(idAttrName)) .collect(toList()); validationResource.setReadonlyAttrs(readonlyAttrs); } }
@Override public void deleteAll() { defaultValueReferenceValidator.validateEntityTypeNotReferenced(getEntityType()); delegate().deleteAll(); }
@Override public void deleteById(Object id) { defaultValueReferenceValidator.validateEntityNotReferencedById(id, getEntityType()); delegate().deleteById(id); }
@Override public void deleteAll(Stream<Object> ids) { delegate() .deleteAll( defaultValueReferenceValidator.validateEntitiesNotReferencedById(ids, getEntityType())); }
@Override public void delete(Stream<Entity> entities) { delegate() .delete( defaultValueReferenceValidator.validateEntitiesNotReferenced( entities, getEntityType())); }
stream(getEntityType().getAtomicAttributes().spliterator(), false) .filter(attr -> isReferenceType(attr) && attr.getExpression() == null) .collect(toList()); String backend = dataService.getMeta().getBackend(getEntityType()).getName(); refAttrs = stream(getEntityType().getAtomicAttributes().spliterator(), false) .filter( attr -> refAttrs .stream() .anyMatch(refAttr -> refAttr.getRefEntity().getId().equals(getEntityType().getId()))); validationResource.setRefAttrs(refAttrs);
stream(getEntityType().getAtomicAttributes().spliterator(), false) .filter(attr -> attr.isUnique() && attr.getExpression() == null) .collect(toList());