@Override public Iterable<EntityLink> getEntityLinks(Object entity, Class<? extends EntityType> type) { return entityLinkService.getEntityLinks(entity, type); }
@Override public Iterable<EntityLink> getEntityLinks(Object entity) { return entityLinkService.getEntityLinks(entity); }
@Override public Iterable<EntityLink> getEntityLinks(String localKey, @Nullable final ApplicationId applicationId) { Iterable<EntityLink> links = entityLinkService.getEntityLinks(getRawEntity(localKey), SonarQubeResourceEntityLinkType.class); if (applicationId == null) { return links; } else { return Iterables.filter(links, new Predicate<EntityLink>() { @Override public boolean apply(@Nullable EntityLink entityLink) { return entityLink != null && entityLink.getApplicationLink().getId().equals(applicationId); } }); } }
/** * Get all the FishEye repositories which have been linked to the given JIRA project. Protected for testing only. * * @param jiraProjectKey the key of the JIRA project * @return the repositories */ @VisibleForTesting protected Iterable<FishEyeRepository> getAllLinkedRepositoriesForJiraProjectKey(String jiraProjectKey) { Project project = projectManager.getProjectObjByKey(jiraProjectKey); if (project != null) { return Iterables.transform(entityLinkService.getEntityLinks(project, FishEyeRepositoryEntityType.class), new Function<EntityLink, FishEyeRepository>() { public FishEyeRepository apply(final EntityLink entityLink) { return createRepository(entityLink); } }); } else { return Collections.emptyList(); } }
private Iterable<String> getJiraEntityLinkKeys(ApplicationLink appLink, Object entity) { List<String> keys = new LinkedList<>(); Iterable<EntityLink> entityLinks = entityLinkService.getEntityLinks(entity, JiraProjectEntityType.class); for (EntityLink link : entityLinks) { if (link.getApplicationLink().equals(appLink)) { keys.add(link.getKey()); } } return keys; } }
@Override public EntityLink getEntityLink(String localKey, final @Nullable ApplicationId applicationId, final @Nullable String remoteKey) { Iterable<EntityLink> links = entityLinkService.getEntityLinks(getRawEntity(localKey), SonarQubeResourceEntityLinkType.class); Predicate<EntityLink> predicate; if ((applicationId == null || remoteKey == null) && Iterables.size(links) == 1) { return links.iterator().next(); } else if (applicationId == null || remoteKey == null) { predicate = new Predicate<EntityLink>() { @Override public boolean apply(@Nullable EntityLink entityLink) { return entityLink != null && entityLink.isPrimary(); } }; } else { predicate = new Predicate<EntityLink>() { @Override public boolean apply(@Nullable EntityLink entityLink) { return entityLink != null && applicationId.equals(entityLink.getApplicationLink().getId()) && remoteKey.equals (entityLink.getKey()); } }; } try { return Iterables.find(links, predicate); } catch (Exception e) { return null; } }
for (EntityLink entityLink : entityLinkService.getEntityLinks(jiraProject, FishEyeRepositoryEntityType.class)) { repositoryNamesFromEntityLinks.add(entityLink.getKey()); for (EntityLink entityLink : entityLinkService.getEntityLinks(jiraProject, FishEyeCrucibleProjectEntityType.class)) { String key = entityLink.getApplicationLink().getId().get() + "." + entityLink.getKey(); if (!jiraCrucibleEntityLinks.containsKey(key)) {