use of org.apache.cayenne.map.Relationship in project cayenne by apache.
the class EJBQLPathTranslator method resolveJoin.
protected void resolveJoin() {
EJBQLJoinAppender joinAppender = context.getTranslatorFactory().getJoinAppender(context);
String newPath = idPath + '.' + lastPathComponent;
String oldPath = joinAppender.registerReusableJoin(idPath, lastPathComponent, newPath);
this.fullPath = fullPath + '.' + lastPathComponent;
if (oldPath != null) {
this.idPath = oldPath;
Relationship lastRelationship = currentEntity.getRelationship(lastPathComponent);
if (lastRelationship != null) {
ObjEntity targetEntity = (ObjEntity) lastRelationship.getTargetEntity();
this.lastAlias = context.getTableAlias(fullPath, context.getQuotingStrategy().quotedFullyQualifiedName(targetEntity.getDbEntity()));
} else {
String tableName = context.getQuotingStrategy().quotedFullyQualifiedName(currentEntity.getDbEntity());
this.lastAlias = context.getTableAlias(oldPath, tableName);
}
} else {
Relationship lastRelationship = currentEntity.getRelationship(lastPathComponent);
ObjEntity targetEntity = null;
if (lastRelationship != null) {
targetEntity = (ObjEntity) lastRelationship.getTargetEntity();
} else {
targetEntity = currentEntity;
}
// register join
if (innerJoin) {
joinAppender.appendInnerJoin(joinMarker, new EJBQLTableId(idPath), new EJBQLTableId(fullPath));
} else {
joinAppender.appendOuterJoin(joinMarker, new EJBQLTableId(idPath), new EJBQLTableId(fullPath));
}
this.lastAlias = context.getTableAlias(fullPath, context.getQuotingStrategy().quotedFullyQualifiedName(targetEntity.getDbEntity()));
this.idPath = newPath;
}
}
use of org.apache.cayenne.map.Relationship in project cayenne by apache.
the class ManyToManyCandidateEntityTest method testOptimisationForManyToManyEntity.
@Test
public void testOptimisationForManyToManyEntity() {
ObjEntity manyToManyEntity = map.getObjEntity("Table1Table2");
ManyToManyCandidateEntity.build(manyToManyEntity).optimizeRelationships(new DefaultObjectNameGenerator(NoStemStemmer.getInstance()));
ObjEntity table1Entity = map.getObjEntity("Table1");
ObjEntity table2Entity = map.getObjEntity("Table2");
assertEquals(1, table1Entity.getRelationships().size());
assertEquals(table2Entity, new ArrayList<Relationship>(table1Entity.getRelationships()).get(0).getTargetEntity());
assertEquals(1, table2Entity.getRelationships().size());
assertEquals(table1Entity, new ArrayList<Relationship>(table2Entity.getRelationships()).get(0).getTargetEntity());
}
use of org.apache.cayenne.map.Relationship in project cayenne by apache.
the class SQLTemplatePrefetchTab method createBrowserModel.
protected TreeModel createBrowserModel(Entity entity) {
EntityTreeModel treeModel = new EntityTreeModel(entity);
treeModel.setFilter(new EntityTreeFilter() {
public boolean attributeMatch(Object node, Attribute attr) {
return false;
}
public boolean relationshipMatch(Object node, Relationship rel) {
return true;
}
});
return treeModel;
}
use of org.apache.cayenne.map.Relationship in project cayenne by apache.
the class SelectQueryPrefetchTab method createBrowserModel.
protected TreeModel createBrowserModel(Entity entity) {
EntityTreeModel treeModel = new EntityTreeModel(entity);
treeModel.setFilter(new EntityTreeFilter() {
public boolean attributeMatch(Object node, Attribute attr) {
return false;
}
public boolean relationshipMatch(Object node, Relationship rel) {
return true;
}
});
return treeModel;
}
use of org.apache.cayenne.map.Relationship in project cayenne by apache.
the class BaseGraphBuilder method createRelationshipCell.
protected DefaultEdge createRelationshipCell(Relationship rel) {
if (!relCells.containsKey(getQualifiedName(rel))) {
Relationship reverse = rel.getReverseRelationship();
DefaultEdge edge = new DefaultEdge();
// GraphConstants.setLineStyle(edge.getAttributes(),
// GraphConstants.STYLE_ORTHOGONAL);
// GraphConstants.setRouting(edge.getAttributes(),
// GraphConstants.ROUTING_SIMPLE);
GraphConstants.setEditable(edge.getAttributes(), false);
GraphConstants.setLabelAlongEdge(edge.getAttributes(), true);
GraphConstants.setSelectable(edge.getAttributes(), false);
GraphConstants.setFont(edge.getAttributes(), EDGE_FONT);
updateRelationshipLabels(edge, rel, reverse);
relCells.put(getQualifiedName(rel), edge);
if (reverse != null) {
relCells.put(getQualifiedName(reverse), edge);
}
return edge;
}
return null;
}
Aggregations