You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by re...@apache.org on 2015/03/23 17:38:18 UTC
[34/51] [partial] incubator-taverna-engine git commit:
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateReferenceSetDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateReferenceSetDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateReferenceSetDao.java
new file mode 100644
index 0000000..67e5cac
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateReferenceSetDao.java
@@ -0,0 +1,197 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static org.apache.taverna.reference.T2ReferenceType.ReferenceSet;
+
+import java.util.List;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.ReferenceSetDao;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.annotations.DeleteIdentifiedOperation;
+import org.apache.taverna.reference.annotations.GetIdentifiedOperation;
+import org.apache.taverna.reference.annotations.PutIdentifiedOperation;
+
+import org.hibernate.Query;
+import org.hibernate.SessionFactory;
+
+/**
+ * An implementation of ReferenceSetDao based on raw hibernate session factory
+ * injection and running within a spring managed context through auto-proxy
+ * generation. To use this in spring inject a property 'sessionFactory' with
+ * either a {@link org.springframework.orm.hibernate3.LocalSessionFactoryBean
+ * LocalSessionFactoryBean} or the equivalent class from the T2Platform module
+ * to add SPI based implementation discovery and mapping. To use outside of
+ * Spring ensure you call the setSessionFactory(..) method before using this
+ * (but really, use it from Spring, so much easier).
+ * <p>
+ * Methods in this Dao require transactional support
+ *
+ * @author Tom Oinn
+ */
+public class TransactionalHibernateReferenceSetDao implements ReferenceSetDao {
+ private static final String GET_REFSETS_FOR_RUN = "FROM ReferenceSetImpl WHERE namespacePart=:workflow_run_id";
+ private SessionFactory sessionFactory;
+
+ public void setSessionFactory(SessionFactory sessionFactory) {
+ this.sessionFactory = sessionFactory;
+ }
+
+ /**
+ * Store the specified new reference set
+ *
+ * @param rs
+ * a reference set, must not already exist in the database.
+ * @throws DaoException
+ * if the entry already exists in the database, if the supplied
+ * reference set isn't an instance of ReferenceSetImpl or if
+ * something else goes wrong connecting to the database
+ */
+ @Override
+ @PutIdentifiedOperation
+ public void store(ReferenceSet rs) throws DaoException {
+ if (rs.getId() == null)
+ throw new DaoException(
+ "Supplied reference set has a null ID, allocate "
+ + "an ID before calling the store method in the dao.");
+ if (!rs.getId().getReferenceType().equals(ReferenceSet))
+ throw new DaoException(
+ "Strangely the reference set ID doesn't have type "
+ + "T2ReferenceType.ReferenceSet, something has probably "
+ + "gone badly wrong somewhere earlier!");
+ if (!(rs instanceof ReferenceSetImpl))
+ throw new DaoException(
+ "Supplied reference set not an instance of ReferenceSetImpl");
+
+ try {
+ sessionFactory.getCurrentSession().save(rs);
+ } catch (Exception ex) {
+ throw new DaoException(ex);
+ }
+ }
+
+ /**
+ * Update a pre-existing entry in the database
+ *
+ * @param rs
+ * the reference set to update. This must already exist in the
+ * database
+ * @throws DaoException
+ */
+ @Override
+ @PutIdentifiedOperation
+ public void update(ReferenceSet rs) throws DaoException {
+ if (rs.getId() == null)
+ throw new DaoException(
+ "Supplied reference set has a null ID, allocate "
+ + "an ID before calling the store method in the dao.");
+ if (!rs.getId().getReferenceType().equals(ReferenceSet))
+ throw new DaoException(
+ "Strangely the reference set ID doesn't have type "
+ + "T2ReferenceType.ReferenceSet, something has probably "
+ + "gone badly wrong somewhere earlier!");
+ if (!(rs instanceof ReferenceSetImpl))
+ throw new DaoException(
+ "Supplied reference set not an instance of ReferenceSetImpl");
+
+ try {
+ sessionFactory.getCurrentSession().update(rs);
+ } catch (Exception ex) {
+ throw new DaoException(ex);
+ }
+ }
+
+ /**
+ * Fetch a reference set by id
+ *
+ * @param ref
+ * the ReferenceSetT2ReferenceImpl to fetch
+ * @return a retrieved ReferenceSetImpl
+ * @throws DaoException
+ * if the supplied reference is of the wrong type or if
+ * something goes wrong fetching the data or connecting to the
+ * database
+ */
+ @Override
+ @GetIdentifiedOperation
+ public ReferenceSetImpl get(T2Reference ref) throws DaoException {
+ if (ref == null)
+ throw new DaoException(
+ "Supplied reference is null, can't retrieve.");
+ if (!ref.getReferenceType().equals(ReferenceSet))
+ throw new DaoException(
+ "This dao can only retrieve reference of type T2Reference.ReferenceSet");
+ if (!(ref instanceof T2ReferenceImpl))
+ throw new DaoException(
+ "Reference must be an instance of T2ReferenceImpl");
+
+ try {
+ return (ReferenceSetImpl) sessionFactory.getCurrentSession().get(
+ ReferenceSetImpl.class,
+ ((T2ReferenceImpl) ref).getCompactForm());
+ } catch (Exception ex) {
+ throw new DaoException(ex);
+ }
+ }
+
+ @Override
+ @DeleteIdentifiedOperation
+ public boolean delete(ReferenceSet rs) throws DaoException {
+ if (rs.getId() == null)
+ throw new DaoException(
+ "Supplied reference set has a null ID, allocate "
+ + "an ID before calling the store method in the dao.");
+ if (!rs.getId().getReferenceType().equals(ReferenceSet))
+ throw new DaoException(
+ "Strangely the reference set ID doesn't have type "
+ + "T2ReferenceType.ReferenceSet, something has probably "
+ + "gone badly wrong somewhere earlier!");
+ if (!(rs instanceof ReferenceSetImpl))
+ throw new DaoException(
+ "Supplied reference set not an instance of ReferenceSetImpl");
+
+ try {
+ sessionFactory.getCurrentSession().delete(rs);
+ return true;
+ } catch (Exception ex) {
+ throw new DaoException(ex);
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ @DeleteIdentifiedOperation
+ public synchronized void deleteReferenceSetsForWFRun(String workflowRunId)
+ throws DaoException {
+ try {
+ // Select all ReferenceSets for this wf run
+ Query selectQuery = sessionFactory.getCurrentSession().createQuery(
+ GET_REFSETS_FOR_RUN);
+ selectQuery.setString("workflow_run_id", workflowRunId);
+ List<ReferenceSet> referenceSets = selectQuery.list();
+ for (ReferenceSet referenceSet : referenceSets)
+ delete(referenceSet);
+ } catch (Exception ex) {
+ throw new DaoException(ex);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TranslationPath.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TranslationPath.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TranslationPath.java
new file mode 100644
index 0000000..6422a0f
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TranslationPath.java
@@ -0,0 +1,285 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.taverna.reference.DereferenceException;
+import org.apache.taverna.reference.ExternalReferenceBuilderSPI;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ExternalReferenceTranslatorSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferenceSet;
+
+/**
+ * A path from one external reference to another along with a total estimated
+ * path cost through one or more reference translators.
+ */
+public class TranslationPath implements Comparable<TranslationPath>,
+ Iterable<ExternalReferenceTranslatorSPI<?, ?>> {
+ private List<ExternalReferenceTranslatorSPI<?, ?>> translators = new ArrayList<>();
+ private ExternalReferenceBuilderSPI<?> initialBuilder = null;
+ private ExternalReferenceSPI sourceReference = null;
+ private List<ExternalReferenceBuilderSPI<?>> builders;
+
+ public TranslationPath() {
+ }
+
+ /**
+ * Return a human readable representation of this translation path, used by
+ * the logging methods to print trace information.
+ */
+ @SuppressWarnings("rawtypes")
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(getPathCost() + " ");
+ if (getSourceReference() != null && getInitialBuilder() != null) {
+ sb.append(getSourceReference()).append("->bytes(")
+ .append(getSourceReference().getResolutionCost())
+ .append(")->");
+ String builderClassName = getInitialBuilder().getClass()
+ .getSimpleName();
+ String builtType = getInitialBuilder().getReferenceType()
+ .getSimpleName();
+ sb.append("builder:").append(builderClassName).append("(")
+ .append(getInitialBuilder().getConstructionCost())
+ .append("):<").append(builtType).append(">");
+ } else if (!getTranslators().isEmpty())
+ sb.append("<")
+ .append(getTranslators().get(0).getSourceReferenceType()
+ .getSimpleName()).append(">");
+ for (ExternalReferenceTranslatorSPI translator : getTranslators())
+ sb.append("-")
+ .append(translator.getClass().getSimpleName())
+ .append("(")
+ .append(translator.getTranslationCost())
+ .append(")-<")
+ .append(translator.getTargetReferenceType().getSimpleName())
+ .append(">");
+ return sb.toString();
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public Set<ExternalReferenceSPI> doTranslation(ReferenceSet rs,
+ ReferenceContext context) {
+ Set<ExternalReferenceSPI> results = new HashSet<>();
+ /*
+ * Firstly check whether we have an initial reference and builder
+ * defined
+ */
+ ExternalReferenceSPI currentReference = null;
+ if (getInitialBuilder() != null && getSourceReference() != null)
+ try (InputStream stream = getSourceReference().openStream(context)) {
+ ExternalReferenceSPI builtReference = getInitialBuilder()
+ .createReference(stream, context);
+ results.add(builtReference);
+ currentReference = builtReference;
+ } catch (IOException e) {
+ throw new DereferenceException(
+ "Can't create reference from stream", e);
+ }
+ if (!getTranslators().isEmpty() && currentReference == null)
+ /*
+ * If there are translators in the path (there may not be if this is
+ * a pure 'dereference and build' type path) and the
+ * currentReference hasn't been set then search the existing
+ * references for an appropriate starting point for the translation.
+ */
+ for (ExternalReferenceSPI er : rs.getExternalReferences())
+ if (er.getClass().equals(
+ getTranslators().get(0).getSourceReferenceType())) {
+ currentReference = er;
+ break;
+ }
+ if (currentReference == null)
+ throw new RuntimeException(
+ "Can't locate a starting reference for the"
+ + " translation path");
+
+ for (ExternalReferenceTranslatorSPI translator : getTranslators()) {
+ ExternalReferenceSPI translatedReference = translator
+ .createReference(currentReference, context);
+ results.add(translatedReference);
+ currentReference = translatedReference;
+ }
+ return results;
+ }
+
+ /**
+ * Sum of translation costs of all translators in path
+ */
+ public float getPathCost() {
+ float cost = 0.0f;
+ for (ExternalReferenceTranslatorSPI<?, ?> ert : this)
+ cost += ert.getTranslationCost();
+ /*
+ * If the source reference and initial builder are non-null then we're
+ * going to start this translation path by downloading a byte stream
+ * from the specified (current) reference and using it to construct the
+ * starting point for the translation path via the specified builder.
+ */
+ if (getSourceReference() != null)
+ cost += getSourceReference().getResolutionCost();
+ if (getInitialBuilder() != null)
+ cost += getInitialBuilder().getConstructionCost();
+ return cost;
+ }
+
+ /**
+ * Return a list of translation paths based on this one but which start at
+ * an existing reference within the supplied reference set. Will only
+ * function if there is a reference builder registered that can build the
+ * initial reference type used by this translation path, otherwise it
+ * returns an empty list.
+ *
+ * @param rs
+ * @return
+ */
+ @SuppressWarnings("rawtypes")
+ public List<TranslationPath> getDereferenceBasedPaths(ReferenceSet rs) {
+ List<TranslationPath> results = new ArrayList<>();
+ for (ExternalReferenceBuilderSPI erb : getBuilders())
+ /*
+ * Check for each reference builder to see if it can build the
+ * source type for this path
+ */
+ if (erb.getReferenceType().equals(this.getSourceType()))
+ /*
+ * The builder can construct the type used by the start of this
+ * translation path, so we can in general create a path from a
+ * fooreference to the target by de-referencing the fooreference
+ * and building the start type from it.
+ */
+ for (ExternalReferenceSPI er : rs.getExternalReferences()) {
+ /*
+ * For each external reference in the existing reference
+ * set, check whether that type is already going to be
+ * created in the translation path - if so then there's not
+ * much point in emiting the modified path, as you'd have
+ * something like bytes->a->b->a->result which wouldn't make
+ * any sense
+ */
+ boolean overlapsExistingType = false;
+ for (ExternalReferenceTranslatorSPI translationStep : this)
+ if (translationStep.getSourceReferenceType().equals(
+ er.getClass())) {
+ overlapsExistingType = true;
+ break;
+ }
+ if (!overlapsExistingType) {
+ /*
+ * The type wasn't found anywhere within the translation
+ * path, so we're not generating obviously stupid
+ * candidate paths.
+ */
+ TranslationPath newPath = new TranslationPath();
+ newPath.setBuilders(getBuilders());
+ newPath.setTranslators(getTranslators());
+ newPath.setInitialBuilder(erb);
+ newPath.setSourceReference(er);
+ results.add(newPath);
+ }
+ }
+ return results;
+ }
+
+ public List<ExternalReferenceTranslatorSPI<?, ?>> pathSteps() {
+ return getTranslators();
+ }
+
+ /**
+ * Order by total path cost
+ */
+ @Override
+ public int compareTo(TranslationPath tp) {
+ float tpCost = tp.getPathCost();
+ float myCost = getPathCost();
+ if (tpCost > myCost)
+ return -1;
+ if (tpCost < myCost)
+ return 1;
+ return 0;
+ }
+
+ /**
+ * Wrap translator list iterator for convenience
+ */
+ @Override
+ public Iterator<ExternalReferenceTranslatorSPI<?, ?>> iterator() {
+ return getTranslators().iterator();
+ }
+
+ public Class<? extends ExternalReferenceSPI> getSourceType() {
+ if (!getTranslators().isEmpty())
+ return getTranslators().get(0).getSourceReferenceType();
+ if (getSourceReference() != null)
+ return getSourceReference().getClass();
+ return null;
+ }
+
+ public Class<? extends ExternalReferenceSPI> getTargetType() {
+ if (!getTranslators().isEmpty())
+ return getTranslators().get(getTranslators().size() - 1)
+ .getTargetReferenceType();
+ if (getInitialBuilder() != null)
+ return getInitialBuilder().getReferenceType();
+ return null;
+ }
+
+ public List<ExternalReferenceTranslatorSPI<?, ?>> getTranslators() {
+ return translators;
+ }
+
+ public void setTranslators(
+ List<ExternalReferenceTranslatorSPI<?, ?>> translators) {
+ this.translators = translators;
+ }
+
+ public ExternalReferenceBuilderSPI<?> getInitialBuilder() {
+ return initialBuilder;
+ }
+
+ public void setInitialBuilder(ExternalReferenceBuilderSPI<?> initialBuilder) {
+ this.initialBuilder = initialBuilder;
+ }
+
+ public ExternalReferenceSPI getSourceReference() {
+ return sourceReference;
+ }
+
+ public void setSourceReference(ExternalReferenceSPI sourceReference) {
+ this.sourceReference = sourceReference;
+ }
+
+ public List<ExternalReferenceBuilderSPI<?>> getBuilders() {
+ return builders;
+ }
+
+ public void setBuilders(List<ExternalReferenceBuilderSPI<?>> builders) {
+ this.builders = builders;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/UUIDT2ReferenceGenerator.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/UUIDT2ReferenceGenerator.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/UUIDT2ReferenceGenerator.java
new file mode 100644
index 0000000..aba8ab4
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/UUIDT2ReferenceGenerator.java
@@ -0,0 +1,55 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import java.util.UUID;
+
+import org.apache.taverna.reference.T2ReferenceGenerator;
+
+/**
+ * A T2ReferenceGenerator based on UUIDs. Not as fast as
+ * {@link SimpleT2ReferenceGenerator}, but IDs will be globally unique.
+ *
+ * @author Stian Soiland-Reyes
+ */
+public class UUIDT2ReferenceGenerator extends AbstractT2ReferenceGenerator
+ implements T2ReferenceGenerator {
+ private String namespace = "uuid";
+
+ /**
+ * Set the namespace for identifiers generated by this class as a string
+ *
+ * @param newNamespace
+ * the namespace to use
+ */
+ public void setNamespace(String newNamespace) {
+ this.namespace = newNamespace;
+ }
+
+ @Override
+ public String getNamespace() {
+ return namespace;
+ }
+
+ @Override
+ protected String getNextLocalPart() {
+ return UUID.randomUUID().toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/WriteQueueAspect.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/WriteQueueAspect.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/WriteQueueAspect.java
new file mode 100644
index 0000000..2dd17f4
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/WriteQueueAspect.java
@@ -0,0 +1,141 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.reference.impl;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+import java.lang.ref.SoftReference;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+
+import org.apache.taverna.reference.DaoException;
+import org.apache.taverna.reference.Identified;
+import org.apache.taverna.reference.T2Reference;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+
+/**
+ * An aspect used to intercept calls to the various data access objects and
+ * execute data writes on a thread limited executer with an unbounded blocking
+ * queue.
+ *
+ * @author David Withers
+ */
+public class WriteQueueAspect {
+ private Map<T2Reference, Identified> store = new ConcurrentHashMap<>();
+ private Map<T2Reference, SoftReference<Identified>> cache = new ConcurrentHashMap<>();
+ private ThreadPoolExecutor executer;
+
+ public WriteQueueAspect() {
+ this(5);
+ }
+
+ public WriteQueueAspect(int threads) {
+ executer = new ThreadPoolExecutor(threads, threads, 60, SECONDS,
+ new LinkedBlockingQueue<Runnable>(),
+ Executors.defaultThreadFactory(),
+ new ThreadPoolExecutor.CallerRunsPolicy());
+ }
+
+ /**
+ * Handle a 'get by T2Reference' operation on a Dao
+ *
+ * @param pjp
+ * the join point representing the ongoing method call to the dao
+ * @return the entity identified by the T2Reference supplied to the method
+ * to which this advice applies
+ * @throws DaoException
+ * if anything goes wrong
+ */
+ public final Identified getObject(final ProceedingJoinPoint pjp)
+ throws DaoException {
+ Identified result = null;
+
+ // Get the T2Reference from the argument to the get method
+ T2Reference id = (T2Reference) pjp.getArgs()[0];
+ if (id != null) {
+ // try the cache
+ SoftReference<Identified> ref = cache.get(id);
+ if (ref != null)
+ result = ref.get();
+ if (result == null)
+ // not in the cache, check if it's still in the write queue
+ result = store.get(id);
+ }
+ // If we miss the cache then call the method as usual
+ if (result == null)
+ try {
+ result = (Identified) pjp.proceed();
+ if (result != null)
+ cache.put(id, new SoftReference<>(result));
+ } catch (DaoException e) {
+ throw e;
+ } catch (Throwable e) {
+ throw new DaoException(
+ "Unexpected exception type during aspect "
+ + "based invocation", e);
+ }
+
+ return result;
+ }
+
+ /**
+ * Called around a write or update operation on the backing store, writes
+ * through to the cache after modifying the state of the backing store and
+ * before returning from the dao method
+ *
+ * @param pjp
+ * join point representing the ongoing method invocation to cache
+ * @throws DaoException
+ * if anything goes wrong
+ */
+ public void putObject(final ProceedingJoinPoint pjp) throws DaoException {
+ // Get the Identified being stored by the method we're advising
+ final Identified storedObject = (Identified) pjp.getArgs()[0];
+
+ Runnable task = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ // Run the store or update method
+ pjp.proceed();
+ store.remove(storedObject.getId());
+ } catch (DaoException e) {
+ throw e;
+ } catch (Throwable e) {
+ throw new DaoException(
+ "Unexpected exception type during aspect "
+ + "based invocation", e);
+ }
+ }
+ };
+
+ cache.put(storedObject.getId(), new SoftReference<>(storedObject));
+ store.put(storedObject.getId(), storedObject);
+ executer.execute(task);
+ }
+
+ public int cacheSize() {
+ return executer.getActiveCount() + executer.getQueue().size();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/package.html b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/package.html
new file mode 100644
index 0000000..79e0107
--- /dev/null
+++ b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/package.html
@@ -0,0 +1,5 @@
+<body>
+Implementation of the reference manager APIs backed by Hibernate. These
+classes are intended to be used with Spring, so have their dependencies
+injected through set methods rather than constructor arguments.
+</body>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateComponentClass
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateComponentClass b/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateComponentClass
deleted file mode 100644
index b7b5d58..0000000
--- a/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateComponentClass
+++ /dev/null
@@ -1,2 +0,0 @@
-net.sf.taverna.t2.reference.impl.T2ReferenceImpl
-net.sf.taverna.t2.reference.impl.StackTraceElementBeanImpl
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateMappedEntity
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateMappedEntity b/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateMappedEntity
deleted file mode 100644
index ddf2cc5..0000000
--- a/taverna-reference-impl/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.h3.HibernateMappedEntity
+++ /dev/null
@@ -1,3 +0,0 @@
-net.sf.taverna.t2.reference.impl.ReferenceSetImpl
-net.sf.taverna.t2.reference.impl.T2ReferenceListImpl
-net.sf.taverna.t2.reference.impl.ErrorDocumentImpl
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateComponentClass
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateComponentClass b/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateComponentClass
new file mode 100644
index 0000000..913661c
--- /dev/null
+++ b/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateComponentClass
@@ -0,0 +1,2 @@
+org.apache.taverna.reference.impl.T2ReferenceImpl
+org.apache.taverna.reference.impl.StackTraceElementBeanImpl
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateMappedEntity
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateMappedEntity b/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateMappedEntity
new file mode 100644
index 0000000..d9f0cf4
--- /dev/null
+++ b/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateMappedEntity
@@ -0,0 +1,3 @@
+org.apache.taverna.reference.impl.ReferenceSetImpl
+org.apache.taverna.reference.impl.T2ReferenceListImpl
+org.apache.taverna.reference.impl.ErrorDocumentImpl
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/spring.handlers
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/spring.handlers b/taverna-reference-impl/src/main/resources/META-INF/spring.handlers
index 462f844..f3bed57 100644
--- a/taverna-reference-impl/src/main/resources/META-INF/spring.handlers
+++ b/taverna-reference-impl/src/main/resources/META-INF/spring.handlers
@@ -1 +1 @@
-http\://taverna.sf.net/schema/artifact-support=net.sf.taverna.platform.spring.ArtifactSupportNamespaceHandler
\ No newline at end of file
+http\://taverna.sf.net/schema/artifact-support=org.apache.taverna.platform.spring.ArtifactSupportNamespaceHandler
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/spring/hibernate-reference-impl-context.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/spring/hibernate-reference-impl-context.xml b/taverna-reference-impl/src/main/resources/META-INF/spring/hibernate-reference-impl-context.xml
index 4fb8ba4..ad4ed52 100644
--- a/taverna-reference-impl/src/main/resources/META-INF/spring/hibernate-reference-impl-context.xml
+++ b/taverna-reference-impl/src/main/resources/META-INF/spring/hibernate-reference-impl-context.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="hibernateReferenceService" class="net.sf.taverna.t2.reference.impl.ReferenceServiceImpl">
+ <bean id="hibernateReferenceService" class="org.apache.taverna.reference.impl.ReferenceServiceImpl">
<property name="converters" ref="converters" />
<property name="valueBuilders" ref="valueBuilders" />
<property name="referenceSetService">
@@ -17,7 +17,7 @@
</property>
</bean>
- <bean id="referenceSetService" class="net.sf.taverna.t2.reference.impl.ReferenceSetServiceImpl">
+ <bean id="referenceSetService" class="org.apache.taverna.reference.impl.ReferenceSetServiceImpl">
<property name="referenceSetDao">
<ref local="referenceSetDao" />
</property>
@@ -25,14 +25,14 @@
<property name="referenceSetAugmentor" ref="referenceSetAugmentor" />
</bean>
- <bean id="listService" class="net.sf.taverna.t2.reference.impl.ListServiceImpl">
+ <bean id="listService" class="org.apache.taverna.reference.impl.ListServiceImpl">
<property name="listDao">
<ref local="listDao" />
</property>
<property name="t2ReferenceGenerator" ref="t2ReferenceGenerator" />
</bean>
- <bean id="errorDocumentService" class="net.sf.taverna.t2.reference.impl.ErrorDocumentServiceImpl">
+ <bean id="errorDocumentService" class="org.apache.taverna.reference.impl.ErrorDocumentServiceImpl">
<property name="errorDao">
<ref local="errorDocumentDao" />
</property>
@@ -81,34 +81,34 @@
<property name="mappingResources">
<list>
<value>
- net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml
+ org/apache/taverna/reference/AbstractExternalReference.hbm.xml
</value>
<value>
- net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml
+ org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml
</value>
<value>
- net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml
+ org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml
</value>
<value>
- net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml
+ org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml
</value>
</list>
</property>
</bean>
- <bean id="referenceSetDao" class="net.sf.taverna.t2.reference.impl.HibernateReferenceSetDao" >
+ <bean id="referenceSetDao" class="org.apache.taverna.reference.impl.HibernateReferenceSetDao" >
<property name="sessionFactory">
<ref local="sessionFactoryBean" />
</property>
</bean>
- <bean id="listDao" class="net.sf.taverna.t2.reference.impl.HibernateListDao" >
+ <bean id="listDao" class="org.apache.taverna.reference.impl.HibernateListDao" >
<property name="sessionFactory">
<ref local="sessionFactoryBean" />
</property>
</bean>
- <bean id="errorDocumentDao" class="net.sf.taverna.t2.reference.impl.HibernateErrorDocumentDao" >
+ <bean id="errorDocumentDao" class="org.apache.taverna.reference.impl.HibernateErrorDocumentDao" >
<property name="sessionFactory">
<ref local="sessionFactoryBean" />
</property>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/spring/in-memory-reference-impl-context.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/spring/in-memory-reference-impl-context.xml b/taverna-reference-impl/src/main/resources/META-INF/spring/in-memory-reference-impl-context.xml
index 3508214..e9b025d 100644
--- a/taverna-reference-impl/src/main/resources/META-INF/spring/in-memory-reference-impl-context.xml
+++ b/taverna-reference-impl/src/main/resources/META-INF/spring/in-memory-reference-impl-context.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="inMemoryReferenceService" class="net.sf.taverna.t2.reference.impl.ReferenceServiceImpl">
+ <bean id="inMemoryReferenceService" class="org.apache.taverna.reference.impl.ReferenceServiceImpl">
<property name="converters" ref="converters" />
<property name="valueBuilders" ref="valueBuilders" />
<property name="referenceSetService">
@@ -17,7 +17,7 @@
</property>
</bean>
- <bean id="referenceSetService" class="net.sf.taverna.t2.reference.impl.ReferenceSetServiceImpl">
+ <bean id="referenceSetService" class="org.apache.taverna.reference.impl.ReferenceSetServiceImpl">
<property name="referenceSetDao">
<ref local="referenceSetDao" />
</property>
@@ -25,22 +25,22 @@
<property name="referenceSetAugmentor" ref="referenceSetAugmentor" />
</bean>
- <bean id="listService" class="net.sf.taverna.t2.reference.impl.ListServiceImpl">
+ <bean id="listService" class="org.apache.taverna.reference.impl.ListServiceImpl">
<property name="listDao">
<ref local="listDao" />
</property>
<property name="t2ReferenceGenerator" ref="t2ReferenceGenerator" />
</bean>
- <bean id="errorDocumentService" class="net.sf.taverna.t2.reference.impl.ErrorDocumentServiceImpl">
+ <bean id="errorDocumentService" class="org.apache.taverna.reference.impl.ErrorDocumentServiceImpl">
<property name="errorDao">
<ref local="errorDocumentDao" />
</property>
<property name="t2ReferenceGenerator" ref="t2ReferenceGenerator" />
</bean>
- <bean id="referenceSetDao" class="net.sf.taverna.t2.reference.impl.InMemoryReferenceSetDao" />
- <bean id="listDao" class="net.sf.taverna.t2.reference.impl.InMemoryListDao" />
- <bean id="errorDocumentDao" class="net.sf.taverna.t2.reference.impl.InMemoryErrorDocumentDao" />
+ <bean id="referenceSetDao" class="org.apache.taverna.reference.impl.InMemoryReferenceSetDao" />
+ <bean id="listDao" class="org.apache.taverna.reference.impl.InMemoryListDao" />
+ <bean id="errorDocumentDao" class="org.apache.taverna.reference.impl.InMemoryErrorDocumentDao" />
</beans>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context-osgi.xml b/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context-osgi.xml
index 27430cd..dd2f2c7 100644
--- a/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context-osgi.xml
+++ b/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context-osgi.xml
@@ -8,18 +8,18 @@
http://www.springframework.org/schema/osgi-compendium
http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">
- <list id="converters" interface="net.sf.taverna.t2.reference.ValueToReferenceConverterSPI" cardinality="0..N" />
- <list id="valueBuilders" interface="net.sf.taverna.t2.reference.StreamToValueConverterSPI" cardinality="0..N" />
- <list id="builders" interface="net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI" cardinality="0..N">
+ <list id="converters" interface="org.apache.taverna.reference.ValueToReferenceConverterSPI" cardinality="0..N" />
+ <list id="valueBuilders" interface="org.apache.taverna.reference.StreamToValueConverterSPI" cardinality="0..N" />
+ <list id="builders" interface="org.apache.taverna.reference.ExternalReferenceBuilderSPI" cardinality="0..N">
<listener ref="referenceSetAugmentor" bind-method="buildersUpdated" unbind-method="buildersUpdated" />
</list>
- <list id="translators" interface="net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI" cardinality="0..N">
+ <list id="translators" interface="org.apache.taverna.reference.ExternalReferenceTranslatorSPI" cardinality="0..N">
<listener ref="referenceSetAugmentor" bind-method="translatorsUpdated" unbind-method="translatorsUpdated" />
</list>
- <reference id="databaseManager" interface="uk.org.taverna.configuration.database.DatabaseManager"/>
+ <reference id="databaseManager" interface="org.apache.taverna.configuration.database.DatabaseManager"/>
- <service ref="inMemoryReferenceService" interface="net.sf.taverna.t2.reference.ReferenceService" />
- <service ref="hibernateReferenceService" interface="net.sf.taverna.t2.reference.ReferenceService" />
+ <service ref="inMemoryReferenceService" interface="org.apache.taverna.reference.ReferenceService" />
+ <service ref="hibernateReferenceService" interface="org.apache.taverna.reference.ReferenceService" />
</beans:beans>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context.xml b/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context.xml
index f87847b..855085b 100644
--- a/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context.xml
+++ b/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context.xml
@@ -3,12 +3,12 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="referenceSetAugmentor" class="net.sf.taverna.t2.reference.impl.ReferenceSetAugmentorImpl">
+ <bean id="referenceSetAugmentor" class="org.apache.taverna.reference.impl.ReferenceSetAugmentorImpl">
<property name="builders" ref="builders" />
<property name="translators" ref="translators" />
</bean>
- <bean id="t2ReferenceGenerator" class="net.sf.taverna.t2.reference.impl.UUIDT2ReferenceGenerator">
+ <bean id="t2ReferenceGenerator" class="org.apache.taverna.reference.impl.UUIDT2ReferenceGenerator">
<property name="namespace" value="taverna" />
</bean>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml b/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml
deleted file mode 100644
index 0bf7bba..0000000
--- a/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for ErrorDocumentImpl -->
-<hibernate-mapping>
- <class name="net.sf.taverna.t2.reference.impl.ErrorDocumentImpl"
- abstract="false">
- <id name="internalId" column="id" type="string"/>
- <!-- Composite key constructed from the namespace and local -->
- <!-- parts of the T2Reference implementation type -->
- <component name="typedId"
- class="net.sf.taverna.t2.reference.impl.T2ReferenceImpl">
- <property name="namespacePart" />
- <property name="localPart" />
- <property name="containsErrors"/>
- <property name="depth"/>
- <property name="referenceType"/>
- </component>
- <property name="message" length="10000"/>
- <property name="exceptionMessage" length="10000"/>
- <list name="stackTraceList" cascade="all" lazy="false">
- <key column="id" not-null="true"/>
- <list-index column="i" base="0" />
- <composite-element
- class="net.sf.taverna.t2.reference.impl.StackTraceElementBeanImpl">
- <property name="fileName" />
- <property name="className" />
- <property name="methodName" />
- <property name="lineNumber" />
- </composite-element>
- </list>
- <set name="errorReferenceSet" cascade="all" lazy="false">
- <key column="id" not-null="true"/>
- <composite-element
- class="net.sf.taverna.t2.reference.impl.T2ReferenceImpl">
- <property name="namespacePart" />
- <property name="localPart" />
- <property name="containsErrors"/>
- <property name="depth"/>
- <property name="referenceType"/>
- </composite-element>
- </set>
- </class>
-</hibernate-mapping>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml b/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml
deleted file mode 100644
index 04c316d..0000000
--- a/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for ReferenceSetImpl -->
-<hibernate-mapping>
- <class name="net.sf.taverna.t2.reference.impl.ReferenceSetImpl"
- abstract="false" lazy="false">
- <id name="internalId" column="id" type="string"
- unsaved-value="null" />
-
- <!-- Composite key constructed from the namespace and local -->
- <!-- parts of the T2Reference implementation type, used as -->
- <!-- the foreign key in the one to many relationship with -->
- <!-- extensions of AbstractExternalReference -->
-
- <component name="typedId"
- class="net.sf.taverna.t2.reference.impl.T2ReferenceImpl">
- <property name="namespacePart" />
- <property name="localPart" />
- <property name="containsErrors" />
- <property name="depth" />
- <property name="referenceType" />
- </component>
- <set name="externalReferences" cascade="all" lazy="false">
- <key column="id" />
- <one-to-many
- class="net.sf.taverna.t2.reference.AbstractExternalReference" />
- </set>
- <property name="approximateSizeInBytes" />
- </class>
-</hibernate-mapping>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml b/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml
deleted file mode 100644
index b24c333..0000000
--- a/taverna-reference-impl/src/main/resources/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for T2ReferenceListImpl, used by HibernateListDao -->
-<hibernate-mapping>
- <class name="net.sf.taverna.t2.reference.impl.T2ReferenceListImpl"
- abstract="false">
- <id name="internalId" column="id" type="string"/>
- <!-- Composite key constructed from the namespace and local -->
- <!-- parts of the T2Reference implementation type, used as -->
- <!-- the foreign key in the one to many relationship with -->
- <!-- extensions of AbstractExternalReference -->
- <component name="typedId"
- class="net.sf.taverna.t2.reference.impl.T2ReferenceImpl">
- <property name="namespacePart" />
- <property name="localPart" />
- <property name="containsErrors" />
- <property name="depth" />
- <property name="referenceType" />
- </component>
- <list name="listContents" cascade="all" lazy="false">
- <key column="id"/>
- <list-index column="i" base="0" />
- <composite-element
- class="net.sf.taverna.t2.reference.impl.T2ReferenceImpl">
- <!-- Explicit column mapping otherwise we collide with the implicit -->
- <!-- mapping used in the key columns. Oh the joys of composites.. -->
- <property name="namespacePart" column="c_namespace" />
- <property name="localPart" column="c_local" />
- <property name="containsErrors" column="c_errors" />
- <property name="depth" column="c_depth" />
- <property name="referenceType" column="c_type" />
- </composite-element>
- </list>
- </class>
-</hibernate-mapping>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml b/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml
new file mode 100644
index 0000000..54b3532
--- /dev/null
+++ b/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for ErrorDocumentImpl -->
+<hibernate-mapping>
+ <class abstract="false" name="org.apache.taverna.reference.impl.ErrorDocumentImpl">
+ <id column="id" name="internalId" type="string"/>
+ <!-- Composite key constructed from the namespace and local -->
+ <!-- parts of the T2Reference implementation type -->
+ <component class="org.apache.taverna.reference.impl.T2ReferenceImpl" name="typedId">
+ <property name="namespacePart"/>
+ <property name="localPart"/>
+ <property name="containsErrors"/>
+ <property name="depth"/>
+ <property name="referenceType"/>
+ </component>
+ <property length="10000" name="message"/>
+ <property length="10000" name="exceptionMessage"/>
+ <list cascade="all" lazy="false" name="stackTraceList">
+ <key column="id" not-null="true"/>
+ <list-index base="0" column="i"/>
+ <composite-element class="org.apache.taverna.reference.impl.StackTraceElementBeanImpl">
+ <property name="fileName"/>
+ <property name="className"/>
+ <property name="methodName"/>
+ <property name="lineNumber"/>
+ </composite-element>
+ </list>
+ <set cascade="all" lazy="false" name="errorReferenceSet">
+ <key column="id" not-null="true"/>
+ <composite-element class="org.apache.taverna.reference.impl.T2ReferenceImpl">
+ <property name="namespacePart"/>
+ <property name="localPart"/>
+ <property name="containsErrors"/>
+ <property name="depth"/>
+ <property name="referenceType"/>
+ </composite-element>
+ </set>
+ </class>
+</hibernate-mapping>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml b/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml
new file mode 100644
index 0000000..b8c7e9a
--- /dev/null
+++ b/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for ReferenceSetImpl -->
+<hibernate-mapping>
+ <class abstract="false" lazy="false" name="org.apache.taverna.reference.impl.ReferenceSetImpl">
+ <id column="id" name="internalId" type="string" unsaved-value="null"/>
+ <!-- Composite key constructed from the namespace and local -->
+ <!-- parts of the T2Reference implementation type, used as -->
+ <!-- the foreign key in the one to many relationship with -->
+ <!-- extensions of AbstractExternalReference -->
+ <component class="org.apache.taverna.reference.impl.T2ReferenceImpl" name="typedId">
+ <property name="namespacePart"/>
+ <property name="localPart"/>
+ <property name="containsErrors"/>
+ <property name="depth"/>
+ <property name="referenceType"/>
+ </component>
+ <set cascade="all" lazy="false" name="externalReferences">
+ <key column="id"/>
+ <one-to-many class="org.apache.taverna.reference.AbstractExternalReference"/>
+ </set>
+ <property name="approximateSizeInBytes"/>
+ </class>
+</hibernate-mapping>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml b/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml
new file mode 100644
index 0000000..7d980e9
--- /dev/null
+++ b/taverna-reference-impl/src/main/resources/org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for T2ReferenceListImpl, used by HibernateListDao -->
+<hibernate-mapping>
+ <class abstract="false" name="org.apache.taverna.reference.impl.T2ReferenceListImpl">
+ <id column="id" name="internalId" type="string"/>
+ <!-- Composite key constructed from the namespace and local -->
+ <!-- parts of the T2Reference implementation type, used as -->
+ <!-- the foreign key in the one to many relationship with -->
+ <!-- extensions of AbstractExternalReference -->
+ <component class="org.apache.taverna.reference.impl.T2ReferenceImpl" name="typedId">
+ <property name="namespacePart"/>
+ <property name="localPart"/>
+ <property name="containsErrors"/>
+ <property name="depth"/>
+ <property name="referenceType"/>
+ </component>
+ <list cascade="all" lazy="false" name="listContents">
+ <key column="id"/>
+ <list-index base="0" column="i"/>
+ <composite-element class="org.apache.taverna.reference.impl.T2ReferenceImpl">
+ <!-- Explicit column mapping otherwise we collide with the implicit -->
+ <!-- mapping used in the key columns. Oh the joys of composites.. -->
+ <property column="c_namespace" name="namespacePart"/>
+ <property column="c_local" name="localPart"/>
+ <property column="c_errors" name="containsErrors"/>
+ <property column="c_depth" name="depth"/>
+ <property column="c_type" name="referenceType"/>
+ </composite-element>
+ </list>
+ </class>
+</hibernate-mapping>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/platform/spring/jdbc/TemporaryJDBCTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/platform/spring/jdbc/TemporaryJDBCTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/platform/spring/jdbc/TemporaryJDBCTest.java
deleted file mode 100644
index 449f2b6..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/platform/spring/jdbc/TemporaryJDBCTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.platform.spring.jdbc;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-
-import org.junit.Test;
-
-/**
- * Test {@link TemporaryJDBC}
- *
- * @author Stian Soiland-Reyes
- *
- */
-public class TemporaryJDBCTest {
-
- private static final String DB = ".db";
- private static final String T2PLATFORM = "t2platform-";
- private static final String CREATE_TRUE = ";create=true";
- private static final String JDBC_DERBY = "jdbc:derby:";
-
- @Test
- public void getDerby() throws Exception {
- TemporaryJDBC temporaryJDBC = new TemporaryJDBC();
- String jdbcURL = temporaryJDBC.getTemporaryDerbyJDBC();
- assertTrue("Not a Derby URL", jdbcURL.startsWith(JDBC_DERBY));
- String url = jdbcURL.split(JDBC_DERBY)[1];
- assertTrue("Did not end with " + CREATE_TRUE, url.endsWith(CREATE_TRUE));
- String location = url.split(CREATE_TRUE)[0];
- assertFalse("Location was an empty string", location.equals(""));
- File locationFile = new File(location);
- assertFalse("File already exists: " + locationFile, locationFile.exists());
- File parentFile = locationFile.getParentFile();
- assertTrue("Parent directory did not exist", parentFile.isDirectory());
- assertTrue("Did not end with " + T2PLATFORM, parentFile.getName().startsWith(T2PLATFORM));
- assertTrue("Did not start with " + DB , parentFile.getName().endsWith(DB));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/AppContextSetup.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/AppContextSetup.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/AppContextSetup.java
deleted file mode 100644
index 62b6427..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/AppContextSetup.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class AppContextSetup {
- public static List<ApplicationContext> contextList;
-
- public static void setup() throws Exception {
- if (contextList == null){
-
- contextList = new ArrayList<ApplicationContext>();
- //Add all three contexts for storing referenced data
- contextList = new ArrayList<ApplicationContext>();
- ApplicationContext context = null;
- context = new ClassPathXmlApplicationContext(
- "vanillaHibernateAppContext.xml"); // hibernate context
- contextList.add(context);
- context = new ClassPathXmlApplicationContext(
- "vanillaInMemoryAppContext.xml");
- contextList.add(context); // in memory
- context = new ClassPathXmlApplicationContext(
- "vanillaHibernateTransactionalAppContext.xml");
- contextList.add(context); // transactional hibernate context
-
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/DatabaseSetupTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/DatabaseSetupTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/DatabaseSetupTest.java
deleted file mode 100644
index 24f1ce9..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/DatabaseSetupTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.HashSet;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ListDao;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.ReferenceSetDao;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.T2ReferenceType;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.context.ApplicationContext;
-
-/**
- * Tests initialization of the Derby database and Hibernate ORM system
- *
- * @author Tom Oinn
- */
-public class DatabaseSetupTest {
-
- @Before
- public void setup() throws Exception {
- AppContextSetup.setup();
- }
-
-
- @Test
- public void testListStorage() {
- ApplicationContext context = AppContextSetup.contextList.get(0); // Hibernate context
- ListDao o = (ListDao) context.getBean("testListDao");
- T2ReferenceImpl listReference = new T2ReferenceImpl();
- listReference.setContainsErrors(false);
- listReference.setDepth(1);
- listReference.setLocalPart("list1");
- listReference.setNamespacePart("testNamespace");
- listReference.setReferenceType(T2ReferenceType.IdentifiedList);
-
- T2ReferenceListImpl l = new T2ReferenceListImpl();
-
- T2ReferenceImpl itemId1 = new T2ReferenceImpl();
- itemId1.setNamespacePart("testNamespace");
- itemId1.setLocalPart("item1");
- T2ReferenceImpl itemId2 = new T2ReferenceImpl();
- itemId2.setNamespacePart("testNamespace");
- itemId2.setLocalPart("item2");
-
- l.add(itemId1);
- l.add(itemId2);
-
- l.setTypedId(listReference);
-
- System.out.println(l);
-
- o.store(l);
-
- T2ReferenceImpl listReference2 = new T2ReferenceImpl();
- listReference2.setContainsErrors(false);
- listReference2.setDepth(1);
- listReference2.setLocalPart("list1");
- listReference2.setNamespacePart("testNamespace");
- listReference2.setReferenceType(T2ReferenceType.IdentifiedList);
-
- System.out.println(o.get(listReference2));
-
- }
-
- @SuppressWarnings("serial")
- @Test
- public void testDatabaseReadWriteWithoutPlugins() {
- ApplicationContext context = AppContextSetup.contextList.get(0); // Hibernate context
- ReferenceSetDao o = (ReferenceSetDao) context
- .getBean("testDao");
- T2ReferenceImpl id = new T2ReferenceImpl();
- id.setNamespacePart("testNamespace");
- id.setLocalPart("testLocal");
- ReferenceSetImpl rs = new ReferenceSetImpl(
- new HashSet<ExternalReferenceSPI>(), id);
- o.store(rs);
-
-
- // Retrieve with a new instance of an anonymous subclass of
- // ReferenceSetT2ReferenceImpl, just to check that hibernate can cope
- // with this. It can, but this *must* be a subclass of the registered
- // component type, which means we need to modify the component type to
- // be the fully generic T2Reference with all fields accessed via
- // properties.
- T2Reference newReference = new T2ReferenceImpl() {
-
- @Override
- public boolean containsErrors() {
- return false;
- }
-
- @Override
- public int getDepth() {
- return 0;
- }
-
- @Override
- public String getLocalPart() {
- return "testLocal";
- }
-
- @Override
- public String getNamespacePart() {
- return "testNamespace";
- }
-
- };
-
-
- ReferenceSet returnedset = o.get(newReference);
- Assert.assertNotNull(returnedset.getId());
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentDaoTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentDaoTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentDaoTest.java
deleted file mode 100644
index d5d47af..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentDaoTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import net.sf.taverna.t2.reference.ErrorDocumentDao;
-import net.sf.taverna.t2.reference.T2ReferenceType;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.context.ApplicationContext;
-
-public class ErrorDocumentDaoTest {
-
- @Before
- public void setup() throws Exception {
- AppContextSetup.setup();
- }
-
- @Test
- public void testStore() throws Exception {
- for (ApplicationContext context : AppContextSetup.contextList){
-
- ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
- ErrorDocumentImpl doc = new ErrorDocumentImpl();
- T2ReferenceImpl id = new T2ReferenceImpl();
- id.setReferenceType(T2ReferenceType.ErrorDocument);
- id.setDepth(0);
- id.setContainsErrors(true);
- id.setNamespacePart("testNamespace0");
- id.setLocalPart("testLocal0");
-
- doc.setExceptionMessage("An exception");
-
- T2ReferenceImpl typedId = T2ReferenceImpl.getAsImpl(id);
-
- doc.setTypedId(typedId);
-
- dao.store(doc);
- assertNotNull(dao.get(id));
- }
- }
-
- /**
- * Tests that .get returns null when its missing, rather than throw an exception
- */
- @Test
- public void getMissingItemReturnsNull() {
- for (ApplicationContext context : AppContextSetup.contextList){
- ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
- ErrorDocumentImpl doc = new ErrorDocumentImpl();
- T2ReferenceImpl id = new T2ReferenceImpl();
- id.setReferenceType(T2ReferenceType.ErrorDocument);
- id.setDepth(0);
- id.setContainsErrors(true);
- id.setNamespacePart("testNamespace1");
- id.setLocalPart("testLocal1");
-
- doc.setExceptionMessage("An exception");
-
- T2ReferenceImpl typedId = T2ReferenceImpl.getAsImpl(id);
-
- doc.setTypedId(typedId);
- assertNull(dao.get(id));
- }
- }
-
- @Test
- public void testDelete() throws Exception {
- for (ApplicationContext context : AppContextSetup.contextList){
-
- ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
- ErrorDocumentImpl doc = new ErrorDocumentImpl();
- T2ReferenceImpl id = new T2ReferenceImpl();
- id.setReferenceType(T2ReferenceType.ErrorDocument);
- id.setDepth(0);
- id.setContainsErrors(true);
- id.setNamespacePart("testNamespace2");
- id.setLocalPart("testLocal2");
-
- doc.setExceptionMessage("An exception");
-
- T2ReferenceImpl typedId = T2ReferenceImpl.getAsImpl(id);
-
- doc.setTypedId(typedId);
-
- dao.store(doc);
- assertNotNull(dao.get(id));
-
- assertTrue(dao.delete(doc));
- assertNull(dao.get(id));
- }
-
- }
-
- @Test
- public void testDeleteErrorDocumentsForWFRun() throws Exception {
- for (ApplicationContext context : AppContextSetup.contextList){
-
- ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
-
- ErrorDocumentImpl doc1 = new ErrorDocumentImpl();
- T2ReferenceImpl id1 = new T2ReferenceImpl();
- id1.setReferenceType(T2ReferenceType.ErrorDocument);
- id1.setDepth(0);
- id1.setContainsErrors(true);
- id1.setNamespacePart("wfRunErrorDocTest1");
- id1.setLocalPart("testLocal1");
- doc1.setExceptionMessage("An exception 1");
- T2ReferenceImpl typedId1 = T2ReferenceImpl.getAsImpl(id1);
- doc1.setTypedId(typedId1);
- dao.store(doc1);
- assertNotNull(dao.get(id1));
-
- ErrorDocumentImpl doc2 = new ErrorDocumentImpl();
- T2ReferenceImpl id2 = new T2ReferenceImpl();
- id2.setReferenceType(T2ReferenceType.ErrorDocument);
- id2.setDepth(0);
- id2.setContainsErrors(true);
- id2.setNamespacePart("wfRunErrorDocTest1");
- id2.setLocalPart("testLocal2");
- doc2.setExceptionMessage("An exception 2");
- T2ReferenceImpl typedId2 = T2ReferenceImpl.getAsImpl(id2);
- doc2.setTypedId(typedId2);
- dao.store(doc2);
- assertNotNull(dao.get(id2));
-
- ErrorDocumentImpl doc3 = new ErrorDocumentImpl();
- T2ReferenceImpl id3 = new T2ReferenceImpl();
- id3.setReferenceType(T2ReferenceType.ErrorDocument);
- id3.setDepth(0);
- id3.setContainsErrors(true);
- id3.setNamespacePart("wfRunErrorDocTest2");
- id3.setLocalPart("testLocal3");
- doc3.setExceptionMessage("An exception 3");
- T2ReferenceImpl typedId3 = T2ReferenceImpl.getAsImpl(id3);
- doc3.setTypedId(typedId3);
- dao.store(doc3);
- assertNotNull(dao.get(id3));
-
- dao.deleteErrorDocumentsForWFRun("wfRunErrorDocTest1");
-
- assertNull(dao.get(id1));
- assertNull(dao.get(id2));
- assertNotNull(dao.get(id3));
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceTest.java
deleted file mode 100644
index e035922..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.reference.ErrorDocument;
-import net.sf.taverna.t2.reference.ErrorDocumentDao;
-import net.sf.taverna.t2.reference.WorkflowRunIdEntity;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class ErrorDocumentServiceTest {
-
- private List<ErrorDocumentServiceImpl> serviceList = new ArrayList<ErrorDocumentServiceImpl>();
-
- @Before
- public void setup() throws Exception {
-
- AppContextSetup.setup();
-
- ErrorDocumentServiceImpl service = null;
-
- service = new ErrorDocumentServiceImpl();
- service.setErrorDao((ErrorDocumentDao)AppContextSetup.contextList.get(0).getBean("testErrorDao")); // hiberate
- service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
- serviceList.add(service);
-
- service = new ErrorDocumentServiceImpl();
- service.setErrorDao((ErrorDocumentDao)AppContextSetup.contextList.get(1).getBean("testErrorDao")); // in memory
- service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
- serviceList.add(service);
-
- service = new ErrorDocumentServiceImpl();
- service.setErrorDao((ErrorDocumentDao)AppContextSetup.contextList.get(2).getBean("testErrorDao")); // transactional hibernate
- service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
- serviceList.add(service);
-
- }
-
- @Test
- public void testDelete() throws Exception {
- ReferenceContextImpl invocationContext = new ReferenceContextImpl();
- invocationContext.addEntity(new WorkflowRunIdEntity("wfRunErrorDocTest"));
- for (ErrorDocumentServiceImpl service : serviceList){
- ErrorDocument doc = service.registerError("Fred", 0, invocationContext);
- assertNotNull(service.getError(doc.getId()));
- assertTrue(service.delete(doc.getId()));
- assertNull(service.getError(doc.getId()));
- assertFalse(service.delete(doc.getId()));
- }
- }
-
- @Test
- public void testDeleteErrorDocumentsForWFRun() throws Exception {
-
- for (ErrorDocumentServiceImpl service : serviceList){
-
- String wfRunId1 = "wfRunErrorDocTest1";
- ReferenceContextImpl invocationContext1 = new ReferenceContextImpl();
- invocationContext1.addEntity(new WorkflowRunIdEntity(wfRunId1));
-
- String wfRunId2 = "wfRunErrorDocTest2";
- ReferenceContextImpl invocationContext2 = new ReferenceContextImpl();
- invocationContext2.addEntity(new WorkflowRunIdEntity(wfRunId2));
-
- ErrorDocument doc1 = service.registerError("Fred1", 0, invocationContext1);
- ErrorDocument doc2 = service.registerError("Fred2", 0, invocationContext1);
- ErrorDocument doc3 = service.registerError("Fred3", 0, invocationContext2);
-
- assertNotNull(service.getError(doc1.getId()));
- assertNotNull(service.getError(doc2.getId()));
- assertNotNull(service.getError(doc3.getId()));
-
- service.deleteErrorDocumentsForWorkflowRun(wfRunId1);
-
- assertNull(service.getError(doc1.getId()));
- assertNull(service.getError(doc2.getId()));
- assertNotNull(service.getError(doc3.getId()));
-
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListDaoTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListDaoTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListDaoTest.java
deleted file mode 100644
index a39d353..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListDaoTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import net.sf.taverna.t2.reference.ListDao;
-import net.sf.taverna.t2.reference.T2ReferenceType;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.context.ApplicationContext;
-
-public class ListDaoTest {
-
- @Before
- public void setup() throws Exception {
- AppContextSetup.setup();
- }
-
- @Test
- public void testStore() throws Exception {
- for (ApplicationContext context : AppContextSetup.contextList){
- ListDao dao = (ListDao)context.getBean("testListDao");
- T2ReferenceImpl r = new T2ReferenceImpl();
- r.setNamespacePart("testNamespace0");
- r.setLocalPart("testLocal0");
- r.setReferenceType(T2ReferenceType.IdentifiedList);
- r.setDepth(0);
- r.setContainsErrors(false);
- T2ReferenceListImpl newList = new T2ReferenceListImpl();
- newList.setTypedId(r);
- dao.store(newList);
- assertNotNull(dao.get(r));
- }
- }
-
- /**
- * Tests that .get returns null when its missing, rather than throw an exception
- */
- @Test
- public void getMissingItemReturnsNull() {
- for (ApplicationContext context : AppContextSetup.contextList){
- ListDao dao = (ListDao)context.getBean("testListDao");
- T2ReferenceImpl r = new T2ReferenceImpl();
- r.setNamespacePart("testNamespace1");
- r.setLocalPart("testLocal1");
- r.setReferenceType(T2ReferenceType.IdentifiedList);
- r.setDepth(0);
- r.setContainsErrors(false);
- T2ReferenceListImpl newList = new T2ReferenceListImpl();
- newList.setTypedId(r);
- assertNull(dao.get(r));
- }
- }
-
- @Test
- public void testDelete() throws Exception {
- for (ApplicationContext context : AppContextSetup.contextList){
- ListDao dao = (ListDao)context.getBean("testListDao");
- T2ReferenceImpl r = new T2ReferenceImpl();
- r.setNamespacePart("testNamespace2");
- r.setLocalPart("testLocal2");
- r.setReferenceType(T2ReferenceType.IdentifiedList);
- r.setDepth(0);
- r.setContainsErrors(false);
- T2ReferenceListImpl newList = new T2ReferenceListImpl();
- newList.setTypedId(r);
- dao.store(newList);
- assertNotNull(dao.get(r));
- assertTrue(dao.delete(newList));
- assertNull(dao.get(r));
- }
- }
-
- @Test
- public void testIdentifiedListsForWFRun() throws Exception {
- for (ApplicationContext context : AppContextSetup.contextList){
- ListDao dao = (ListDao)context.getBean("testListDao");
-
- T2ReferenceImpl r1 = new T2ReferenceImpl();
- r1.setReferenceType(T2ReferenceType.IdentifiedList);
- r1.setDepth(0);
- r1.setContainsErrors(true);
- r1.setNamespacePart("wfRunListsTest1");
- r1.setLocalPart("testLocal1");
- T2ReferenceListImpl list1 = new T2ReferenceListImpl();
- list1.setTypedId(r1);
- dao.store(list1);
- assertNotNull(dao.get(r1));
-
- T2ReferenceImpl r2 = new T2ReferenceImpl();
- r2.setReferenceType(T2ReferenceType.IdentifiedList);
- r2.setDepth(1);
- r2.setContainsErrors(true);
- r2.setNamespacePart("wfRunListsTest1");
- r2.setLocalPart("testLocal2");
- T2ReferenceListImpl list2 = new T2ReferenceListImpl();
- list2.setTypedId(r2);
- dao.store(list2);
- assertNotNull(dao.get(r2));
-
- T2ReferenceImpl r3 = new T2ReferenceImpl();
- r3.setReferenceType(T2ReferenceType.IdentifiedList);
- r3.setDepth(0);
- r3.setContainsErrors(true);
- r3.setNamespacePart("wfRunListsTest2");
- r3.setLocalPart("testLocal3");
- T2ReferenceListImpl list3 = new T2ReferenceListImpl();
- list3.setTypedId(r3);
- dao.store(list3);
- assertNotNull(dao.get(r3));
-
- dao.deleteIdentifiedListsForWFRun("wfRunListsTest1");
-
- assertNull(dao.get(r1));
- assertNull(dao.get(r2));
- assertNotNull(dao.get(r3));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListServiceTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListServiceTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListServiceTest.java
deleted file mode 100644
index 062337a..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListServiceTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.reference.IdentifiedList;
-import net.sf.taverna.t2.reference.ListDao;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.WorkflowRunIdEntity;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class ListServiceTest {
-
- private List<ListServiceImpl> serviceList = new ArrayList<ListServiceImpl>();
-
- @Before
- public void setup() throws Exception {
-
- AppContextSetup.setup();
-
- ListServiceImpl service = null;
-
- service = new ListServiceImpl();
- service.setListDao((ListDao)AppContextSetup.contextList.get(0).getBean("testListDao")); // hibernate
- service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
- serviceList.add(service);
-
- service = new ListServiceImpl();
- service.setListDao((ListDao)AppContextSetup.contextList.get(1).getBean("testListDao")); // in memory
- service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
- serviceList.add(service);
-
-
- service = new ListServiceImpl();
- service.setListDao((ListDao)AppContextSetup.contextList.get(2).getBean("testListDao")); // transactional hibernate
- service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
- serviceList.add(service);
-
- }
-
- @Test
- public void testDelete() throws Exception {
- ReferenceContextImpl invocationContext = new ReferenceContextImpl();
- invocationContext.addEntity(new WorkflowRunIdEntity("wfRunListsTest"));
- for (ListServiceImpl service : serviceList){
- IdentifiedList<T2Reference> list =service.registerEmptyList(1, invocationContext);
- assertNotNull(service.getList(list.getId()));
- assertTrue(service.delete(list.getId()));
- assertNull(service.getList(list.getId()));
- assertFalse(service.delete(list.getId()));
- }
- }
-
- @Test
- public void testDeleteIdentifiedListsForWFRun() throws Exception {
-
- for (ListServiceImpl service : serviceList){
-
- String wfRunId1 = "wfRunListsTest1";
- ReferenceContextImpl invocationContext1 = new ReferenceContextImpl();
- invocationContext1.addEntity(new WorkflowRunIdEntity(wfRunId1));
-
- String wfRunId2 = "wfRunListsTest2";
- ReferenceContextImpl invocationContext2 = new ReferenceContextImpl();
- invocationContext2.addEntity(new WorkflowRunIdEntity(wfRunId2));
-
- IdentifiedList<T2Reference> list1 = service.registerEmptyList(2, invocationContext1);
- IdentifiedList<T2Reference> list2 = service.registerEmptyList(1, invocationContext1);
- IdentifiedList<T2Reference> list3 = service.registerEmptyList(1, invocationContext2);
-
- assertNotNull(service.getList(list1.getId()));
- assertNotNull(service.getList(list2.getId()));
- assertNotNull(service.getList(list3.getId()));
-
- service.deleteIdentifiedListsForWorkflowRun(wfRunId1);
-
- assertNull(service.getList(list1.getId()));
- assertNull(service.getList(list2.getId()));
- assertNotNull(service.getList(list3.getId()));
-
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceContextImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceContextImpl.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceContextImpl.java
deleted file mode 100644
index a898d27..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceContextImpl.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-class ReferenceContextImpl implements ReferenceContext{
- private List<Object> entities;
-
- public ReferenceContextImpl(){
- entities = new ArrayList<Object>();
- }
-
- @Override
- public <T> List<T> getEntities(Class<T> entityType) {
- List<T> entitiesOfType = new ArrayList<T>();
- for (Object entity : entities){
- if (entityType.isInstance(entity)){
- entitiesOfType.add(entityType.cast(entity));
- }
- }
- return entitiesOfType;
- }
-
- @Override
- public void addEntity(Object entity){
- entities.add(entity);
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetDaoTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetDaoTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetDaoTest.java
deleted file mode 100644
index f453cca..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetDaoTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.HashSet;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceSetDao;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.context.ApplicationContext;
-
-public class ReferenceSetDaoTest {
-
- @Before
- public void setup() throws Exception {
-
- AppContextSetup.setup();
- }
-
- @Test
- public void testStore() throws Exception {
- for (ApplicationContext context : AppContextSetup.contextList){
- ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
- T2ReferenceImpl id = new T2ReferenceImpl();
- id.setNamespacePart("testNamespace0");
- id.setLocalPart("testLocal0");
- ReferenceSetImpl rs = new ReferenceSetImpl(
- new HashSet<ExternalReferenceSPI>(), id);
- dao.store(rs);
- assertNotNull(dao.get(id));
- }
- }
-
- @Test
- public void testDelete() throws Exception {
- for (ApplicationContext context : AppContextSetup.contextList){
- ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
- T2ReferenceImpl id = new T2ReferenceImpl();
- id.setNamespacePart("testNamespace1");
- id.setLocalPart("testLocal1");
- ReferenceSetImpl rs = new ReferenceSetImpl(
- new HashSet<ExternalReferenceSPI>(), id);
- dao.store(rs);
- assertNotNull(dao.get(id));
- assertTrue(dao.delete(rs));
- assertNull(dao.get(id));
- }
- }
-
- @Test
- public void testDeleteRerefenceSetsForWFRun() throws Exception {
- for (ApplicationContext context : AppContextSetup.contextList){
- ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
-
- T2ReferenceImpl id1 = new T2ReferenceImpl();
- id1.setNamespacePart("wfRunRefSetTest1");
- id1.setLocalPart("testLocal1");
- ReferenceSetImpl rs1 = new ReferenceSetImpl(
- new HashSet<ExternalReferenceSPI>(), id1);
- dao.store(rs1);
- assertNotNull(dao.get(id1));
-
- T2ReferenceImpl id2 = new T2ReferenceImpl();
- id2.setNamespacePart("wfRunRefSetTest1");
- id2.setLocalPart("testLocal2");
- ReferenceSetImpl rs2 = new ReferenceSetImpl(
- new HashSet<ExternalReferenceSPI>(), id2);
- dao.store(rs2);
- assertNotNull(dao.get(id2));
-
- T2ReferenceImpl id3 = new T2ReferenceImpl();
- id3.setNamespacePart("wfRunRefSetTest2");
- id3.setLocalPart("testLocal3");
- ReferenceSetImpl rs3 = new ReferenceSetImpl(
- new HashSet<ExternalReferenceSPI>(), id3);
- dao.store(rs3);
- assertNotNull(dao.get(id3));
-
- dao.deleteReferenceSetsForWFRun("wfRunRefSetTest1");
-
- assertNull(dao.get(id1));
- assertNull(dao.get(id2));
- assertNotNull(dao.get(id3));
- }
- }
-
- /**
- * Tests that .get returns null when its missing, rather than throw an exception
- */
- @Test
- public void getMissingItemReturnsNull() {
- for (ApplicationContext context : AppContextSetup.contextList){
- ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
- T2ReferenceImpl id = new T2ReferenceImpl();
- id.setNamespacePart("testNamespace2");
- id.setLocalPart("testLocal2");
- assertNull(dao.get(id));
- }
- }
-
-}