Project

General

Profile

1
package eu.dnetlib.validator.service.impls.rules;
2

    
3
import java.util.HashMap;
4

    
5
import org.apache.log4j.Logger;
6

    
7
import eu.dnetlib.validator.service.impls.rules.oaipmh.OAIPMHDateGranularityRule;
8
import eu.dnetlib.validator.service.impls.rules.oaipmh.OAIPMHEmbargoDateRule;
9
import eu.dnetlib.validator.service.impls.rules.oaipmh.OAIPMHIncrementalRecordDeliveryRule;
10
import eu.dnetlib.validator.service.impls.rules.oaipmh.OAIPMHResumptionTokenDurationRule;
11
import eu.dnetlib.validator.service.impls.rules.xml.XMLCardinalityRule;
12
import eu.dnetlib.validator.service.impls.rules.xml.XMLCrisClassVocabularyRule;
13
import eu.dnetlib.validator.service.impls.rules.xml.XMLCrisReferentialIntegrityRule;
14
import eu.dnetlib.validator.service.impls.rules.xml.XMLFieldExistsRule;
15
import eu.dnetlib.validator.service.impls.rules.xml.XMLNotConfusedFieldsRule;
16
import eu.dnetlib.validator.service.impls.rules.xml.XMLRegularExpressionRule;
17
import eu.dnetlib.validator.service.impls.rules.xml.XMLValidURL;
18
import eu.dnetlib.validator.service.impls.rules.xml.XMLVocabularyRule;
19

    
20

    
21
public class RuleTypes {
22
	
23
	static private Logger logger = Logger.getLogger(RuleTypes.class);
24

    
25
	static private HashMap<String, String> types;
26
	static private HashMap<String, String> entities;
27
	
28
	static {
29
		logger.debug("initializing the RuleTypes map");
30
		types = new HashMap<String, String>();
31
		//rules
32
//		types.put("Cardinality", CardinalityRule.class.getName());
33
		types.put("ChainRule", ChainRule.class.getName());
34
//		types.put("Regular Expression", RegularExpressionRule.class.getName());
35
//		types.put("Valid Url", ValidUrlRule.class.getName());
36
//		types.put("Vocabulary", VocabularyRule.class.getName());
37
		//rules OAIPMH
38
		types.put("OAIPMH Incremental Record Delivery", OAIPMHIncrementalRecordDeliveryRule.class.getName());
39
		types.put("OAIPMH Date Granularity", OAIPMHDateGranularityRule.class.getName());
40
		types.put("OAIPMH Resumption Token Duration Check", OAIPMHResumptionTokenDurationRule.class.getName());
41
		types.put("OAIPMH Embargo Date Check", OAIPMHEmbargoDateRule.class.getName());
42
		//rules TEXT
43
//		types.put("TEXT Regular Expression", TextRegularExpressionRule.class.getName());
44
//		types.put("TEXT", TextRule.class.getName());
45
//		types.put("TEXT Vocabulary", TextVocabularyRule.class.getName());		
46
		//rules XML
47
		types.put("XML Cardinality", XMLCardinalityRule.class.getName());
48
		types.put("XML Field Exists", XMLFieldExistsRule.class.getName());
49
		types.put("XML Not Confused Fields", XMLNotConfusedFieldsRule.class.getName());
50
		types.put("XML Regular Expression", XMLRegularExpressionRule.class.getName());
51
//		types.put("XML", XMLRule.class.getName());
52
		types.put("XML Valid Url", XMLValidURL.class.getName());
53
		types.put("XML Vocabulary", XMLVocabularyRule.class.getName());
54
		types.put("XML Cris Class Vocabulary", XMLCrisClassVocabularyRule.class.getName());
55
		types.put("XML CRIS Referential Integrity Rule", XMLCrisReferentialIntegrityRule.class.getName());
56

    
57
		//unsupported
58
//		types.put("Retrievable Resource", RetrievableResourceRule.class.getName());
59
//		types.put("Schema Validity Check", SchemaValidityRule.class.getName());
60

    
61
		logger.debug("initializing the RuleEntities map");
62
		entities = new HashMap<String, String>();
63
		entities.put("Publication", "openaire_cris_publications");
64
		entities.put("Person", "openaire_cris_persons");
65
		entities.put("Organisation", "openaire_cris_orgunits");
66
		entities.put("Project", "openaire_cris_projects" );
67
		entities.put("Funding", "openaire_cris_funding" );
68
		entities.put("Service", "openaire_cris_services");
69
		entities.put("Product", "openaire_cris_datasets");		
70
	}
71

    
72
	public static HashMap<String, String> getEntities() {
73
		return entities;
74
	}
75

    
76
	public static void setEntities(HashMap<String, String> entities) {
77
		RuleTypes.entities = entities;
78
	}
79
	
80
	static public String getSetOfEntity(String entity) {
81
		return entities.get(entity);
82
	}
83
		
84
	static public String[] getTypes() {
85
		logger.debug("getting all types of rules");
86
		String[] dummy = new String[0];
87
		return types.keySet().toArray(dummy);
88
	}
89
	
90
	static public String getClassOfType(String type) {
91
		logger.debug("getting class of rule type "+type);
92
		return types.get(type);
93
	}
94
	
95
}
(4-4/6)