# HG changeset patch # User Sascha L. Teichmann # Date 1252253814 0 # Node ID 0d6badf6af42824f09a2609091b6cf3cc83e9ccf # Parent 3f01e317f615c9fea8e26532b7a1a5782420906d Added not yet working backend to artifact database. artifacts/trunk@28 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 3f01e317f615 -r 0d6badf6af42 Changelog --- 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 + + * 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 * artifact-database/src/main/java/de/intevation/artifactdatabase/DBConnection.java: diff -r 3f01e317f615 -r 0d6badf6af42 artifact-database/src/main/java/de/intevation/artifactdatabase/App.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: diff -r 3f01e317f615 -r 0d6badf6af42 artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java --- /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: diff -r 3f01e317f615 -r 0d6badf6af42 artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java --- /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: diff -r 3f01e317f615 -r 0d6badf6af42 artifact-database/src/main/java/de/intevation/artifactdatabase/Config.java --- 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: -