Search in sources :

Example 1 with ReusedIdentifier

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);
    }
}
Also used : ReusedIdentifier(org.tmdmaker.core.model.ReusedIdentifier) Detail(org.tmdmaker.core.model.Detail) IdentifierRef(org.tmdmaker.core.model.IdentifierRef)

Example 2 with ReusedIdentifier

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;
}
Also used : ReusedIdentifier(org.tmdmaker.core.model.ReusedIdentifier) SurrogateKeyRef(org.tmdmaker.core.model.SurrogateKeyRef) IAttribute(org.tmdmaker.core.model.IAttribute) ArrayList(java.util.ArrayList) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) SurrogateKey(org.tmdmaker.core.model.SurrogateKey) IdentifierRef(org.tmdmaker.core.model.IdentifierRef)

Example 3 with ReusedIdentifier

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;
}
Also used : ReusedIdentifier(org.tmdmaker.core.model.ReusedIdentifier) HashMap(java.util.HashMap) Map(java.util.Map) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel)

Example 4 with ReusedIdentifier

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;
}
Also used : ReusedIdentifier(org.tmdmaker.core.model.ReusedIdentifier) ArrayList(java.util.ArrayList) Map(java.util.Map) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) IdentifierRef(org.tmdmaker.core.model.IdentifierRef)

Example 5 with ReusedIdentifier

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());
}
Also used : ReusedIdentifier(org.tmdmaker.core.model.ReusedIdentifier) Entity(org.tmdmaker.core.model.Entity) ReusedIdentifier(org.tmdmaker.core.model.ReusedIdentifier) Identifier(org.tmdmaker.core.model.Identifier) MultivalueAndSuperset(org.tmdmaker.core.model.MultivalueAndSuperset) Header2DetailRelationship(org.tmdmaker.core.model.Header2DetailRelationship) Detail(org.tmdmaker.core.model.Detail) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) Diagram(org.tmdmaker.core.model.Diagram) AbstractConnectionModel(org.tmdmaker.core.model.AbstractConnectionModel) Test(org.junit.Test)

Aggregations

ReusedIdentifier (org.tmdmaker.core.model.ReusedIdentifier)5 AbstractEntityModel (org.tmdmaker.core.model.AbstractEntityModel)4 IdentifierRef (org.tmdmaker.core.model.IdentifierRef)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Detail (org.tmdmaker.core.model.Detail)2 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 AbstractConnectionModel (org.tmdmaker.core.model.AbstractConnectionModel)1 Diagram (org.tmdmaker.core.model.Diagram)1 Entity (org.tmdmaker.core.model.Entity)1 Header2DetailRelationship (org.tmdmaker.core.model.Header2DetailRelationship)1 IAttribute (org.tmdmaker.core.model.IAttribute)1 Identifier (org.tmdmaker.core.model.Identifier)1 MultivalueAndSuperset (org.tmdmaker.core.model.MultivalueAndSuperset)1 SurrogateKey (org.tmdmaker.core.model.SurrogateKey)1 SurrogateKeyRef (org.tmdmaker.core.model.SurrogateKeyRef)1