Search in sources :

Example 6 with VirtualSuperset

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

the class DiagramTest method testCreateVirtualSuperset.

@Test
public void testCreateVirtualSuperset() {
    Diagram diagram = new Diagram();
    Entity e1 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
    diagram.addChild(e1);
    Entity e2 = Entity.ofEvent(new Identifier("テスト2番号")).withDefaultAttribute();
    diagram.addChild(e2);
    List<AbstractEntityModel> list = new ArrayList<AbstractEntityModel>();
    list.add(e1);
    list.add(e2);
    VirtualSuperset vsp = VirtualSuperset.of(new ModelName("スーパーセット"));
    vsp.virtualSubsets().builder().subsetList(list).build();
    VirtualSupersetType2VirtualSupersetRelationship t2v = (VirtualSupersetType2VirtualSupersetRelationship) vsp.getModelTargetConnections().get(0);
    VirtualSupersetType type = vsp.getVirtualSupersetType();
    Entity2VirtualSupersetTypeRelationship m2t1 = (Entity2VirtualSupersetTypeRelationship) type.getModelTargetConnections().get(0);
    assertEquals(2, vsp.getVirtualSubsetList().size());
    assertEquals(true, t2v.isDeletable());
    assertEquals("スーパーセット", t2v.getSourceName());
    assertEquals("テスト1,テスト2", t2v.getTargetName());
    assertEquals("スーパーセット", m2t1.getSourceName());
    assertEquals("テスト1", m2t1.getTargetName());
}
Also used : Entity(org.tmdmaker.core.model.Entity) VirtualSupersetType(org.tmdmaker.core.model.VirtualSupersetType) Identifier(org.tmdmaker.core.model.Identifier) ModelName(org.tmdmaker.core.model.parts.ModelName) Entity2VirtualSupersetTypeRelationship(org.tmdmaker.core.model.Entity2VirtualSupersetTypeRelationship) VirtualSupersetType2VirtualSupersetRelationship(org.tmdmaker.core.model.VirtualSupersetType2VirtualSupersetRelationship) ArrayList(java.util.ArrayList) VirtualSuperset(org.tmdmaker.core.model.VirtualSuperset) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) Diagram(org.tmdmaker.core.model.Diagram) Test(org.junit.Test)

Example 7 with VirtualSuperset

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

the class VirtualSupersetCreateAction method run.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    // アクション呼び出し時のマウスカーソル位置を取得。位置の微調整必要かも
    Point pos = getControlCursorLocation();
    List<AbstractEntityModel> selectedModels = getSelectedModelList();
    Diagram diagram = getDiagram();
    VirtualSuperset original = null;
    VirtualSupersetType aggregator = null;
    if (!selectedModels.isEmpty()) {
        original = getVirtualSuperset();
        if (original != null) {
            selectedModels.remove(original);
        }
    }
    VirtualSupersetCreateDialog dialog = new VirtualSupersetCreateDialog(getControl().getShell(), diagram, original, selectedModels);
    if (dialog.open() == Dialog.OK) {
        CompoundCommand ccommand = null;
        VirtualSuperset edited = dialog.getEditedValue();
        aggregator = dialog.getEditedAggregator();
        List<AbstractEntityModel> selection = dialog.getSelection();
        // みなしスーパーセット作成
        if (original == null) {
            if (selection.isEmpty()) {
                return;
            }
            ccommand = new CompoundCommand();
            ccommand.add(new VirtualSupersetCreateCommand(edited, selection, pos.x, pos.y));
            ccommand.add(new VirtualSupersetTypeChangeCommand(edited, aggregator.isApplyAttribute()));
        } else {
            ccommand = new VirtualSupersetEditCommand(original, edited, selection, aggregator.isApplyAttribute());
        }
        execute(ccommand);
    }
}
Also used : VirtualSupersetCreateCommand(org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetCreateCommand) VirtualSupersetType(org.tmdmaker.core.model.VirtualSupersetType) VirtualSupersetCreateDialog(org.tmdmaker.ui.dialogs.VirtualSupersetCreateDialog) VirtualSuperset(org.tmdmaker.core.model.VirtualSuperset) VirtualSupersetTypeChangeCommand(org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetTypeChangeCommand) Point(org.eclipse.swt.graphics.Point) VirtualSupersetEditCommand(org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetEditCommand) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) Diagram(org.tmdmaker.core.model.Diagram) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 8 with VirtualSuperset

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

