/** * @return */ public UUID getConnectingEntityId() { if ( connectingEntity == null ) { return null; } return connectingEntity.getUuid(); }
public static UUID getUuid( EntityRef ref ) { if ( ref == null ) { return null; } return ref.getUuid(); }
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() ); }
/** * top level * * @param head the top-level entity */ public PathQuery( EntityRef head ) { this.uuid = head.getUuid(); this.type = head.getType(); this.query = null; }
public ConnectedEntityRefImpl( String connectionType, EntityRef connectedEntity ) { super( connectedEntity.getType(), connectedEntity.getUuid() ); this.connectionType = connectionType; }
@Override public ConnectionRef connectionRef( EntityRef connectingEntity, String connectionType, EntityRef connectedEntityRef ) throws Exception { return new ConnectionRefImpl( connectingEntity.getType(), connectingEntity.getUuid(), connectionType, connectedEntityRef.getType(), connectedEntityRef.getUuid() ); }
private Object getRolePermissionsKey( UUID groupId, String roleName ) { try { return CassandraPersistenceUtils .key( getGroupRoleRef( groupId, roleName ).getUuid(), DICTIONARY_PERMISSIONS ); } catch ( Exception e ) { logger.error( "Error creating role key for uuid {} and role {}", groupId, roleName ); 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; }
/** * 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 Notification getSourceNotification(EntityRef receipt) throws Exception { Receipt r = em.get(receipt.getUuid(), Receipt.class); return em.get(r.getNotificationUUID(), Notification.class); }
@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 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); } }
@Override public OrganizationInfo getOrganizationByName( String organizationName ) throws Exception { if ( organizationName == null ) { return null; } EntityManager em = emf.getEntityManager(smf.getManagementAppId()); EntityRef ref = em.getAlias( Group.ENTITY_TYPE, organizationName ); if ( ref == null ) { return null; } return getOrganizationByUuid( ref.getUuid() ); }
@Override public OrganizationConfig getOrganizationConfigByName( String organizationName ) throws Exception { if ( organizationName == null || organizationName.equals(CassandraService.MANAGEMENT_APPLICATION)) { return getOrganizationConfigDefaultsOnly(); } EntityManager em = emf.getEntityManager(smf.getManagementAppId()); EntityRef ref = em.getAlias( Group.ENTITY_TYPE, organizationName ); return ref != null ? getOrganizationConfigByUuid(ref.getUuid()) : getOrganizationConfigDefaultsOnly(); }
public void addDevice(EntityRef notification, EntityRef device) throws Exception { String jobQueueName = getJobQueueName(notification); Message message = new Message(); message.setObjectProperty(MESSAGE_PROPERTY_DEVICE_UUID, device.getUuid()); sm.getQueueManager().postToQueue(jobQueueName, message); }
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 ); } }
public ServiceResults getApplicationEntity( ServiceContext context ) throws Exception { checkPermissionsForPath( context, "/" ); Entity entity = em.get( em.getApplicationRef() ); Results r = Results.fromEntity( entity ); Map<String, Object> collections = em.getApplicationCollectionMetadata(); // Set<String> collections = em.getApplicationCollections(); if ( collections.size() > 0 ) { r.setMetadata( em.getApplicationRef().getUuid(), "collections", collections ); } return genericServiceResults( r ); }
public void setChildResults( ServiceResults childResults ) { setChildResults( childResults.getResultsType(), childResults.getRequest().getOwner().getUuid(), childResults.getChildPath(), childResults.getEntities() ); }
/** /** * 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 ); }