Search in sources :

Example 6 with Procedure

use of org.apache.cayenne.map.Procedure in project cayenne by apache.

the class ProcedureParameterErrorMsg method displayField.

public void displayField(ProjectController mediator, JFrame frame) {
    Object object = super.validationFailure.getSource();
    DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode();
    ProcedureParameter procedureParameter = (ProcedureParameter) object;
    Procedure procedure = procedureParameter.getProcedure();
    DataMap map = procedure.getDataMap();
    // Race condition between the two events...?
    // first display the stored procedure
    // for whatever reason, other validators do not require this step
    // (E.g. DbAttributeErrorMsg)
    ProcedureDisplayEvent procedureEvent = new ProcedureDisplayEvent(frame, procedure, map, domain);
    procedureEvent.setTabReset(true);
    mediator.fireProcedureDisplayEvent(procedureEvent);
    // now show the failed parameter
    ProcedureParameterDisplayEvent event = new ProcedureParameterDisplayEvent(frame, procedureParameter, procedure, map, domain);
    event.setTabReset(true);
    mediator.fireProcedureParameterDisplayEvent(event);
}
Also used : ProcedureParameter(org.apache.cayenne.map.ProcedureParameter) ProcedureDisplayEvent(org.apache.cayenne.modeler.event.ProcedureDisplayEvent) ProcedureParameterDisplayEvent(org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) Procedure(org.apache.cayenne.map.Procedure) DataMap(org.apache.cayenne.map.DataMap)

Example 7 with Procedure

use of org.apache.cayenne.map.Procedure in project cayenne by apache.

the class ProjectTreeView method procedureAdded.

public void procedureAdded(ProcedureEvent e) {
    DefaultMutableTreeNode node = getProjectModel().getNodeForObjectPath(new Object[] { mediator.getProject().getRootNode(), e.getProcedure().getDataMap() });
    if (node == null) {
        return;
    }
    Procedure procedure = e.getProcedure();
    DefaultMutableTreeNode currentNode = new DefaultMutableTreeNode(procedure, false);
    positionNode(node, currentNode, Comparators.getDataMapChildrenComparator());
    showNode(currentNode);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Procedure(org.apache.cayenne.map.Procedure)

Example 8 with Procedure

use of org.apache.cayenne.map.Procedure 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 9 with Procedure

use of org.apache.cayenne.map.Procedure in project cayenne by apache.

the class RemoveAction method removeLastPathComponent.

/**
 * Removes an object, depending on its type
 */
private UndoableEdit removeLastPathComponent(ConfigurationNode object, ConfigurationNode parentObject) {
    UndoableEdit undo = null;
    if (object instanceof DataMap) {
        if (parentObject != null && parentObject instanceof DataNodeDescriptor) {
            undo = new RemoveUndoableEdit(application, (DataNodeDescriptor) parentObject, (DataMap) object);
            removeDataMapFromDataNode((DataNodeDescriptor) parentObject, (DataMap) object);
        } else {
            // Not under Data Node, remove completely
            undo = new RemoveUndoableEdit(application, (DataMap) object);
            removeDataMap((DataMap) object);
        }
    } else if (object instanceof DataNodeDescriptor) {
        undo = new RemoveUndoableEdit(application, (DataNodeDescriptor) object);
        removeDataNode((DataNodeDescriptor) object);
    } else if (object instanceof DbEntity) {
        undo = new RemoveUndoableEdit(((DbEntity) object).getDataMap(), (DbEntity) object);
        removeDbEntity(((DbEntity) object).getDataMap(), (DbEntity) object);
    } else if (object instanceof ObjEntity) {
        undo = new RemoveUndoableEdit(((ObjEntity) object).getDataMap(), (ObjEntity) object);
        removeObjEntity(((ObjEntity) object).getDataMap(), (ObjEntity) object);
    } else if (object instanceof QueryDescriptor) {
        undo = new RemoveUndoableEdit(((QueryDescriptor) object).getDataMap(), (QueryDescriptor) object);
        removeQuery(((QueryDescriptor) object).getDataMap(), (QueryDescriptor) object);
    } else if (object instanceof Procedure) {
        undo = new RemoveUndoableEdit(((Procedure) object).getDataMap(), (Procedure) object);
        removeProcedure(((Procedure) object).getDataMap(), (Procedure) object);
    } else if (object instanceof Embeddable) {
        undo = new RemoveUndoableEdit(((Embeddable) object).getDataMap(), (Embeddable) object);
        removeEmbeddable(((Embeddable) object).getDataMap(), (Embeddable) object);
    }
    return undo;
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) ObjEntity(org.apache.cayenne.map.ObjEntity) DbEntity(org.apache.cayenne.map.DbEntity) RemoveAttributeUndoableEdit(org.apache.cayenne.modeler.undo.RemoveAttributeUndoableEdit) RemoveCallbackMethodUndoableEdit(org.apache.cayenne.modeler.undo.RemoveCallbackMethodUndoableEdit) UndoableEdit(javax.swing.undo.UndoableEdit) RemoveRelationshipUndoableEdit(org.apache.cayenne.modeler.undo.RemoveRelationshipUndoableEdit) RemoveUndoableEdit(org.apache.cayenne.modeler.undo.RemoveUndoableEdit) RemoveCompoundUndoableEdit(org.apache.cayenne.modeler.undo.RemoveCompoundUndoableEdit) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) Procedure(org.apache.cayenne.map.Procedure) RemoveUndoableEdit(org.apache.cayenne.modeler.undo.RemoveUndoableEdit) DataMap(org.apache.cayenne.map.DataMap) Embeddable(org.apache.cayenne.map.Embeddable)

