public EntityType getEntityType() { return entityLink.getType(); }
public boolean apply(final EntityLink input) { return typeOfRemoteEntities.isAssignableFrom(input.getType().getClass()); } });
public EntityLink makePrimary(final String localKey, final Class<? extends EntityType> localType, final EntityLink newPrimary) { checkNotNull(localKey); checkNotNull(localType); checkNotNull(newPrimary); //confirm that the entity is actually linked to from the specified local entity if (getEntityLink(localKey, localType, newPrimary.getKey(), newPrimary.getType().getClass(), newPrimary.getApplicationLink().getId()) == null) { throw new IllegalArgumentException(String.format( "Can not make %s the new primary, not linked to from local entity %s:%s", newPrimary, localType, localKey)); } makePrimaryImpl(localKey, localType, newPrimary); return newPrimary; }
private static boolean equivalent(final EntityLink a, final String key, final Class<? extends EntityType> type, final ApplicationId applicationId) { return a.getKey().equals(key) && a.getType().getClass().equals(type) && a.getApplicationLink().getId().equals(applicationId); }
@GET @Path("primaryLinks/{type}/{key}") public Response getEntityLinks(@PathParam("type") final TypeId localTypeId, @PathParam("key") final String localKey) { final EntityType localType = typeAccessor.loadEntityType(localTypeId.get()); checkPermissionToManageEntityLink(localKey, localType); final Map<String, Set<EntityLinkEntity>> linkMap = new HashMap<String, Set<EntityLinkEntity>>(); for (final EntityLink link : entityLinkService.getEntityLinksForKey(localKey, localType.getClass())) { Set<EntityLinkEntity> links = linkMap.get(link.getType().getI18nKey()); if (links == null) { links = new TreeSet<EntityLinkEntity>(PRIMARY_FIRST); linkMap.put(link.getType().getI18nKey(), links); } links.add(new EntityLinkEntity(link)); } return ok(linkMap); }
public String apply(final EntityLink from) { final Map<String, String> propertyMap = new HashMap<String, String>(); propertyMap.put(KEY, from.getKey()); propertyMap.put(NAME, from.getName()); propertyMap.put(TYPE, getTypeId(from.getType()).get()); propertyMap.put(TYPE_I18N, from.getType().getI18nKey()); propertyMap.put(APPLICATION_ID, from.getApplicationLink().getId().get()); final StringWriter sw = new StringWriter(); try { new JSONObject(propertyMap).write(sw); } catch (JSONException e) { throw new RuntimeException(e); } return sw.getBuffer().toString(); } }));
final StringBuilder where = new StringBuilder(); for (EntityLink entityLink : entityLinkService.getEntityLinksForKey(projectKey, JiraProjectEntityType.class)) { if (entityLink.getType() instanceof JenkinsJobEntityLinkType || entityLink.getType() instanceof HudsonJobEntityLinkType) { if (where.length() > 0) { where.append(" OR ");
public boolean apply(final EntityLink input) { if (link.getId().equals(input.getApplicationLink().getId())) { // we're going to delete this - check if it is a primary link we're going to need to reassign if (!typesForWhichToReassignPrimaries.contains(input.getType().getClass())) { final PrimaryRef primary = getPrimaryRef(localEntity.getKey(), getTypeId(localEntity.getType()), getTypeId(input.getType())); if (primary.refersTo(input)) { typesForWhichToReassignPrimaries.add(input.getType().getClass()); } } removedEntityLinks.add(input); return false; } else { //this is not the link you are looking for, move along return true; } } }));
private void makePrimaryImpl(final String localKey, final Class<? extends EntityType> localType, final EntityLink newEntity) { final String primaryPropertyKey = primaryPropertyKey(getTypeId(newEntity.getType())); final Properties primary = new Properties(); primary.put(KEY, newEntity.getKey()); primary.put(APPLICATION_ID, newEntity.getApplicationLink().getId().get()); if (LOG.isDebugEnabled()) { String message = String.format("Set primary link for [%s] [%s] as [%s]", localKey, lookUpTypeId(localType), primary); LOG.debug(message); } propertyService.getLocalEntityProperties(localKey, lookUpTypeId(localType)).putProperty(primaryPropertyKey, primary); }
private static boolean equivalent(final EntityLink a, final EntityLink b) { return equivalent(a, b.getKey(), b.getType().getClass(), b.getApplicationLink().getId()); }
public boolean deleteEntityLink(final String localKey, final Class<? extends EntityType> localType, final EntityLink entityToDelete) { final List<EntityLink> entities = getStoredEntityLinks(localKey, localType); boolean deleted = false; for (final Iterator<EntityLink> iterator = entities.iterator(); iterator.hasNext(); ) { final EntityLink entity = iterator.next(); if (equivalent(entity, entityToDelete)) { iterator.remove(); deleted = true; break; } } if (deleted) { if (LOG.isDebugEnabled()) { String message = String.format("Deleting Entity Link for [%s] [%s] was [%s]", loadTypeFromClass(localType), localKey, entityToDelete); LOG.debug(message); } //if that link was the primary and there's still links of that type in existence, we'll need to assign a new one final PrimaryRef primary = getPrimaryRef(localKey, lookUpTypeId(localType), getTypeId(entityToDelete.getType())); if (primary.refersTo(entityToDelete)) { selectNewPrimary(localKey, localType, entityToDelete.getType().getClass(), entities); } propertyService.getProperties(entityToDelete).removeAll(); setStoredEntityLinks(localKey, localType, entities); eventPublisher.publish(new EntityLinkDeletedEvent(entityToDelete, localKey, localType)); } return deleted; }
if (entityLink.isPrimary() || getPrimaryRef(localKey, lookUpTypeId(localType), getTypeId(entityLink.getType())) == null) { makePrimaryImpl(localKey, localType, entityLink);
public boolean refersTo(final EntityLink link) { return refersTo(link.getKey(), getTypeId(link.getType()), link.getApplicationLink().getId()); } }
private String key(final EntityLink entity) { return String.format("%s.%s.%s.%s", ENTITY_PREFIX, escape(entity.getApplicationLink().getId().get()), escape(getTypeId(entity.getType()).get()), escape(entity.getKey()) ); }
.deleteApplicationEntityLink(getTypeId(remoteEntity.getType()), remoteEntity.getKey(), getTypeId(localType), localKey, internalHostApplication.getId().get(), true) .toString();
} catch (ReciprocalActionException e) { final String warning = i18nResolver.getText("applinks.ual.upgrade.reciprocate.entitylinks.failed", i18nResolver.getText(entityLink.getType().getI18nKey()), // from "Charlie"
.createRequest(Request.MethodType.PUT, restUrlBuilder .getUrlFor(baseUri, EntityLinkResource.class) .createEntityLink(getTypeId(entityLink.getType()), entityLink.getKey(), false, linkBack) .toString());
final EntityLink newEntityLink = entityLinkBuilderFactory.builder() .applicationLink(to) .type(oldEntityLink.getType()) .key(oldEntityLink.getKey()) .name(oldEntityLink.getName()) final String primaryPropertyKey = primaryPropertyKey(getTypeId(newEntityLink.getType())); final PropertySet props = propertyService.getLocalEntityProperties(localEntity.getKey(), TypeId.getTypeId(localEntity.getType())); final Object value = props.getProperty(primaryPropertyKey);