use of org.apache.cayenne.map.QueryDescriptor in project cayenne by apache.
the class QueryType method createQuery.
/**
* Action method that creates a query for the specified query type.
*/
public void createQuery() {
String queryType = getSelectedQuery();
// update query...
QueryDescriptor query = QueryDescriptor.descriptor(queryType);
query.setName(NameBuilder.builder(query, dataMap).name());
query.setDataMap(dataMap);
dataMap.addQueryDescriptor(query);
mediator.getApplication().getUndoManager().addEdit(new CreateQueryUndoableEdit(domain, dataMap, query));
// notify listeners
fireQueryEvent(this, mediator, dataMap, query);
view.dispose();
}
use of org.apache.cayenne.map.QueryDescriptor 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);
}
use of org.apache.cayenne.map.QueryDescriptor in project cayenne by apache.
the class EjbqlQueryMainTab 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.EJBQL_QUERY.equals(query.getType())) {
setVisible(false);
return;
}
name.setText(query.getName());
comment.setText(getQueryComment(query));
properties.initFromModel(query);
setVisible(true);
}
use of org.apache.cayenne.map.QueryDescriptor in project cayenne by apache.
the class EjbqlQueryMainTab method setQueryName.
/**
* Initializes Query name from string.
*/
void setQueryName(String newName) {
if (newName != null && newName.trim().length() == 0) {
newName = null;
}
QueryDescriptor query = getQuery();
if (query == null) {
return;
}
if (Util.nullSafeEquals(newName, query.getName())) {
return;
}
if (newName == null) {
throw new ValidationException("Query name is required.");
}
DataMap map = mediator.getCurrentDataMap();
if (map.getQueryDescriptor(newName) == null) {
// completely new name, set new name for entity
QueryEvent e = new QueryEvent(this, query, query.getName());
ProjectUtil.setQueryName(map, query, newName);
mediator.fireQueryEvent(e);
} else {
// there is a query with the same name
throw new ValidationException("There is another query named '" + newName + "'. Use a different name.");
}
}
use of org.apache.cayenne.map.QueryDescriptor in project cayenne by apache.
the class EjbqlQueryScriptsTab method initFromModel.
public void initFromModel() {
QueryDescriptor query = mediator.getCurrentQuery();
if (query == null || !QueryDescriptor.EJBQL_QUERY.equals(query.getType())) {
setVisible(false);
return;
}
scriptArea.setEnabled(true);
displayScript();
validateEJBQL();
setVisible(true);
}
Aggregations