Changeset 6729
- Timestamp:
- 11/02/15 15:22:55 (9 years ago)
- Location:
- vlo/branches/vlo-3.3-oeaw/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-3.3-oeaw/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/CMDIData.java
r6400 r6729 42 42 43 43 private String profileId; 44 private String profileName;45 44 private String originalResourceType; 46 45 … … 162 161 return profileId; 163 162 } 164 165 public String getProfileName() {166 return profileName;167 }168 169 public void setProfileName(String profileName) {170 this.profileName = profileName;171 }172 163 173 164 public String getOriginalResourceType() { … … 179 170 } 180 171 181 182 172 } -
vlo/branches/vlo-3.3-oeaw/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/CMDIParserVTDXML.java
r6723 r6729 60 60 LOG.error("Problems mapping facets for file: {}", file.getAbsolutePath()); 61 61 } 62 63 List<String> profileName = (postProcessors.get(FacetConstants.FIELD_CLARIN_PROFILE)).process(profileId); 64 cmdiData.setProfileName(profileName.get(0)); 62 65 63 nav.toElement(VTDNav.ROOT); 66 64 processResources(cmdiData, nav); -
vlo/branches/vlo-3.3-oeaw/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/MetadataImporter.java
r6715 r6729 89 89 POST_PROCESSORS.put(FacetConstants.FIELD_CLARIN_PROFILE, new CMDIComponentProfileNamePostProcessor()); 90 90 POST_PROCESSORS.put(FacetConstants.FIELD_RESOURCE_CLASS, new ResourceClassPostProcessor()); 91 POST_PROCESSORS.put(FacetConstants.FIELD_PROFILE, new ProfileNamePostProcessor());92 91 } 93 92 … … 435 434 436 435 437 //Add profileId & profileName & original resource type 438 solrDocument.addField("profileName", cmdiData.getProfileName()); 439 solrDocument.addField("profileId", cmdiData.getProfileId()); 436 //Add profileId & original resource type 437 solrDocument.addField("_componentProfileId", cmdiData.getProfileId()); 440 438 solrDocument.addField("resourceClassOrig", cmdiData.getOriginalResourceType()); 441 439 -
vlo/branches/vlo-3.3-oeaw/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/NationalProjectPostProcessor.java
r6715 r6729 2 2 3 3 import java.util.ArrayList; 4 import java.util.HashMap;5 4 import java.util.List; 6 import java.util.Map;7 import java.util.Map.Entry;8 import java.util.TreeMap;9 import java.util.regex.Matcher;10 import java.util.regex.Pattern;11 5 12 6 import org.slf4j.Logger; 13 7 import org.slf4j.LoggerFactory; 14 15 import eu.clarin.cmdi.vlo.pojo.Variant;16 import eu.clarin.cmdi.vlo.pojo.VariantsMap;17 8 18 9 /** -
vlo/branches/vlo-3.3-oeaw/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/PostProcessorsWithVocabularyMap.java
r6725 r6729 4 4 import java.io.FileInputStream; 5 5 import java.io.InputStream; 6 import java.util.List;7 6 import java.util.Map; 8 import java.util.Map.Entry;9 7 10 8 import org.slf4j.Logger; 11 9 import org.slf4j.LoggerFactory; 12 10 11 import eu.clarin.cmdi.vlo.normalization.NormalizationService; 12 import eu.clarin.cmdi.vlo.normalization.NormalizationVocabulary; 13 import eu.clarin.cmdi.vlo.normalization.VocabularyEntry; 13 14 import eu.clarin.cmdi.vlo.pojo.VariantsMap; 14 import eu.clarin.cmdi.vlo.pojo.VocabularyEntry;15 15 import eu.clarin.cmdi.vlo.transformers.VariantsMapMarshaller; 16 16 … … 25 25 */ 26 26 27 public abstract class PostProcessorsWithVocabularyMap implements PostProcessor{ 28 29 private final static Logger _logger = LoggerFactory.getLogger(PostProcessorsWithVocabularyMap.class); 30 31 private List<VocabularyEntry> map = null; 32 33 34 /* 35 * This method is used for normalization of facet values based on normalization maps. 36 * In case that value is not in the map, the input value is returned. 37 * 38 * @param value - original value from record 39 * @return normalized value if there is a match otherwise original value 40 * 41 */ 42 public String normalize(String value){ 43 return normalize(value, value); 44 } 45 46 47 /* 48 * This method is used for normalization of facet values based on normalization maps. 49 * With second parameter user can specify what to return in case when value is not in normalization map (special case for NationalProject facet). 50 * 51 * @param value - original value from record 52 * @param fallBackValue - value to be returned in case of no match 53 * @return normalized value if there is a match otherwise returns what is specified with 2nd parameter 54 * 55 */ 56 public String normalize(String value, String fallBackValue){ 57 //init 58 if(map == null) 59 createMap(); 60 61 int ind = map.indexOf(value); 62 return (ind != -1)? map.get(ind).getNormalizedValue() : fallBackValue; 63 } 64 65 public Map<String, String> getCrossMappings(String value){ 66 67 //init 68 if(map == null) 69 createMap(); 70 71 int ind = map.indexOf(value); 72 return (ind != -1)? map.get(ind).getCrossMap() : null; 73 } 74 75 public abstract String getNormalizationMapURL(); 76 77 private void createMap(){ 78 VariantsMap varinatsRawMap = getMappingFromFile(getNormalizationMapURL()); 79 map = varinatsRawMap.getMap(); 80 81 printMap(); 82 } 83 84 protected VariantsMap getMappingFromFile(String mapUrl){ 85 try { 86 87 _logger.info("Reading vocabulary file from: {}", mapUrl); 88 // load records from file 89 // in the future this should be loaded from CLAVAS directly and the file only used as fallback 90 91 //InputStream is = PostProcessorsWithVocabularyMap.class.getClassLoader().getResourceAsStream(mapUrl); 92 InputStream is = new FileInputStream(new File(mapUrl)); 27 public abstract class PostProcessorsWithVocabularyMap implements PostProcessor, NormalizationService { 93 28 94 95 return VariantsMapMarshaller.unmarshal(is); 96 } catch (Exception e) { 97 throw new RuntimeException("Cannot instantiate postProcessor:", e); 98 } 99 } 100 101 102 // for debug 103 public void printMap(){ 104 _logger.info("map contains {} entries", map.size()); 105 for(VocabularyEntry entry: map) 106 _logger.info(entry.toString()); 107 108 } 29 private final static Logger _logger = LoggerFactory.getLogger(PostProcessorsWithVocabularyMap.class); 30 31 private NormalizationVocabulary vocabulary; 32 33 public String normalize(String value) { 34 return normalize(value, value); 35 } 36 37 public String normalize(String value, String fallBackValue) { 38 if (vocabulary == null) 39 initVocabulary(); 40 41 return vocabulary.normalize(value, fallBackValue); 42 } 43 44 public Map<String, String> getCrossMappings(String value) { 45 if (vocabulary == null) 46 initVocabulary(); 47 48 return vocabulary.getCrossMappings(value); 49 } 50 51 public abstract String getNormalizationMapURL(); 52 53 private void initVocabulary() { 54 VariantsMap varinatsRawMap = getMappingFromFile(getNormalizationMapURL()); 55 vocabulary = varinatsRawMap.getMap(); 56 57 printMap(); 58 } 59 60 protected VariantsMap getMappingFromFile(String mapUrl) { 61 try { 62 63 _logger.info("Reading vocabulary file from: {}", mapUrl); 64 // load records from file 65 // in the future this should be loaded from CLAVAS directly and the 66 // file only used as fallback 67 68 // InputStream is = 69 // PostProcessorsWithVocabularyMap.class.getClassLoader().getResourceAsStream(mapUrl); 70 InputStream is = new FileInputStream(new File(mapUrl)); 71 72 return VariantsMapMarshaller.unmarshal(is); 73 } catch (Exception e) { 74 throw new RuntimeException("Cannot instantiate postProcessor:", e); 75 } 76 } 77 78 // for debug 79 public void printMap() { 80 _logger.info("map contains {} entries", vocabulary.getEntries().length); 81 for(int i = 0; i < vocabulary.getEntries().length; i++) 82 _logger.info(vocabulary.getEntries()[i].toString()); 83 84 85 } 109 86 }
Note: See TracChangeset
for help on using the changeset viewer.