use of org.tmdmaker.core.model.ReusedIdentifier in project tmdmaker by tmdmaker.
the class DetailTreeEditPart method setIdentifiers.
/**
* {@inheritDoc}
*
* @see org.tmdmaker.ui.editor.gef3.treeeditparts.AbstractEntityModelTreeEditPart#setIdentifiers()
*/
@Override
protected void setIdentifiers() {
Detail detail = getModel();
IdentifierRef original = detail.getOriginalReusedIdentifier().getUniqueIdentifiers().get(0);
addOriginalIdentifier(original);
if (detail.isDetailIdentifierEnabled()) {
identifiers.add(detail.getDetailIdentifier());
}
for (ReusedIdentifier r : detail.getReusedIdentifiers().values()) {
for (IdentifierRef i : r.getUniqueIdentifiers()) {
if (!i.isSame(original)) {
identifiers.add(i);
}
}
}
if (identifiers != null && !identifiers.isEmpty()) {
modelChildren.add(identifiers);
}
}
use of org.tmdmaker.core.model.ReusedIdentifier 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.ReusedIdentifier in project tmdmaker by tmdmaker.
the class DdlUtilsConverter method createForeignConstraints.
/**
* 外部キーテーブルを生成する
*
* @param entity
* 対象モデル
* @param table
* 対象テーブル
*/
private ForeignConstraints createForeignConstraints(AbstractEntityModel entity, Table table) {
logger.trace("createForeignConstraints {} {}", entity.getName(), table.getName());
ForeignConstraints foreignConstraints = new ForeignConstraints(table);
for (Map.Entry<AbstractEntityModel, ReusedIdentifier> reusedMap : entity.getReusedIdentifiers().entrySet()) {
AbstractEntityModel foreignEntity = reusedMap.getKey();
ReusedIdentifier reused = reusedMap.getValue();
foreignConstraints.addForeignReference(foreignEntity.getImplementName(), convert(reused), isRecursive(reused));
}
return foreignConstraints;
}
use of org.tmdmaker.core.model.ReusedIdentifier in project tmdmaker by tmdmaker.
the class DetailFigure method setupRelationshipList.
/**
* {@inheritDoc}
*
* @see org.tmdmaker.ui.editor.draw2d.figure.node.AbstractModelFigure#setupRelationshipList(org.tmdmaker.core.model.AbstractEntityModel)
*/
@Override
protected List<String> setupRelationshipList(Detail model) {
List<String> relationshipList = new ArrayList<String>();
IdentifierRef original = model.getOriginalUniqueIdentifierRef();
for (Map.Entry<AbstractEntityModel, ReusedIdentifier> rk : model.getReusedIdentifiers().entrySet()) {
for (IdentifierRef i : rk.getValue().getUniqueIdentifiers()) {
if (!i.isSame(original)) {
relationshipList.add(i.getName());
}
}
}
return relationshipList;
}
use of org.tmdmaker.core.model.ReusedIdentifier in project tmdmaker by tmdmaker.
the class MultivalueAndTest method testDetail.
@Test
public void testDetail() {
Diagram diagram = new Diagram();
Entity e1 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
diagram.addChild(e1);
Entity e2 = Entity.ofResource(new Identifier("テスト2番号")).withDefaultAttribute();
diagram.addChild(e2);
Entity e3 = Entity.ofEvent(new Identifier("テスト3番号")).withDefaultAttribute();
diagram.addChild(e1);
Header2DetailRelationship r1 = new Header2DetailRelationship(e1);
r1.connect();
MultivalueAndSuperset sp = r1.getMultivalueAndSuperset();
assertEquals(true, sp != null);
Detail dtl = (Detail) r1.getTarget();
assertEquals(true, dtl.isDeletable());
assertEquals(e1.getIdentifier(), dtl.getOriginalReusedIdentifier().getIdentifiers().get(0).getOriginal());
assertEquals(false, dtl.isEntityTypeEditable());
AbstractConnectionModel r2 = Relationship.of(dtl, e2);
r2.connect();
assertEquals(false, dtl.isDeletable());
AbstractConnectionModel r3 = Relationship.of(dtl, e3);
r3.connect();
// Detailへの個体指定子変更伝播
e1.setIdentifierName("テスト1番号変更");
Map<AbstractEntityModel, ReusedIdentifier> reused1 = dtl.getReusedIdentifiers();
assertEquals(2, reused1.size());
ReusedIdentifier ri1 = reused1.get(e1);
assertEquals("テスト1番号変更", ri1.getIdentifiers().get(0).getName());
Map<AbstractEntityModel, ReusedIdentifier> reused2 = e3.getReusedIdentifiers();
assertEquals(1, reused2.size());
ReusedIdentifier dri1 = reused2.get(dtl);
assertEquals(2, dri1.getIdentifiers().size());
assertEquals("テスト1番号変更", dri1.getIdentifiers().get(0).getName());
assertEquals("テスト1明細番号", dri1.getIdentifiers().get(1).getName());
// Detailからの個体指定子変更伝播
dtl.setDetailIdentifierName("テスト1明細番号変更");
Map<AbstractEntityModel, ReusedIdentifier> reused3 = e3.getReusedIdentifiers();
assertEquals(1, reused3.size());
ReusedIdentifier dri2 = reused3.get(dtl);
assertEquals(2, dri2.getIdentifiers().size());
assertEquals("テスト1番号変更", dri2.getIdentifiers().get(0).getName());
assertEquals("テスト1明細番号変更", dri2.getIdentifiers().get(1).getName());
dtl.setDetailIdentifier(new Identifier("テスト1明細番号変更2"));
Map<AbstractEntityModel, ReusedIdentifier> reused4 = e3.getReusedIdentifiers();
assertEquals(1, reused4.size());
ReusedIdentifier dri3 = reused4.get(dtl);
assertEquals(2, dri3.getIdentifiers().size());
assertEquals("テスト1番号変更", dri3.getIdentifiers().get(0).getName());
// 伝播しない
assertEquals("テスト1明細番号変更", dri3.getIdentifiers().get(1).getName());
}
Aggregations