Revision 34342
Added by Nikon Gasparis over 9 years ago
OAIPMHEmbargoDateRule.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.service.impls.rules.oaipmh; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
import java.util.Properties; |
|
6 |
|
|
7 |
import eu.dnetlib.validator.engine.data.Rule; |
|
8 |
import eu.dnetlib.validator.engine.data.RuleException; |
|
9 |
import eu.dnetlib.validator.engine.execution.ValidationObject; |
|
10 |
import eu.dnetlib.validator.service.impls.providers.OAIPMHRecordProvider; |
|
11 |
import eu.dnetlib.validator.service.impls.rules.ChainRule; |
|
12 |
import eu.dnetlib.validator.service.impls.rules.xml.XMLRegularExpressionRule; |
|
13 |
import eu.dnetlib.validator.service.impls.rules.xml.XMLVocabularyRule; |
|
14 |
|
|
15 |
/** |
|
16 |
* <p> |
|
17 |
* Checks if an oai_dc record handles embargo dates as specified by the OpenAIRE |
|
18 |
* Guidelines. |
|
19 |
* </p> |
|
20 |
* <p> |
|
21 |
* The Validation Object given to |
|
22 |
* {@link OAIPMHEmbargoDateRule#apply(ValidationObject)} must be an oai_dc |
|
23 |
* record retrieved by an {@link OAIPMHRecordProvider}. |
|
24 |
* </p> |
|
25 |
* |
|
26 |
* @author Manos Karvounis |
|
27 |
* |
|
28 |
*/ |
|
29 |
public class OAIPMHEmbargoDateRule extends Rule { |
|
30 |
|
|
31 |
public OAIPMHEmbargoDateRule(Properties pros, int id) { |
|
32 |
super(pros, id); |
|
33 |
} |
|
34 |
|
|
35 |
private static final long serialVersionUID = 770275867973085409L; |
|
36 |
|
|
37 |
|
|
38 |
@Override |
|
39 |
public boolean apply(ValidationObject obj) throws RuleException { |
|
40 |
Properties pros1 = new Properties(); |
|
41 |
pros1.setProperty(XMLVocabularyRule.XPATH, "/OAI-PMH/GetRecord/record/metadata//*[name()='dc:rights']/text()"); |
|
42 |
pros1.setProperty(XMLVocabularyRule.TERMS, "info:eu-repo/semantics/embargoedAccess"); |
|
43 |
pros1.setProperty(XMLVocabularyRule.SUCCESS, ">0"); |
|
44 |
XMLVocabularyRule rights = new XMLVocabularyRule(pros1, 1); |
|
45 |
|
|
46 |
Properties pros2 = new Properties(); |
|
47 |
pros2.setProperty(XMLRegularExpressionRule.REGEXP, "info:eu-repo/date/embargoEnd/[0123456789]{4}-[01][0123456789]-[0123][0123456789]"); |
|
48 |
pros2.setProperty(XMLRegularExpressionRule.XPATH, "/OAI-PMH/GetRecord/record/metadata//*[name()='dc:date']/text()"); |
|
49 |
pros2.setProperty(XMLRegularExpressionRule.SUCCESS, ">0"); |
|
50 |
XMLRegularExpressionRule date = new XMLRegularExpressionRule(pros2, 2); |
|
51 |
|
|
52 |
List<Rule> rules = new ArrayList<Rule>(); |
|
53 |
rules.add(rights); |
|
54 |
rules.add(date); |
|
55 |
|
|
56 |
Properties pros3 = new Properties(); |
|
57 |
pros3.setProperty(ChainRule.TYPE, "horn"); |
|
58 |
ChainRule<Rule> chain = new ChainRule<Rule>(pros3, 3, rules); |
|
59 |
|
|
60 |
return chain.apply(obj); |
|
61 |
} |
|
62 |
|
|
63 |
} |
|
0 | 64 |
Also available in: Unified diff
*new version of validator service
*it now includes the validator implementation(replaces uoa-validator)
*registry for jobs,rules and providers is now removed.
*supports and implements the new ValidatorService interface
*new way to submit a new job (a common method is used for tests,registrations,or cris)
*content and usage jobs are now merged to one.
*listeners updated to support job merging
*works as standalone or with IS (BETA)