Repository: incubator-ignite Updated Branches: refs/heads/ignite-32 d3a70694a -> 7e954e409
# IGNITE-32 WIP: minor fixes in xml generation. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7e954e40 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7e954e40 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7e954e40 Branch: refs/heads/ignite-32 Commit: 7e954e40909cf585bb5c29d67fe6d763d58452e2 Parents: d3a7069 Author: AKuznetsov <akuznet...@gridgain.com> Authored: Thu Dec 25 11:43:43 2014 +0700 Committer: AKuznetsov <akuznet...@gridgain.com> Committed: Thu Dec 25 11:43:43 2014 +0700 ---------------------------------------------------------------------- .../query/GridCacheQueryTypeDescriptor.java | 7 ++ .../ignite/schema/xml/XmlTransformer.java | 73 +++++++++----------- 2 files changed, 40 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7e954e40/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeDescriptor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeDescriptor.java b/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeDescriptor.java index 675795d..3f31b2b 100644 --- a/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeDescriptor.java +++ b/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeDescriptor.java @@ -26,6 +26,13 @@ public class GridCacheQueryTypeDescriptor { private int dbType; /** + * Default constructor. + */ + public GridCacheQueryTypeDescriptor() { + // No-op. + } + + /** * @param javaName Field name in java object. * @param javaType Field java type. * @param dbName Column name in database. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7e954e40/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java ---------------------------------------------------------------------- diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java b/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java index 18ece72..ae97420 100644 --- a/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java +++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java @@ -91,17 +91,19 @@ public class XmlTransformer { * * @param parent Parent XML node. * @param tagName XML tag name. - * @param name Value for "name" attribute. - * @param val Value for "value" attribute. + * @param attr1 Name for first attr. + * @param val1 Value for first attribute. + * @param attr2 Name for second attr. + * @param val2 Value for second attribute. */ - private Element addElement(Node parent, String tagName, String name, String val) { + private Element addElement(Node parent, String tagName, String attr1, String val1, String attr2, String val2) { Element elem = doc.createElement(tagName); - if (name != null) - elem.setAttribute("name", name); + if (attr1 != null) + elem.setAttribute(attr1, val1); - if (val != null) - elem.setAttribute("value", val); + if (attr2 != null) + elem.setAttribute(attr2, val2); parent.appendChild(elem); @@ -115,28 +117,17 @@ public class XmlTransformer { * @param tagName XML tag name. */ private Element addElement(Node parent, String tagName) { - return addElement(parent, tagName, null, null); + return addElement(parent, tagName, null, null, null, null); } /** - * Add property to xml document. - * - * @param parent Parent element. - * @param name Property name. - * @param val Property value. - */ - private Element addProperty(Node parent, String name, String val) { - return addElement(parent, "property", name, val); - } - - /** - * Add property to xml document. + * Add element to XML document. * * @param parent Parent XML node. - * @param name Property name. + * @param tagName XML tag name. */ - private Element addProperty(Node parent, String name) { - return addProperty(parent, name, null); + private Element addElement(Node parent, String tagName, String attrName, String attrVal) { + return addElement(parent, tagName, attrName, attrVal, null, null); } /** @@ -148,12 +139,12 @@ public class XmlTransformer { */ private void addFields(Node parent, String name, Map<String, Class<?>> fields) { if (!fields.isEmpty()) { - Element prop = addProperty(parent, name); + Element prop = addElement(parent, "property", "name", name); Element map = addElement(prop, "map"); for(Map.Entry<String, Class<?>> item : fields.entrySet()) - addElement(map, "entry", item.getKey(), item.getValue().getName()); + addElement(map, "entry", "key", item.getKey(), "value", item.getValue().getName()); } } @@ -166,17 +157,17 @@ public class XmlTransformer { */ private void addTypeDescriptors(Node parent, String name, Collection<GridCacheQueryTypeDescriptor> descs) { if (!descs.isEmpty()) { - Element prop = addProperty(parent, name); + Element prop = addElement(parent, "property", "name", name); Element list = addElement(prop, "list"); for (GridCacheQueryTypeDescriptor desc : descs) { Element item = addBean(list, GridCacheQueryTypeDescriptor.class); - addProperty(item, "javaName", desc.getJavaName()); - addProperty(item, "javaType", desc.getJavaType().getName()); - addProperty(item, "dbName", desc.getDbName()); - addProperty(item, "dbType", String.valueOf(desc.getDbType())); + addElement(item, "property", "name", "javaName", "value", desc.getJavaName()); + addElement(item, "property", "name", "javaType", "value", desc.getJavaType().getName()); + addElement(item, "property", "name", "dbName", "value", desc.getDbName()); + addElement(item, "property", "name", "dbType", "value", String.valueOf(desc.getDbType())); } } } @@ -188,7 +179,7 @@ public class XmlTransformer { */ private void addTextFields(Node parent, Collection<String> textFields) { if (!textFields.isEmpty()) { - Element prop = addProperty(parent, "textFields"); + Element prop = addElement(parent, "property", "name", "textFields"); Element list = addElement(prop, "list"); @@ -204,7 +195,7 @@ public class XmlTransformer { */ private void addGroups(Node parent, Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> groups) { if (!F.isEmpty(groups)) { - Element prop = addProperty(parent, "groups"); + Element prop = addElement(parent, "property", "name", "groups"); Element map = addElement(prop, "map"); @@ -216,16 +207,18 @@ public class XmlTransformer { LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>> fields = group.getValue(); for(Map.Entry<String, IgniteBiTuple<Class<?>, Boolean>> field : fields.entrySet()) { - Element entry2 = addElement(val1, "entry", field.getKey(), null); + Element entry2 = addElement(val1, "entry", "key", field.getKey(), null, null); Element val2 = addBean(entry2, IgniteBiTuple.class); - Class<?> clazz = field.getValue().get1(); + IgniteBiTuple<Class<?>, Boolean> tuple = field.getValue(); + + Class<?> clazz = tuple.get1(); assert clazz != null; - addProperty(val2, "1", field.getValue().get1().getCanonicalName()); - addProperty(val2, "2", String.valueOf(field.getValue().get2())); + addElement(val2, "constructor-arg", "type", "java.lang.Class", "value", clazz.getName()); + addElement(val2, "constructor-arg", "type", "java.lang.Boolean", "value", String.valueOf(tuple.get2())); } } } @@ -240,13 +233,13 @@ public class XmlTransformer { private void addCacheQueryTypeMetadata(Node parent, GridCacheQueryTypeMetadata meta) { Element bean = addBean(parent, GridCacheQueryTypeMetadata.class); - addProperty(bean, "type", meta.getType()); + addElement(bean, "property", "type", meta.getType()); - addProperty(bean, "keyType", meta.getKeyType()); + addElement(bean, "property", "keyType", meta.getKeyType()); - addProperty(bean, "schema", meta.getSchema()); + addElement(bean, "property", "schema", meta.getSchema()); - addProperty(bean, "tableName", meta.getTableName()); + addElement(bean, "property", "tableName", meta.getTableName()); addTypeDescriptors(bean, "keyDescriptors", meta.getKeyDescriptors());