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()); }
List<ValidationRun> runs = structureService.getValidationRunsForValidationStamp(entity.getId(), 0, 5);
private <T> Ack editProperty(ProjectEntity entity, PropertyType<T> propertyType, T value) { // Checks for edition if (!propertyType.canEdit(entity, securityService)) { throw new AccessDeniedException("Property is not opened for edition."); } // Gets the JSON for the storage JsonNode storage = propertyType.forStorage(value); // Stores the property propertyRepository.saveProperty( propertyType.getClass().getName(), entity.getProjectEntityType(), entity.getId(), storage ); // Property change event eventPostService.post(eventFactory.propertyChange(entity, propertyType)); // Listener propertyType.onPropertyChanged(entity, value); // OK return Ack.OK; }
private <T> Ack deleteProperty(ProjectEntity entity, PropertyType<T> propertyType) { // Checks for edition if (!propertyType.canEdit(entity, securityService)) { throw new AccessDeniedException("Property is not opened for viewing."); } // Gets the existing value T value = getPropertyValue(propertyType, entity); // If existing, deletes it if (value != null) { Ack ack = propertyRepository.deleteProperty(propertyType.getClass().getName(), entity.getProjectEntityType(), entity.getId()); if (ack.isSuccess()) { // Property deletion event eventPostService.post(eventFactory.propertyDelete(entity, propertyType)); // Listener propertyType.onPropertyDeleted(entity, value); } // OK return ack; } else { return Ack.NOK; } }