use of org.tmdmaker.core.model.RelatedRelationship 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());
}
use of org.tmdmaker.core.model.RelatedRelationship in project tmdmaker by tmdmaker.
the class RelatedRelationshipTest method testTableHelper.
/**
* Test method for {@link org.tmdmaker.core.model.RelatedRelationship}
* .
*/
@Test
public void testTableHelper() {
Diagram diagram = new Diagram();
Entity e1 = Entity.ofResource(new Identifier("テスト1番号")).withDefaultAttribute();
diagram.addChild(e1);
Entity e2 = Entity.ofResource(new Identifier("テスト2番号")).withDefaultAttribute();
diagram.addChild(e2);
AbstractRelationship r = Relationship.of(e1, e2);
r.connect();
CombinationTable t1 = (CombinationTable) r.getTable();
RelatedRelationship rr = (RelatedRelationship) t1.getModelTargetConnections().get(0);
assertEquals("テスト1", rr.getSourceName());
assertEquals("テスト2", rr.getTargetName());
}
use of org.tmdmaker.core.model.RelatedRelationship in project tmdmaker by tmdmaker.
the class RelatedRelationshipTest method testVirtualSupersetHelper.
/**
* Test method for {@link org.tmdmaker.core.model.RelatedRelationship}
* .
*/
@Test
public void testVirtualSupersetHelper() {
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);
VirtualSuperset vsp = VirtualSuperset.of(new ModelName("スーパーセット"));
VirtualSupersetType type = new VirtualSupersetType();
diagram.addChild(vsp);
diagram.addChild(type);
RelatedRelationship t2v = new RelatedRelationship(type, vsp);
Entity2VirtualSupersetTypeRelationship m2t1 = new Entity2VirtualSupersetTypeRelationship(e1, type);
Entity2VirtualSupersetTypeRelationship m2t2 = new Entity2VirtualSupersetTypeRelationship(e2, type);
t2v.connect();
m2t1.connect();
m2t2.connect();
assertEquals(true, t2v.isDeletable());
assertEquals("スーパーセット", t2v.getSourceName());
assertEquals("テスト1,テスト2", t2v.getTargetName());
assertEquals("スーパーセット", m2t1.getSourceName());
assertEquals("テスト1", m2t1.getTargetName());
}
use of org.tmdmaker.core.model.RelatedRelationship in project tmdmaker by tmdmaker.
the class Patch040SerializerHandler method convertVirtualSupersetType2VirtualSupersetRelationship.
private void convertVirtualSupersetType2VirtualSupersetRelationship(VirtualSuperset superset) {
AbstractConnectionModel acm = superset.getModelTargetConnections().get(0);
if (acm instanceof VirtualSupersetType2VirtualSupersetRelationship) {
return;
}
RelatedRelationship rr = (RelatedRelationship) acm;
VirtualSupersetType type = (VirtualSupersetType) rr.getSource();
VirtualSupersetType2VirtualSupersetRelationship newRelationship = new VirtualSupersetType2VirtualSupersetRelationship();
List<Entity2VirtualSupersetTypeRelationship> newSubsetList = new ArrayList<Entity2VirtualSupersetTypeRelationship>();
for (AbstractConnectionModel c : type.getModelTargetConnections()) {
newSubsetList.add((Entity2VirtualSupersetTypeRelationship) c);
}
rr.disconnect();
newRelationship.setSource(type);
newRelationship.setTarget(superset);
newRelationship.setSubset2typeRelationshipList(newSubsetList);
newRelationship.connect();
}
use of org.tmdmaker.core.model.RelatedRelationship in project tmdmaker by tmdmaker.
the class Patch023SerializerHandler method convertRelatedRelationships.
private void convertRelatedRelationships(List<AbstractConnectionModel> connections) {
AnchorConstraintMigrator converter = new AnchorConstraintMigrator();
for (AbstractConnectionModel c : connections) {
if (c instanceof RelatedRelationship) {
logger.debug("convertRelatedRelationships():{}", c);
converter.convertNullLocationPoint(c);
}
if (c instanceof Entity2SubsetTypeRelationship) {
logger.debug("convertEntity2SubsetTypeRelationships():{}", c);
converter.convertNullLocationPoint(c);
}
}
}
Aggregations