Project

General

Profile

« Previous | Next » 

Revision 34342

Added by Nikon Gasparis over 9 years ago

*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)

View differences:

XMLCardinalityRule.java
1
package eu.dnetlib.validator.service.impls.rules.xml;
2

  
3
import java.util.Properties;
4

  
5
import org.w3c.dom.NodeList;
6

  
7
import eu.dnetlib.validator.engine.data.DataException;
8
import eu.dnetlib.validator.engine.data.RuleException;
9
import eu.dnetlib.validator.engine.execution.ValidationObject;
10
import eu.dnetlib.validator.service.impls.rules.CardinalityRule;
11
import eu.dnetlib.validator.service.impls.valobjs.XMLTextValidationObject;
12

  
13
public class XMLCardinalityRule extends CardinalityRule implements XMLRule {
14

  
15
	private static final long serialVersionUID = -3293960407395273309L;
16

  
17
	public XMLCardinalityRule(Properties pros, int id) {
18
		super(pros, id);
19
	}
20

  
21
	@Override
22
	public boolean apply(ValidationObject obj) throws RuleException {
23
		XMLTextValidationObject tobj = (XMLTextValidationObject) obj;
24
		NodeList nodes;
25
		try {
26
			nodes = tobj.getNodes(this.pros.getProperty(XPATH));
27
		} catch (DataException e) {
28
			log.error("", e);
29
			return false;
30
		}
31
		
32
		int number = nodes.getLength();
33
		
34
		log.debug("XML Cardinality Rule. Count: "+number);
35
		
36
		if (number < Integer.parseInt(pros.getProperty(LESS_THAN)) && number > Integer.parseInt(pros.getProperty(GREATER_THAN)))
37
			return true;
38
		else
39
			return false;
40
	}
41

  
42
}
0 43

  

Also available in: Unified diff