Search in sources :

Example 31 with DataMap

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

the class ProcedureQueryView method initFromModel.

/**
 * Updates the view from the current model state. Invoked when a currently displayed
 * query is changed.
 */
void initFromModel() {
    QueryDescriptor query = mediator.getCurrentQuery();
    if (query == null || !QueryDescriptor.PROCEDURE_QUERY.equals(query.getType())) {
        setVisible(false);
        return;
    }
    properties.setEnabled(true);
    name.setText(query.getName());
    comment.setText(getQueryComment(query));
    // init root choices and title label..
    // - ProcedureQuery supports Procedure roots
    // TODO: now we only allow roots from the current map,
    // since query root is fully resolved during map loading,
    // making it impossible to reference other DataMaps.
    DataMap map = mediator.getCurrentDataMap();
    Procedure[] roots = map.getProcedures().toArray(new Procedure[0]);
    if (roots.length > 1) {
        Arrays.sort(roots, Comparators.getDataMapChildrenComparator());
    }
    DefaultComboBoxModel<Procedure> model = new DefaultComboBoxModel<>(roots);
    model.setSelectedItem(query.getRoot());
    queryRoot.setModel(model);
    properties.initFromModel(query);
    setVisible(true);
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) ProcedureQueryDescriptor(org.apache.cayenne.map.ProcedureQueryDescriptor) Procedure(org.apache.cayenne.map.Procedure) DataMap(org.apache.cayenne.map.DataMap)

Example 32 with DataMap

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

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

the class QueryErrorMsg method displayField.

public void displayField(ProjectController mediator, JFrame frame) {
    Object object = super.validationFailure.getSource();
    DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode();
    QueryDescriptor query = (QueryDescriptor) object;
    DataMap map = query.getDataMap();
    QueryDisplayEvent event = new QueryDisplayEvent(frame, query, map, domain);
    mediator.fireQueryDisplayEvent(event);
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) QueryDisplayEvent(org.apache.cayenne.modeler.event.QueryDisplayEvent) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) DataMap(org.apache.cayenne.map.DataMap)

Example 34 with DataMap

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

the class DataMapView method setClientSupport.

void setClientSupport(boolean flag) {
    DataMap dataMap = eventController.getCurrentDataMap();
    if (dataMap == null) {
        return;
    }
    if (dataMap.isClientSupported() != flag) {
        dataMap.setClientSupported(flag);
        toggleClientProperties(flag);
        eventController.fireDataMapEvent(new DataMapEvent(this, dataMap));
    }
}
Also used : DataMapEvent(org.apache.cayenne.configuration.event.DataMapEvent) DataMap(org.apache.cayenne.map.DataMap)

Example 35 with DataMap

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

the class DataMapView method setDefaultSchema.

void setDefaultSchema(String newSchema) {
    DataMap dataMap = eventController.getCurrentDataMap();
    if (dataMap == null) {
        return;
    }
    if (newSchema != null && newSchema.trim().length() == 0) {
        newSchema = null;
    }
    String oldSchema = dataMap.getDefaultSchema();
    if (Util.nullSafeEquals(newSchema, oldSchema)) {
        return;
    }
    dataMap.setDefaultSchema(newSchema);
    eventController.fireDataMapEvent(new DataMapEvent(this, dataMap));
}
Also used : DataMapEvent(org.apache.cayenne.configuration.event.DataMapEvent) DataMap(org.apache.cayenne.map.DataMap)

Aggregations

DataMap (org.apache.cayenne.map.DataMap)233 Test (org.junit.Test)88 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)48 DbEntity (org.apache.cayenne.map.DbEntity)48 ObjEntity (org.apache.cayenne.map.ObjEntity)45 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)22 URL (java.net.URL)21 URLResource (org.apache.cayenne.resource.URLResource)20 ArrayList (java.util.ArrayList)19 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)19 MergerToken (org.apache.cayenne.dbsync.merge.token.MergerToken)17 QueryDescriptor (org.apache.cayenne.map.QueryDescriptor)16 DataMapEvent (org.apache.cayenne.configuration.event.DataMapEvent)15 File (java.io.File)14 Procedure (org.apache.cayenne.map.Procedure)14 Embeddable (org.apache.cayenne.map.Embeddable)13 Injector (org.apache.cayenne.di.Injector)12 DbAttribute (org.apache.cayenne.map.DbAttribute)11 EntityResolver (org.apache.cayenne.map.EntityResolver)11 Entity (org.apache.cayenne.map.Entity)10