use of org.apache.cayenne.map.QueryDescriptor in project cayenne by apache.
the class FindAction method jumpToResult.
/**
* Navigate to search result
* Used also in {@link org.apache.cayenne.modeler.graph.action.EntityDisplayAction}
*/
public static void jumpToResult(FindAction.SearchResultEntry searchResultEntry) {
EditorView editor = ((CayenneModelerFrame) Application.getInstance().getFrameController().getView()).getView();
DataChannelDescriptor domain = (DataChannelDescriptor) Application.getInstance().getProject().getRootNode();
if (searchResultEntry.getObject() instanceof Entity) {
jumpToEntityResult((Entity) searchResultEntry.getObject(), editor, domain);
} else if (searchResultEntry.getObject() instanceof QueryDescriptor) {
jumpToQueryResult((QueryDescriptor) searchResultEntry.getObject(), editor, domain);
} else if (searchResultEntry.getObject() instanceof Embeddable) {
jumpToEmbeddableResult((Embeddable) searchResultEntry.getObject(), editor, domain);
} else if (searchResultEntry.getObject() instanceof EmbeddableAttribute) {
jumpToEmbeddableAttributeResult((EmbeddableAttribute) searchResultEntry.getObject(), editor, domain);
} else if (searchResultEntry.getObject() instanceof Attribute || searchResultEntry.getObject() instanceof Relationship) {
jumpToAttributeResult(searchResultEntry, editor, domain);
}
}
use of org.apache.cayenne.map.QueryDescriptor 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;
}
use of org.apache.cayenne.map.QueryDescriptor in project cayenne by apache.
the class RemoveAction method removeObjEntity.
/**
* Removes current object entity from its DataMap.
*/
public void removeObjEntity(DataMap map, ObjEntity entity) {
ProjectController mediator = getProjectController();
EntityEvent e = new EntityEvent(Application.getFrame(), entity, MapEvent.REMOVE);
e.setDomain((DataChannelDescriptor) mediator.getProject().getRootNode());
map.removeObjEntity(entity.getName(), true);
mediator.fireObjEntityEvent(e);
// clone to be able to remove within iterator...
for (QueryDescriptor query : new ArrayList<>(map.getQueryDescriptors())) {
if (!QueryDescriptor.EJBQL_QUERY.equals(query.getType())) {
Object root = query.getRoot();
if (root == entity || (root instanceof String && root.toString().equals(entity.getName()))) {
removeQuery(map, query);
}
}
}
}
use of org.apache.cayenne.map.QueryDescriptor in project cayenne by apache.
the class MappedSelect method createReplacementQuery.
@Override
protected Query createReplacementQuery(EntityResolver resolver) {
QueryDescriptor descriptor = resolver.getQueryDescriptor(queryName);
Query query = super.createReplacementQuery(resolver);
QueryCacheStrategy cacheStrategyOverride = null;
if (forceNoCache) {
QueryCacheStrategy cacheStrategy = query.getMetaData(resolver).getCacheStrategy();
if (QueryCacheStrategy.LOCAL_CACHE == cacheStrategy) {
cacheStrategyOverride = QueryCacheStrategy.LOCAL_CACHE_REFRESH;
} else if (QueryCacheStrategy.SHARED_CACHE == cacheStrategy) {
cacheStrategyOverride = QueryCacheStrategy.SHARED_CACHE_REFRESH;
}
}
switch(descriptor.getType()) {
case QueryDescriptor.SELECT_QUERY:
SelectQuery selectQuery = (SelectQuery) query;
if (fetchLimit != null) {
selectQuery.setFetchLimit(fetchLimit);
}
if (fetchOffset != null) {
selectQuery.setFetchOffset(fetchOffset);
}
if (statementFetchSize != null) {
selectQuery.setStatementFetchSize(statementFetchSize);
}
if (pageSize != null) {
selectQuery.setPageSize(pageSize);
}
if (cacheStrategyOverride != null) {
selectQuery.setCacheStrategy(cacheStrategyOverride);
}
break;
case QueryDescriptor.SQL_TEMPLATE:
SQLTemplate sqlTemplate = (SQLTemplate) query;
if (fetchLimit != null) {
sqlTemplate.setFetchLimit(fetchLimit);
}
if (fetchOffset != null) {
sqlTemplate.setFetchOffset(fetchOffset);
}
if (statementFetchSize != null) {
sqlTemplate.setStatementFetchSize(statementFetchSize);
}
if (pageSize != null) {
sqlTemplate.setPageSize(pageSize);
}
if (cacheStrategyOverride != null) {
sqlTemplate.setCacheStrategy(cacheStrategyOverride);
}
break;
case QueryDescriptor.EJBQL_QUERY:
EJBQLQuery ejbqlQuery = (EJBQLQuery) query;
if (fetchLimit != null) {
ejbqlQuery.setFetchLimit(fetchLimit);
}
if (fetchOffset != null) {
ejbqlQuery.setFetchOffset(fetchOffset);
}
if (statementFetchSize != null) {
ejbqlQuery.setStatementFetchSize(statementFetchSize);
}
if (pageSize != null) {
ejbqlQuery.setPageSize(pageSize);
}
if (cacheStrategyOverride != null) {
ejbqlQuery.setCacheStrategy(cacheStrategyOverride);
}
break;
case QueryDescriptor.PROCEDURE_QUERY:
ProcedureQuery procedureQuery = (ProcedureQuery) query;
if (fetchLimit != null) {
procedureQuery.setFetchLimit(fetchLimit);
}
if (fetchOffset != null) {
procedureQuery.setFetchOffset(fetchOffset);
}
if (statementFetchSize != null) {
procedureQuery.setStatementFetchSize(statementFetchSize);
}
if (pageSize != null) {
procedureQuery.setPageSize(pageSize);
}
if (cacheStrategyOverride != null) {
procedureQuery.setCacheStrategy(cacheStrategyOverride);
}
break;
default:
throw new CayenneRuntimeException("Unknown query type: %s", descriptor.getType());
}
return query;
}
use of org.apache.cayenne.map.QueryDescriptor in project cayenne by apache.
the class QueryDisplayEventType method fireLastDisplayEvent.
@Override
public void fireLastDisplayEvent() {
DataChannelDescriptor dataChannel = (DataChannelDescriptor) controller.getProject().getRootNode();
if (!dataChannel.getName().equals(preferences.getDomain())) {
return;
}
DataMap dataMap = dataChannel.getDataMap(preferences.getDataMap());
if (dataMap == null) {
return;
}
QueryDescriptor query = dataMap.getQueryDescriptor(preferences.getQuery());
if (query == null) {
return;
}
QueryDisplayEvent queryDisplayEvent = new QueryDisplayEvent(this, query, dataMap, dataChannel);
controller.fireQueryDisplayEvent(queryDisplayEvent);
}
Aggregations