the class ModelFeatureTest method testCanCreateSubset.

/**
 * モデル毎のサブセットの作成可否をテスト
 */
@Test
public void testCanCreateSubset() {
    CombinationTable t = new CombinationTable();
    assertEquals(true, t.canCreateSubset());
    Entity e = new Entity();
    assertEquals(true, e.canCreateSubset());
    Detail d = new Detail();
    assertEquals(true, d.canCreateSubset());
    Laputa l = new Laputa();
    assertEquals(false, l.canCreateSubset());
    MappingList m = new MappingList();
    assertEquals(true, m.canCreateSubset());
    MultivalueAndSuperset ms = new MultivalueAndSuperset();
    assertEquals(false, ms.canCreateSubset());
    MultivalueOrEntity mo = new MultivalueOrEntity();
    assertEquals(true, mo.canCreateSubset());
    RecursiveTable r = new RecursiveTable();
    assertEquals(true, r.canCreateSubset());
    SubsetEntity s = new SubsetEntity();
    assertEquals(true, s.canCreateSubset());
    VirtualEntity v = new VirtualEntity();
    assertEquals(false, v.canCreateSubset());
    VirtualSuperset vs = new VirtualSuperset();
    assertEquals(false, vs.canCreateSubset());
    Memo mm = new Memo();
    assertEquals(false, mm.canCreateSubset());
    TurboFile tb = new TurboFile();
    assertEquals(false, tb.canCreateSubset());
}
Also used : SubsetEntity(org.tmdmaker.core.model.SubsetEntity) MultivalueOrEntity(org.tmdmaker.core.model.MultivalueOrEntity) SubsetEntity(org.tmdmaker.core.model.SubsetEntity) Entity(org.tmdmaker.core.model.Entity) VirtualEntity(org.tmdmaker.core.model.VirtualEntity) MultivalueAndSuperset(org.tmdmaker.core.model.MultivalueAndSuperset) TurboFile(org.tmdmaker.core.model.other.TurboFile) MappingList(org.tmdmaker.core.model.MappingList) MultivalueOrEntity(org.tmdmaker.core.model.MultivalueOrEntity) VirtualSuperset(org.tmdmaker.core.model.VirtualSuperset) CombinationTable(org.tmdmaker.core.model.CombinationTable) VirtualEntity(org.tmdmaker.core.model.VirtualEntity) RecursiveTable(org.tmdmaker.core.model.RecursiveTable) Laputa(org.tmdmaker.core.model.Laputa) Detail(org.tmdmaker.core.model.Detail) Memo(org.tmdmaker.core.model.other.Memo) Test(org.junit.Test)

Example 9 with VirtualSuperset

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

the class ModelFeatureTest method testCanCreateVirtualEntity.

/**
 * モデル毎のみなしエンティティ作成可否をテスト
 */
@Test
public void testCanCreateVirtualEntity() {
    CombinationTable t = new CombinationTable();
    assertEquals(true, t.canCreateVirtualEntity());
    Entity e = new Entity();
    assertEquals(true, e.canCreateVirtualEntity());
    Detail d = new Detail();
    assertEquals(true, d.canCreateVirtualEntity());
    Laputa l = new Laputa();
    assertEquals(false, l.canCreateVirtualEntity());
    MappingList m = new MappingList();
    assertEquals(true, m.canCreateVirtualEntity());
    MultivalueAndSuperset ms = new MultivalueAndSuperset();
    assertEquals(false, ms.canCreateVirtualEntity());
    MultivalueOrEntity mo = new MultivalueOrEntity();
    assertEquals(true, mo.canCreateVirtualEntity());
    RecursiveTable r = new RecursiveTable();
    assertEquals(true, r.canCreateVirtualEntity());
    SubsetEntity s = new SubsetEntity();
    assertEquals(true, s.canCreateVirtualEntity());
    VirtualEntity v = new VirtualEntity();
    assertEquals(false, v.canCreateVirtualEntity());
    VirtualSuperset vs = new VirtualSuperset();
    assertEquals(false, vs.canCreateVirtualEntity());
    Memo mm = new Memo();
    assertEquals(false, mm.canCreateVirtualEntity());
    TurboFile tb = new TurboFile();
    assertEquals(false, tb.canCreateVirtualEntity());
}
Also used : SubsetEntity(org.tmdmaker.core.model.SubsetEntity) MultivalueOrEntity(org.tmdmaker.core.model.MultivalueOrEntity) SubsetEntity(org.tmdmaker.core.model.SubsetEntity) Entity(org.tmdmaker.core.model.Entity) VirtualEntity(org.tmdmaker.core.model.VirtualEntity) MultivalueAndSuperset(org.tmdmaker.core.model.MultivalueAndSuperset) TurboFile(org.tmdmaker.core.model.other.TurboFile) MappingList(org.tmdmaker.core.model.MappingList) MultivalueOrEntity(org.tmdmaker.core.model.MultivalueOrEntity) VirtualSuperset(org.tmdmaker.core.model.VirtualSuperset) CombinationTable(org.tmdmaker.core.model.CombinationTable) VirtualEntity(org.tmdmaker.core.model.VirtualEntity) RecursiveTable(org.tmdmaker.core.model.RecursiveTable) Laputa(org.tmdmaker.core.model.Laputa) Detail(org.tmdmaker.core.model.Detail) Memo(org.tmdmaker.core.model.other.Memo) Test(org.junit.Test)

