changeset 13:0d6badf6af42

Added not yet working backend to artifact database. artifacts/trunk@28 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 06 Sep 2009 16:16:54 +0000
parents 3f01e317f615
children 0d16d1bb2df0
files Changelog artifact-database/src/main/java/de/intevation/artifactdatabase/App.java artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java artifact-database/src/main/java/de/intevation/artifactdatabase/Config.java
diffstat 5 files changed, 100 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Changelog	Sun Sep 06 13:23:26 2009 +0000
+++ b/Changelog	Sun Sep 06 16:16:54 2009 +0000
@@ -1,3 +1,17 @@
+2009-09-06	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java:
+	New. Used to wrap database presentations of artifacts into artifacts.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java:
+	New. Implements a ArtifactDatabase backed by Backend.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/Config.java:
+	Removed empty last line.
+	
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/App.java:
+	Wired together Backend, ArtifactDatabaseImpl and FactoryBootstrap.
+
 2009-09-06	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* artifact-database/src/main/java/de/intevation/artifactdatabase/DBConnection.java:
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/App.java	Sun Sep 06 13:23:26 2009 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/App.java	Sun Sep 06 16:16:54 2009 +0000
@@ -11,6 +11,11 @@
         FactoryBootstrap bootstrap = new FactoryBootstrap();
 
         bootstrap.boot();
+
+        Backend backend = new Backend();
+
+        ArtifactDatabaseImpl db = new ArtifactDatabaseImpl(
+            bootstrap, backend);
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Sun Sep 06 16:16:54 2009 +0000
@@ -0,0 +1,57 @@
+package de.intevation.artifactdatabase;
+
+import java.util.HashMap;
+
+import de.intevation.artifacts.ArtifactDatabase;
+import de.intevation.artifacts.ArtifactFactory;
+import de.intevation.artifacts.Artifact;
+
+/**
+ *  @author Sascha L. Teichmann
+ */
+public class ArtifactDatabaseImpl
+implements   ArtifactDatabase
+{
+    protected String [] factoryNames;
+    protected HashMap   name2factory;
+
+    protected Backend   backend;
+    protected Object    context;
+
+    public ArtifactDatabaseImpl() {
+    }
+
+    public ArtifactDatabaseImpl(FactoryBootstrap bootstrap, Backend backend) {
+        name2factory = new HashMap();
+
+        ArtifactFactory [] factories = bootstrap.getArtifactFactories();
+        factoryNames = new String[factories.length];
+
+        for (int i = 0; i < factories.length; ++i) {
+            ArtifactFactory factory = factories[i];
+            name2factory.put(factoryNames[i] = factory.getName(), factory);
+        }
+
+        context = bootstrap.getContext();
+    }
+
+    public String [] getArtifactFactoryNames() {
+        return factoryNames;
+    }
+
+    public Artifact getArtifact(String identifier) {
+        return backend.getArtifact(identifier);
+    }
+
+    public Artifact createArtifactWithFactory(String factoryName) {
+        ArtifactFactory factory = (ArtifactFactory)name2factory.get(factoryName);
+        return  factory == null
+            ? null
+            : backend.createArtifactWithFactory(factory, context);
+    }
+
+    public Object getArtifactContext() {
+        return context;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Sun Sep 06 16:16:54 2009 +0000
@@ -0,0 +1,24 @@
+package de.intevation.artifactdatabase;
+
+import de.intevation.artifacts.ArtifactFactory;
+import de.intevation.artifacts.Artifact;
+
+/**
+ *  @author Sascha L. Teichmann
+ */
+public class Backend
+{
+    public Backend() {
+    }
+
+    public Artifact getArtifact(String idenitfier) {
+        return null;
+    }
+
+    public Artifact createArtifactWithFactory(
+        ArtifactFactory factory, Object context
+    ) {
+        return null;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Config.java	Sun Sep 06 13:23:26 2009 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Config.java	Sun Sep 06 16:16:54 2009 +0000
@@ -139,4 +139,3 @@
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
-

http://dive4elements.wald.intevation.org