Search in sources :

Example 56 with DataNodeDescriptor

use of org.apache.cayenne.configuration.DataNodeDescriptor in project cayenne by apache.

the class EntityDisplayEventType method fireLastDisplayEvent.

@Override
public void fireLastDisplayEvent() {
    DataChannelDescriptor dataChannel = (DataChannelDescriptor) controller.getProject().getRootNode();
    if (!dataChannel.getName().equals(preferences.getDomain())) {
        return;
    }
    DataNodeDescriptor dataNode = dataChannel.getNodeDescriptor(preferences.getNode());
    DataMap dataMap = dataChannel.getDataMap(preferences.getDataMap());
    if (dataMap == null) {
        return;
    }
    Entity entity = getLastEntity(dataMap);
    if (entity == null) {
        return;
    }
    EntityDisplayEvent entityDisplayEvent = new EntityDisplayEvent(this, entity, dataMap, dataNode, dataChannel);
    if (entity instanceof ObjEntity) {
        controller.fireObjEntityDisplayEvent(entityDisplayEvent);
    } else if (entity instanceof DbEntity) {
        controller.fireDbEntityDisplayEvent(entityDisplayEvent);
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) DbEntity(org.apache.cayenne.map.DbEntity) Entity(org.apache.cayenne.map.Entity) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) ObjEntity(org.apache.cayenne.map.ObjEntity) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) DbEntity(org.apache.cayenne.map.DbEntity) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) DataMap(org.apache.cayenne.map.DataMap)

Example 57 with DataNodeDescriptor

use of org.apache.cayenne.configuration.DataNodeDescriptor in project cayenne by apache.

the class RelationshipDisplayEventType method fireLastDisplayEvent.

@Override
public void fireLastDisplayEvent() {
    DataChannelDescriptor dataChannel = (DataChannelDescriptor) controller.getProject().getRootNode();
    if (!dataChannel.getName().equals(preferences.getDomain())) {
        return;
    }
    DataNodeDescriptor dataNode = dataChannel.getNodeDescriptor(preferences.getNode());
    DataMap dataMap = dataChannel.getDataMap(preferences.getDataMap());
    if (dataMap == null) {
        return;
    }
    Entity entity = getLastEntity(dataMap);
    if (entity == null) {
        return;
    }
    Relationship[] relationships = getLastEntityRelationships(entity);
    EntityDisplayEvent entityDisplayEvent = new EntityDisplayEvent(this, entity, dataMap, dataNode, dataChannel);
    RelationshipDisplayEvent displayEvent = new RelationshipDisplayEvent(this, relationships, entity, dataMap, dataChannel);
    if (entity instanceof ObjEntity) {
        controller.fireObjEntityDisplayEvent(entityDisplayEvent);
        controller.fireObjRelationshipDisplayEvent(displayEvent);
    } else if (entity instanceof DbEntity) {
        controller.fireDbEntityDisplayEvent(entityDisplayEvent);
        controller.fireDbRelationshipDisplayEvent(displayEvent);
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) DbEntity(org.apache.cayenne.map.DbEntity) Entity(org.apache.cayenne.map.Entity) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) ObjEntity(org.apache.cayenne.map.ObjEntity) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) DbEntity(org.apache.cayenne.map.DbEntity) Relationship(org.apache.cayenne.map.Relationship) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) DataMap(org.apache.cayenne.map.DataMap) RelationshipDisplayEvent(org.apache.cayenne.modeler.event.RelationshipDisplayEvent)

Example 58 with DataNodeDescriptor

use of org.apache.cayenne.configuration.DataNodeDescriptor in project cayenne by apache.

the class DataNodeEventTest method testNameChange.

@Test
public void testNameChange() throws Exception {
    MapEvent event = new DataNodeEvent(new Object(), new DataNodeDescriptor("someName"), "someOldName");
    assertEquals("someName", event.getNewName());
    assertTrue(event.isNameChange());
}
Also used : MapEvent(org.apache.cayenne.map.event.MapEvent) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) Test(org.junit.Test)

Aggregations

DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)58 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)28 DataMap (org.apache.cayenne.map.DataMap)23 Test (org.junit.Test)22 DbEntity (org.apache.cayenne.map.DbEntity)11 ArrayList (java.util.ArrayList)8 Injector (org.apache.cayenne.di.Injector)8 Constants (org.apache.cayenne.configuration.Constants)7 RuntimeProperties (org.apache.cayenne.configuration.RuntimeProperties)7 DbAdapter (org.apache.cayenne.dba.DbAdapter)7 AdhocObjectFactory (org.apache.cayenne.di.AdhocObjectFactory)7 ClassLoaderManager (org.apache.cayenne.di.ClassLoaderManager)7 DIBootstrap (org.apache.cayenne.di.DIBootstrap)7 Key (org.apache.cayenne.di.Key)7 Module (org.apache.cayenne.di.Module)7 DefaultAdhocObjectFactory (org.apache.cayenne.di.spi.DefaultAdhocObjectFactory)7 DefaultClassLoaderManager (org.apache.cayenne.di.spi.DefaultClassLoaderManager)7 JdbcEventLogger (org.apache.cayenne.log.JdbcEventLogger)7 Slf4jJdbcEventLogger (org.apache.cayenne.log.Slf4jJdbcEventLogger)7 ObjEntity (org.apache.cayenne.map.ObjEntity)7