Search in sources :

Example 1 with Identifier

use of org.tmdmaker.core.model.Identifier in project tmdmaker by tmdmaker.

the class TMDEditorOutlineTreePartFactory method createEditPart.

/**
 * @param context
 *            コンテキスト
 * @param model
 *            TMのモデル
 * @return EditPart modelに対応したEditPart
 */
@Override
public final EditPart createEditPart(final EditPart context, final Object model) {
    EditPart part = null;
    if (model instanceof ModelElement) {
        ModelElement element = (ModelElement) model;
        TMDOutlineTreeEditPartVisitor visitor = new TMDOutlineTreeEditPartVisitor();
        element.accept(visitor);
        return visitor.getEditPart();
    } else if (model instanceof KeyModel) {
        logger.debug("KeyModel用の EditPart を返しました");
        logger.debug(((KeyModel) model).getName());
        part = new KeyModelTreeEditPart();
    } else if (model instanceof List<?>) {
        logger.debug("フォルダー用EditPartを準備します。");
        List<?> list = (List<?>) model;
        if (list.size() > 0) {
            if (list.get(0) instanceof Identifier) {
                logger.debug("個体指定子のフォルダー用EditPartを返しました。");
                part = new FolderTreeEditPart<Identifier>(Messages.Identifier);
            } else if (list.get(0) instanceof Attribute) {
                logger.debug("属性のフォルダー用EditPartを返しました。");
                part = new FolderTreeEditPart<Attribute>(Messages.Attribute);
            } else if (list.get(0) instanceof KeyModel) {
                logger.debug("キーのフォルダー用EditPartを返しました。");
                part = new FolderTreeEditPart<KeyModel>(Messages.KeyDefinitions);
            }
        }
    }
    if (part != null) {
        part.setModel(model);
    }
    return part;
}
Also used : ModelElement(org.tmdmaker.core.model.ModelElement) KeyModel(org.tmdmaker.core.model.KeyModel) Identifier(org.tmdmaker.core.model.Identifier) Attribute(org.tmdmaker.core.model.Attribute) EditPart(org.eclipse.gef.EditPart) List(java.util.List)

Example 2 with Identifier

use of org.tmdmaker.core.model.Identifier in project tmdmaker by tmdmaker.

the class EditPartFactoryTest method setUp.

/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    diagram = new Diagram();
    e1 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
    diagram.addChild(e1);
    e2 = Entity.ofEvent(new Identifier("テスト2番号")).withDefaultAttribute();
    diagram.addChild(e2);
    r1 = Entity.ofResource(new Identifier("テスト1No")).withDefaultAttribute();
    diagram.addChild(r1);
    r2 = Entity.ofResource(new Identifier("テスト2No")).withDefaultAttribute();
    diagram.addChild(r2);
    factory = new TMDEditPartFactory();
    // subsetType = new SubsetType();
    // subsetType.setExceptNull(false);
    // subsetType.setSubsetType(SubsetTypeValue.SAME);
    // diagram.addChild(subsetType);
    List<AbstractEntityModel> list = new ArrayList<AbstractEntityModel>();
    list.add(e1);
    list.add(e2);
    vsp = VirtualSuperset.of(new ModelName("スーパーセット"));
    vsp.virtualSubsets().builder().subsetList(list).build();
    vtype = vsp.getVirtualSupersetType();
}
Also used : Identifier(org.tmdmaker.core.model.Identifier) ModelName(org.tmdmaker.core.model.parts.ModelName) ArrayList(java.util.ArrayList) TMDEditPartFactory(org.tmdmaker.ui.editor.gef3.editparts.TMDEditPartFactory) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) Diagram(org.tmdmaker.core.model.Diagram) Before(org.junit.Before)

Example 3 with Identifier

use of org.tmdmaker.core.model.Identifier in project tmdmaker by tmdmaker.

the class EditPartFactoryTest method testCreateEditPart.

