use of org.apache.cayenne.map.Relationship 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.Relationship in project cayenne by apache.
the class FindAction method jumpToAttributeResult.
private static void jumpToAttributeResult(SearchResultEntry searchResultEntry, EditorView editor, DataChannelDescriptor domain) {
DataMap map;
Entity entity;
if (searchResultEntry.getObject() instanceof Attribute) {
map = ((Attribute) searchResultEntry.getObject()).getEntity().getDataMap();
entity = ((Attribute) searchResultEntry.getObject()).getEntity();
} else {
map = ((Relationship) searchResultEntry.getObject()).getSourceEntity().getDataMap();
entity = ((Relationship) searchResultEntry.getObject()).getSourceEntity();
}
buildAndSelectTreePath(map, entity, editor);
if (searchResultEntry.getObject() instanceof Attribute) {
AttributeDisplayEvent event = new AttributeDisplayEvent(editor.getProjectTreeView(), (Attribute) searchResultEntry.getObject(), entity, map, domain);
event.setMainTabFocus(true);
if (searchResultEntry.getObject() instanceof DbAttribute) {
editor.getDbDetailView().currentDbAttributeChanged(event);
} else {
editor.getObjDetailView().currentObjAttributeChanged(event);
}
} else if (searchResultEntry.getObject() instanceof Relationship) {
RelationshipDisplayEvent event = new RelationshipDisplayEvent(editor.getProjectTreeView(), (Relationship) searchResultEntry.getObject(), entity, map, domain);
event.setMainTabFocus(true);
if (searchResultEntry.getObject() instanceof DbRelationship) {
editor.getDbDetailView().currentDbRelationshipChanged(event);
} else {
editor.getObjDetailView().currentObjRelationshipChanged(event);
}
}
}
use of org.apache.cayenne.map.Relationship in project cayenne by apache.
the class ObjRelationshipInfo method valueChanged.
/**
* Sets list of DB Relationships current ObjRelationship is mapped to
*/
public void valueChanged(TreeSelectionEvent e) {
TreePath selectedPath = e.getPath();
// at least two elements to constitute a valid ordering path
if (selectedPath == null || selectedPath.getPathCount() < 2) {
return;
}
Relationship rel = (Relationship) selectedPath.getLastPathComponent();
DbEntity target = (DbEntity) rel.getTargetEntity();
/**
* Initialize root with one of mapped ObjEntities.
*/
Collection<ObjEntity> objEntities = target.getDataMap().getMappedEntities(target);
List<DbRelationship> relPath = new Vector<DbRelationship>(selectedPath.getPathCount() - 1);
for (int i = 1; i < selectedPath.getPathCount(); i++) {
relPath.add((DbRelationship) selectedPath.getPathComponent(i));
}
setDbRelationships(relPath);
updateCollectionChoosers();
}
use of org.apache.cayenne.map.Relationship in project cayenne by apache.
the class ManyToManyCandidateEntityTest method setUp.
@Before
public void setUp() throws Exception {
Module testModule = binder -> {
binder.bind(ClassLoaderManager.class).to(DefaultClassLoaderManager.class);
binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
binder.bind(DataMapLoader.class).to(XMLDataMapLoader.class);
binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);
binder.bind(HandlerFactory.class).to(DefaultHandlerFactory.class);
binder.bind(DataChannelMetaData.class).to(NoopDataChannelMetaData.class);
binder.bind(XMLReader.class).toProviderInstance(new XMLReaderProvider(false)).withoutScope();
};
Injector injector = DIBootstrap.createInjector(testModule);
// create and initialize loader instance to test
XMLDataChannelDescriptorLoader loader = new XMLDataChannelDescriptorLoader();
injector.injectMembers(loader);
String testConfigName = "relationship-optimisation";
URL url = getClass().getResource("cayenne-" + testConfigName + ".xml");
ConfigurationTree<DataChannelDescriptor> tree = loader.load(new URLResource(url));
map = tree.getRootNode().getDataMap(testConfigName);
}
use of org.apache.cayenne.map.Relationship in project cayenne by apache.
the class EJBQLDbPathTranslator method resolveJoin.
private void resolveJoin(boolean inner) {
EJBQLJoinAppender joinAppender = context.getTranslatorFactory().getJoinAppender(context);
// TODO: andrus 1/6/2007 - conflict with object path naming... maybe
// 'registerReusableJoin' should normalize everything to a db path?
String newPath = idPath + '.' + lastPathComponent;
String oldPath = joinAppender.registerReusableJoin(idPath, lastPathComponent, newPath);
this.fullPath = fullPath + '.' + lastPathComponent;
if (oldPath != null) {
this.idPath = oldPath;
this.lastAlias = context.getTableAlias(oldPath, context.getQuotingStrategy().quotedFullyQualifiedName(currentEntity));
} else {
// register join
if (inner) {
joinAppender.appendInnerJoin(joinMarker, new EJBQLTableId(idPath), new EJBQLTableId(fullPath));
this.lastAlias = context.getTableAlias(fullPath, context.getQuotingStrategy().quotedFullyQualifiedName(currentEntity));
} else {
joinAppender.appendOuterJoin(joinMarker, new EJBQLTableId(idPath), new EJBQLTableId(fullPath));
Relationship lastRelationship = currentEntity.getRelationship(lastPathComponent);
DbEntity targetEntity = (DbEntity) lastRelationship.getTargetEntity();
this.lastAlias = context.getTableAlias(fullPath, context.getQuotingStrategy().quotedFullyQualifiedName(targetEntity));
}
this.idPath = newPath;
}
}
Aggregations