Changeset 7660 for RevitalizationWS


Ignore:
Timestamp:
26/10/10 16:00:00 (9 years ago)
Author:
mnagni
Message:

added a service to retrieve provider statistics

Location:
RevitalizationWS/ws/DPWS/trunk/src/main
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/DPWS.java

    r7656 r7660  
    5050import ndg.services.revitalization.executor.ExecuteGetProcessStatusRequest; 
    5151import ndg.services.revitalization.executor.ExecuteGetProviderDetails; 
     52import ndg.services.revitalization.executor.ExecuteGetProviderStatistic; 
    5253import ndg.services.revitalization.executor.ExecuteHarvest; 
    5354import ndg.services.revitalization.executor.ServiceExecutor; 
     
    7475import ndg.services.schemas.revitalization.GetProviderDetailsRequest; 
    7576import ndg.services.schemas.revitalization.GetProviderDetailsResponse; 
     77import ndg.services.schemas.revitalization.GetProviderStatisticRequest; 
     78import ndg.services.schemas.revitalization.GetProviderStatisticResponse; 
    7679 
    7780import org.jboss.wsf.spi.annotation.WebContext; 
     
    170173                return executor.doService(request); 
    171174        } 
     175         
     176        @WebMethod(operationName = "getProviderStatistic") 
     177        public GetProviderStatisticResponse getProviderStatistic(@WebParam(name = "request") GetProviderStatisticRequest request) { 
     178                ServiceExecutor<GetProviderStatisticRequest, GetProviderStatisticResponse> executor = new ExecuteGetProviderStatistic(); 
     179                return executor.doService(request); 
     180        }        
    172181} 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/ModelManager.java

    r7656 r7660  
    3232package ndg.services.revitalization.ejb; 
    3333 
     34import java.math.BigInteger; 
    3435import java.sql.Timestamp; 
    3536import java.util.ArrayList; 
     
    4647import javax.persistence.Query; 
    4748 
    48 import ndg.common.NdgMessage; 
    4949import ndg.common.ejb.exception.TimerCreationException; 
    5050import ndg.common.exception.NdgExecutionException; 
     
    6161import ndg.services.revitalization.jpa.ProviderCommon; 
    6262import ndg.services.revitalization.jpa.ProviderEmail; 
     63import ndg.services.revitalization.jpa.ProviderStatistic; 
    6364import ndg.services.revitalization.jpa.ServiceConfig; 
    6465import ndg.services.revitalization.jpa.ServiceParameterValue; 
     
    8788        private final static String GET_INGEST_LOG_BY_PROVIDER = "select l, p.providerId from IngestSearchLogging l, HiProcess p  where l.reqId=p.id and p.providerId=:providerID and l.startIngest >= :start and l.stopIngest <= :end"; 
    8889        private final static String GET_INGEST_LOG_ALL_PROVIDER = "select l, p.providerId from IngestSearchLogging l, HiProcess p  where l.reqId=p.id and l.startIngest >= :start and l.stopIngest <= :end"; 
     90        private final static String GET_PROVIDER_STATISTIC = "select count(datacentre_name) from original_document where datacentre_name IN (:providerIDs) group by datacentre_name"; 
     91        private final static String GET_ALL_PROVIDER_STATISTIC = "select count(datacentre_name), datacentre_name from original_document group by datacentre_name"; 
    8992         
    9093 
     
    9295        private EntityManager em; 
    9396 
     97        @PersistenceContext(unitName = "discoveryDB") 
     98        private EntityManager emDiscovery; 
     99         
    94100        @EJB 
    95101        private HiProcessModelLocal processModel; 
     
    343349        } 
    344350         
     351        public List<ProviderStatistic> getProviderStatistic(List<Integer> providerID) throws NdgExecutionException { 
     352                 
     353                //to delete and substitute with the commented code 
     354                String sqlString = GET_ALL_PROVIDER_STATISTIC;           
     355                /* 
     356                String sqlString = GET_PROVIDER_STATISTIC; 
     357                if (providerID == null || providerID.size() == 0) 
     358                        sqlString = GET_ALL_PROVIDER_STATISTIC; 
     359                */ 
     360                 
     361                Query query = emDiscovery.createNativeQuery(sqlString); 
     362                if (sqlString.equals(GET_PROVIDER_STATISTIC)) 
     363                        query.setParameter("providerIDs", providerID); 
     364                List<Object[]> origDocs = query.getResultList(); 
     365                 
     366                List<ProviderStatistic> ret = new ArrayList<ProviderStatistic>(); 
     367                ProviderStatistic ps = null; 
     368                for(Object[] stat : origDocs) { 
     369                        ps = new ProviderStatistic(); 
     370                        ps.setProviderID(-1); 
     371                        if (stat[1] != null && stat[1].getClass().isAssignableFrom(Integer.class)) 
     372                                ps.setProviderID((Integer)stat[1]); 
     373                        ps.setIngestedRecord(((BigInteger)stat[0]).intValue()); 
     374                        ret.add(ps); 
     375                } 
     376                return ret; 
     377        }        
     378         
    345379        @SuppressWarnings("unchecked") 
    346380        private <T extends ProviderCommon> T getProvider(int id, String queryText) { 
     
    353387                        return values.get(0); 
    354388        } 
    355  
    356389} 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/interfaces/ModelManagerLocal.java

    r7656 r7660  
    4444import ndg.services.revitalization.jpa.IngestSearchLogging; 
    4545import ndg.services.revitalization.jpa.ProviderCommon; 
     46import ndg.services.revitalization.jpa.ProviderStatistic; 
    4647import ndg.services.revitalization.jpa.TimerInfo; 
    4748import ndg.services.revitalization.jpa.TimerInfoLog; 
     
    107108         
    108109        public void deleteProvider(List<Integer> providerID) throws NdgExecutionException; 
     110         
     111        public List<ProviderStatistic> getProviderStatistic(List<Integer> providerID) throws NdgExecutionException; 
    109112} 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/interfaces/ModelManagerRemote.java

    r7656 r7660  
    4646import ndg.services.revitalization.jpa.IngestSearchLogging; 
    4747import ndg.services.revitalization.jpa.ProviderCommon; 
     48import ndg.services.revitalization.jpa.ProviderStatistic; 
    4849import ndg.services.revitalization.jpa.TimerInfo; 
    4950import ndg.services.revitalization.jpa.TimerInfoLog; 
     
    178179         
    179180        public void deleteProvider(List<Integer> providerID) throws NdgExecutionException; 
     181         
     182        public List<ProviderStatistic> getProviderStatistic(List<Integer> providerID) throws NdgExecutionException; 
    180183} 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/executor/ExecuteDeleteProvider.java

    r7656 r7660  
    3434import ndg.common.exception.NdgExecutionException; 
    3535import ndg.services.revitalization.EJBBeanFactory; 
    36 import ndg.services.revitalization.jpa.TimerInfo; 
    37 import ndg.services.revitalization.jpa.TimerInfoLog; 
    3836import ndg.services.schemas.revitalization.DeleteProviderRequest; 
    3937import ndg.services.schemas.revitalization.DeleteProviderResponse; 
    40 import ndg.services.schemas.revitalization.DeleteTimerRequest; 
    41 import ndg.services.schemas.revitalization.DeleteTimerResponse; 
    4238 
    4339/**   
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/jpa/CswProvider.java

    r7389 r7660  
    1717import javax.persistence.Column; 
    1818import javax.persistence.Entity; 
     19import javax.persistence.PersistenceContext; 
    1920import javax.persistence.PrimaryKeyJoinColumn; 
    2021import javax.persistence.Table; 
  • RevitalizationWS/ws/DPWS/trunk/src/main/resources/META-INF/persistence.xml

    r7321 r7660  
    1010                </properties>            
    1111        </persistence-unit> 
     12         
     13        <persistence-unit name="discoveryDB" transaction-type="JTA"> 
     14                <jta-data-source>jdbc/discoveryDB</jta-data-source> 
     15                <exclude-unlisted-classes>true</exclude-unlisted-classes> 
     16                <properties> 
     17                        <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" /> 
     18                        <property name="hibernate.hbm2ddl.auto" value="validate" /> 
     19                </properties>            
     20        </persistence-unit>      
    1221</persistence> 
Note: See TracChangeset for help on using the changeset viewer.