use of org.apache.cayenne.modeler.undo.CreateObjEntityUndoableEdit in project cayenne by apache.
the class CreateObjEntityAction method createObjEntity.
protected void createObjEntity() {
ProjectController mediator = getProjectController();
DataMap dataMap = mediator.getCurrentDataMap();
ObjEntity entity = new ObjEntity();
entity.setName(NameBuilder.builder(entity, dataMap).name());
// init defaults
entity.setSuperClassName(dataMap.getDefaultSuperclass());
entity.setDeclaredLockType(dataMap.getDefaultLockType());
DbEntity dbEntity = mediator.getCurrentDbEntity();
if (dbEntity != null) {
entity.setDbEntity(dbEntity);
// TODO: use injectable name generator
String baseName = new DefaultObjectNameGenerator(NoStemStemmer.getInstance()).objEntityName(dbEntity);
entity.setName(NameBuilder.builder(entity, dbEntity.getDataMap()).baseName(baseName).name());
}
entity.setClassName(dataMap.getNameWithDefaultPackage(entity.getName()));
if (dataMap.isClientSupported()) {
entity.setClientClassName(dataMap.getNameWithDefaultClientPackage(entity.getName()));
entity.setClientSuperClassName(dataMap.getDefaultClientSuperclass());
}
dataMap.addObjEntity(entity);
// TODO: Modeler-controlled defaults for all the hardcoded boolean flags here.
EntityMergeSupport merger = new EntityMergeSupport(new DefaultObjectNameGenerator(NoStemStemmer.getInstance()), NamePatternMatcher.EXCLUDE_ALL, true, true, false);
merger.setNameGenerator(new DbEntitySyncAction.PreserveRelationshipNameGenerator());
merger.addEntityMergeListener(DeleteRuleUpdater.getEntityMergeListener());
merger.synchronizeWithDbEntity(entity);
fireObjEntityEvent(this, mediator, dataMap, entity);
application.getUndoManager().addEdit(new CreateObjEntityUndoableEdit(dataMap, entity));
}
Aggregations