svnno****@sourc*****
svnno****@sourc*****
2009年 2月 6日 (金) 01:32:10 JST
Revision: 2618 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2618 Author: daisuke_m Date: 2009-02-06 01:32:10 +0900 (Fri, 06 Feb 2009) Log Message: ----------- シリアライザのテストが1つ通ったのでコミット。 Modified Paths: -------------- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewDomSerializerEnhancer.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewFactoryExtensionEnhancer.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/test/ViewTestModelBuilder.java zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-view.xsd zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml -------------- next part -------------- Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java =================================================================== --- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java 2009-02-05 15:29:18 UTC (rev 2617) +++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java 2009-02-05 16:32:10 UTC (rev 2618) @@ -236,25 +236,22 @@ String xml2 = convertRootModelToXml(serializer2, rootModel2); // 参考のため、targetディレクトリに出力XMLを記録 - FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this, "null") + FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this.getClass()) + "_test1_xml1.xml"), xml1, CharEncoding.UTF_8); - FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this, "null") + FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this.getClass()) + "_test1_xml2.xml"), xml2, CharEncoding.UTF_8); - boolean equals = EqualsUtil.equals(rootModel2, rootModel1); + EqualsUtil.equals(rootModel2, rootModel1); - FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this, "null") + FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this.getClass()) + "_test1_gtree1.txt"), EqualsUtil.rightGTree, CharEncoding.UTF_8); - FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this, "null") + FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this.getClass()) + "_test1_gtree2.txt"), EqualsUtil.leftGTree, CharEncoding.UTF_8); - assertEquals(EqualsUtil.rightGTree, EqualsUtil.leftGTree); assertEquals(xml1, xml2); - - assertThat(equals, is(true)); - assertThat(xml2, is(xml1)); + assertEquals(EqualsUtil.rightGTree, EqualsUtil.leftGTree); } /** @@ -284,25 +281,22 @@ assertThat(validator.validate(rootModel2).size(), is(0)); // 一応バリデーションを行っておく // 参考のため、targetディレクトリに出力XMLを記録 - FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this, "null") + FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this.getClass()) + "_test2_xml1.xml"), xml1, CharEncoding.UTF_8); - FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this, "null") + FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this.getClass()) + "_test2_xml2.xml"), xml2, CharEncoding.UTF_8); - boolean equals = EqualsUtil.equals(rootModel2, rootModel1); + EqualsUtil.equals(rootModel2, rootModel1); - FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this, "null") + FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this.getClass()) + "_test2_gtree1.txt"), EqualsUtil.rightGTree, CharEncoding.UTF_8); - FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this, "null") + FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this.getClass()) + "_test2_gtree2.txt"), EqualsUtil.leftGTree, CharEncoding.UTF_8); - assertEquals(EqualsUtil.rightGTree, EqualsUtil.leftGTree); assertEquals(xml1, xml2); - - assertThat(equals, is(true)); - assertThat(xml2, is(xml1)); + assertEquals(EqualsUtil.rightGTree, EqualsUtil.leftGTree); } private String convertRootModelToXml(JiemamySerializer serializer, RootModel rootModel) Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewDomSerializerEnhancer.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewDomSerializerEnhancer.java 2009-02-05 15:29:18 UTC (rev 2617) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewDomSerializerEnhancer.java 2009-02-05 16:32:10 UTC (rev 2618) @@ -47,7 +47,6 @@ import org.jiemamy.utils.XpathUtil; import org.jiemamy.utils.enhancer.Invocation; import org.jiemamy.utils.enhancer.InvocationHandler; -import org.jiemamy.utils.model.PresentationUtil; import org.jiemamy.utils.model.RootModelUtil; import org.jiemamy.xml.CoreQName; import org.jiemamy.xml.ViewQName; @@ -109,10 +108,11 @@ logger.info(" nodeLayouts"); Element nodeLayoutsElement = DomUtil.newChild(presentationElement, ViewQName.NODE_LAYOUTS); for (Map.Entry<NodeAdapter, NodeProfile> entry : presentation.getFigureProfiles().entrySet()) { + NodeAdapter node = entry.getKey(); + NodeProfile nodeProfile = entry.getValue(); logger.info(" nodeLayout"); Element nodeLayoutElement = DomUtil.newChild(nodeLayoutsElement, ViewQName.NODE_LAYOUT); - NodeAdapter node = entry.getKey(); - NodeProfile nodeProfile = entry.getValue(); + nodeLayoutElement.setAttribute("id", nodeProfile.getId().toString()); Element nodeElement; if (node.unwrap() == null) { nodeElement = DomUtil.newChild(nodeLayoutElement, ViewQName.STICKY); @@ -221,8 +221,11 @@ Attr colorAttr = XpathUtil.getAttr(nodeLayoutNode, "view:boundary/@color"); JmColor color = colorAttr == null ? null : JmColor.parse(colorAttr.getValue()); - PresentationUtil.setLayout(presentation, nodeAdapter, rect); - PresentationUtil.setColor(presentation, nodeAdapter, color); + NodeProfile nodeProfile = + factory.newModel(NodeProfile.class, DomUtil.getUUID(nodeLayoutNode, CoreQName.ID)); + nodeProfile.setLayout(rect); + nodeProfile.setColor(color); + presentation.getFigureProfiles().put(nodeAdapter, nodeProfile); } presentation.setName(XpathUtil.getTextContent(dpElement, "core:name")); Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewFactoryExtensionEnhancer.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewFactoryExtensionEnhancer.java 2009-02-05 15:29:18 UTC (rev 2617) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewFactoryExtensionEnhancer.java 2009-02-05 16:32:10 UTC (rev 2618) @@ -96,6 +96,11 @@ } } + /** + * コネクションのソートオーダーを決めるコンパレータ。 + * + * @author daisuke + */ protected enum ConnectionComparator implements Comparator<ConnectionAdapter> { /** singleton instance */ @@ -129,6 +134,19 @@ INSTANCE; public int compare(NodeAdapter o1, NodeAdapter o2) { + if (o1 == null && o2 == null) { + return 0; + } else if (o1 == null) { + return -1; + } else if (o2 == null) { + return 1; + } else if (o1.unwrap() == null && o2.unwrap() == null) { + return o1.getClass().getName().compareTo(o2.getClass().getName()); + } else if (o1.unwrap() == null) { + return 1; + } else if (o2.unwrap() == null) { + return -1; + } EntityModel e1 = o1.unwrap(); EntityModel e2 = o2.unwrap(); if (e1 != null && e2 != null) { Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/test/ViewTestModelBuilder.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/test/ViewTestModelBuilder.java 2009-02-05 15:29:18 UTC (rev 2617) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/test/ViewTestModelBuilder.java 2009-02-05 16:32:10 UTC (rev 2618) @@ -146,36 +146,59 @@ private void createPresentations() { if (factory.getSupportedSpecs().contains(OfficialSpecs.VIEW)) { // ダイアグラム表現の生成・追加(1) - DiagramPresentationModel presentation = + DiagramPresentationModel presentation1 = factory.newModel(DiagramPresentationModel.class, uuid.get("1deca0e8-6153-47ad-abe8-ac764f768d96")); - presentation.setName("全部表示する"); - PresentationUtil.setLayout(presentation, tableEmp.getAdapter(NodeAdapter.class), new JmRectangle(360, 60)); - PresentationUtil.setLayout(presentation, tableDept.getAdapter(NodeAdapter.class), new JmRectangle(60, 60)); - PresentationUtil.setLayout(presentation, viewHighSal.getAdapter(NodeAdapter.class), - new JmRectangle(60, 270)); - PresentationUtil.setLayout(presentation, sticky, new JmRectangle(360, 270)); - PresentationUtil.setColor(presentation, sticky, new JmColor(10, 11, 12)); + presentation1.setName("全部表示する"); + NodeProfile empLayout = + factory.newModel(NodeProfile.class, uuid.get("aa7caa23-7958-4bd0-a356-8f09d4b74f08")); + presentation1.getFigureProfiles().put(tableEmp.getAdapter(NodeAdapter.class), empLayout); + empLayout.setLayout(new JmRectangle(360, 60)); + + NodeProfile deptLayout = + factory.newModel(NodeProfile.class, uuid.get("eb6506ef-4a25-4296-b6d7-c08741f19d5a")); + presentation1.getFigureProfiles().put(tableDept.getAdapter(NodeAdapter.class), deptLayout); + deptLayout.setLayout(new JmRectangle(60, 60)); + + NodeProfile viewLayout = + factory.newModel(NodeProfile.class, uuid.get("2387bfd0-7106-44ad-a34e-24231bbea6d5")); + presentation1.getFigureProfiles().put(viewHighSal.getAdapter(NodeAdapter.class), viewLayout); + viewLayout.setLayout(new JmRectangle(60, 270)); + + NodeProfile stickyLayout = + factory.newModel(NodeProfile.class, uuid.get("2689d193-52a1-4fd4-a14c-9857274518c5")); + presentation1.getFigureProfiles().put(sticky, stickyLayout); + stickyLayout.setLayout(new JmRectangle(360, 270)); + stickyLayout.setColor(new JmColor(10, 11, 12)); + List<JmPoint> bendpoints = new ArrayList<JmPoint>(); - NodeProfile nodeProf = presentation.getFigureProfiles().get(tableEmp.getAdapter(NodeAdapter.class)); + NodeProfile nodeProf = presentation1.getFigureProfiles().get(tableEmp.getAdapter(NodeAdapter.class)); JmRectangle rect = nodeProf.getLayout(); bendpoints.add(0, new JmPoint(Math.max(rect.x - offset, 0), rect.y)); bendpoints.add(1, new JmPoint(rect.x, Math.max(rect.y - offset, 0))); - presentation.getConnectionLayouts().put(fkEmpEmp.getAdapter(ConnectionAdapter.class), bendpoints); - presentation.getConnectionLayouts().put(fkEmpDept.getAdapter(ConnectionAdapter.class), + presentation1.getConnectionLayouts().put(fkEmpEmp.getAdapter(ConnectionAdapter.class), bendpoints); + presentation1.getConnectionLayouts().put(fkEmpDept.getAdapter(ConnectionAdapter.class), new ArrayList<JmPoint>()); // bendpount無し - rootModel.getAdapter(DiagramPresentations.class).add(presentation); + rootModel.getAdapter(DiagramPresentations.class).add(presentation1); // ダイアグラム表現の生成・追加(2) - presentation = + DiagramPresentationModel presentation2 = factory.newModel(DiagramPresentationModel.class, uuid.get("53c7cdb7-1512-46c7-8ee3-aadec6007896")); - presentation.setName("一部表示する"); - PresentationUtil.setLayout(presentation, tableEmp.getAdapter(NodeAdapter.class), new JmRectangle(60, 60)); - PresentationUtil.setLayout(presentation, viewHighSal.getAdapter(NodeAdapter.class), new JmRectangle(270, - 270)); - PresentationUtil.setLayout(presentation, fkEmpDept.getAdapter(ConnectionAdapter.class), + presentation2.setName("一部表示する"); + + NodeProfile empLayout2 = + factory.newModel(NodeProfile.class, uuid.get("d71ff015-101c-4669-8745-312d1da34efe")); + presentation2.getFigureProfiles().put(tableEmp.getAdapter(NodeAdapter.class), empLayout2); + empLayout2.setLayout(new JmRectangle(60, 60)); + + NodeProfile viewLayout2 = + factory.newModel(NodeProfile.class, uuid.get("2df7718f-d71e-4dbf-8327-e0ad36f03d5d")); + presentation2.getFigureProfiles().put(viewHighSal.getAdapter(NodeAdapter.class), viewLayout2); + viewLayout2.setLayout(new JmRectangle(270, 270)); + + PresentationUtil.setLayout(presentation2, fkEmpDept.getAdapter(ConnectionAdapter.class), new ArrayList<JmPoint>()); // bendpount無し - rootModel.getAdapter(DiagramPresentations.class).add(presentation); + rootModel.getAdapter(DiagramPresentations.class).add(presentation2); } } } Modified: zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-view.xsd =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-view.xsd 2009-02-05 15:29:18 UTC (rev 2617) +++ zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-view.xsd 2009-02-05 16:32:10 UTC (rev 2618) @@ -64,6 +64,7 @@ </xsd:complexType> </xsd:element> </xsd:sequence> + <xsd:attribute name="id" type="core:uuidType" use="required" /> </xsd:complexType> </xsd:element> Modified: zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml 2009-02-05 15:29:18 UTC (rev 2617) +++ zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml 2009-02-05 16:32:10 UTC (rev 2618) @@ -491,24 +491,24 @@ <view:diagramPresentation id="1deca0e8-6153-47ad-abe8-ac764f768d96"> <name>全部表示する</name> <view:nodeLayouts> - <view:nodeLayout> - <view:sticky id="43beb884-2562-4480-8030-bb797f701783"> - <view:contents>メモーー</view:contents> - </view:sticky> - <view:boundary color="#0a0b0c" height="-1" width="-1" x="360" y="270"/> - </view:nodeLayout> - <view:nodeLayout> + <view:nodeLayout id="aa7caa23-7958-4bd0-a356-8f09d4b74f08"> <view:nodeObjectRef ref="9f522e56-809c-45fd-8416-39201014218b"/> <view:boundary height="-1" width="-1" x="360" y="60"/> </view:nodeLayout> - <view:nodeLayout> + <view:nodeLayout id="eb6506ef-4a25-4296-b6d7-c08741f19d5a"> <view:nodeObjectRef ref="d7489ed6-0add-443d-95cf-234376eb0455"/> <view:boundary height="-1" width="-1" x="60" y="60"/> </view:nodeLayout> - <view:nodeLayout> + <view:nodeLayout id="2387bfd0-7106-44ad-a34e-24231bbea6d5"> <view:nodeObjectRef ref="516f7961-cb7b-48e2-990b-7fb0c750c3a4"/> <view:boundary height="-1" width="-1" x="60" y="270"/> </view:nodeLayout> + <view:nodeLayout id="2689d193-52a1-4fd4-a14c-9857274518c5"> + <view:sticky id="43beb884-2562-4480-8030-bb797f701783"> + <view:contents>メモーー</view:contents> + </view:sticky> + <view:boundary color="#0a0b0c" height="-1" width="-1" x="360" y="270"/> + </view:nodeLayout> </view:nodeLayouts> <view:connectionLayouts> <view:connectionLayout> @@ -526,11 +526,11 @@ <view:diagramPresentation id="53c7cdb7-1512-46c7-8ee3-aadec6007896"> <name>一部表示する</name> <view:nodeLayouts> - <view:nodeLayout> + <view:nodeLayout id="d71ff015-101c-4669-8745-312d1da34efe"> <view:nodeObjectRef ref="9f522e56-809c-45fd-8416-39201014218b"/> <view:boundary height="-1" width="-1" x="60" y="60"/> </view:nodeLayout> - <view:nodeLayout> + <view:nodeLayout id="2df7718f-d71e-4dbf-8327-e0ad36f03d5d"> <view:nodeObjectRef ref="516f7961-cb7b-48e2-990b-7fb0c750c3a4"/> <view:boundary height="-1" width="-1" x="270" y="270"/> </view:nodeLayout>