Revision 33298
Added by Nikon Gasparis almost 10 years ago
modules/uoa-validator/tags/uoa-validator-1.0.1/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" ?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<parent> |
|
4 |
<groupId>eu.dnetlib</groupId> |
|
5 |
<artifactId>dnet-parent</artifactId> |
|
6 |
<version>1.0.0</version> |
|
7 |
</parent> |
|
8 |
<modelVersion>4.0.0</modelVersion> |
|
9 |
<groupId>eu.dnetlib</groupId> |
|
10 |
<artifactId>uoa-validator</artifactId> |
|
11 |
<packaging>jar</packaging> |
|
12 |
<version>1.0.1</version> |
|
13 |
<scm> |
|
14 |
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-validator/tags/uoa-validator-1.0.1</developerConnection> |
|
15 |
</scm> |
|
16 |
<dependencies> |
|
17 |
<dependency> |
|
18 |
<groupId>eu.dnetlib</groupId> |
|
19 |
<artifactId>uoa-clients</artifactId> |
|
20 |
<version>[1.0.0]</version> |
|
21 |
</dependency> |
|
22 |
<dependency> |
|
23 |
<groupId>eu.dnetlib</groupId> |
|
24 |
<artifactId>uoa-utils</artifactId> |
|
25 |
<version>[1.0.0]</version> |
|
26 |
</dependency> |
|
27 |
<dependency> |
|
28 |
<groupId>eu.dnetlib</groupId> |
|
29 |
<artifactId>uoa-api</artifactId> |
|
30 |
<version>[1.0.0]</version> |
|
31 |
</dependency> |
|
32 |
<dependency> |
|
33 |
<groupId>apache</groupId> |
|
34 |
<artifactId>commons-io</artifactId> |
|
35 |
<version>[1.4,)</version> |
|
36 |
</dependency> |
|
37 |
<dependency> |
|
38 |
<groupId>apache</groupId> |
|
39 |
<artifactId>commons-cli</artifactId> |
|
40 |
<version>[1.0,)</version> |
|
41 |
</dependency> |
|
42 |
<dependency> |
|
43 |
<groupId>log4j</groupId> |
|
44 |
<artifactId>log4j</artifactId> |
|
45 |
<version>[1.2.14,1.3.0)</version> |
|
46 |
</dependency> |
|
47 |
<dependency> |
|
48 |
<groupId>com.thoughtworks.xstream</groupId> |
|
49 |
<artifactId>xstream</artifactId> |
|
50 |
<version>[0.0.0,)</version> |
|
51 |
</dependency> |
|
52 |
<dependency> |
|
53 |
<groupId>junit</groupId> |
|
54 |
<artifactId>junit</artifactId> |
|
55 |
<version>[0.0.0,)</version> |
|
56 |
<scope>test</scope> |
|
57 |
</dependency> |
|
58 |
<dependency> |
|
59 |
<groupId>org.springframework</groupId> |
|
60 |
<artifactId>spring-jdbc</artifactId> |
|
61 |
<version>${spring.version}</version> |
|
62 |
</dependency> |
|
63 |
<dependency> |
|
64 |
<groupId>org.springframework</groupId> |
|
65 |
<artifactId>spring-tx</artifactId> |
|
66 |
<version>${spring.version}</version> |
|
67 |
</dependency> |
|
68 |
<dependency> |
|
69 |
<groupId>org.apache.velocity</groupId> |
|
70 |
<artifactId>velocity</artifactId> |
|
71 |
<version>1.7</version> |
|
72 |
</dependency> |
|
73 |
<dependency> |
|
74 |
<groupId>eu.dnetlib</groupId> |
|
75 |
<artifactId>cnr-blackboard-common</artifactId> |
|
76 |
<version>[1.0.0]</version> |
|
77 |
</dependency> |
|
78 |
<dependency> |
|
79 |
<groupId>postgresql</groupId> |
|
80 |
<artifactId>postgresql</artifactId> |
|
81 |
<version>9.1-901.jdbc4</version> |
|
82 |
</dependency> |
|
83 |
<dependency> |
|
84 |
<groupId>se.kb</groupId> |
|
85 |
<artifactId>oai4j</artifactId> |
|
86 |
<version>[0.6b1,)</version> |
|
87 |
</dependency> |
|
88 |
</dependencies> |
|
89 |
</project> |
modules/uoa-validator/tags/uoa-validator-1.0.1/deploy.info | ||
---|---|---|
1 |
{ |
|
2 |
"type_source": "SVN", |
|
3 |
"goal": "package -U -T 4C source:jar", |
|
4 |
"url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-validator/trunk", |
|
5 |
"deploy_repository": "dnet4-snapshots", |
|
6 |
"version": "4", |
|
7 |
"mail": "antleb@di.uoa.gr, kiatrop@di.uoa.gr, nikonas@di.uoa.gr", |
|
8 |
"deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", |
|
9 |
"name": "uoa-validator" |
|
10 |
} |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/resources/gr/uoa/di/validator/service/springContext-validator-service.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<beans xmlns="http://www.springframework.org/schema/beans" |
|
3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" |
|
4 |
xmlns:cxf="http://cxf.apache.org/core" xmlns:jaxws="http://cxf.apache.org/jaxws" |
|
5 |
xmlns:p="http://http://www.springframework.org/schema/p" |
|
6 |
xmlns:template="http://dnetlib.eu/springbeans/template" xmlns:t="http://dnetlib.eu/springbeans/t" |
|
7 |
xmlns:tx="http://www.springframework.org/schema/tx" |
|
8 |
|
|
9 |
xsi:schemaLocation=" |
|
10 |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd |
|
11 |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd |
|
12 |
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd |
|
13 |
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd |
|
14 |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd |
|
15 |
http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd" |
|
16 |
default-autowire="no"> |
|
17 |
|
|
18 |
<bean id="blackboardHandler" |
|
19 |
class="eu.dnetlib.enabling.tools.blackboard.BlackboardHandlerImpl"> |
|
20 |
<property name="registryLocator" ref="cnr.registryLocator" /> |
|
21 |
<property name="messageFactory"> |
|
22 |
<bean class="eu.dnetlib.miscutils.jaxb.JaxbFactory"> |
|
23 |
<constructor-arg |
|
24 |
value="eu.dnetlib.enabling.tools.blackboard.BlackboardMessageImpl" /> |
|
25 |
</bean> |
|
26 |
</property> |
|
27 |
</bean> |
|
28 |
|
|
29 |
<bean id="notificationListener" class="gr.uoa.di.validator.service.NotificationListener" |
|
30 |
scope="singleton"> |
|
31 |
<property name="valManager" ref="validatorManager" /> |
|
32 |
<property name="blackboardHandler" ref="blackboardHandler" /> |
|
33 |
</bean> |
|
34 |
|
|
35 |
<bean id="validatorManager" class="gr.uoa.di.validator.service.ValidatorManagerImpl" |
|
36 |
scope="singleton" init-method="start"> |
|
37 |
<property name="validator" ref="validator" /> |
|
38 |
<property name="jobSubmittedDao" ref="jobSubmittedDao" /> |
|
39 |
<property name="ruleSetDao" ref="ruleSetDao" /> |
|
40 |
<property name="ruleStoredDao" ref="ruleStoredDao" /> |
|
41 |
<lookup-method name="createListener" bean="openaireValListener" /> |
|
42 |
<lookup-method name="createDnetListener" bean="openaireDnetListener" /> |
|
43 |
</bean> |
|
44 |
|
|
45 |
<bean id="validatorService" class="gr.uoa.di.validator.service.ValidatorServiceImpl" |
|
46 |
scope="singleton"> |
|
47 |
<property name="snManager" ref="snManager" /> |
|
48 |
<property name="blackboardNotificationHandler" ref="notificationListener" /> |
|
49 |
</bean> |
|
50 |
|
|
51 |
<!-- <bean id="dnetProvider" class="gr.uoa.di.validator.service.DnetProvider" factory-method="getInstance"> --> |
|
52 |
<!-- <property name="dataSourceResolver" ref="extendedDataSourceResolver" /> --> |
|
53 |
<!-- <property name="rsFactory" ref="resultSetFactory" /> --> |
|
54 |
<!-- </bean> --> |
|
55 |
|
|
56 |
|
|
57 |
<!-- The web service bean --> |
|
58 |
<bean id="validatorWebServiceImpl" |
|
59 |
class="eu.dnetlib.clients.functionality.validator.ws.ValidatorWebServiceImpl"> |
|
60 |
<property name="service" ref="validatorService" /> |
|
61 |
</bean> |
|
62 |
|
|
63 |
<!-- Service endpoint --> |
|
64 |
<jaxws:endpoint |
|
65 |
id="validatorWebService" |
|
66 |
implementor="#validatorWebServiceImpl" |
|
67 |
implementorClass="eu.dnetlib.clients.functionality.validator.ws.ValidatorWebService" |
|
68 |
address="/validatorWebService"/> |
|
69 |
|
|
70 |
<template:instance name="nkua.serviceRegistrationManager" |
|
71 |
t:name="validatorServiceRegistrationManager" |
|
72 |
t:service="validatorService" |
|
73 |
t:endpoint="validatorWebService"/> |
|
74 |
</beans> |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/resources/gr/uoa/di/validator/dao/springContext-validator-dao.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<beans xmlns="http://www.springframework.org/schema/beans" |
|
3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" |
|
4 |
xmlns:cxf="http://cxf.apache.org/core" xmlns:jaxws="http://cxf.apache.org/jaxws" |
|
5 |
xmlns:p="http://http://www.springframework.org/schema/p" |
|
6 |
xmlns:template="http://dnetlib.eu/springbeans/template" xmlns:t="http://dnetlib.eu/springbeans/t" |
|
7 |
xmlns:tx="http://www.springframework.org/schema/tx" |
|
8 |
|
|
9 |
xsi:schemaLocation=" |
|
10 |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd |
|
11 |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd |
|
12 |
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd |
|
13 |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd |
|
14 |
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd |
|
15 |
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd |
|
16 |
http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd" |
|
17 |
default-autowire="no"> |
|
18 |
|
|
19 |
<bean id="jobSubmittedDao" class="gr.uoa.di.validator.dao.JobSubmittedDAOImpl"> |
|
20 |
<property name="datasource" ref="validator.dataSource" /> |
|
21 |
</bean> |
|
22 |
|
|
23 |
<bean id="repositoryStoredDao" class="gr.uoa.di.validator.dao.RepositoryStoredDAOImpl"> |
|
24 |
<property name="datasource" ref="validator.dataSource" /> |
|
25 |
</bean> |
|
26 |
|
|
27 |
<bean id="ruleSetDao" class="gr.uoa.di.validator.dao.RuleSetDAOimpl"> |
|
28 |
<property name="datasource" ref="validator.dataSource" /> |
|
29 |
</bean> |
|
30 |
|
|
31 |
<bean id="ruleStoredDao" class="gr.uoa.di.validator.dao.RuleStoredDAOimpl"> |
|
32 |
<property name="datasource" ref="validator.dataSource" /> |
|
33 |
</bean> |
|
34 |
|
|
35 |
<bean id="taskStoredDao" class="gr.uoa.di.validator.dao.TaskStoredDAOimpl"> |
|
36 |
<property name="datasource" ref="validator.dataSource" /> |
|
37 |
</bean> |
|
38 |
|
|
39 |
<bean id="userStoredDao" class="gr.uoa.di.validator.dao.UserStoredDAOimpl"> |
|
40 |
<property name="datasource" ref="validator.dataSource" /> |
|
41 |
</bean> |
|
42 |
|
|
43 |
</beans> |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/resources/gr/uoa/di/validator/dao/springContext-validator-dao-datasource.properties | ||
---|---|---|
1 |
services.validator.db.driverClassName = org.postgresql.Driver |
|
2 |
services.validator.db.url = jdbc:postgresql://194.177.192.223:5432/validatornew |
|
3 |
services.validator.db.username = nickonas |
|
4 |
services.validator.db.password = 123456 |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/resources/gr/uoa/di/validator/dao/springContext-validator-dao-datasource.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<beans xmlns="http://www.springframework.org/schema/beans" |
|
3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
4 |
xmlns:context="http://www.springframework.org/schema/context" |
|
5 |
xmlns:cxf="http://cxf.apache.org/core" |
|
6 |
xmlns:jaxws="http://cxf.apache.org/jaxws" |
|
7 |
xmlns:p="http://http://www.springframework.org/schema/p" |
|
8 |
xmlns:template="http://dnetlib.eu/springbeans/template" |
|
9 |
xmlns:t="http://dnetlib.eu/springbeans/t" |
|
10 |
xmlns:tx="http://www.springframework.org/schema/tx" |
|
11 |
|
|
12 |
xsi:schemaLocation=" |
|
13 |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd |
|
14 |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd |
|
15 |
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd |
|
16 |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd |
|
17 |
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd |
|
18 |
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd |
|
19 |
http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd" |
|
20 |
default-autowire="no"> |
|
21 |
|
|
22 |
<bean id="validator.dataSource" class="org.apache.commons.dbcp.BasicDataSource" |
|
23 |
destroy-method="close"> |
|
24 |
<property name="driverClassName" value="${services.validator.db.driverClassName}" /> |
|
25 |
<property name="url" value="${services.validator.db.url}" /> |
|
26 |
<property name="username" value="${services.validator.db.username}" /> |
|
27 |
<property name="password" value="${services.validator.db.password}" /> |
|
28 |
|
|
29 |
<property name="maxIdle" value="10" /> |
|
30 |
<property name="maxActive" value="100" /> |
|
31 |
<property name="maxWait" value="10000" /> |
|
32 |
<property name="validationQuery" value="select 1" /> |
|
33 |
<property name="testOnBorrow" value="true" /> |
|
34 |
<property name="testWhileIdle" value="true" /> |
|
35 |
<property name="timeBetweenEvictionRunsMillis" value="1200000" /> |
|
36 |
<property name="minEvictableIdleTimeMillis" value="1800000" /> |
|
37 |
<property name="numTestsPerEvictionRun" value="5" /> |
|
38 |
<property name="defaultAutoCommit" value="false" /> |
|
39 |
|
|
40 |
<property name="removeAbandoned" value="true" /> |
|
41 |
<property name="removeAbandonedTimeout" value="60" /> |
|
42 |
<property name="logAbandoned" value="true" /> |
|
43 |
</bean> |
|
44 |
|
|
45 |
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> |
|
46 |
<property name="dataSource" ref="validator.dataSource" /> |
|
47 |
</bean> |
|
48 |
|
|
49 |
<tx:annotation-driven transaction-manager="txManager" proxy-target-class="true"/> |
|
50 |
</beans> |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/resources/gr/uoa/di/validator/impls/springContext-validator-library.properties | ||
---|---|---|
1 |
services.validator.engine.timeout=3600 |
|
2 |
services.validator.engine.generalTimeout=86400 |
|
3 |
|
|
4 |
services.validator.engine.poolExecutor.corePoolSize=20 |
|
5 |
services.validator.engine.poolExecutor.maximumPoolSize=40 |
|
6 |
services.validator.engine.poolExecutor.keepAliveTime=3600 |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/resources/gr/uoa/di/validator/impls/listeners/springContext-validator-listeners.properties | ||
---|---|---|
1 |
services.validator.baseUrl = localhost |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/resources/gr/uoa/di/validator/impls/listeners/springContext-validator-listeners.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<beans xmlns="http://www.springframework.org/schema/beans" |
|
3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
4 |
xmlns:context="http://www.springframework.org/schema/context" |
|
5 |
xmlns:cxf="http://cxf.apache.org/core" |
|
6 |
xmlns:jaxws="http://cxf.apache.org/jaxws" |
|
7 |
xmlns:p="http://http://www.springframework.org/schema/p" |
|
8 |
xmlns:template="http://dnetlib.eu/springbeans/template" |
|
9 |
xmlns:t="http://dnetlib.eu/springbeans/t" |
|
10 |
xmlns:tx="http://www.springframework.org/schema/tx" |
|
11 |
|
|
12 |
xsi:schemaLocation=" |
|
13 |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd |
|
14 |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd |
|
15 |
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd |
|
16 |
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd |
|
17 |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd |
|
18 |
http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd" |
|
19 |
default-autowire="no"> |
|
20 |
|
|
21 |
<bean id ="openaireValListener" class="gr.uoa.di.validator.impls.listeners.ValidatorJobListener" scope="prototype"> |
|
22 |
<property name="jobSubmittedDao" ref="jobSubmittedDao" /> |
|
23 |
<property name="taskStoredDao" ref="taskStoredDao" /> |
|
24 |
<property name="ruleStoredDao" ref="ruleStoredDao" /> |
|
25 |
<property name="valBaseUrl" value="${services.validator.baseUrl}" /> |
|
26 |
</bean> |
|
27 |
|
|
28 |
<bean id ="openaireDnetListener" class="gr.uoa.di.validator.impls.listeners.DnetListener" scope="prototype" init-method="init"> |
|
29 |
<property name="xmlBuilder" ref="recordXMLBuilder" /> |
|
30 |
<property name="resultSetServiceLocator" ref="resultSetServiceLocator"/> |
|
31 |
</bean> |
|
32 |
|
|
33 |
<bean id ="recordXMLBuilder" class="gr.uoa.di.validator.impls.listeners.RecordXMLBuilder" init-method="init" scope="prototype" /> |
|
34 |
|
|
35 |
</beans> |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/resources/gr/uoa/di/validator/impls/listeners/xml.vm | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<validator:result xmlns:validator="http://eu.dnetlib/validator" recordId=$record.id status=$record.status score=$record.score> |
|
3 |
<validator:failedRules> |
|
4 |
#foreach( $rule in $ruleList ) |
|
5 |
<validator:rule id=$rule.id errorMessage=$rule.error/> |
|
6 |
#end |
|
7 |
</validator:failedRules> |
|
8 |
<validator:record> |
|
9 |
$recordFull |
|
10 |
</validator:record> |
|
11 |
|
|
12 |
</validator:result> |
|
13 |
|
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/resources/gr/uoa/di/validator/impls/listeners/xmlFinalReport.vm | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<validator:jobResult xmlns:validator="http://eu.dnetlib/validator" recordId=$record.id status=$record.status score=$record.score> |
|
3 |
<validator:startDate startDate=$job.startDate/> |
|
4 |
<validator:endDate endDate=$job.endDate /> |
|
5 |
<validator:duration duration=$job.duration /> |
|
6 |
<validator:totalRecords totalRecords=$job.totalRecords /> |
|
7 |
<validator:passedRecords passedRecords=$job.passedRecords /> |
|
8 |
<validator:failedRecords failedRecords=$job.failedRecords /> |
|
9 |
<validator:score score=$job.score /> |
|
10 |
</validator:jobResult> |
|
11 |
|
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/resources/gr/uoa/di/validator/impls/springContext-validator-library.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<beans xmlns="http://www.springframework.org/schema/beans" |
|
3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" |
|
4 |
xmlns:cxf="http://cxf.apache.org/core" xmlns:jaxws="http://cxf.apache.org/jaxws" |
|
5 |
xmlns:p="http://http://www.springframework.org/schema/p" |
|
6 |
xmlns:template="http://dnetlib.eu/springbeans/template" xmlns:t="http://dnetlib.eu/springbeans/t" |
|
7 |
xmlns:tx="http://www.springframework.org/schema/tx" |
|
8 |
xmlns:util="http://www.springframework.org/schema/util" |
|
9 |
|
|
10 |
xsi:schemaLocation=" |
|
11 |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd |
|
12 |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd |
|
13 |
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd |
|
14 |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd |
|
15 |
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd |
|
16 |
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd |
|
17 |
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd |
|
18 |
http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd" |
|
19 |
default-autowire="no"> |
|
20 |
|
|
21 |
<bean id="validator" class="gr.uoa.di.validator.impls.MemoryThreadValidator" init-method="start"> |
|
22 |
<property name="mdStoreServiceLocator" ref="mdStoreServiceLocator" /> |
|
23 |
<property name="rsFactory" ref="resultSetFactory" /> |
|
24 |
<property name="dnetWorkflow" value="${services.validator.dnetWorkflow}" /> |
|
25 |
<!-- <property name="dnetWorkflow" value="true" /> --> |
|
26 |
<constructor-arg index="0" ref="persistance" /> |
|
27 |
<constructor-arg index="1" ref="threadPoolExecutor" /> |
|
28 |
<constructor-arg index="2" ref="taskExecutor" /> |
|
29 |
<constructor-arg index="3" value="${services.validator.engine.timeout}" /> |
|
30 |
<constructor-arg index="4" value="${services.validator.engine.generalTimeout}" /> |
|
31 |
</bean> |
|
32 |
|
|
33 |
|
|
34 |
<!-- <bean id="extendedDataSourceResolver" --> |
|
35 |
<!-- class="eu.dnetlib.data.information.DataSourceResolverDispatcher"> --> |
|
36 |
<!-- <property name="resolvers"> --> |
|
37 |
<!-- <map> --> |
|
38 |
<!-- <entry key="EPR"> --> |
|
39 |
<!-- <bean class="eu.dnetlib.data.information.EPRDataSourceResolverImpl"> --> |
|
40 |
<!-- </bean> --> |
|
41 |
<!-- </entry> --> |
|
42 |
<!-- </map> --> |
|
43 |
<!-- </property> --> |
|
44 |
<!-- </bean> --> |
|
45 |
|
|
46 |
<bean id="persistance" class ="gr.uoa.di.validator.impls.persistance.XMLFilePersistance"> |
|
47 |
<constructor-arg index="0"> |
|
48 |
<props> |
|
49 |
<prop key="directory">output</prop> |
|
50 |
</props> |
|
51 |
</constructor-arg> |
|
52 |
</bean> |
|
53 |
|
|
54 |
<bean id="taskExecutor" class="gr.uoa.di.validator.impls.executors.ThreadExecutor"> |
|
55 |
<constructor-arg index="0" ref="threadPoolExecutor"/> |
|
56 |
</bean> |
|
57 |
|
|
58 |
<bean id="threadPoolExecutor" class="java.util.concurrent.ThreadPoolExecutor" > |
|
59 |
<constructor-arg index="0" value="${services.validator.engine.poolExecutor.corePoolSize}" /> |
|
60 |
<constructor-arg index="1" value="${services.validator.engine.poolExecutor.maximumPoolSize}" /> |
|
61 |
<constructor-arg index="2" value="${services.validator.engine.poolExecutor.keepAliveTime}" /> |
|
62 |
<constructor-arg index="3"><util:constant static-field="java.util.concurrent.TimeUnit.SECONDS"/></constructor-arg> |
|
63 |
<constructor-arg index="4"> |
|
64 |
<bean class="java.util.concurrent.LinkedBlockingQueue"/> |
|
65 |
</constructor-arg> |
|
66 |
</bean> |
|
67 |
</beans> |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/java/gr/uoa/di/validator/persistance/Registry.java | ||
---|---|---|
1 |
package gr.uoa.di.validator.persistance; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.Validator; |
|
4 |
|
|
5 |
import java.io.Serializable; |
|
6 |
|
|
7 |
/** |
|
8 |
* A Registry used to store serializable objects. |
|
9 |
* Registries are used by {@link Validator} to store the objects they need to run. |
|
10 |
* @author Manos Karvounis |
|
11 |
* |
|
12 |
* @param <T> |
|
13 |
*/ |
|
14 |
public abstract class Registry<T extends Serializable> { |
|
15 |
|
|
16 |
public final String name; |
|
17 |
|
|
18 |
public Registry(String name) { |
|
19 |
super(); |
|
20 |
this.name = name; |
|
21 |
} |
|
22 |
|
|
23 |
public abstract T getObject(int id); |
|
24 |
|
|
25 |
public abstract void addObject(int id, T obj); |
|
26 |
|
|
27 |
} |
|
28 | 0 |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/java/gr/uoa/di/validator/persistance/Persistable.java | ||
---|---|---|
1 |
package gr.uoa.di.validator.persistance; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.data.DataException; |
|
4 |
|
|
5 |
/** |
|
6 |
* Indicates that an object may be persisted to permanent storage and be retrieved from it. |
|
7 |
* @author manos |
|
8 |
* |
|
9 |
*/ |
|
10 |
public interface Persistable { |
|
11 |
|
|
12 |
public void persist() throws DataException; |
|
13 |
|
|
14 |
public void restore() throws DataException; |
|
15 |
} |
|
16 | 0 |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/java/gr/uoa/di/validator/persistance/Persistance.java | ||
---|---|---|
1 |
package gr.uoa.di.validator.persistance; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.data.DataException; |
|
4 |
import gr.uoa.di.validator.data.ResultSet; |
|
5 |
|
|
6 |
import java.io.Serializable; |
|
7 |
|
|
8 |
/** |
|
9 |
* A mechainism for persisting/retrieving Serializable objects to/from permanent storage. |
|
10 |
* @author Manos Karvounis |
|
11 |
* |
|
12 |
*/ |
|
13 |
public interface Persistance { |
|
14 |
|
|
15 |
/** |
|
16 |
* Initialize the mechanism. Must be invoked before any other method is invoked. |
|
17 |
* @throws DataException |
|
18 |
*/ |
|
19 |
public void open() throws DataException; |
|
20 |
|
|
21 |
/** |
|
22 |
* Close the mechanism and release all held resources. |
|
23 |
* Must be invoked even if a an exception was raised by another method. |
|
24 |
* @throws DataException |
|
25 |
*/ |
|
26 |
public void close() throws DataException; |
|
27 |
|
|
28 |
/** |
|
29 |
* Persists a serializable object to permanent storage. |
|
30 |
* @param <T> |
|
31 |
* @param objid A unique id identifying the object. |
|
32 |
* @param obj The object itself. |
|
33 |
* @param container The name of the container where the object will be stored. Note that objects are restored as a whole from their container {@link Persistance#restore(String) |
|
34 |
* @throws DataException |
|
35 |
*/ |
|
36 |
public <T extends Serializable> void persist(int objid, T obj, String container) throws DataException; |
|
37 |
|
|
38 |
/** |
|
39 |
* Restore all the contents of a container. |
|
40 |
* @param <T> |
|
41 |
* @param container The name of the container. |
|
42 |
* @return The objects contained in the container. |
|
43 |
* @throws DataException |
|
44 |
*/ |
|
45 |
public <T extends Serializable> ResultSet<T> restore(String container) throws DataException; |
|
46 |
|
|
47 |
} |
|
48 | 0 |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/java/gr/uoa/di/validator/service/ValidatorManager.java | ||
---|---|---|
1 |
package gr.uoa.di.validator.service; |
|
2 |
|
|
3 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
|
4 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardNotificationHandler; |
|
5 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler; |
|
6 |
import gr.uoa.di.validator.ValidatorException; |
|
7 |
import gr.uoa.di.validator.dao.JobSubmitted; |
|
8 |
|
|
9 |
public interface ValidatorManager { |
|
10 |
|
|
11 |
public JobSubmitted beginDataJobForWorkflow(String datasource, String guidelines, String groupBy, BlackboardJob bJob, BlackboardNotificationHandler<BlackboardServerHandler> blackboardHandler, int workers) throws ValidatorException; |
|
12 |
|
|
13 |
public JobSubmitted beginContentJobForWorkflow(String baseUrl, String validationSet, BlackboardJob bJob, BlackboardNotificationHandler<BlackboardServerHandler> blackboardHandler) throws ValidatorException; |
|
14 |
|
|
15 |
public JobSubmitted beginUsageJobForWorkflow(String baseUrl, String validationSet, BlackboardJob bJob, BlackboardNotificationHandler<BlackboardServerHandler> blackboardHandler) throws ValidatorException; |
|
16 |
} |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/java/gr/uoa/di/validator/service/ValidatorManagerImpl.java | ||
---|---|---|
1 |
package gr.uoa.di.validator.service; |
|
2 |
|
|
3 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
|
4 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardNotificationHandler; |
|
5 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler; |
|
6 |
import gr.uoa.di.validator.Validator; |
|
7 |
import gr.uoa.di.validator.ValidatorException; |
|
8 |
import gr.uoa.di.validator.dao.JobSubmitted; |
|
9 |
import gr.uoa.di.validator.dao.JobSubmittedDAO; |
|
10 |
import gr.uoa.di.validator.dao.RuleSet; |
|
11 |
import gr.uoa.di.validator.dao.RuleSetDAO; |
|
12 |
import gr.uoa.di.validator.dao.RuleStored; |
|
13 |
import gr.uoa.di.validator.dao.RuleStoredDAO; |
|
14 |
import gr.uoa.di.validator.dao.Utilities; |
|
15 |
import gr.uoa.di.validator.data.Rule; |
|
16 |
import gr.uoa.di.validator.execution.Job; |
|
17 |
import gr.uoa.di.validator.impls.MemoryThreadValidator; |
|
18 |
import gr.uoa.di.validator.impls.listeners.DnetListener; |
|
19 |
import gr.uoa.di.validator.impls.listeners.ValidatorJobListener; |
|
20 |
import gr.uoa.di.validator.impls.providers.OAIPMHRecordProvider; |
|
21 |
import gr.uoa.di.validator.impls.providers.OAIPMHSinglePageVerbProvider; |
|
22 |
import gr.uoa.di.validator.impls.rules.ChainRule; |
|
23 |
import gr.uoa.di.validator.impls.rules.RuleTypes; |
|
24 |
|
|
25 |
import java.io.Serializable; |
|
26 |
import java.lang.reflect.InvocationTargetException; |
|
27 |
import java.util.ArrayList; |
|
28 |
import java.util.HashMap; |
|
29 |
import java.util.HashSet; |
|
30 |
import java.util.List; |
|
31 |
import java.util.Map; |
|
32 |
import java.util.Properties; |
|
33 |
import java.util.Set; |
|
34 |
|
|
35 |
import org.apache.log4j.Logger; |
|
36 |
import org.springframework.transaction.annotation.Propagation; |
|
37 |
import org.springframework.transaction.annotation.Transactional; |
|
38 |
|
|
39 |
@Transactional(propagation = Propagation.REQUIRED) |
|
40 |
public abstract class ValidatorManagerImpl implements ValidatorManager { |
|
41 |
|
|
42 |
private Validator validator; |
|
43 |
private JobSubmittedDAO jobSubmittedDao; |
|
44 |
private RuleSetDAO ruleSetDao; |
|
45 |
private RuleStoredDAO ruleStoredDao; |
|
46 |
|
|
47 |
// private Map<Integer, Integer> ruleLinkingMap = new HashMap<Integer, Integer>(); |
|
48 |
private Integer jobIdRegistry = 1; |
|
49 |
private Integer ruleIdRegistry = 1; |
|
50 |
|
|
51 |
private static Logger logger = Logger.getLogger(ValidatorManagerImpl.class); |
|
52 |
|
|
53 |
protected abstract ValidatorJobListener createListener(); |
|
54 |
protected abstract DnetListener createDnetListener(); |
|
55 |
|
|
56 |
public void start() { |
|
57 |
logger.debug("Initializing Validator Manager module"); |
|
58 |
} |
|
59 |
|
|
60 |
@Transactional(propagation = Propagation.REQUIRED) |
|
61 |
public JobSubmitted beginDataJobForWorkflow(String mdstoreId, String guidelines, String groupBy, BlackboardJob bJob, BlackboardNotificationHandler<BlackboardServerHandler> blackboardHandler, int workers) throws ValidatorException{ |
|
62 |
try { |
|
63 |
logger.debug("Submitting data job for workflow"); |
|
64 |
// String desiredCompatibility = "openaire3.0"; |
|
65 |
Set<Integer> ruleIdsContent = new HashSet<Integer>(); |
|
66 |
for (RuleSet ruleset : ruleSetDao.getRuleSets()) { |
|
67 |
if (ruleset.getGuidelinesAcronym().equals(guidelines)) { |
|
68 |
ruleIdsContent = Utilities.convertListToSet(ruleset.getRuleIdsContent()); |
|
69 |
} |
|
70 |
} |
|
71 |
Properties pros = new Properties(); |
|
72 |
|
|
73 |
pros.setProperty(DnetProvider.MDSTORE_ID, mdstoreId); |
|
74 |
// pros.setProperty(DnetProvider.BATCH_SIZE, bJob.getParameters().get("batchSize")); |
|
75 |
pros.setProperty(DnetProvider.BATCH_SIZE, "50"); |
|
76 |
pros.setProperty(DnetProvider.RECORDS, bJob.getParameters().get("records")); |
|
77 |
|
|
78 |
JobSubmitted newJob = new JobSubmitted(); |
|
79 |
|
|
80 |
Set<Integer> rules = new HashSet<Integer>(); |
|
81 |
|
|
82 |
Map<Integer,Integer> ruleLinkingMap = new HashMap<Integer,Integer>(); |
|
83 |
|
|
84 |
for (Integer ruleId : ruleIdsContent) { |
|
85 |
|
|
86 |
RuleStored tempRule=ruleStoredDao.get(ruleId.toString()); |
|
87 |
|
|
88 |
//special behaviour type of rule is chain |
|
89 |
if(tempRule.getType().equals("ChainRule")) { |
|
90 |
ChainRule<Rule> chainRule = this.handleChain(tempRule); |
|
91 |
validator.addToRegistry(ruleIdRegistry,chainRule, MemoryThreadValidator.RegistryType.rules); |
|
92 |
} |
|
93 |
else { |
|
94 |
validator.addToRegistry(ruleIdRegistry,this.getRuleClassInstanceByType(tempRule.getType(), tempRule.getConfiguration(), ruleIdRegistry), MemoryThreadValidator.RegistryType.rules); |
|
95 |
} |
|
96 |
rules.add(ruleIdRegistry); |
|
97 |
// this.linkRules(ruleIdRegistry, ruleId); |
|
98 |
ruleLinkingMap.put(ruleIdRegistry, ruleId); |
|
99 |
ruleIdRegistry++; |
|
100 |
} |
|
101 |
|
|
102 |
Job job = new Job(this.jobIdRegistry, 3, rules, pros); |
|
103 |
this.jobIdRegistry++; |
|
104 |
|
|
105 |
newJob.setUser("Workflow Service"); |
|
106 |
newJob.setValidationType("OAI Content"); |
|
107 |
newJob.setGuidelines(guidelines); |
|
108 |
// newJob.setType("OAI Content Validation"); |
|
109 |
newJob.setStatus("working"); |
|
110 |
newJob.setJobType("Workflow Request"); |
|
111 |
newJob.setDuration("--"); |
|
112 |
newJob.setRepo(mdstoreId); |
|
113 |
newJob.setRules(ruleIdsContent); |
|
114 |
newJob.setRecords(pros.getProperty(DnetProvider.RECORDS)); |
|
115 |
newJob.setSet("dnet-workflow"); |
|
116 |
newJob.setGroupBy_xpath(groupBy); |
|
117 |
newJob.setMetadata_prefix("oai_dc"); |
|
118 |
newJob.setId("-1"); |
|
119 |
int jobIdStored = jobSubmittedDao.save(newJob); |
|
120 |
ValidatorJobListener listener = createListener(); |
|
121 |
listener.setJobSubmittedId(jobIdStored); |
|
122 |
listener.setJobSubmittedUser("Workflow Service"); |
|
123 |
listener.setRuleLinkingMap(ruleLinkingMap); |
|
124 |
listener.setGroupBy_xpath(groupBy); |
|
125 |
listener.setInternalJobsSum(workers); |
|
126 |
// |
|
127 |
DnetListener dnetListener = createDnetListener(); |
|
128 |
dnetListener.setJob(bJob); |
|
129 |
dnetListener.setBlackboardHandler(blackboardHandler); |
|
130 |
|
|
131 |
// validator.submitJob(job, listener, dnetListener); |
|
132 |
validator.submitJob(job, workers, listener, dnetListener); |
|
133 |
|
|
134 |
return newJob; |
|
135 |
|
|
136 |
|
|
137 |
} catch (Exception e) { |
|
138 |
logger.error("Error Submitting content job", e); |
|
139 |
throw new ValidatorException(e); |
|
140 |
} |
|
141 |
} |
|
142 |
|
|
143 |
|
|
144 |
/* public JobSubmitted beginDataJobForWorkflow(String mdstoreId, BlackboardJob bJob, BlackboardNotificationHandler<BlackboardServerHandler> blackboardHandler) throws ValidatorException{ |
|
145 |
try { |
|
146 |
logger.debug("Submitting data job for workflow"); |
|
147 |
Set<Integer> ruleIdsContent = new HashSet<Integer>(); |
|
148 |
|
|
149 |
for (RuleSet ruleset : ruleSetDao.getRuleSets()) { |
|
150 |
String regRuleset; |
|
151 |
|
|
152 |
regRuleset = "OpenAIRE For Literature Repositories"; |
|
153 |
|
|
154 |
if (ruleset.getName().equals(regRuleset)) { |
|
155 |
ruleIdsContent = Utilities.convertListToSet(ruleset.getRuleIdsContent()); |
|
156 |
} |
|
157 |
} |
|
158 |
|
|
159 |
Properties pros = new Properties(); |
|
160 |
|
|
161 |
pros.setProperty(DnetProvider.MDSTORE_ID, mdstoreId); |
|
162 |
pros.setProperty(DnetProvider.BATCH_SIZE, "10"); |
|
163 |
pros.setProperty(DnetProvider.RECORDS, "5"); |
|
164 |
|
|
165 |
JobSubmitted newJob = new JobSubmitted(); |
|
166 |
|
|
167 |
Set<Integer> rules = new HashSet<Integer>(); |
|
168 |
|
|
169 |
for (Integer ruleId : ruleIdsContent) { |
|
170 |
RuleStored tempRule = ruleStoredDao.get(ruleId.toString()); |
|
171 |
|
|
172 |
// special behaviour type of rule is chain |
|
173 |
if (tempRule.getType().equals("ChainRule")) { |
|
174 |
logger.debug("chain rule found"); |
|
175 |
RuleStored tempRuleChain1 = ruleStoredDao.get(tempRule.getConfiguration().getProperty("rule_1")); |
|
176 |
RuleStored tempRuleChain2 = ruleStoredDao.get(tempRule.getConfiguration().getProperty("rule_2")); |
|
177 |
List<Rule> rules_chain = new ArrayList<Rule>(); |
|
178 |
rules_chain.add((Rule) this.getRuleClassInstanceByType(tempRuleChain1.getType(), tempRuleChain1.getConfiguration(), ruleIdRegistry)); |
|
179 |
ruleIdRegistry++; |
|
180 |
rules_chain.add((Rule) this.getRuleClassInstanceByType(tempRuleChain2.getType(), tempRuleChain2.getConfiguration(), ruleIdRegistry)); |
|
181 |
ruleIdRegistry++; |
|
182 |
|
|
183 |
Properties chainPros = new Properties(); |
|
184 |
chainPros.setProperty(ChainRule.TYPE, tempRule.getConfiguration().getProperty(ChainRule.TYPE)); |
|
185 |
ChainRule<Rule> chainRule = new ChainRule<Rule>(chainPros, ruleIdRegistry, rules_chain); |
|
186 |
|
|
187 |
validator.addToRegistry(ruleIdRegistry, chainRule, MemoryThreadValidator.RegistryType.rules); |
|
188 |
} else { |
|
189 |
validator.addToRegistry(ruleIdRegistry, this.getRuleClassInstanceByType(tempRule.getType(), tempRule.getConfiguration(), ruleIdRegistry), MemoryThreadValidator.RegistryType.rules); |
|
190 |
} |
|
191 |
rules.add(ruleIdRegistry); |
|
192 |
this.linkRules(ruleIdRegistry, ruleId); |
|
193 |
ruleIdRegistry++; |
|
194 |
} |
|
195 |
|
|
196 |
Job job = new Job(this.jobIdRegistry, 3, rules, pros); |
|
197 |
this.jobIdRegistry++; |
|
198 |
|
|
199 |
newJob.setUser("Workflow Service"); |
|
200 |
newJob.setValidationType("OAI Content"); |
|
201 |
// newJob.setType("OAI Content Validation"); |
|
202 |
newJob.setStatus("working"); |
|
203 |
newJob.setJobType("Workflow Request"); |
|
204 |
// newJob.setRuleset("Workflow Request"); |
|
205 |
//TODO FIX |
|
206 |
newJob.setGuidelines("OpenAIRE For Literature Repositories"); |
|
207 |
newJob.setActivation_id(null); |
|
208 |
newJob.setDuration("--"); |
|
209 |
newJob.setRepo(mdstoreId); |
|
210 |
newJob.setRules(ruleIdsContent); |
|
211 |
newJob.setRecords(pros.getProperty(DnetProvider.RECORDS)); |
|
212 |
newJob.setSet("dnet-workflow"); |
|
213 |
newJob.setGroupBy_xpath(null); |
|
214 |
newJob.setMetadata_prefix(""); |
|
215 |
newJob.setId("-1"); |
|
216 |
|
|
217 |
int jobIdStored = jobSubmittedDao.save(newJob); |
|
218 |
|
|
219 |
ValidatorJobListener listener = createListener(); |
|
220 |
listener.setJobSubmittedId(jobIdStored); |
|
221 |
listener.setJobSubmittedUser("Workflow Service"); |
|
222 |
listener.setRuleLinkingMap(ruleLinkingMap); |
|
223 |
listener.setGroupBy_xpath(null); |
|
224 |
listener.setInternalJobsSum(1); |
|
225 |
|
|
226 |
DnetListener dnetListener = createDnetListener(); |
|
227 |
dnetListener.setJob(bJob); |
|
228 |
dnetListener.setBlackboardHandler(blackboardHandler); |
|
229 |
|
|
230 |
validator.submitJob(job, listener, dnetListener); |
|
231 |
return newJob; |
|
232 |
|
|
233 |
} catch (Exception e) { |
|
234 |
logger.error("Error Submitting content job for workflow", e); |
|
235 |
throw new ValidatorException(e); |
|
236 |
} |
|
237 |
|
|
238 |
} */ |
|
239 |
|
|
240 |
@Override |
|
241 |
public JobSubmitted beginContentJobForWorkflow(String baseUrl, String validationSet, BlackboardJob bJob, BlackboardNotificationHandler<BlackboardServerHandler> blackboardHandler) throws ValidatorException { |
|
242 |
try { |
|
243 |
logger.debug("Submitting content job for workflow"); |
|
244 |
Set<Integer> ruleIdsContent = new HashSet<Integer>(); |
|
245 |
for (RuleSet ruleset : ruleSetDao.getRuleSets()) { |
|
246 |
String regRuleset; |
|
247 |
if (validationSet.equalsIgnoreCase("openaire_data")) { |
|
248 |
regRuleset = "OpenAIRE For Data Archives"; |
|
249 |
} else { |
|
250 |
regRuleset = "OpenAIRE For Literature Repositories"; |
|
251 |
} |
|
252 |
if (ruleset.getName().equals(regRuleset)) { |
|
253 |
ruleIdsContent = Utilities.convertListToSet(ruleset.getRuleIdsContent()); |
|
254 |
} |
|
255 |
} |
|
256 |
|
|
257 |
Properties pros = null; |
|
258 |
pros = new Properties(); |
|
259 |
pros.setProperty(OAIPMHRecordProvider.BASEURL, baseUrl); |
|
260 |
pros.setProperty(OAIPMHRecordProvider.METADATA_PREFIX, "oai_dc"); |
|
261 |
pros.setProperty(OAIPMHRecordProvider.TIMEOUT, "360000"); |
|
262 |
pros.setProperty(OAIPMHRecordProvider.DELAY, "1000"); |
|
263 |
pros.setProperty(OAIPMHRecordProvider.RETRY_DELAY, "60000"); |
|
264 |
pros.setProperty(OAIPMHRecordProvider.RETRY_EFFORTS, "3"); |
|
265 |
// pros.setProperty(OAIPMHRecordProvider.RECORDS, "20"); |
|
266 |
pros.setProperty(OAIPMHRecordProvider.RECORDS, "all"); |
|
267 |
pros.setProperty(OAIPMHRecordProvider.SET, validationSet); |
|
268 |
|
|
269 |
JobSubmitted newJob = new JobSubmitted(); |
|
270 |
|
|
271 |
Set<Integer> rules = new HashSet<Integer>(); |
|
272 |
|
|
273 |
Map<Integer,Integer> ruleLinkingMap = new HashMap<Integer,Integer>(); |
|
274 |
|
|
275 |
for (Integer ruleId : ruleIdsContent) { |
|
276 |
RuleStored tempRule = ruleStoredDao.get(ruleId.toString()); |
|
277 |
|
|
278 |
// special behaviour type of rule is chain |
|
279 |
if (tempRule.getType().equals("ChainRule")) { |
|
280 |
logger.debug("chain rule found"); |
|
281 |
RuleStored tempRuleChain1 = ruleStoredDao.get(tempRule.getConfiguration().getProperty("rule_1")); |
|
282 |
RuleStored tempRuleChain2 = ruleStoredDao.get(tempRule.getConfiguration().getProperty("rule_2")); |
|
283 |
List<Rule> rules_chain = new ArrayList<Rule>(); |
|
284 |
rules_chain.add((Rule) this.getRuleClassInstanceByType(tempRuleChain1.getType(), tempRuleChain1.getConfiguration(), ruleIdRegistry)); |
|
285 |
ruleIdRegistry++; |
|
286 |
rules_chain.add((Rule) this.getRuleClassInstanceByType(tempRuleChain2.getType(), tempRuleChain2.getConfiguration(), ruleIdRegistry)); |
|
287 |
ruleIdRegistry++; |
|
288 |
|
|
289 |
Properties chainPros = new Properties(); |
|
290 |
chainPros.setProperty(ChainRule.TYPE, tempRule.getConfiguration().getProperty(ChainRule.TYPE)); |
|
291 |
ChainRule<Rule> chainRule = new ChainRule<Rule>(chainPros, ruleIdRegistry, rules_chain); |
|
292 |
|
|
293 |
validator.addToRegistry(ruleIdRegistry, chainRule, MemoryThreadValidator.RegistryType.rules); |
|
294 |
} else { |
|
295 |
validator.addToRegistry(ruleIdRegistry, this.getRuleClassInstanceByType(tempRule.getType(), tempRule.getConfiguration(), ruleIdRegistry), MemoryThreadValidator.RegistryType.rules); |
|
296 |
} |
|
297 |
rules.add(ruleIdRegistry); |
|
298 |
// this.linkRules(ruleIdRegistry, ruleId); |
|
299 |
ruleLinkingMap.put(ruleIdRegistry, ruleId); |
|
300 |
ruleIdRegistry++; |
|
301 |
} |
|
302 |
if (pros.getProperty(OAIPMHRecordProvider.SET).equalsIgnoreCase( |
|
303 |
"openaire_data")) |
|
304 |
pros.setProperty(OAIPMHRecordProvider.METADATA_PREFIX, |
|
305 |
"oai_datacite"); |
|
306 |
|
|
307 |
Job job = new Job(this.jobIdRegistry, 1, rules, pros); |
|
308 |
this.jobIdRegistry++; |
|
309 |
|
|
310 |
newJob.setUser("Workflow Service"); |
|
311 |
newJob.setValidationType("OAI Content"); |
|
312 |
// newJob.setType("OAI Content Validation"); |
|
313 |
newJob.setStatus("working"); |
|
314 |
newJob.setJobType("Workflow Request"); |
|
315 |
//TODO FIX |
|
316 |
newJob.setGuidelines("OpenAIRE For Literature Repositories"); |
|
317 |
newJob.setActivation_id(null); |
|
318 |
newJob.setDuration("--"); |
|
319 |
newJob.setRepo(baseUrl); |
|
320 |
newJob.setRules(ruleIdsContent); |
|
321 |
newJob.setRecords(pros.getProperty(OAIPMHRecordProvider.RECORDS)); |
|
322 |
newJob.setSet(pros.getProperty(OAIPMHRecordProvider.SET)); |
|
323 |
newJob.setGroupBy_xpath(null); |
|
324 |
newJob.setMetadata_prefix(pros.getProperty(OAIPMHRecordProvider.METADATA_PREFIX)); |
|
325 |
newJob.setId("-1"); |
|
326 |
int jobIdStored = jobSubmittedDao.save(newJob); |
|
327 |
|
|
328 |
ValidatorJobListener listener = createListener(); |
|
329 |
listener.setJobSubmittedId(jobIdStored); |
|
330 |
listener.setJobSubmittedUser("Workflow Service"); |
|
331 |
listener.setRuleLinkingMap(ruleLinkingMap); |
|
332 |
listener.setGroupBy_xpath(null); |
|
333 |
listener.setInternalJobsSum(1); |
|
334 |
|
|
335 |
DnetListener dnetListener = createDnetListener(); |
|
336 |
dnetListener.setJob(bJob); |
|
337 |
dnetListener.setBlackboardHandler(blackboardHandler); |
|
338 |
|
|
339 |
validator.submitJob(job, 1, listener, dnetListener); |
|
340 |
return newJob; |
|
341 |
|
|
342 |
} catch (Exception e) { |
|
343 |
logger.error("Error Submitting content job for workflow", e); |
|
344 |
throw new ValidatorException(e); |
|
345 |
} |
|
346 |
|
|
347 |
} |
|
348 |
|
|
349 |
@Override |
|
350 |
public JobSubmitted beginUsageJobForWorkflow(String baseUrl, String validationSet, BlackboardJob bJob, BlackboardNotificationHandler<BlackboardServerHandler> blackboardHandler) throws ValidatorException { |
|
351 |
try { |
|
352 |
|
|
353 |
logger.debug("Submitting Usage job(s) for workflow"); |
|
354 |
|
|
355 |
Set<Integer> ruleIdsUsage = new HashSet<Integer>(); |
|
356 |
for (RuleSet ruleset : ruleSetDao.getRuleSets()) { |
|
357 |
String regRuleset; |
|
358 |
if (validationSet.equalsIgnoreCase("openaire_data")) { |
|
359 |
regRuleset = "OpenAIRE For Data Archives"; |
|
360 |
} else { |
|
361 |
regRuleset = "OpenAIRE For Literature Repositories"; |
|
362 |
} |
|
363 |
if (ruleset.getName().equals(regRuleset)) { |
|
364 |
ruleIdsUsage = Utilities.convertListToSet(ruleset |
|
365 |
.getRuleIdsUsage()); |
|
366 |
} |
|
367 |
} |
|
368 |
|
|
369 |
Properties pros = new Properties(); |
|
370 |
pros.setProperty(OAIPMHSinglePageVerbProvider.BASEURL, baseUrl); |
|
371 |
pros.setProperty(OAIPMHSinglePageVerbProvider.TIMEOUT, "360000"); |
|
372 |
pros.setProperty(OAIPMHSinglePageVerbProvider.DELAY, "1000"); |
|
373 |
pros.setProperty(OAIPMHSinglePageVerbProvider.RETRY_DELAY, "60000"); |
|
374 |
pros.setProperty(OAIPMHSinglePageVerbProvider.RETRY_EFFORTS, "3"); |
|
375 |
|
|
376 |
JobSubmitted newJob = new JobSubmitted(); |
|
377 |
|
|
378 |
List<RuleStored> rulesStored = new ArrayList<RuleStored>(); |
|
379 |
for (Integer id : ruleIdsUsage) { |
|
380 |
logger.debug("Rule with id: " + id + " added"); |
|
381 |
rulesStored.add(ruleStoredDao.get(id.toString())); |
|
382 |
} |
|
383 |
|
|
384 |
logger.debug("Creating map for provider information"); |
|
385 |
Map<String, Set<Integer>> verbRuleMap = new HashMap<String, Set<Integer>>(); |
|
386 |
Set<Integer> old, temp = null; |
|
387 |
for (RuleStored ruleStored : rulesStored) { |
|
388 |
logger.debug("Checking for verb : " + ruleStored.getProvider_information()); |
|
389 |
if ((old = verbRuleMap.get(ruleStored.getProvider_information())) == null) { |
|
390 |
logger.debug("Verb doesn't exist"); |
|
391 |
temp = new HashSet<Integer>(); |
|
392 |
temp.add(Integer.parseInt(ruleStored.getId())); |
|
393 |
verbRuleMap.put(ruleStored.getProvider_information(), temp); |
|
394 |
} else { |
|
395 |
logger.debug("Verb exists"); |
|
396 |
old.add(Integer.parseInt(ruleStored.getId())); |
|
397 |
} |
|
398 |
} |
|
399 |
|
|
400 |
Set<Integer> rules = null; |
|
401 |
|
|
402 |
Job job = null; |
|
403 |
newJob.setUser("Workflow Service"); |
|
404 |
newJob.setValidationType("OAI Usage"); |
|
405 |
newJob.setStatus("working"); |
|
406 |
newJob.setJobType("Workflow Request"); |
|
407 |
// newJob.setRuleset("Workflow Request"); |
|
408 |
//TODO FIX |
|
409 |
newJob.setGuidelines("OpenAIRE For Literature Repositories"); |
|
410 |
newJob.setActivation_id(null); |
|
411 |
newJob.setDuration("--"); |
|
412 |
newJob.setRepo(pros.getProperty(OAIPMHSinglePageVerbProvider.BASEURL)); |
|
413 |
newJob.setRules(ruleIdsUsage); |
|
414 |
newJob.setMetadata_prefix(pros.getProperty(OAIPMHRecordProvider.METADATA_PREFIX)); |
|
415 |
newJob.setId("-1"); |
|
416 |
|
|
417 |
int jobIdStored = jobSubmittedDao.save(newJob); |
|
418 |
|
|
419 |
Map<Integer,Integer> ruleLinkingMap = new HashMap<Integer,Integer>(); |
|
420 |
|
|
421 |
ValidatorJobListener listener = createListener(); |
|
422 |
listener.setJobSubmittedId(jobIdStored); |
|
423 |
listener.setJobSubmittedUser("Workflow Service"); |
|
424 |
listener.setRuleLinkingMap(ruleLinkingMap); |
|
425 |
|
|
426 |
listener.setInternalJobsSum(verbRuleMap.size()); |
|
427 |
for (Map.Entry<String, Set<Integer>> entry : verbRuleMap.entrySet()) { |
|
428 |
pros.remove(OAIPMHSinglePageVerbProvider.VERB); |
|
429 |
pros.setProperty(OAIPMHSinglePageVerbProvider.VERB, |
|
430 |
entry.getKey()); |
|
431 |
rules = new HashSet<Integer>(); |
|
432 |
for (Integer ruleId : entry.getValue()) { |
|
433 |
RuleStored tempRule = ruleStoredDao.get(Integer |
|
434 |
.toString(ruleId)); |
|
435 |
logger.debug("prepare to add rule to registry with regexp: " + tempRule.getConfiguration().getProperty("regexp") + " and ruleIdregistry: " + ruleIdRegistry); |
|
436 |
validator.addToRegistry(ruleIdRegistry, this.getRuleClassInstanceByType(tempRule.getType(), tempRule.getConfiguration(), ruleIdRegistry), MemoryThreadValidator.RegistryType.rules); |
|
437 |
rules.add(ruleIdRegistry); |
|
438 |
// this.linkRules(ruleIdRegistry, ruleId); |
|
439 |
ruleLinkingMap.put(ruleIdRegistry, ruleId); |
|
440 |
ruleIdRegistry++; |
|
441 |
} |
|
442 |
|
|
443 |
job = new Job(this.jobIdRegistry, 2, rules, pros); |
|
444 |
|
|
445 |
DnetListener dnetListener = createDnetListener(); |
|
446 |
dnetListener.setJob(bJob); |
|
447 |
dnetListener.setBlackboardHandler(blackboardHandler); |
|
448 |
|
|
449 |
validator.submitJob(job, 1, listener, dnetListener); |
|
450 |
|
|
451 |
this.jobIdRegistry++; |
|
452 |
} |
|
453 |
return newJob; |
|
454 |
} catch (Exception e) { |
|
455 |
logger.error("Error Submitting usage job(s)", e); |
|
456 |
throw new ValidatorException(e); |
|
457 |
} |
|
458 |
|
|
459 |
} |
|
460 |
|
|
461 |
private Serializable getRuleClassInstanceByType(String type, |
|
462 |
Properties pros, int id) throws ValidatorException { |
|
463 |
logger.debug("getting rule object of type " + type); |
|
464 |
String classname = RuleTypes.getClassOfType(type); |
|
465 |
if (classname == null) { |
|
466 |
logger.debug("error getting rule object of type " + type |
|
467 |
+ " classname=null"); |
|
468 |
return null; |
|
469 |
} else { |
|
470 |
try { |
|
471 |
Class<?> clazz = Class.forName(classname); |
|
472 |
logger.debug("classname: " + clazz.getName()); |
|
473 |
return (Serializable) clazz.getConstructor( |
|
474 |
new Class[] { Properties.class, Integer.TYPE }) |
|
475 |
.newInstance(pros, id); |
|
476 |
|
|
477 |
} catch (ClassNotFoundException e) { |
|
478 |
logger.debug("error getting rule object: " + e); |
|
479 |
return null; |
|
480 |
} catch (NoSuchMethodException e) { |
|
481 |
logger.debug("error getting rule object: " + e); |
|
482 |
return null; |
|
483 |
} catch (InvocationTargetException e) { |
|
484 |
logger.debug("error getting rule object: " + e); |
|
485 |
return null; |
|
486 |
} catch (InstantiationException e) { |
|
487 |
logger.debug("error getting rule object: " + e); |
|
488 |
return null; |
|
489 |
} catch (IllegalAccessException e) { |
|
490 |
logger.debug("error getting rule object: " + e); |
|
491 |
return null; |
|
492 |
} |
|
493 |
} |
|
494 |
|
|
495 |
} |
|
496 |
|
|
497 |
private ChainRule<Rule> handleChain(RuleStored tempRule) throws Exception { |
|
498 |
logger.debug("chain rule found"); |
|
499 |
List<Rule> rules_chain = new ArrayList<Rule>(); |
|
500 |
RuleStored tempRuleChain1=ruleStoredDao.get(tempRule.getConfiguration().getProperty("rule_1")); |
|
501 |
if(tempRuleChain1.getType().equals("ChainRule")) { |
|
502 |
ChainRule<Rule> chainRule1 = this.handleChain(tempRuleChain1); |
|
503 |
rules_chain.add(chainRule1); |
|
504 |
ruleIdRegistry++; |
|
505 |
} else { |
|
506 |
rules_chain.add((Rule) this.getRuleClassInstanceByType(tempRuleChain1.getType(), tempRuleChain1.getConfiguration(), ruleIdRegistry)); |
|
507 |
ruleIdRegistry++; |
|
508 |
} |
|
509 |
RuleStored tempRuleChain2=ruleStoredDao.get(tempRule.getConfiguration().getProperty("rule_2")); |
|
510 |
if(tempRuleChain2.getType().equals("ChainRule")) { |
|
511 |
ChainRule<Rule> chainRule2 = this.handleChain(tempRuleChain2); |
|
512 |
rules_chain.add(chainRule2); |
|
513 |
ruleIdRegistry++; |
|
514 |
} else { |
|
515 |
rules_chain.add((Rule) this.getRuleClassInstanceByType(tempRuleChain2.getType(), tempRuleChain2.getConfiguration(), ruleIdRegistry)); |
|
516 |
ruleIdRegistry++; |
|
517 |
} |
|
518 |
Properties chainPros = new Properties(); |
|
519 |
chainPros.setProperty(ChainRule.TYPE,tempRule.getConfiguration().getProperty(ChainRule.TYPE)); |
|
520 |
ChainRule<Rule> chainRule = new ChainRule<Rule>(chainPros, ruleIdRegistry, rules_chain); |
|
521 |
return chainRule; |
|
522 |
} |
|
523 |
|
|
524 |
// private void linkRules(int ruleRegistry, int ruleStored) { |
|
525 |
// this.ruleLinkingMap.put(ruleRegistry, ruleStored); |
|
526 |
// } |
|
527 |
// |
|
528 |
// private int getRuleFromLink(int ruleRegistry) { |
|
529 |
// return this.ruleLinkingMap.get(ruleRegistry); |
|
530 |
// } |
|
531 |
|
|
532 |
public Validator getValidator() { |
|
533 |
return validator; |
|
534 |
} |
|
535 |
public void setValidator(Validator validator) { |
|
536 |
this.validator = validator; |
|
537 |
} |
|
538 |
public JobSubmittedDAO getJobSubmittedDao() { |
|
539 |
return jobSubmittedDao; |
|
540 |
} |
|
541 |
public void setJobSubmittedDao(JobSubmittedDAO jobSubmittedDao) { |
|
542 |
this.jobSubmittedDao = jobSubmittedDao; |
|
543 |
} |
|
544 |
public RuleSetDAO getRuleSetDao() { |
|
545 |
return ruleSetDao; |
|
546 |
} |
|
547 |
public void setRuleSetDao(RuleSetDAO ruleSetDao) { |
|
548 |
this.ruleSetDao = ruleSetDao; |
|
549 |
} |
|
550 |
public RuleStoredDAO getRuleStoredDao() { |
|
551 |
return ruleStoredDao; |
|
552 |
} |
|
553 |
public void setRuleStoredDao(RuleStoredDAO ruleStoredDao) { |
|
554 |
this.ruleStoredDao = ruleStoredDao; |
|
555 |
} |
|
556 |
// public Map<Integer, Integer> getRuleLinkingMap() { |
|
557 |
// return ruleLinkingMap; |
|
558 |
// } |
|
559 |
// public void setRuleLinkingMap(Map<Integer, Integer> ruleLinkingMap) { |
|
560 |
// this.ruleLinkingMap = ruleLinkingMap; |
|
561 |
// } |
|
562 |
} |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/java/gr/uoa/di/validator/service/DnetProvider.java | ||
---|---|---|
1 |
package gr.uoa.di.validator.service; |
|
2 |
|
|
3 |
import eu.dnetlib.api.data.MDStoreService; |
|
4 |
import eu.dnetlib.domain.EPR; |
|
5 |
import gr.uoa.di.driver.enabling.resultset.ResultSetFactory; |
|
6 |
import gr.uoa.di.driver.util.ServiceLocator; |
|
7 |
import gr.uoa.di.validator.data.DataException; |
|
8 |
import gr.uoa.di.validator.data.Provider; |
|
9 |
import gr.uoa.di.validator.data.ResultSet; |
|
10 |
import gr.uoa.di.validator.execution.ValidationObject; |
|
11 |
import gr.uoa.di.validator.impls.valobjs.XMLTextValidationObject; |
|
12 |
|
|
13 |
import java.io.StringReader; |
|
14 |
import java.util.ArrayList; |
|
15 |
import java.util.List; |
|
16 |
|
|
17 |
import javax.xml.parsers.DocumentBuilder; |
|
18 |
import javax.xml.parsers.DocumentBuilderFactory; |
|
19 |
import javax.xml.parsers.ParserConfigurationException; |
|
20 |
import javax.xml.xpath.XPath; |
|
21 |
import javax.xml.xpath.XPathConstants; |
|
22 |
import javax.xml.xpath.XPathExpression; |
|
23 |
import javax.xml.xpath.XPathExpressionException; |
|
24 |
import javax.xml.xpath.XPathFactory; |
|
25 |
|
|
26 |
import org.w3c.dom.Document; |
|
27 |
import org.w3c.dom.Element; |
|
28 |
import org.w3c.dom.Node; |
|
29 |
import org.w3c.dom.ls.DOMImplementationLS; |
|
30 |
import org.w3c.dom.ls.LSSerializer; |
|
31 |
import org.xml.sax.InputSource; |
|
32 |
|
|
33 |
public class DnetProvider extends Provider{ |
|
34 |
|
|
35 |
private static final long serialVersionUID = -4280319954962194170L; |
|
36 |
|
|
37 |
private static ServiceLocator<MDStoreService> mdStoreServiceServiceLocator; |
|
38 |
|
|
39 |
private static ResultSetFactory rsFactory = null; |
|
40 |
|
|
41 |
public static final String DATASOURCE = "DATASOURCE"; |
|
42 |
|
|
43 |
public static final String BATCH_SIZE = "BATCH_SIZE"; |
|
44 |
|
|
45 |
public static final String RECORDS = "RECORDS"; |
|
46 |
|
|
47 |
public static final String MDSTORE_ID = "MDSTORE_ID"; |
|
48 |
|
|
49 |
public static final String FROM = "FROM"; |
|
50 |
|
|
51 |
public static final String BEGIN_RECORD = "BEGIN_RECORD"; |
|
52 |
|
|
53 |
public static final String UNTIL = "UNTIL"; |
|
54 |
|
|
55 |
public static final String RECORD_FILTER = "RECORD_FILTER"; |
|
56 |
|
|
57 |
public static final String WORKER_ID = "WORKER_ID"; |
|
58 |
|
|
59 |
public static final String WORKERS = "WORKERS"; |
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
public DnetProvider(Integer id) { |
|
64 |
super(id); |
|
65 |
|
|
66 |
} |
|
67 |
|
|
68 |
@Override |
|
69 |
public ResultSet<ValidationObject> getValidationObjects() throws ProviderException { |
|
70 |
return new DnetRecordResultSet(); |
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
74 |
public ResultSet<String> getValidationObjectIds() throws ProviderException, |
|
75 |
UnsupportedOperationException { |
|
76 |
// TODO Auto-generated method stub |
|
77 |
return null; |
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
81 |
public ValidationObject getValidationObject(String valObjId) |
|
82 |
throws ProviderException, UnsupportedOperationException { |
|
83 |
// TODO Auto-generated method stub |
|
84 |
return null; |
|
85 |
} |
|
86 |
|
|
87 |
public static void printXmlDocument(Document document) { |
|
88 |
DOMImplementationLS domImplementationLS = |
|
89 |
(DOMImplementationLS) document.getImplementation(); |
|
90 |
LSSerializer lsSerializer = |
|
91 |
domImplementationLS.createLSSerializer(); |
|
92 |
String string = lsSerializer.writeToString(document); |
|
93 |
System.out.println(string); |
|
94 |
} |
|
95 |
|
|
96 |
private class DnetResultSet { |
|
97 |
|
|
98 |
gr.uoa.di.driver.enabling.resultset.ResultSet<String> rs = null; |
|
99 |
|
|
100 |
protected DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
|
101 |
protected DocumentBuilder builder; |
|
102 |
protected XPathFactory xfactory = XPathFactory.newInstance(); |
|
103 |
protected List<Node> records = null; |
|
104 |
protected int records_sum = 0; |
|
105 |
protected int index = -1; |
|
106 |
protected int pointer = 0; |
|
107 |
protected int recordsNum = 0; |
|
108 |
protected int workers = 0; |
|
109 |
protected int workerId = 0; |
|
110 |
protected int beginRecord = 0; |
|
111 |
protected int endRecord = 0; |
|
112 |
protected String error = null; |
|
113 |
|
|
114 |
public DnetResultSet() { |
|
115 |
|
|
116 |
try { |
|
117 |
builder = factory.newDocumentBuilder(); |
|
118 |
log.debug("Retrieving the datasource.."); |
|
119 |
|
|
120 |
log.debug("RECORDS " + pros.getProperty(RECORDS)); |
|
121 |
log.debug("MDSTORE_ID " + pros.getProperty(MDSTORE_ID)); |
|
122 |
log.debug("DATASOURCE: " + pros.getProperty(DATASOURCE)); |
|
123 |
log.debug("WORKER_ID: " + pros.getProperty(WORKER_ID)); |
|
124 |
workerId = Integer.parseInt(pros.getProperty(WORKER_ID)); |
|
125 |
workers = Integer.parseInt(pros.getProperty(WORKERS)); |
|
126 |
// log.debug("BEGIN RECORD: " + pros.getProperty(BEGIN_RECORD)); |
|
127 |
// EPR epr = mdStoreServiceServiceLocator.getService().deliverMDRecords(pros.getProperty(MD_ID), pros.getProperty(FROM), pros.getProperty(UNTIL), pros.getProperty(RECORD_FILTER)); |
|
128 |
log.debug("Issuing request on mdstore: " + pros.getProperty(MDSTORE_ID)); |
|
129 |
EPR epr = mdStoreServiceServiceLocator.getService().deliverMDRecords(pros.getProperty(MDSTORE_ID), null, null, null); |
|
130 |
|
|
131 |
rs = rsFactory.createResultSet(epr); |
|
132 |
|
|
133 |
log.debug("rs created"); |
|
134 |
records_sum = rs.size(); |
|
135 |
log.debug("Number of records in ResultSet: " + records_sum); |
|
136 |
if (pros.getProperty(RECORDS).equalsIgnoreCase("all") ) { |
|
137 |
pros.setProperty(RECORDS,Integer.toString(records_sum)); |
|
138 |
} else if (Integer.parseInt(pros.getProperty(RECORDS)) > records_sum) { |
|
139 |
pros.setProperty(RECORDS,Integer.toString(records_sum)); |
|
140 |
} |
|
141 |
recordsNum = Integer.parseInt(pros.getProperty(RECORDS)); |
|
142 |
log.error("W"+ workerId + "# RECORDS TO TEST: " + recordsNum); |
|
143 |
log.error("W"+ workerId + "# WORKERS: " + workers); |
|
144 |
// pros.setProperty(DnetProvider.BEGIN_RECORD, Integer.toString(Integer.parseInt(pros.getProperty(WORKER_ID)) * (Integer.parseInt(pros.getProperty(RECORDS))/Integer.parseInt(pros.getProperty(WORKERS))))); |
|
145 |
beginRecord = workerId * (recordsNum/workers); |
|
146 |
endRecord = (recordsNum/workers) + beginRecord; |
|
147 |
// endRecord = Integer.parseInt(pros.getProperty(RECORDS))/Integer.parseInt(pros.getProperty(WORKERS)) + Integer.parseInt(pros.getProperty(BEGIN_RECORD)); |
|
148 |
if (workerId == workers-1) |
|
149 |
endRecord += recordsNum % workers; |
|
150 |
log.error("W"+ workerId + "# BEGIN RECORD: " + beginRecord); |
|
151 |
log.error("W"+ workerId + "# END RECORD: " + endRecord); |
|
152 |
pointer = beginRecord; |
|
153 |
} catch (ParserConfigurationException e) { |
|
154 |
log.error("", e); |
|
155 |
} catch (Exception e) { |
|
156 |
log.error("", e); |
|
157 |
} |
|
158 |
} |
|
159 |
|
|
160 |
protected List<Node> getRecords() throws DataException { |
|
161 |
List<Node> records = new ArrayList<Node>(); |
|
162 |
|
|
163 |
try { |
|
164 |
int to = pointer + Integer.parseInt(pros.getProperty(BATCH_SIZE)) -1 ; |
|
165 |
log.error("to : " + to + " and limit: " + endRecord); |
|
166 |
if (to < endRecord) { |
|
167 |
log.error("Issuing request for records. From : " + pointer + " to : " + to); |
|
168 |
List<String> tempRecords = rs.get(pointer, to); |
|
169 |
pointer += Integer.parseInt(pros.getProperty(BATCH_SIZE)); |
|
170 |
for (String record : tempRecords) { |
|
171 |
// log.debug("record from resultSet is : " + record); |
|
172 |
InputSource is = new InputSource(new StringReader(record)); |
|
173 |
Document doc = builder.parse(is); |
|
174 |
XPath xpath = xfactory.newXPath(); |
|
175 |
XPathExpression expr = xpath.compile("//*[local-name()='record']"); |
|
176 |
records.add((Node) expr.evaluate(doc, XPathConstants.NODE)); |
|
177 |
} |
|
178 |
} |
|
179 |
if (records.size() == 0) { |
|
180 |
log.debug("There are no records. "); |
|
181 |
error = "There are no records"; |
|
182 |
log.debug("Error: "+ error); |
|
183 |
} |
|
184 |
|
|
185 |
} catch (Exception e) { |
|
186 |
log.error("", e); |
|
187 |
throw new DataException(); |
|
188 |
} |
|
189 |
return records; |
|
190 |
} |
|
191 |
} |
|
192 |
|
|
193 |
private class DnetRecordResultSet extends DnetResultSet implements ResultSet<ValidationObject> { |
|
194 |
|
|
195 |
@Override |
|
196 |
public String getError() { |
|
197 |
if (error != null) |
|
198 |
log.debug("An error occured "+ this.error); |
|
199 |
else |
|
200 |
log.debug("No errors on request"); |
|
201 |
return this.error; |
|
202 |
} |
|
203 |
|
|
204 |
@Override |
|
205 |
public boolean next() throws DataException { |
|
206 |
index++; |
|
207 |
log.debug("Moving cursor to result "+index); |
|
208 |
if (records == null || index >= records.size()) { |
|
209 |
if (records != null && (records.size() == 0)) |
|
210 |
return false; |
|
211 |
index = -1; |
|
212 |
records = getRecords(); |
|
213 |
return next(); |
|
214 |
} |
|
215 |
return true; |
|
216 |
} |
|
217 |
|
|
218 |
@Override |
|
219 |
public ValidationObject get() throws DataException { |
|
220 |
XMLTextValidationObject ret = null; |
|
221 |
|
|
222 |
Document newXmlDocument; |
|
223 |
try { |
|
224 |
newXmlDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); |
|
225 |
|
|
226 |
Element root = newXmlDocument.createElement("root"); |
|
227 |
newXmlDocument.appendChild(root); |
|
228 |
Node node = records.get(index); |
|
229 |
Node copyNode = newXmlDocument.importNode(node, true); |
|
230 |
root.appendChild(copyNode); |
|
231 |
printXmlDocument(newXmlDocument); |
|
232 |
ret = new XMLTextValidationObject(newXmlDocument); |
|
233 |
XPathFactory factory = XPathFactory.newInstance(); |
|
234 |
XPath xPath = factory.newXPath(); |
|
235 |
ret.setId(xPath.evaluate("//*[local-name()='header']/*[name()='dri:recordIdentifier']/text()", records.get(index))); |
|
236 |
ret.setStatus(xPath.evaluate("//*[local-name()='header']/@status", records.get(index))); |
|
237 |
log.debug("record id: " + ret.getId()); |
|
238 |
log.debug("record status: " + ret.getStatus()); |
|
239 |
|
|
240 |
} catch (ParserConfigurationException e) { |
|
241 |
log.error("error getting object"+ e); |
|
242 |
} catch (XPathExpressionException e) { |
|
243 |
log.error("error getting object"+ e); |
|
244 |
} |
|
245 |
return ret; |
|
246 |
} |
|
247 |
|
|
248 |
|
|
249 |
} |
|
250 |
|
|
251 |
|
|
252 |
public static ResultSetFactory getRsFactory() { |
|
253 |
return rsFactory; |
|
254 |
} |
|
255 |
|
|
256 |
public static void setRsFactory(ResultSetFactory rsFactory) { |
|
257 |
DnetProvider.rsFactory = rsFactory; |
|
258 |
} |
|
259 |
|
|
260 |
public static ServiceLocator<MDStoreService> getMdStoreServiceServiceLocator() { |
|
261 |
return mdStoreServiceServiceLocator; |
|
262 |
} |
|
263 |
|
|
264 |
public static void setMdStoreServiceServiceLocator(ServiceLocator<MDStoreService> mdStoreServiceServiceLocator) { |
|
265 |
DnetProvider.mdStoreServiceServiceLocator = mdStoreServiceServiceLocator; |
|
266 |
} |
|
267 |
} |
modules/uoa-validator/tags/uoa-validator-1.0.1/src/main/java/gr/uoa/di/validator/service/ValidatorServiceImpl.java | ||
---|---|---|
1 |
package gr.uoa.di.validator.service; |
|
2 |
|
|
3 |
import eu.dnetlib.api.functionality.ValidatorService; |
|
4 |
import eu.dnetlib.domain.ActionType; |
|
5 |
import eu.dnetlib.domain.EPR; |
|
6 |
import eu.dnetlib.domain.ResourceType; |
|
7 |
import eu.dnetlib.domain.enabling.Notification; |
|
8 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardNotificationHandler; |
|
9 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler; |
|
10 |
import gr.uoa.di.driver.app.DriverServiceImpl; |
|
11 |
import gr.uoa.di.driver.enabling.issn.NotificationListener; |
|
12 |
|
|
13 |
import org.apache.log4j.Logger; |
|
14 |
|
|
15 |
public class ValidatorServiceImpl extends DriverServiceImpl implements |
|
16 |
ValidatorService { |
|
17 |
|
|
18 |
private BlackboardNotificationHandler<BlackboardServerHandler> blackboardNotificationHandler = null; |
|
19 |
private Logger logger = Logger.getLogger(ValidatorServiceImpl.class); |
|
20 |
|
|
21 |
|
|
22 |
// do NOT call directly. It will be called by the |
|
23 |
// InitializingServiceRegistrationManager |
|
24 |
// after it sets the service EPR and id. |
|
25 |
@Override |
|
26 |
public void init() { |
|
27 |
super.init(); |
|
28 |
this.subscribe(ActionType.UPDATE, |
|
29 |
ResourceType.VALIDATORSERVICERESOURCETYPE, this |
|
30 |
.getServiceEPR().getParameter("serviceId"), |
|
31 |
"RESOURCE_PROFILE/BODY/BLACKBOARD/LAST_REQUEST", |
|
32 |
new NotificationListener() { |
|
33 |
@Override |
|
34 |
public void processNotification(Notification notification) { |
|
35 |
blackboardNotificationHandler.notified( |
|
36 |
notification.getSubscriptionId(), |
|
37 |
notification.getTopic(), |
|
38 |
notification.getIsId(), |
Also available in: Unified diff
deleted release 1.0.1