@Override public Optional<GitConfiguration> getConfiguration(Project project) { return propertyService.getProperty(project, GitLabProjectConfigurationPropertyType.class) .option() .map(this::getGitConfiguration); }
@Override public Collection<Property<?>> getSourceItems() { return propertyService.getProperties(source); }
private <C extends UserPasswordConfiguration<C>, T extends ConfigurationProperty<C>> void cleanupType(PropertyType<T> propertyType, String configurationName) { //noinspection unchecked propertyService // Looks for all entities which have a property pointing to this configuration .searchWithPropertyValue( (Class<? extends PropertyType<T>>) propertyType.getClass(), (entityType, id) -> entityType.getEntityFn(structureService).apply(id), property -> StringUtils.equals(property.getConfiguration().getName(), configurationName) ) // Deleting this property .forEach(projectEntity -> propertyService.deleteProperty(projectEntity, propertyType.getTypeName())); } }
@Override public void forEachConfiguredBranch( Predicate<SVNProjectConfigurationProperty> projectConfigurationPredicate, BiConsumer<Branch, SVNBranchConfigurationProperty> branchConsumer) { // Loops over all authorised branches for (Project project : structureService.getProjectList()) { // Filter on SVN configuration: must be present and equal to the one the revision info is looked into Property<SVNProjectConfigurationProperty> projectSvnConfig = propertyService.getProperty(project, SVNProjectConfigurationPropertyType.class); if (!projectSvnConfig.isEmpty() && projectConfigurationPredicate.test(projectSvnConfig.getValue())) { structureService.getBranchesForProject(project.getId()).stream() .filter(branch -> propertyService.hasProperty(branch, SVNBranchConfigurationPropertyType.class)) .forEach(branch -> { // Branch configuration SVNBranchConfigurationProperty branchConfiguration = propertyService.getProperty(branch, SVNBranchConfigurationPropertyType.class).getValue(); // OK branchConsumer.accept(branch, branchConfiguration); }); } } }
private void cleanPromotionLevel(PromotionLevel promotionLevel, int validationStampId) { Optional<AutoPromotionProperty> oProperty = propertyService.getProperty(promotionLevel, AutoPromotionPropertyType.class).option(); if (oProperty.isPresent()) { AutoPromotionProperty property = oProperty.get(); List<ValidationStamp> keptValidationStamps = property.getValidationStamps().stream().filter( validationStamp -> (validationStampId != validationStamp.id()) ).collect(Collectors.toList()); if (keptValidationStamps.size() < property.getValidationStamps().size()) { property = new AutoPromotionProperty( keptValidationStamps, property.getInclude(), property.getExclude() ); propertyService.editProperty( promotionLevel, AutoPromotionPropertyType.class, property ); } } }
private <T> boolean matchProperty(ProjectEntity e, PropertyFilter filter) { PropertyType<T> type = propertyService.getPropertyTypeByName(filter.getType()); Property<T> property = propertyService.getProperty(e, filter.getType()); return !property.isEmpty() && ( StringUtils.isBlank(filter.getValue()) || type.containsValue(property.getValue(), filter.getValue()) ); }
protected boolean canApplyTo(Branch branch) { return propertyService.hasProperty(branch.getProject(), SVNProjectConfigurationPropertyType.class) && propertyService.hasProperty(branch, SVNBranchConfigurationPropertyType.class); }
/** * Deletes the value of a property. * * @param entity Type of the entity to edit * @param propertyType Class of the property to delete */ default <T> Ack deleteProperty(ProjectEntity entity, Class<? extends PropertyType<T>> propertyType) { return deleteProperty(entity, propertyType.getName()); }
protected <T> void setProperty(ProjectEntity projectEntity, Class<? extends PropertyType<T>> propertyTypeClass, T data) throws Exception { asUser().with(projectEntity, ProjectEdit.class).execute(() -> propertyService.editProperty( projectEntity, propertyTypeClass, data ) ); }
private void cleanup(String configurationName) { securityService.asAdmin(() -> { propertyService.getPropertyTypes().stream() // Keeps only the types which are linked to configuration properties .filter(propertyType -> propertyType instanceof ConfigurationPropertyType) // Casting .map(propertyType -> (ConfigurationPropertyType) propertyType) // Cleanup for each type .forEach(propertyType -> cleanupType(propertyType, configurationName)); } ); }
Property<SVNProjectConfigurationProperty> projectSvnConfig = propertyService.getProperty(project, SVNProjectConfigurationPropertyType.class); if (!projectSvnConfig.isEmpty() && repository.getConfiguration().getName().equals(projectSvnConfig.getValue().getConfiguration().getName())) { propertyService.hasProperty(branch, SVNBranchConfigurationPropertyType.class)) {
/** * One can edit the SVN synchronisation only if he can configure the project and if the branch * is configured for SVN. */ @Override public boolean canEdit(ProjectEntity entity, SecurityService securityService) { return securityService.isProjectFunctionGranted(entity, ProjectConfig.class) && propertyService.hasProperty( entity, SVNBranchConfigurationPropertyType.class); }
@Override public void deleteTargetItem(Property<?> targetProperty) { propertyService.deleteProperty(target, targetProperty.getType().getTypeName()); }
protected <T> void doSetProperty(ProjectEntity entity, Class<? extends PropertyType<T>> propertyType, T data) throws Exception { asUser().with(entity, ProjectEdit.class).call(() -> propertyService.editProperty( entity, propertyType, data ) ); }
@Override public List<GraphQLFieldDefinition> getFields(Class<? extends ProjectEntity> projectEntityClass, ProjectEntityType projectEntityType) { return propertyService.getPropertyTypes().stream() // Gets properties which supports this type of entity .filter(propertyType -> propertyType.getSupportedEntityTypes().contains(projectEntityType)) // Gets as a field definition .map(propertyType -> newFieldDefinition() .name(propertyFieldName(propertyType)) .description(propertyType.getDescription()) .type(property.getTypeRef()) .dataFetcher(projectEntityPropertyDataFetcher(propertyType, projectEntityClass)) .build()) // OK .collect(Collectors.toList()); }
/** * Tests if a property is defined. */ default <T> boolean hasProperty(ProjectEntity entity, Class<? extends PropertyType<T>> propertyTypeClass) { return !getProperty(entity, propertyTypeClass).isEmpty(); }
@Override public Collection<Property<?>> getTargetItems() { return propertyService.getProperties(target); }
/** * Gets the list of all branches, for all projects, which are properly configured for SVN. */ protected Stream<Branch> getSVNConfiguredBranches() { return structureService.getProjectList() .stream() // ...which have a SVN configuration .filter(project -> propertyService.hasProperty(project, SVNProjectConfigurationPropertyType.class)) // ...gets all their branches .flatMap(project -> structureService.getBranchesForProject(project.getId()).stream()) // ...which have a SVN configuration .filter(branch -> propertyService.hasProperty(branch, SVNBranchConfigurationPropertyType.class)); } }
@Override public Optional<GitConfiguration> getConfiguration(Project project) { return propertyService.getProperty(project, GitHubProjectConfigurationPropertyType.class) .option() .map(this::getGitConfiguration); }
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)); } }