/**
 * Test method for
 * {@link org.tmdmaker.ui.editor.gef3.editparts.TMDEditPartFactory#createEditPart(org.eclipse.gef.EditPart, java.lang.Object)}
 * .
 */
@Test
public void testCreateEditPart() {
    Object o = new Attribute();
    EditPart editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(AttributeEditPart.class));
    AbstractRelationship r = Relationship.of(r1, r2);
    r.connect();
    o = r.getTable();
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(CombinationTableEditPart.class));
    Entity res1 = Entity.ofResource(new Identifier("リソース番号"));
    Entity ev1 = Entity.ofEvent(new Identifier("イベント番号"));
    AbstractRelationship rel = Relationship.of(res1, ev1);
    rel.connect();
    rel.setSourceCardinality(Cardinality.MANY);
    rel.setTargetCardinality(Cardinality.MANY);
    ev1.multivalueAnd().builder().build();
    o = ev1.multivalueAnd().detail();
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(DetailEditPart.class));
    o = new Diagram();
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(DiagramEditPart.class));
    o = Entity.ofResource(new ModelName("個体"), new Identifier("番号"));
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(EntityEditPart.class));
    o = Laputa.of();
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(LaputaEditPart.class));
    o = new MappingList();
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(MappingListEditPart.class));
    o = ev1.multivalueAnd().superset();
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(MultivalueAndSupersetEditPart.class));
    Entity ev2 = Entity.ofEvent(new Identifier("イベント番号"));
    ev2.multivalueOr().builder().typeName("テスト種別").build();
    o = ev2.multivalueOr().query().findByName(new ModelName("イベント.テスト種別")).get(0);
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(MultivalueOrEditPart.class));
    o = new RecursiveTable();
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(RecursiveTableEditPart.class));
    Entity e = Entity.ofResource(new Identifier("親ID"));
    e.subsets().builder().add(new ModelName("サブセット")).build();
    o = e.subsets().query().findByName(new ModelName("サブセット")).get(0);
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(SubsetEntityEditPart.class));
    ModelName searchName = new ModelName("みなし");
    e.virtualEntities().builder().virtualEntityName(searchName).build();
    o = e.virtualEntities().query().findByName(searchName).get(0);
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(VirtualEntityEditPart.class));
    o = VirtualSuperset.of(new ModelName("スーパーセット"));
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(VirtualSupersetEditPart.class));
    o = new RecursiveRelationship(e1);
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(RecursiveRelationshipEditPart.class));
    o = new Event2EventRelationship(e1, e2);
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(RelationshipEditPart.class));
    Entity2SubsetTypeRelationship r1 = new Entity2SubsetTypeRelationship(e1);
    r1.connect();
    editPart = factory.createEditPart(null, r1);
    assertThat(editPart, instanceOf(Entity2SubsetTypeRelationshipEditPart.class));
    o = (Entity2VirtualSupersetTypeRelationship) vtype.getModelTargetConnections().get(0);
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(RelatedRelationshipEditPart.class));
    o = ev1.multivalueAnd().aggregator();
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(MultivalueAndAggregatorEditPart.class));
    o = new RelatedRelationship(e1, e2);
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(RelatedRelationshipEditPart.class));
    Entity2SubsetTypeRelationship r2 = new Entity2SubsetTypeRelationship(null);
    editPart = factory.createEditPart(null, r2.getSubsetType());
    assertThat(editPart, instanceOf(SubsetTypeEditPart.class));
    o = vtype;
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, instanceOf(VirtualSupersetTypeEditPart.class));
    o = new ModelElement();
    editPart = factory.createEditPart(null, o);
    assertThat(editPart, nullValue());