Example 10 with VirtualSuperset

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

the class VirtualSupersetTest method testDeleteSuperSuper1.

@Test
public void testDeleteSuperSuper1() {
    List<AbstractEntityModel> list = new ArrayList<AbstractEntityModel>();
    Diagram diagram = new Diagram();
    Entity e1 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
    diagram.addChild(e1);
    Entity e2 = Entity.ofEvent(new Identifier("テスト2番号")).withDefaultAttribute();
    diagram.addChild(e2);
    Entity e3 = Entity.ofEvent(new Identifier("テスト2番号")).withDefaultAttribute();
    diagram.addChild(e3);
    VirtualSuperset vsp1 = VirtualSuperset.of(new ModelName("スーパーセット"));
    VirtualSubsetBuilder builder = vsp1.virtualSubsets().builder();
    list.add(e1);
    list.add(e2);
    list.add(e3);
    builder.subsetList(list).build();
    assertEquals(3, vsp1.virtualSubsets().all().size());
    List<AbstractEntityModel> list2 = new ArrayList<AbstractEntityModel>();
    list2.add(e1);
    list2.add(e2);
    builder = vsp1.virtualSubsets().builder();
    builder.subsetList(null).build();
    assertTrue(!vsp1.hasSubset());
    assertEquals(vsp1.virtualSubsets().all().size(), 0);
    builder.rollback();
    assertTrue(vsp1.hasSubset());
    assertEquals(vsp1.virtualSubsets().all().size(), 3);
}
Also used : Entity(org.tmdmaker.core.model.Entity) Identifier(org.tmdmaker.core.model.Identifier) ModelName(org.tmdmaker.core.model.parts.ModelName) VirtualSubsetBuilder(org.tmdmaker.core.model.virtual.VirtualSubsetBuilder) ArrayList(java.util.ArrayList) VirtualSuperset(org.tmdmaker.core.model.VirtualSuperset) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) Diagram(org.tmdmaker.core.model.Diagram) Test(org.junit.Test)

Aggregations

VirtualSuperset (org.tmdmaker.core.model.VirtualSuperset)14 Test (org.junit.Test)12 Diagram (org.tmdmaker.core.model.Diagram)11 Entity (org.tmdmaker.core.model.Entity)11 AbstractEntityModel (org.tmdmaker.core.model.AbstractEntityModel)9 Identifier (org.tmdmaker.core.model.Identifier)8 ModelName (org.tmdmaker.core.model.parts.ModelName)8 ArrayList (java.util.ArrayList)7 VirtualSupersetType (org.tmdmaker.core.model.VirtualSupersetType)7 VirtualSubsetBuilder (org.tmdmaker.core.model.virtual.VirtualSubsetBuilder)4 CombinationTable (org.tmdmaker.core.model.CombinationTable)3 Detail (org.tmdmaker.core.model.Detail)3 Laputa (org.tmdmaker.core.model.Laputa)3 MappingList (org.tmdmaker.core.model.MappingList)3 MultivalueAndSuperset (org.tmdmaker.core.model.MultivalueAndSuperset)3 MultivalueOrEntity (org.tmdmaker.core.model.MultivalueOrEntity)3 RecursiveTable (org.tmdmaker.core.model.RecursiveTable)3 SubsetEntity (org.tmdmaker.core.model.SubsetEntity)3 VirtualEntity (org.tmdmaker.core.model.VirtualEntity)3 Memo (org.tmdmaker.core.model.other.Memo)3