Ignore:
Timestamp:
01/03/12 21:40:02 (8 years ago)
Author:
mnagni
Message:

Implemented WAF Harvester

Location:
mauRepo/revitalizationProject/branches/MEDIN/dpws
Files:
9 added
1 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/pom.xml

    r8118 r8121  
    3939                                </configuration> 
    4040                        </plugin> 
     41        <plugin> 
     42          <groupId>org.apache.maven.plugins</groupId> 
     43          <artifactId>maven-surefire-plugin</artifactId> 
     44          <version>2.12</version> 
     45        </plugin>                        
    4146                </plugins> 
    4247        </build> 
     48 
     49        <properties> 
     50                <version.saxon>9.1.0.8</version.saxon> 
     51        </properties> 
    4352 
    4453        <dependencies> 
     
    178187                        <groupId>commons-io</groupId> 
    179188                        <artifactId>commons-io</artifactId> 
    180                         <version>2.0.1</version> 
     189                        <version>${version.commons-io}</version> 
     190                </dependency> 
     191 
     192                <dependency> 
     193                        <groupId>commons-collections</groupId> 
     194                        <artifactId>commons-collections</artifactId> 
     195                        <version>${version.commons-collections}</version> 
     196                </dependency> 
     197 
     198                <dependency> 
     199                        <groupId>net.sf.saxon</groupId> 
     200                        <artifactId>saxon-xqj</artifactId> 
     201                        <version>${version.saxon}</version> 
     202                </dependency> 
     203 
     204                <dependency> 
     205                        <groupId>net.sf.saxon</groupId> 
     206                        <artifactId>saxon-dom</artifactId> 
     207                        <version>${version.saxon}</version> 
     208                </dependency> 
     209 
     210                <dependency> 
     211                        <groupId>net.sf.saxon</groupId> 
     212                        <artifactId>saxon</artifactId> 
     213                        <version>${version.saxon}</version> 
    181214                </dependency> 
    182215 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/jpa/ListNamesItem.java

    r8118 r8121  
     1/* BSD Licence 
     2 * Copyright (c) 2012, Science & Technology Facilities Council (STFC) 
     3 * All rights reserved. 
     4 * 
     5 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
     6 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
     7 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the 
     8 *      documentation and/or other materials provided with the distribution. 
     9 *  - Neither the name of the Science & Technology Facilities Council (STFC) nor the names of its contributors may be used to endorse or promote 
     10 *      products derived from this software without specific prior written permission. 
     11 * 
     12 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     13 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
     14 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
     15 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
     16 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
     17 * DAMAGE. 
     18 */ 
    119package ndg.services.jpa; 
    220 
     
    1331/** 
    1432 * The persistent class for the harvest_log database table. 
    15  *  
     33 * @Author Maurizio Nagni 
    1634 */ 
    1735@Entity 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/EJBBeanFactory.java

    r8033 r8121  
    1 /** 
    2  * BSD Licence 
    3  * Copyright (c) 2009, Science & Technology Facilities Council (STFC) All rights reserved. 
    4  * Redistribution and use in source and binary forms, with or without 
    5  * modification, are permitted provided that the following conditions are 
    6  * met: 
     1/* BSD Licence 
     2 * Copyright (c) 2012, Science & Technology Facilities Council (STFC) 
     3 * All rights reserved. 
    74 * 
    8  *   - Redistributions of source code must retain the above copyright 
    9  *     notice, this list of conditions and the following disclaimer. 
    10  *   - Redistributions in binary form must reproduce the above 
    11  *     copyright notice, this list of conditions and the following disclaimer 
    12  *     in the documentation and/or other materials provided with the 
    13  *     distribution. 
    14  *   - Neither the name of the Science & Technology Facilities Council 
    15  *     (STFC) nor the names of its contributors may be used to endorse or 
    16  *     promote products derived from this software without specific prior 
    17  *     written permission. 
     5 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
     6 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
     7 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the 
     8 *      documentation and/or other materials provided with the distribution. 
     9 *  - Neither the name of the Science & Technology Facilities Council (STFC) nor the names of its contributors may be used to endorse or promote 
     10 *      products derived from this software without specific prior written permission. 
    1811 * 
    19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    30  *  
     12 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     13 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
     14 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
     15 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
     16 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
     17 * DAMAGE. 
    3118 */ 
    3219package ndg.services.revitalization; 
     
    4734 * Utility class to retrieve the remote EJB necessary to the application. 
    4835 *  
    49  * @author Maurizio Nagni <maurizio.nagni@stfc.ac.uk> 
     36 * @author Maurizio Nagni 
    5037 **/ 
    5138public class EJBBeanFactory { 
    5239 
     40        private static DiscoveryServiceRemote discoveryRemoteService; 
     41        private static ModelManagerRemote modelManagerRemoteService;  
     42         
     43        /** 
     44         * Sets externals EJBs instances instead of the ApplicationServer ones. 
     45         * The method purpose is to allow the use of external instantiated classes  
     46         * during out-of-the-container unit tests.  
     47         */ 
     48        public static final void overrideEJBBeans(DiscoveryServiceRemote discoveryRemoteService,  
     49                        ModelManagerRemote modelManagerRemoteService){ 
     50                EJBBeanFactory.discoveryRemoteService = discoveryRemoteService; 
     51                EJBBeanFactory.modelManagerRemoteService = modelManagerRemoteService; 
     52        } 
     53         
    5354        /** 
    5455         * Returns a {@link JMSDispatcherRemote} 
     
    7576         **/ 
    7677        public static ModelManagerRemote getModelManager() throws NdgExecutionException { 
    77                 return getEJBInstance("ModelManager", ModelManagerRemote.class); 
     78                return EJBBeanFactory.modelManagerRemoteService == null ? 
     79                                getEJBInstance("ModelManager", ModelManagerRemote.class) : 
     80                                        EJBBeanFactory.modelManagerRemoteService;                
    7881        } 
    7982 
     
    8487         **/ 
    8588        public static DiscoveryServiceRemote getDiscoveryService() throws NdgExecutionException { 
    86                 return getEJBInstance("DiscoveryService", DiscoveryServiceRemote.class); 
     89                return EJBBeanFactory.discoveryRemoteService == null ? 
     90                        getEJBInstance("DiscoveryService", DiscoveryServiceRemote.class) : 
     91                                EJBBeanFactory.discoveryRemoteService; 
    8792        }        
    8893         
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/MailHelper.java

    r8033 r8121  
    1 /* 
    2  * BSD Licence 
    3  * Copyright (c) 2009, Science & Technology Facilities Council (STFC) 
     1/* BSD Licence 
     2 * Copyright (c) 2012, Science & Technology Facilities Council (STFC) 
    43 * All rights reserved. 
    5  
    6  * See the LICENSE file in the source distribution of this software for 
    7  * the full license text.        
    8  * Copyright (C) 2007 STFC & NERC (Science and Technology Facilities Council). 
    9  * This software may be distributed under the terms of the 
    10  * Q Public License, version 1.0 or later. 
    11  * http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt 
     4 * 
     5 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
     6 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
     7 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the 
     8 *      documentation and/or other materials provided with the distribution. 
     9 *  - Neither the name of the Science & Technology Facilities Council (STFC) nor the names of its contributors may be used to endorse or promote 
     10 *      products derived from this software without specific prior written permission. 
     11 * 
     12 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     13 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
     14 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
     15 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
     16 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
     17 * DAMAGE. 
    1218 */ 
    1319package ndg.services.revitalization; 
     
    1521import java.util.ArrayList; 
    1622import java.util.List; 
     23import java.util.logging.Logger; 
     24 
     25import org.apache.commons.collections.CollectionUtils; 
     26 
    1727 
    1828import ndg.common.MessageFormatter; 
     
    2838 * Offers some helper methods to send specific mails. 
    2939 *  
    30  * @author Maurizio Nagni <maurizio.nagni@stfc.ac.uk> 
     40 * @author Maurizio Nagni 
    3141 */ 
    3242public class MailHelper { 
    3343 
     44        private final static Logger logger = Logger.getLogger(MailHelper.class.getName()); 
     45         
    3446        private MailHelper() { 
    3547        } 
     
    93105                        throws NdgExecutionException { 
    94106                List<String> mailTo = filterEmail(null, hiProcess.getProviderId()); 
     107                 
     108                if (CollectionUtils.isEmpty(mailTo)) { 
     109                        return; 
     110                } 
     111                 
    95112                String text = EJBBeanFactory.getModelManager().getConfigurationParameter(msg); 
    96113                Object[] params = { hiProcess.getId() }; 
     
    142159         * @param common 
    143160         *            the object containig the default emails information 
    144          * @return a list of emails 
     161         * @return a list of emails, eventually empty 
    145162         * */ 
    146163        private List<String> filterEmail(List<Integer> emailIDs, ProviderCommon common) throws NdgExecutionException { 
    147164                List<String> mailTo = new ArrayList<String>(); 
     165                 
     166                if (common.getProviderEmails() == null) { 
     167                        logger.warning(String.format("No email adresses for provider %1$s", common.getId())); 
     168                        return mailTo; 
     169                } 
     170                 
    148171                for (ProviderEmail email : common.getProviderEmails()) { 
    149172                        if (emailIDs == null || emailIDs.contains(email.getId()) 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/ejb/HiProcessModel.java

    r8033 r8121  
    5050        private EntityManager em; 
    5151 
     52        /** 
     53         * Default constructor for the application container 
     54         */      
     55        public HiProcessModel() { 
     56                super(); 
     57        }        
     58 
     59        /** 
     60         * Allows the execution of the bean outside of the application container   
     61         * @param dpwsEntityManager an <code>EntityManager</code> binded to the dpwsDB persistence unit 
     62         **/     
     63        public HiProcessModel(EntityManager dpwsEntityManager) { 
     64                super(); 
     65                this.em = dpwsEntityManager; 
     66        } 
     67 
    5268        @Override 
    5369        @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW) 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/ejb/ModelManager.java

    r8119 r8121  
    1 /** 
    2  * BSD Licence 
    3  * Copyright (c) 2009, Science & Technology Facilities Council (STFC) All rights reserved. 
    4  * Redistribution and use in source and binary forms, with or without 
    5  * modification, are permitted provided that the following conditions are 
    6  * met: 
     1/* BSD Licence 
     2 * Copyright (c) 2012, Science & Technology Facilities Council (STFC) 
     3 * All rights reserved. 
    74 * 
    8  *   - Redistributions of source code must retain the above copyright 
    9  *     notice, this list of conditions and the following disclaimer. 
    10  *   - Redistributions in binary form must reproduce the above 
    11  *     copyright notice, this list of conditions and the following disclaimer 
    12  *     in the documentation and/or other materials provided with the 
    13  *     distribution. 
    14  *   - Neither the name of the Science & Technology Facilities Council 
    15  *     (STFC) nor the names of its contributors may be used to endorse or 
    16  *     promote products derived from this software without specific prior 
    17  *     written permission. 
     5 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
     6 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
     7 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the 
     8 *      documentation and/or other materials provided with the distribution. 
     9 *  - Neither the name of the Science & Technology Facilities Council (STFC) nor the names of its contributors may be used to endorse or promote 
     10 *      products derived from this software without specific prior written permission. 
    1811 * 
    19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    30  *  
     12 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     13 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
     14 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
     15 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
     16 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
     17 * DAMAGE. 
    3118 */ 
    3219package ndg.services.revitalization.ejb; 
     
    7057import ndg.services.revitalization.jpa.TimerInfo; 
    7158import ndg.services.revitalization.jpa.TimerInfoLog; 
     59import ndg.services.revitalization.jpa.WAFProvider; 
    7260 
    7361import org.apache.log4j.Logger; 
     
    7664 * Session Bean implementation class ModelManager 
    7765 *  
    78  * @author Maurizio Nagni <maurizio.nagni@stfc.ac.uk> 
     66 * @author Maurizio Nagni 
    7967 */ 
    8068@Stateless(mappedName="ModelManager") 
     
    8573        private final static String GET_CONFIGURATION_PARAMETER = "from ServiceConfig p where p.id=:id"; 
    8674        private final static String GET_PROVIDER_COMMON = "from ProviderCommon p"; 
    87         private final static String GET_PROVIDER_COMMON_BY_ID = "from ProviderCommon p where p.id=:id"; 
    88         private final static String GET_OAI_PROVIDER = "from OaiProvider p where p.id=:id"; 
    89         private final static String GET_CSW_PROVIDER = "from CswProvider p where p.id=:id";      
     75        //private final static String GET_PROVIDER_COMMON_BY_ID = "from ProviderCommon p where p.id=:id"; 
    9076        private final static String GET_INGESTER_HISTORY = "from IngestSearchLogging p where p.id IN (:processIds)"; 
    91         private final static String GET_HARVEST_HISTORY = "from HarvestLog p where p.reqId IN (:processIds)"; 
    9277        private final static String GET_HARVEST_LOG_BY_PROVIDER = "select l, p.providerId from HarvestLog l, HiProcess p  where l.reqId=p.id and p.providerId=:providerID and l.startHarvest >= :start and l.stopHarvest <= :end"; 
    9378        private final static String GET_HARVEST_LOG_ALL_PROVIDER = "select l, p.providerId from HarvestLog l, HiProcess p  where l.reqId=p.id and l.startHarvest >= :start and l.stopHarvest <= :end"; 
     
    11095        @EJB 
    11196        private HTITimerServiceLocal timerService; 
     97         
     98        /** 
     99         * Default constructor for the application container 
     100         */ 
     101        public ModelManager(){   
     102                super(); 
     103        } 
     104         
     105        /** 
     106         * Allows the execution of the bean outside of the application container 
     107         * @param discoveryEntityManager an <code>EntityManager</code> binded to the discoveryDB persistence unit   
     108         * @param dpwsEntityManager an <code>EntityManager</code> binded to the dpwsDB persistence unit 
     109         * @param hiProcessModel an EJB managing the HiProcess objects 
     110         * @param timerService an Timer instance    
     111         **/     
     112        public ModelManager(EntityManager dpwsEntityManager, EntityManager discoveryEntityManager, 
     113                        HiProcessModelLocal hiProcessModel, HTITimerServiceLocal timerService) { 
     114                super(); 
     115                this.em = dpwsEntityManager; 
     116                this.emDiscovery = discoveryEntityManager; 
     117                this.processModel = hiProcessModel; 
     118                this.timerService = timerService; 
     119        } 
    112120 
    113121        /* 
     
    215223        @SuppressWarnings("unchecked") 
    216224        public List<HarvestLog> getHarvestLog(List<Integer> processIds) { 
    217                         Query query = em.createQuery(GET_HARVEST_HISTORY); 
     225                        Query query = em.createNamedQuery("GET_HARVEST_HISTORY"); 
    218226                        query.setParameter("processIds", processIds); 
    219227                        return (List<HarvestLog>) query.getResultList(); 
     
    222230        @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW) 
    223231        public HiProcess updateHarvestingLogAndStatus(HiProcess hiProcess, HarvestLog harvestLog) { 
     232                        startTransaction(); 
     233                         
    224234                        // set the process's status to run_harvest 
    225235                        hiProcess = processModel.advanceStatus(hiProcess); 
     
    234244                                em.merge(harvestLog); 
    235245                        } 
     246                        commitTransaction();                     
    236247                        return hiProcess; 
    237248        } 
    238249 
    239250        @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW) 
    240         public <T extends ProviderCommon> T createNewProvider(T provider) { 
     251        public <T extends ProviderCommon> T createNewProvider(T provider) {                      
     252                        startTransaction(); 
     253                         
    241254                        ProviderCommon storedProvider = null; 
    242255                        //its a new Provider 
    243256                        if (provider.getId() == null) { 
    244                                 em.persist(provider); 
     257                                        em.persist(provider);    
    245258                                int id = provider.getId(); 
    246                                 for (ProviderEmail email : provider.getProviderEmails()) { 
    247                                         email.setCommonId(id); 
     259                                if (provider.getProviderEmails() != null) { 
     260                                        for (ProviderEmail email : provider.getProviderEmails()) { 
     261                                                email.setCommonId(id); 
     262                                        }                                        
    248263                                } 
    249264                                storedProvider = provider; 
     
    322337                                } 
    323338                                 
     339                                //WAF Provider 
     340                                if (storedProvider.getClass().isAssignableFrom(WAFProvider.class) 
     341                                                && provider.getClass().isAssignableFrom(WAFProvider.class)){ 
     342                                        WAFProvider oldWAF = (WAFProvider)storedProvider; 
     343                                        WAFProvider newWAF = (WAFProvider)provider; 
     344                                        if (newWAF.getHarvestTimeLimit()!= null && !newWAF.getHarvestTimeLimit().equals(oldWAF.getHarvestTimeLimit()))  { 
     345                                                oldWAF.setHarvestTimeLimit(newWAF.getHarvestTimeLimit()); 
     346                                        }        
     347                                } 
     348 
    324349                                //OAI Provider 
    325350                                if (storedProvider.getClass().isAssignableFrom(OaiProvider.class) 
     
    335360                                        }                
    336361                                         
    337                                         if (newOAI.getSet()!= null && !newOAI.getSet().equals(oldOAI.getSet())) { 
    338                                                 oldOAI.setSet(newOAI.getSet()); 
     362                                        if (newOAI.getSet_()!= null && !newOAI.getSet_().equals(oldOAI.getSet_()))      { 
     363                                                oldOAI.setSet_(newOAI.getSet_()); 
    339364                                        }                                                                                        
    340                                 } 
    341                                                                  
     365                                }                                
     366                                 
    342367                                //CSW Provider 
    343368                                if (storedProvider.getClass().isAssignableFrom(CswProvider.class) 
     
    379404                                } 
    380405                        } 
     406                        commitTransaction(); 
    381407                        return (T)storedProvider; 
    382408        } 
     
    429455         * */ 
    430456        public <T extends ProviderCommon> T getHarvesterConfiguration(int commonID) { 
    431                         ProviderCommon ret = getProvider(commonID, GET_OAI_PROVIDER); 
     457                        Query query = em.createNamedQuery("GET_OAI_PROVIDER"); 
     458                        query.setParameter("id", commonID); 
     459                        ProviderCommon ret = getProvider(query); 
    432460                        if (ret == null) { 
    433                                 ret = getProvider(commonID, GET_CSW_PROVIDER); 
     461                                query = em.createNamedQuery("GET_CSW_PROVIDER"); 
     462                                query.setParameter("id", commonID); 
     463                                ret = getProvider(query); 
     464                        }  
     465                        if (ret == null) { 
     466                                query = em.createNamedQuery("GET_WAF_PROVIDER"); 
     467                                query.setParameter("id", commonID); 
     468                                ret = getProvider(query); 
    434469                        }  
    435470                        return (T)ret; 
     
    559594         
    560595        @SuppressWarnings("unchecked") 
    561         private ProviderCommon getProvider(int id, String queryText) { 
    562                         Query query = em.createQuery(queryText); 
    563                         query.setParameter("id", id); 
     596        private ProviderCommon getProvider(Query query) { 
    564597                        List<ProviderCommon> values = query.getResultList(); 
    565598                        if (values == null || values.size() == 0) { 
     
    568601                        return values.get(0); 
    569602        } 
     603         
     604        /** 
     605         * Used to start a transaction when there is no managed container to  
     606         * do it following the annotation requirements  
     607         * */ 
     608        private void startTransaction(){                 
     609                if (!em.getTransaction().isActive()) { 
     610                        em.getTransaction().begin();     
     611                } 
     612        } 
     613         
     614        /** 
     615         * Used to commit a transaction when there is no managed container to  
     616         * do it following the annotation requirements  
     617         * */ 
     618        private void commitTransaction(){                
     619                if (em.getTransaction().isActive()) { 
     620                        em.getTransaction().commit();    
     621                } 
     622        } 
    570623} 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/ejb/discovery/DiscoveryService.java

    r8118 r8121  
    141141                try { 
    142142                        conn = discoveryDS.getConnection(); 
    143                         SearchHelper helper = new SearchHelper(conn, searchType, this); 
     143                        SearchHelper helper = new SearchHelper(conn, searchType); 
    144144                        return helper.doSearch(); 
    145145                } catch (SQLException e) { 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/ejb/discovery/SearchHelper.java

    r8118 r8121  
    2222import ndg.services.jpa.ListNamesItem; 
    2323import ndg.services.jpa.OriginalDocument; 
     24import ndg.services.revitalization.EJBBeanFactory; 
    2425import ndg.services.revitalization.ejb.interfaces.DiscoveryServiceRemote; 
    2526import ndg.services.schemas.revitalization.discovery.BoundingBoxType; 
     
    5859 
    5960        private final DoSearchType searchType; 
    60         private final Connection conn; 
    61         private final DiscoveryServiceRemote discoveryService;   
    62  
    63         public SearchHelper(Connection conn, DoSearchType searchType, DiscoveryServiceRemote discoveryService) { 
     61        private final Connection conn;   
     62 
     63        public SearchHelper(Connection conn, DoSearchType searchType) { 
    6464                super(); 
    6565                this.conn = conn; 
    6666                this.searchType = searchType; 
    67                 this.discoveryService = discoveryService; 
    6867        } 
    6968 
     
    200199                ListNames listNames = null; 
    201200                try { 
    202                         listNames = discoveryService.getNamesListByName(DiscoveryDictionaryDPWS.TERM_TARGET); 
     201                        listNames = EJBBeanFactory.getDiscoveryService().getNamesListByName(DiscoveryDictionaryDPWS.TERM_TARGET); 
    203202                } catch (NoResultException ex) { 
    204203                        return retList; 
     
    259258                        term = parser.parseTerm(term);   
    260259 
    261                         ListNamesItem listNamesItem = discoveryService.getNamesListItemByLabel(termType.getTermTarget()); 
     260                        ListNamesItem listNamesItem = EJBBeanFactory.getDiscoveryService().getNamesListItemByLabel(termType.getTermTarget()); 
    262261                        //logHelper.logMessage("Search term - TermTarget: " + term + " - " + termTarget, Level.DEBUG); 
    263262 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/harvest/HarvesterBase.java

    r8033 r8121  
    1 /* 
    2  * BSD Licence 
    3  * Copyright (c) 2009, Science & Technology Facilities Council (STFC) 
     1/* BSD Licence 
     2 * Copyright (c) 2012, Science & Technology Facilities Council (STFC) 
    43 * All rights reserved. 
    5  
    6  * See the LICENSE file in the source distribution of this software for 
    7  * the full license text.        
    8  * Copyright (C) 2007 STFC & NERC (Science and Technology Facilities Council). 
    9  * This software may be distributed under the terms of the 
    10  * Q Public License, version 1.0 or later. 
    11  * http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt 
     4 * 
     5 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
     6 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
     7 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the 
     8 *      documentation and/or other materials provided with the distribution. 
     9 *  - Neither the name of the Science & Technology Facilities Council (STFC) nor the names of its contributors may be used to endorse or promote 
     10 *      products derived from this software without specific prior written permission. 
     11 * 
     12 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     13 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
     14 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
     15 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
     16 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
     17 * DAMAGE. 
    1218 */ 
    1319package ndg.services.revitalization.harvest; 
     
    2430import ndg.services.revitalization.EJBBeanFactory; 
    2531import ndg.services.revitalization.MailHelper; 
     32import ndg.services.revitalization.ejb.interfaces.ModelManagerRemote; 
    2633import ndg.services.revitalization.harvest.oai.OAIHarvester; 
    2734import ndg.services.revitalization.jpa.HarvestLog; 
     
    3340 *  
    3441 * @see OAIHarvester 
    35  * @author Maurizio Nagni <maurizio.nagni@stfc.ac.uk>  
     42 * @author Maurizio Nagni  
    3643 **/ 
    3744public abstract class HarvesterBase<T extends HarvestRequest> implements Harvester<T>{ 
     
    4754         
    4855        private final HarvestResult harvestResult = new HarvestResult(); 
     56         
     57        private ModelManagerRemote modelManager = null; 
    4958 
    5059        protected abstract void doHarvest() throws NdgExecutionException; 
     
    6776                        doHarvest();     
    6877                        harvestLog = finalizeHarvesting();                       
    69                         hiProcess = EJBBeanFactory.getModelManager().updateHarvestingLogAndStatus(hiProcess, harvestLog);                
     78                        hiProcess = getModelManager().updateHarvestingLogAndStatus(hiProcess, harvestLog);               
    7079                        MailHelper.getInstance().terminatedHarvestMail(getHiProcess());                  
    7180                } catch (NdgExecutionException ex) { 
    7281                        //in future a StatePattern could be better 
    7382                        getHiProcess().getHiStatus().setId("failed_harv"); 
    74                         if (ex.getBundlMessage() == null) 
     83                        if (ex.getBundlMessage() == null) { 
    7584                                throw new NdgExecutionException(ex); 
     85                        } 
    7686                         
    7787                        throw new NdgExecutionException(ex.getBundlMessage()); 
     
    8898                harvestLog.setStartHarvest(new Timestamp(Calendar.getInstance().getTimeInMillis())); 
    8999                getHarvestResult().setStartTime(harvestLog.getStartHarvest()); 
    90                 hiProcess = EJBBeanFactory.getModelManager().updateHarvestingLogAndStatus(hiProcess, harvestLog); 
     100                hiProcess = getModelManager().updateHarvestingLogAndStatus(hiProcess, harvestLog); 
    91101        } 
    92102         
     
    94104                List<Integer> procId = new ArrayList<Integer>(); 
    95105                procId.add(hiProcess.getId()); 
    96                 List<HarvestLog> harvestLogs = EJBBeanFactory.getModelManager().getHarvestLog(procId); 
     106                List<HarvestLog> harvestLogs = getModelManager().getHarvestLog(procId); 
    97107                 
    98108                HarvestLog harvestLog = null; 
    99                 if (harvestLogs == null || harvestLogs.size() == 0) 
     109                if (harvestLogs == null || harvestLogs.size() == 0) { 
    100110                        throw new NdgExecutionException(new NdgMessage("execution.error", new Object[] { "finalizeHarvesting()", 
    101111                                        "Cannot find harvestLog reqId:" + hiProcess.getId() }, null)); 
     112                } 
    102113                 
    103114                harvestLog = harvestLogs.get(0); 
     
    119130                if (outDir.isDirectory()) { 
    120131                        String numfiles[] = outDir.list(); 
    121                         if (numfiles != null) 
     132                        if (numfiles != null) { 
    122133                                return numfiles.length; 
     134                        } 
     135                                 
    123136                } 
    124137                return 0; 
     
    154167                } 
    155168        } 
     169         
     170        private ModelManagerRemote getModelManager() throws NdgExecutionException { 
     171                if (modelManager == null) { 
     172                        modelManager = EJBBeanFactory.getModelManager(); 
     173                } 
     174                return modelManager; 
     175        } 
    156176} 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/harvest/ProviderAdapterFactory.java

    r8033 r8121  
    44import ndg.services.revitalization.harvest.csw.CSWAdapterHelper; 
    55import ndg.services.revitalization.harvest.oai.OAIAdapterHelper; 
     6import ndg.services.revitalization.harvest.waf.WAFAdapterHelper; 
    67import ndg.services.revitalization.jpa.CswProvider; 
    78import ndg.services.revitalization.jpa.OaiProvider; 
    89import ndg.services.revitalization.jpa.ProviderCommon; 
     10import ndg.services.revitalization.jpa.WAFProvider; 
    911import ndg.services.schemas.revitalization.CSWProviderDetailsType; 
    1012import ndg.services.schemas.revitalization.OAIProviderDetailsType; 
    1113import ndg.services.schemas.revitalization.ProviderDetailsType; 
     14import ndg.services.schemas.revitalization.WAFProviderDetailsType; 
    1215 
    1316/** 
     
    2831                        return new CSWAdapterHelper(); 
    2932                } 
    30  
     33                if (clazz.isAssignableFrom(WAFProvider.class) || clazz.isAssignableFrom(WAFProviderDetailsType.class)) { 
     34                        return new WAFAdapterHelper(); 
     35                } 
    3136                throw new NdgExecutionException("Provider type does not exists"); 
    3237        } 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/harvest/csw/CSWHarvester.java

    r8033 r8121  
    1 /* 
    2  * BSD Licence Copyright (c) 2009, Science & Technology Facilities Council 
    3  * (STFC) All rights reserved. 
    4  *  
    5  * See the LICENSE file in the source distribution of this software for the full 
    6  * license text. Copyright (C) 2007 STFC & NERC (Science and Technology 
    7  * Facilities Council). This software may be distributed under the terms of the 
    8  * Q Public License, version 1.0 or later. 
    9  * http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt 
     1/* BSD Licence 
     2 * Copyright (c) 2012, Science & Technology Facilities Council (STFC) 
     3 * All rights reserved. 
     4 * 
     5 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
     6 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
     7 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the 
     8 *      documentation and/or other materials provided with the distribution. 
     9 *  - Neither the name of the Science & Technology Facilities Council (STFC) nor the names of its contributors may be used to endorse or promote 
     10 *      products derived from this software without specific prior written permission. 
     11 * 
     12 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     13 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
     14 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
     15 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
     16 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
     17 * DAMAGE. 
    1018 */ 
    1119package ndg.services.revitalization.harvest.csw; 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/harvest/oai/OAIAdapterHelper.java

    r8033 r8121  
     1/* BSD Licence 
     2 * Copyright (c) 2012, Science & Technology Facilities Council (STFC) 
     3 * All rights reserved. 
     4 * 
     5 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
     6 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
     7 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the 
     8 *      documentation and/or other materials provided with the distribution. 
     9 *  - Neither the name of the Science & Technology Facilities Council (STFC) nor the names of its contributors may be used to endorse or promote 
     10 *      products derived from this software without specific prior written permission. 
     11 * 
     12 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     13 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
     14 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
     15 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
     16 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
     17 * DAMAGE. 
     18 */ 
    119package ndg.services.revitalization.harvest.oai; 
    220 
     
    1129import ndg.services.schemas.revitalization.ObjectFactory; 
    1230 
     31/** 
     32 * @author Maurizio Nagni 
     33 * */ 
    1334public class OAIAdapterHelper  
    1435                implements ProviderAdapterHelper<OaiProvider, OAIProviderDetailsType, OAIHarvester>{ 
     
    2546                OaiProvider nprovider = new OaiProvider(); 
    2647                nprovider.setFormat(providerDetails.getFormat()); 
    27                 nprovider.setSet(providerDetails.getSetSpec()); 
     48                nprovider.setSet_(providerDetails.getSetSpec()); 
    2849                nprovider.setSplitBySet(providerDetails.isSetSplitBySet()); 
    2950                return nprovider; 
     
    3455                OAIProviderDetailsType pdt = of.createOAIProviderDetailsType(); 
    3556                pdt.setFormat(oai.getFormat()); 
    36                 pdt.setSetSpec(oai.getSet()); 
     57                pdt.setSetSpec(oai.getSet_()); 
    3758                pdt.setSplitBySet(oai.getSplitBySet()); 
    3859                return of.createOAIProvider(pdt); 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/harvest/oai/OAIHarvestRequest.java

    r8033 r8121  
    1 /* 
    2  * BSD Licence 
    3  * Copyright (c) 2009, Science & Technology Facilities Council (STFC) 
     1/* BSD Licence 
     2 * Copyright (c) 2012, Science & Technology Facilities Council (STFC) 
    43 * All rights reserved. 
    5  
    6  * See the LICENSE file in the source distribution of this software for 
    7  * the full license text.        
    8  * Copyright (C) 2007 STFC & NERC (Science and Technology Facilities Council). 
    9  * This software may be distributed under the terms of the 
    10  * Q Public License, version 1.0 or later. 
    11  * http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt 
     4 * 
     5 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
     6 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
     7 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the 
     8 *      documentation and/or other materials provided with the distribution. 
     9 *  - Neither the name of the Science & Technology Facilities Council (STFC) nor the names of its contributors may be used to endorse or promote 
     10 *      products derived from this software without specific prior written permission. 
     11 * 
     12 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     13 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
     14 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
     15 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
     16 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
     17 * DAMAGE. 
    1218 */ 
    1319package ndg.services.revitalization.harvest.oai; 
     
    2026/** 
    2127 * Represents an Harvest request to an OAI provider 
    22  * @author Maurizio Nagni <maurizio.nagni@stfc.ac.uk>    
     28 * @author Maurizio Nagni 
    2329 **/ 
    2430public class OAIHarvestRequest extends HarvestRequest { 
     
    3238                super(request.getProcess(), request.getEmailID()); 
    3339                url = provider.getBaseUrl(); 
    34                 this.setSet(provider.getSet()); 
     40                this.setSet(provider.getSet_()); 
    3541                if (!provider.getFormat().equals("ANY")) 
    3642                        this.setMetadataPrefix(provider.getFormat()); 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/jpa/CswProvider.java

    r8033 r8121  
    1 /** 
    2  * BSD Licence 
    3  * Copyright (c) 2009, Science & Technology Facilities Council (STFC) All rights reserved. 
    4  * Redistribution and use in source and binary forms, with or without 
    5  * modification, are permitted provided that the following conditions are 
    6  * met: 
     1/* BSD Licence 
     2 * Copyright (c) 2012, Science & Technology Facilities Council (STFC) 
     3 * All rights reserved. 
    74 * 
    8  *   - Redistributions of source code must retain the above copyright 
    9  *     notice, this list of conditions and the following disclaimer. 
    10  *   - Redistributions in binary form must reproduce the above 
    11  *     copyright notice, this list of conditions and the following disclaimer 
    12  *     in the documentation and/or other materials provided with the 
    13  *     distribution. 
    14  *   - Neither the name of the Science & Technology Facilities Council 
    15  *     (STFC) nor the names of its contributors may be used to endorse or 
    16  *     promote products derived from this software without specific prior 
    17  *     written permission. 
     5 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
     6 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
     7 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the 
     8 *      documentation and/or other materials provided with the distribution. 
     9 *  - Neither the name of the Science & Technology Facilities Council (STFC) nor the names of its contributors may be used to endorse or promote 
     10 *      products derived from this software without specific prior written permission. 
    1811 * 
    19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    30  *  
     12 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     13 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
     14 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
     15 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
     16 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
     17 * DAMAGE. 
    3118 */ 
    3219package ndg.services.revitalization.jpa; 
     
    3623import javax.persistence.Column; 
    3724import javax.persistence.Entity; 
     25import javax.persistence.NamedQueries; 
     26import javax.persistence.NamedQuery; 
    3827import javax.persistence.PrimaryKeyJoinColumn; 
    3928import javax.persistence.Table; 
     
    4534/** 
    4635 * The persistent class for the csw_provider database table. 
    47  * @author Maurizio Nagni <maurizio.nagni@stfc.ac.uk>    
     36 * @author Maurizio Nagni 
    4837 */ 
    4938@Entity 
    5039@Table(name="csw_provider") 
    5140@PrimaryKeyJoinColumn(name="common_id") 
     41@NamedQueries({ 
     42        @NamedQuery(name="GET_CSW_PROVIDER",  
     43                                query="from CswProvider p where p.id=:id")}) 
    5244public class CswProvider extends ProviderCommon { 
    5345 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/jpa/HarvestLog.java

    r8033 r8121  
     1/* BSD Licence 
     2 * Copyright (c) 2012, Science & Technology Facilities Council (STFC) 
     3 * All rights reserved. 
     4 * 
     5 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
     6 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
     7 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the 
     8 *      documentation and/or other materials provided with the distribution. 
     9 *  - Neither the name of the Science & Technology Facilities Council (STFC) nor the names of its contributors may be used to endorse or promote 
     10 *      products derived from this software without specific prior written permission. 
     11 * 
     12 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     13 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
     14 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
     15 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
     16 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
     17 * DAMAGE. 
     18 */ 
    119package ndg.services.revitalization.jpa; 
    220 
    321import java.io.Serializable; 
    4 import javax.persistence.*; 
    522import java.sql.Timestamp; 
     23 
     24import javax.persistence.Column; 
     25import javax.persistence.Entity; 
     26import javax.persistence.Id; 
     27import javax.persistence.NamedQueries; 
     28import javax.persistence.NamedQuery; 
     29import javax.persistence.Table; 
    630 
    731 
     
    933 * The persistent class for the harvest_log database table. 
    1034 *  
     35 * @author Maurizio Nagni 
    1136 */ 
    1237@Entity 
    1338@Table(name="harvest_log") 
     39@NamedQueries({ 
     40        @NamedQuery(name="GET_HARVEST_HISTORY", query="select p from HarvestLog p where p.reqId IN (:processIds)")}) 
    1441public class HarvestLog implements Serializable { 
    1542        private static final long serialVersionUID = 1L; 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/jpa/OaiProvider.java

    r8033 r8121  
    33import javax.persistence.Column; 
    44import javax.persistence.Entity; 
     5import javax.persistence.NamedQueries; 
     6import javax.persistence.NamedQuery; 
    57import javax.persistence.PrimaryKeyJoinColumn; 
    68import javax.persistence.Table; 
     
    1416@Table(name="oai_provider") 
    1517@PrimaryKeyJoinColumn(name="common_id") 
     18@NamedQueries({ 
     19        @NamedQuery(name="GET_OAI_PROVIDER",  
     20                                query="from OaiProvider p where p.id=:id")}) 
    1621public class OaiProvider extends ProviderCommon { 
    1722        /** 
     
    2025        private static final long serialVersionUID = -1990261352187103208L; 
    2126        private String format; 
    22         private String set; 
     27        private String set_; 
    2328        private Boolean splitBySet; 
    2429 
     
    2631    } 
    2732 
     33    @Column(name="format") 
    2834        public String getFormat() { 
    2935                return this.format; 
     
    3440        } 
    3541 
    36  
    37         public String getSet() { 
    38                 return this.set; 
     42        @Column(name="set_") 
     43        public String getSet_() { 
     44                return this.set_; 
    3945        } 
    4046 
    41         public void setSet(String set) { 
    42                 this.set = set; 
     47        public void setSet_(String set_) { 
     48                this.set_ = set_; 
    4349        } 
    4450 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/main/java/ndg/services/revitalization/jpa/ServiceConfig.java

    r8033 r8121  
    2121 
    2222        @Id 
    23         @TableGenerator(name="SERVICE_CONFIG_KEY_GENERATOR",  
    24                         table="GENERATOR_TABLE", 
    25                 pkColumnName="PRIMARY_KEY_COLUMN", 
    26                 valueColumnName="VALUE_COLUMN", 
    27                 pkColumnValue="SERVICE_CONFIG_ID", 
    28                 allocationSize=10)       
    29         @GeneratedValue(strategy=GenerationType.TABLE, generator="SERVICE_CONFIG_KEY_GENERATOR")         
    3023        @Column(name="param_name") 
    3124        public String getParamName() { 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/test/java/ndg/services/revitalization/ejb/discovery/DBTestBase.java

    r8118 r8121  
    33import java.sql.Connection; 
    44import java.sql.DriverManager; 
     5import java.util.HashMap; 
     6import java.util.Map; 
    57 
    68import javax.persistence.EntityManager; 
     
    810import javax.persistence.Persistence; 
    911import javax.sql.DataSource; 
     12 
     13import ndg.services.revitalization.EJBBeanFactory; 
     14import ndg.services.revitalization.ejb.HiProcessModel; 
     15import ndg.services.revitalization.ejb.ModelManager; 
     16import ndg.services.revitalization.jpa.HiStatus; 
     17import ndg.services.revitalization.jpa.ServiceConfig; 
    1018 
    1119import org.hsqldb.jdbc.JDBCDataSource; 
     
    2230        private EntityManagerFactory discoveryEntityManagerFactory; 
    2331        private EntityManager discoveryEntityManager; 
     32        private EntityManagerFactory dpwsEntityManagerFactory; 
     33        private EntityManager dpwsEntityManager; 
     34         
    2435         
    2536        Connection connection; 
     
    3849                        Assert.fail("Exception during HSQL database startup."); 
    3950                } 
     51 
     52                 
     53                DiscoveryService discoveryService = new DiscoveryService(getDiscoveryDBds(), getDiscoveryEntityManager()); 
     54                HiProcessModel hiProcessModel = new HiProcessModel(getDPWSEntityManager()); 
     55                ModelManager modelManager = new ModelManager(getDPWSEntityManager(), getDiscoveryEntityManager(), hiProcessModel, null);                 
     56                EJBBeanFactory.overrideEJBBeans(discoveryService, modelManager); 
     57        initializeServiceConfig();               
     58                initializeHiStatus();             
    4059        } 
    4160 
     
    4867                if (getDiscoveryEntityManagerFactory() != null) { 
    4968                        getDiscoveryEntityManagerFactory().close(); 
     69                } 
     70 
     71                if (getDPWSEntityManager() != null) { 
     72                        getDPWSEntityManager().close(); 
     73                } 
     74                if (getDPWSEntityManagerFactory() != null) { 
     75                        getDPWSEntityManagerFactory().close(); 
    5076                } 
    5177                logger.info("Stopping in-memory HSQL database."); 
     
    6490        } 
    6591         
    66         EntityManager getDiscoveryEntityManager() { 
     92        private EntityManager getDiscoveryEntityManager() { 
    6793                if (discoveryEntityManager == null) { 
    6894                        logger.info("Building JPA EntityManager for unit tests");  
     
    7298        } 
    7399 
     100        private EntityManagerFactory getDPWSEntityManagerFactory() { 
     101                if (dpwsEntityManagerFactory == null) { 
     102                        logger.info("Building DPWS's JPA EntityManagerFactory for unit tests"); 
     103                        dpwsEntityManagerFactory = Persistence.createEntityManagerFactory("discoveryDPWS");  
     104                } 
     105                return dpwsEntityManagerFactory; 
     106        } 
     107         
     108        private EntityManager getDPWSEntityManager() { 
     109                if (dpwsEntityManager == null) { 
     110                        logger.info("Building DPWS's JPA EntityManager for unit tests");  
     111                        dpwsEntityManager = getDPWSEntityManagerFactory().createEntityManager(); 
     112                } 
     113                return dpwsEntityManager; 
     114        } 
     115         
    74116        DataSource getDiscoveryDBds() { 
    75117                if (discoveryDBds == null) { 
     
    83125                return discoveryDBds; 
    84126        } 
     127         
     128        private void initializeHiStatus() { 
     129                Map<String, String> hiStatusMap = new HashMap<String, String>(); 
     130                hiStatusMap.put("start_harv", "The harvesting process is starting"); 
     131                hiStatusMap.put("run_harv", "The harvesting process is running"); 
     132                hiStatusMap.put("end_harv", "The harvesting process is terminated"); 
     133                hiStatusMap.put("start_ingest", "The ingest process is starting"); 
     134                hiStatusMap.put("run_ingest", "The ingest process is running"); 
     135                hiStatusMap.put("end_ingest", "The ingest process is terminated"); 
     136                hiStatusMap.put("run_harv", "The Harvesting process has failed"); 
     137                hiStatusMap.put("failed_harv", "The harvesting process is running"); 
     138                hiStatusMap.put("failed_ingest", "The Ingest process has failed"); 
     139                 
     140                getDPWSEntityManager().getTransaction().begin(); 
     141                HiStatus hiStatus = null; 
     142                for (String key : hiStatusMap.keySet()) { 
     143                        hiStatus = new HiStatus(); 
     144                        hiStatus.setId(key); 
     145                        hiStatus.setDescription(hiStatusMap.get(key)); 
     146                        getDPWSEntityManager().persist(hiStatus);                        
     147                } 
     148                getDPWSEntityManager().getTransaction().commit(); 
     149        } 
     150         
     151        private void initializeServiceConfig() { 
     152                Map<String, String> serviceConfigMap = new HashMap<String, String>(); 
     153                serviceConfigMap.put("HARVEST_ROOT_PATH", getClass().getClassLoader().getResource(".").getPath()); 
     154                getDPWSEntityManager().getTransaction().begin(); 
     155                ServiceConfig serviceConfig = null; 
     156                for (String key : serviceConfigMap.keySet()) { 
     157                        serviceConfig = new ServiceConfig(); 
     158                        serviceConfig.setParamName(key); 
     159                        serviceConfig.setParamValue(serviceConfigMap.get(key)); 
     160                        getDPWSEntityManager().persist(serviceConfig);   
     161                } 
     162                getDPWSEntityManager().getTransaction().commit(); 
     163        } 
    85164} 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/test/java/ndg/services/revitalization/ejb/discovery/SearchAgentTest.java

    r8118 r8121  
    3131         
    3232        private ObjectFactory of = new ObjectFactory(); 
    33         private final DiscoveryService discoveryService = new DiscoveryService(getDiscoveryDBds(), getDiscoveryEntityManager()); 
    3433         
    3534        private void dotestPrepareTermSearch(DoSearchType st, String referenceQuery) { 
    36                 SearchHelper sa = new SearchHelper(connection, st, discoveryService);            
     35                SearchHelper sa = new SearchHelper(connection, st);              
    3736                try {                    
    3837                        String query = sa.assembleSearch(st); 
  • mauRepo/revitalizationProject/branches/MEDIN/dpws/src/test/resources/META-INF/persistence.xml

    r8118 r8121  
    1010                <class>ndg.services.jpa.ListNamesItem</class> 
    1111                <properties> 
    12                         <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:unit-testing-jpa" /> 
     12                        <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:discovery-unit-testing" /> 
     13                        <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" /> 
     14                        <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" /> 
     15                        <property name="hibernate.hbm2ddl.auto" value="create-drop" /> 
     16                        <property name="hibernate.connection.username" value="sa" /> 
     17                        <property name="hibernate.connection.password" value="" /> 
     18                </properties> 
     19        </persistence-unit> 
     20         
     21        <persistence-unit name="discoveryDPWS" transaction-type="RESOURCE_LOCAL"> 
     22                <provider>org.hibernate.ejb.HibernatePersistence</provider> 
     23                <class>ndg.services.revitalization.jpa.HiProcess</class> 
     24                <class>ndg.services.revitalization.jpa.HiStatus</class> 
     25                <class>ndg.services.revitalization.jpa.ProviderCommon</class>            
     26                <class>ndg.services.revitalization.jpa.WAFProvider</class>               
     27                <class>ndg.services.revitalization.jpa.OaiProvider</class>               
     28                <class>ndg.services.revitalization.jpa.CswProvider</class>               
     29                <class>ndg.services.revitalization.jpa.ProviderEmail</class>             
     30                <class>ndg.services.revitalization.jpa.HarvestLog</class>                
     31                <class>ndg.services.revitalization.jpa.ServiceConfig</class>             
     32                <class>ndg.services.revitalization.jpa.HarvestLog</class>                
     33                <properties> 
     34                        <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:dpws-unit-testing" /> 
    1335                        <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" /> 
    1436                        <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" /> 
Note: See TracChangeset for help on using the changeset viewer.