// TODO 必要になったらaccept(IVisitor)メソッドをIdentifierRefでoverrideする
// o = new IdentifierRef(e1.getIdentifier());
// editPart = factory.createEditPart(null, o);
// assertThat(editPart, nullValue());
// TODO 必要になったらaccept(IVisitor)メソッドをIdentifierでoverrideする
// Identifier i = e1.getIdentifier();
// editPart = factory.createEditPart(null, i);
// assertThat(editPart, nullValue());
}
Also used : RecursiveRelationshipEditPart(org.tmdmaker.ui.editor.gef3.editparts.relationship.RecursiveRelationshipEditPart) Entity(org.tmdmaker.core.model.Entity) LaputaEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.LaputaEditPart) MultivalueOrEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.MultivalueOrEditPart) RecursiveRelationship(org.tmdmaker.core.model.RecursiveRelationship) Attribute(org.tmdmaker.core.model.Attribute) Entity2SubsetTypeRelationship(org.tmdmaker.core.model.Entity2SubsetTypeRelationship) VirtualSupersetTypeEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.VirtualSupersetTypeEditPart) SubsetEntityEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.SubsetEntityEditPart) ModelElement(org.tmdmaker.core.model.ModelElement) RecursiveTableEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.RecursiveTableEditPart) Identifier(org.tmdmaker.core.model.Identifier) Event2EventRelationship(org.tmdmaker.core.model.Event2EventRelationship) RecursiveTable(org.tmdmaker.core.model.RecursiveTable) EntityEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.EntityEditPart) SubsetEntityEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.SubsetEntityEditPart) VirtualEntityEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.VirtualEntityEditPart) MultivalueAndAggregatorEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.MultivalueAndAggregatorEditPart) SubsetTypeEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.SubsetTypeEditPart) MultivalueAndSupersetEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.MultivalueAndSupersetEditPart) VirtualEntityEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.VirtualEntityEditPart) MappingListEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.MappingListEditPart) ModelName(org.tmdmaker.core.model.parts.ModelName) AbstractRelationship(org.tmdmaker.core.model.AbstractRelationship) DetailEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.DetailEditPart) DiagramEditPart(org.tmdmaker.ui.editor.gef3.editparts.DiagramEditPart) MultivalueOrEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.MultivalueOrEditPart) MultivalueAndAggregatorEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.MultivalueAndAggregatorEditPart) RelationshipEditPart(org.tmdmaker.ui.editor.gef3.editparts.relationship.RelationshipEditPart) Entity2SubsetTypeRelationshipEditPart(org.tmdmaker.ui.editor.gef3.editparts.relationship.Entity2SubsetTypeRelationshipEditPart) AttributeEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.AttributeEditPart) RecursiveRelationshipEditPart(org.tmdmaker.ui.editor.gef3.editparts.relationship.RecursiveRelationshipEditPart) RelatedRelationshipEditPart(org.tmdmaker.ui.editor.gef3.editparts.relationship.RelatedRelationshipEditPart) VirtualSupersetEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.VirtualSupersetEditPart) EntityEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.EntityEditPart) MultivalueAndSupersetEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.MultivalueAndSupersetEditPart) EditPart(org.eclipse.gef.EditPart) MappingListEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.MappingListEditPart) SubsetEntityEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.SubsetEntityEditPart) SubsetTypeEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.SubsetTypeEditPart) CombinationTableEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.CombinationTableEditPart) RecursiveTableEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.RecursiveTableEditPart) VirtualEntityEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.VirtualEntityEditPart) LaputaEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.LaputaEditPart) VirtualSupersetTypeEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.VirtualSupersetTypeEditPart) MappingList(org.tmdmaker.core.model.MappingList) Entity2SubsetTypeRelationshipEditPart(org.tmdmaker.ui.editor.gef3.editparts.relationship.Entity2SubsetTypeRelationshipEditPart) RelatedRelationshipEditPart(org.tmdmaker.ui.editor.gef3.editparts.relationship.RelatedRelationshipEditPart) Diagram(org.tmdmaker.core.model.Diagram) CombinationTableEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.CombinationTableEditPart) AttributeEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.AttributeEditPart) DiagramEditPart(org.tmdmaker.ui.editor.gef3.editparts.DiagramEditPart) RelationshipEditPart(org.tmdmaker.ui.editor.gef3.editparts.relationship.RelationshipEditPart) Entity2SubsetTypeRelationshipEditPart(org.tmdmaker.ui.editor.gef3.editparts.relationship.Entity2SubsetTypeRelationshipEditPart) RecursiveRelationshipEditPart(org.tmdmaker.ui.editor.gef3.editparts.relationship.RecursiveRelationshipEditPart) RelatedRelationshipEditPart(org.tmdmaker.ui.editor.gef3.editparts.relationship.RelatedRelationshipEditPart) VirtualSupersetEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.VirtualSupersetEditPart) RelatedRelationship(org.tmdmaker.core.model.RelatedRelationship) DetailEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.DetailEditPart) Test(org.junit.Test)

