@JsonSerialize(include = Inclusion.NON_NULL) public Map<UUID, EntityRef> getRefsMap() { if ( refsMap != null ) { return refsMap; } getEntitiesMap(); if ( entitiesMap != null ) { refsMap = cast( entitiesMap ); return refsMap; } getRefs(); if ( refs != null ) { refsMap = new LinkedHashMap<UUID, EntityRef>(); for ( EntityRef ref : refs ) { refsMap.put( ref.getUuid(), ref ); } } return refsMap; }
public List<EntityRef> getEntityRefsByType( String type ) { if ( entitiesByType != null ) { return refsByType.get( type ); } List<EntityRef> l = cast( getEntitiesByType( type ) ); if ( l != null ) { return l; } getRefs(); if ( refs == null ) { return null; } refsByType = new LinkedHashMap<String, List<EntityRef>>(); for ( Entity entity : entities ) { l = refsByType.get( entity.getType() ); if ( l == null ) { l = new ArrayList<EntityRef>(); refsByType.put( entity.getType(), l ); } l.add( entity ); } return l; }
public void distribute( EntityRef group, Entity activity ) throws Exception { if ( activity == null ) { return; } em.addToCollection( group, "feed", activity ); Results r = em.getCollection( group, "users", null, 10000, Level.REFS, false ); List<EntityRef> refs = r.getRefs(); if ( refs != null ) { em.addToCollections( refs, "feed", activity ); } } }
public int calculatePasswordHistorySizeForUser( UUID userId ) throws Exception { if(logger.isTraceEnabled()){ logger.trace( "calculatePasswordHistorySizeForUser {}", userId.toString() ); } int size = 0; EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); Results orgResults = em.getCollection( new SimpleEntityRef( User.ENTITY_TYPE, userId ), Schema.COLLECTION_GROUPS, null, 10000, Level.REFS, false ); if(logger.isTraceEnabled()){ logger.trace(" orgResults.size() = {}", orgResults.size()); } for ( EntityRef orgRef : orgResults.getRefs() ) { Map<Object, Object> properties = em.getDictionaryAsMap( orgRef, ORGANIZATION_PROPERTIES_DICTIONARY ); if ( properties != null ) { OrganizationInfo orgInfo = new OrganizationInfo( null, null, properties ); if(logger.isTraceEnabled()){ logger.trace( " orgInfo.getPasswordHistorySize() = {}", orgInfo.getPasswordHistorySize() ); } size = Math.max( orgInfo.getPasswordHistorySize(), size ); } } return size; }
break; case REFS: currentPage = results.getRefs(); level = origLevel; break;
public void distribute( EntityRef group, EntityRef user, Entity activity ) throws Exception { if ( activity == null ) { return; } em.addToCollection( user, "feed", activity ); Results r1 = em.getCollection( group, "users", null, 10000, Level.IDS, false ); if ( ( r1 == null ) || ( r1.isEmpty() ) ) { return; } Results r2 = em.getSourceEntities(new SimpleEntityRef(user.getType(), user.getUuid()), "following", User.ENTITY_TYPE, Level.IDS); if ( ( r2 == null ) || ( r2.isEmpty() ) ) { return; } r1.and( r2 ); List<EntityRef> refs = Results.fromIdList( r1.getIds(), User.ENTITY_TYPE ).getRefs(); if ( refs != null ) { em.addToCollections( refs, "feed", activity ); } } }
List<ServiceRequest> nextRequests = context.getNextServiceRequests( r.getRefs() );
@Override public void copyRelationships( String srcRelationName, EntityRef dstEntityRef, String dstRelationName ) throws Exception { headEntity = em.validate( headEntity ); dstEntityRef = em.validate( dstEntityRef ); CollectionInfo srcCollection = getDefaultSchema().getCollection( headEntity.getType(), srcRelationName ); CollectionInfo dstCollection = getDefaultSchema().getCollection( dstEntityRef.getType(), dstRelationName ); Results results = null; do { if ( srcCollection != null ) { results = em.getCollection( headEntity, srcRelationName, null, 5000, Level.REFS, false ); } else { results = em.getTargetEntities( headEntity, srcRelationName, null, Level.REFS ); } if ( ( results != null ) && ( results.size() > 0 ) ) { List<EntityRef> refs = results.getRefs(); for ( EntityRef ref : refs ) { if ( dstCollection != null ) { em.addToCollection( dstEntityRef, dstRelationName, ref ); } else { em.createConnection( dstEntityRef, dstRelationName, ref ); } } } } while ( ( results != null ) && ( results.hasMoreResults() ) ); }
nextRequests = context.getNextServiceRequests( r.getRefs() );