Revision 34342
Added by Nikon Gasparis over 9 years ago
XMLRule.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.service.impls.rules.xml; |
|
2 |
|
|
3 |
import org.apache.log4j.Logger; |
|
4 |
|
|
5 |
import eu.dnetlib.validator.service.impls.valobjs.XMLTextValidationObject; |
|
6 |
|
|
7 |
/** |
|
8 |
* Indicates that a rule is applied on xml text objects. |
|
9 |
* @author Manos Karvounis |
|
10 |
* @author Nikon Gasparis |
|
11 |
* @see XMLTextValidationObject |
|
12 |
*/ |
|
13 |
public interface XMLRule { |
|
14 |
|
|
15 |
/** |
|
16 |
* The xpath that will be used to retrieve specific nodes on which the rule will be applied. |
|
17 |
*/ |
|
18 |
public static final String XPATH = "xpath"; |
|
19 |
// 'all', '>0', '0' |
|
20 |
/** |
|
21 |
* Accepted values: |
|
22 |
* 'all': The rule is successful if all the nodes retrieved by the XPATH have the rule applied successfully on them |
|
23 |
* '>0': If at least one of the nodes is successful |
|
24 |
* '0': If none of the nodes is successful |
|
25 |
* '1': If total nodes number is 1 and that node succeeds |
|
26 |
*/ |
|
27 |
public static final String SUCCESS = "success"; |
|
28 |
|
|
29 |
public class Utils { |
|
30 |
public static boolean success(String condition, int successes, int all) { |
|
31 |
Logger log = Logger.getLogger(Utils.class); |
|
32 |
log.debug("condition: "+condition+", "+"successes: "+successes+" all: "+all); |
|
33 |
if(condition.equals("all")) { |
|
34 |
return (successes == all && all != 0); |
|
35 |
} else if(condition.equals(">0")) { |
|
36 |
return successes > 0; |
|
37 |
} else if(condition.equals("0")) { |
|
38 |
return successes == 0; |
|
39 |
} else if(condition.equals("1")) { |
|
40 |
return (successes == 1 && all == 1); |
|
41 |
} else |
|
42 |
return false; |
|
43 |
} |
|
44 |
} |
|
45 |
} |
|
0 | 46 |
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)