Mercurial > dive4elements > framework
changeset 192:dad6071c9072
Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
artifacts/trunk@1422 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 08 Mar 2011 09:10:55 +0000 |
parents | 3bce5556a2e5 |
children | 949d69ad3756 |
files | ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java |
diffstat | 2 files changed, 44 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Mar 08 09:08:15 2011 +0000 +++ b/ChangeLog Tue Mar 08 09:10:55 2011 +0000 @@ -1,3 +1,9 @@ +2011-03-08 Ingo Weinzierl <ingo@intevation.de> + + * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java: + Implemented the setCollectionAttribute() and getCollectionAttribute() + methods. + 2011-03-08 Ingo Weinzierl <ingo@intevation.de> * artifact-database/src/main/resources/sql/org-h2-driver.properties,
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Tue Mar 08 09:08:15 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Tue Mar 08 09:10:55 2011 +0000 @@ -1240,14 +1240,47 @@ } public Document getCollectionAttribute(String collectionId, String artifactId, - CallMeta callMeta) throws ArtifactDatabaseException { - throw new ArtifactDatabaseException("Not implemented, yet!"); + CallMeta callMeta) throws ArtifactDatabaseException + { + logger.debug("Fetch the attribute for the artifact: " + artifactId); + + return backend.getCollectionAttribute(collectionId, artifactId); } public Document setCollectionAttribute(String collectionId, String artifactId, - Document attribute, CallMeta callMeta) - throws ArtifactDatabaseException { - throw new ArtifactDatabaseException("Not implemented, yet!"); + Document source, CallMeta callMeta) + throws ArtifactDatabaseException + { + logger.debug("Set the attribute for the artifact: " + artifactId); + + Document attribute = XMLUtils.newDocument(); + + Node attr = (Node) XMLUtils.xpath( + source, + XPATH_COLLECTION_ITEM_ATTRIBUTE, + XPathConstants.NODE, + ArtifactNamespaceContext.INSTANCE); + + if (attr != null) { + attribute.appendChild(attribute.importNode(attr, true)); + } + + Document result = XMLUtils.newDocument(); + + XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( + result, + ArtifactNamespaceContext.NAMESPACE_URI, + ArtifactNamespaceContext.NAMESPACE_PREFIX); + + Element root = ec.create("result"); + result.appendChild(root); + + boolean success = backend.setCollectionAttribute( + collectionId, artifactId, attribute); + + root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE); + + return result; } public Document addCollectionArtifact(