/** * @return */ public String getConnectingEntityType() { if ( connectingEntity == null ) { return null; } return connectingEntity.getType(); }
public static String getType( EntityRef ref ) { if ( ref == null ) { return null; } return ref.getType(); } }
/** * top level * * @param head the top-level entity */ public PathQuery( EntityRef head ) { this.uuid = head.getUuid(); this.type = head.getType(); this.query = null; }
public SimpleEntityRef( EntityRef entityRef ) { type = entityRef.getType(); uuid = entityRef.getUuid(); }
public ConnectedEntityRefImpl( String connectionType, EntityRef connectedEntity ) { super( connectedEntity.getType(), connectedEntity.getUuid() ); this.connectionType = connectionType; }
@Override public void doWrite(EntityManager em, FileImport fileImport, FileImportTracker stats) { try { if (logger.isTraceEnabled()) { logger.trace("Adding map to {}:{} dictionary {}", ownerEntityRef.getType(), ownerEntityRef.getType(), dictionaryName); } em.addMapToDictionary(ownerEntityRef, dictionaryName, dictionary); } catch (Exception e) { logger.error("Error writing dictionary. From file: " + fileImport.getFileName(), e); // TODO add statistics for dictionary writes and failures } } }
private void validateEntityType( EntityRef item, UUID id ) throws UnexpectedEntityTypeException { if ( !getEntityType().equalsIgnoreCase( item.getType() ) ) { throw new UnexpectedEntityTypeException( "Entity " + id + " is not the expected type, expected " + getEntityType() + ", found " + item .getType() ); } } }
@Override public ConnectionRef connectionRef( EntityRef connectingEntity, String connectionType, EntityRef connectedEntityRef ) throws Exception { return new ConnectionRefImpl( connectingEntity.getType(), connectingEntity.getUuid(), connectionType, connectedEntityRef.getType(), connectedEntityRef.getUuid() ); }
public Entity updateEntity( ServiceRequest request, EntityRef ref, ServicePayload payload ) throws Exception { Service service = getEntityService( ref.getType() ); if ( service != null ) { return service.updateEntity( request, ref, payload ); } return null; }
@Override public boolean isConnectionMember( String connectionType, EntityRef entity ) throws Exception { Id entityId = new SimpleId( entity.getUuid(), entity.getType() ); if (logger.isTraceEnabled()) { logger.trace("isConnectionMember(): Checking for edge type {} from {}:{} to {}:{}", connectionType, headEntity.getType(), headEntity.getUuid(), entity.getType(), entity.getUuid() ); } GraphManager gm = managerCache.getGraphManager( applicationScope ); Observable<MarkedEdge> edges = gm.loadEdgeVersions( CpNamingUtils .createEdgeFromConnectionType( new SimpleId( headEntity.getUuid(), headEntity.getType() ), connectionType, entityId ) ); return edges.toBlocking().firstOrDefault( null ) != null; }
@SuppressWarnings( "unchecked" ) @Override public boolean isCollectionMember( String collectionName, EntityRef entity ) throws Exception { Id entityId = new SimpleId( entity.getUuid(), entity.getType() ); if (logger.isTraceEnabled()) { logger.trace("isCollectionMember(): Checking for edge type {} from {}:{} to {}:{}", collectionName, headEntity.getType(), headEntity.getUuid(), entity.getType(), entity.getUuid() ); } GraphManager gm = managerCache.getGraphManager( applicationScope ); Observable<MarkedEdge> edges = gm.loadEdgeVersions( CpNamingUtils .createEdgeFromCollectionName( new SimpleId( headEntity.getUuid(), headEntity.getType() ), collectionName, entityId ) ); return edges.toBlocking().firstOrDefault( null ) != null; }
/** * top level * @param head the top-level entity * @param query the query - must have a collection or connectType value set */ public PathQuery(EntityRef head, Query query) { if ( query.getCollection() == null && query.getConnectionType() == null ) { throw new IllegalArgumentException( "Query must have a collection or connectionType value" ); } this.uuid = head.getUuid(); this.type = head.getType(); this.query = query; }
@Override public <A extends Entity> A get( EntityRef entityRef, Class<A> entityClass ) throws Exception { if ( entityRef == null ) { return null; } Entity entity = get(entityRef); if ( entity == null ) { logger.warn( "Entity {}/{} not found ", entityRef.getUuid(), entityRef.getType() ); return null; } A ret = EntityFactory.newEntity(entityRef.getUuid(), entityRef.getType(), entityClass); ret.setProperties( entity.getProperties() ); return ret; }
public SimpleCollectionRef( EntityRef ownerRef, String collectionName, EntityRef itemRef ) { this.ownerRef = ownerRef; this.collectionName = collectionName; this.itemRef = itemRef; type = itemRef.getType() + ":" + MEMBER_ENTITY_TYPE; id = CassandraPersistenceUtils.keyID( ownerRef.getUuid(), collectionName, itemRef.getUuid() ); }
public void walkCollections(final CpEntityManager em, final EntityRef start, String collectionName, boolean reverse, final CpVisitor visitor) throws Exception { if(start != null) { doWalkCollections( em, collectionName, reverse, new SimpleId(start.getUuid(), start.getType()), visitor); } }
private Results getResultsFor( EntityRef ref ) { entityRef.setUUID(ref.getUuid()); entityRef.setType(ref.getType()); try { return ( query.getCollection() != null ) ? entityManager.searchCollection( entityRef, query.getCollection(), query ) : entityManager.searchTargetEntities(entityRef, query); } catch ( Exception e ) { throw new RuntimeException( e ); } }
@Override public ServiceResults getItemByName( ServiceContext context, String name ) throws Exception { if ( ( context.getOwner() != null ) && Group.ENTITY_TYPE.equals( context.getOwner().getType() ) ) { return getItemById( context, em.getGroupRoleRef( context.getOwner().getUuid(), name ).getUuid() ); } return super.getItemByName( context, name ); }
public boolean isCollectionReversed( ServiceContext context ) { if ( info == null ) { return false; } if ( "application".equals( context.getOwner().getType() ) ) { return Schema.getDefaultSchema().isCollectionReversed("application", pluralize(info.getItemType())); } return Schema.getDefaultSchema().isCollectionReversed(info.getContainerType(), info.getCollectionName()); }
public String getCollectionSort( ServiceContext context ) { if ( info == null ) { return null; } if ( "application".equals( context.getOwner().getType() ) ) { return Schema.getDefaultSchema().getCollectionSort("application", pluralize(info.getItemType())); } return Schema.getDefaultSchema().getCollectionSort(info.getContainerType(), info.getCollectionName()); }
/** /** * Go around EntityManager and get directly from Core Persistence. */ private org.apache.usergrid.persistence.model.entity.Entity getCpEntity( EntityRef eref ) { EntityManager em = app.getEntityManager(); EntityCollectionManagerFactory ecmf = SpringResource.getInstance().getBean( Injector.class ).getInstance( EntityCollectionManagerFactory.class ); EntityCollectionManager ecm = ecmf.createCollectionManager( new ApplicationScopeImpl( new SimpleId(em.getApplicationId(), "application" ) ) ); return ecm.load( new SimpleId( eref.getUuid(), eref.getType() ) ) .toBlocking().lastOrDefault( null ); }