use of org.apache.cayenne.map.ObjEntity in project cayenne by apache.
the class TranslateExpressionIT method testCompQualifier.
@Test
public void testCompQualifier() {
ObjEntity entity = context.getEntityResolver().getObjEntity("Painting");
Expression expression = ExpressionFactory.pathExp("toArtist.artistExhibitArray.toExhibit");
Expression translatedExpression = entity.translateToRelatedEntity(expression, "toGallery");
assertEquals(ExpressionFactory.dbPathExp("paintingArray.toArtist.artistExhibitArray.toExhibit"), translatedExpression);
}
use of org.apache.cayenne.map.ObjEntity in project cayenne by apache.
the class TranslateExpressionIT method testCompQualifierAndPref.
@Test
public void testCompQualifierAndPref() {
ObjEntity entity = context.getEntityResolver().getObjEntity("Artist");
Expression expression = ExpressionFactory.pathExp("paintingArray.toGallery");
Expression translatedExpression = entity.translateToRelatedEntity(expression, "artistExhibitArray.toExhibit");
assertEquals(ExpressionFactory.dbPathExp("artistExhibitArray.toArtist.paintingArray.toGallery"), translatedExpression);
}
use of org.apache.cayenne.map.ObjEntity in project cayenne by apache.
the class TranslateExpressionIT method testRelationshipPathEqualsToInput.
@Test
public void testRelationshipPathEqualsToInput() {
ObjEntity entity = context.getEntityResolver().getObjEntity("Painting");
Expression expression = ExpressionFactory.pathExp("toArtist");
Expression translatedExpression = entity.translateToRelatedEntity(expression, "toArtist");
assertEquals(ExpressionFactory.dbPathExp("paintingArray.toArtist"), translatedExpression);
}
use of org.apache.cayenne.map.ObjEntity 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.ObjEntity in project cayenne by apache.
the class ObjEntitySyncAction method syncObjEntity.
protected void syncObjEntity() {
ProjectController mediator = getProjectController();
ObjEntity entity = mediator.getCurrentObjEntity();
if (entity != null && entity.getDbEntity() != null) {
EntityMergeSupport merger = new EntitySyncController(Application.getInstance().getFrameController(), entity).createMerger();
if (merger == null) {
return;
}
merger.setNameGenerator(new DbEntitySyncAction.PreserveRelationshipNameGenerator());
if (merger.synchronizeWithDbEntity(entity)) {
mediator.fireObjEntityEvent(new EntityEvent(this, entity, MapEvent.CHANGE));
mediator.fireObjEntityDisplayEvent(new EntityDisplayEvent(this, entity, entity.getDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode()));
}
}
}
Aggregations