svnno****@sourc*****
svnno****@sourc*****
2009年 2月 3日 (火) 19:17:14 JST
Revision: 2610 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2610 Author: daisuke_m Date: 2009-02-03 19:17:14 +0900 (Tue, 03 Feb 2009) Log Message: ----------- view-prefixのXML処理を一部追加。 / テスト拡充。 / refactor Modified Paths: -------------- artemis/trunk/jiemamy-artemis-test/.project artemis/trunk/jiemamy-artemis-test/pom.xml artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/FactoryExtension.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractJiemamyElement.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/ElementReferenceImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/RepresentationAdapter.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/AbstractConstraintModel.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/BuiltinDataTypeImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomParser.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomSerializer.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XpathUtil.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/EqualsUtil.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/RootModelUtil.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/model/DiagramPresentationModelImpl.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/CoreQName.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/Namespaces.java zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-core.xsd zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml Added Paths: ----------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/xml/JiemamyNamespaceContext.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/XpathUtilTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/xml/ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/xml/JiemamyNamespaceContextTest.java -------------- next part -------------- Modified: artemis/trunk/jiemamy-artemis-test/.project =================================================================== --- artemis/trunk/jiemamy-artemis-test/.project 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-artemis-test/.project 2009-02-03 10:17:14 UTC (rev 2610) @@ -34,14 +34,14 @@ </natures> <linkedResources> <link> - <name>.fbprefs</name> + <name>findbugs.xml</name> <type>1</type> - <locationURI>DOCUMENTS/jiemamy-artemis/.fbprefs</locationURI> + <locationURI>DOCUMENTS/jiemamy-artemis/findbugs.xml</locationURI> </link> <link> - <name>findbugs.xml</name> + <name>.fbprefs</name> <type>1</type> - <locationURI>DOCUMENTS/jiemamy-artemis/findbugs.xml</locationURI> + <locationURI>DOCUMENTS/jiemamy-artemis/.fbprefs</locationURI> </link> <link> <name>.checkstyle</name> Modified: artemis/trunk/jiemamy-artemis-test/pom.xml =================================================================== --- artemis/trunk/jiemamy-artemis-test/pom.xml 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-artemis-test/pom.xml 2009-02-03 10:17:14 UTC (rev 2610) @@ -50,6 +50,12 @@ <scope>test</scope> </dependency> <dependency> + <groupId>commons-jxpath</groupId> + <artifactId>commons-jxpath</artifactId> + <version>1.3</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>${project.groupId}</groupId> <artifactId>jiemamy-core</artifactId> <version>${project.version}</version> 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-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -20,6 +20,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.CoreMatchers.nullValue; import static org.junit.Assert.assertThat; import java.io.ByteArrayInputStream; @@ -29,12 +30,13 @@ import java.io.UnsupportedEncodingException; import java.util.Collection; import java.util.List; +import java.util.Map; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.lang.CharEncoding; import org.apache.commons.lang.ClassUtils; -import org.apache.commons.lang.builder.ToStringBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -47,8 +49,12 @@ import org.jiemamy.JiemamyFactory; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.AttributeModel; +import org.jiemamy.model.attribute.ColumnRef; +import org.jiemamy.model.dataset.DataSetModel; +import org.jiemamy.model.dataset.RecordModel; import org.jiemamy.model.datatype.DomainModel; import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.entity.TableRef; import org.jiemamy.model.entity.ViewModel; import org.jiemamy.test.AllValidator; import org.jiemamy.test.TestModelBuilder; @@ -105,6 +111,10 @@ } finally { IOUtils.closeQuietly(out); } + + String xml = out.toString(CharEncoding.UTF_8); + + assertThat(xml, is(notNullValue())); } /** @@ -114,8 +124,6 @@ @Test public void test02_とりあえずXMLから読み込んでみる() throws Exception { Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView())); - TestModelBuilder mb = new ViewTestModelBuilder(jiemamy); - mb.build(); JiemamySerializer serializer = jiemamy.getSerializer(); InputStream in = null; @@ -129,24 +137,38 @@ assertThat(rootModel, is(notNullValue())); + JXPathContext jxpath = JXPathContext.newContext(rootModel); + logger.info("RootModel(Id):" + rootModel.getId()); - assertThat(rootModel.getId().toString(), is("d5a96af3-b1e9-4285-a8ef-c491ce5ae308")); + assertThat(jxpath.getValue("id").toString(), is("d5a96af3-b1e9-4285-a8ef-c491ce5ae308")); logger.info("RootModel(Dialect):" + rootModel.getDialectClassName()); - assertThat(rootModel.getDialectClassName(), is("org.jiemamy.dialect.mysql.MySqlDialect")); + assertThat((String) jxpath.getValue("dialectClassName"), is("org.jiemamy.dialect.mysql.MySqlDialect")); logger.info("RootModel(BeginScript):" + rootModel.getBeginScript()); + assertThat((String) jxpath.getValue("beginScript"), is("BEGIN;")); + logger.info("RootModel(EndScript):" + rootModel.getEndScript()); + assertThat((String) jxpath.getValue("endScript"), is("COMMIT;")); + logger.info("RootModel(Description):" + rootModel.getDescription()); + assertThat((String) jxpath.getValue("description"), is("Jiemamyテストモデル1")); + logger.info("RootModel(SchemaName):" + rootModel.getSchemaName()); + assertThat((String) jxpath.getValue("schemaName"), is("FOO")); - logger.info("***Domain"); + logger.info("***Domains"); List<DomainModel> domains = rootModel.getDomains(); for (DomainModel domain : domains) { - logger.info(" " + ToStringBuilder.reflectionToString(domain)); + logger.info(" " + domain); } + assertThat(domains.size(), is(2)); + assertThat((String) jxpath.getValue("domains[1]/name"), is("ID")); + assertThat(jxpath.getValue("domains[1]/logicalName"), is(nullValue())); + assertThat((String) jxpath.getValue("domains[2]/name"), is("NAME")); + assertThat(jxpath.getValue("domains[2]/logicalName"), is(nullValue())); - logger.info("***Attribute"); + logger.info("***Entities"); Collection<TableModel> tables = RootModelUtil.getEntities(rootModel, TableModel.class); for (TableModel table : tables) { logger.info(" Table:" + table.getId() + "," + table.getName() + "," + table.getLogicalName() + "," @@ -156,12 +178,28 @@ logger.info(" " + attribute); } } + assertThat(tables.size(), is(2)); - logger.info("***View"); Collection<ViewModel> views = RootModelUtil.getEntities(rootModel, ViewModel.class); for (ViewModel view : views) { logger.info(" View:" + view); } + assertThat(views.size(), is(1)); + + logger.info("***DataSets"); + List<DataSetModel> dataSets = rootModel.getDataSets(); + for (DataSetModel dataSet : dataSets) { + logger.info(" DataSet:" + dataSet.getId() + "," + dataSet.getName()); + for (Map.Entry<TableRef, List<RecordModel>> entry : dataSet.getRecords().entrySet()) { + logger.info(" TableRef:" + entry.getKey()); + for (RecordModel recordModel : entry.getValue()) { + for (Map.Entry<ColumnRef, String> e2 : recordModel.getValues().entrySet()) { + logger.info(" " + e2.getKey() + ":" + e2.getValue()); + } + } + } + } + assertThat(dataSets.size(), is(2)); } @Test @@ -183,6 +221,9 @@ // xml1 -> rootModel2 RootModel rootModel2 = convertXmlToRootModel(xml1, serializer2); Collection<Problem> problems2 = validator.validate(rootModel2); + for (Problem problem : problems2) { + logger.warn(problem.getMessage()); + } assertThat(problems2.size(), is(0)); // 一応バリデーションを行っておく // rootModel2 -> xml2 Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/FactoryExtension.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/FactoryExtension.java 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/FactoryExtension.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.TreeMap; import java.util.TreeSet; import java.util.UUID; @@ -152,6 +153,46 @@ /** + * エンティティのソートオーダーを決めるコンパレータ。 + * + * <p>まずFQCNで比較し、同一だったらUUIDで比較。</p> + * + * @author daisuke + */ + protected enum EntityComparator implements Comparator<EntityModel> { + + /** singleton instance */ + INSTANCE; + + public int compare(EntityModel o1, EntityModel o2) { + int classNameComparison = o1.getClass().getName().compareTo(o2.getClass().getName()); + if (classNameComparison != 0) { + return classNameComparison; + } + + return o1.getId().compareTo(o2.getId()); + } + } + + protected static class TableRefComparator implements Comparator<TableRef> { + + private final Jiemamy jiemamy; + + + TableRefComparator(Jiemamy jiemamy) { + this.jiemamy = jiemamy; + + } + + public int compare(TableRef o1, TableRef o2) { + ReferenceResolver resolver = jiemamy.getReferenceResolver(); + TableModel t1 = resolver.resolve(o1); + TableModel t2 = resolver.resolve(o2); + return EntityComparator.INSTANCE.compare(t1, t2); + } + } + + /** * モデルインスタンス生成戦略。 * @author daisuke */ @@ -281,7 +322,8 @@ @Override public <T>T newInstance(Jiemamy jiemamy, UUID id) { DataSetModelImpl insertDataSetModel = new DataSetModelImpl(jiemamy, id); - insertDataSetModel.setRecords(new HashMap<TableRef, List<RecordModel>>()); + insertDataSetModel + .setRecords(new TreeMap<TableRef, List<RecordModel>>(new TableRefComparator(jiemamy))); return (T) insertDataSetModel; } }, @@ -380,27 +422,6 @@ } } - /** - * エンティティのソートオーダーを決めるコンパレータ。 - * - * <p>まずFQCNで比較し、同一だったらUUIDで比較。</p> - * - * @author daisuke - */ - private enum EntityComparator implements Comparator<EntityModel> { - - /** singleton instance */ - INSTANCE; - - public int compare(EntityModel o1, EntityModel o2) { - int classNameComparison = o1.getClass().getName().compareTo(o2.getClass().getName()); - if (classNameComparison != 0) { - return classNameComparison; - } - - return o1.getId().compareTo(o2.getId()); - } - } } // @SuppressWarnings("unchecked") Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractJiemamyElement.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractJiemamyElement.java 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractJiemamyElement.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -21,7 +21,7 @@ import java.util.UUID; import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.jiemamy.Jiemamy; @@ -73,7 +73,13 @@ */ @Override public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + ReflectionToStringBuilder toStringBuilder = + new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); + toStringBuilder.setExcludeFieldNames(new String[] { + "jiemamy" + }); + + return toStringBuilder.toString(); } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/ElementReferenceImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/ElementReferenceImpl.java 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/ElementReferenceImpl.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -20,6 +20,9 @@ import java.util.UUID; +import org.apache.commons.lang.builder.ReflectionToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + import org.jiemamy.Jiemamy; /** @@ -64,4 +67,17 @@ return referenceId; } + /** + * {@inheritDoc} + */ + @Override + public String toString() { + ReflectionToStringBuilder toStringBuilder = + new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); + toStringBuilder.setExcludeFieldNames(new String[] { + "jiemamy" + }); + + return toStringBuilder.toString(); + } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/RepresentationAdapter.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/RepresentationAdapter.java 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/RepresentationAdapter.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -18,6 +18,8 @@ */ package org.jiemamy.model.attribute; +import org.apache.commons.lang.ClassUtils; + import org.jiemamy.model.ModelAdapter; /** @@ -81,4 +83,11 @@ this.representation = representation; } + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return ClassUtils.getShortClassName(this, "null") + "[" + representation + "]"; + } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/AbstractConstraintModel.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/AbstractConstraintModel.java 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/AbstractConstraintModel.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -20,8 +20,6 @@ import java.util.UUID; -import org.apache.commons.lang.ClassUtils; - import org.jiemamy.Jiemamy; import org.jiemamy.model.attribute.AbstractAttributeModel; @@ -42,12 +40,4 @@ super(jiemamy, id); } - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return ClassUtils.getShortClassName(this, "null"); - } - } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/BuiltinDataTypeImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/BuiltinDataTypeImpl.java 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/BuiltinDataTypeImpl.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -21,7 +21,7 @@ import java.lang.reflect.Field; import java.sql.Types; -import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.jiemamy.exception.UnexpectedConditionError; @@ -72,7 +72,13 @@ */ @Override public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + ReflectionToStringBuilder toStringBuilder = + new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); + toStringBuilder.setExcludeFieldNames(new String[] { + "jiemamy" + }); + + return toStringBuilder.toString(); } private void validate(int sqlType) { Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainModelImpl.java 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainModelImpl.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -21,7 +21,6 @@ import java.util.List; import java.util.UUID; -import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.Validate; import org.jiemamy.Jiemamy; @@ -216,12 +215,4 @@ this.name = name; } - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return name + ":" + ObjectUtils.toString(dataType, "null"); - } - } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomParser.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomParser.java 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomParser.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -86,7 +86,7 @@ private static void readAdapter(Element element, Adaptable jiemamyElement) { - NodeList adapterNodeList = XpathUtil.getNodes(element, "adapter"); + NodeList adapterNodeList = XpathUtil.getNodes(element, "core:adapter"); Iterable<Node> adapterIterator = new IterableNodeList(adapterNodeList); for (Node adapterNode : adapterIterator) { @@ -191,8 +191,9 @@ return new DomainRefImpl(jiemamy, DomUtil.getUUID(element, CoreQName.REF)); } else { String sqlTypeString = - (String) XpathUtil.XPATH.evaluate("sqlType/text()", element, XPathConstants.STRING); - String typeName = (String) XpathUtil.XPATH.evaluate("typeName/text()", element, XPathConstants.STRING); + (String) XpathUtil.XPATH.evaluate("core:sqlType/text()", element, XPathConstants.STRING); + String typeName = + (String) XpathUtil.XPATH.evaluate("core:typeName/text()", element, XPathConstants.STRING); int sqlType; try { @@ -215,7 +216,7 @@ } private void parseCheckConstraints(Element tableElement, TableModel tableModel) { - NodeList checkNodeList = XpathUtil.getNodes(tableElement, "attributes/check"); + NodeList checkNodeList = XpathUtil.getNodes(tableElement, "core:attributes/core:check"); Iterable<Node> checkIterableNodeList = new IterableNodeList(checkNodeList); for (Node checkNode : checkIterableNodeList) { if ((checkNode instanceof Element) == false) { @@ -225,16 +226,16 @@ Element checkElement = (Element) checkNode; CheckConstraintModel checkModel = factory.newModel(CheckConstraintModel.class, DomUtil.getUUID(checkNode, CoreQName.ID)); - checkModel.setName(XpathUtil.getText(checkElement, "name/text()")); - checkModel.setLogicalName(XpathUtil.getText(checkElement, "logicalName/text()")); - checkModel.setExpression(XpathUtil.getText(checkElement, "expression/text()")); + checkModel.setName(XpathUtil.getText(checkElement, "core:name/text()")); + checkModel.setLogicalName(XpathUtil.getText(checkElement, "core:logicalName/text()")); + checkModel.setExpression(XpathUtil.getText(checkElement, "core:expression/text()")); readAdapter(checkElement, checkModel); tableModel.getAttributes().add(checkModel); } } private void parseColumns(Element tableElement, TableModel tableModel) { - NodeList columnNodeList = XpathUtil.getNodes(tableElement, "attributes/column"); + NodeList columnNodeList = XpathUtil.getNodes(tableElement, "core:attributes/core:column"); Iterable<Node> columnIterableNodeList = new IterableNodeList(columnNodeList); for (Node columnNode : columnIterableNodeList) { if ((columnNode instanceof Element) == false) { @@ -242,27 +243,27 @@ } Element columnElement = (Element) columnNode; ColumnModel columnModel = factory.newModel(ColumnModel.class, DomUtil.getUUID(columnNode, CoreQName.ID)); - columnModel.setName(XpathUtil.getText(columnElement, "name/text()")); - columnModel.setLogicalName(XpathUtil.getText(columnElement, "logicalName/text()")); - columnModel.setDataType(getDataType((Element) XpathUtil.getNode(columnElement, "dataType"))); - columnModel.setDefaultValue(XpathUtil.getText(columnElement, "defaultValue/text()")); - columnModel.setFreeString(XpathUtil.getText(columnElement, "freeString/text()")); - columnModel.setDescription(XpathUtil.getText(columnElement, "description/text()")); + columnModel.setName(XpathUtil.getText(columnElement, "core:name/text()")); + columnModel.setLogicalName(XpathUtil.getText(columnElement, "core:logicalName/text()")); + columnModel.setDataType(getDataType((Element) XpathUtil.getNode(columnElement, "core:dataType"))); + columnModel.setDefaultValue(XpathUtil.getText(columnElement, "core:defaultValue/text()")); + columnModel.setFreeString(XpathUtil.getText(columnElement, "core:freeString/text()")); + columnModel.setDescription(XpathUtil.getText(columnElement, "core:description/text()")); readAdapter(columnElement, columnModel); tableModel.getAttributes().add(columnModel); } } private void parseDataSetSection(RootModel rootModel) { - NodeList dataSetNodeList = XpathUtil.getNodes(document, "/rootModel/dataSets/dataSet"); + NodeList dataSetNodeList = XpathUtil.getNodes(document, "/core:rootModel/core:dataSets/core:dataSet"); Iterable<Node> dataSetIterableNodeList = new IterableNodeList(dataSetNodeList); for (Node dataSetNode : dataSetIterableNodeList) { DataSetModel dataSetModel = factory.newModel(DataSetModel.class, DomUtil.getUUID(dataSetNode, CoreQName.ID)); - dataSetModel.setName(XpathUtil.getText(dataSetNode, "name/text()")); + dataSetModel.setName(XpathUtil.getText(dataSetNode, "core:name/text()")); - NodeList tableRefNodeList = XpathUtil.getNodes(dataSetNode, "tableRef"); + NodeList tableRefNodeList = XpathUtil.getNodes(dataSetNode, "core:tableRef"); Iterable<Node> tableRefIterableNodeList = new IterableNodeList(tableRefNodeList); for (Node tableRefNode : tableRefIterableNodeList) { @@ -272,13 +273,13 @@ recordModels = new ArrayList<RecordModel>(); } - NodeList recordNodeList = XpathUtil.getNodes(tableRefNode, "record"); + NodeList recordNodeList = XpathUtil.getNodes(tableRefNode, "core:record"); Iterable<Node> recordIterableNodeList = new IterableNodeList(recordNodeList); for (Node recordNode : recordIterableNodeList) { RecordModel recordModel = factory.newModel(RecordModel.class, DomUtil.getUUID(recordNode, CoreQName.ID)); - NodeList columnRefNodeList = XpathUtil.getNodes(recordNode, "columnRef"); + NodeList columnRefNodeList = XpathUtil.getNodes(recordNode, "core:columnRef"); Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList); for (Node columnRefNode : columnRefIterableNodeList) { ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(columnRefNode, CoreQName.REF)); @@ -294,15 +295,15 @@ } private void parseDeferrability(Element keyElement, KeyConstraintModel keyModel) { - Node deferrabilityElement = XpathUtil.getNode(keyElement, "deferrability"); + Node deferrabilityElement = XpathUtil.getNode(keyElement, "core:deferrability"); if (deferrabilityElement != null) { Deferrability deferrability = factory.newModel(Deferrability.class, DomUtil.getUUID(deferrabilityElement, CoreQName.ID)); - String deferrableString = XpathUtil.getText(deferrabilityElement, "deferrable/text()"); + String deferrableString = XpathUtil.getText(deferrabilityElement, "core:deferrable/text()"); deferrability.setDeferrable(BooleanUtils.toBoolean(deferrableString)); - String initiallyCheckTimeString = XpathUtil.getText(deferrabilityElement, "initiallyCheckTime/text()"); + String initiallyCheckTimeString = XpathUtil.getText(deferrabilityElement, "core:initiallyCheckTime/text()"); InitiallyCheckTime initiallyCheckTime = initiallyCheckTimeString == null ? null : InitiallyCheckTime.valueOf(initiallyCheckTimeString); deferrability.setInitiallyCheckTime(initiallyCheckTime); @@ -313,16 +314,17 @@ } private void parseDomainSection(RootModel rootModel) { - NodeList domainsNodeList = XpathUtil.getNodes(document, "/rootModel/domains/domain"); + NodeList domainsNodeList = XpathUtil.getNodes(document, "/core:rootModel/core:domains/core:domain"); Iterable<Node> domainsIterableNodeList = new IterableNodeList(domainsNodeList); for (Node domainNode : domainsIterableNodeList) { DomainModel domainModel = factory.newModel(DomainModel.class, DomUtil.getUUID(domainNode, CoreQName.ID)); - domainModel.setName(XpathUtil.getText(domainNode, "name/text()")); - domainModel.setLogicalName(XpathUtil.getText(domainNode, "logicalName/text()")); - domainModel.setDataType((BuiltinDataType) getDataType((Element) XpathUtil.getNode(domainNode, "dataType"))); - domainModel.setDefaultValue(XpathUtil.getText(domainNode, "defaultValue/text()")); + domainModel.setName(XpathUtil.getText(domainNode, "core:name/text()")); + domainModel.setLogicalName(XpathUtil.getText(domainNode, "core:logicalName/text()")); + domainModel.setDataType((BuiltinDataType) getDataType((Element) XpathUtil.getNode(domainNode, + "core:dataType"))); + domainModel.setDefaultValue(XpathUtil.getText(domainNode, "core:defaultValue/text()")); - NodeList constraintNodeList = XpathUtil.getNodes(domainNode, "constraints/*"); + NodeList constraintNodeList = XpathUtil.getNodes(domainNode, "core:constraints/*"); Iterable<Node> constraintIterableNodeList = new IterableNodeList(constraintNodeList); for (Node constraintNode : constraintIterableNodeList) { if ((constraintNode instanceof Element) == false) { @@ -340,21 +342,21 @@ } else if (constraintElement.getNodeName().equals(CHECK_CONSTRAINT.getQName().getLocalPart())) { CheckConstraintModel checkConstraintModel = factory.newModel(CheckConstraintModel.class, DomUtil.getUUID(constraintNode, CoreQName.ID)); - checkConstraintModel.setExpression(XpathUtil.getText(constraintElement, "expression/text()")); + checkConstraintModel.setExpression(XpathUtil.getText(constraintElement, "core:expression/text()")); constraint = checkConstraintModel; } else { logger.warn("unknown constraint: " + constraintElement.getNodeName()); continue; } - constraint.setName(XpathUtil.getText(constraintElement, "name/text()")); - constraint.setLogicalName(XpathUtil.getText(constraintElement, "logicalName/text()")); + constraint.setName(XpathUtil.getText(constraintElement, "core:name/text()")); + constraint.setLogicalName(XpathUtil.getText(constraintElement, "core:logicalName/text()")); domainModel.getConstraints().add(constraint); } - domainModel.setFreeString(XpathUtil.getText(domainNode, "freeString/text()")); - domainModel.setDescription(XpathUtil.getText(domainNode, "description/text()")); + domainModel.setFreeString(XpathUtil.getText(domainNode, "core:freeString/text()")); + domainModel.setDescription(XpathUtil.getText(domainNode, "core:description/text()")); readAdapter((Element) domainNode, domainModel); rootModel.getDomains().add(domainModel); @@ -362,7 +364,7 @@ } private void parseEntitiesSection(RootModel rootModel) { - NodeList entitityNodeList = XpathUtil.getNodes(document, "/rootModel/entities/*"); + NodeList entitityNodeList = XpathUtil.getNodes(document, "/core:rootModel/core:entities/*"); Iterable<Node> entitityIterableNodeList = new IterableNodeList(entitityNodeList); for (Node entityNode : entitityIterableNodeList) { if ((entityNode instanceof Element) == false) { @@ -387,7 +389,7 @@ } private void parseForeignKeys(Element tableElement, TableModel tableModel) { - NodeList fkNodeList = XpathUtil.getNodes(tableElement, "attributes/foreignKey"); + NodeList fkNodeList = XpathUtil.getNodes(tableElement, "core:attributes/core:foreignKey"); Iterable<Node> fkIterableNodeList = new IterableNodeList(fkNodeList); for (Node fkNode : fkIterableNodeList) { if ((fkNode instanceof Element) == false) { @@ -395,15 +397,15 @@ } Element fkElement = (Element) fkNode; ForeignKeyModel fkModel = factory.newModel(ForeignKeyModel.class, DomUtil.getUUID(fkNode, CoreQName.ID)); - fkModel.setName(XpathUtil.getText(fkElement, "name/text()")); - fkModel.setLogicalName(XpathUtil.getText(fkElement, "logicalName/text()")); - NodeList columnRefNodeList = XpathUtil.getNodes(fkElement, "columnRefs/columnRef"); + fkModel.setName(XpathUtil.getText(fkElement, "core:name/text()")); + fkModel.setLogicalName(XpathUtil.getText(fkElement, "core:logicalName/text()")); + NodeList columnRefNodeList = XpathUtil.getNodes(fkElement, "core:columnRefs/core:columnRef"); Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList); for (Node node : columnRefIterableNodeList) { ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF)); fkModel.getKeyColumns().add(columnRef); } - NodeList referenceColumnRefNodeList = XpathUtil.getNodes(fkElement, "referenceColumns/columnRef"); + NodeList referenceColumnRefNodeList = XpathUtil.getNodes(fkElement, "core:referenceColumns/core:columnRef"); Iterable<Node> referenceColumnRefIterableNodeList = new IterableNodeList(referenceColumnRefNodeList); for (Node node : referenceColumnRefIterableNodeList) { ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF)); @@ -412,11 +414,11 @@ parseDeferrability(fkElement, fkModel); - String onDeleteString = XpathUtil.getText(fkElement, "onDelete/text()"); + String onDeleteString = XpathUtil.getText(fkElement, "core:onDelete/text()"); ReferentialAction onDelete = onDeleteString == null ? null : ReferentialAction.valueOf(onDeleteString); fkModel.setOnDelete(onDelete); - String onUpdateString = XpathUtil.getText(fkElement, "onUpdate/text()"); + String onUpdateString = XpathUtil.getText(fkElement, "core:onUpdate/text()"); ReferentialAction onUpdate = onUpdateString == null ? null : ReferentialAction.valueOf(onUpdateString); fkModel.setOnUpdate(onUpdate); @@ -426,7 +428,7 @@ } private void parseNotNullConstraints(Element tableElement, TableModel tableModel) { - NodeList nnNodeList = XpathUtil.getNodes(tableElement, "attributes/notNull"); + NodeList nnNodeList = XpathUtil.getNodes(tableElement, "core:attributes/core:notNull"); Iterable<Node> nnIterableNodeList = new IterableNodeList(nnNodeList); for (Node nnNode : nnIterableNodeList) { if ((nnNode instanceof Element) == false) { @@ -435,9 +437,9 @@ Element nnElement = (Element) nnNode; NotNullConstraintModel nnModel = factory.newModel(NotNullConstraintModel.class, DomUtil.getUUID(nnNode, CoreQName.ID)); - nnModel.setName(XpathUtil.getText(nnElement, "name/text()")); - nnModel.setLogicalName(XpathUtil.getText(nnElement, "logicalName/text()")); - Node columnRefNode = XpathUtil.getNode(nnElement, "columnRef"); + nnModel.setName(XpathUtil.getText(nnElement, "core:name/text()")); + nnModel.setLogicalName(XpathUtil.getText(nnElement, "core:logicalName/text()")); + Node columnRefNode = XpathUtil.getNode(nnElement, "core:columnRef"); ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(columnRefNode, CoreQName.REF)); nnModel.setColumn(columnRef); @@ -447,7 +449,7 @@ } private void parsePrimaryKey(Element tableElement, TableModel tableModel) { - NodeList pkNodeList = XpathUtil.getNodes(tableElement, "attributes/primaryKey"); + NodeList pkNodeList = XpathUtil.getNodes(tableElement, "core:attributes/core:primaryKey"); Iterable<Node> pkIterableNodeList = new IterableNodeList(pkNodeList); for (Node pkNode : pkIterableNodeList) { if ((pkNode instanceof Element) == false) { @@ -456,9 +458,9 @@ } Element pkElement = (Element) pkNode; PrimaryKeyModel pkModel = factory.newModel(PrimaryKeyModel.class, DomUtil.getUUID(pkNode, CoreQName.ID)); - pkModel.setName(XpathUtil.getText(pkElement, "name/text()")); - pkModel.setLogicalName(XpathUtil.getText(pkElement, "logicalName/text()")); - NodeList columnRefNodeList = XpathUtil.getNodes(pkElement, "columnRefs/columnRef"); + pkModel.setName(XpathUtil.getText(pkElement, "core:name/text()")); + pkModel.setLogicalName(XpathUtil.getText(pkElement, "core:logicalName/text()")); + NodeList columnRefNodeList = XpathUtil.getNodes(pkElement, "core:columnRefs/core:columnRef"); Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList); for (Node node : columnRefIterableNodeList) { ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF)); @@ -476,22 +478,22 @@ Element rootElement = document.getDocumentElement(); RootModel rootModel = factory.getRootModel(DomUtil.getUUID(rootElement, CoreQName.ID)); - rootModel.setDialectClassName(XpathUtil.getText(document, "/rootModel/dialect/text()")); - rootModel.setSchemaName(XpathUtil.getText(document, "/rootModel/schemaName/text()")); - rootModel.setBeginScript(XpathUtil.getText(document, "/rootModel/beginScript/text()")); - rootModel.setEndScript(XpathUtil.getText(document, "/rootModel/endScript/text()")); - rootModel.setDescription(XpathUtil.getText(document, "/rootModel/description/text()")); + rootModel.setDialectClassName(XpathUtil.getText(document, "/core:rootModel/core:dialect/text()")); + rootModel.setSchemaName(XpathUtil.getText(document, "/core:rootModel/core:schemaName/text()")); + rootModel.setBeginScript(XpathUtil.getText(document, "/core:rootModel/core:beginScript/text()")); + rootModel.setEndScript(XpathUtil.getText(document, "/core:rootModel/core:endScript/text()")); + rootModel.setDescription(XpathUtil.getText(document, "/core:rootModel/core:description/text()")); return rootModel; } private TableModel parseTable(Element tableElement) { TableModel tableModel = factory.newModel(TableModel.class, DomUtil.getUUID(tableElement, CoreQName.ID)); - tableModel.setName(XpathUtil.getText(tableElement, "name/text()")); - tableModel.setLogicalName(XpathUtil.getText(tableElement, "logicalName/text()")); - tableModel.setBeginScript(XpathUtil.getText(tableElement, "beginScript/text()")); - tableModel.setEndScript(XpathUtil.getText(tableElement, "endScript/text()")); - tableModel.setDescription(XpathUtil.getText(tableElement, "description/text()")); + tableModel.setName(XpathUtil.getText(tableElement, "core:name/text()")); + tableModel.setLogicalName(XpathUtil.getText(tableElement, "core:logicalName/text()")); + tableModel.setBeginScript(XpathUtil.getText(tableElement, "core:beginScript/text()")); + tableModel.setEndScript(XpathUtil.getText(tableElement, "core:endScript/text()")); + tableModel.setDescription(XpathUtil.getText(tableElement, "core:description/text()")); parseColumns(tableElement, tableModel); parsePrimaryKey(tableElement, tableModel); @@ -505,7 +507,7 @@ } private void parseUniqueKeys(Element tableElement, TableModel tableModel) { - NodeList ukNodeList = XpathUtil.getNodes(tableElement, "attributes/uniqueKey"); + NodeList ukNodeList = XpathUtil.getNodes(tableElement, "core:attributes/uniqueKey"); Iterable<Node> ukIterableNodeList = new IterableNodeList(ukNodeList); for (Node ukNode : ukIterableNodeList) { if ((ukNode instanceof Element) == false) { @@ -513,9 +515,9 @@ } Element ukElement = (Element) ukNode; UniqueKeyModel ukModel = factory.newModel(UniqueKeyModel.class, DomUtil.getUUID(ukNode, CoreQName.ID)); - ukModel.setName(XpathUtil.getText(ukElement, "name/text()")); - ukModel.setLogicalName(XpathUtil.getText(ukElement, "logicalName/text()")); - NodeList columnRefNodeList = XpathUtil.getNodes(ukElement, "columnRefs/columnRef"); + ukModel.setName(XpathUtil.getText(ukElement, "core:name/text()")); + ukModel.setLogicalName(XpathUtil.getText(ukElement, "core:logicalName/text()")); + NodeList columnRefNodeList = XpathUtil.getNodes(ukElement, "core:columnRefs/columnRef"); Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList); for (Node node : columnRefIterableNodeList) { ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF)); @@ -531,12 +533,12 @@ private ViewModel parseView(Element viewElement) { ViewModel viewModel = factory.newModel(ViewModel.class, DomUtil.getUUID(viewElement, CoreQName.ID)); - viewModel.setName(XpathUtil.getText(viewElement, "name/text()")); - viewModel.setLogicalName(XpathUtil.getText(viewElement, "logicalName/text()")); - viewModel.setBeginScript(XpathUtil.getText(viewElement, "beginScript/text()")); - viewModel.setEndScript(XpathUtil.getText(viewElement, "endScript/text()")); - viewModel.setDescription(XpathUtil.getText(viewElement, "description/text()")); - viewModel.setDefinition(XpathUtil.getText(viewElement, "definition/text()")); + viewModel.setName(XpathUtil.getText(viewElement, "core:name/text()")); + viewModel.setLogicalName(XpathUtil.getText(viewElement, "core:logicalName/text()")); + viewModel.setBeginScript(XpathUtil.getText(viewElement, "core:beginScript/text()")); + viewModel.setEndScript(XpathUtil.getText(viewElement, "core:endScript/text()")); + viewModel.setDescription(XpathUtil.getText(viewElement, "core:description/text()")); + viewModel.setDefinition(XpathUtil.getText(viewElement, "core:definition/text()")); readAdapter(viewElement, viewModel); return viewModel; } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomSerializer.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomSerializer.java 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomSerializer.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -67,11 +67,10 @@ + "</xsl:stylesheet>"; static { - // FIXME 名前空間を有効にせよ。→ XPath調整 -// DOCUMENT_BUILDER_FACTORY.setNamespaceAware(true); + DOCUMENT_BUILDER_FACTORY.setNamespaceAware(true); } - private Jiemamy jiemamy; + private final Jiemamy jiemamy; /** @@ -165,4 +164,5 @@ protected RootModel parseDom(Document document) { return new DomParser(jiemamy, document).parse(); } + } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -25,9 +25,9 @@ import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.jiemamy.xml.JiemamyQName; @@ -50,7 +50,9 @@ * @return 値 */ public static String getAttributeString(Element domElement, JiemamyQName node) { - return domElement.getAttributes().getNamedItem(node.getQNameString()).getTextContent(); + Attr attr = XpathUtil.getAttr(domElement, "@" + node.getQNameString()); + return attr.getValue(); +// return domElement.getAttributes().getNamedItem(node.getQNameString()).getTextContent(); } /** @@ -72,16 +74,19 @@ * @return {@link UUID} */ public static UUID getUUID(Node domNode, String attributeName) { - NamedNodeMap attributes = domNode.getAttributes(); + String uuidStr = XpathUtil.getAttr(domNode, "@" + attributeName).getValue(); + return UUIDUtil.valueOfOrRandom(uuidStr); - for (int i = 0; i < attributes.getLength(); i++) { - Node node = attributes.item(i); - if (node.getNodeName().equals(attributeName)) { - return UUIDUtil.valueOfOrRandom(node.getNodeValue()); - } - } - logger.error("uuid attribute not found in this element: " + domNode.getNodeName()); - return null; +// NamedNodeMap attributes = domNode.getAttributes(); +// +// for (int i = 0; i < attributes.getLength(); i++) { +// Node node = attributes.item(i); +// if (node.getNodeName().equals(attributeName)) { +// return UUIDUtil.valueOfOrRandom(node.getNodeValue()); +// } +// } +// logger.error("uuid attribute not found in this element: " + domNode.getNodeName()); +// return null; } /** Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XpathUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XpathUtil.java 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XpathUtil.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -23,12 +23,14 @@ import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; -import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Attr; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.jiemamy.exception.UnexpectedConditionError; -import org.jiemamy.xml.Namespaces; +import org.jiemamy.xml.JiemamyNamespaceContext; /** * XPathを使用するユーティリティクラス。 @@ -40,11 +42,21 @@ /** XPathインスタンス */ public static final XPath XPATH = XPathFactory.newInstance().newXPath(); + private static Logger logger = LoggerFactory.getLogger(XpathUtil.class); + static { - XPATH.setNamespaceContext(new Namespaces.JiemamyNamespaceContext()); + XPATH.setNamespaceContext(new JiemamyNamespaceContext()); } + public static Attr getAttr(Node root, String strExpr) { + try { + return (Attr) XPATH.evaluate(strExpr, root, XPathConstants.NODE); + } catch (XPathExpressionException e) { + throw new UnexpectedConditionError("XPath expression error: " + strExpr, e); + } + } + /** * XPath式で特定される{@link Node}を取得する。 * @@ -85,12 +97,24 @@ public static String getText(Node root, String strExpr) { try { String str = (String) XPATH.evaluate(strExpr, root, XPathConstants.STRING); - return StringUtils.defaultIfEmpty(str, null); + return str; //StringUtils.defaultIfEmpty(str, null); } catch (XPathExpressionException e) { throw new UnexpectedConditionError("XPath expression error: " + strExpr, e); } } + public static String getTextContent(Node root, String strExpr) { + try { + Node node = (Node) XPATH.evaluate(strExpr, root, XPathConstants.NODE); + if (node == null) { + return null; + } + return node.getTextContent(); + } catch (XPathExpressionException e) { + throw new UnexpectedConditionError("XPath expression error: " + strExpr, e); + } + } + private XpathUtil() { } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/EqualsUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/EqualsUtil.java 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/EqualsUtil.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -76,17 +76,8 @@ // コンバータを作る ObjectConverter converter = - CachedObjectConverter.newInstance(Arrays.asList(new JiemamyPropertyConverter(), - new AdapterConverter(), new ReferenceConverter(), new ConverterDriver() { - - public Value convert(Object object, ObjectConverter converter) { - if (object.getClass().getName().endsWith("DiagramPresentationsImpl")) { - return Terminal.of(""); - } - return null; - } - - }, new InterfaceBeanConverter())); + CachedObjectConverter.newInstance(Arrays.asList(new JiemamyPropertyConverter(), new AdapterConverter(), + new ReferenceConverter(), new InterfaceBeanConverter())); // コンバータでモデルをGeneric Treeに変換 Value leftGenericTree = converter.convert(left); @@ -113,20 +104,6 @@ } - private static class JiemamyPropertyConverter implements ConverterDriver { - - /** - * {@inheritDoc} - */ - public Value convert(Object object, ObjectConverter converter) { - if (object instanceof Jiemamy) { - return Terminal.of("<JIEMAMY>"); - } - return null; - } - - } - private static class AdapterConverter implements ConverterDriver { /** @@ -136,6 +113,12 @@ if (object.getClass().getAnnotation(LogicAdapter.class) != null) { return Terminal.of("<LogicAdapter>"); } else if (object.getClass().getAnnotation(ModelAdapter.class) != null) { + for (Class<?> interf : object.getClass().getInterfaces()) { + if (interf.getName().equals("org.jiemamy.model.DiagramPresentationModel")) { + return null; + } + } + List<Entry> entries = new ArrayList<Entry>(); for (Field f : object.getClass().getDeclaredFields()) { f.setAccessible(true); @@ -157,6 +140,20 @@ } + private static class JiemamyPropertyConverter implements ConverterDriver { + + /** + * {@inheritDoc} + */ + public Value convert(Object object, ObjectConverter converter) { + if (object instanceof Jiemamy) { + return Terminal.of("<JIEMAMY>"); + } + return null; + } + + } + private static class ReferenceConverter implements ConverterDriver { /** Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/RootModelUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/RootModelUtil.java 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/RootModelUtil.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -20,16 +20,27 @@ import java.util.Collection; import java.util.List; +import java.util.UUID; +import org.apache.commons.lang.Validate; + import org.jiemamy.dialect.Dialect; import org.jiemamy.exception.ElementNotFoundException; import org.jiemamy.exception.TooManyElementsException; import org.jiemamy.internal.processor.GetEntityProcessor; import org.jiemamy.internal.processor.GetNodesProcessor; +import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.AttributeModel; +import org.jiemamy.model.attribute.constraint.Deferrability; import org.jiemamy.model.attribute.constraint.ForeignKeyModel; +import org.jiemamy.model.attribute.constraint.ValueConstraintModel; +import org.jiemamy.model.dataset.DataSetModel; +import org.jiemamy.model.dataset.RecordModel; +import org.jiemamy.model.datatype.DomainModel; import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.index.IndexModel; import org.jiemamy.utils.CollectionsUtil; import org.jiemamy.utils.ProcessorUtil; @@ -41,6 +52,67 @@ public final class RootModelUtil { /** + * TODO for daisuke + * + * @param refId + * @return + */ + public static JiemamyElement findJiemamyElement(RootModel rootModel, UUID refId) { + Validate.notNull(refId); + for (DomainModel domainModel : rootModel.getDomains()) { + if (domainModel.getId().equals(refId)) { + return domainModel; + } + for (ValueConstraintModel valueConstraintModel : domainModel.getConstraints()) { + if (valueConstraintModel.getId().equals(refId)) { + return valueConstraintModel; + } + } + } + + for (EntityModel entityModel : rootModel.getEntities()) { + if (refId.equals(entityModel.getId())) { + return entityModel; + } + if (entityModel instanceof TableModel) { + TableModel tableModel = (TableModel) entityModel; + for (AttributeModel attributeModel : tableModel.getAttributes()) { + if (refId.equals(attributeModel.getId())) { + return attributeModel; + } + if (attributeModel instanceof ForeignKeyModel) { + ForeignKeyModel foreignKeyModel = (ForeignKeyModel) attributeModel; + Deferrability deferrability = foreignKeyModel.getDeferrability(); + if (deferrability != null && refId.equals(deferrability.getId())) { + return deferrability; + } + } + } + for (IndexModel indexModel : tableModel.getIndexes()) { + if (refId.equals(indexModel.getId())) { + return indexModel; + } + } + } + } + + for (DataSetModel dataSetModel : rootModel.getDataSets()) { + if (refId.equals(dataSetModel.getId())) { + return dataSetModel; + } + for (List<RecordModel> records : dataSetModel.getRecords().values()) { + for (RecordModel recordModel : records) { + if (refId.equals(recordModel.getId())) { + return recordModel; + } + } + } + } + + return null; + } + + /** * この {@link RootModel} 内に存在する全ての外部キーの集合を取得する。 * * @param rootModel 検索対象の{@link RootModel} Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/xml/JiemamyNamespaceContext.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/xml/JiemamyNamespaceContext.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/xml/JiemamyNamespaceContext.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -0,0 +1,41 @@ +package org.jiemamy.xml; + +import java.util.Arrays; +import java.util.Iterator; + +import javax.xml.namespace.NamespaceContext; + +/** + * TODO for daisuke + * + * @author daisuke + */ +public class JiemamyNamespaceContext implements NamespaceContext { + + public String getNamespaceURI(String prefix) { + for (Namespaces ns : Namespaces.values()) { + if (prefix.equals(ns.prefix)) { + return ns.namespaceURI; + } + } + return null; + } + + public String getPrefix(String namespaceURI) { + for (Namespaces ns : Namespaces.values()) { + if (namespaceURI.equals(ns.namespaceURI)) { + return ns.prefix; + } + } + return null; + } + + @SuppressWarnings("unchecked") + public Iterator getPrefixes(String namespaceURI) { + String p = getPrefix(namespaceURI); + if (p != null) { + return Arrays.asList(p).iterator(); + } + return null; + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/xml/JiemamyNamespaceContext.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/XpathUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/XpathUtilTest.java (rev 0) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/XpathUtilTest.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -0,0 +1,135 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/03 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.utils; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; + +import java.io.ByteArrayInputStream; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Document; + +/** + * TODO for daisuke + * + * @author daisuke + */ +public class XpathUtilTest { + + private static Logger logger = LoggerFactory.getLogger(XpathUtilTest.class); + + private static final String XML = // + "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" // + + "<root xmlns=\"http://jiemamy.org/xml/ns/core\" xmlns:view=\"http://jiemamy.org/xml/ns/view\">\n" // + + " <foobar id=\"1\">foo</foobar>\n" // + + " <foobar id=\"2\">bar</foobar>\n" // + + " <view:hogefuga id=\"3\">hoge</view:hogefuga>\n" // + + " <view:hogefuga id=\"4\">fuga</view:hogefuga>\n" // + + " <content id=\"5\">unba</content>\n" // + + " <empty id=\"5\"></empty>\n" // + + " <nul id=\"6\"/>\n" // + + "</root>\n"; + + private Document document; + + + /** + * setup + * + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + documentBuilderFactory.setNamespaceAware(true); + DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); + document = documentBuilder.parse(new ByteArrayInputStream(XML.getBytes("UTF-8"))); + } + + /** + * teardown + * + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + document = null; + } + + /** + * デフォルトNamespaceのノードが取得できる。 + * + * @throws Exception + */ + @Test + public void test01_デフォルトNamespaceの要素が取得できる() throws Exception { + assertThat(XpathUtil.getNode(document, "/core:root"), is(notNullValue())); + assertThat(XpathUtil.getNodes(document, "//core:foobar").getLength(), is(2)); + assertThat(XpathUtil.getNode(document, "/core:root/core:foobar[1]"), is(notNullValue())); + assertThat(XpathUtil.getNode(document, "/core:root/core:foobar[2]"), is(notNullValue())); + assertThat(XpathUtil.getNode(document, "/core:root/core:foobar[3]"), is(nullValue())); + + assertThat(XpathUtil.getText(document, "/core:root/core:foobar[1]/text()"), is("foo")); + assertThat(XpathUtil.getText(document, "/core:root/core:foobar[2]/text()"), is("bar")); + } + + /** + * 特定Namespaceのノードが取得できる。 + * + * @throws Exception + */ + @Test + public void test02_特定Namespaceのノードが要素できる() throws Exception { + assertThat(XpathUtil.getNodes(document, "//view:hogefuga").getLength(), is(2)); + assertThat(XpathUtil.getNode(document, "/core:root/view:hogefuga[1]"), is(notNullValue())); + assertThat(XpathUtil.getNode(document, "/core:root/view:hogefuga[2]"), is(notNullValue())); + assertThat(XpathUtil.getNode(document, "/core:root/view:hogefuga[3]"), is(nullValue())); + + assertThat(XpathUtil.getText(document, "/core:root/view:hogefuga[1]/text()"), is("hoge")); + assertThat(XpathUtil.getText(document, "/core:root/view:hogefuga[2]/text()"), is("fuga")); + } + + @Test + public void test03_() throws Exception { + assertThat(XpathUtil.getNode(document, "/core:root/core:foobar[1]/@id").getTextContent(), is("1")); + assertThat(XpathUtil.getNode(document, "/core:root/core:foobar[2]/@id").getTextContent(), is("2")); + assertThat(XpathUtil.getNode(document, "/core:root/view:hogefuga[1]/@id").getTextContent(), is("3")); + } + + @Test + public void test04() throws Exception { + assertThat(XpathUtil.getText(document, "/core:root/core:content/text()"), is("unba")); + assertThat(XpathUtil.getText(document, "/core:root/core:empty/text()"), is("")); + assertThat(XpathUtil.getText(document, "/core:root/core:nul/text()"), is("")); + + assertThat(XpathUtil.getTextContent(document, "/core:root/core:content"), is("unba")); + assertThat(XpathUtil.getTextContent(document, "/core:root/core:empty"), is("")); + assertThat(XpathUtil.getTextContent(document, "/core:root/core:nul"), is(nullValue())); + } +} Property changes on: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/XpathUtilTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/xml/JiemamyNamespaceContextTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/xml/JiemamyNamespaceContextTest.java (rev 0) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/xml/JiemamyNamespaceContextTest.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -0,0 +1,69 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/03 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.xml; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * TODO for daisuke + * + * @author daisuke + */ +public class JiemamyNamespaceContextTest { + + private JiemamyNamespaceContext ctx; + + + /** + * TODO for daisuke + * + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + ctx = new JiemamyNamespaceContext(); + } + + /** + * TODO for daisuke + * + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + ctx = null; + } + + @Test + public void testname() throws Exception { + assertThat(ctx.getNamespaceURI(""), is("http://jiemamy.org/xml/ns/core")); + assertThat(ctx.getNamespaceURI("core"), is("http://jiemamy.org/xml/ns/core")); + assertThat(ctx.getPrefix("http://jiemamy.org/xml/ns/core"), is("")); + + assertThat(ctx.getNamespaceURI("view"), is("http://jiemamy.org/xml/ns/view")); + assertThat(ctx.getPrefix("http://jiemamy.org/xml/ns/view"), is("view")); + + } +} Property changes on: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/xml/JiemamyNamespaceContextTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain 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-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewDomSerializerEnhancer.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -17,6 +17,7 @@ import java.util.List; import java.util.Map; +import java.util.UUID; import javax.xml.parsers.ParserConfigurationException; @@ -42,6 +43,7 @@ import org.jiemamy.utils.XpathUtil; import org.jiemamy.utils.enhancer.Invocation; import org.jiemamy.utils.enhancer.InvocationHandler; +import org.jiemamy.utils.model.RootModelUtil; import org.jiemamy.xml.CoreQName; import org.jiemamy.xml.ViewQName; @@ -68,6 +70,8 @@ private static Logger logger = LoggerFactory.getLogger(ViewDomSerializer.class); + private Jiemamy jiemamy; + /** * インスタンスを生成する。 @@ -76,6 +80,7 @@ */ public ViewDomSerializer(Jiemamy jiemamy) { super(jiemamy); + this.jiemamy = jiemamy; logger.info("JiemamyDomSerializer extended by Jiemamy VIEW Specification"); } @@ -135,15 +140,49 @@ @Override protected RootModel parseDom(Document document) { RootModel rootModel = super.parseDom(document); - NodeList dpNodeList = XpathUtil.getNodes(document.getDocumentElement(), "//diagramPresentation"); + NodeList dpNodeList = + XpathUtil.getNodes(document, "/core:rootModel/view:diagramPresentations/view:diagramPresentation"); Iterable<Node> dpNodeListIterable = new IterableNodeList(dpNodeList); logger.debug("presentation count = " + dpNodeList.getLength()); - for (Node node : dpNodeListIterable) { - if ((node instanceof Element) == false) { + + JiemamyFactory factory = jiemamy.getFactory(); + + for (Node dpNode : dpNodeListIterable) { + if ((dpNode instanceof Element) == false) { continue; } - Element e = (Element) node; - logger.debug(e.getTagName()); + Element dpElement = (Element) dpNode; + DiagramPresentationModel presentation = + factory.newModel(DiagramPresentationModel.class, DomUtil.getUUID(dpElement, CoreQName.ID)); + presentation.setName(XpathUtil.getText(dpElement, "core:name/text()")); + + NodeList nodeNodeList = XpathUtil.getNodes(dpElement, "view:node"); + Iterable<Node> nodeNodeListIterable = new IterableNodeList(nodeNodeList); + for (Node nodeNode : nodeNodeListIterable) { + UUID refId = DomUtil.getUUID(nodeNode, CoreQName.REF); + JiemamyElement jElement = RootModelUtil.findJiemamyElement(rootModel, refId); + if (jElement == null) { + logger.error("null element: " + refId.toString()); + continue; + } + NodeAdapter nodeAdapter = jElement.getAdapter(NodeAdapter.class); + if (nodeAdapter == null) { + logger.error("null node: " + jElement.getId().toString()); + continue; + } + JmRectangle rect = new JmRectangle(// + Integer.valueOf(XpathUtil.getAttr(nodeNode, "@x").getValue()), // + Integer.valueOf(XpathUtil.getAttr(nodeNode, "@y").getValue()), // + Integer.valueOf(XpathUtil.getAttr(nodeNode, "@width").getValue()), // + Integer.valueOf(XpathUtil.getAttr(nodeNode, "@height").getValue())); + presentation.setConstraint(nodeAdapter, rect); + } + presentation.setName(XpathUtil.getText(dpElement, "core:name/text()")); + + // TODO +// presentation.setBendpoints(connection, bendpoints); + + rootModel.getAdapter(DiagramPresentations.class).add(presentation); } // TODO return rootModel; 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-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewFactoryExtensionEnhancer.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -16,9 +16,12 @@ package org.jiemamy; import java.util.ArrayList; +import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.TreeMap; +import java.util.TreeSet; import java.util.UUID; import org.jiemamy.model.DiagramPresentationModel; @@ -81,8 +84,8 @@ presentation.setConnectionLayouts(new HashMap<ConnectionAdapter, List<JmPoint>>()); presentation.setDisplayTargetSet(new HashSet<DisplayItem>()); presentation.setNodeColors(new HashMap<NodeAdapter, JmColor>()); - presentation.setNodeLayouts(new HashMap<NodeAdapter, JmRectangle>()); - presentation.setNodes(new ArrayList<NodeAdapter>()); + presentation.setNodeLayouts(new TreeMap<NodeAdapter, JmRectangle>(NodeComparator.INSTANCE)); + presentation.setNodes(new TreeSet<NodeAdapter>(NodeComparator.INSTANCE)); product = clazz.cast(presentation); } else if (clazz == StickyModel.class) { assert product == null; @@ -92,4 +95,32 @@ return product; } } + + /** + * エンティティのソートオーダーを決めるコンパレータ。 + * + * <p>まずFQCNで比較し、同一だったらUUIDで比較。</p> + * + * @author daisuke + */ + protected enum NodeComparator implements Comparator<NodeAdapter> { + + /** singleton instance */ + INSTANCE; + + public int compare(NodeAdapter o1, NodeAdapter o2) { + EntityModel e1 = o1.unwrap(); + EntityModel e2 = o2.unwrap(); + if (e1 != null && e2 != null) { + return FactoryExtension.EntityComparator.INSTANCE.compare(e1, e2); + } else if (e1 != null) { + return 1; + } else if (e2 != null) { + return -1; + } else { + return 0; + } + } + } + } Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/DiagramPresentationModelImpl.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/DiagramPresentationModelImpl.java 2009-02-02 23:10:47 UTC (rev 2609) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/DiagramPresentationModelImpl.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -27,8 +27,6 @@ import java.util.UUID; import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; import org.jiemamy.Jiemamy; import org.jiemamy.internal.processor.ResetBendpointProcessor; @@ -245,14 +243,6 @@ this.nodes = nodes; } - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - private class NodesProxy extends AbstractCollection<NodeAdapter> implements Collection<NodeAdapter> { Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/CoreQName.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/CoreQName.java 2009-02-02 23:10:47 UTC (rev 2609) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/CoreQName.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -170,13 +170,13 @@ // -------- Attributes /***/ - ID(Namespaces.DEFAULT, "id"), + ID(Namespaces.NONE, "id"), /***/ - REF(Namespaces.DEFAULT, "ref"), + REF(Namespaces.NONE, "ref"), /***/ - CLASS(Namespaces.DEFAULT, "class"); + CLASS(Namespaces.NONE, "class"); /** XML仕様における完全修飾名 */ private final QName qName; Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/Namespaces.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/Namespaces.java 2009-02-02 23:10:47 UTC (rev 2609) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/Namespaces.java 2009-02-03 10:17:14 UTC (rev 2610) @@ -18,11 +18,6 @@ */ package org.jiemamy.xml; -import java.util.Arrays; -import java.util.Iterator; - -import javax.xml.namespace.NamespaceContext; - /** * XML名前空間定数クラス。 * @author daisuke @@ -41,14 +36,17 @@ /** Jiemamy core specifications */ NS_CORE("", "http://jiemamy.org/xml/ns/core"), + /** Jiemamy core specifications */ + NS_DEFAULT("core", "http://jiemamy.org/xml/ns/core"), + /** Jiemamy view specifications */ NS_VIEW("view", "http://jiemamy.org/xml/ns/view"), /** Jiemamy diff specifications */ NS_DIFF("diff", "http://jiemamy.org/xml/ns/diff"), - /** default namespace */ - DEFAULT("", ""); + /** */ + NONE("", ""); /** 名前空間prefix */ public final String prefix; @@ -61,40 +59,4 @@ this.prefix = prefix; this.namespaceURI = namespaceURI; } - - - /** - * TODO for daisuke - * - * @author daisuke - */ - public static class JiemamyNamespaceContext implements NamespaceContext { - - public String getNamespaceURI(String prefix) { - for (Namespaces ns : Namespaces.values()) { - if (prefix.equals(ns.prefix)) { - return ns.namespaceURI; - } - } - return null; - } - - public String getPrefix(String namespaceURI) { - for (Namespaces ns : Namespaces.values()) { - if (namespaceURI.equals(ns.namespaceURI)) { - return ns.prefix; - } - } - return null; - } - - @SuppressWarnings("unchecked") - public Iterator getPrefixes(String namespaceURI) { - String p = getPrefix(namespaceURI); - if (p != null) { - return Arrays.asList(p).iterator(); - } - return null; - } - } } Modified: zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-core.xsd =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-core.xsd 2009-02-02 23:10:47 UTC (rev 2609) +++ zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-core.xsd 2009-02-03 10:17:14 UTC (rev 2610) @@ -12,6 +12,9 @@ <xsd:documentation source="description" xml:lang="ja-JP">Jiemamyモデルスキーマ</xsd:documentation> </xsd:annotation> + <!-- TODO nullValueの設定 --> + <xsd:element name="nullValue"/> + <xsd:element name="rootModel"> <xsd:complexType> <xsd:sequence maxOccurs="1" minOccurs="1"> @@ -401,7 +404,6 @@ <xsd:element name="defaultValue" type="xsd:string" /> <xsd:element name="freeString" type="xsd:string" /> - <!-- 単純型 --> <xsd:simpleType name="uuidType"> Modified: zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml 2009-02-02 23:10:47 UTC (rev 2609) +++ zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml 2009-02-03 10:17:14 UTC (rev 2610) @@ -298,32 +298,6 @@ <dataSets> <dataSet id="b73100b5-2d70-4b48-a825-311eacb63b2f"> <name>データ群en</name> - <tableRef ref="d7489ed6-0add-443d-95cf-234376eb0455"> - <record id="176bfb08-99cb-4c76-bf8e-6979e0c7afb9"> - <columnRef ref="c7ed225d-92a6-4cc2-90de-60531804464e">1</columnRef> - <columnRef ref="2d951389-6bc7-49d7-8631-1d26fe17047e">10</columnRef> - <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">ACCOUNTING</columnRef> - <columnRef ref="7bf79e76-07b8-43b6-a993-b8ef374a31f5">NEW YORK</columnRef> - </record> - <record id="3971430b-ef1d-4e5a-b996-f2acfa7536c0"> - <columnRef ref="c7ed225d-92a6-4cc2-90de-60531804464e">2</columnRef> - <columnRef ref="2d951389-6bc7-49d7-8631-1d26fe17047e">20</columnRef> - <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">RESEARCH</columnRef> - <columnRef ref="7bf79e76-07b8-43b6-a993-b8ef374a31f5">DALLAS</columnRef> - </record> - <record id="0591cc1e-45a6-4598-b85a-20fae51b7991"> - <columnRef ref="c7ed225d-92a6-4cc2-90de-60531804464e">3</columnRef> - <columnRef ref="2d951389-6bc7-49d7-8631-1d26fe17047e">30</columnRef> - <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">SALES</columnRef> - <columnRef ref="7bf79e76-07b8-43b6-a993-b8ef374a31f5">CHICAGO</columnRef> - </record> - <record id="ac275955-4710-484a-b694-f7acc6ded08f"> - <columnRef ref="c7ed225d-92a6-4cc2-90de-60531804464e">4</columnRef> - <columnRef ref="2d951389-6bc7-49d7-8631-1d26fe17047e">40</columnRef> - <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">OPERATIONS</columnRef> - <columnRef ref="7bf79e76-07b8-43b6-a993-b8ef374a31f5">BOSTON</columnRef> - </record> - </tableRef> <tableRef ref="9f522e56-809c-45fd-8416-39201014218b"> <record id="6ce22d69-bd75-4822-946f-a51221fd45eb"> <columnRef ref="44c8e93d-b7ad-46cc-9b29-88c3a7d6c33e">1</columnRef> @@ -398,34 +372,35 @@ <columnRef ref="4ae69b7a-7a0e-422a-89dc-0f0cff77565b">2</columnRef> </record> </tableRef> - </dataSet> - <dataSet id="91246ed4-1ef3-440e-bf12-40fa4439a71b"> - <name>データ群ja</name> <tableRef ref="d7489ed6-0add-443d-95cf-234376eb0455"> - <record id="61671217-d61c-4f42-9985-4f6b2c970171"> + <record id="176bfb08-99cb-4c76-bf8e-6979e0c7afb9"> <columnRef ref="c7ed225d-92a6-4cc2-90de-60531804464e">1</columnRef> <columnRef ref="2d951389-6bc7-49d7-8631-1d26fe17047e">10</columnRef> - <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">経理部</columnRef> - <columnRef ref="7bf79e76-07b8-43b6-a993-b8ef374a31f5">広島</columnRef> + <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">ACCOUNTING</columnRef> + <columnRef ref="7bf79e76-07b8-43b6-a993-b8ef374a31f5">NEW YORK</columnRef> </record> - <record id="171d019e-163f-42f6-82dc-15340798fdf4"> + <record id="3971430b-ef1d-4e5a-b996-f2acfa7536c0"> <columnRef ref="c7ed225d-92a6-4cc2-90de-60531804464e">2</columnRef> <columnRef ref="2d951389-6bc7-49d7-8631-1d26fe17047e">20</columnRef> - <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">研究開発部</columnRef> - <columnRef ref="7bf79e76-07b8-43b6-a993-b8ef374a31f5">京都</columnRef> + <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">RESEARCH</columnRef> + <columnRef ref="7bf79e76-07b8-43b6-a993-b8ef374a31f5">DALLAS</columnRef> </record> - <record id="838344e6-093d-4202-aaca-bacf1a7ff376"> + <record id="0591cc1e-45a6-4598-b85a-20fae51b7991"> <columnRef ref="c7ed225d-92a6-4cc2-90de-60531804464e">3</columnRef> <columnRef ref="2d951389-6bc7-49d7-8631-1d26fe17047e">30</columnRef> - <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">営業部</columnRef> - <columnRef ref="7bf79e76-07b8-43b6-a993-b8ef374a31f5">東京</columnRef> + <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">SALES</columnRef> + <columnRef ref="7bf79e76-07b8-43b6-a993-b8ef374a31f5">CHICAGO</columnRef> </record> - <record id="2f29bb19-0a20-4251-8052-568194e6101c"> + <record id="ac275955-4710-484a-b694-f7acc6ded08f"> <columnRef ref="c7ed225d-92a6-4cc2-90de-60531804464e">4</columnRef> <columnRef ref="2d951389-6bc7-49d7-8631-1d26fe17047e">40</columnRef> - <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">経営本部</columnRef> + <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">OPERATIONS</columnRef> + <columnRef ref="7bf79e76-07b8-43b6-a993-b8ef374a31f5">BOSTON</columnRef> </record> </tableRef> + </dataSet> + <dataSet id="91246ed4-1ef3-440e-bf12-40fa4439a71b"> + <name>データ群ja</name> <tableRef ref="9f522e56-809c-45fd-8416-39201014218b"> <record id="9365e670-1eff-4a23-90bd-f794b9742b10"> <columnRef ref="44c8e93d-b7ad-46cc-9b29-88c3a7d6c33e">1</columnRef> @@ -500,6 +475,31 @@ <columnRef ref="4ae69b7a-7a0e-422a-89dc-0f0cff77565b">2</columnRef> </record> </tableRef> + <tableRef ref="d7489ed6-0add-443d-95cf-234376eb0455"> + <record id="61671217-d61c-4f42-9985-4f6b2c970171"> + <columnRef ref="c7ed225d-92a6-4cc2-90de-60531804464e">1</columnRef> + <columnRef ref="2d951389-6bc7-49d7-8631-1d26fe17047e">10</columnRef> + <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">経理部</columnRef> + <columnRef ref="7bf79e76-07b8-43b6-a993-b8ef374a31f5">広島</columnRef> + </record> + <record id="171d019e-163f-42f6-82dc-15340798fdf4"> + <columnRef ref="c7ed225d-92a6-4cc2-90de-60531804464e">2</columnRef> + <columnRef ref="2d951389-6bc7-49d7-8631-1d26fe17047e">20</columnRef> + <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">研究開発部</columnRef> + <columnRef ref="7bf79e76-07b8-43b6-a993-b8ef374a31f5">京都</columnRef> + </record> + <record id="838344e6-093d-4202-aaca-bacf1a7ff376"> + <columnRef ref="c7ed225d-92a6-4cc2-90de-60531804464e">3</columnRef> + <columnRef ref="2d951389-6bc7-49d7-8631-1d26fe17047e">30</columnRef> + <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">営業部</columnRef> + <columnRef ref="7bf79e76-07b8-43b6-a993-b8ef374a31f5">東京</columnRef> + </record> + <record id="2f29bb19-0a20-4251-8052-568194e6101c"> + <columnRef ref="c7ed225d-92a6-4cc2-90de-60531804464e">4</columnRef> + <columnRef ref="2d951389-6bc7-49d7-8631-1d26fe17047e">40</columnRef> + <columnRef ref="1fcd63d3-974e-4d2e-a0d8-3b9c233104d9">経営本部</columnRef> + </record> + </tableRef> </dataSet> </dataSets> <view:diagramPresentations xmlns:view="http://jiemamy.org/xml/ns/view"> @@ -510,15 +510,15 @@ <view:contents>メモーー</view:contents> </view:sticky> </view:nodes> - <view:node height="-1" ref="43beb884-2562-4480-8030-bb797f701783" width="-1" x="360" y="270" color="#ff00ff"/> <view:node height="-1" ref="9f522e56-809c-45fd-8416-39201014218b" width="-1" x="360" y="60" color="#ff00ff"/> <view:node height="-1" ref="d7489ed6-0add-443d-95cf-234376eb0455" width="-1" x="60" y="60" color="#ff00ff"/> <view:node height="-1" ref="516f7961-cb7b-48e2-990b-7fb0c750c3a4" width="-1" x="60" y="270" color="#ff00ff"/> - <view:connection ref="e7dd92b4-1d97-4be6-bab6-fa9fe26eb6ed"/> + <view:node height="-1" ref="43beb884-2562-4480-8030-bb797f701783" width="-1" x="360" y="270" color="#ff00ff"/> <view:connection ref="e43d3c43-33c8-4b02-aa42-83f2d868cfe6"> <view:bendpoint x="310" y="60"/> <view:bendpoint x="360" y="10"/> </view:connection> + <view:connection ref="e7dd92b4-1d97-4be6-bab6-fa9fe26eb6ed"/> </view:diagramPresentation> <view:diagramPresentation id="53c7cdb7-1512-46c7-8ee3-aadec6007896"> <name>一部表示する</name>