use of org.tmdmaker.core.model.SurrogateKey in project tmdmaker by tmdmaker.
the class ImplementRule method findAllImplementAttributes.
/**
* モデルの実装対象アトリビュートを取得する
*
* @param model
* 対象モデル
* @return アトリビュートのリスト
*/
public static List<IAttribute> findAllImplementAttributes(AbstractEntityModel model) {
List<IAttribute> attributes = new ArrayList<IAttribute>();
SurrogateKey surrogateKey = model.getKeyModels().getSurrogateKey();
if (surrogateKey.isEnabled()) {
attributes.add(surrogateKey);
}
// 個体指定子を追加
addIdentifier(model, attributes);
// re-usedを追加
Map<AbstractEntityModel, ReusedIdentifier> reused = model.getReusedIdentifiers();
for (Entry<AbstractEntityModel, ReusedIdentifier> entry : reused.entrySet()) {
ReusedIdentifier ri = entry.getValue();
if (ri == null) {
continue;
}
if (ri.isSurrogateKeyEnabled()) {
for (SurrogateKeyRef s : ri.getSurrogateKeys()) {
attributes.add(s);
}
} else {
for (IdentifierRef ref : ri.getUniqueIdentifiers()) {
attributes.add(ref);
}
}
}
// モデルのアトリビュートを追加
attributes.addAll(model.getAttributes());
// 派生元に戻して実装するモデルのアトリビュートを追加
for (AbstractEntityModel m : model.getImplementDerivationModels()) {
attributes.addAll(m.getAttributes());
}
return attributes;
}
use of org.tmdmaker.core.model.SurrogateKey in project tmdmaker by tmdmaker.
the class EditImplementEntity method addSurrogateKey.
private void addSurrogateKey(AbstractEntityModel model) {
KeyModels originalKeyModels = model.getKeyModels();
if (originalKeyModels == null) {
return;
}
originalKeyModels.copyTo(keyModels);
SurrogateKey key = originalKeyModels.getSurrogateKey();
surrogateKey = new EditSurrogateKey(model, key);
if (surrogateKey.isEnabled()) {
attributes.add(surrogateKey);
}
}
use of org.tmdmaker.core.model.SurrogateKey in project tmdmaker by tmdmaker.
the class ImplementInfoEditAction method run.
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
ImplementInfoEditDialog dialog = new ImplementInfoEditDialog(getPart().getViewer().getControl().getShell(), getModel());
if (dialog.open() == Dialog.OK) {
CompoundCommand ccommand = new CompoundCommand();
ccommand.add(new ModelEditCommand(getModel(), dialog.getEditedValueEntity()));
for (EditImplementAttribute ea : dialog.getEditedValueAttributes()) {
IAttribute original = ea.getOriginalAttribute();
IAttribute newAttribute = original.getCopy();
ea.copyTo(newAttribute);
ccommand.add(new AttributeEditCommand(original, newAttribute, ea.getContainerModel()));
}
SurrogateKey newSurrogateKey = new SurrogateKey();
EditSurrogateKey edited = dialog.getEditedSurrogateKey();
edited.copyTo(newSurrogateKey);
ImplementRule.setSurrogateKeyDefaultValue(newSurrogateKey);
SurrogateKey original = (SurrogateKey) edited.getOriginalAttribute();
ccommand.add(new AttributeEditCommand(original, newSurrogateKey, edited.getContainerModel()));
execute(ccommand);
}
}
Aggregations