/** * Called from TaskManager - Creates a persistent receipt * */ private void saveReceipt(EntityRef notification, EntityRef device, Receipt receipt, boolean hasError) throws Exception { boolean debug = false; if(this.notification != null){ debug = this.notification.getDebug(); } if ( debug || hasError) { List<EntityRef> entities = Arrays.asList(notification, device); if (receipt.getUuid() == null) { Receipt savedReceipt = em.create(receipt); em.addToCollections(entities, Notification.RECEIPTS_COLLECTION, savedReceipt); } else { em.addToCollections(entities, Notification.RECEIPTS_COLLECTION, receipt); } if ( logger.isDebugEnabled() ) { logger.debug( "Notification {} receipt saved for device {}", notification.getUuid(), device.getUuid() ); } } }
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 ); } } }
em.addToCollections(refs, "feed", activity); refs.clear(); em.addToCollections(refs, "feed", activity);
em.addToCollections( owners, "test", created );
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 ); } } }