Repository: incubator-taverna-engine Updated Branches: refs/heads/master 24c1ed998 -> 0f7b70a9c
Removed hibernate dependency Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/commit/0f7b70a9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/tree/0f7b70a9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/diff/0f7b70a9 Branch: refs/heads/master Commit: 0f7b70a9c63f99fb6466fb1d0329423c64ed11b7 Parents: 24c1ed9 Author: Alan R Williams <[email protected]> Authored: Tue Jul 28 14:34:18 2015 +0100 Committer: Alan R Williams <[email protected]> Committed: Tue Jul 28 14:34:18 2015 +0100 ---------------------------------------------------------------------- taverna-reference-impl/pom.xml | 33 +--- .../impl/HibernateErrorDocumentDao.java | 153 -------------- .../reference/impl/HibernateListDao.java | 150 -------------- .../impl/HibernateReferenceSetDao.java | 197 ------------------- .../TransactionalHibernateErrorDocumentDao.java | 154 --------------- .../impl/TransactionalHibernateListDao.java | 153 -------------- .../TransactionalHibernateReferenceSetDao.java | 197 ------------------- ...taverna.reference.h3.HibernateComponentClass | 2 - ...e.taverna.reference.h3.HibernateMappedEntity | 3 - .../spring/hibernate-reference-impl-context.xml | 117 ----------- .../taverna/reference/impl/AppContextSetup.java | 13 +- .../reference/impl/DatabaseSetupTest.java | 139 ------------- .../impl/ErrorDocumentServiceTest.java | 15 +- .../taverna/reference/impl/ListServiceTest.java | 16 +- .../reference/impl/ReferenceSetServiceTest.java | 21 +- .../resources/vanillaHibernateAppContext.xml | 120 ----------- .../vanillaHibernateTransactionalAppContext.xml | 118 ----------- 17 files changed, 24 insertions(+), 1577 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/0f7b70a9/taverna-reference-impl/pom.xml ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/pom.xml b/taverna-reference-impl/pom.xml index 98f3b4d..6f530bd 100644 --- a/taverna-reference-impl/pom.xml +++ b/taverna-reference-impl/pom.xml @@ -34,9 +34,7 @@ <Import-Package> org.aspectj.lang, org.springframework.orm.*, - org.hibernate.*, - org.hibernate.cfg, - org.hibernate.proxy, * + * </Import-Package> <!-- <Import-Package> org.aspectj.lang;resolution:=optional, org.springframework.orm.*;resolution:=optional, org.hibernate.*;resolution:=optional, org.hibernate.proxy;resolution:=optional, @@ -79,30 +77,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.hibernate</groupId> - <artifactId>com.springsource.org.hibernate</artifactId> - <version>${hibernate.version}</version> - <!-- <optional>true</optional> --> - <exclusions> - <exclusion> - <groupId>javax.transaction</groupId> - <artifactId>jta</artifactId> - </exclusion> - <exclusion> - <groupId>net.sf.ehcache</groupId> - <artifactId>ehcache</artifactId> - </exclusion> - <exclusion> - <groupId>asm</groupId> - <artifactId>asm-attrs</artifactId> - </exclusion> - <exclusion> - <groupId>antlr</groupId> - <artifactId>antlr</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> <groupId>javax.transaction</groupId> <artifactId>com.springsource.javax.transaction</artifactId> <version>${javax.transaction.version}</version> @@ -112,6 +86,11 @@ <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>${commons.logging.version}</version> + </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/0f7b70a9/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateErrorDocumentDao.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateErrorDocumentDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateErrorDocumentDao.java deleted file mode 100644 index fe86880..0000000 --- a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateErrorDocumentDao.java +++ /dev/null @@ -1,153 +0,0 @@ -/* -* 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.ErrorDocument; - -import java.util.List; - -import org.apache.taverna.reference.DaoException; -import org.apache.taverna.reference.ErrorDocument; -import org.apache.taverna.reference.ErrorDocumentDao; -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.Session; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -/** - * An implementation of ErrorDocumentDao based on Spring's HibernateDaoSupport. - * 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). - * - * @author Tom Oinn - */ -public class HibernateErrorDocumentDao extends HibernateDaoSupport implements - ErrorDocumentDao { - private static final String GET_ERRORS_FOR_RUN = "FROM ErrorDocumentImpl WHERE namespacePart = :workflow_run_id"; - - /** - * 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) getHibernateTemplate().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 { - getHibernateTemplate().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 { - getHibernateTemplate().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 - Session session = getSession(); - Query selectQuery = session.createQuery(GET_ERRORS_FOR_RUN); - selectQuery.setString("workflow_run_id", workflowRunId); - List<ErrorDocument> errorDocuments = selectQuery.list(); - session.close(); - /* - * need to close before we do delete otherwise hibernate complains - * that two sessions are accessing collection - */ - getHibernateTemplate().deleteAll(errorDocuments); - } catch (Exception ex) { - throw new DaoException(ex); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/0f7b70a9/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateListDao.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateListDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateListDao.java deleted file mode 100644 index f7c0cbd..0000000 --- a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateListDao.java +++ /dev/null @@ -1,150 +0,0 @@ -/* -* 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.IdentifiedList; - -import java.util.List; - -import org.apache.taverna.reference.DaoException; -import org.apache.taverna.reference.IdentifiedList; -import org.apache.taverna.reference.ListDao; -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.Session; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -/** - * An implementation of ListDao based on Spring's HibernateDaoSupport. 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). - * - * @author Tom Oinn - */ -public class HibernateListDao extends HibernateDaoSupport implements ListDao { - private static final String GET_LISTS_FOR_RUN = "FROM T2ReferenceListImpl WHERE namespacePart = :workflow_run_id"; - - /** - * 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) getHibernateTemplate().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 { - getHibernateTemplate().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 { - getHibernateTemplate().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 - Session session = getSession(); - Query selectQuery = session.createQuery(GET_LISTS_FOR_RUN); - selectQuery.setString("workflow_run_id", workflowRunId); - List<IdentifiedList<T2Reference>> identifiedLists = selectQuery - .list(); - session.close(); - /* - * need to close before we do delete otherwise hibernate complains - * that two sessions are accessing collection - */ - getHibernateTemplate().deleteAll(identifiedLists); - } catch (Exception ex) { - throw new DaoException(ex); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/0f7b70a9/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateReferenceSetDao.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateReferenceSetDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateReferenceSetDao.java deleted file mode 100644 index c710aa7..0000000 --- a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/HibernateReferenceSetDao.java +++ /dev/null @@ -1,197 +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 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.Session; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -/** - * An implementation of ReferenceSetDao based on Spring's HibernateDaoSupport. - * 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). - * - * @author Tom Oinn - */ -public class HibernateReferenceSetDao extends HibernateDaoSupport implements - ReferenceSetDao { - private static final String GET_REFSETS_FOR_RUN = "FROM ReferenceSetImpl WHERE namespacePart = :workflow_run_id"; - - /** - * 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 { - getHibernateTemplate().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 { - getHibernateTemplate().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) getHibernateTemplate().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 { - getHibernateTemplate().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 - Session session = getSession(); - Query selectQuery = session - .createQuery(GET_REFSETS_FOR_RUN); - selectQuery.setString("workflow_run_id", workflowRunId); - List<ReferenceSet> referenceSets = selectQuery.list(); - session.close(); - /* - * need to close before we do delete otherwise hibernate complains - * that two sessions are accessing collection - */ - getHibernateTemplate().deleteAll(referenceSets); - } catch (Exception ex) { - throw new DaoException(ex); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/0f7b70a9/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateErrorDocumentDao.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateErrorDocumentDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateErrorDocumentDao.java deleted file mode 100644 index 38a6988..0000000 --- a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateErrorDocumentDao.java +++ /dev/null @@ -1,154 +0,0 @@ -/* -* 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.ErrorDocument; - -import java.util.List; - -import org.apache.taverna.reference.DaoException; -import org.apache.taverna.reference.ErrorDocument; -import org.apache.taverna.reference.ErrorDocumentDao; -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 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/0f7b70a9/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateListDao.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateListDao.java b/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateListDao.java deleted file mode 100644 index 3cc6561..0000000 --- a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateListDao.java +++ /dev/null @@ -1,153 +0,0 @@ -/* -* 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.IdentifiedList; - -import java.util.List; - -import org.apache.taverna.reference.DaoException; -import org.apache.taverna.reference.IdentifiedList; -import org.apache.taverna.reference.ListDao; -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 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/0f7b70a9/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 deleted file mode 100644 index 67e5cac..0000000 --- a/taverna-reference-impl/src/main/java/org/apache/taverna/reference/impl/TransactionalHibernateReferenceSetDao.java +++ /dev/null @@ -1,197 +0,0 @@ -/* -* 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/0f7b70a9/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 deleted file mode 100644 index 913661c..0000000 --- a/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateComponentClass +++ /dev/null @@ -1,2 +0,0 @@ -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/0f7b70a9/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 deleted file mode 100644 index d9f0cf4..0000000 --- a/taverna-reference-impl/src/main/resources/META-INF/services/org.apache.taverna.reference.h3.HibernateMappedEntity +++ /dev/null @@ -1,3 +0,0 @@ -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/0f7b70a9/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 ad4ed52..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="org.apache.taverna.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="org.apache.taverna.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="org.apache.taverna.reference.impl.ListServiceImpl"> - <property name="listDao"> - <ref local="listDao" /> - </property> - <property name="t2ReferenceGenerator" ref="t2ReferenceGenerator" /> - </bean> - - <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="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> - org/apache/taverna/reference/AbstractExternalReference.hbm.xml - </value> - <value> - org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml - </value> - <value> - org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml - </value> - <value> - org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml - </value> - </list> - </property> - </bean> - - <bean id="referenceSetDao" class="org.apache.taverna.reference.impl.HibernateReferenceSetDao" > - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - - <bean id="listDao" class="org.apache.taverna.reference.impl.HibernateListDao" > - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - - <bean id="errorDocumentDao" class="org.apache.taverna.reference.impl.HibernateErrorDocumentDao" > - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - -</beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/0f7b70a9/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/AppContextSetup.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/AppContextSetup.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/AppContextSetup.java index fb3d1f0..edca360 100644 --- a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/AppContextSetup.java +++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/AppContextSetup.java @@ -31,19 +31,12 @@ public class AppContextSetup { public static void setup() throws Exception { if (contextList == null){ + //Add the contexts for storing referenced data 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( + ApplicationContext 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/0f7b70a9/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/DatabaseSetupTest.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/DatabaseSetupTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/DatabaseSetupTest.java deleted file mode 100644 index 265719c..0000000 --- a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/DatabaseSetupTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* -* 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.HashSet; - -import org.apache.taverna.reference.ExternalReferenceSPI; -import org.apache.taverna.reference.ListDao; -import org.apache.taverna.reference.ReferenceSet; -import org.apache.taverna.reference.ReferenceSetDao; -import org.apache.taverna.reference.T2Reference; -import org.apache.taverna.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/0f7b70a9/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentServiceTest.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentServiceTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentServiceTest.java index a7b8425..83837f1 100644 --- a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentServiceTest.java +++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentServiceTest.java @@ -33,6 +33,7 @@ import org.apache.taverna.reference.WorkflowRunIdEntity; import org.junit.Before; import org.junit.Test; +import org.springframework.context.ApplicationContext; public class ErrorDocumentServiceTest { @@ -45,20 +46,12 @@ public class ErrorDocumentServiceTest { ErrorDocumentServiceImpl service = null; + for (ApplicationContext context : AppContextSetup.contextList) { service = new ErrorDocumentServiceImpl(); - service.setErrorDao((ErrorDocumentDao)AppContextSetup.contextList.get(0).getBean("testErrorDao")); // hiberate + service.setErrorDao((ErrorDocumentDao) context.getBean("testErrorDao")); 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); + } } http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/0f7b70a9/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListServiceTest.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListServiceTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListServiceTest.java index 1d40730..f0414ac 100644 --- a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListServiceTest.java +++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListServiceTest.java @@ -34,6 +34,7 @@ import org.apache.taverna.reference.WorkflowRunIdEntity; import org.junit.Before; import org.junit.Test; +import org.springframework.context.ApplicationContext; public class ListServiceTest { @@ -46,22 +47,13 @@ public class ListServiceTest { 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); - + for (ApplicationContext context : AppContextSetup.contextList) { service = new ListServiceImpl(); - service.setListDao((ListDao)AppContextSetup.contextList.get(2).getBean("testListDao")); // transactional hibernate + service.setListDao((ListDao)context.getBean("testListDao")); service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator()); serviceList.add(service); - + } } @Test http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/0f7b70a9/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetServiceTest.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetServiceTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetServiceTest.java index 8eb39f4..119cb92 100644 --- a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetServiceTest.java +++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetServiceTest.java @@ -34,6 +34,7 @@ import org.apache.taverna.reference.WorkflowRunIdEntity; import org.junit.Before; import org.junit.Test; +import org.springframework.context.ApplicationContext; public class ReferenceSetServiceTest { @@ -45,22 +46,14 @@ public class ReferenceSetServiceTest { AppContextSetup.setup(); ReferenceSetServiceImpl service = null; - - service = new ReferenceSetServiceImpl(); - service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(0).getBean("testDao")); // hibernate - service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator()); - serviceList.add(service); - - service = new ReferenceSetServiceImpl(); - service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(1).getBean("testDao")); // in memory - service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator()); - serviceList.add(service); - service = new ReferenceSetServiceImpl(); - service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(2).getBean("testDao")); // transactional hibernate - service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator()); - serviceList.add(service); + for (ApplicationContext context : AppContextSetup.contextList) { + service = new ReferenceSetServiceImpl(); + service.setReferenceSetDao((ReferenceSetDao)context.getBean("testDao")); + service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator()); + serviceList.add(service); + } } @Test http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/0f7b70a9/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml b/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml deleted file mode 100644 index 0bcd04d..0000000 --- a/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml +++ /dev/null @@ -1,120 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- A test context with no raven aware components used by the DatabaseSetupTest --> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:aop="http://www.springframework.org/schema/aop" - xmlns:tx="http://www.springframework.org/schema/tx" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd - http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-2.5.xsd - http://www.springframework.org/schema/tx - http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> - - <!-- Transaction manager, commented out to use the regular dao implementations --> - <!-- - <tx:annotation-driven transaction-manager="txManager" /> - <bean id="txManager" - class="org.springframework.orm.hibernate3.HibernateTransactionManager"> - <property name="sessionFactory" ref="sessionFactoryBean" /> - </bean> - --> - - - <!-- Apache Derby rooted at a temporary directory --> - <bean id="t2reference.jdbc.temporaryjdbc" - class="org.apache.taverna.platform.spring.jdbc.TemporaryJDBC"> - </bean> - <bean id="t2reference.jdbc.url" class="java.lang.String" - factory-bean="t2reference.jdbc.temporaryjdbc" - factory-method="getTemporaryDerbyJDBC" /> - - <!-- At least for testing purposes we use Apache Derby --> - <bean id="exampleDataSource" - class="org.springframework.jdbc.datasource.DriverManagerDataSource"> - <property name="driverClassName"> - <value>org.apache.derby.jdbc.EmbeddedDriver</value> - </property> - <property name="url"> - <ref bean="t2reference.jdbc.url" /> - </property> - </bean> - - <!-- Configure hibernate to use dynamic schema update --> - <bean id="exampleHibernateProperties" - 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="exampleDataSource" /> - </property> - <property name="hibernateProperties"> - <ref bean="exampleHibernateProperties" /> - </property> - <property name="mappingResources"> - <list> - <value> - org/apache/taverna/reference/AbstractExternalReference.hbm.xml - </value> - <value> - org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml - </value> - <value> - org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml - </value> - <value> - org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml - </value> - </list> - </property> - </bean> - - <!-- Test data access object --> - <bean id="testDao" - class="org.apache.taverna.reference.impl.HibernateReferenceSetDao"> - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - - <!-- Test list data access object --> - <bean id="testListDao" - class="org.apache.taverna.reference.impl.HibernateListDao"> - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - - <!-- Test list data access object --> - <bean id="testErrorDao" - class="org.apache.taverna.reference.impl.HibernateErrorDocumentDao"> - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - -</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/0f7b70a9/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml b/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml deleted file mode 100644 index 373e2e8..0000000 --- a/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml +++ /dev/null @@ -1,118 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- A test context with no raven aware components used by the DatabaseSetupTest --> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:aop="http://www.springframework.org/schema/aop" - xmlns:tx="http://www.springframework.org/schema/tx" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd - http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-2.5.xsd - http://www.springframework.org/schema/tx - http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> - - <!-- Transaction manager, commented out to use the regular dao implementations --> - <tx:annotation-driven transaction-manager="txManager" /> - - <bean id="txManager" - class="org.springframework.orm.hibernate3.HibernateTransactionManager"> - <property name="sessionFactory" ref="sessionFactoryBean" /> - </bean> - - <!-- Apache Derby rooted at a temporary directory --> - <bean id="t2reference.jdbc.temporaryjdbc" - class="org.apache.taverna.platform.spring.jdbc.TemporaryJDBC"> - </bean> - <bean id="t2reference.jdbc.url" class="java.lang.String" - factory-bean="t2reference.jdbc.temporaryjdbc" - factory-method="getTemporaryDerbyJDBC" /> - - <!-- At least for testing purposes we use Apache Derby --> - <bean id="exampleDataSource" - class="org.springframework.jdbc.datasource.DriverManagerDataSource"> - <property name="driverClassName"> - <value>org.apache.derby.jdbc.EmbeddedDriver</value> - </property> - <property name="url"> - <ref bean="t2reference.jdbc.url" /> - </property> - </bean> - - <!-- Configure hibernate to use dynamic schema update --> - <bean id="exampleHibernateProperties" - 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="exampleDataSource" /> - </property> - <property name="hibernateProperties"> - <ref bean="exampleHibernateProperties" /> - </property> - <property name="mappingResources"> - <list> - <value> - org/apache/taverna/reference/AbstractExternalReference.hbm.xml - </value> - <value> - org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml - </value> - <value> - org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml - </value> - <value> - org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml - </value> - </list> - </property> - </bean> - - <!-- Test data access object --> - <bean id="testDao" - class="org.apache.taverna.reference.impl.TransactionalHibernateReferenceSetDao"> - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - - <!-- Test list data access object --> - <bean id="testListDao" - class="org.apache.taverna.reference.impl.TransactionalHibernateListDao"> - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - - <!-- Test list data access object --> - <bean id="testErrorDao" - class="org.apache.taverna.reference.impl.TransactionalHibernateErrorDocumentDao"> - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - -</beans> \ No newline at end of file
