/** * Returns the document identifier in the repository's index for the given component. */ @Nullable private String identifier(@Nullable final EntityId componentId) { return componentId != null ? componentId.getValue() : null; }
@Override public String getTokenFromId(final Entity entity) { return id(entity).getValue(); } }
/** * Returns the {@link CapabilityIdentity} for the persisted {@link EntityId}. * * @since 3.1 */ static CapabilityIdentity identity(EntityId entityId) { return new CapabilityIdentity(entityId.getValue()); }
private String documentId(final Asset asset) { return EntityHelper.id(asset).getValue(); }
@Override public boolean equals(final Object o) { if (this == o) { return true; } else if (o instanceof AttachedEntityId) { AttachedEntityId that = (AttachedEntityId)o; return identity.equals(that.identity); } else if (o instanceof EntityId) { EntityId that = (EntityId)o; return getValue().equals(that.getValue()); } return false; }
public ORID recordIdentity(final EntityId id) { checkNotNull(id); if (id instanceof AttachedEntityId) { return ((AttachedEntityId) id).getIdentity(); } return getRecordIdObfuscator().decode(getSchemaType(), id.getValue()); }
public Iterable<ODocument> documents(final ODatabaseDocumentTx db, final Iterable<EntityId> ids) { Set<ORID> rids = stream(ids).map(id -> { if (id instanceof AttachedEntityId) { return ((AttachedEntityId) id).getIdentity(); } return getRecordIdObfuscator().decode(getSchemaType(), id.getValue()); }).collect(toSet()); return db.command(new OCommandSQL("select from :rids")).execute(singletonMap("rids", rids)); }
/** * Return the document for given {@link EntityId}. */ public ODocument document(final ODatabaseDocumentTx db, final EntityId id) { ORID rid; if (id instanceof AttachedEntityId) { rid = ((AttachedEntityId)id).getIdentity(); } else { rid = getRecordIdObfuscator().decode(getSchemaType(), id.getValue()); } return db.getRecord(rid); }
/** * Returns detached entity metadata. */ public DetachedEntityMetadata detach() { return new DetachedEntityMetadata( new DetachedEntityId(id.getValue()), new DetachedEntityVersion(version.getValue()) ); }
private ComponentXO fromComponent(Component component, Repository repository) { String internalId = id(component).getValue(); ComponentXO componentXO = componentXOFactory.createComponentXO(); componentXO .setAssets(browseService.browseComponentAssets(repository, component.getEntityMetadata().getId().getValue()) .getResults() .stream() .map(asset -> fromAsset(asset, repository)) .collect(toList())); componentXO.setGroup(component.group()); componentXO.setName(component.name()); componentXO.setVersion(component.version()); componentXO.setId(new RepositoryItemIDXO(repository.getName(), internalId).getValue()); componentXO.setRepository(repository.getName()); componentXO.setFormat(repository.getFormat().getValue()); for (ComponentsResourceExtension componentsResourceExtension : componentsResourceExtensions) { componentXO = componentsResourceExtension.updateComponentXO(componentXO, component); } return componentXO; }