changeset 115:a1200c6ed048

Initial interfaces to handle with Collections and Users. artifacts/trunk@1338 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 01 Mar 2011 12:17:00 +0000
parents 19b86e27d0c3
children 2707b7ec273f
files ChangeLog artifacts/src/main/java/de/intevation/artifacts/Artifact.java artifacts/src/main/java/de/intevation/artifacts/ArtifactCollection.java artifacts/src/main/java/de/intevation/artifacts/ArtifactCollectionFactory.java artifacts/src/main/java/de/intevation/artifacts/User.java artifacts/src/main/java/de/intevation/artifacts/UserFactory.java
diffstat 6 files changed, 221 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Feb 18 14:21:32 2011 +0000
+++ b/ChangeLog	Tue Mar 01 12:17:00 2011 +0000
@@ -1,3 +1,19 @@
+2011-03-01	Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	* artifacts/src/main/java/de/intevation/artifacts/ArtifactCollectionFactory.java:
+	  New: factory to create new collections.
+
+	* artifacts/src/main/java/de/intevation/artifacts/ArtifactCollection.java:
+	  New: Bundles artifacts to be owned by a user.
+
+	* artifacts/src/main/java/de/intevation/artifacts/UserFactory.java:
+	  New: Creates a new user.
+
+	* artifacts/src/main/java/de/intevation/artifacts/User.java:
+	  New: Model of a user.
+
+	* artifacts/src/main/java/de/intevation/artifacts/Artifact.java: Typo fix.
+
 2011-02-18  Ingo Weinzierl <ingo@intevation.de>
 
 	* artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java:
--- a/artifacts/src/main/java/de/intevation/artifacts/Artifact.java	Fri Feb 18 14:21:32 2011 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/Artifact.java	Tue Mar 01 12:17:00 2011 +0000
@@ -91,7 +91,7 @@
     Document feed(Document data, CallContext context);
 
     /**
-     * Produce output from this artifact.
+     * Produce output for this artifact.
      * @param format Specifies the format of the output.
      * @param out Stream to write the result data to.
      * @param context The global context of the runtime system.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactCollection.java	Tue Mar 01 12:17:00 2011 +0000
@@ -0,0 +1,106 @@
+/*
+ * 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 org.w3c.dom.Document;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Serializable;
+
+public interface ArtifactCollection
+extends          Serializable
+{
+    /**
+     * Set a new identifier for this collection.
+     * @param identifier New identifier for this collection.
+     */
+    void setIdentifier(String identifier);
+
+    /**
+     * Identify this collection.
+     * @return Returns unique string to identify this collection globally.
+     */
+    String identifier();
+
+    /**
+     * Set a new owner of this collection.
+     * @param user New owner for this collection.
+     */
+    void setUser(User user);
+
+    /**
+     * Identify the owner of the collection.
+     * @return Returns owner of the collection.
+     */
+    User getUser(); // FIXME: Is ArtifactCollectionFactory needed?
+
+    /**
+     * When created by a factory this method is called to
+     * initialize the collection.
+     * @param identifier The identifier from collection database
+     * @param factory    The factory which created this collection.
+     * @param context    The global context of the runtime system.
+     * @param data       The data which can be use to setup a collection with
+     *                   more details.
+     */
+    void setup(
+        String                    identifier,
+        ArtifactCollectionFactory factory,
+        Object                    context,
+        Document                  data);
+
+    //TODO: create LifeCycle interface
+    /**
+     * Called from artifact database when an artifact is
+     * going to be removed from system.
+     * @param context The global context of the runtime system.
+     */
+    void endOfLife(Object context);
+
+    /**
+     * Internal hash of this collection.
+     * @return Returns hash that should stay the same if the internal
+     *         value has not changed. Useful for caching
+     */
+    String hash();
+
+
+    /**
+     * Called from artifact database before an artifact is
+     * going to be exported as xml document.
+     * @param context The global context of the runtime system.
+     */
+    void cleanup(Object context);
+
+
+    void addArtifact(Artifact artifact, Document attributes);
+
+    void removeArtifact(Artifact artifact);
+
+    Artifact [] getArtifacts();
+
+    Document getAttribute(Artifact artifact);
+
+    void setAtribute(Artifact artifact, Document document);
+
+    /**
+     * Produce output for this collection.
+     * @param format Specifies the format of the output.
+     * @param out Stream to write the result data to.
+     * @param context The global context of the runtime system.
+     * @throws IOException Thrown if an I/O occurs.
+     */
+    void out(
+        Document     format,
+        OutputStream out,
+        CallContext  context)
+    throws IOException;
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactCollectionFactory.java	Tue Mar 01 12:17:00 2011 +0000
@@ -0,0 +1,45 @@
+/*
+ * 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 org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+public interface ArtifactCollectionFactory
+{
+    /**
+     * The short name of this factory.
+     * @return the name of this factory.
+     */
+    String getName();
+
+    /**
+     * Description of this factory.
+     * @return description of the factory.
+     */
+    String getDescription();
+
+    /**
+     * Create a new artifact of certain type, given a general purpose context and
+     * an identifier.
+     * @param context a context from the ArtifactDatabase.
+     * @param identifier unique identifer for the new artifact
+     * @param data  the data containing more details for the setup of an Artifact.
+     * @return a new {@linkplain de.intevation.artifacts.ArtifactCollection ArtifactCollection}
+     */
+    ArtifactCollection createCollection(String identifier, Object context, Document data);
+
+    /**
+     * Setup the factory with a given configuration
+     * @param config the configuration
+     * @param factoryNode the ConfigurationNode of this Factory
+     */
+    void setup(Document config, Node factoryNode);
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
+  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/User.java	Tue Mar 01 12:17:00 2011 +0000
@@ -0,0 +1,29 @@
+/*
+ * 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 org.w3c.dom.Document;
+
+import java.io.Serializable;
+
+public interface User
+extends          Serializable
+{
+    String identifier();
+
+    String getName();
+
+    void setName(String name);
+
+    void setIdentifier(String identifier);
+
+    void setRole(Document role);
+
+    Document getRole();
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/UserFactory.java	Tue Mar 01 12:17:00 2011 +0000
@@ -0,0 +1,24 @@
+/*
+ * 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 org.w3c.dom.Document;
+
+import java.io.Serializable;
+
+public interface UserFactory
+{
+    User createUser(String identifier, String name, Document role);
+
+    void deleteUser(User user);
+
+    User getUser(String identifier);
+
+    User [] getUsers();
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org