@Override public Optional<GitConfiguration> getConfiguration(Project project) { return propertyService.getProperty(project, GitLabProjectConfigurationPropertyType.class) .option() .map(this::getGitConfiguration); }
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()) ); }
/** * Tests if a property is defined. */ default <T> boolean hasProperty(ProjectEntity entity, Class<? extends PropertyType<T>> propertyTypeClass) { return !getProperty(entity, propertyTypeClass).isEmpty(); }
@Override public Optional<GitConfiguration> getConfiguration(Project project) { return propertyService.getProperty(project, GitHubProjectConfigurationPropertyType.class) .option() .map(this::getGitConfiguration); }
@Override public Optional<GitConfiguration> getConfiguration(Project project) { return propertyService.getProperty(project, StashProjectConfigurationPropertyType.class) .option() .map(this::getGitConfiguration); }
/** * Checks that the project is properly configured with a SVN configuration. */ @Override public boolean apply(Project project) { return !propertyService.getProperty(project, SVNProjectConfigurationPropertyType.class).isEmpty(); } }
private <P> DataFetcher projectEntityPropertyDataFetcher(PropertyType<P> propertyType, Class<? extends ProjectEntity> projectEntityClass) { return environment -> { Object source = environment.getSource(); if (projectEntityClass.isInstance(source)) { ProjectEntity projectEntity = (ProjectEntity) source; return propertyService.<P>getProperty( projectEntity, propertyType.getClass().getName() ); } else { return null; } }; } }
@Override public List<Decoration<Boolean>> getDecorations(ProjectEntity entity) { return propertyService.getProperty(entity, AutoPromotionPropertyType.class).option() .map(autoPromotionProperty -> Collections.singletonList(Decoration.of(this, Boolean.TRUE))) .orElse(Collections.emptyList()); } }
@Override public List<Decoration<MessageProperty>> getDecorations(ProjectEntity entity) { // Gets the `message` property return propertyService.getProperty(entity, MessagePropertyType.class) .option() .map( messageProperty -> Collections.singletonList( Decoration.of( this, messageProperty ) ) ) .orElse(Collections.<Decoration<MessageProperty>>emptyList()); }
@Override public Collection<? extends Issue> getLinkedIssues(Project project, IssueServiceConfiguration issueServiceConfiguration, Issue issue) { // Gets a list of link names to follow return propertyService.getProperty(project, JIRAFollowLinksPropertyType.class).option() .map(property -> { Map<String, JIRAIssue> issues = new LinkedHashMap<>(); followLinks( (JIRAConfiguration) issueServiceConfiguration, (JIRAIssue) issue, Sets.newHashSet(property.getLinkNames()), issues ); return issues.values(); }) .orElse(Collections.singleton((JIRAIssue) issue)); }
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 Stream<JobRegistration> collectJobRegistrations() { if (subversionConfProperties.isBuildSyncDisabled()) { return Stream.empty(); } else { return securityService.asAdmin(() -> getSVNConfiguredBranches() .filter(branch -> propertyService.getProperty(branch, SVNSyncPropertyType.class).option().isPresent()) .map(this::getSVNBuildSyncJobRegistration) ); } }
@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 SVNSyncInfo getSyncInfo(ID branchId) { Branch branch = structureService.getBranch(branchId); return new SVNSyncInfo( branch, propertyService.getProperty(branch, SVNSyncPropertyType.class).getValue() ); }
@Override public List<Decoration<TestDecorationData>> getDecorations(ProjectEntity entity) { return propertyService.getProperty(entity, TestDecoratorPropertyType.class) .option() .map(data -> Collections.singletonList( Decoration.of( TestDecorator.this, data ) )) .orElse(Collections.emptyList()); }
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); }
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() ); }
private JobRegistration getSVNBuildSyncJobRegistration(Branch branch) { Property<SVNSyncProperty> svnSync = propertyService.getProperty(branch, SVNSyncPropertyType.class); if (svnSync.isEmpty()) { throw new IllegalStateException("No SVN build sync is set"); } else { return JobRegistration.of(createJob(branch)) .everyMinutes(svnSync.getValue().getInterval()); } }
public JobRegistration scheduleArtifactoryBuildSync(Branch branch) { ArtifactoryPromotionSyncProperty property = propertyService.getProperty(branch, ArtifactoryPromotionSyncPropertyType.class).getValue(); return JobRegistration.of(getBranchSyncJob(branch)).everyMinutes(property.getInterval()); }
protected String getSVNBuildPath(Build build) { // Gets the build path property value Property<SVNBranchConfigurationProperty> branchConfiguration = propertyService.getProperty( build.getBranch(), SVNBranchConfigurationPropertyType.class ); if (branchConfiguration.isEmpty()) { throw new MissingSVNBranchConfigurationException(build.getBranch().getName()); } else { // Gets the build revision link ConfiguredBuildSvnRevisionLink<Object> revisionLink = buildSvnRevisionLinkService.getConfiguredBuildSvnRevisionLink( branchConfiguration.getValue().getBuildRevisionLink() ); // Gets the path to the build return revisionLink.getBuildPath(build, branchConfiguration.getValue()); } }