# HG changeset patch # User Ingo Weinzierl # Date 1299510816 0 # Node ID 15c7638511dc559267cc5ccb2be12a17d0f5de7f # Parent afd5945ff8d161ef5dd1c3f30bba344a9a54a29a Added an interface for CollectionItems and renamed the CollectionItem class from the artifact-database package to DefaultCollectionItem - because this is the default implementation of the interface. artifacts/trunk@1416 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r afd5945ff8d1 -r 15c7638511dc ChangeLog --- a/ChangeLog Mon Mar 07 14:49:43 2011 +0000 +++ b/ChangeLog Mon Mar 07 15:13:36 2011 +0000 @@ -1,3 +1,17 @@ +2011-03-07 Ingo Weinzierl + + * artifacts/src/main/java/de/intevation/artifacts/CollectionItem.java: + New. An interface that wraps artifacts and its attributes in collections. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultCollectionItem.java, + artifact-database/src/main/java/de/intevation/artifactdatabase/CollectionItem.java: + Moved. The CollectionItem has been moved to DefaultCollectionItem and + implements the new interface CollectionItem. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java: + The listCollectionArtifacts() method instantiates DefaultCollectionItem + objects now. + 2011-03-07 Sascha L. Teichmann * artifact-database/src/main/java/de/intevation/artifactdatabase/CollectionItem.java: diff -r afd5945ff8d1 -r 15c7638511dc artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java Mon Mar 07 14:49:43 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java Mon Mar 07 15:13:36 2011 +0000 @@ -12,6 +12,7 @@ import de.intevation.artifacts.ArtifactCollectionFactory; import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.ArtifactSerializer; +import de.intevation.artifacts.CollectionItem; import de.intevation.artifacts.User; import de.intevation.artifacts.UserFactory; @@ -1357,7 +1358,7 @@ stmnt.setString(1, collectionId); result = stmnt.executeQuery(); while (result.next()) { - CollectionItem item = new CollectionItem( + CollectionItem item = new DefaultCollectionItem( result.getString(1), result.getBytes(2)); collectionItems.add(item); diff -r afd5945ff8d1 -r 15c7638511dc artifact-database/src/main/java/de/intevation/artifactdatabase/CollectionItem.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/CollectionItem.java Mon Mar 07 14:49:43 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2011 by Intevation GmbH - * - * This program is free software under the LGPL (>=v2.1) - * Read the file LGPL.txt coming with the software for details - * or visit http://www.gnu.org/licenses/ if it does not exist. - */ -package de.intevation.artifactdatabase; - -import de.intevation.artifacts.common.utils.XMLUtils; - -import org.w3c.dom.Document; - -public class CollectionItem -{ - protected String artifactIdentifier; - - protected byte [] data; - - protected Document document; - - public CollectionItem() { - } - - public CollectionItem(String artifactIdentifier, byte [] attribute) { - this.artifactIdentifier = artifactIdentifier; - this.data = data; - } - - public String getArtifactIdentifier() { - return artifactIdentifier; - } - - public synchronized Document getAttribute() { - if (document == null) { - if (data != null) { - document = XMLUtils.fromByteArray(data); - } - } - return document; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r afd5945ff8d1 -r 15c7638511dc artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultCollectionItem.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultCollectionItem.java Mon Mar 07 15:13:36 2011 +0000 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2011 by Intevation GmbH + * + * This program is free software under the LGPL (>=v2.1) + * Read the file LGPL.txt coming with the software for details + * or visit http://www.gnu.org/licenses/ if it does not exist. + */ +package de.intevation.artifactdatabase; + +import de.intevation.artifacts.CollectionItem; + +import de.intevation.artifacts.common.utils.XMLUtils; + +import org.w3c.dom.Document; + +public class DefaultCollectionItem +implements CollectionItem +{ + protected String artifactIdentifier; + + protected byte [] data; + + protected Document document; + + public DefaultCollectionItem() { + } + + public DefaultCollectionItem(String artifactIdentifier, byte [] attribute) { + this.artifactIdentifier = artifactIdentifier; + this.data = data; + } + + public String getArtifactIdentifier() { + return artifactIdentifier; + } + + public synchronized Document getAttribute() { + if (document == null) { + if (data != null) { + document = XMLUtils.fromByteArray(data); + } + } + return document; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r afd5945ff8d1 -r 15c7638511dc artifacts/src/main/java/de/intevation/artifacts/CollectionItem.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/CollectionItem.java Mon Mar 07 15:13:36 2011 +0000 @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2011 by Intevation GmbH + * + * This program is free software under the LGPL (>=v2.1) + * Read the file LGPL.txt coming with the software for details + * or visit http://www.gnu.org/licenses/ if it does not exist. + */ +package de.intevation.artifacts; + +import java.io.Serializable; + +import org.w3c.dom.Document; + + +public interface CollectionItem extends Serializable { + + String getArtifactIdentifier(); + + Document getAttribute(); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :