Search in sources :

Example 56 with ProjectController

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

the class CreateObjEntityAction method createObjEntity.

protected void createObjEntity() {
    ProjectController mediator = getProjectController();
    DataMap dataMap = mediator.getCurrentDataMap();
    ObjEntity entity = new ObjEntity();
    entity.setName(NameBuilder.builder(entity, dataMap).name());
    // init defaults
    entity.setSuperClassName(dataMap.getDefaultSuperclass());
    entity.setDeclaredLockType(dataMap.getDefaultLockType());
    DbEntity dbEntity = mediator.getCurrentDbEntity();
    if (dbEntity != null) {
        entity.setDbEntity(dbEntity);
        // TODO: use injectable name generator
        String baseName = new DefaultObjectNameGenerator(NoStemStemmer.getInstance()).objEntityName(dbEntity);
        entity.setName(NameBuilder.builder(entity, dbEntity.getDataMap()).baseName(baseName).name());
    }
    entity.setClassName(dataMap.getNameWithDefaultPackage(entity.getName()));
    if (dataMap.isClientSupported()) {
        entity.setClientClassName(dataMap.getNameWithDefaultClientPackage(entity.getName()));
        entity.setClientSuperClassName(dataMap.getDefaultClientSuperclass());
    }
    dataMap.addObjEntity(entity);
    // TODO: Modeler-controlled defaults for all the hardcoded boolean flags here.
    EntityMergeSupport merger = new EntityMergeSupport(new DefaultObjectNameGenerator(NoStemStemmer.getInstance()), NamePatternMatcher.EXCLUDE_ALL, true, true, false);
    merger.setNameGenerator(new DbEntitySyncAction.PreserveRelationshipNameGenerator());
    merger.addEntityMergeListener(DeleteRuleUpdater.getEntityMergeListener());
    merger.synchronizeWithDbEntity(entity);
    fireObjEntityEvent(this, mediator, dataMap, entity);
    application.getUndoManager().addEdit(new CreateObjEntityUndoableEdit(dataMap, entity));
}
Also used : DefaultObjectNameGenerator(org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator) EntityMergeSupport(org.apache.cayenne.dbsync.merge.context.EntityMergeSupport) ObjEntity(org.apache.cayenne.map.ObjEntity) CreateObjEntityUndoableEdit(org.apache.cayenne.modeler.undo.CreateObjEntityUndoableEdit) DbEntity(org.apache.cayenne.map.DbEntity) ProjectController(org.apache.cayenne.modeler.ProjectController) DataMap(org.apache.cayenne.map.DataMap)

Example 57 with ProjectController

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

the class CreateObjEntityAction method createObjEntity.

public void createObjEntity(DataMap dataMap, ObjEntity entity) {
    ProjectController mediator = getProjectController();
    dataMap.addObjEntity(entity);
    fireObjEntityEvent(this, mediator, dataMap, entity);
}
Also used : ProjectController(org.apache.cayenne.modeler.ProjectController)

Example 58 with ProjectController

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

the class CreateProcedureParameterAction method performAction.

/**
 * Creates ProcedureParameter depending on context.
 */
@Override
public void performAction(ActionEvent e) {
    ProjectController mediator = getProjectController();
    if (getProjectController().getCurrentProcedure() != null) {
        Procedure procedure = getProjectController().getCurrentProcedure();
        ProcedureParameter parameter = new ProcedureParameter();
        parameter.setName(NameBuilder.builder(parameter, procedure).name());
        createProcedureParameter(procedure, parameter);
        application.getUndoManager().addEdit(new CreateProcedureParameterUndoableEdit((DataChannelDescriptor) mediator.getProject().getRootNode(), mediator.getCurrentDataMap(), procedure, parameter));
    }
}
Also used : ProcedureParameter(org.apache.cayenne.map.ProcedureParameter) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) Procedure(org.apache.cayenne.map.Procedure) CreateProcedureParameterUndoableEdit(org.apache.cayenne.modeler.undo.CreateProcedureParameterUndoableEdit) ProjectController(org.apache.cayenne.modeler.ProjectController)

Example 59 with ProjectController

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

the class CreateProcedureParameterAction method createProcedureParameter.

public void createProcedureParameter(Procedure procedure, ProcedureParameter parameter) {
    procedure.addCallParameter(parameter);
    ProjectController mediator = getProjectController();
    fireProcedureParameterEvent(this, mediator, procedure, parameter);
}
Also used : ProjectController(org.apache.cayenne.modeler.ProjectController)

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