@Override public List<Property<?>> getProperties(ProjectEntity entity) { // With all the existing properties... return getPropertyTypes().stream() // ... filters them by entity .filter(type -> type.getSupportedEntityTypes().contains(entity.getProjectEntityType())) // ... filters them by access right .filter(type -> type.canView(entity, securityService)) // ... loads them from the store .map(type -> getProperty(type, entity)) // .. flags with editionrights .map(prop -> prop.editable(prop.getType().canEdit(entity, securityService))) // ... and returns them .collect(Collectors.toList()); }
protected <T> T getPropertyValue(PropertyType<T> type, ProjectEntity entity) { // Supported entity? if (!type.getSupportedEntityTypes().contains(entity.getProjectEntityType())) { throw new PropertyUnsupportedEntityTypeException(type.getClass().getName(), entity.getProjectEntityType()); } // Checks for viewing if (!type.canView(entity, securityService)) { throw new AccessDeniedException("Property is not opened for viewing."); } // Gets the raw information from the repository TProperty t = propertyRepository.loadProperty( type.getClass().getName(), entity.getProjectEntityType(), entity.getId()); // If null, returns null if (t == null) { return null; } // Converts the stored value into an actual value return type.fromStorage(t.getJson()); }