protected @Nullable Build lookupBuild(SVNLocation location, SVNLocation firstCopy, Branch branch) { // Gets the SVN configuration for the branch Property<SVNBranchConfigurationProperty> configurationProperty = propertyService.getProperty(branch, SVNBranchConfigurationPropertyType.class); if (configurationProperty.isEmpty()) { return null; } // Gets the build link ConfiguredBuildSvnRevisionLink<Object> revisionLink = buildSvnRevisionLinkService.getConfiguredBuildSvnRevisionLink( configurationProperty.getValue().getBuildRevisionLink() ); // Gets the earliest build return revisionLink.getEarliestBuild(branch, location, firstCopy, configurationProperty.getValue()).orElse(null); }
@Override public Optional<GitConfiguration> getConfiguration(Project project) { return propertyService.getProperty(project, GitLabProjectConfigurationPropertyType.class) .option() .map(this::getGitConfiguration); }
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 ); } }
public static boolean hasProperty(PropertyService propertyService, ProjectEntity entity, String propertyTypeName, String propertyValue) { try { Property<?> property = propertyService.getProperty(entity, propertyTypeName); return !property.isEmpty() && ( StringUtils.isBlank(propertyValue) || property.containsValue(propertyValue)); } catch (PropertyTypeNotFoundException ex) { return false; } }
@Override public boolean isTargetItemPresent(Property<?> targetItem) { return targetItem != null && !targetItem.isEmpty(); } }
@Override public SVNSyncInfo getSyncInfo(ID branchId) { Branch branch = structureService.getBranch(branchId); return new SVNSyncInfo( branch, propertyService.getProperty(branch, SVNSyncPropertyType.class).getValue() ); }
private DataFetcher projectEntityPropertiesDataFetcher(Class<? extends ProjectEntity> projectEntityClass) { return environment -> { Object o = environment.getSource(); if (projectEntityClass.isInstance(o)) { // Filters Optional<String> typeFilter = GraphqlUtils.getStringArgument(environment, "type"); boolean hasValue = GraphqlUtils.getBooleanArgument(environment, "hasValue", false); // Gets the raw list return propertyService.getProperties((ProjectEntity) o).stream() // Filter by type .filter(property -> typeFilter .map(typeFilterName -> StringUtils.equals( typeFilterName, property.getTypeDescriptor().getTypeName() )) .orElse(true) ) // Filter by value .filter(property -> !hasValue || !property.isEmpty()) // OK .collect(Collectors.toList()); } else { return null; } }; } }
@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()); }
@Override public String getItemId(Property<?> item) { return item.getType().getTypeName(); }
@Override public Property<T> of(T value) { return Property.of(this, value); }
protected void validateIssue(I issue, List<Property<?>> properties, SCMChangeLog<T> changeLog) { for (Property<?> property : properties) { if (!property.isEmpty()) { validateIssue(issue, property, changeLog); } } }
protected <T> T getProperty(ProjectEntity projectEntity, Class<? extends PropertyType<T>> propertyTypeClass) throws Exception { return asUser().with(projectEntity, ProjectEdit.class).call(() -> propertyService.getProperty( projectEntity, propertyTypeClass ).getValue() ); }
@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); }
@Override public void deleteTargetItem(Property<?> targetProperty) { propertyService.deleteProperty(target, targetProperty.getType().getTypeName()); }
@Override public List<Decoration<String>> getDecorations(ProjectEntity entity) { Property<SVNProjectConfigurationProperty> property = propertyService.getProperty(entity, SVNProjectConfigurationPropertyType.class); if (!property.isEmpty()) { return Collections.singletonList( Decoration.of( this, property.getValue().getUrl() ) ); } else { return Collections.emptyList(); } }
@Override public Optional<GitConfiguration> getConfiguration(Project project) { return propertyService.getProperty(project, GitHubProjectConfigurationPropertyType.class) .option() .map(this::getGitConfiguration); }
/** * Tests if a property is defined. */ default <T> boolean hasProperty(ProjectEntity entity, Class<? extends PropertyType<T>> propertyTypeClass) { return !getProperty(entity, propertyTypeClass).isEmpty(); }
public JobRegistration scheduleArtifactoryBuildSync(Branch branch) { ArtifactoryPromotionSyncProperty property = propertyService.getProperty(branch, ArtifactoryPromotionSyncPropertyType.class).getValue(); return JobRegistration.of(getBranchSyncJob(branch)).everyMinutes(property.getInterval()); }