Changeset 6311
- Timestamp:
- 06/19/15 13:58:05 (9 years ago)
- Location:
- vlo/trunk/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/trunk/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/CMDIParserVTDXML.java
r6310 r6311 268 268 setNameSpace(ap); 269 269 ap.selectXPath(pattern); 270 270 271 271 boolean matchedPattern = false; 272 272 int index = ap.evalXPath(); … … 287 287 } 288 288 289 final List<String> valueList = postProcess(config.getName(), value); 290 insertFacetValues(config.getName(), valueList, cmdiData, languageCode, allowMultipleValues, config.isCaseInsensitive()); 289 final List<String> values = postProcess(config.getName(), value); 290 insertFacetValues(config.getName(), values, cmdiData, languageCode, allowMultipleValues, config.isCaseInsensitive()); 291 292 // insert post-processed values into derived facet(s) if configured 293 for (String derivedFacet : config.getDerivedFacets()) { 294 final List<String> derivedValues = new ArrayList<String>(); 295 for (String postProcessedValue : values) { 296 derivedValues.addAll(postProcess(derivedFacet, postProcessedValue)); 297 } 298 insertFacetValues(derivedFacet, derivedValues, cmdiData, languageCode, allowMultipleValues, config.isCaseInsensitive()); 299 } 300 291 301 index = ap.evalXPath(); 292 302 -
vlo/trunk/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/FacetConceptMapping.java
r6201 r6311 15 15 import javax.xml.bind.annotation.XmlRootElement; 16 16 17 18 17 /** 19 18 * Corresponds to the facet concepts file. 20 * 21 * This class holds the mapping of facet name -> facetConcepts/patterns 22 * A facetConcept is a ISOcat conceptLink e.g.: http://www.isocat.org/datcat/DC-2544 23 * the conceptLink will be analysed and translated into a valid Xpath expression to extract data out of the metadata. 24 * Valid xpath expression e.g. /c:CMD/c:Header/c:MdSelfLink/text(), the 'c' namespace will be mapped to http://www.clarin.eu/cmd/ in the parser. 25 * A pattern is an xpath expression used directly on the metadata. Use patterns only when a conceptLink does not suffice. 19 * 20 * This class holds the mapping of facet name -> facetConcepts/patterns A 21 * facetConcept is a ISOcat conceptLink e.g.: 22 * http://www.isocat.org/datcat/DC-2544 the conceptLink will be analysed and 23 * translated into a valid Xpath expression to extract data out of the metadata. 24 * Valid xpath expression e.g. /c:CMD/c:Header/c:MdSelfLink/text(), the 'c' 25 * namespace will be mapped to http://www.clarin.eu/cmd/ in the parser. A 26 * pattern is an xpath expression used directly on the metadata. Use patterns 27 * only when a conceptLink does not suffice. 26 28 * 27 29 */ … … 42 44 this.facetConcepts = facetConcepts; 43 45 } 44 46 45 47 public Map<String, FacetConcept> getFacetConceptMap() { 46 Map<String, FacetConcept> facetConceptMap = new HashMap<String, FacetConcept>(); 47 for(FacetConcept facet : getFacetConcepts()) 48 facetConceptMap.put(facet.getName(), facet); 49 50 return facetConceptMap; 51 } 52 48 Map<String, FacetConcept> facetConceptMap = new HashMap<String, FacetConcept>(); 49 for (FacetConcept facet : getFacetConcepts()) { 50 facetConceptMap.put(facet.getName(), facet); 51 } 52 53 return facetConceptMap; 54 } 55 53 56 public void check() { 54 57 for (FacetConcept facetConcept : getFacetConcepts()) { … … 56 59 AcceptableContext acceptableContext = facetConcept.getAcceptableContext(); 57 60 RejectableContext rejectableContext = facetConcept.getRejectableContext(); 58 if (acceptableContext.includeAny() && rejectableContext.includeAny()) 59 LOG.error("Error: any context is both acceptable and rejectable for facet '"+facetConcept.getName()+"'"); 60 if (acceptableContext.includeEmpty() && rejectableContext.includeEmpty()) 61 LOG.error("Error: empty context is both acceptable and rejectable for facet '"+facetConcept.getName()+"'"); 61 if (acceptableContext.includeAny() && rejectableContext.includeAny()) { 62 LOG.error("Error: any context is both acceptable and rejectable for facet '" + facetConcept.getName() + "'"); 63 } 64 if (acceptableContext.includeEmpty() && rejectableContext.includeEmpty()) { 65 LOG.error("Error: empty context is both acceptable and rejectable for facet '" + facetConcept.getName() + "'"); 66 } 62 67 } 63 68 } … … 67 72 @XmlRootElement(name = "facetConcept") 68 73 public static class FacetConcept { 74 69 75 @XmlAttribute 70 76 private String name; 71 77 72 78 /** 73 * Values will be stored lowercase by default, set isCaseInsensitive to true if you want to keep the case of the value 79 * Values will be stored lowercase by default, set isCaseInsensitive to 80 * true if you want to keep the case of the value 74 81 */ 75 82 @XmlAttribute … … 77 84 78 85 /** 79 * By default multiple values that are found for a matching pattern will be stored. For some facets this leads to too much values 80 * with little value for instance for "subject". Set allowMultipleValues to false will only store the first found value. 86 * By default multiple values that are found for a matching pattern will 87 * be stored. For some facets this leads to too much values with little 88 * value for instance for "subject". Set allowMultipleValues to false 89 * will only store the first found value. 81 90 */ 82 91 @XmlAttribute 83 92 private boolean allowMultipleValues = true; 84 93 85 94 @XmlAttribute 86 95 private String description = ""; 87 96 88 97 @XmlAttribute 89 98 private String definition = ""; … … 100 109 @XmlElement(name = "pattern") 101 110 private List<String> patterns = new ArrayList<String>(); 102 111 103 112 @XmlElement(name = "blacklistPattern") 104 113 private List<String> blacklistPatterns = new ArrayList<String>(); 105 114 115 @XmlElement(name = "derivedFacet") 116 private List<String> derivedFacets = new ArrayList<String>(); 117 106 118 public void setConcepts(List<String> concepts) { 107 119 this.concepts = concepts; … … 119 131 return acceptableContext; 120 132 } 121 133 122 134 public boolean hasAcceptableContext() { 123 return (acceptableContext !=null);135 return (acceptableContext != null); 124 136 } 125 137 … … 131 143 return rejectableContext; 132 144 } 133 145 134 146 public boolean hasRejectableContext() { 135 return (rejectableContext !=null);136 } 137 147 return (rejectableContext != null); 148 } 149 138 150 public boolean hasContext() { 139 151 return (hasAcceptableContext() || hasRejectableContext()); … … 163 175 return allowMultipleValues; 164 176 } 165 177 166 178 public void setDescription(String description) { 167 168 } 169 179 this.description = description; 180 } 181 170 182 public String getDescription() { 171 172 } 173 183 return this.description; 184 } 185 174 186 public void setDefinition(String definition) { 175 176 } 177 187 this.definition = definition; 188 } 189 178 190 public String getDefinition() { 179 191 return this.definition; 180 192 } 181 193 … … 187 199 return patterns; 188 200 } 189 201 190 202 public void setBlacklistPatterns(List<String> blacklistPatterns) { 191 203 this.blacklistPatterns = blacklistPatterns; … … 194 206 public List<String> getBlacklistPatterns() { 195 207 return blacklistPatterns; 208 } 209 210 public List<String> getDerivedFacets() { 211 return derivedFacets; 212 } 213 214 public void setDerivedFacets(List<String> derivedFacets) { 215 this.derivedFacets = derivedFacets; 196 216 } 197 217 … … 202 222 203 223 } 204 224 205 225 @XmlAccessorType(XmlAccessType.FIELD) 206 226 @XmlRootElement(name = "acceptableContext") … … 239 259 return includeEmpty; 240 260 } 241 261 242 262 } 243 263 … … 278 298 return includeEmpty; 279 299 } 280 300 281 301 } 282 302 -
vlo/trunk/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/FacetConfiguration.java
r6201 r6311 6 6 7 7 /** 8 * Once created contains the information about the facets and such. 9 * Just acontainer for some information, doesn't do processing.8 * Once created contains the information about the facets and such. Just a 9 * container for some information, doesn't do processing. 10 10 */ 11 12 11 public class FacetConfiguration { 13 12 14 13 private String name; 15 private boolean caseInsensitive = false;14 private boolean caseInsensitive = false; 16 15 private List<String> patterns = new ArrayList<String>(); 17 16 private List<String> fallbackPatterns = new ArrayList<String>(); 17 private List<String> derivedFacets = new ArrayList<String>(); 18 18 private boolean allowMultipleValues = true; 19 19 … … 29 29 this.patterns = patterns; 30 30 } 31 31 32 32 public void setFallbackPatterns(List<String> fallbackPatterns) { 33 33 this.fallbackPatterns = fallbackPatterns; … … 37 37 this.patterns = Collections.singletonList(pattern); 38 38 } 39 39 40 40 public void setFallbackPattern(String fallbackPattern) { 41 41 this.fallbackPatterns = Collections.singletonList(fallbackPattern); … … 48 48 return patterns; 49 49 } 50 50 51 51 public List<String> getFallbackPatterns() { 52 52 return fallbackPatterns; … … 63 63 @Override 64 64 public String toString() { 65 return "name=" +name+", pattern="+patterns;65 return "name=" + name + ", pattern=" + patterns; 66 66 } 67 67 … … 73 73 this.allowMultipleValues = allowMultipleValues; 74 74 } 75 76 public List<String> getDerivedFacets() { 77 return derivedFacets; 78 } 79 80 public void setDerivedFacets(List<String> derivedFacets) { 81 this.derivedFacets = derivedFacets; 82 } 83 75 84 } -
vlo/trunk/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/FacetMappingFactory.java
r6216 r6311 179 179 config.setPatterns(new ArrayList<String>(linkedHashSet)); 180 180 config.setFallbackPatterns(facetConcept.getPatterns()); 181 config.setDerivedFacets(facetConcept.getDerivedFacets()); 181 182 182 183 if (!config.getPatterns().isEmpty() || !config.getFallbackPatterns().isEmpty()) {
Note: See TracChangeset
for help on using the changeset viewer.