Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java @ 1950:37a7b3841565
Include state data items in description document of collection.
flys-artifacts/trunk@3343 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 02 Dec 2011 11:01:11 +0000 |
parents | 65f9d707caff |
children | 3c3e81fca092 |
comparison
equal
deleted
inserted
replaced
1949:d04cc7e4b55d | 1950:37a7b3841565 |
---|---|
51 private static Logger log = Logger.getLogger(FLYSArtifactCollection.class); | 51 private static Logger log = Logger.getLogger(FLYSArtifactCollection.class); |
52 | 52 |
53 /** Constant XPath that points to the outputmodes of an artifact. */ | 53 /** Constant XPath that points to the outputmodes of an artifact. */ |
54 public static final String XPATH_ARTIFACT_OUTPUTMODES = | 54 public static final String XPATH_ARTIFACT_OUTPUTMODES = |
55 "/art:result/art:outputmodes"; | 55 "/art:result/art:outputmodes"; |
56 | |
57 public static final String XPATH_ARTIFACT_STATE_DATA = | |
58 "/art:result/art:ui/art:static/art:state/art:data"; | |
56 | 59 |
57 public static final String XPATH_COLLECTION_ITEMS = | 60 public static final String XPATH_COLLECTION_ITEMS = |
58 "/art:result/art:artifact-collection/art:collection-item"; | 61 "/art:result/art:artifact-collection/art:collection-item"; |
59 | 62 |
60 public static final String XPATH_OUT_NAME = "/art:action/@art:name"; | 63 public static final String XPATH_OUT_NAME = "/art:action/@art:name"; |
412 } | 415 } |
413 } | 416 } |
414 } | 417 } |
415 | 418 |
416 aParser.parse(oldAttr); | 419 aParser.parse(oldAttr); |
417 | 420 |
418 return new AttributeWriter( | 421 return new AttributeWriter( |
419 db, | 422 db, |
420 aParser.getOuts(), | 423 aParser.getOuts(), |
421 aParser.getFacets(), | 424 aParser.getFacets(), |
422 oParser.getOuts(), | 425 oParser.getOuts(), |
824 | 827 |
825 return null; | 828 return null; |
826 } | 829 } |
827 | 830 |
828 | 831 |
832 /** | |
833 * Create the Artifacts Node that contains outputmode and statedata. | |
834 * @param uuid uuid of the artifact. | |
835 */ | |
829 protected Element buildArtifactNode( | 836 protected Element buildArtifactNode( |
830 ArtifactDatabase database, | 837 ArtifactDatabase database, |
831 String uuid, | 838 String uuid, |
832 CallContext context, | 839 CallContext context, |
833 XMLUtils.ElementCreator ec) | 840 XMLUtils.ElementCreator ec) |
836 log.debug("Append artifact '" + uuid + "' to collection description"); | 843 log.debug("Append artifact '" + uuid + "' to collection description"); |
837 | 844 |
838 // TODO | 845 // TODO |
839 String hash = "MYHASH"; | 846 String hash = "MYHASH"; |
840 | 847 |
841 Element ci = ec.create("artifact"); | 848 Element ci = ec.create("artifact"); |
842 ec.addAttr(ci, "uuid", uuid, true); | 849 ec.addAttr(ci, "uuid", uuid, true); |
843 ec.addAttr(ci, "hash", hash, true); | 850 ec.addAttr(ci, "hash", hash, true); |
844 | 851 |
845 // XXX I am not sure if it works well every time with an empty document | 852 // XXX I am not sure if it works well every time with an empty document |
846 // in the describe operation of an artifact. | 853 // in the describe operation of an artifact. |
847 Document description = database.describe(uuid, null, context.getMeta()); | 854 Document description = database.describe(uuid, null, context.getMeta()); |
848 | 855 |
856 // Add outputmode element(s). | |
849 Node outputModes = (Node) XMLUtils.xpath( | 857 Node outputModes = (Node) XMLUtils.xpath( |
850 description, | 858 description, |
851 XPATH_ARTIFACT_OUTPUTMODES, | 859 XPATH_ARTIFACT_OUTPUTMODES, |
852 XPathConstants.NODE, | 860 XPathConstants.NODE, |
853 ArtifactNamespaceContext.INSTANCE); | 861 ArtifactNamespaceContext.INSTANCE); |
854 | 862 |
855 if (outputModes != null) { | 863 if (outputModes != null) { |
856 Document doc = ci.getOwnerDocument(); | 864 Document doc = ci.getOwnerDocument(); |
857 ci.appendChild(doc.importNode(outputModes, true)); | 865 ci.appendChild(doc.importNode(outputModes, true)); |
866 } | |
867 | |
868 // Add state-data element(s). | |
869 Node dataNode = ci.appendChild( | |
870 ci.getOwnerDocument().createElement("art:data-items")); | |
871 | |
872 NodeList dataNodes = (NodeList) XMLUtils.xpath( | |
873 description, | |
874 XPATH_ARTIFACT_STATE_DATA, | |
875 XPathConstants.NODESET, | |
876 ArtifactNamespaceContext.INSTANCE); | |
877 | |
878 if (dataNodes != null) { | |
879 Document doc = ci.getOwnerDocument(); | |
880 for (int i = 0; i < dataNodes.getLength(); i++) { | |
881 dataNode.appendChild(doc.importNode(dataNodes.item(i), true)); | |
882 } | |
858 } | 883 } |
859 | 884 |
860 return ci; | 885 return ci; |
861 } | 886 } |
862 | 887 |