public void on(org.apache.isis.applib.services.eventbus.CollectionDomainEvent<?,?> ev) { recordEvent(ev); switch (ev.getEventPhase()) { case HIDE: if(getSubscriberBehaviour() == DemoBehaviour.DEPENDENCIES_COLLECTION_HIDE && ev.getIdentifier().getMemberName().equals("dependencies")) { ev.veto(""); ev.getIdentifier().getMemberName().equals("similarTo")) { ev.veto(""); ev.getIdentifier().getMemberName().equals("dependencies")) { ev.veto("ToDoItemSubscriptions says: dependencies collection disabled!"); ev.getIdentifier().getMemberName().equals("dependencies") && ev.getOf() == CollectionDomainEvent.Of.ADD_TO ) { ev.veto("ToDoItemSubscriptions says: can't add this object to dependencies collection!"); ev.getIdentifier().getMemberName().equals("dependencies") && ev.getOf() == CollectionDomainEvent.Of.REMOVE_FROM ) { ev.veto("ToDoItemSubscriptions says: can't remove this object from dependencies collection!"); break; case EXECUTED: if(ev.getOf() == CollectionDomainEvent.Of.ADD_TO) { LOG.info("Received CollectionDomainEvent, " + ev.getSource().toString() + ", added to " + ev.getIdentifier().getMemberName() + " : " + ev.getValue()); } else { LOG.info("Received CollectionDomainEvent, " + ev.getSource().toString() + ", removed from " + ev.getIdentifier().getMemberName() + " : " + ev.getValue());
@Test public void collectionAddedToDefaultEventType() throws Exception { final SomeDomainObject sdo = new SomeDomainObject(); final SomeReferencedObject other = new SomeReferencedObject(); final Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "references"); final CollectionDomainEvent<Object, Object> ev = new DomainEventHelper(null).newCollectionDomainEvent( CollectionAddedToEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, CollectionDomainEvent.Of.ADD_TO, other); assertThat(ev.getSource(), is((Object)sdo)); assertThat(ev.getIdentifier(), is(identifier)); assertThat(ev.getOf(), is(CollectionDomainEvent.Of.ADD_TO)); assertThat(ev.getValue(), is((Object)other)); }
@Test public void defaultEventType() throws Exception { final SomeDomainObject sdo = new SomeDomainObject(); final SomeReferencedObject other = new SomeReferencedObject(); final Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "references"); final CollectionDomainEvent<Object, Object> ev = new DomainEventHelper(null).newCollectionDomainEvent( CollectionDomainEvent.Default.class, null, identifier, sdo, CollectionDomainEvent.Of.ADD_TO, other); assertThat(ev.getSource(), is((Object)sdo)); assertThat(ev.getIdentifier(), is(identifier)); assertThat(ev.getOf(), is(CollectionDomainEvent.Of.ADD_TO)); assertThat(ev.getValue(), is((Object)other)); }
@Test public void customEventType() throws Exception { final SomeDomainObject sdo = new SomeDomainObject(); final SomeReferencedObject other = new SomeReferencedObject(); final Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "references"); final CollectionDomainEvent<SomeDomainObject, SomeReferencedObject> ev = new DomainEventHelper(null).newCollectionDomainEvent( SomeDomainObjectCollectionDomainEvent.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, CollectionDomainEvent.Of.ADD_TO, other); assertThat(ev.getSource(), is(sdo)); assertThat(ev.getIdentifier(), is(identifier)); assertThat(ev.getOf(), is(CollectionDomainEvent.Of.ADD_TO)); assertThat(ev.getValue(), is(other)); }
@Test public void defaultEventType() throws Exception { SomeDomainObject sdo = new SomeDomainObject(); SomeReferencedObject other = new SomeReferencedObject(); Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "references"); final CollectionDomainEvent<Object, Object> ev = new DomainEventHelper(null).newCollectionDomainEvent( CollectionRemovedFromEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, CollectionDomainEvent.Of.REMOVE_FROM, other); assertThat(ev.getSource(), is((Object)sdo)); assertThat(ev.getIdentifier(), is(identifier)); assertThat(ev.getOf(), is(CollectionDomainEvent.Of.REMOVE_FROM)); assertThat(ev.getValue(), is((Object)other)); }
@Test public void collectionRemovedFromDefaultEventType() throws Exception { SomeDomainObject sdo = new SomeDomainObject(); SomeReferencedObject other = new SomeReferencedObject(); Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "references"); final CollectionDomainEvent<Object, Object> ev = new DomainEventHelper(null).newCollectionDomainEvent( CollectionRemovedFromEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, CollectionDomainEvent.Of.REMOVE_FROM, other); assertThat(ev.getSource(), is((Object)sdo)); assertThat(ev.getIdentifier(), is(identifier)); assertThat(ev.getOf(), is(CollectionDomainEvent.Of.REMOVE_FROM)); assertThat(ev.getValue(), is((Object)other)); }
@Test public void customEventType() throws Exception { SomeDomainObject sdo = new SomeDomainObject(); SomeReferencedObject other = new SomeReferencedObject(); Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "references"); final CollectionDomainEvent<SomeDomainObject, SomeReferencedObject> ev = new DomainEventHelper(null).newCollectionDomainEvent( SomeDomainObjectCollectionRemovedFromDomainEvent.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, CollectionDomainEvent.Of.REMOVE_FROM, other); assertThat(ev.getSource(), is(sdo)); assertThat(ev.getIdentifier(), is(identifier)); assertThat(ev.getOf(), is(CollectionDomainEvent.Of.REMOVE_FROM)); assertThat(ev.getValue(), is(other)); }