@Override public String getItemId(Property<?> item) { return item.getType().getTypeName(); }
@Override public <T> void copyProperty(ProjectEntity sourceEntity, Property<T> property, ProjectEntity targetEntity, Function<String, String> replacementFn) { // Property copy T data = property.getType().copy(sourceEntity, property.getValue(), targetEntity, replacementFn); // Direct edition editProperty(targetEntity, property.getType(), data); }
private <C> void validateIssue(I issue, Property<C> property, SCMChangeLog<T> changeLog) { SCMChangeLogIssueValidator<C, S, T, I> validator = (SCMChangeLogIssueValidator<C, S, T, I>) property.getType(); validator.validate(changeLog, issue, property.getValue()); }
@Override public void deleteTargetItem(Property<?> targetProperty) { propertyService.deleteProperty(target, targetProperty.getType().getTypeName()); }
@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 void validateIssues(List<I> issuesList, SCMChangeLog<T> changeLog) { // Same branch only if (changeLog.isSameBranch()) { // Gets the branch Branch branch = changeLog.getFrom().getBuild().getBranch(); // Gets the list of validators for this branch List<Property<?>> properties = propertyService.getProperties(branch).stream() .filter(property -> !property.isEmpty() && property.getType() instanceof SCMChangeLogIssueValidator) .collect(Collectors.toList()); // Validates each issues issuesList.forEach(issue -> validateIssue(issue, properties, changeLog)); } }
protected <T> void doCopyProperty(ProjectEntity sourceEntity, Property<T> property, ProjectEntity targetEntity, Function<String, String> replacementFn) { if (!property.isEmpty() && property.getType().canEdit(targetEntity, securityService)) { // Copy of the property propertyService.copyProperty( sourceEntity, property, targetEntity, replacementFn ); } }