Example 10 with Procedure

use of org.apache.cayenne.map.Procedure in project cayenne by apache.

the class CatalogUpdateController method updateCatalog.

protected void updateCatalog() {
    boolean doAll = isAllEntities();
    String defaultCatalog = dataMap.getDefaultCatalog();
    // set catalog for DbEntities
    for (DbEntity entity : dataMap.getDbEntities()) {
        if (doAll || Util.isEmptyString(entity.getCatalog())) {
            if (!Util.nullSafeEquals(defaultCatalog, entity.getCatalog())) {
                entity.setCatalog(defaultCatalog);
                // any way to batch events, a big change will flood the app
                // with entity events..?
                mediator.fireDbEntityEvent(new EntityEvent(this, entity));
            }
        }
    }
    // set catalog for procedures...
    for (Procedure procedure : dataMap.getProcedures()) {
        if (doAll || Util.isEmptyString(procedure.getCatalog())) {
            if (!Util.nullSafeEquals(defaultCatalog, procedure.getCatalog())) {
                procedure.setCatalog(defaultCatalog);
                // any way to batch events, a big change will flood the app
                // with procedure events..?
                mediator.fireProcedureEvent(new ProcedureEvent(this, procedure));
            }
        }
    }
    view.dispose();
}
Also used : DbEntity(org.apache.cayenne.map.DbEntity) EntityEvent(org.apache.cayenne.map.event.EntityEvent) ProcedureEvent(org.apache.cayenne.configuration.event.ProcedureEvent) Procedure(org.apache.cayenne.map.Procedure)

Aggregations

Procedure (org.apache.cayenne.map.Procedure)38 DataMap (org.apache.cayenne.map.DataMap)14 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)8 DbEntity (org.apache.cayenne.map.DbEntity)7 ProcedureParameter (org.apache.cayenne.map.ProcedureParameter)7 ProcedureEvent (org.apache.cayenne.configuration.event.ProcedureEvent)6 QueryDescriptor (org.apache.cayenne.map.QueryDescriptor)6 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)5 Embeddable (org.apache.cayenne.map.Embeddable)5 ObjEntity (org.apache.cayenne.map.ObjEntity)5 ProcedureDisplayEvent (org.apache.cayenne.modeler.event.ProcedureDisplayEvent)5 Test (org.junit.Test)4 ProjectController (org.apache.cayenne.modeler.ProjectController)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 DataRow (org.apache.cayenne.DataRow)2 DataNode (org.apache.cayenne.access.DataNode)2 PatternFilter (org.apache.cayenne.dbsync.reverse.filters.PatternFilter)2 DbAttribute (org.apache.cayenne.map.DbAttribute)2 DbRelationship (org.apache.cayenne.map.DbRelationship)2 EmbeddableAttribute (org.apache.cayenne.map.EmbeddableAttribute)2