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);
}
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));
}
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);
}
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);
}
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);
}
}
Aggregations