Example 4 with Identifier

use of org.tmdmaker.core.model.Identifier in project tmdmaker by tmdmaker.

the class DiagramTest method testImplementEntityQuery.

@Test
public void testImplementEntityQuery() {
    Diagram diagram = new Diagram();
    assertEquals(0, diagram.query().listEntityModel().size());
    Entity e1 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
    Entity e2 = Entity.ofEvent(new Identifier("テスト2番号")).withDefaultAttribute();
    diagram.addChild(e1);
    diagram.addChild(e2);
    e2.setNotImplement(true);
    assertEquals(2, diagram.query().listEntityModel().size());
    assertEquals(1, diagram.query().implementModel().listEntityModel().size());
}
Also used : Entity(org.tmdmaker.core.model.Entity) Identifier(org.tmdmaker.core.model.Identifier) Diagram(org.tmdmaker.core.model.Diagram) Test(org.junit.Test)

Example 5 with Identifier

use of org.tmdmaker.core.model.Identifier in project tmdmaker by tmdmaker.

the class IdentifierTest method testGetCopy.

@Test
public void testGetCopy() {
    Identifier identifier1 = new Identifier("請求書番号");
    Identifier identifier2 = (Identifier) identifier1.getCopy();
    assertEquals(identifier1.getName(), identifier2.getName());
}
Also used : Identifier(org.tmdmaker.core.model.Identifier) Test(org.junit.Test)

Aggregations

Identifier (org.tmdmaker.core.model.Identifier)38 Entity (org.tmdmaker.core.model.Entity)28 Test (org.junit.Test)25 Diagram (org.tmdmaker.core.model.Diagram)23 ModelName (org.tmdmaker.core.model.parts.ModelName)18 AbstractEntityModel (org.tmdmaker.core.model.AbstractEntityModel)11 ArrayList (java.util.ArrayList)10 VirtualSuperset (org.tmdmaker.core.model.VirtualSuperset)8 VirtualSupersetType (org.tmdmaker.core.model.VirtualSupersetType)5 Attribute (org.tmdmaker.core.model.Attribute)4 Detail (org.tmdmaker.core.model.Detail)4 Header2DetailRelationship (org.tmdmaker.core.model.Header2DetailRelationship)4 ReusedIdentifier (org.tmdmaker.core.model.ReusedIdentifier)4 VirtualSubsetBuilder (org.tmdmaker.core.model.virtual.VirtualSubsetBuilder)4 AbstractRelationship (org.tmdmaker.core.model.AbstractRelationship)3 RelatedRelationship (org.tmdmaker.core.model.RelatedRelationship)3 EditPart (org.eclipse.gef.EditPart)2 Before (org.junit.Before)2 AbstractConnectionModel (org.tmdmaker.core.model.AbstractConnectionModel)2 Entity2VirtualSupersetTypeRelationship (org.tmdmaker.core.model.Entity2VirtualSupersetTypeRelationship)2