http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleCacheProviderImpl.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleCacheProviderImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleCacheProviderImpl.java deleted file mode 100644 index ccbf67b..0000000 --- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleCacheProviderImpl.java +++ /dev/null @@ -1,57 +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.HashMap; -import java.util.Map; - -import net.sf.taverna.t2.reference.Identified; -import net.sf.taverna.t2.reference.ReferenceServiceCacheProvider; -import net.sf.taverna.t2.reference.T2Reference; - -import org.apache.log4j.Logger; - -/** - * Completely naive cache provider that just stores everything in a map. This - * <em>will</em> run out of memory as it makes no attempt to evict old items, - * it's really just here as a test! - * - * @author Tom Oinn - */ -public class SimpleCacheProviderImpl implements ReferenceServiceCacheProvider { - private final Logger log = Logger.getLogger(SimpleCacheProviderImpl.class); - private Map<T2Reference, Identified> cache = new HashMap<>(); - - @Override - public Identified get(T2Reference id) { - if (log.isDebugEnabled()) - log.debug("Get " + id.toString() + " (" + cache.containsKey(id) - + ")"); - return cache.get(id); - } - - @Override - public void put(Identified i) { - if (log.isDebugEnabled()) - log.debug("Put " + i.getId().toString()); - cache.put(i.getId(), i); - } -}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleT2ReferenceGenerator.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleT2ReferenceGenerator.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleT2ReferenceGenerator.java deleted file mode 100644 index 897fc96..0000000 --- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/SimpleT2ReferenceGenerator.java +++ /dev/null @@ -1,63 +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 net.sf.taverna.t2.reference.T2ReferenceGenerator; - -/** - * Simple implementation of T2ReferenceGenerator intended to be injected into - * the service layers for integration testing. Exposes a namespace property - * which can be configured through spring and allocates local parts based on an - * integer counter - this is only guaranteed to be unique within a single - * instance of this object so isn't suitable for real production use. For proper - * usage use an implementation tied to the backing store you're putting t2 - * reference objects into. - * - * @author Tom Oinn - */ -public class SimpleT2ReferenceGenerator extends AbstractT2ReferenceGenerator implements T2ReferenceGenerator { - private String namespace = "testNS"; - private String localPrefix = "test"; - private int counter = 0; - - /** - * 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; - } - - /** - * Get the namespace for identifiers generated by this class - */ - @Override - public String getNamespace() { - return namespace; - } - - @Override - protected synchronized String getNextLocalPart() { - return localPrefix + (counter++); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/StackTraceElementBeanImpl.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/StackTraceElementBeanImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/StackTraceElementBeanImpl.java deleted file mode 100644 index 6943127..0000000 --- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/StackTraceElementBeanImpl.java +++ /dev/null @@ -1,77 +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 net.sf.taverna.t2.reference.StackTraceElementBean; -import net.sf.taverna.t2.reference.h3.HibernateComponentClass; - -/** - * Simple bean implementation of StackTraceElement for Hibernate - * - * @author Tom Oinn - */ -public class StackTraceElementBeanImpl implements StackTraceElementBean, - HibernateComponentClass { - private String className; - private String fileName; - private String methodName; - private int lineNumber; - - public StackTraceElementBeanImpl() { - // - } - - @Override - public String getClassName() { - return this.className; - } - - public void setClassName(String className) { - this.className = className; - } - - @Override - public String getFileName() { - return this.fileName; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - @Override - public int getLineNumber() { - return lineNumber; - } - - public void setLineNumber(int lineNumber) { - this.lineNumber = lineNumber; - } - - @Override - public String getMethodName() { - return this.methodName; - } - - public void setMethodName(String methodName) { - this.methodName = methodName; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceImpl.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceImpl.java deleted file mode 100644 index f5f00d3..0000000 --- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceImpl.java +++ /dev/null @@ -1,288 +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 static net.sf.taverna.t2.reference.T2ReferenceType.ErrorDocument; - -import java.io.Serializable; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.UUID; - -import net.sf.taverna.t2.reference.T2Reference; -import net.sf.taverna.t2.reference.T2ReferenceType; -import net.sf.taverna.t2.reference.h3.HibernateComponentClass; - -import org.apache.log4j.Logger; - -/** - * An implementation of T2Reference specific to the ReferenceSetImpl. This is - * needed because ReferenceSetImpl uses a component based primary key driven - * from the namespace and local parts of T2Reference. This in turn means we can - * query hibernate directly with a T2Reference instance in the data access - * object. Because this is only used as a component (i.e. a value type) we don't - * need to define a hibernate mapping file for it. - * - * @author Tom Oinn - * @author David Withers - */ -public class T2ReferenceImpl implements T2Reference, Serializable, HibernateComponentClass { - private static Logger logger = Logger.getLogger(T2ReferenceImpl.class); - - private static final long serialVersionUID = 8363330461158750319L; - private String localPart; - private String namespacePart; - private long localMostSigBits, localLeastSigBits; - private boolean containsErrors = false; - private T2ReferenceType referenceType = T2ReferenceType.ReferenceSet; - private int depth = 0; - private transient URI cachedURI; - - public T2ReferenceImpl() { - // Default constructor for Hibernate et al - } - - /** - * Construct a deep copy of the given T2Reference - * - * @param source - * T2Reference to copy - */ - private T2ReferenceImpl(T2Reference source) { - super(); - setNamespacePart(source.getNamespacePart()); - setLocalPart(source.getLocalPart()); - setContainsErrors(source.containsErrors()); - setReferenceType(source.getReferenceType()); - setDepth(source.getDepth()); - } - - public static T2ReferenceImpl getAsImpl(T2Reference source) { - if (source instanceof T2ReferenceImpl) - return (T2ReferenceImpl) source; - return new T2ReferenceImpl(source); - } - - /** - * Return whether the identified entity either is or contains errors - */ - @Override - public boolean containsErrors() { - return this.containsErrors; - } - - /** - * Property accessor for Hibernate, complies with java bean spec - */ - public boolean getContainsErrors() { - return this.containsErrors; - } - - /** - * Get the depth of the entity referred to by this reference - */ - @Override - public int getDepth() { - return this.depth; - } - - /** - * Get the local part of the URI for this reference - */ - @Override - public String getLocalPart() { - if (localPart == null) { - UUID localPartUUID = new UUID(localMostSigBits, localLeastSigBits); - return localPartUUID.toString(); - } - return localPart; - } - - /** - * Get the namespace part of the URI for this reference - */ - @Override - public String getNamespacePart() { - return namespacePart; - } - - /** - * Get the type of the entity to which this reference refers - */ - @Override - public T2ReferenceType getReferenceType() { - return referenceType; - } - - /** - * This method is only ever called from within Hibernate when - * re-constructing the identifier component to set the namespace part of the - * identifier. - */ - public synchronized void setNamespacePart(String namespacePart) { - this.namespacePart = namespacePart; - } - - /** - * This method is only ever called from within Hibernate when - * re-constructing the identifier component to set the local part of the - * identifier. - */ - public synchronized void setLocalPart(String localPart) { - try { - UUID namespacePartUUID = UUID.fromString(localPart); - localMostSigBits = namespacePartUUID.getMostSignificantBits(); - localLeastSigBits = namespacePartUUID.getLeastSignificantBits(); - this.localPart = null; - } catch (IllegalArgumentException e) { - this.localPart = localPart; - } - } - - /** - * This method is only ever called from within Hibernate when - * re-constructing the identifier component to set the depth of the - * identifier. - */ - public synchronized void setDepth(int depth) { - this.depth = depth; - } - - /** - * This method is only ever called from within Hibernate when - * re-constructing the identifier component to set the error property of the - * identifier. - */ - public synchronized void setContainsErrors(boolean containsErrors) { - this.containsErrors = containsErrors; - } - - /** - * This method is only ever called from within Hibernate when - * re-constructing the identifier component to set the reference type - * property of the identifier. - */ - public synchronized void setReferenceType(T2ReferenceType type) { - this.referenceType = type; - } - - /** - * By default when printing an identifier we use {@link #toUri()}. - * {@link java.net.URI#toASCIIString() toASCIIString()} - */ - @Override - public String toString() { - return toUri().toASCIIString(); - } - - /** - * Drill inside an error document reference to get the error one deeper than - * this as long as it is at least depth 1. - */ - T2ReferenceImpl getDeeperErrorReference() { - if (!getReferenceType().equals(ErrorDocument)) - throw new AssertionError( - "Attempt to get a deeper reference on something that isn't an error ref"); - if (getDepth() == 0) - throw new AssertionError( - "Error identifier already has depth 0, cannot decrease"); - - T2ReferenceImpl result = new T2ReferenceImpl(); - result.setContainsErrors(true); - result.setDepth(getDepth() - 1); - result.setLocalPart(getLocalPart()); - result.setNamespacePart(getNamespacePart()); - result.setReferenceType(ErrorDocument); - return result; - } - - /** - * Returns the identifier expressed as a {@link java.net.URI URI}, - * constructed based on the reference type. For references to ReferenceSet - * this is - * <code>new URI("t2:ref//" + namespacePart + "?" + localPart)</code> - * leading to URIs of the form <code>t2:ref//namespace?local</code> - */ - @Override - public synchronized URI toUri() { - try { - if (cachedURI == null) - switch (referenceType) { - case ReferenceSet: - cachedURI = new URI("t2:ref//" + getNamespacePart() + "?" - + getLocalPart()); - case IdentifiedList: - cachedURI = new URI("t2:list//" + getNamespacePart() + "?" - + getLocalPart() + "/" + containsErrors + "/" - + depth); - case ErrorDocument: - cachedURI = new URI("t2:error//" + getNamespacePart() + "?" - + getLocalPart() + "/" + depth); - } - } catch (URISyntaxException e) { - logger.error("Unable to create URI", e); - } - return cachedURI; - } - - @Override - public int hashCode() { - int result = 1; - result = 31 * result + depth; - result = 31 * result + (int) (localLeastSigBits ^ (localLeastSigBits >>> 32)); - result = 31 * result + (int) (localMostSigBits ^ (localMostSigBits >>> 32)); - result = 31 * result + ((localPart == null) ? 0 : localPart.hashCode()); - result = 31 * result + ((namespacePart == null) ? 0 : namespacePart.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - T2ReferenceImpl other = (T2ReferenceImpl) obj; - if (depth != other.depth) - return false; - if (localLeastSigBits != other.localLeastSigBits) - return false; - if (localMostSigBits != other.localMostSigBits) - return false; - if (localPart == null) { - if (other.localPart != null) - return false; - } else if (!localPart.equals(other.localPart)) - return false; - if (namespacePart == null) { - if (other.namespacePart != null) - return false; - } else if (!namespacePart.equals(other.namespacePart)) - return false; - return true; - } - - public synchronized String getCompactForm() { - return getNamespacePart() + ":" + getLocalPart() + ":" + getDepth(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.java deleted file mode 100644 index 3b865dd..0000000 --- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.java +++ /dev/null @@ -1,75 +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.List; - -import net.sf.taverna.t2.reference.T2Reference; -import net.sf.taverna.t2.reference.h3.HibernateMappedEntity; - -/** - * Simple extension of - * <code>{@link IdentifiedArrayList IdentifiedArrayList<T2Reference>}</code> - * exposing get and set methods for the list contents so we can map it in - * hibernate. - * - * @author Tom Oinn - */ -public class T2ReferenceListImpl extends IdentifiedArrayList<T2Reference> - implements HibernateMappedEntity { - public T2ReferenceListImpl() { - super(); - } - - /** - * This is only called from Hibernate, outside of test code, so is - * relatively safe to leave unchecked. - */ - @SuppressWarnings("rawtypes") - public List getListContents() { - return this.listDelegate; - } - - /** - * This is only called from Hibernate, outside of test code, so is - * relatively safe to leave unchecked. - */ - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void setListContents(List newList) { - this.listDelegate = newList; - } - - /** - * Print the contents of this list for vaguely human readable debug - * purposes. - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(getId()).append("\n"); - int counter = 0; - for (T2Reference ref : listDelegate) - sb.append(" ").append(++counter).append(") ").append(ref) - .append("\n"); - return sb.toString(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateErrorDocumentDao.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateErrorDocumentDao.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateErrorDocumentDao.java deleted file mode 100644 index 987facb..0000000 --- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateErrorDocumentDao.java +++ /dev/null @@ -1,155 +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 static net.sf.taverna.t2.reference.T2ReferenceType.ErrorDocument; - -import java.util.List; - -import net.sf.taverna.t2.reference.DaoException; -import net.sf.taverna.t2.reference.ErrorDocument; -import net.sf.taverna.t2.reference.ErrorDocumentDao; -import net.sf.taverna.t2.reference.T2Reference; -import net.sf.taverna.t2.reference.annotations.DeleteIdentifiedOperation; -import net.sf.taverna.t2.reference.annotations.GetIdentifiedOperation; -import net.sf.taverna.t2.reference.annotations.PutIdentifiedOperation; - -import org.hibernate.Query; -import org.hibernate.SessionFactory; - -/** - * An implementation of ErrorDocumentDao 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 TransactionalHibernateErrorDocumentDao implements ErrorDocumentDao { - private static final String GET_ERRORS_FOR_RUN = "FROM ErrorDocumentImpl WHERE namespacePart = :workflow_run_id"; - private SessionFactory sessionFactory; - - public void setSessionFactory(SessionFactory sessionFactory) { - this.sessionFactory = sessionFactory; - } - - /** - * Fetch an ErrorDocument list by id - * - * @param ref - * the T2Reference to fetch - * @return a retrieved identified list of T2 references - * @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 ErrorDocument get(T2Reference ref) throws DaoException { - if (ref == null) - throw new DaoException( - "Supplied reference is null, can't retrieve."); - if (!ref.getReferenceType().equals(ErrorDocument)) - throw new DaoException( - "This dao can only retrieve reference of type T2Reference.ErrorDocument"); - if (!(ref instanceof T2ReferenceImpl)) - throw new DaoException( - "Reference must be an instance of T2ReferenceImpl"); - - try { - return (ErrorDocumentImpl) sessionFactory.getCurrentSession().get( - ErrorDocumentImpl.class, - ((T2ReferenceImpl) ref).getCompactForm()); - } catch (Exception ex) { - throw new DaoException(ex); - } - } - - @Override - @PutIdentifiedOperation - public void store(ErrorDocument theDocument) throws DaoException { - if (theDocument.getId() == null) - throw new DaoException( - "Supplied error document set has a null ID, allocate " - + "an ID before calling the store method in the dao."); - if (!theDocument.getId().getReferenceType().equals(ErrorDocument)) - throw new DaoException("Strangely the list ID doesn't have type " - + "T2ReferenceType.ErrorDocument, something has probably " - + "gone badly wrong somewhere earlier!"); - if (!(theDocument instanceof ErrorDocumentImpl)) - throw new DaoException( - "Supplied ErrorDocument not an instance of ErrorDocumentImpl"); - - try { - sessionFactory.getCurrentSession().save(theDocument); - } catch (Exception ex) { - throw new DaoException(ex); - } - } - - @Override - @DeleteIdentifiedOperation - public boolean delete(ErrorDocument theDocument) throws DaoException { - if (theDocument.getId() == null) - throw new DaoException( - "Supplied error document set has a null ID, allocate " - + "an ID before calling the store method in the dao."); - if (!theDocument.getId().getReferenceType().equals(ErrorDocument)) - throw new DaoException("Strangely the list ID doesn't have type " - + "T2ReferenceType.ErrorDocument, something has probably " - + "gone badly wrong somewhere earlier!"); - if (!(theDocument instanceof ErrorDocumentImpl)) - throw new DaoException( - "Supplied ErrorDocument not an instance of ErrorDocumentImpl"); - - try { - sessionFactory.getCurrentSession().delete(theDocument); - return true; - } catch (Exception ex) { - throw new DaoException(ex); - } - } - - @Override - @SuppressWarnings("unchecked") - @DeleteIdentifiedOperation - public synchronized void deleteErrorDocumentsForWFRun(String workflowRunId) - throws DaoException { - try { - // Select all ErrorDocuments for this wf run - Query selectQuery = sessionFactory.getCurrentSession().createQuery( - GET_ERRORS_FOR_RUN); - selectQuery.setString("workflow_run_id", workflowRunId); - List<ErrorDocument> errorDocuments = selectQuery.list(); - for (ErrorDocument errorDocument : errorDocuments) - delete(errorDocument); - } catch (Exception ex) { - throw new DaoException(ex); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateListDao.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateListDao.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateListDao.java deleted file mode 100644 index 1a57041..0000000 --- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateListDao.java +++ /dev/null @@ -1,154 +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 static net.sf.taverna.t2.reference.T2ReferenceType.IdentifiedList; - -import java.util.List; - -import net.sf.taverna.t2.reference.DaoException; -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.annotations.DeleteIdentifiedOperation; -import net.sf.taverna.t2.reference.annotations.GetIdentifiedOperation; -import net.sf.taverna.t2.reference.annotations.PutIdentifiedOperation; - -import org.hibernate.Query; -import org.hibernate.SessionFactory; - -/** - * An implementation of ListDao based on 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 TransactionalHibernateListDao implements ListDao { - private static final String GET_REFLISTS_FOR_RUN = "FROM T2ReferenceListImpl WHERE namespacePart = :workflow_run_id"; - private SessionFactory sessionFactory; - - public void setSessionFactory(SessionFactory sessionFactory) { - this.sessionFactory = sessionFactory; - } - - /** - * Fetch a t2reference list by id - * - * @param ref - * the T2Reference to fetch - * @return a retrieved identified list of T2 references - * @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 IdentifiedList<T2Reference> get(T2Reference ref) throws DaoException { - if (ref == null) - throw new DaoException( - "Supplied reference is null, can't retrieve."); - if (!ref.getReferenceType().equals(IdentifiedList)) - throw new DaoException( - "This dao can only retrieve reference of type T2Reference.IdentifiedList"); - if (!(ref instanceof T2ReferenceImpl)) - throw new DaoException( - "Reference must be an instance of T2ReferenceImpl"); - - try { - return (T2ReferenceListImpl) sessionFactory.getCurrentSession() - .get(T2ReferenceListImpl.class, - ((T2ReferenceImpl) ref).getCompactForm()); - } catch (Exception ex) { - throw new DaoException(ex); - } - } - - @Override - @PutIdentifiedOperation - public void store(IdentifiedList<T2Reference> theList) throws DaoException { - if (theList.getId() == null) - throw new DaoException("Supplied list set has a null ID, allocate " - + "an ID before calling the store method in the dao."); - if (!theList.getId().getReferenceType().equals(IdentifiedList)) - throw new DaoException("Strangely the list ID doesn't have type " - + "T2ReferenceType.IdentifiedList, something has probably " - + "gone badly wrong somewhere earlier!"); - if (!(theList instanceof T2ReferenceListImpl)) - throw new DaoException( - "Supplied identifier list not an instance of T2ReferenceList"); - - try { - sessionFactory.getCurrentSession().save(theList); - } catch (Exception ex) { - throw new DaoException(ex); - } - } - - @Override - public boolean delete(IdentifiedList<T2Reference> theList) - throws DaoException { - if (theList.getId() == null) - throw new DaoException("Supplied list set has a null ID, allocate " - + "an ID before calling the store method in the dao."); - if (!theList.getId().getReferenceType().equals(IdentifiedList)) - throw new DaoException("Strangely the list ID doesn't have type " - + "T2ReferenceType.IdentifiedList, something has probably " - + "gone badly wrong somewhere earlier!"); - if (!(theList instanceof T2ReferenceListImpl)) - throw new DaoException( - "Supplied identifier list not an instance of T2ReferenceList"); - - try { - sessionFactory.getCurrentSession().delete(theList); - return true; - } catch (Exception ex) { - throw new DaoException(ex); - } - } - - @Override - @SuppressWarnings("unchecked") - @DeleteIdentifiedOperation - public synchronized void deleteIdentifiedListsForWFRun(String workflowRunId) - throws DaoException { - try { - // Select all T2Reference lists for this wf run - Query selectQuery = sessionFactory.getCurrentSession().createQuery( - GET_REFLISTS_FOR_RUN); - selectQuery.setString("workflow_run_id", workflowRunId); - List<IdentifiedList<T2Reference>> referenceLists = selectQuery - .list(); - for (IdentifiedList<T2Reference> referenceList : referenceLists) - delete(referenceList); - } catch (Exception ex) { - throw new DaoException(ex); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateReferenceSetDao.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateReferenceSetDao.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateReferenceSetDao.java deleted file mode 100644 index 2fc1edd..0000000 --- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TransactionalHibernateReferenceSetDao.java +++ /dev/null @@ -1,198 +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 static net.sf.taverna.t2.reference.T2ReferenceType.ReferenceSet; - -import java.util.List; - -import net.sf.taverna.t2.reference.DaoException; -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.annotations.DeleteIdentifiedOperation; -import net.sf.taverna.t2.reference.annotations.GetIdentifiedOperation; -import net.sf.taverna.t2.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/3ecb1291/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TranslationPath.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TranslationPath.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TranslationPath.java deleted file mode 100644 index bd4a1f0..0000000 --- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/TranslationPath.java +++ /dev/null @@ -1,266 +0,0 @@ -package net.sf.taverna.t2.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 net.sf.taverna.t2.reference.DereferenceException; -import net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI; -import net.sf.taverna.t2.reference.ExternalReferenceSPI; -import net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI; -import net.sf.taverna.t2.reference.ReferenceContext; -import net.sf.taverna.t2.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/3ecb1291/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/UUIDT2ReferenceGenerator.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/UUIDT2ReferenceGenerator.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/UUIDT2ReferenceGenerator.java deleted file mode 100644 index 9e6bbef..0000000 --- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/UUIDT2ReferenceGenerator.java +++ /dev/null @@ -1,56 +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.UUID; - -import net.sf.taverna.t2.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/3ecb1291/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/WriteQueueAspect.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/WriteQueueAspect.java b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/WriteQueueAspect.java deleted file mode 100644 index be1b68b..0000000 --- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/WriteQueueAspect.java +++ /dev/null @@ -1,142 +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 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 net.sf.taverna.t2.reference.DaoException; -import net.sf.taverna.t2.reference.Identified; -import net.sf.taverna.t2.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/3ecb1291/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/package.html ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/package.html b/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/package.html deleted file mode 100644 index 79e0107..0000000 --- a/taverna-reference-impl/src/main/java/net/sf/taverna/t2/reference/impl/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<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/3ecb1291/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/3ecb1291/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/3ecb1291/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 deleted file mode 100644 index 462f844..0000000 --- a/taverna-reference-impl/src/main/resources/META-INF/spring.handlers +++ /dev/null @@ -1 +0,0 @@ -http\://taverna.sf.net/schema/artifact-support=net.sf.taverna.platform.spring.ArtifactSupportNamespaceHandler \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-impl/src/main/resources/META-INF/spring.schemas ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/resources/META-INF/spring.schemas b/taverna-reference-impl/src/main/resources/META-INF/spring.schemas deleted file mode 100644 index a4a0513..0000000 --- a/taverna-reference-impl/src/main/resources/META-INF/spring.schemas +++ /dev/null @@ -1 +0,0 @@ -http\://taverna.sf.net/schema/artifact-support/artifact-support.xsd=artifact-support.xsd \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/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 deleted file mode 100644 index 4fb8ba4..0000000 --- a/taverna-reference-impl/src/main/resources/META-INF/spring/hibernate-reference-impl-context.xml +++ /dev/null @@ -1,117 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - 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"> - <property name="converters" ref="converters" /> - <property name="valueBuilders" ref="valueBuilders" /> - <property name="referenceSetService"> - <ref local="referenceSetService" /> - </property> - <property name="listService"> - <ref local="listService" /> - </property> - <property name="errorDocumentService"> - <ref local="errorDocumentService" /> - </property> - </bean> - - <bean id="referenceSetService" class="net.sf.taverna.t2.reference.impl.ReferenceSetServiceImpl"> - <property name="referenceSetDao"> - <ref local="referenceSetDao" /> - </property> - <property name="t2ReferenceGenerator" ref="t2ReferenceGenerator" /> - <property name="referenceSetAugmentor" ref="referenceSetAugmentor" /> - </bean> - - <bean id="listService" class="net.sf.taverna.t2.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"> - <property name="errorDao"> - <ref local="errorDocumentDao" /> - </property> - <property name="t2ReferenceGenerator" ref="t2ReferenceGenerator" /> - </bean> - - <bean id="dataSource" class="javax.sql.DataSource" - factory-bean="databaseManager" - factory-method="getDataSource" /> - - <!-- Configure hibernate to use dynamic schema update --> - <bean id="hibernateProperties" - class="org.springframework.beans.factory.config.PropertiesFactoryBean"> - <property name="properties"> - <props> - <prop key="hibernate.hbm2ddl.auto">create</prop> - <prop key="hibernate.dialect"> - org.hibernate.dialect.DerbyDialect - </prop> - <prop key="hibernate.query.substitutions"> - true 'T', false 'F' - </prop> - <prop key="hibernate.show_sql">false</prop> - <prop key="hibernate.c3p0.minPoolSize">5</prop> - <prop key="hibernate.c3p0.maxPoolSize">20</prop> - <prop key="hibernate.c3p0.timeout">600</prop> - <prop key="hibernate.c3p0.max_statement">50</prop> - <prop key="hibernate.c3p0.testConnectionOnCheckout"> - false - </prop> - <prop key="show_sql">true</prop> - <prop key="format_sql">true</prop> - </props> - </property> - </bean> - - <!-- A regular hibernate session factory --> - <bean id="sessionFactoryBean" - class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> - <property name="dataSource"> - <ref local="dataSource" /> - </property> - <property name="hibernateProperties"> - <ref bean="hibernateProperties" /> - </property> - <property name="mappingResources"> - <list> - <value> - net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml - </value> - <value> - net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml - </value> - <value> - net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml - </value> - <value> - net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml - </value> - </list> - </property> - </bean> - - <bean id="referenceSetDao" class="net.sf.taverna.t2.reference.impl.HibernateReferenceSetDao" > - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - - <bean id="listDao" class="net.sf.taverna.t2.reference.impl.HibernateListDao" > - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - - <bean id="errorDocumentDao" class="net.sf.taverna.t2.reference.impl.HibernateErrorDocumentDao" > - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - -</beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/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 deleted file mode 100644 index 3508214..0000000 --- a/taverna-reference-impl/src/main/resources/META-INF/spring/in-memory-reference-impl-context.xml +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - 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"> - <property name="converters" ref="converters" /> - <property name="valueBuilders" ref="valueBuilders" /> - <property name="referenceSetService"> - <ref local="referenceSetService" /> - </property> - <property name="listService"> - <ref local="listService" /> - </property> - <property name="errorDocumentService"> - <ref local="errorDocumentService" /> - </property> - </bean> - - <bean id="referenceSetService" class="net.sf.taverna.t2.reference.impl.ReferenceSetServiceImpl"> - <property name="referenceSetDao"> - <ref local="referenceSetDao" /> - </property> - <property name="t2ReferenceGenerator" ref="t2ReferenceGenerator" /> - <property name="referenceSetAugmentor" ref="referenceSetAugmentor" /> - </bean> - - <bean id="listService" class="net.sf.taverna.t2.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"> - <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" /> - -</beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/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 deleted file mode 100644 index 27430cd..0000000 --- a/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context-osgi.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans:beans xmlns="http://www.springframework.org/schema/osgi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:beans="http://www.springframework.org/schema/beans" xmlns:osgix="http://www.springframework.org/schema/osgi-compendium" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/osgi - http://www.springframework.org/schema/osgi/spring-osgi.xsd - 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"> - <listener ref="referenceSetAugmentor" bind-method="buildersUpdated" unbind-method="buildersUpdated" /> - </list> - <list id="translators" interface="net.sf.taverna.t2.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"/> - - <service ref="inMemoryReferenceService" interface="net.sf.taverna.t2.reference.ReferenceService" /> - <service ref="hibernateReferenceService" interface="net.sf.taverna.t2.reference.ReferenceService" /> - -</beans:beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/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 deleted file mode 100644 index f87847b..0000000 --- a/taverna-reference-impl/src/main/resources/META-INF/spring/reference-impl-context.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - 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"> - <property name="builders" ref="builders" /> - <property name="translators" ref="translators" /> - </bean> - - <bean id="t2ReferenceGenerator" class="net.sf.taverna.t2.reference.impl.UUIDT2ReferenceGenerator"> - <property name="namespace" value="taverna" /> - </bean> - -</beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-impl/src/main/resources/artifact-support.xsd ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/resources/artifact-support.xsd b/taverna-reference-impl/src/main/resources/artifact-support.xsd deleted file mode 100644 index 9fd6891..0000000 --- a/taverna-reference-impl/src/main/resources/artifact-support.xsd +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<xsd:schema xmlns="http://taverna.sf.net/schema/artifact-support" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:beans="http://www.springframework.org/schema/beans" - targetNamespace="http://taverna.sf.net/schema/artifact-support" - elementFormDefault="qualified"> - - <xsd:import namespace="http://www.springframework.org/schema/beans" /> - - <xsd:attribute name="artifact" type="xsd:string" /> - <xsd:attribute name="repository" type="xsd:string" /> - - <xsd:element name="repository"> - <xsd:complexType> - <xsd:complexContent> - <xsd:extension base="beans:identifiedType"> - <xsd:all> - <xsd:element ref="system" /> - <xsd:element ref="repositories" /> - </xsd:all> - <xsd:attribute name="base" type="xsd:string" - use="required" /> - </xsd:extension> - </xsd:complexContent> - </xsd:complexType> - </xsd:element> - - <xsd:element name="system"> - <xsd:complexType> - <xsd:sequence maxOccurs="unbounded" minOccurs="0"> - <xsd:element ref="sys" /> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - - <xsd:element name="sys"> - <xsd:complexType> - <xsd:attribute name="artifact" type="xsd:string" use="required"/> - </xsd:complexType> - </xsd:element> - - <xsd:element name="repositories"> - <xsd:complexType> - <xsd:sequence maxOccurs="unbounded" minOccurs="0"> - <xsd:element ref="rep" /> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - - <xsd:element name="rep"> - <xsd:complexType> - <xsd:attribute name="url" type="xsd:anyURI" use="required" /> - </xsd:complexType> - </xsd:element> - - -</xsd:schema> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/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/3ecb1291/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/3ecb1291/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/3ecb1291/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)); - } - -}
