use of org.apache.cayenne.map.event.EntityEvent in project cayenne by apache.
the class PKGeneratorPanel method resetStrategy.
protected void resetStrategy(DbEntity entity, boolean resetCustomSequence, boolean resetDBGenerated) {
boolean hasChanges = false;
if (resetCustomSequence && entity.getPrimaryKeyGenerator() != null) {
entity.setPrimaryKeyGenerator(null);
hasChanges = true;
}
if (resetDBGenerated) {
for (DbAttribute a : entity.getPrimaryKeys()) {
if (a.isGenerated()) {
a.setGenerated(false);
hasChanges = true;
}
}
}
if (hasChanges) {
mediator.fireDbEntityEvent(new EntityEvent(this, entity));
}
}
use of org.apache.cayenne.map.event.EntityEvent 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()));
}
}
}
use of org.apache.cayenne.map.event.EntityEvent in project cayenne by apache.
the class RemoveAction method removeDbEntity.
/**
* Removes current DbEntity from its DataMap and fires "remove" EntityEvent.
*/
public void removeDbEntity(DataMap map, DbEntity ent) {
ProjectController mediator = getProjectController();
EntityEvent e = new EntityEvent(Application.getFrame(), ent, MapEvent.REMOVE);
e.setDomain((DataChannelDescriptor) mediator.getProject().getRootNode());
map.removeDbEntity(ent.getName(), true);
mediator.fireDbEntityEvent(e);
}
use of org.apache.cayenne.map.event.EntityEvent 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.event.EntityEvent in project cayenne by apache.
the class CatalogUpdateController method updateCatalog.
protected void updateCatalog() {
boolean doAll = isAllEntities();
String defaultCatalog = dataMap.getDefaultCatalog();
// set catalog for DbEntities
for (DbEntity entity : dataMap.getDbEntities()) {
if (doAll || Util.isEmptyString(entity.getCatalog())) {
if (!Util.nullSafeEquals(defaultCatalog, entity.getCatalog())) {
entity.setCatalog(defaultCatalog);
// any way to batch events, a big change will flood the app
// with entity events..?
mediator.fireDbEntityEvent(new EntityEvent(this, entity));
}
}
}
// set catalog for procedures...
for (Procedure procedure : dataMap.getProcedures()) {
if (doAll || Util.isEmptyString(procedure.getCatalog())) {
if (!Util.nullSafeEquals(defaultCatalog, procedure.getCatalog())) {
procedure.setCatalog(defaultCatalog);
// any way to batch events, a big change will flood the app
// with procedure events..?
mediator.fireProcedureEvent(new ProcedureEvent(this, procedure));
}
}
}
view.dispose();
}
Aggregations