Search in sources :

Example 21 with QueryDescriptor

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

the class ProcedureQueryView method setEntity.

void setEntity(ObjEntity entity) {
    QueryDescriptor query = mediator.getCurrentQuery();
    if (query != null && QueryDescriptor.PROCEDURE_QUERY.equals(query.getType())) {
        ((ProcedureQueryDescriptor) query).setResultEntityName(entity != null ? entity.getName() : null);
        mediator.fireQueryEvent(new QueryEvent(this, query));
    }
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) ProcedureQueryDescriptor(org.apache.cayenne.map.ProcedureQueryDescriptor) ProcedureQueryDescriptor(org.apache.cayenne.map.ProcedureQueryDescriptor) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent)

Example 22 with QueryDescriptor

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

the class RootSelectionHandler method actionPerformed.

public void actionPerformed(ActionEvent ae) {
    QueryDescriptor query = queryTab.getQuery();
    if (query != null) {
        Entity root = (Entity) queryTab.getQueryRoot().getModel().getSelectedItem();
        if (root != null) {
            query.setRoot(root);
            if (needChangeName) {
                // not changed by user
                /*
                     * Doing auto name change, following CAY-888 #2
                     */
                String newPrefix = root.getName() + "Query";
                newName = newPrefix;
                DataMap map = queryTab.getMediator().getCurrentDataMap();
                long postfix = 1;
                while (map.getQueryDescriptor(newName) != null) {
                    newName = newPrefix + (postfix++);
                }
                queryTab.getNameField().setText(newName);
            }
        }
    }
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) Entity(org.apache.cayenne.map.Entity) DataMap(org.apache.cayenne.map.DataMap)

Example 23 with QueryDescriptor

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

the class RootSelectionHandler method focusGained.

public void focusGained(FocusEvent e) {
    // reset new name tracking
    newName = null;
    QueryDescriptor query = queryTab.getQuery();
    if (query != null) {
        needChangeName = hasDefaultName(query);
    } else {
        needChangeName = false;
    }
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor)

Example 24 with QueryDescriptor

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

the class SQLTemplateMainTab method setQueryComment.

private void setQueryComment(String text) {
    QueryDescriptor query = getQuery();
    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) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent)

Example 25 with QueryDescriptor

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

the class SQLTemplateMainTab method setEntity.

void setEntity(ObjEntity entity) {
    QueryDescriptor template = getQuery();
    if (template != null) {
        // in case of null entity, set root to DataMap
        Object root = entity != null ? entity : mediator.getCurrentDataMap();
        template.setRoot(root);
        mediator.fireQueryEvent(new QueryEvent(this, template));
    }
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent)

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