• R/O
  • HTTP
  • SSH
  • HTTPS

tmdmaker: Commit

TMD-Maker(T字形ER図作成ツール)のEclipse Plugin,RCP,Webサイト用


Commit MetaInfo

Revision2bcb123991af4ef4d2754ad3553137a3201cdd4b (tree)
Time2018-09-05 22:13:54
Authornakag <nakag@user...>
Commiternakag

Log Message

Refactoring multialue and build.

Change Summary

Incremental Difference

--- a/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/Detail.java
+++ b/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/Detail.java
@@ -17,6 +17,8 @@ package jp.sourceforge.tmdmaker.model;
1717
1818 import java.util.Map.Entry;
1919
20+import jp.sourceforge.tmdmaker.model.rule.ImplementRule;
21+
2022 /**
2123 * 多値のANDのディテール
2224 *
@@ -35,11 +37,45 @@ public class Detail extends AbstractEntityModel {
3537 /** DTLの個体指定子を使用するか? */
3638 private boolean isDetailIdentifierEnabled;
3739
38- public Detail() {
40+ /**
41+ * コンストラクタは非公開.
42+ */
43+ protected Detail() {
3944 isDetailIdentifierEnabled = true;
4045 }
4146
4247 /**
48+ * 多値のANDのDetailを作成する。
49+ *
50+ * @param header
51+ * 派生元のモデル
52+ * @return 多値のANDのDetail
53+ */
54+ protected static Detail build(AbstractEntityModel header) {
55+ Detail detail = new Detail();
56+ detail.setName(header.getName() + "DTL");
57+ detail.setEntityType(header.getEntityType());
58+ detail.setOriginalReusedIdentifier(header.createReusedIdentifier());
59+ detail.getDetailIdentifier().copyFrom(createDetailIdentifier(header.getName()));
60+ ImplementRule.setModelDefaultValue(detail);
61+ return detail;
62+ }
63+
64+ /**
65+ * Detailの個体指定子を作成する
66+ *
67+ * @param headerName
68+ * 派生元のモデル名
69+ * @return Detailの個体指定子
70+ */
71+ private static Identifier createDetailIdentifier(String headerName) {
72+ Identifier id = new Identifier(headerName + "明細番号");
73+ ImplementRule.setIdentifierDefaultValue(id);
74+
75+ return id;
76+ }
77+
78+ /**
4379 * DTLの個体指定子名(明細番号)を設定する
4480 *
4581 * @param name
--- a/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/Header2DetailRelationship.java
+++ b/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/Header2DetailRelationship.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright 2009-2017 TMD-Maker Project <http://tmdmaker.sourceforge.jp/>
2+ * Copyright 2009-2018 TMD-Maker Project <https://tmdmaker.osdn.jp/>
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
1515 */
1616 package jp.sourceforge.tmdmaker.model;
1717
18-import jp.sourceforge.tmdmaker.model.rule.ImplementRule;
19-
2018 /**
2119 * 多値のANDのヘッダとディテールとのリレーションシップ
2220 *
@@ -49,11 +47,11 @@ public class Header2DetailRelationship extends TransfarReuseKeysToTargetRelation
4947 */
5048 public Header2DetailRelationship(AbstractEntityModel header) {
5149 setSource(header);
52- detail = createDetail(header);
50+ detail = Detail.build(header);
5351 setTarget(detail);
5452 setTargetCardinality(Cardinality.MANY);
5553
56- superset = createMultivalueAndSuperset(header);
54+ superset = MultivalueAndSuperset.build(header);
5755 superset.setDetail(detail);
5856
5957 aggregator = new MultivalueAndAggregator();
@@ -68,53 +66,6 @@ public class Header2DetailRelationship extends TransfarReuseKeysToTargetRelation
6866 }
6967
7068 /**
71- * 多値のANDのSupersetを作成する。
72- *
73- * @param header
74- * 派生元のモデル
75- * @return 多値のANDのSuperset
76- */
77- private MultivalueAndSuperset createMultivalueAndSuperset(AbstractEntityModel header) {
78- MultivalueAndSuperset superset = new MultivalueAndSuperset();
79- superset.setEntityType(header.getEntityType());
80- superset.setName(header.getName());
81- superset.addReusedIdentifier(header);
82-
83- return superset;
84- }
85-
86- /**
87- * 多値のANDのDetailを作成する。
88- *
89- * @param header
90- * 派生元のモデル
91- * @return 多値のANDのDetail
92- */
93- private Detail createDetail(AbstractEntityModel header) {
94- Detail detail = new Detail();
95- detail.setName(header.getName() + "DTL");
96- detail.setEntityType(header.getEntityType());
97- detail.setOriginalReusedIdentifier(header.createReusedIdentifier());
98- detail.getDetailIdentifier().copyFrom(createDetailIdentifier(header.getName()));
99- ImplementRule.setModelDefaultValue(detail);
100- return detail;
101- }
102-
103- /**
104- * Detailの個体指定子を作成する
105- *
106- * @param headerName
107- * 派生元のモデル名
108- * @return Detailの個体指定子
109- */
110- private Identifier createDetailIdentifier(String headerName) {
111- Identifier id = new Identifier(headerName + "明細番号");
112- ImplementRule.setIdentifierDefaultValue(id);
113-
114- return id;
115- }
116-
117- /**
11869 * 多値のANDのHeaderの名称を作成する。
11970 *
12071 * @param model
@@ -140,8 +91,11 @@ public class Header2DetailRelationship extends TransfarReuseKeysToTargetRelation
14091 * スーパーセットを接続して表示する。
14192 */
14293 public void connectSuperset() {
143- getSource().getDiagram().addChild(superset);
144- getSource().getDiagram().addChild(aggregator);
94+ Diagram diagram = getSource().getDiagram();
95+ if (diagram != null) {
96+ diagram.addChild(superset);
97+ diagram.addChild(aggregator);
98+ }
14599 superset2aggregator.connect();
146100 header2aggregator.connect();
147101 detail2aggregator.connect();
@@ -166,8 +120,11 @@ public class Header2DetailRelationship extends TransfarReuseKeysToTargetRelation
166120 detail2aggregator.disconnect();
167121 header2aggregator.disconnect();
168122 superset2aggregator.disconnect();
169- getSource().getDiagram().removeChild(aggregator);
170- getSource().getDiagram().removeChild(superset);
123+ Diagram diagram = getSource().getDiagram();
124+ if (diagram != null) {
125+ diagram.removeChild(aggregator);
126+ diagram.removeChild(superset);
127+ }
171128 }
172129
173130 /**
@@ -186,7 +143,10 @@ public class Header2DetailRelationship extends TransfarReuseKeysToTargetRelation
186143 */
187144 @Override
188145 public void attachTarget() {
189- getSource().getDiagram().addChild(detail);
146+ Diagram diagram = getSource().getDiagram();
147+ if (diagram != null) {
148+ diagram.addChild(detail);
149+ }
190150 super.attachTarget();
191151 }
192152
@@ -198,7 +158,10 @@ public class Header2DetailRelationship extends TransfarReuseKeysToTargetRelation
198158 @Override
199159 public void detachTarget() {
200160 super.detachTarget();
201- getSource().getDiagram().removeChild(detail);
161+ Diagram diagram = getSource().getDiagram();
162+ if (diagram != null) {
163+ diagram.removeChild(detail);
164+ }
202165 }
203166
204167 /**
--- a/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/MultivalueAndAggregator.java
+++ b/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/MultivalueAndAggregator.java
@@ -27,9 +27,9 @@ import java.util.List;
2727 @SuppressWarnings("serial")
2828 public class MultivalueAndAggregator extends AbstractSubsetType<MultivalueAndSuperset> {
2929 /**
30- * コンストラクタ.
30+ * コンストラクタは非公開.
3131 */
32- public MultivalueAndAggregator() {
32+ protected MultivalueAndAggregator() {
3333 super();
3434 }
3535
--- a/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/MultivalueAndSuperset.java
+++ b/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/MultivalueAndSuperset.java
@@ -27,6 +27,28 @@ public class MultivalueAndSuperset extends AbstractEntityModel {
2727 private Detail detail;
2828
2929 /**
30+ * コンストラクタは非公開.
31+ */
32+ protected MultivalueAndSuperset() {
33+ super();
34+ }
35+
36+ /**
37+ * 多値のANDのSupersetを作成する。
38+ *
39+ * @param header
40+ * 派生元のモデル
41+ * @return 多値のANDのSuperset
42+ */
43+ protected static MultivalueAndSuperset build(AbstractEntityModel header) {
44+ MultivalueAndSuperset superset = new MultivalueAndSuperset();
45+ superset.setEntityType(header.getEntityType());
46+ superset.setName(header.getName());
47+ superset.addReusedIdentifier(header);
48+
49+ return superset;
50+ }
51+ /**
3052 * {@inheritDoc}
3153 */
3254 @Override
--- a/tests/tmdmaker.test/src/jp/sourceforge/tmdmaker/editpart/TMDEditPartFactoryTest.java
+++ b/tests/tmdmaker.test/src/jp/sourceforge/tmdmaker/editpart/TMDEditPartFactoryTest.java
@@ -29,7 +29,7 @@ import org.junit.Test;
2929 import jp.sourceforge.tmdmaker.model.AbstractEntityModel;
3030 import jp.sourceforge.tmdmaker.model.AbstractRelationship;
3131 import jp.sourceforge.tmdmaker.model.Attribute;
32-import jp.sourceforge.tmdmaker.model.Detail;
32+import jp.sourceforge.tmdmaker.model.Cardinality;
3333 import jp.sourceforge.tmdmaker.model.Diagram;
3434 import jp.sourceforge.tmdmaker.model.Entity;
3535 import jp.sourceforge.tmdmaker.model.Entity2SubsetTypeRelationship;
@@ -39,8 +39,6 @@ import jp.sourceforge.tmdmaker.model.Identifier;
3939 import jp.sourceforge.tmdmaker.model.Laputa;
4040 import jp.sourceforge.tmdmaker.model.MappingList;
4141 import jp.sourceforge.tmdmaker.model.ModelElement;
42-import jp.sourceforge.tmdmaker.model.MultivalueAndAggregator;
43-import jp.sourceforge.tmdmaker.model.MultivalueAndSuperset;
4442 import jp.sourceforge.tmdmaker.model.MultivalueOrEntity;
4543 import jp.sourceforge.tmdmaker.model.RecursiveRelationship;
4644 import jp.sourceforge.tmdmaker.model.RecursiveTable;
@@ -136,7 +134,15 @@ public class TMDEditPartFactoryTest {
136134 editPart = factory.createEditPart(null, o);
137135 assertThat(editPart, instanceOf(CombinationTableEditPart.class));
138136
139- o = new Detail();
137+ Entity res1 = Entity.ofResource(new Identifier("リソース番号"));
138+ Entity ev1 = Entity.ofEvent(new Identifier("イベント番号"));
139+ AbstractRelationship rel = Relationship.of(res1, ev1);
140+ rel.connect();
141+ rel.setSourceCardinality(Cardinality.MANY);
142+ rel.setTargetCardinality(Cardinality.MANY);
143+ ev1.multivalueAnd().builder().build();
144+
145+ o = ev1.multivalueAnd().detail();
140146 editPart = factory.createEditPart(null, o);
141147 assertThat(editPart, instanceOf(DetailEditPart.class));
142148
@@ -156,7 +162,7 @@ public class TMDEditPartFactoryTest {
156162 editPart = factory.createEditPart(null, o);
157163 assertThat(editPart, instanceOf(MappingListEditPart.class));
158164
159- o = new MultivalueAndSuperset();
165+ o = ev1.multivalueAnd().superset();
160166 editPart = factory.createEditPart(null, o);
161167 assertThat(editPart, instanceOf(MultivalueAndSupersetEditPart.class));
162168
@@ -200,7 +206,7 @@ public class TMDEditPartFactoryTest {
200206 editPart = factory.createEditPart(null, o);
201207 assertThat(editPart, instanceOf(RelatedRelationshipEditPart.class));
202208
203- o = new MultivalueAndAggregator();
209+ o = ev1.multivalueAnd().aggregator();
204210 editPart = factory.createEditPart(null, o);
205211 assertThat(editPart, instanceOf(MultivalueAndAggregatorEditPart.class));
206212
Show on old repository browser