TMD-Maker(T字形ER図作成ツール)のEclipse Plugin版
Révision | dcf9f622bfca08617a6d2514f2073a5c178632a3 (tree) |
---|---|
l'heure | 2009-12-19 13:45:56 |
Auteur | nakag <nakag@user...> |
Commiter | nakag |
アトリビュートリストの出力順をアトリビュート名、エンティティ名の順になるように修正。
同じアトリビュート名が1つにまとめられる不具合を合わせて修正。
@@ -35,6 +35,7 @@ import jp.sourceforge.tmdmaker.model.CombinationTable; | ||
35 | 35 | import jp.sourceforge.tmdmaker.model.Detail; |
36 | 36 | import jp.sourceforge.tmdmaker.model.Diagram; |
37 | 37 | import jp.sourceforge.tmdmaker.model.Entity; |
38 | +import jp.sourceforge.tmdmaker.model.Identifier; | |
38 | 39 | import jp.sourceforge.tmdmaker.model.MappingList; |
39 | 40 | import jp.sourceforge.tmdmaker.model.ModelElement; |
40 | 41 | import jp.sourceforge.tmdmaker.model.MultivalueAndSuperset; |
@@ -95,22 +96,22 @@ public class AttributeListHtmlGenerator { | ||
95 | 96 | new File(rootDir, "index.html"))); |
96 | 97 | // context.put("entities", findAvailableModel(model)); |
97 | 98 | context.put("esc", new EscapeTool()); |
98 | - Map<Attribute, AbstractEntityModel> attributes = findAllAttributes(model); | |
99 | + Map<String, EntityAttributePair> attributes = findAllAttributes(model); | |
99 | 100 | |
100 | 101 | context.put("entities", findAvailableModel(model)); |
101 | 102 | applyTemplate("summary.html", new File(rootDir, "summary.html"), |
102 | 103 | context); |
103 | 104 | |
104 | - context.put("attributes", attributes.keySet()); | |
105 | + context.put("attributes", attributes.entrySet()); | |
105 | 106 | |
106 | 107 | applyTemplate("attribute_list.html", new File(rootDir, |
107 | 108 | "attribute_list.html"), context); |
108 | 109 | File attributesDir = new File(rootDir, "attributes"); |
109 | 110 | attributesDir.mkdir(); |
110 | - for (Map.Entry<Attribute, AbstractEntityModel> entry : attributes | |
111 | + for (Map.Entry<String, EntityAttributePair> entry : attributes | |
111 | 112 | .entrySet()) { |
112 | - Attribute attribute = entry.getKey(); | |
113 | - AbstractEntityModel entity = entry.getValue(); | |
113 | + Attribute attribute = entry.getValue().getAttribute(); | |
114 | + AbstractEntityModel entity = entry.getValue().getModel(); | |
114 | 115 | context.put("attribute", attribute); |
115 | 116 | context.put("entity", entity); |
116 | 117 | if (entity instanceof Entity) { |
@@ -119,9 +120,8 @@ public class AttributeListHtmlGenerator { | ||
119 | 120 | } else { |
120 | 121 | context.remove("entityType"); |
121 | 122 | } |
122 | - applyTemplate("attribute.html", new File(attributesDir, attribute | |
123 | - .getName() | |
124 | - + ".html"), context); | |
123 | + applyTemplate("attribute.html", new File(attributesDir, | |
124 | + entry.getValue().createAttributeFileKey() + ".html"), context); | |
125 | 125 | } |
126 | 126 | } |
127 | 127 |
@@ -154,10 +154,11 @@ public class AttributeListHtmlGenerator { | ||
154 | 154 | return entities; |
155 | 155 | } |
156 | 156 | |
157 | - private Map<Attribute, AbstractEntityModel> findAllAttributes( | |
157 | + private Map<String, EntityAttributePair> findAllAttributes( | |
158 | 158 | Diagram diagram) { |
159 | - Map<Attribute, AbstractEntityModel> attributes = new TreeMap<Attribute, AbstractEntityModel>( | |
160 | - new Comparator<Attribute>() { | |
159 | + | |
160 | + Map<String, EntityAttributePair> attributes = new TreeMap<String, EntityAttributePair>( | |
161 | + new Comparator<String>() { | |
161 | 162 | |
162 | 163 | /** |
163 | 164 | * {@inheritDoc} |
@@ -166,23 +167,29 @@ public class AttributeListHtmlGenerator { | ||
166 | 167 | * java.lang.Object) |
167 | 168 | */ |
168 | 169 | @Override |
169 | - public int compare(Attribute o1, Attribute o2) { | |
170 | - return o1.getName().compareTo(o2.getName()); | |
170 | + public int compare(String o1, String o2) { | |
171 | + return o1.compareTo(o2); | |
171 | 172 | |
172 | 173 | } |
174 | + | |
173 | 175 | }); |
174 | 176 | |
175 | 177 | for (AbstractEntityModel m : findAvailableModel(diagram)) { |
176 | 178 | if (m instanceof Entity) { |
177 | 179 | Entity e = (Entity) m; |
178 | - attributes.put(e.getIdentifier(), e); | |
180 | + Identifier i = e.getIdentifier(); | |
181 | + EntityAttributePair pair = new EntityAttributePair(e, i); | |
182 | + attributes.put(pair.createAttributeFileKey(), pair); | |
179 | 183 | } |
180 | 184 | if (m instanceof Detail) { |
181 | 185 | Detail d = (Detail) m; |
182 | - attributes.put(d.getDetailIdentifier(), d); | |
186 | + Identifier i = d.getDetailIdentifier(); | |
187 | + EntityAttributePair pair = new EntityAttributePair(d, i); | |
188 | + attributes.put(pair.createAttributeFileKey(), pair); | |
183 | 189 | } |
184 | 190 | for (Attribute a : m.getAttributes()) { |
185 | - attributes.put(a, m); | |
191 | + EntityAttributePair pair = new EntityAttributePair(m, a); | |
192 | + attributes.put(pair.createAttributeFileKey(), pair); | |
186 | 193 | } |
187 | 194 | } |
188 | 195 | return attributes; |
@@ -209,4 +216,5 @@ public class AttributeListHtmlGenerator { | ||
209 | 216 | } |
210 | 217 | } |
211 | 218 | } |
219 | + | |
212 | 220 | } |
@@ -0,0 +1,69 @@ | ||
1 | +/* | |
2 | + * Copyright 2009 TMD-Maker Project <http://tmdmaker.sourceforge.jp/> | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | + * See the License for the specific language governing permissions and | |
14 | + * limitations under the License. | |
15 | + */ | |
16 | +package jp.sourceforge.tmdmaker.generate.attributelist; | |
17 | + | |
18 | +import jp.sourceforge.tmdmaker.model.AbstractEntityModel; | |
19 | +import jp.sourceforge.tmdmaker.model.Attribute; | |
20 | + | |
21 | +/** | |
22 | + * エンティティ系モデルとアトリビュートの1:1のペアモデル | |
23 | + * | |
24 | + * @author nakaG | |
25 | + * | |
26 | + */ | |
27 | +public class EntityAttributePair { | |
28 | + private Attribute attribute; | |
29 | + private AbstractEntityModel model; | |
30 | + | |
31 | + /** | |
32 | + * コンストラクタ | |
33 | + * | |
34 | + * @param model | |
35 | + * @param attribute | |
36 | + */ | |
37 | + public EntityAttributePair(AbstractEntityModel model, Attribute attribute) { | |
38 | + this.model = model; | |
39 | + this.attribute = attribute; | |
40 | + } | |
41 | + public String createAttributeFileKey() { | |
42 | + return attribute.getName() + "_" + model.getName(); | |
43 | + } | |
44 | + /** | |
45 | + * @return the attribute | |
46 | + */ | |
47 | + public Attribute getAttribute() { | |
48 | + return attribute; | |
49 | + } | |
50 | + /** | |
51 | + * @param attribute the attribute to set | |
52 | + */ | |
53 | + public void setAttribute(Attribute attribute) { | |
54 | + this.attribute = attribute; | |
55 | + } | |
56 | + /** | |
57 | + * @return the model | |
58 | + */ | |
59 | + public AbstractEntityModel getModel() { | |
60 | + return model; | |
61 | + } | |
62 | + /** | |
63 | + * @param model the model to set | |
64 | + */ | |
65 | + public void setModel(AbstractEntityModel model) { | |
66 | + this.model = model; | |
67 | + } | |
68 | + | |
69 | +} |
@@ -23,7 +23,7 @@ | ||
23 | 23 | <strong><a href="summary.html" target="attribute_frame">対象エンティティ一覧</a></strong><br> |
24 | 24 | #foreach($attr in $attributes) |
25 | 25 | |
26 | - <a href="attributes/${attr.name}.html" target="attribute_frame">$esc.html($attr.name)</a><br> | |
26 | + <a href="attributes/${attr.value.createAttributeFileKey()}.html" target="attribute_frame">$esc.html($attr.value.attribute.name)</a><br> | |
27 | 27 | #end |
28 | 28 | </body> |
29 | 29 | </html> |
\ No newline at end of file |