Transaction operation is required when editing models in astah* API. Please see the Transaction operation.
Sample: Edit class name and its definition
try { TransactionManager.beginTransaction(); BasicModelEditor bme = ModelEditorFactory.getBasicModelEditor(); // Create a class IClass class0 = bme.createClass(project, "class0"); // Set name class0.setName("new class name"); // Set definition class0.setDefinition("Definition of the class"); TransactionManager.endTransaction(); } catch (InvalidEditingException e) { TransactionManager.abortTransaction(); } |
Sample: Edit physical name of ER entity (professional only)
IERModel erModel = (IERModel) getElement(project.getOwnedElements(), "ER_Model"); schema = erModel.getSchemata()[0]; IEREntity[] entities = schema.getEntities(); for (int i = 0; i < entities.length; i++) { if ("Entity0".equals(entities[i].getName())) { try { TransactionManager.beginTransaction(); // Set physical name entities[i].setPhysicalName("entity0 physical name"); TransactionManager.endTransaction(); } catch (InvalidEditingException e) { TransactionManager.abortTransaction(); } } |