Search in sources :

Example 1 with QueryDescriptor

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

the class ProcedureQueryView method setQueryComment.

private void setQueryComment(String text) {
    QueryDescriptor query = mediator.getCurrentQuery();
    if (query == null) {
        return;
    }
    ObjectInfo.putToMetaData(mediator.getApplication().getMetaData(), query, ObjectInfo.COMMENT, text);
    mediator.fireQueryEvent(new QueryEvent(this, query));
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) ProcedureQueryDescriptor(org.apache.cayenne.map.ProcedureQueryDescriptor) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent)

Example 2 with QueryDescriptor

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

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

the class ProcedureQueryView method initController.

private void initController() {
    queryRoot.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            QueryDescriptor query = mediator.getCurrentQuery();
            if (query != null) {
                query.setRoot(queryRoot.getModel().getSelectedItem());
                mediator.fireQueryEvent(new QueryEvent(this, query));
            }
        }
    });
    mediator.addQueryDisplayListener(new QueryDisplayListener() {

        public void currentQueryChanged(QueryDisplayEvent e) {
            initFromModel();
        }
    });
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) ProcedureQueryDescriptor(org.apache.cayenne.map.ProcedureQueryDescriptor) QueryDisplayEvent(org.apache.cayenne.modeler.event.QueryDisplayEvent) ActionListener(java.awt.event.ActionListener) QueryDisplayListener(org.apache.cayenne.modeler.event.QueryDisplayListener) ActionEvent(java.awt.event.ActionEvent) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent)

Example 4 with QueryDescriptor

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

the class SelectPropertiesPanel method setQueryProperty.

void setQueryProperty(String property, String value) {
    QueryDescriptor query = getQuery();
    if (query != null) {
        try {
            Object old = query.getProperty(property);
            if (Util.nullSafeEquals(value, old)) {
                return;
            }
            query.setProperty(property, value);
            mediator.fireQueryEvent(new QueryEvent(this, query));
        } catch (Exception ex) {
            logObj.warn("Error setting property: " + property, ex);
        }
    }
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent) ValidationException(org.apache.cayenne.validation.ValidationException)

Example 5 with QueryDescriptor

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

the class SelectQueryOrderingTab method initFromModel.

protected void initFromModel() {
    QueryDescriptor query = mediator.getCurrentQuery();
    if (query == null || !QueryDescriptor.SELECT_QUERY.equals(query.getType())) {
        processInvalidModel("Unknown query.");
        return;
    }
    if (!(query.getRoot() instanceof Entity)) {
        processInvalidModel("SelectQuery has no root set.");
        return;
    }
    this.selectQuery = (SelectQueryDescriptor) query;
    browser.setModel(createBrowserModel((Entity) selectQuery.getRoot()));
    table.setModel(createTableModel());
    // init column sizes
    table.getColumnModel().getColumn(0).setPreferredWidth(250);
    cardLayout.show(this, REAL_PANEL);
}
Also used : SelectQueryDescriptor(org.apache.cayenne.map.SelectQueryDescriptor) QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) Entity(org.apache.cayenne.map.Entity)

Aggregations

QueryDescriptor (org.apache.cayenne.map.QueryDescriptor)37 DataMap (org.apache.cayenne.map.DataMap)16 QueryEvent (org.apache.cayenne.configuration.event.QueryEvent)12 ObjEntity (org.apache.cayenne.map.ObjEntity)9 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)8 DbEntity (org.apache.cayenne.map.DbEntity)7 Embeddable (org.apache.cayenne.map.Embeddable)6 Procedure (org.apache.cayenne.map.Procedure)6 ProcedureQueryDescriptor (org.apache.cayenne.map.ProcedureQueryDescriptor)6 SelectQueryDescriptor (org.apache.cayenne.map.SelectQueryDescriptor)6 Entity (org.apache.cayenne.map.Entity)5 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)4 QueryDisplayEvent (org.apache.cayenne.modeler.event.QueryDisplayEvent)4 ValidationException (org.apache.cayenne.validation.ValidationException)4 DbAttribute (org.apache.cayenne.map.DbAttribute)3 DbRelationship (org.apache.cayenne.map.DbRelationship)3 EmbeddableAttribute (org.apache.cayenne.map.EmbeddableAttribute)3 ObjAttribute (org.apache.cayenne.map.ObjAttribute)3 ObjRelationship (org.apache.cayenne.map.ObjRelationship)3 ProjectController (org.apache.cayenne.modeler.ProjectController)3