Changeset 7301 for RevitalizationWS


Ignore:
Timestamp:
06/08/10 17:02:40 (9 years ago)
Author:
mnagni
Message:

Implemented OAIProvider and CSWProvider as inheriting from a common class (ProvoderCommon?).
The same structure is reported in the DB

Location:
RevitalizationWS/ws/DPWS/trunk
Files:
2 added
19 edited

Legend:

Unmodified
Added
Removed
  • RevitalizationWS/ws/DPWS/trunk/.classpath

    r7271 r7301  
    33        <classpathentry kind="src" output="target/classes" path="src/main/java"/> 
    44        <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> 
    5         <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> 
     5        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 
    66        <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"> 
    77                <attributes> 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/DPWS.java

    r7282 r7301  
    3232import ndg.services.schemas.revitalization.GetProcessStatusResponse; 
    3333import ndg.services.schemas.revitalization.GetProviderDetailsRequest; 
    34 import ndg.services.schemas.revitalization.GetProviderDetailsReturn; 
     34import ndg.services.schemas.revitalization.GetProviderDetailsResponse; 
    3535import ndg.services.schemas.revitalization.GetProviderStatsRequest; 
    3636import ndg.services.schemas.revitalization.GetProviderStatsReturn; 
     
    9999         
    100100        @WebMethod(operationName="getProviderDetails") 
    101         public GetProviderDetailsReturn getProviderDetails(@WebParam(name="request") GetProviderDetailsRequest request) { 
    102                 return of.createGetProviderDetailsReturn(); 
     101        public GetProviderDetailsResponse getProviderDetails(@WebParam(name="request") GetProviderDetailsRequest request) { 
     102                return of.createGetProviderDetailsResponse(); 
    103103        } 
    104104         
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/ModelManager.java

    r7282 r7301  
    2020import ndg.services.revitalization.jpa.HarvestLog; 
    2121import ndg.services.revitalization.jpa.HiProcess; 
    22 import ndg.services.revitalization.jpa.OaiProvider; 
    2322import ndg.services.revitalization.jpa.ProviderCommon; 
    2423import ndg.services.revitalization.jpa.ProviderEmail; 
     
    8584 
    8685        @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW) 
    87         public void createNewProvider(OaiProvider provider) { 
    88                 em.persist(provider.getProviderCommon()); 
    89                 ProviderCommon common = provider.getProviderCommon(); 
    90                 int id = common.getId(); 
    91                 for (ProviderEmail email : common.getProviderEmails()) { 
     86        public <T extends ProviderCommon> void createNewProvider(T provider) { 
     87                em.persist(provider); 
     88                int id = provider.getId(); 
     89                for (ProviderEmail email : provider.getProviderEmails()) { 
    9290                        email.setCommonId(id); 
    9391                } 
    94                 em.merge(common); 
    95                 provider.setCommonId(id); 
    96                 em.persist(provider); 
     92                em.merge(provider); 
    9793        } 
    9894 
     
    137133        } 
    138134         
    139         private <T> T getProvider(int id, String queryText) { 
     135        private <T extends ProviderCommon> T getProvider(int id, String queryText) { 
    140136                Query query = em.createQuery(queryText); 
    141137                query.setParameter("id", id); 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/interfaces/ModelManagerLocal.java

    r7282 r7301  
    77import ndg.services.revitalization.jpa.HiProcess; 
    88import ndg.services.revitalization.jpa.OaiProvider; 
     9import ndg.services.revitalization.jpa.ProviderCommon; 
    910 
    1011@Local 
     
    3334        public List<HiProcess> getHiProcess(List<Integer> processIDs); 
    3435         
    35         public void createNewProvider(OaiProvider provider); 
     36        public <T extends ProviderCommon> void createNewProvider(T provider); 
    3637         
    3738        public String getConfigurationParameter(String param); 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/interfaces/ModelManagerRemote.java

    r7282 r7301  
    66import ndg.services.revitalization.jpa.HarvestLog; 
    77import ndg.services.revitalization.jpa.HiProcess; 
    8 import ndg.services.revitalization.jpa.OaiProvider; 
    98import ndg.services.revitalization.jpa.ProviderCommon; 
    109 
     
    3534        public List<HiProcess> getHiProcess(List<Integer> processIDs); 
    3635         
    37         public void createNewProvider(OaiProvider provider); 
     36        public <T extends ProviderCommon> void createNewProvider(T provider); 
    3837         
    3938        public String getConfigurationParameter(String parameterName); 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/executor/ExecuteDoNewProvider.java

    r7282 r7301  
    77import ndg.common.exception.NdgExecutionException; 
    88import ndg.services.revitalization.EJBBeanFactory; 
    9 import ndg.services.revitalization.jpa.CswProvider; 
    10 import ndg.services.revitalization.jpa.OaiProvider; 
     9import ndg.services.revitalization.ProviderFactory; 
    1110import ndg.services.revitalization.jpa.ProviderCommon; 
    1211import ndg.services.revitalization.jpa.ProviderEmail; 
    13 import ndg.services.schemas.revitalization.CSWProviderDetailsType; 
    14 import ndg.services.schemas.revitalization.ConfirmationType; 
    1512import ndg.services.schemas.revitalization.DoNewProviderRequest; 
    1613import ndg.services.schemas.revitalization.DoNewProviderResponse; 
    1714import ndg.services.schemas.revitalization.EmailContactType; 
    18 import ndg.services.schemas.revitalization.NewProviderDetails; 
    19 import ndg.services.schemas.revitalization.OAIProviderDetailsType; 
    2015import ndg.services.schemas.revitalization.ProviderCommonType; 
    21 import ndg.services.schemas.revitalization.NewProviderDetails.HarvestDetails; 
     16import ndg.services.schemas.revitalization.ProviderDetail; 
    2217import ndg.services.schemas.revitalization.ProviderCommonType.ProviderAdminEmail; 
    2318 
     
    2621        @Override 
    2722        protected DoNewProviderResponse createResponse() { 
    28                 DoNewProviderResponse response = getOf().createDoNewProviderResponse(); 
    29                 response.setConfirmation(getOf().createConfirmationType()); 
    30                 return response; 
     23                return getOf().createDoNewProviderResponse(); 
    3124        } 
    3225 
     
    3427        protected void execute(DoNewProviderRequest request) 
    3528                        throws NdgExecutionException { 
    36                 NewProviderDetails pdetails = request.getDoNewProvider(); 
     29                ProviderDetail pdetails = request.getDoNewProvider(); 
    3730                if (pdetails == null) 
    3831                        throw new NdgExecutionException(new NdgMessage("null.object", new Object[]{"NewProviderDetails"})); 
     
    4134                        throw new NdgExecutionException(new NdgMessage("null.object", new Object[]{"ProviderCommon"})); 
    4235                 
    43                 ProviderCommon common = prepareCommonProvider(pdetails.getProviderCommon()); 
    44                 common.setProviderEmails(prepareProviderEmails(pdetails.getProviderCommon())); 
     36                if (pdetails.getProviderType() == null) 
     37                        throw new NdgExecutionException(new NdgMessage("null.object", new Object[]{"ProviderType"})); 
    4538                 
    46                 HarvestDetails hdetails = pdetails.getHarvestDetails(); 
    47                 if (hdetails == null) 
    48                         throw new NdgExecutionException(new NdgMessage("null.object", new Object[]{"HarvestDetails"})); 
    49                  
    50                 if(hdetails.isSetOAIProvider()) 
    51                         createProvider(pdetails.getHarvestDetails().getOAIProvider(), common); 
    52  
    53                 if(hdetails.isSetCSWProvider()) 
    54                         createProvider(pdetails.getHarvestDetails().getCSWProvider(), common); 
     39                createProvider(pdetails); 
    5540        } 
    56  
    57         @Override 
    58         protected ConfirmationType getConfirmationType() { 
    59                 return getResponse().getConfirmation(); 
    60         } 
    61          
    62         private ProviderCommon prepareCommonProvider(ProviderCommonType common) { 
    63                 ProviderCommon result = new ProviderCommon(); 
    64                 result.setBaseUrl(common.getProviderURL()); 
    65                 result.setEmailToAdmin(common.isSetProviderAdminEmail()); 
    66                 result.setName(common.getProviderName()); 
    67                 return result;           
    68         }        
    6941         
    7042        private List<ProviderEmail> prepareProviderEmails(ProviderCommonType common) { 
     
    9971        }        
    10072         
    101         private void createProvider(OAIProviderDetailsType provider, ProviderCommon common) throws NdgExecutionException{ 
    102                 OaiProvider nprovider = new OaiProvider();               
    103                  
    104                 nprovider.setFormat(provider.getFormat()); 
    105                 nprovider.setSet(provider.getSetSpec()); 
    106                 nprovider.setSplitBySet(provider.isSetSplitBySet()); 
    107                 nprovider.setProviderCommon(common); 
    108                 EJBBeanFactory.getModelManager().createNewProvider(nprovider); 
     73        private <T extends ProviderCommon> void prepareCommonProvider(ProviderCommonType common, T provider) { 
     74                provider.setBaseUrl(common.getProviderURL()); 
     75                provider.setEmailToAdmin(common.isSetProviderAdminEmail()); 
     76                provider.setName(common.getProviderName());      
     77                provider.setProviderEmails(prepareProviderEmails(common)); 
    10978        } 
    110  
    111         private void createProvider(CSWProviderDetailsType provider, ProviderCommon common)  throws NdgExecutionException{ 
    112                 CswProvider nprovider = new CswProvider(); 
    113                 //EJBBeanFactory.getModelManager().createNewProvider(provider, emails) 
     79         
     80        private void createProvider(ProviderDetail pdetails) throws NdgExecutionException { 
     81                ProviderCommon provider = ProviderFactory.getInstance().getProvider(pdetails); 
     82                prepareCommonProvider(pdetails.getProviderCommon(), provider);           
     83                EJBBeanFactory.getModelManager().createNewProvider(provider); 
    11484        } 
    11585} 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/executor/ExecuteGetList.java

    r7271 r7301  
    55import ndg.common.exception.NdgExecutionException; 
    66import ndg.services.revitalization.EJBBeanFactory; 
    7 import ndg.services.schemas.revitalization.ConfirmationType; 
    87import ndg.services.schemas.revitalization.GetListResponse; 
    98import ndg.services.schemas.revitalization.GetListType; 
     
    1312        @Override 
    1413        protected GetListResponse createResponse() { 
    15                 GetListResponse response = getOf().createGetListResponse(); 
    16                 response.setConfirmation(getOf().createConfirmationType()); 
    17                 return response; 
     14                return getOf().createGetListResponse(); 
    1815        } 
    1916 
     
    2522        } 
    2623 
    27         @Override 
    28         protected ConfirmationType getConfirmationType() { 
    29                 return getResponse().getConfirmation(); 
    30         } 
    31  
    3224} 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/executor/ExecuteGetListNames.java

    r7271 r7301  
    55import ndg.common.exception.NdgExecutionException; 
    66import ndg.services.revitalization.EJBBeanFactory; 
    7 import ndg.services.schemas.revitalization.ConfirmationType; 
    87import ndg.services.schemas.revitalization.GetListNamesResponse; 
    98 
     
    1211        @Override 
    1312        protected GetListNamesResponse createResponse() { 
    14                 GetListNamesResponse response = getOf().createGetListNamesResponse(); 
    15                 response.setConfirmation(getOf().createConfirmationType()); 
    16                 return response; 
     13                return getOf().createGetListNamesResponse(); 
    1714        } 
    1815 
     
    2320                getResponse().getListNames().getListItem().addAll(names); 
    2421        } 
    25  
    26         @Override 
    27         protected ConfirmationType getConfirmationType() { 
    28                 return getResponse().getConfirmation(); 
    29         } 
    3022} 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/executor/ExecuteGetProcessStatusRequest.java

    r7282 r7301  
    66import ndg.services.revitalization.EJBBeanFactory; 
    77import ndg.services.revitalization.jpa.HiProcess; 
    8 import ndg.services.schemas.revitalization.ConfirmationType; 
    98import ndg.services.schemas.revitalization.GetProcessStatusRequest; 
    109import ndg.services.schemas.revitalization.GetProcessStatusResponse; 
     
    1514        @Override 
    1615        protected GetProcessStatusResponse createResponse() { 
    17                 GetProcessStatusResponse response = getOf().createGetProcessStatusResponse(); 
    18                 response.setConfirmation(getOf().createConfirmationType()); 
    19                 return response; 
     16                return getOf().createGetProcessStatusResponse(); 
    2017        } 
    2118 
     
    3330                } 
    3431        } 
    35  
    36         @Override 
    37         protected ConfirmationType getConfirmationType() { 
    38                 return getResponse().getConfirmation();  
    39         } 
    4032} 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/executor/ExecuteHarvest.java

    r7282 r7301  
    99import ndg.services.revitalization.harvest.DispatchedHarvestRequest; 
    1010import ndg.services.revitalization.jpa.HiProcess; 
    11 import ndg.services.schemas.revitalization.ConfirmationType; 
    1211import ndg.services.schemas.revitalization.DoHarvestRequest; 
    1312import ndg.services.schemas.revitalization.DoHarvestResponse; 
     
    1817        @Override 
    1918        protected DoHarvestResponse createResponse() { 
    20                 DoHarvestResponse response = getOf().createDoHarvestResponse(); 
    21                 response.setConfirmation(getOf().createConfirmationType()); 
    22                 return response; 
     19                return getOf().createDoHarvestResponse(); 
    2320        } 
    2421 
     
    3734                MailHelper.getInstance().newDispatchedHarvestMail(request, process); 
    3835        } 
    39          
    40         @Override 
    41         protected ConfirmationType getConfirmationType() { 
    42                 return getResponse().getConfirmation(); 
    43         } 
    4436 
    4537        private HiProcess createHiProcess() throws NdgExecutionException { 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/executor/MailHelper.java

    r7284 r7301  
    55 
    66import ndg.common.MessageFormatter; 
    7 import ndg.common.NdgMessage; 
    87import ndg.common.exception.NdgExecutionException; 
    98import ndg.services.revitalization.EJBBeanFactory; 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/executor/ServiceExecutor.java

    r7271 r7301  
    11package ndg.services.revitalization.executor; 
    2  
    3 import org.apache.log4j.Logger; 
    42 
    53import ndg.common.MessageFormatter; 
     
    86import ndg.services.schemas.revitalization.ConfirmationType; 
    97import ndg.services.schemas.revitalization.ObjectFactory; 
     8import ndg.services.schemas.revitalization.ResponseType; 
    109 
    11 public abstract class ServiceExecutor<Y, T> { 
     10import org.apache.log4j.Logger; 
     11 
     12public abstract class ServiceExecutor<Y, T extends ResponseType> { 
    1213         
    1314        private final static ObjectFactory of = new ObjectFactory(); 
     
    3031                try { 
    3132                        execute(request); 
    32                         manageSuccess(getConfirmationType()); 
     33                        manageSuccess(getResponse().getConfirmation()); 
    3334                } catch (NdgExecutionException e) { 
    34                         manageError(getConfirmationType(), e); 
     35                        manageError(getResponse().getConfirmation(), e); 
    3536                } 
    3637                return response; 
     
    4041                if (this.response == null) { 
    4142                        this.response = createResponse(); 
     43                        this.response.setConfirmation(getOf().createConfirmationType()); 
    4244                }  
    4345                return this.response; 
     
    5557         
    5658        protected abstract T createResponse(); 
    57         protected abstract ConfirmationType getConfirmationType(); 
    5859        protected abstract void execute(Y request) throws NdgExecutionException; 
    5960} 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/harvest/HarvesterBase.java

    r7282 r7301  
    4343                harvestLog.setReqId(hiProcess.getId()); 
    4444                harvestLog.setProviderId(this.request.getProviderID()); 
    45                 harvestLog.setProviderIdType(this.request.getProviderTypeID()); 
    4645                EJBBeanFactory.getModelManager().updateHarvestingLogAndStatus(hiProcess, harvestLog); 
    4746        } 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/harvest/ejb/HarvestRequestConsumer.java

    r7282 r7301  
    1818import ndg.common.exception.NdgExecutionException; 
    1919import ndg.services.revitalization.dictionary.ServiceConfigurationParameter; 
    20 import ndg.services.revitalization.ejb.interfaces.HiProcessModelLocal; 
    2120import ndg.services.revitalization.ejb.interfaces.ModelManagerLocal; 
    2221import ndg.services.revitalization.exception.NdgHarvestNotExistingException; 
     
    4241        @EJB 
    4342        private AsyncHarvesterLocal executor; 
    44          
    45         @EJB 
    46         private HiProcessModelLocal processModel; 
    4743         
    4844        public void onMessage(Message message) { 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/harvest/oai/OAIHarvestRequest.java

    r7282 r7301  
    1313 
    1414        public OAIHarvestRequest(OaiProvider provider, DoHarvestRequest doRequest) { 
    15                 super(provider.getCommonId(), provider.getFormat(), provider.getProviderCommon().getBaseUrl());  
     15                super(provider.getId(), provider.getFormat(), provider.getBaseUrl());    
    1616                this.setSet(provider.getSet()); 
    1717                if (!provider.getFormat().equals("ANY")) 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/jpa/CswProvider.java

    r7282 r7301  
    11package ndg.services.revitalization.jpa; 
    22 
    3 import java.io.Serializable; 
    4 import javax.persistence.*; 
     3import javax.persistence.Entity; 
     4import javax.persistence.PrimaryKeyJoinColumn; 
     5import javax.persistence.Table; 
    56 
    67 
     
    1112@Entity 
    1213@Table(name="csw_provider") 
    13 public class CswProvider implements Serializable { 
    14         private static final long serialVersionUID = 1L; 
    15         private Integer commonId; 
    16         private ProviderCommon providerCommon; 
     14@PrimaryKeyJoinColumn(name="common_id") 
     15public class CswProvider extends ProviderCommon { 
    1716 
    18     public CswProvider() { 
     17    /** 
     18         *  
     19         */ 
     20        private static final long serialVersionUID = -8551777635863224854L; 
     21 
     22        public CswProvider() { 
    1923    } 
    20  
    21  
    22         @Id 
    23         @Column(name="common_id") 
    24         public Integer getCommonId() { 
    25                 return this.commonId; 
    26         } 
    27  
    28         public void setCommonId(Integer commonId) { 
    29                 this.commonId = commonId; 
    30         } 
    31  
    32         //uni-directional one-to-one association to ProviderCommon 
    33         @OneToOne 
    34         @JoinColumn(name="common_id") 
    35         public ProviderCommon getProviderCommon() { 
    36                 return this.providerCommon; 
    37         } 
    38  
    39         public void setProviderCommon(ProviderCommon providerCommon) { 
    40                 this.providerCommon = providerCommon; 
    41         }        
    4224} 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/jpa/HarvestLog.java

    r7271 r7301  
    1616        private Integer reqId; 
    1717        private Integer providerId; 
    18         private String providerIdType; 
    1918        private Timestamp startHarvest; 
    2019        private Timestamp stopHarvest; 
     
    5453        } 
    5554 
    56  
    57         @Column(name="provider_id_type") 
    58         public String getProviderIdType() { 
    59                 return this.providerIdType; 
    60         } 
    61  
    62         public void setProviderIdType(String providerIdType) { 
    63                 this.providerIdType = providerIdType; 
    64         } 
    65  
    66  
    6755        @Column(name="start_harvest") 
    6856        public Timestamp getStartHarvest() { 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/jpa/OaiProvider.java

    r7282 r7301  
    11package ndg.services.revitalization.jpa; 
    22 
    3 import java.io.Serializable; 
    4 import javax.persistence.*; 
     3import javax.persistence.Column; 
     4import javax.persistence.Entity; 
     5import javax.persistence.PrimaryKeyJoinColumn; 
     6import javax.persistence.Table; 
    57 
    68 
     
    1113@Entity 
    1214@Table(name="oai_provider") 
    13 public class OaiProvider implements Serializable { 
    14         private static final long serialVersionUID = 1L; 
    15         private Integer commonId; 
     15@PrimaryKeyJoinColumn(name="common_id") 
     16public class OaiProvider extends ProviderCommon { 
     17        /** 
     18         *  
     19         */ 
     20        private static final long serialVersionUID = -1990261352187103208L; 
    1621        private String format; 
    1722        private String set; 
    1823        private Boolean splitBySet; 
    19         private ProviderCommon providerCommon; 
    2024 
    2125    public OaiProvider() { 
    2226    } 
    23  
    24  
    25         @Id 
    26         @Column(name="common_id") 
    27         public Integer getCommonId() { 
    28                 return this.commonId; 
    29         } 
    30  
    31         public void setCommonId(Integer commonId) { 
    32                 this.commonId = commonId; 
    33         } 
    34  
    3527 
    3628        public String getFormat() { 
     
    5951        public void setSplitBySet(Boolean splitBySet) { 
    6052                this.splitBySet = splitBySet; 
    61         } 
    62  
    63  
    64         //uni-directional one-to-one association to ProviderCommon 
    65         @OneToOne 
    66         @JoinColumn(name="common_id") 
    67         public ProviderCommon getProviderCommon() { 
    68                 return this.providerCommon; 
    69         } 
    70  
    71         public void setProviderCommon(ProviderCommon providerCommon) { 
    72                 this.providerCommon = providerCommon; 
    73         } 
    74          
     53        }        
    7554} 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/jpa/ProviderCommon.java

    r7282 r7301  
    1212@Entity 
    1313@Table(name="provider_common") 
     14@Inheritance(strategy=InheritanceType.JOINED) 
    1415public class ProviderCommon implements Serializable { 
    1516        private static final long serialVersionUID = 1L; 
Note: See TracChangeset for help on using the changeset viewer.