Search in sources :

Example 11 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class CreateProcedureAction method createProcedure.

public void createProcedure(DataMap map, Procedure procedure) {
    ProjectController mediator = getProjectController();
    procedure.setSchema(map.getDefaultSchema());
    procedure.setCatalog(map.getDefaultCatalog());
    map.addProcedure(procedure);
    fireProcedureEvent(this, mediator, map, procedure);
}
Also used : ProjectController(org.apache.cayenne.modeler.ProjectController)

Example 12 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class CreateProcedureAction method performAction.

public void performAction(ActionEvent e) {
    ProjectController mediator = getProjectController();
    DataMap map = mediator.getCurrentDataMap();
    Procedure procedure = new Procedure();
    procedure.setName(NameBuilder.builder(procedure, map).name());
    createProcedure(map, procedure);
    application.getUndoManager().addEdit(new CreateProcedureUndoableEdit(map, procedure));
}
Also used : Procedure(org.apache.cayenne.map.Procedure) ProjectController(org.apache.cayenne.modeler.ProjectController) CreateProcedureUndoableEdit(org.apache.cayenne.modeler.undo.CreateProcedureUndoableEdit) DataMap(org.apache.cayenne.map.DataMap)

Example 13 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class CreateRelationshipAction method createObjRelationship.

public void createObjRelationship(ObjEntity objEntity, ObjRelationship rel) {
    ProjectController mediator = getProjectController();
    rel.setSourceEntity(objEntity);
    DeleteRuleUpdater.updateObjRelationship(rel);
    objEntity.addRelationship(rel);
    fireObjRelationshipEvent(this, mediator, objEntity, rel);
}
Also used : ProjectController(org.apache.cayenne.modeler.ProjectController)

Example 14 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class CreateRelationshipAction method createDbRelationship.

public void createDbRelationship(DbEntity dbEntity, DbRelationship rel) {
    ProjectController mediator = getProjectController();
    rel.setSourceEntity(dbEntity);
    dbEntity.addRelationship(rel);
    fireDbRelationshipEvent(this, mediator, dbEntity, rel);
}
Also used : ProjectController(org.apache.cayenne.modeler.ProjectController)

Example 15 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class DbEntitySyncAction method syncDbEntity.

protected void syncDbEntity() {
    ProjectController mediator = getProjectController();
    DbEntity dbEntity = mediator.getCurrentDbEntity();
    if (dbEntity != null) {
        Collection<ObjEntity> entities = dbEntity.getDataMap().getMappedEntities(dbEntity);
        if (entities.isEmpty()) {
            return;
        }
        EntityMergeSupport merger = new EntitySyncController(Application.getInstance().getFrameController(), dbEntity).createMerger();
        if (merger == null) {
            return;
        }
        merger.setNameGenerator(new PreserveRelationshipNameGenerator());
        DbEntitySyncUndoableEdit undoableEdit = new DbEntitySyncUndoableEdit((DataChannelDescriptor) mediator.getProject().getRootNode(), mediator.getCurrentDataMap());
        // filter out inherited entities, as we need to add attributes only to the roots
        filterInheritedEntities(entities);
        for (ObjEntity entity : entities) {
            DbEntitySyncUndoableEdit.EntitySyncUndoableListener listener = undoableEdit.new EntitySyncUndoableListener(entity);
            merger.addEntityMergeListener(listener);
            // we should not be trying to introspect the merger
            if (merger.isRemovingMeaningfulFKs()) {
                undoableEdit.addEdit(undoableEdit.new MeaningfulFKsUndoableEdit(entity, merger.getMeaningfulFKs(entity)));
            }
            if (merger.synchronizeWithDbEntity(entity)) {
                mediator.fireObjEntityEvent(new EntityEvent(this, entity, MapEvent.CHANGE));
            }
            merger.removeEntityMergeListener(listener);
        }
        application.getUndoManager().addEdit(undoableEdit);
    }
}
Also used : EntityMergeSupport(org.apache.cayenne.dbsync.merge.context.EntityMergeSupport) ObjEntity(org.apache.cayenne.map.ObjEntity) DbEntity(org.apache.cayenne.map.DbEntity) EntityEvent(org.apache.cayenne.map.event.EntityEvent) DbEntitySyncUndoableEdit(org.apache.cayenne.modeler.undo.DbEntitySyncUndoableEdit) ProjectController(org.apache.cayenne.modeler.ProjectController) EntitySyncController(org.apache.cayenne.modeler.dialog.objentity.EntitySyncController)

Aggregations

ProjectController (org.apache.cayenne.modeler.ProjectController)59 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)12 ObjEntity (org.apache.cayenne.map.ObjEntity)10 DbEntity (org.apache.cayenne.map.DbEntity)8 DataMap (org.apache.cayenne.map.DataMap)7 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)6 EntityEvent (org.apache.cayenne.map.event.EntityEvent)6 DataNodeEvent (org.apache.cayenne.configuration.event.DataNodeEvent)5 ObjAttribute (org.apache.cayenne.map.ObjAttribute)5 ProcedureParameter (org.apache.cayenne.map.ProcedureParameter)5 ArrayList (java.util.ArrayList)4 DbAttribute (org.apache.cayenne.map.DbAttribute)4 DbRelationship (org.apache.cayenne.map.DbRelationship)4 Embeddable (org.apache.cayenne.map.Embeddable)4 EmbeddableAttribute (org.apache.cayenne.map.EmbeddableAttribute)4 ObjRelationship (org.apache.cayenne.map.ObjRelationship)4 RelationshipEvent (org.apache.cayenne.map.event.RelationshipEvent)4 ComponentAdapter (java.awt.event.ComponentAdapter)3 ComponentEvent (java.awt.event.ComponentEvent)3 EntityMergeSupport (org.apache.cayenne.dbsync.merge.context.EntityMergeSupport)3