Changeset 6267
- Timestamp:
- 06/04/15 07:57:04 (9 years ago)
- Location:
- vlo/branches/vlo-ticket761
- Files:
-
- 62 edited
- 12 copied
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-ticket761
- Property svn:mergeinfo changed
/vlo/trunk merged: 6190-6195,6199-6208,6210-6216,6218,6227-6228,6230,6232-6233,6235,6239-6240,6242,6245-6248,6252-6253,6257-6258,6260,6264
- Property svn:mergeinfo changed
-
vlo/branches/vlo-ticket761/CHANGES.txt
r6160 r6267 1 1 Bug Fixes and Features 2 2 3 VLO 3.2 (June 2015) 4 5 Mapping: 6 * Added search facet "Availability" based on licensing information 7 <https://trac.clarin.eu/ticket/393> 8 * Non-English language names are ignored (if language code is not used) 9 <https://trac.clarin.eu/ticket/170> 10 * Mapping of language name variants to canonical names (OLAC) 11 <https://trac.clarin.eu/ticket/749> 12 * Mapping of language tags without olac-language attribute (OLAC) 13 <https://trac.clarin.eu/ticket/412> 14 15 Search interface: 16 * Added tooltips to facets with facet descriptions 17 <https://trac.clarin.eu/ticket/711> 18 * Search term can be removed without removing facet selection in 'bread crumbs' 19 <https://trac.clarin.eu/ticket/619> 20 * Search result ranking by relevance 21 <https://trac.clarin.eu/ticket/575> 22 23 Record page: 24 * Paging of resources in record page 25 <https://trac.clarin.eu/ticket/565> 26 * Improved handle resolution for resources in record page 27 <https://trac.clarin.eu/ticket/550> 28 * Fixed handle link in record page for cases that contain an '@' character 29 <https://trac.clarin.eu/ticket/625> 30 * Link to language info page uses new URL scheme 31 <https://trac.clarin.eu/ticket/753> 32 33 Web application general: 34 * VLO web pages contain a canonical URL link (improving search engine behaviour) 35 <https://trac.clarin.eu/ticket/135> 36 3 37 VLO 3.1 (March 2015) 4 38 * Added the 'license' facet -
vlo/branches/vlo-ticket761/DEPLOY-README.txt
r6102 r6267 24 24 vlo-3.0-Distribution.tar.gz 25 25 26 in a temporary directory: 'temp'. Next, stop the Tomcat server :27 28 26 in a temporary directory: 'temp'. Next, stop the Tomcat server, e.g.: 27 28 /etc/init.d/tomcat6 stop 29 29 30 30 After the server has stopped, copy the contents of the vlo_parent-2.13 … … 193 193 6. Importing data 194 194 195 Before starting data import, first start the Tomcat server :196 197 /etc/init.d/tomcat6 start195 Before starting data import, first start the Tomcat server, e.g.: 196 197 /etc/init.d/tomcat6 start 198 198 199 199 To be sure the Solr server is working as it should, inspect the Tomcat log … … 202 202 Next, you can run the importer by starting the 203 203 204 ./vlo_solr_importer.sh 205 206 script in the vlo/bin directory. Messages are logged to the console. Because 207 meta data is not static, it is recommended to run the importer a couple of 208 times a week. Please note that, given the current (04.2014) set of data, a 209 run typically takes between two and four hours. 204 ./vlo_solr_importer.sh 205 206 script in the vlo/bin directory. Messages are logged to the a log file. 207 Because meta data is not static, it is recommended to run the importer a 208 couple of times a week. Please note that, given the current (04.2014) set of 209 data, a run typically takes between two and four hours. 210 211 More information about running the importer can be found in the README.txt 212 file. 213 -
vlo/branches/vlo-ticket761/README.txt
r6101 r6267 1 = Table of Contents = 2 - What is the VLO? 3 - What should I read? 4 - Setting up 5 - Preparing for release 6 - Using the VLO 7 - Running an import 8 1 9 = What is the VLO? = 2 10 … … 26 34 Some general development notes. 27 35 28 = = Setting up ==36 = Setting up = 29 37 30 38 Follow the instructions in DEPLOY-README to set up a development environment. … … 82 90 files. 83 91 92 = Using the VLO = 93 94 After a successful deployment and configuration, you should be able to browse to 95 the VLO web app and browse the imported records. 96 97 If the VLO is empty, you will need to run an import first. 98 99 == Running an import == 100 101 To run an import, go the 'bin' child directory of the VLO application directory 102 and run 103 104 ./vlo_solr_importer.sh 105 106 as the appropriate user (e.g. 'vlouser'). 107 108 It's advisable to run this in a detached background process (for example using 109 "screen") because an import can take quite a long time depending on the amount 110 of records to be imported. 111 112 Some progress information is logged to a file 'log/vlo-importer.log'. It gets 113 rotated automatically by the import process. 114 115 For a fresh import, even when the VLO is not configured to delete all documents 116 from the index first, you can simply remove the contents of the Solr data 117 directory (check server configuration documentation for the exact location). -
vlo/branches/vlo-ticket761/UPGRADE.txt
- Property svn:mergeinfo changed
/vlo/trunk/UPGRADE.txt merged: 6193,6230,6232,6239-6240,6260
r6160 r6267 13 13 appropriate user (i.e. 'vlouser' on catalog.clarin.eu) 14 14 15 - In the 'config' directory, adjust VloConfig.xml as needed (make a backup first). In 16 particular, make sure that the following instance specific sections are kept: 15 - In the 'config' directory, adjust VloConfig.xml as needed (make a backup 16 first). In particular, make sure that the following instance specific sections 17 are kept from the current version: 17 18 - dataRoots and its children 18 19 - solrUrl … … 25 26 - Replace the 'current' symlink with a link to location of the new VLO directory 26 27 27 - If needed, flush the Solr index (by removing the data directory )28 - If needed, flush the Solr index (by removing the data directory's content) 28 29 - In 'bin', run the importer using the updated configuration file: 29 30 ./vlo_solr_importer.sh -c ../config/VloConfig.xml 31 32 --------------------------- 33 Upgrading from 3.1 to 3.2 34 --------------------------- 35 * Take note of the following changes in VloConfig.xml: 36 37 - 'facetConceptsFile' now defines the location of the facet/concept mapping 38 definition on disk; to use the default bundled definition, leave it empty. 39 Before this used to have the value '/facetConcepts.xml' which will no longer be 40 valid - it can safely be replaced with either the empty string or 41 'facetConcepts.xml' to use the file in the same directory as VloConfig.xml. 42 43 - 'languageLinkPrefix' element has been REPLACED by 'languageLinkTemplate'; 44 remove the former and add the following to existing configurations: 45 46 <languageLinkTemplate>https://infra.clarin.eu/content/language_info/data/{}.html</languageLinkTemplate> 47 48 - 'languageNameVariantsUrl' and 'licenseAvailabilityMapUrl' are now required 49 mapping configuration elements. So the following should normally be added: 50 51 <languageNameVariantsUrl>/LanguageNameVariantsMap.xml</languageNameVariantsUrl> 52 <licenseAvailabilityMapUrl>/LicenseAvailabilityMap.xml</licenseAvailabilityMapUrl> 53 54 - optional 'showResultScores' element, defaults to false. Should be false except 55 when debugging result ranking. 56 57 - The facet field 'availability' is now available 58 59 * Be aware that the default maximum heap space of the importer has been 60 increased from 2GB to 3GB (by means of a change in bin/vlo_solr_importer.sh). 30 61 31 62 --------------------------- - Property svn:mergeinfo changed
-
vlo/branches/vlo-ticket761/pom.xml
r5991 r6267 11 11 in each module's pom.xml 12 12 --> 13 <version>3. 2-SNAPSHOT</version>13 <version>3.3-SNAPSHOT</version> 14 14 15 15 <description>Virtual Language Observatory (VLO) parent project</description> … … 28 28 29 29 <properties> 30 <solr.version>4. 8.1</solr.version>31 <slf4j.version>1.7.1 0</slf4j.version>30 <solr.version>4.10.4</solr.version> 31 <slf4j.version>1.7.12</slf4j.version> 32 32 <saxon.version>9.5.1-8</saxon.version> 33 33 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> -
vlo/branches/vlo-ticket761/vlo-commons/pom.xml
r5991 r6267 6 6 <groupId>eu.clarin.cmdi</groupId> 7 7 <artifactId>vlo</artifactId> 8 <version>3. 2-SNAPSHOT</version>8 <version>3.3-SNAPSHOT</version> 9 9 </parent> 10 10 <groupId>eu.clarin.cmdi</groupId> 11 11 <artifactId>vlo-commons</artifactId> 12 <version>3. 2-SNAPSHOT</version>12 <version>3.3-SNAPSHOT</version> 13 13 <name>VLO Commons</name> 14 14 <url>http://maven.apache.org</url> -
vlo/branches/vlo-ticket761/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/FacetConstants.java
r6188 r6267 27 27 public static final String FIELD_NATIONAL_PROJECT = "nationalProject"; 28 28 public static final String FIELD_KEYWORDS = "keywords"; 29 /** 30 * Solr pseudo-field that reveals the ranking score 31 * 32 * @see 33 * https://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_see_the_relevancy_scores_for_search_results 34 */ 35 public static final String FIELD_SOLR_SCORE = "score"; 29 36 30 37 //The _ facets are not meant to be shown to users. … … 35 42 public static final String FIELD_SEARCH_SERVICE = "_contentSearchRef"; 36 43 public static final String FIELD_LAST_SEEN = "_lastSeen"; 44 public static final String FIELD_HIERARCHY_WEIGHT = "_hierarchyWeight"; 45 public static final String FIELD_IS_PART_OF = "_isPartOf"; 46 public static final String FIELD_HAS_PART = "_hasPart"; 37 47 38 48 /** -
vlo/branches/vlo-ticket761/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/StringUtils.java
r4480 r6267 1 1 package eu.clarin.cmdi.vlo; 2 3 import java.util.Arrays; 4 import java.util.HashSet; 5 import java.util.Set; 2 6 3 7 public final class StringUtils { … … 43 47 return result; 44 48 } 49 50 private static final Set<Character> reservedCharacters = new HashSet<Character>(Arrays.asList('!', '*', '\'', '(', 51 ')', ';', ':', '@', '&', '=', '+', '$', ',', '/', '?', '#', '[', ']')); 52 53 /** 54 * Return normalized String where all reserved characters in URL encoding 55 * are replaced by their ASCII code (in underscores) 56 * 57 * @param idString String that will be normalized 58 * @return normalized version of value where all reserved 59 * characters in URL encoding are replaced by their ASCII code 60 */ 61 public static String normalizeIdString(String idString) { 62 StringBuilder normalizedString = new StringBuilder(); 63 for (int i = 0; i < idString.length(); i++) { 64 Character character = idString.charAt(i); 65 if (reservedCharacters.contains(character)) { 66 normalizedString.append("_").append((int) character).append("_"); 67 } else { 68 normalizedString.append(character); 69 } 70 } 71 return normalizedString.toString(); 72 } 45 73 46 74 } -
vlo/branches/vlo-ticket761/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/AbstractXmlVloConfigFactory.java
r4517 r6267 19 19 import java.io.IOException; 20 20 import java.io.InputStream; 21 import java.net.URI; 21 22 import javax.xml.bind.JAXBException; 22 23 import javax.xml.transform.stream.StreamSource; … … 41 42 final InputStream fileStream = getXmlConfigurationInputStream(); 42 43 try { 43 return marshaller.unmarshal(new StreamSource(fileStream)); 44 final VloConfig config = marshaller.unmarshal(new StreamSource(fileStream)); 45 config.setConfigLocation(getLocation()); 46 return config; 44 47 } catch (JAXBException ex) { 45 48 throw new RuntimeException("Could not deserialize configuration file", ex); … … 56 59 */ 57 60 protected abstract InputStream getXmlConfigurationInputStream() throws IOException; 61 62 protected abstract URI getLocation(); 58 63 59 64 } -
vlo/branches/vlo-ticket761/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/DefaultVloConfigFactory.java
r4517 r6267 18 18 19 19 import java.io.InputStream; 20 import java.net.URI; 21 import java.net.URISyntaxException; 20 22 21 23 /** … … 37 39 return getClass().getResourceAsStream(DEFAULT_CONFIG_RESOURCE); 38 40 } 41 42 @Override 43 protected URI getLocation() { 44 try { 45 return getClass().getResource(DEFAULT_CONFIG_RESOURCE).toURI(); 46 } catch (URISyntaxException ex) { 47 throw new RuntimeException("Invalid config file URI", ex); 48 } 49 } 50 39 51 } -
vlo/branches/vlo-ticket761/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/VloConfig.java
r6160 r6267 1 1 package eu.clarin.cmdi.vlo.config; 2 2 3 import java.io.UnsupportedEncodingException; 4 import java.net.URLEncoder; 3 import java.net.URI; 5 4 import java.util.ArrayList; 6 5 import java.util.Collection; … … 19 18 public class VloConfig { 20 19 20 public static final String LANGUAGE_LINK_TEMPLATE_LANGUAGE_CODE_PLACEHOLDER = "{}"; 21 public static final String DEFAULT_FACET_CONCEPTS_RESOURCE_FILE = "/facetConcepts.xml"; 22 21 23 /* 22 24 * VLO application parameter members<br><br> … … 64 66 //(required = false) 65 67 private String nationalProjectMapping = ""; 66 68 67 69 private String organisationNamesUrl; 68 70 69 71 private String languageNameVariantsUrl; 70 72 71 73 private String licenseAvailabilityMapUrl; 72 74 … … 94 96 private String imdiBrowserUrl = ""; 95 97 96 private String languageLink Prefix= "";98 private String languageLinkTemplate = ""; 97 99 98 100 // web application user interface … … 104 106 105 107 private String feedbackFromUrl = ""; 108 109 private boolean showResultScores = false; 110 106 111 /** 107 112 * A set of fields to be excluded from display<br><br> … … 141 146 142 147 private String collectionFacet; 143 148 144 149 // test related parameters 145 150 //(required = false) … … 152 157 private String cqlEndpointAlternative = ""; 153 158 159 private URI configLocation; 160 154 161 /** 155 162 * Get and set methods for web application parameter members<br><br> … … 596 603 * 597 604 * @return the value 598 */ 599 public String getLanguageLinkPrefix() { 600 return languageLinkPrefix; 605 * @see #LANGUAGE_LINK_TEMPLATE_LANGUAGE_CODE_PLACEHOLDER 606 */ 607 public String getLanguageLinkTemplate() { 608 return languageLinkTemplate; 601 609 } 602 610 … … 608 616 * 609 617 * @param param the value 610 */ 611 public void setLanguageLinkPrefix(String param) { 612 languageLinkPrefix = param; 618 * @see #LANGUAGE_LINK_TEMPLATE_LANGUAGE_CODE_PLACEHOLDER 619 */ 620 public void setLanguageLinkTemplate(String param) { 621 languageLinkTemplate = param; 613 622 } 614 623 … … 943 952 reverseProxyPrefix = param; 944 953 } 945 946 954 955 /** 947 956 * Get the value of the organisationNamesUrl parameter<br><br> 948 957 * … … 967 976 organisationNamesUrl = param; 968 977 } 969 978 970 979 /** 971 980 * Get the value of the languageNameVariantsUrl parameter<br><br> … … 991 1000 languageNameVariantsUrl = param; 992 1001 } 993 994 /**1002 1003 /** 995 1004 * Get the value of the licenseAvailabilityMapUrl parameter<br><br> 996 1005 * … … 1063 1072 cqlEndpointAlternative = param; 1064 1073 } 1074 1075 /** 1076 * Sets the originating file for the current configuration 1077 * 1078 * @param configFile the file this config was read from 1079 */ 1080 public void setConfigLocation(URI configFile) { 1081 this.configLocation = configFile; 1082 } 1083 1084 /** 1085 * 1086 * @return the file this config was read from. may be null! 1087 */ 1088 public URI getConfigLocation() { 1089 return configLocation; 1090 } 1091 1092 public void setShowResultScores(boolean showResultScores) { 1093 this.showResultScores = showResultScores; 1094 } 1095 1096 public boolean isShowResultScores() { 1097 return showResultScores; 1098 } 1065 1099 } -
vlo/branches/vlo-ticket761/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/XmlVloConfigFactory.java
r4520 r6267 19 19 import java.io.IOException; 20 20 import java.io.InputStream; 21 import java.net.URI; 22 import java.net.URISyntaxException; 21 23 import java.net.URL; 22 24 … … 31 33 32 34 /** 33 * 35 * 34 36 * @param configLocation URL from which the configuration should be read 35 37 */ … … 41 43 return configLocation.openStream(); 42 44 } 45 46 @Override 47 protected URI getLocation() { 48 try { 49 return configLocation.toURI(); 50 } catch (URISyntaxException ex) { 51 throw new RuntimeException("Invalid config file URI", ex); 52 } 53 } 54 43 55 } -
vlo/branches/vlo-ticket761/vlo-commons/src/main/resources/VloConfig.xml
r6160 r6267 47 47 <helpUrl>http://www.clarin.eu/vlo</helpUrl> 48 48 49 <facetConceptsFile>/facetConcepts.xml</facetConceptsFile> 49 <!-- leave empty to use default packaged definition --> 50 <facetConceptsFile><!-- use default packaged definition --></facetConceptsFile> 50 51 51 52 <profileSchemaUrl>http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/{PROFILE_ID}/xsd</profileSchemaUrl> … … 139 140 <countryComponentUrl>http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/clarin.eu:cr1:c_1271859438104/xml</countryComponentUrl> 140 141 141 <languageLink Prefix>http://infra.clarin.eu/service/language/info.php?code=</languageLinkPrefix>142 <languageLinkTemplate>https://infra.clarin.eu/content/language_info/data/{}.html</languageLinkTemplate> 142 143 143 144 <feedbackFromUrl>http://www.clarin.eu/node/3759?url=</feedbackFromUrl> … … 156 157 157 158 <cqlEndpointAlternative>http://cqlservlet.mpi.nl/</cqlEndpointAlternative> 159 160 <!-- makes the score for the result ranking visible in the search results --> 161 <showResultScores>false</showResultScores> 158 162 </VloConfig> -
vlo/branches/vlo-ticket761/vlo-commons/src/test/java/eu/clarin/cmdi/vlo/config/DefaultVloConfigFactoryTest.java
r6160 r6267 2 2 3 3 import java.io.File; 4 import java.io.UnsupportedEncodingException;5 import java.net.URLEncoder;6 import java.util.ArrayList;7 4 import java.util.Arrays; 8 import java.util.HashSet;9 5 import java.util.List; 10 6 import java.util.Set; … … 499 495 500 496 /** 501 * Test the getLanguageLink Prefixmethod497 * Test the getLanguageLinkTemplate method 502 498 */ 503 499 @Test … … 506 502 System.out.println("getLanguageLinkPrefix"); 507 503 508 String expResult = "http ://infra.clarin.eu/service/language/info.php?code=";509 String result = config.getLanguageLink Prefix();504 String expResult = "https://infra.clarin.eu/content/language_info/data/{}.html"; 505 String result = config.getLanguageLinkTemplate(); 510 506 511 507 assertEquals(expResult, result); … … 520 516 System.out.println("setLanguageLinkPrefix"); 521 517 522 String param = "http ://infra.clarin.eu/service/language/info.php?code=";523 524 config.setLanguageLink Prefix(param);525 526 String result = config.getLanguageLink Prefix();518 String param = "https://infra.clarin.eu/content/language_info/data/{}.html"; 519 520 config.setLanguageLinkTemplate(param); 521 522 String result = config.getLanguageLinkTemplate(); 527 523 528 524 assertEquals(param, result); -
vlo/branches/vlo-ticket761/vlo-distribution/pom.xml
r5991 r6267 7 7 <groupId>eu.clarin.cmdi</groupId> 8 8 <artifactId>vlo</artifactId> 9 <version>3. 2-SNAPSHOT</version>9 <version>3.3-SNAPSHOT</version> 10 10 </parent> 11 11 … … 14 14 <artifactId>vlo-distribution</artifactId> 15 15 <packaging>pom</packaging> 16 <version>3. 2-SNAPSHOT</version>16 <version>3.3-SNAPSHOT</version> 17 17 <name>VLO Distribution</name> 18 18 <description> -
vlo/branches/vlo-ticket761/vlo-distribution/src/main/assembly/installPackageBuilder.xml
r6101 r6267 75 75 <excludes> 76 76 <exclude>VloConfig.xml</exclude> 77 <exclude>facetConcepts.xml</exclude> 77 78 </excludes> 78 79 <outputDirectory>bin</outputDirectory> … … 93 94 <includes> 94 95 <include>VloConfig.xml</include> 96 <include>facetConcepts.xml</include> 95 97 </includes> 96 98 <outputDirectory>config</outputDirectory> -
vlo/branches/vlo-ticket761/vlo-importer/pom.xml
r5991 r6267 7 7 <groupId>eu.clarin.cmdi</groupId> 8 8 <artifactId>vlo</artifactId> 9 <version>3. 2-SNAPSHOT</version>9 <version>3.3-SNAPSHOT</version> 10 10 </parent> 11 11 … … 13 13 <groupId>eu.clarin.cmdi</groupId> 14 14 <artifactId>vlo-importer</artifactId> 15 <version>3. 2-SNAPSHOT</version>15 <version>3.3-SNAPSHOT</version> 16 16 <packaging>jar</packaging> 17 17 … … 178 178 <groupId>commons-cli</groupId> 179 179 <artifactId>commons-cli</artifactId> 180 <version>1. 2</version>180 <version>1.3</version> 181 181 <type>jar</type> 182 </dependency> 183 <dependency> 184 <groupId>org.jgrapht</groupId> 185 <artifactId>jgrapht-core</artifactId> 186 <version>0.9.1</version> 182 187 </dependency> 183 188 </dependencies> -
vlo/branches/vlo-ticket761/vlo-importer/src/main/bin/vlo_solr_importer.sh
r6099 r6267 36 36 # take preference over a specification as a property. 37 37 38 $JAVA -Xmx 2024M\38 $JAVA -Xmx3G \ 39 39 -cp "${DIR}:${DIR}/vlo-importer-${project.version}-importer.jar" \ 40 40 -DIMPORTER_LOG_DIR=${LOGDIR} \ -
vlo/branches/vlo-ticket761/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/CMDIParserVTDXML.java
r6160 r6267 12 12 import java.io.FileInputStream; 13 13 import java.io.IOException; 14 import java.net.URI; 14 15 import java.util.ArrayList; 15 16 import java.util.List; … … 22 23 23 24 public class CMDIParserVTDXML implements CMDIDataProcessor { 25 24 26 private final Map<String, PostProcessor> postProcessors; 25 27 private final Boolean useLocalXSDCache; 26 28 private static final Pattern PROFILE_ID_PATTERN = Pattern.compile(".*(clarin.eu:cr1:p_[0-9]+).*"); 27 29 private final static Logger LOG = LoggerFactory.getLogger(CMDIParserVTDXML.class); 28 30 29 31 private static final String DEFAULT_LANGUAGE = "und"; 30 32 31 33 public CMDIParserVTDXML(Map<String, PostProcessor> postProcessors, Boolean useLocalXSDCache) { 32 34 this.postProcessors = postProcessors; … … 38 40 CMDIData cmdiData = new CMDIData(); 39 41 VTDGen vg = new VTDGen(); 40 FileInputStream fileInputStream = new FileInputStream(file); 42 FileInputStream fileInputStream = new FileInputStream(file); 41 43 vg.setDoc(IOUtils.toByteArray(fileInputStream)); 42 44 vg.parse(true); 43 45 fileInputStream.close(); 44 46 45 47 VTDNav nav = vg.getNav(); 46 48 FacetMapping facetMapping = getFacetMapping(nav.cloneNav()); 47 49 48 if (facetMapping.getFacets().isEmpty()){50 if (facetMapping.getFacets().isEmpty()) { 49 51 LOG.error("Problems mapping facets for file: {}", file.getAbsolutePath()); 50 52 } … … 58 60 /** 59 61 * Setting namespace for Autopilot ap 60 * @param ap 62 * 63 * @param ap 61 64 */ 62 65 private void setNameSpace(AutoPilot ap) { … … 66 69 /** 67 70 * Extracts valid XML patterns for all facet definitions 71 * 68 72 * @param nav VTD Navigator 69 73 * @return the facet mapping used to map meta data to facets 70 * @throws VTDException 74 * @throws VTDException 71 75 */ 72 76 private FacetMapping getFacetMapping(VTDNav nav) throws VTDException { … … 75 79 throw new RuntimeException("Cannot get xsd schema so cannot get a proper mapping. Parse failed!"); 76 80 } 81 // final VloConfig config = MetadataImporter.config; 82 // final URI facetConceptsFile 83 // = FacetConceptsMarshaller.resolveFacetsFile(config.getConfigLocation(), config.getFacetConceptsFile()); 84 // final String facetConceptsFilePath = new File(facetConceptsFile).getAbsolutePath(); 85 // return FacetMappingFactory.getFacetMapping(facetConceptsFilePath, profileId, useLocalXSDCache); 86 77 87 String facetConceptsFile = MetadataImporter.config.getFacetConceptsFile(); 78 if (facetConceptsFile.length() == 0){ 79 // use the packaged facet mapping file 80 facetConceptsFile = "/facetConcepts.xml"; 81 } 88 89 //resolve against config location? (empty = default location) 90 if (facetConceptsFile != null && !facetConceptsFile.isEmpty()) { 91 URI configLocation = MetadataImporter.config.getConfigLocation(); 92 if (configLocation != null && !configLocation.getScheme().equals("jar")) { 93 URI facetConceptsLocation = configLocation.resolve(facetConceptsFile); 94 facetConceptsFile = new File(facetConceptsLocation).getAbsolutePath(); 95 } 96 } 97 82 98 return FacetMappingFactory.getFacetMapping(facetConceptsFile, profileId, useLocalXSDCache); 83 99 } 84 100 85 101 /** 86 * Try two approaches to extract the XSD schema information from the CMDI file 87 * @param nav VTD Navigator 88 * @return ID of CMDI schema, or null if neither the CMDI header nor the XMLSchema-instance's attributes contained the information 89 * @throws VTDException 102 * Try two approaches to extract the XSD schema information from the CMDI 103 * file 104 * 105 * @param nav VTD Navigator 106 * @return ID of CMDI schema, or null if neither the CMDI header nor the 107 * XMLSchema-instance's attributes contained the information 108 * @throws VTDException 90 109 */ 91 110 String extractXsd(VTDNav nav) throws VTDException { … … 98 117 99 118 /** 100 * Extract XSD schema information from CMDI header (using element //Header/MdProfile) 101 * @param nav VTD Navigator 102 * @return ID of CMDI schema, or null if content of //Header/MdProfile element could not be read 119 * Extract XSD schema information from CMDI header (using element 120 * //Header/MdProfile) 121 * 122 * @param nav VTD Navigator 123 * @return ID of CMDI schema, or null if content of //Header/MdProfile 124 * element could not be read 103 125 * @throws XPathParseException 104 126 * @throws XPathEvalException 105 * @throws NavException 127 * @throws NavException 106 128 */ 107 129 private String getProfileIdFromHeader(VTDNav nav) throws XPathParseException, XPathEvalException, NavException { … … 119 141 120 142 /** 121 * Extract XSD schema information from schemaLocation or noNamespaceSchemaLocation attributes 143 * Extract XSD schema information from schemaLocation or 144 * noNamespaceSchemaLocation attributes 145 * 122 146 * @param nav VTD Navigator 123 147 * @return ID of CMDI schema, or null if attributes don't exist 124 * @throws NavException 148 * @throws NavException 125 149 */ 126 150 private String getProfileIdFromSchemaLocation(VTDNav nav) throws NavException { … … 137 161 } 138 162 } 139 163 140 164 // extract profile ID 141 if(result != null) { 142 Matcher m = PROFILE_ID_PATTERN.matcher(result); 143 if(m.find()) 144 return m.group(1); 165 if (result != null) { 166 Matcher m = PROFILE_ID_PATTERN.matcher(result); 167 if (m.find()) { 168 return m.group(1); 169 } 145 170 } 146 171 return null; 147 172 } 148 173 149 174 /** 150 175 * Extract ResourceProxies from ResourceProxyList 176 * 151 177 * @param cmdiData representation of the CMDI document 152 178 * @param nav VTD Navigator 153 * @throws VTDException 179 * @throws VTDException 154 180 */ 155 181 private void processResources(CMDIData cmdiData, VTDNav nav) throws VTDException { 156 182 AutoPilot mdSelfLink = new AutoPilot(nav); 183 setNameSpace(mdSelfLink); 184 mdSelfLink.selectXPath("/c:CMD/c:Header/c:MdSelfLink"); 185 String mdSelfLinkString = mdSelfLink.evalXPathToString(); 186 ResourceStructureGraph.addResource(mdSelfLinkString); 187 157 188 AutoPilot resourceProxy = new AutoPilot(nav); 158 189 setNameSpace(resourceProxy); 159 190 resourceProxy.selectXPath("/c:CMD/c:Resources/c:ResourceProxyList/c:ResourceProxy"); 160 191 161 192 AutoPilot resourceRef = new AutoPilot(nav); 162 193 setNameSpace(resourceRef); 163 194 resourceRef.selectXPath("c:ResourceRef"); 164 195 165 196 AutoPilot resourceType = new AutoPilot(nav); 166 197 setNameSpace(resourceType); 167 198 resourceType.selectXPath("c:ResourceType"); 168 199 169 200 AutoPilot resourceMimeType = new AutoPilot(nav); 170 201 setNameSpace(resourceMimeType); 171 202 resourceMimeType.selectXPath("c:ResourceType/@mimetype"); 172 203 173 204 while (resourceProxy.evalXPath() != -1) { 174 205 String ref = resourceRef.evalXPathToString(); 175 206 String type = resourceType.evalXPathToString(); 176 207 String mimeType = resourceMimeType.evalXPathToString(); 177 208 178 209 if (!ref.equals("") && !type.equals("")) { 179 210 // note that the mime type could be empty 180 211 cmdiData.addResource(ref, type, mimeType); 181 212 } 213 214 // resource hierarchy information? 215 if(type.toLowerCase().equals("metadata")) { 216 ResourceStructureGraph.addEdge(ref, mdSelfLinkString); 217 } 182 218 } 183 219 } … … 185 221 /** 186 222 * Extracts facet values according to the facetMapping 223 * 187 224 * @param cmdiData representation of the CMDI document 188 225 * @param nav VTD Navigator 189 226 * @param facetMapping the facet mapping used to map meta data to facets 190 * @throws VTDException 227 * @throws VTDException 191 228 */ 192 229 private void processFacets(CMDIData cmdiData, VTDNav nav, FacetMapping facetMapping) throws VTDException { … … 201 238 } 202 239 } 203 240 204 241 // using fallback patterns if extraction failed 205 242 if (matchedPattern == false) { … … 215 252 216 253 /** 217 * Extracts content from CMDI file for a specific facet based on a single XPath expression 254 * Extracts content from CMDI file for a specific facet based on a single 255 * XPath expression 256 * 218 257 * @param cmdiData representation of the CMDI document 219 258 * @param nav VTD Navigator 220 259 * @param config facet configuration 221 260 * @param pattern XPath expression 222 * @param allowMultipleValues information if multiple values are allowed in this facet 261 * @param allowMultipleValues information if multiple values are allowed in 262 * this facet 223 263 * @return pattern matched a node in the CMDI file? 224 * @throws VTDException 264 * @throws VTDException 225 265 */ 226 266 private boolean matchPattern(CMDIData cmdiData, VTDNav nav, FacetConfiguration config, String pattern, Boolean allowMultipleValues) throws VTDException { … … 237 277 } 238 278 String value = nav.toString(index); 239 279 240 280 // extract language code in xml:lang if available 241 281 Integer langAttrIndex = nav.getAttrVal("xml:lang"); 242 282 String languageCode = DEFAULT_LANGUAGE; 243 if (langAttrIndex != -1)283 if (langAttrIndex != -1) { 244 284 languageCode = nav.toString(langAttrIndex).trim(); 285 } 245 286 // replace 2-letter with 3-letter codes 246 if (MetadataImporter.languageCodeUtils.getSilToIso639Map().containsKey(languageCode))287 if (MetadataImporter.languageCodeUtils.getSilToIso639Map().containsKey(languageCode)) { 247 288 languageCode = MetadataImporter.languageCodeUtils.getSilToIso639Map().get(languageCode); 248 289 } 290 249 291 // ignore non-English language names for facet LANGUAGE_CODE 250 if (config.getName().equals(FacetConstants.FIELD_LANGUAGE_CODE) && !languageCode.equals("en") && !languageCode.equals("eng") && !languageCode.equals("und")) {292 if (config.getName().equals(FacetConstants.FIELD_LANGUAGE_CODE) && !languageCode.equals("en") && !languageCode.equals("eng") && !languageCode.equals("und")) { 251 293 index = ap.evalXPath(); 252 continue; 253 } 254 294 continue; 295 } 296 255 297 List<String> valueList = postProcess(config.getName(), value); 256 for (int i=0; i<valueList.size(); i++) {257 if (!allowMultipleValues && i>0)298 for (int i = 0; i < valueList.size(); i++) { 299 if (!allowMultipleValues && i > 0) { 258 300 break; 301 } 259 302 String fieldValue = valueList.get(i).trim(); 260 if(config.getName().equals(FacetConstants.FIELD_DESCRIPTION)) 261 fieldValue = "{lang='"+languageCode+"'}"+fieldValue; 303 if (config.getName().equals(FacetConstants.FIELD_DESCRIPTION)) { 304 fieldValue = "{lang='" + languageCode + "'}" + fieldValue; 305 } 262 306 cmdiData.addDocField(config.getName(), fieldValue, config.isCaseInsensitive()); 263 307 } 264 308 index = ap.evalXPath(); 265 266 if(!allowMultipleValues) 267 break; 309 310 if (!allowMultipleValues) { 311 break; 312 } 268 313 } 269 314 return matchedPattern; … … 272 317 /** 273 318 * Applies registered PostProcessor to extracted values 319 * 274 320 * @param facetName name of the facet for which value was extracted 275 321 * @param extractedValue extracted value from CMDI file 276 * @return value after applying matching PostProcessor or the original value if no PostProcessor was registered for the facet 322 * @return value after applying matching PostProcessor or the original value 323 * if no PostProcessor was registered for the facet 277 324 */ 278 325 private List<String> postProcess(String facetName, String extractedValue) { -
vlo/branches/vlo-ticket761/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/FacetMappingFactory.java
r5985 r6267 36 36 } 37 37 38 /** 39 * 40 * @param facetConceptsFile path to facet concepts file, leave null or empty to use default 41 * @param xsd 42 * @param useLocalXSDCache 43 * @return 44 */ 38 45 public static FacetMapping getFacetMapping(String facetConceptsFile, String xsd, Boolean useLocalXSDCache) { 39 46 return INSTANCE.getOrCreateMapping(facetConceptsFile, xsd, useLocalXSDCache); … … 166 173 config.setName(facetConcept.getName()); 167 174 168 config.setPatterns(xpaths); 175 LinkedHashSet<String> linkedHashSet = new LinkedHashSet<String>(xpaths); 176 if(xpaths.size() != linkedHashSet.size()) { 177 LOG.error("Duplicate XPaths in : "+xpaths); 178 } 179 config.setPatterns(new ArrayList<String>(linkedHashSet)); 169 180 config.setFallbackPatterns(facetConcept.getPatterns()); 170 181 -
vlo/branches/vlo-ticket761/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/IdPostProcessor.java
r5345 r6267 1 1 package eu.clarin.cmdi.vlo.importer; 2 2 3 import eu.clarin.cmdi.vlo.StringUtils; 3 4 import java.util.ArrayList; 4 import java.util.Arrays;5 import java.util.HashSet;6 5 import java.util.List; 7 import java.util.Set;8 6 9 7 public class IdPostProcessor implements PostProcessor { 10 8 11 private static final Set<Character> reservedCharacters = new HashSet<Character>(Arrays.asList('!', '*', '\'', '(',12 ')', ';', ':', '@', '&', '=', '+', '$', ',', '/', '?', '#', '[', ']'));13 14 9 /** 15 * Return normalized String where all reserved characters in URL encoding 16 * are replaced by their ASCII code (in underscores) 10 * Return normalized String 17 11 * 18 12 * @param value String that will be normalized 19 * @return normalized version of value where all reserved 20 * characters in URL encoding are replaced by their ASCII code 13 * @return normalized version of value 21 14 */ 22 15 @Override 23 16 public List<String> process(String value) { 24 StringBuilder normalizedString = new StringBuilder();25 for (int i = 0; i < value.length(); i++) {26 Character character = value.charAt(i);27 if (reservedCharacters.contains(character)) {28 normalizedString.append("_").append((int) character).append("_");29 } else {30 normalizedString.append(character);31 }32 }33 34 17 List<String> resultList = new ArrayList<String>(); 35 resultList.add( normalizedString.toString());18 resultList.add(StringUtils.normalizeIdString(value)); 36 19 return resultList; 37 20 } -
vlo/branches/vlo-ticket761/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/MetadataImporter.java
r6188 r6267 14 14 import java.text.SimpleDateFormat; 15 15 import java.util.ArrayList; 16 import java.util. Collection;16 import java.util.Arrays; 17 17 import java.util.Date; 18 18 import java.util.HashMap; 19 19 import java.util.HashSet; 20 import java.util.Iterator; 20 21 import java.util.List; 21 22 import java.util.Map; … … 137 138 } 138 139 CMDIDataProcessor processor = new CMDIParserVTDXML(POST_PROCESSORS, false); 139 List<File> files = getFilesFromDataRoot(dataRoot.getRootFile()); 140 for (File file : files) { 141 if (config.getMaxFileSize() > 0 142 && file.length() > config.getMaxFileSize()) { 143 LOG.info("Skipping " + file.getAbsolutePath() + " because it is too large."); 144 } else { 145 LOG.debug("PROCESSING FILE: {}", file.getAbsolutePath()); 146 processCmdi(file, dataRoot, processor); 140 List<List<File>> centreFilesList = getFilesFromDataRoot(dataRoot.getRootFile()); 141 // import files from every endpoint 142 for(List<File> centreFiles : centreFilesList) { 143 LOG.info("Processing directory: {}", centreFiles.get(0).getParent()); 144 for (File file : centreFiles) { 145 if (config.getMaxFileSize() > 0 146 && file.length() > config.getMaxFileSize()) { 147 LOG.info("Skipping " + file.getAbsolutePath() + " because it is too large."); 148 } else { 149 LOG.debug("PROCESSING FILE: {}", file.getAbsolutePath()); 150 processCmdi(file, dataRoot, processor); 151 } 147 152 } 148 } 149 if (!docs.isEmpty()) { 150 sendDocs(); 153 if (!docs.isEmpty()) { 154 sendDocs(); 155 } 156 updateDocumentHierarchy(); 151 157 } 152 158 LOG.info("End of processing: " + dataRoot.getOriginName()); … … 203 209 204 210 /** 205 * Get the rootFile orall files with VALID_CMDI_EXTENSIONS if rootFile is a206 * directory 211 * Get all files with VALID_CMDI_EXTENSIONS if rootFile is a 212 * directory that contains center directories or rootFile if it is a file 207 213 * 208 214 * @param rootFile 209 * @return List with the rootFile or all contained files if rootFile is a 210 * directory 211 */ 212 protected List<File> getFilesFromDataRoot(File rootFile) { 213 List<File> result = new ArrayList<File>(); 214 if (rootFile.isFile()) { 215 result.add(rootFile); 215 * @return List with centre Lists of all contained CMDI files if rootFile is a 216 * directory or rootFile if it is a File 217 */ 218 protected List<List<File>> getFilesFromDataRoot(File rootFile) { 219 List<List<File>> result = new ArrayList<List<File>>(); 220 if(rootFile.isFile()) { 221 List<File> singleFileList = new ArrayList<File>(); 222 singleFileList.add(rootFile); 223 result.add(singleFileList); 216 224 } else { 217 Collection<File> listFiles = FileUtils.listFiles(rootFile, VALID_CMDI_EXTENSIONS, true); 218 result.addAll(listFiles); 225 File[] centerDirs = rootFile.listFiles(); 226 for(File centerDir : centerDirs) { 227 List<File> centerFileList = new ArrayList<File>(); 228 if(centerDir.isDirectory()) { 229 centerFileList.addAll(FileUtils.listFiles(centerDir, VALID_CMDI_EXTENSIONS, true)); 230 } 231 232 if(!centerFileList.isEmpty()) 233 result.add(centerFileList); 234 } 219 235 } 220 236 return result; … … 436 452 } 437 453 454 /** 455 * Updates documents in Solr with their hierarchy weight and lists of related resources (hasPart & isPartOf) 456 * @throws SolrServerException 457 * @throws MalformedURLException 458 */ 459 private void updateDocumentHierarchy() throws SolrServerException, MalformedURLException, IOException { 460 LOG.info(ResourceStructureGraph.printStatistics(0)); 461 List<SolrInputDocument> updateDocs = new ArrayList<SolrInputDocument>(); 462 Iterator<CmdiVertex> vertexIter = ResourceStructureGraph.getFoundVertices().iterator(); 463 while(vertexIter.hasNext()) { 464 CmdiVertex vertex = vertexIter.next(); 465 List<String> incomingVertexNames = ResourceStructureGraph.getIncomingVertexNames(vertex); 466 List<String> outgoingVertexNames = ResourceStructureGraph.getOutgoingVertexNames(vertex); 467 468 // update vertex if changes are necessary (necessary if non-default weight or edges to other resources) 469 if(vertex.getHierarchyWeight() != 0 || !incomingVertexNames.isEmpty() || !outgoingVertexNames.isEmpty()) { 470 SolrInputDocument doc = new SolrInputDocument(); 471 doc.setField(FacetConstants.FIELD_ID, Arrays.asList(vertex.getId())); 472 473 if(vertex.getHierarchyWeight() != 0) { 474 Map<String, Integer> partialUpdate = new HashMap<String, Integer>(); 475 partialUpdate.put("set", Math.abs(vertex.getHierarchyWeight())); 476 doc.addField(FacetConstants.FIELD_HIERARCHY_WEIGHT, partialUpdate); 477 } 478 479 if(!incomingVertexNames.isEmpty()) { 480 Map<String, List<String>> partialUpdate = new HashMap<String, List<String>>(); 481 partialUpdate.put("set", incomingVertexNames); 482 doc.setField(FacetConstants.FIELD_HAS_PART, partialUpdate); 483 } 484 485 if(!outgoingVertexNames.isEmpty()) { 486 Map<String, List<String>> partialUpdate = new HashMap<String, List<String>>(); 487 partialUpdate.put("set", outgoingVertexNames); 488 doc.setField(FacetConstants.FIELD_IS_PART_OF, partialUpdate); 489 } 490 updateDocs.add(doc); 491 } 492 493 if (updateDocs.size() == config.getMaxDocsInList()) { 494 solrServer.add(updateDocs); 495 if (serverError != null) { 496 throw new SolrServerException(serverError); 497 } 498 updateDocs = new ArrayList<SolrInputDocument>(); 499 } 500 } 501 if(!updateDocs.isEmpty()) { 502 solrServer.add(updateDocs); 503 if (serverError != null) { 504 throw new SolrServerException(serverError); 505 } 506 } 507 solrServer.commit(); 508 509 ResourceStructureGraph.clearResourceGraph(); 510 } 511 438 512 public static VloConfig config; 439 513 -
vlo/branches/vlo-ticket761/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/TemporalCoveragePostProcessor.java
r6188 r6267 9 9 10 10 // Open Date Range Format 11 private static final Pattern ODRF_PATTERN = Pattern.compile(" (([0-9]{4}(-[0-9]{2})?(-[0-9]{2})?)?/([0-9]{4}(-[0-9]{2})?(-[0-9]{2})?)?)");12 // simple year13 private static final Pattern YEAR_PATTERN = Pattern.compile("([0-9]{4}(-[0-9]{2})?(-[0-9]{2})?)");11 private static final Pattern ODRF_PATTERN = Pattern.compile("^(([0-9]{4}(-[0-9]{2})?(-[0-9]{2})?)?/([0-9]{4}(-[0-9]{2})?(-[0-9]{2})?)?)"); 12 // Simplified W3C DateTime 13 private static final Pattern DATETIME_PATTERN = Pattern.compile("^([0-9]{4}(-[0-9]{2})?(-[0-9]{2})?)"); 14 14 15 15 /** 16 * Tries to identify relevant yearsubstrings in input16 * Tries to identify relevant temporal substrings in input 17 17 * 18 * @param value extracted yearor date range String18 * @param value extracted date or date range String 19 19 * @return List of accepted values 20 20 */ 21 21 @Override 22 22 public List<String> process(final String value) { 23 Matcher odrfMatcher = ODRF_PATTERN.matcher(value); 24 Matcher yearMatcher = YEAR_PATTERN.matcher(value); 23 String coverageString = value.trim(); 24 25 Matcher odrfMatcher = ODRF_PATTERN.matcher(coverageString); 26 Matcher yearMatcher = DATETIME_PATTERN.matcher(coverageString); 25 27 List<String> resultList = new ArrayList<String>(); 26 28 -
vlo/branches/vlo-ticket761/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/VLOMarshaller.java
r4029 r6267 1 1 package eu.clarin.cmdi.vlo.importer; 2 2 3 import eu.clarin.cmdi.vlo.config.VloConfig; 4 import java.io.FileInputStream; 5 import java.io.FileNotFoundException; 3 6 import java.io.InputStream; 4 7 import java.io.StringWriter; … … 8 11 import javax.xml.bind.Marshaller; 9 12 import javax.xml.bind.Unmarshaller; 13 import org.slf4j.Logger; 14 import org.slf4j.LoggerFactory; 10 15 11 16 public class VLOMarshaller { 12 17 18 private final static Logger logger = LoggerFactory.getLogger(VLOMarshaller.class); 19 13 20 /** 14 21 * Get facet concepts mapping from a facet concept mapping file 15 * 22 * 16 23 * @param facetConcepts name of the facet concepts file 17 24 * @return the facet concept mapping … … 20 27 String facetConcepts) { 21 28 22 InputStream inputStream = 23 VLOMarshaller.class.getResourceAsStream(facetConcepts); 24 25 return unmarshal(inputStream); 29 if (facetConcepts == null || "".equals(facetConcepts)) { 30 return unmarshal(VLOMarshaller.class.getResourceAsStream(VloConfig.DEFAULT_FACET_CONCEPTS_RESOURCE_FILE)); 31 } else { 32 try { 33 return unmarshal(new FileInputStream(facetConcepts)); 34 } catch (FileNotFoundException ex) { 35 logger.error("Could not find facets file: {}", facetConcepts); 36 return null; 37 } 38 } 26 39 } 27 40 28 41 /** 29 42 * Get object from input stream 30 * 43 * 31 44 * @param inputStream 32 * @return 45 * @return 33 46 */ 34 47 static FacetConceptMapping unmarshal(InputStream inputStream) { … … 46 59 /** 47 60 * Put facet mapping object in output file 48 * 61 * 49 62 * @param outputFile 50 * @return 63 * @return 51 64 */ 52 65 static String marshal(FacetConceptMapping outputFile) { -
vlo/branches/vlo-ticket761/vlo-importer/src/test/java/eu/clarin/cmdi/vlo/importer/CMDIDataProcessorTest.java
r6188 r6267 3 3 import eu.clarin.cmdi.vlo.FacetConstants; 4 4 import java.io.File; 5 import java.net.URL; 5 6 import java.util.ArrayList; 6 7 import java.util.Collection; … … 12 13 import static org.junit.Assert.assertNull; 13 14 import static org.junit.Assert.assertTrue; 15 import org.junit.Before; 14 16 import org.junit.Test; 15 17 … … 19 21 return new CMDIParserVTDXML(MetadataImporter.POST_PROCESSORS, true); 20 22 } 21 23 24 @Before 25 @Override 26 public void setup() throws Exception { 27 super.setup(); 28 // make sure the mapping file for testing is used 29 config.setFacetConceptsFile(getTestFacetConceptFilePath()); 30 } 31 22 32 @Test 23 33 public void testCreateCMDIDataFromCorpus() throws Exception { 24 25 // make sure the mapping file for testing is used26 config.setFacetConceptsFile("/facetConceptsTest.xml");27 28 34 String content = ""; 29 35 content += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; … … 86 92 @Test 87 93 public void testCreateCMDIDataFromSession() throws Exception { 88 89 // make sure the mapping file for testing is used90 config.setFacetConceptsFile("/facetConceptsTest.xml");91 92 94 String content = ""; 93 95 content += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; … … 412 414 @Test 413 415 public void testCreateCMDISessionSmall() throws Exception { 414 415 // make sure the mapping file for testing is used416 config.setFacetConceptsFile("/facetConceptsTest.xml");417 418 416 String content = ""; 419 417 content += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; … … 441 439 @Test 442 440 public void testEmptyFieldsShouldBeNull() throws Exception { 443 444 // make sure the mapping file for testing is used445 config.setFacetConceptsFile("/facetConceptsTest.xml");446 447 441 String content = ""; 448 442 content += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; … … 534 528 @Test 535 529 public void testOlac() throws Exception { 536 537 // make sure the mapping file for testing is used538 config.setFacetConceptsFile("/facetConceptsTest.xml");539 540 530 String content = ""; 541 531 content += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; … … 621 611 @Test 622 612 public void testOlacMultiFacets() throws Exception { 623 624 // make sure the mapping file for testing is used625 config.setFacetConceptsFile("/facetConceptsTest.xml");626 627 613 String content = ""; 628 614 content += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; … … 717 703 @Test 718 704 public void testIgnoreWhiteSpaceFacets() throws Exception { 719 720 // make sure the mapping file for testing is used721 config.setFacetConceptsFile("/facetConceptsTest.xml");722 723 705 String content = ""; 724 706 content += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; … … 743 725 @Test 744 726 public void testCountryCodesPostProcessing() throws Exception { 745 746 // make sure the mapping file for testing is used747 config.setFacetConceptsFile("/facetConceptsTest.xml");748 749 727 String content = ""; 750 728 content += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; … … 769 747 @Test 770 748 public void testLanguageCodesPostProcessing() throws Exception { 771 772 // make sure the mapping file for testing is used773 config.setFacetConceptsFile("/facetConceptsTest.xml");774 775 749 String content = ""; 776 750 content += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; … … 800 774 @Test 801 775 public void testOlacCollection() throws Exception { 802 803 // make sure the mapping file for testing is used804 config.setFacetConceptsFile("/facetConceptsTest.xml");805 806 776 String content = ""; 807 777 content += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; … … 853 823 @Test 854 824 public void testLrtCollection() throws Exception { 855 856 // make sure the mapping file for testing is used857 config.setFacetConceptsFile("/facetConceptsTest.xml");858 859 825 String content = ""; 860 826 content += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; -
vlo/branches/vlo-ticket761/vlo-importer/src/test/java/eu/clarin/cmdi/vlo/importer/FacetMappingFactoryTest.java
r6188 r6267 13 13 14 14 public class FacetMappingFactoryTest { 15 16 private final static String FACETCONCEPTS_FILENAME = "/facetConceptsTest.xml";17 15 16 private final static String FACETCONCEPTS_FILENAME = ImporterTestcase.getTestFacetConceptFilePath(); 17 18 18 private final static String IMDI_PROFILE_ID = "clarin.eu:cr1:p_1271859438204"; 19 19 private final static String OLAC_PROFILE_ID = "clarin.eu:cr1:p_1288172614026"; … … 28 28 FacetMapping facetMapping = FacetMappingFactory 29 29 .getFacetMapping(FACETCONCEPTS_FILENAME, IMDI_PROFILE_ID, true); 30 30 31 31 List<FacetConfiguration> facets = facetMapping.getFacets(); 32 32 assertEquals(20, facets.size()); 33 33 34 34 int index = 0; 35 35 FacetConfiguration mapping = facets.get(index++); 36 36 37 37 assertEquals(FacetConstants.FIELD_ID, mapping.getName()); 38 38 assertEquals(1, mapping.getPatterns().size()); 39 assertEquals("/c:CMD/c:Header/c:MdSelfLink/text()", 40 mapping.getPatterns().get(0)); 41 mapping = facets.get(index++); 42 39 assertEquals("/c:CMD/c:Header/c:MdSelfLink/text()", 40 mapping.getPatterns().get(0)); 41 mapping = facets.get(index++); 42 43 43 assertEquals(FacetConstants.FIELD_SELF_LINK, mapping.getName()); 44 44 assertEquals(0, mapping.getPatterns().size()); 45 45 assertEquals(1, mapping.getFallbackPatterns().size()); 46 assertEquals("/c:CMD/c:Header/c:MdSelfLink/text()", 47 mapping.getFallbackPatterns().get(0)); 48 mapping = facets.get(index++); 49 46 assertEquals("/c:CMD/c:Header/c:MdSelfLink/text()", 47 mapping.getFallbackPatterns().get(0)); 48 mapping = facets.get(index++); 49 50 50 assertEquals(FacetConstants.FIELD_COLLECTION, mapping.getName()); 51 51 assertEquals(1, mapping.getFallbackPatterns().size()); 52 52 mapping = facets.get(index++); 53 53 54 54 assertEquals(FacetConstants.FIELD_PROJECT_NAME, mapping.getName()); 55 55 assertEquals(2, mapping.getPatterns().size()); 56 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Project/c:Name/text()", 57 mapping.getPatterns().get(0)); 58 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Project/c:Title/text()", 59 mapping.getPatterns().get(1)); 60 mapping = facets.get(index++); 61 56 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Project/c:Name/text()", 57 mapping.getPatterns().get(0)); 58 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Project/c:Title/text()", 59 mapping.getPatterns().get(1)); 60 mapping = facets.get(index++); 61 62 62 assertEquals(FacetConstants.FIELD_NAME, mapping.getName()); 63 63 assertEquals(2, mapping.getPatterns().size()); 64 assertEquals("/c:CMD/c:Components/c:Session/c:Name/text()", 65 mapping.getPatterns().get(0)); 66 assertEquals("/c:CMD/c:Components/c:Session/c:Title/text()", 67 mapping.getPatterns().get(1)); 68 mapping = facets.get(index++); 69 64 assertEquals("/c:CMD/c:Components/c:Session/c:Name/text()", 65 mapping.getPatterns().get(0)); 66 assertEquals("/c:CMD/c:Components/c:Session/c:Title/text()", 67 mapping.getPatterns().get(1)); 68 mapping = facets.get(index++); 69 70 70 assertEquals(FacetConstants.FIELD_TEMPORAL_COVERAGE, mapping.getName()); 71 71 assertEquals(2, mapping.getPatterns().size()); 72 assertEquals("/c:CMD/c:Components/c:Session/c:Date/text()", 73 mapping.getPatterns().get(0)); 74 mapping = facets.get(index++); 75 72 assertEquals("/c:CMD/c:Components/c:Session/c:Date/text()", 73 mapping.getPatterns().get(0)); 74 mapping = facets.get(index++); 75 76 76 assertEquals(FacetConstants.FIELD_CONTINENT, mapping.getName()); 77 77 assertEquals(1, mapping.getPatterns().size()); 78 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Location/c:Continent/text()", 78 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Location/c:Continent/text()", 79 79 mapping.getPatterns() 80 80 .get(0)); 81 81 mapping = facets.get(index++); 82 82 83 83 assertEquals(FacetConstants.FIELD_COUNTRY, mapping.getName()); 84 84 assertEquals(1, mapping.getPatterns().size()); 85 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Location/c:Country/text()", 85 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Location/c:Country/text()", 86 86 mapping.getPatterns() 87 87 .get(0)); 88 88 mapping = facets.get(index++); 89 89 90 90 assertEquals(FacetConstants.FIELD_LANGUAGE_CODE, mapping.getName()); 91 91 assertEquals(2, mapping.getPatterns().size()); … … 95 95 // assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Actors/c:Actor/c:Actor_Languages/c:Actor_Language/c:Id/text()", 96 96 // mapping.getPatterns().get(1)); 97 assertEquals("/c:CMD/c:Components/c:Session/c:Resources/c:WrittenResource/c:LanguageId/text()", 98 mapping.getPatterns().get(1)); 99 mapping = facets.get(index++); 100 97 assertEquals("/c:CMD/c:Components/c:Session/c:Resources/c:WrittenResource/c:LanguageId/text()", 98 mapping.getPatterns().get(1)); 99 mapping = facets.get(index++); 100 101 101 assertEquals(FacetConstants.FIELD_ORGANISATION, mapping.getName()); 102 102 assertEquals(6, mapping.getPatterns().size()); 103 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Project/c:Contact/c:Organisation/text()", 103 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Project/c:Contact/c:Organisation/text()", 104 104 mapping.getPatterns().get(0)); 105 105 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Actors/c:Actor/c:Contact/c:Organisation/text()", … … 114 114 mapping.getPatterns().get(5)); 115 115 mapping = facets.get(index++); 116 116 117 117 assertEquals(FacetConstants.FIELD_GENRE, mapping.getName()); 118 118 assertEquals(2, mapping.getPatterns().size()); 119 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Content/c:Genre/text()", 120 mapping.getPatterns().get(0)); 121 mapping = facets.get(index++); 122 119 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Content/c:Genre/text()", 120 mapping.getPatterns().get(0)); 121 mapping = facets.get(index++); 122 123 123 assertEquals(FacetConstants.FIELD_MODALITY, mapping.getName()); 124 124 assertEquals(1, mapping.getPatterns().size()); 125 125 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Content/c:Modalities/text()", mapping.getPatterns().get(0)); 126 126 mapping = facets.get(index++); 127 127 128 128 assertEquals(FacetConstants.FIELD_SUBJECT, mapping.getName()); 129 129 assertEquals(1, mapping.getPatterns().size()); 130 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Content/c:Subject/text()", 131 mapping.getPatterns().get(0)); 132 mapping = facets.get(index++); 133 130 assertEquals("/c:CMD/c:Components/c:Session/c:MDGroup/c:Content/c:Subject/text()", 131 mapping.getPatterns().get(0)); 132 mapping = facets.get(index++); 133 134 134 assertEquals(FacetConstants.FIELD_DESCRIPTION, mapping.getName()); 135 135 assertEquals(18, mapping.getPatterns().size()); 136 assertEquals("/c:CMD/c:Components/c:Session/c:descriptions/c:Description/text()", 137 mapping.getPatterns().get(0)); 138 mapping = facets.get(index++); 139 136 assertEquals("/c:CMD/c:Components/c:Session/c:descriptions/c:Description/text()", 137 mapping.getPatterns().get(0)); 138 mapping = facets.get(index++); 139 140 140 assertEquals(FacetConstants.FIELD_RESOURCE_CLASS, mapping.getName()); 141 141 assertEquals(3, mapping.getFallbackPatterns().size()); 142 142 mapping = facets.get(index++); 143 143 144 144 assertEquals(FacetConstants.FIELD_FORMAT, mapping.getName()); 145 145 assertEquals(1, mapping.getPatterns().size()); 146 146 mapping = facets.get(index++); 147 148 assertEquals("/c:CMD/c:Header/c:MdCollectionDisplayName/text()", 149 mapping.getFallbackPatterns().get(0)); 150 assertEquals(1, mapping.getFallbackPatterns().size()); 151 mapping = facets.get(index++); 152 147 148 assertEquals("/c:CMD/c:Header/c:MdCollectionDisplayName/text()", 149 mapping.getFallbackPatterns().get(0)); 150 assertEquals(1, mapping.getFallbackPatterns().size()); 151 mapping = facets.get(index++); 152 153 153 assertEquals("/c:CMD/c:Header//text()", mapping.getFallbackPatterns().get(0)); 154 154 assertEquals("/c:CMD/c:Components//text()", mapping.getFallbackPatterns().get(1)); 155 155 assertEquals(2, mapping.getFallbackPatterns().size()); 156 156 mapping = facets.get(index++); 157 157 158 158 assertEquals("/c:CMD/c:Header/c:MdProfile/text()", mapping.getFallbackPatterns().get(0)); 159 159 assertEquals(1, mapping.getFallbackPatterns().size()); … … 162 162 // test keywords facet mapping 163 163 assertEquals(FacetConstants.FIELD_KEYWORDS, mapping.getName()); 164 assertEquals("/c:CMD/c:Components/c:mods/c:classification/text()", 164 assertEquals("/c:CMD/c:Components/c:mods/c:classification/text()", 165 165 mapping.getFallbackPatterns().get(0)); 166 166 assertEquals(3, mapping.getFallbackPatterns().size()); … … 173 173 FacetMapping facetMapping = FacetMappingFactory 174 174 .getFacetMapping(FACETCONCEPTS_FILENAME, OLAC_PROFILE_ID, true); 175 175 176 176 List<FacetConfiguration> facets = facetMapping.getFacets(); 177 177 assertEquals(18, facets.size()); 178 178 179 179 int index = 0; 180 180 FacetConfiguration mapping = facets.get(index++); 181 181 182 182 assertEquals(FacetConstants.FIELD_ID, mapping.getName()); 183 183 assertEquals(1, mapping.getPatterns().size()); 184 assertEquals("/c:CMD/c:Header/c:MdSelfLink/text()", 185 mapping.getPatterns().get(0)); 186 mapping = facets.get(index++); 187 184 assertEquals("/c:CMD/c:Header/c:MdSelfLink/text()", 185 mapping.getPatterns().get(0)); 186 mapping = facets.get(index++); 187 188 188 assertEquals(FacetConstants.FIELD_SELF_LINK, mapping.getName()); 189 189 assertEquals(0, mapping.getPatterns().size()); 190 190 assertEquals(1, mapping.getFallbackPatterns().size()); 191 assertEquals("/c:CMD/c:Header/c:MdSelfLink/text()", 192 mapping.getFallbackPatterns().get(0)); 193 mapping = facets.get(index++); 194 191 assertEquals("/c:CMD/c:Header/c:MdSelfLink/text()", 192 mapping.getFallbackPatterns().get(0)); 193 mapping = facets.get(index++); 194 195 195 assertEquals(FacetConstants.FIELD_COLLECTION, mapping.getName()); 196 196 assertEquals(1, mapping.getFallbackPatterns().size()); 197 assertEquals("/c:CMD/c:Header/c:MdCollectionDisplayName/text()", 198 mapping.getFallbackPatterns().get(0)); 199 mapping = facets.get(index++); 200 197 assertEquals("/c:CMD/c:Header/c:MdCollectionDisplayName/text()", 198 mapping.getFallbackPatterns().get(0)); 199 mapping = facets.get(index++); 200 201 201 assertEquals(FacetConstants.FIELD_PROJECT_NAME, mapping.getName()); 202 202 assertEquals(3, mapping.getFallbackPatterns().size()); 203 assertEquals("/c:CMD/c:Components/c:teiHeader/c:fileDesc/c:publicationStmt/c:publisher/c:orgName/c:orgName[@role=\"project\"]/text()", 204 mapping.getFallbackPatterns().get(0)); 205 mapping = facets.get(index++); 206 203 assertEquals("/c:CMD/c:Components/c:teiHeader/c:fileDesc/c:publicationStmt/c:publisher/c:orgName/c:orgName[@role=\"project\"]/text()", 204 mapping.getFallbackPatterns().get(0)); 205 mapping = facets.get(index++); 206 207 207 assertEquals(FacetConstants.FIELD_NAME, mapping.getName()); 208 208 assertEquals(1, mapping.getPatterns().size()); 209 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:title/text()", 210 mapping.getPatterns().get(0)); 211 mapping = facets.get(index++); 212 209 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:title/text()", 210 mapping.getPatterns().get(0)); 211 mapping = facets.get(index++); 212 213 213 assertEquals(FacetConstants.FIELD_TEMPORAL_COVERAGE, mapping.getName()); 214 214 assertEquals(3, mapping.getPatterns().size()); 215 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:created/text()", 216 mapping.getPatterns().get(0)); 217 mapping = facets.get(index++); 218 215 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:created/text()", 216 mapping.getPatterns().get(0)); 217 mapping = facets.get(index++); 218 219 219 assertEquals(FacetConstants.FIELD_COUNTRY, mapping.getName()); 220 220 assertEquals(0, mapping.getPatterns().size()); 221 221 assertEquals(2, mapping.getFallbackPatterns().size()); 222 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:spatial[@dcterms-type=\"ISO3166\"]/text()", 222 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:spatial[@dcterms-type=\"ISO3166\"]/text()", 223 223 mapping 224 224 .getFallbackPatterns().get(0)); 225 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:coverage[@dcterms-type=\"ISO3166\"]/text()", 225 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:coverage[@dcterms-type=\"ISO3166\"]/text()", 226 226 mapping 227 227 .getFallbackPatterns().get(1)); 228 228 mapping = facets.get(index++); 229 229 230 230 assertEquals(FacetConstants.FIELD_LANGUAGE_CODE, mapping.getName()); 231 231 assertEquals(1, mapping.getPatterns().size()); … … 234 234 assertEquals("/c:CMD/c:Components//c:OLAC-DcmiTerms/c:language/@olac-language", mapping.getFallbackPatterns().get(0)); 235 235 mapping = facets.get(index++); 236 236 237 237 assertEquals(FacetConstants.FIELD_ORGANISATION, mapping.getName()); 238 238 assertEquals(1, mapping.getPatterns().size()); 239 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:publisher/text()", 239 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:publisher/text()", 240 240 mapping.getPatterns().get(0)); 241 241 mapping = facets.get(index++); … … 243 243 assertEquals(FacetConstants.FIELD_GENRE, mapping.getName()); 244 244 assertEquals(4, mapping.getFallbackPatterns().size()); 245 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:type/@olac-linguistic-type", 246 mapping.getFallbackPatterns().get(0)); 247 assertEquals("/c:CMD/c:Components/c:mods/c:genre/text()", 245 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:type/@olac-linguistic-type", 246 mapping.getFallbackPatterns().get(0)); 247 assertEquals("/c:CMD/c:Components/c:mods/c:genre/text()", 248 248 mapping.getFallbackPatterns().get(1)); 249 249 mapping = facets.get(index++); … … 251 251 assertEquals(FacetConstants.FIELD_SUBJECT, mapping.getName()); 252 252 assertEquals(1, mapping.getPatterns().size()); 253 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:subject/text()", 253 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:subject/text()", 254 254 mapping.getPatterns().get(0)); 255 255 // assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:subject[@dcterms-type=\"LCSH\"]/text()", mapping.getPatterns().get(1)); 256 256 mapping = facets.get(index++); 257 257 258 258 assertEquals(FacetConstants.FIELD_DESCRIPTION, mapping.getName()); 259 259 assertEquals(1, mapping.getPatterns().size()); 260 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:description/text()", 261 mapping.getPatterns().get(0)); 262 mapping = facets.get(index++); 263 260 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:description/text()", 261 mapping.getPatterns().get(0)); 262 mapping = facets.get(index++); 263 264 264 assertEquals(FacetConstants.FIELD_RESOURCE_CLASS, mapping.getName()); 265 assertEquals(1, mapping.getPatterns().size()); 266 mapping = facets.get(index++); 267 265 assertEquals(1, mapping.getPatterns().size()); 266 mapping = facets.get(index++); 267 268 268 assertEquals(FacetConstants.FIELD_FORMAT, mapping.getName()); 269 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:format/text()", 270 mapping.getPatterns().get(0)); 271 assertEquals(1, mapping.getPatterns().size()); 272 mapping = facets.get(index++); 273 269 assertEquals("/c:CMD/c:Components/c:OLAC-DcmiTerms/c:format/text()", 270 mapping.getPatterns().get(0)); 271 assertEquals(1, mapping.getPatterns().size()); 272 mapping = facets.get(index++); 273 274 274 assertEquals(FacetConstants.FIELD_NATIONAL_PROJECT, mapping.getName()); 275 275 assertEquals(1, mapping.getFallbackPatterns().size()); 276 276 mapping = facets.get(index++); 277 278 277 279 278 assertEquals("/c:CMD/c:Header//text()", mapping.getFallbackPatterns().get(0)); … … 281 280 assertEquals(2, mapping.getFallbackPatterns().size()); 282 281 mapping = facets.get(index++); 283 284 282 285 283 assertEquals("/c:CMD/c:Header/c:MdProfile/text()", mapping.getFallbackPatterns().get(0)); 286 284 assertEquals(1, mapping.getFallbackPatterns().size()); … … 288 286 289 287 assertEquals(FacetConstants.FIELD_KEYWORDS, mapping.getName()); 290 assertEquals("/c:CMD/c:Components/c:mods/c:classification/text()", 288 assertEquals("/c:CMD/c:Components/c:mods/c:classification/text()", 291 289 mapping.getFallbackPatterns().get(0)); 292 290 assertEquals(3, mapping.getFallbackPatterns().size()); … … 302 300 List<FacetConfiguration> facets = facetMapping.getFacets(); 303 301 assertEquals(17, facets.size()); 304 302 305 303 int index = 0; 306 304 FacetConfiguration mapping = facets.get(index++); 307 305 308 306 assertEquals(FacetConstants.FIELD_ID, mapping.getName()); 309 307 assertEquals(1, mapping.getPatterns().size()); 310 311 assertEquals("/c:CMD/c:Header/c:MdSelfLink/text()", 312 mapping.getPatterns().get(0)); 313 mapping = facets.get(index++); 314 308 309 assertEquals("/c:CMD/c:Header/c:MdSelfLink/text()", 310 mapping.getPatterns().get(0)); 311 mapping = facets.get(index++); 312 315 313 assertEquals(FacetConstants.FIELD_SELF_LINK, mapping.getName()); 316 314 assertEquals(0, mapping.getPatterns().size()); 317 315 assertEquals(1, mapping.getFallbackPatterns().size()); 318 assertEquals("/c:CMD/c:Header/c:MdSelfLink/text()", 319 mapping.getFallbackPatterns().get(0)); 320 mapping = facets.get(index++); 321 316 assertEquals("/c:CMD/c:Header/c:MdSelfLink/text()", 317 mapping.getFallbackPatterns().get(0)); 318 mapping = facets.get(index++); 319 322 320 assertEquals(FacetConstants.FIELD_COLLECTION, mapping.getName()); 323 321 assertEquals(1, mapping.getFallbackPatterns().size()); 324 322 mapping = facets.get(index++); 325 323 326 324 assertEquals(FacetConstants.FIELD_PROJECT_NAME, mapping.getName()); 327 325 assertEquals(3, mapping.getFallbackPatterns().size()); 328 326 assertEquals("/c:CMD/c:Components/c:media-session-profile/c:media-session/c:Corpus", mapping.getFallbackPatterns().get(1)); 329 327 mapping = facets.get(index++); 330 328 331 329 assertEquals(FacetConstants.FIELD_NAME, mapping.getName()); 332 330 assertEquals(6, mapping.getFallbackPatterns().size()); 333 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtCommon/c:ResourceName/text()", 334 mapping.getFallbackPatterns().get(0)); 335 assertEquals("/c:CMD/c:Components/c:mods/c:titleInfo/title/text()", 331 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtCommon/c:ResourceName/text()", 332 mapping.getFallbackPatterns().get(0)); 333 assertEquals("/c:CMD/c:Components/c:mods/c:titleInfo/title/text()", 336 334 mapping.getFallbackPatterns().get(1)); 337 335 mapping = facets.get(index++); 338 336 339 337 assertEquals(FacetConstants.FIELD_TEMPORAL_COVERAGE, mapping.getName()); 340 338 assertEquals(3, mapping.getPatterns().size()); … … 342 340 "/c:CMD/c:Components/c:LrtInventoryResource/c:LrtCommon/c:FinalizationYearResourceCreation/text()", 343 341 mapping.getPatterns().get(0)); 344 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtLexiconDetails/c:Date/text()", 345 mapping.getPatterns().get(1)); 346 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtServiceDetails/c:Date/text()", 342 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtLexiconDetails/c:Date/text()", 343 mapping.getPatterns().get(1)); 344 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtServiceDetails/c:Date/text()", 347 345 mapping.getPatterns().get(2)); 348 346 mapping = facets.get(index++); 349 347 350 348 assertEquals(FacetConstants.FIELD_COUNTRY, mapping.getName()); 351 349 assertEquals(2, mapping.getPatterns().size()); 352 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtCommon/c:Countries/c:Country/text()", 350 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtCommon/c:Countries/c:Country/text()", 353 351 mapping.getPatterns().get(0)); 354 352 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtCommon/c:Countries/c:Country/c:Code/text()", 355 353 mapping.getPatterns().get(1)); 356 354 mapping = facets.get(index++); 357 355 358 356 assertEquals(FacetConstants.FIELD_LANGUAGE_CODE, mapping.getName()); 359 357 … … 366 364 mapping.getPatterns().get(0)); 367 365 mapping = facets.get(index++); 368 366 369 367 assertEquals(FacetConstants.FIELD_ORGANISATION, mapping.getName()); 370 368 assertEquals(1, mapping.getPatterns().size()); 371 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtCommon/c:Institute/text()", 369 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtCommon/c:Institute/text()", 372 370 mapping.getPatterns() 373 371 .get(0)); 374 372 mapping = facets.get(index++); 375 373 376 374 assertEquals(FacetConstants.FIELD_GENRE, mapping.getName()); 377 375 assertEquals(4, mapping.getFallbackPatterns().size()); 378 376 mapping = facets.get(index++); 379 377 380 378 assertEquals(FacetConstants.FIELD_SUBJECT, mapping.getName()); 381 379 assertEquals(8, mapping.getFallbackPatterns().size()); 382 380 mapping = facets.get(index++); 383 381 384 382 assertEquals(FacetConstants.FIELD_DESCRIPTION, mapping.getName()); 385 383 assertEquals(2, mapping.getPatterns().size()); 386 384 assertEquals(5, mapping.getFallbackPatterns().size()); 387 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtCommon/c:Description/text()", 385 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtCommon/c:Description/text()", 388 386 mapping.getPatterns().get(0)); 389 387 assertEquals("/c:CMD/c:Components/c:mods/c:abstract/text()", mapping.getFallbackPatterns().get(0)); 390 388 mapping = facets.get(index++); 391 389 392 390 assertEquals(FacetConstants.FIELD_RESOURCE_CLASS, mapping.getName()); 393 391 assertEquals(1, mapping.getPatterns().size()); 394 392 assertEquals(3, mapping.getFallbackPatterns().size()); 395 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtCommon/c:ResourceType/text()", 396 mapping.getFallbackPatterns().get(0)); 397 mapping = facets.get(index++); 398 399 assertEquals("/c:CMD/c:Header/c:MdCollectionDisplayName/text()", 400 mapping.getFallbackPatterns().get(0)); 401 assertEquals(1, mapping.getFallbackPatterns().size()); 402 mapping = facets.get(index++); 403 393 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:LrtCommon/c:ResourceType/text()", 394 mapping.getFallbackPatterns().get(0)); 395 mapping = facets.get(index++); 396 397 assertEquals("/c:CMD/c:Header/c:MdCollectionDisplayName/text()", 398 mapping.getFallbackPatterns().get(0)); 399 assertEquals(1, mapping.getFallbackPatterns().size()); 400 mapping = facets.get(index++); 401 404 402 assertEquals("/c:CMD/c:Header//text()", mapping.getFallbackPatterns().get(0)); 405 403 assertEquals("/c:CMD/c:Components//text()", mapping.getFallbackPatterns().get(1)); 406 404 assertEquals(2, mapping.getFallbackPatterns().size()); 407 405 mapping = facets.get(index++); 408 406 409 407 assertEquals("/c:CMD/c:Header/c:MdProfile/text()", mapping.getFallbackPatterns().get(0)); 410 408 assertEquals(1, mapping.getFallbackPatterns().size()); 411 409 mapping = facets.get(index++); 412 410 413 411 assertEquals(FacetConstants.FIELD_KEYWORDS, mapping.getName()); 414 412 assertEquals(1, mapping.getPatterns().size()); 415 413 assertEquals(3, mapping.getFallbackPatterns().size()); 416 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:tags/c:tag/text()", 417 mapping.getPatterns().get(0)); 418 assertEquals("/c:CMD/c:Components/c:mods/c:classification/text()", 414 assertEquals("/c:CMD/c:Components/c:LrtInventoryResource/c:tags/c:tag/text()", 415 mapping.getPatterns().get(0)); 416 assertEquals("/c:CMD/c:Components/c:mods/c:classification/text()", 419 417 mapping.getFallbackPatterns().get(0)); 420 418 assertEquals("check to see we tested them all", facets.size(), index); … … 428 426 429 427 List<FacetConfiguration> facets = facetMapping.getFacets(); 430 428 431 429 FacetConfiguration facet = facets.get(0); 432 430 433 431 assertEquals(FacetConstants.FIELD_ID, facet.getName()); 434 432 assertEquals(2, facet.getPatterns().size()); 435 433 assertEquals("/c:CMD/c:Header/c:MdSelfLink/text()", facet.getPatterns().get(0)); 436 assertEquals("/c:CMD/c:Components/c:EastRepublican/c:GeneralInformation/c:Identifier/text()", 434 assertEquals("/c:CMD/c:Components/c:EastRepublican/c:GeneralInformation/c:Identifier/text()", 437 435 facet.getPatterns().get(1)); 438 436 } 439 437 440 438 /** 441 * Tests black/white listing approach based on acceptableContext/rejectableContext information in facetconcepts.xml 442 * 439 * Tests black/white listing approach based on 440 * acceptableContext/rejectableContext information in facetconcepts.xml 441 * 443 442 * Not in use right now, therefore contains just a dummy test. 444 443 */ 445 444 @Test 446 445 public void testConceptBasedBlacklisting() { 447 assertTrue(true);448 } 449 446 assertTrue(true); 447 } 448 450 449 /** 451 * Tests black/white listing approach based on acceptableContext/rejectableContext information in configuration 450 * Tests black/white listing approach based on 451 * acceptableContext/rejectableContext information in configuration 452 452 */ 453 453 @Test … … 456 456 .getFacetMapping(FACETCONCEPTS_FILENAME, TEXTCORPUSPROFILE_PROFILE_ID, true); 457 457 List<FacetConfiguration> facets = facetMapping.getFacets(); 458 458 459 459 FacetConfiguration facet = facets.get(5); 460 460 assertEquals(FacetConstants.FIELD_TEMPORAL_COVERAGE, facet.getName()); … … 462 462 assertEquals("/c:CMD/c:Components/c:TextCorpusProfile/c:GeneralInfo/c:CompletionYear/text()", facet.getPatterns().get(0)); 463 463 assertEquals("/c:CMD/c:Components/c:TextCorpusProfile/c:GeneralInfo/c:PublicationDate/text()", facet.getPatterns().get(1)); 464 465 464 466 465 facet = facets.get(13); 467 466 assertEquals(FacetConstants.FIELD_DESCRIPTION, facet.getName()); 468 467 assertEquals(1, facet.getPatterns().size()); 469 assertEquals("/c:CMD/c:Components/c:TextCorpusProfile/c:GeneralInfo/c:Descriptions/c:Description/text()" ,facet.getPatterns().get(0));468 assertEquals("/c:CMD/c:Components/c:TextCorpusProfile/c:GeneralInfo/c:Descriptions/c:Description/text()", facet.getPatterns().get(0)); 470 469 } 471 470 } -
vlo/branches/vlo-ticket761/vlo-importer/src/test/java/eu/clarin/cmdi/vlo/importer/ImporterTestcase.java
r5997 r6267 7 7 import java.io.File; 8 8 import java.io.IOException; 9 import java.net.URISyntaxException; 9 10 import org.apache.commons.io.FileUtils; 10 11 import org.junit.After; … … 40 41 MetadataImporter.config.setComponentRegistryRESTURL("http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/"); 41 42 config = MetadataImporter.config; 42 43 43 44 MetadataImporter.languageCodeUtils = new LanguageCodeUtils(config); 44 45 } 45 46 47 public static String getTestFacetConceptFilePath() { 48 try { 49 return new File(ImporterTestcase.class.getResource("/facetConceptsTest.xml").toURI()).getAbsolutePath(); 50 } catch (URISyntaxException ex) { 51 throw new RuntimeException(ex); 52 } 53 } 54 46 55 } -
vlo/branches/vlo-ticket761/vlo-importer/src/test/java/eu/clarin/cmdi/vlo/importer/MetadataImporterTest.java
r5979 r6267 47 47 File sessionFile = createCmdiFile("testSession", session); 48 48 49 String content = ""; 50 content += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; 51 content += "<CMD xmlns=\"http://www.clarin.eu/cmd/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.clarin.eu/cmd http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/clarin.eu:cr1:p_1274880881885/xsd\">\n"; 52 content += " <Header>\n"; 53 content += " <MdSelfLink>testID2</MdSelfLink>\n"; 54 content += " </Header>\n"; 55 content += " <Resources>\n"; 56 content += " <ResourceProxyList>\n"; 57 content += " <ResourceProxy id=\"d28635e19\">\n"; 58 content += " <ResourceType>Metadata</ResourceType>\n"; 59 content += " <ResourceRef>" + sessionFile.getName() + "</ResourceRef>\n"; 60 content += " </ResourceProxy>\n"; 61 content += " </ResourceProxyList>\n"; 62 content += " </Resources>\n"; 63 content += " <Components>\n"; 64 content += " <imdi-corpus>\n"; 65 content += " <Corpus>\n"; 66 content += " <Name>MPI corpora</Name>\n"; 67 content += " </Corpus>\n"; 68 content += " </imdi-corpus>\n"; 69 content += " </Components>\n"; 70 content += "</CMD>\n"; 71 File rootFile = createCmdiFile("rootFile", content); 72 73 List<SolrInputDocument> docs = importData(rootFile.getParentFile()); 49 List<SolrInputDocument> docs = importData(sessionFile); 74 50 assertEquals(1, docs.size()); 75 51 SolrInputDocument doc = docs.get(0); … … 261 237 262 238 // make sure the mapping file for testing is used 263 config.setFacetConceptsFile( "/facetConceptsTest.xml");239 config.setFacetConceptsFile(getTestFacetConceptFilePath()); 264 240 265 241 List<DataRoot> dataRoots = checkDataRoots(); … … 273 249 CMDIParserVTDXML(POST_PROCESSORS, true); 274 250 List<File> files = 275 getFilesFromDataRoot(dataRoot.getRootFile()) ;251 getFilesFromDataRoot(dataRoot.getRootFile()).get(0); 276 252 for (File file : files) { 277 253 if (config.getMaxFileSize () > 0 -
vlo/branches/vlo-ticket761/vlo-importer/src/test/java/eu/clarin/cmdi/vlo/importer/TemporalCoveragePostProcessorTest.java
r6188 r6267 2 2 3 3 import static org.junit.Assert.assertEquals; 4 import static org.junit.Assert.assertNull;5 4 import org.junit.Test; 6 5 … … 12 11 assertEquals("/2012", processor.process("/2012").get(0)); 13 12 assertEquals("2012-02", processor.process("2012-02").get(0)); 13 assertEquals("1997-07-16/1997-07-17", processor.process("1997-07-16/1997-07-17").get(0)); 14 assertEquals("1994-11-05", processor.process("1994-11-05T08:15:30-05:00").get(0)); 15 assertEquals(0, processor.process("northlimit=-16.4933; southlimit=-16.5617; westlimit=167.419; eastlimit=167.46").size()); 14 16 assertEquals(0, processor.process("1. November").size()); 15 17 } -
vlo/branches/vlo-ticket761/vlo-solr/pom.xml
r5991 r6267 4 4 <groupId>eu.clarin.cmdi</groupId> 5 5 <artifactId>vlo</artifactId> 6 <version>3. 2-SNAPSHOT</version>6 <version>3.3-SNAPSHOT</version> 7 7 </parent> 8 8 … … 10 10 <groupId>eu.clarin.cmdi</groupId> 11 11 <artifactId>vlo-solr</artifactId> 12 <version>3. 2-SNAPSHOT</version>12 <version>3.3-SNAPSHOT</version> 13 13 <packaging>war</packaging> 14 14 -
vlo/branches/vlo-ticket761/vlo-solr/src/main/solr_conf/solr/collection1/conf/schema.xml
r6188 r6267 447 447 <field name="_lastSeen" type="tdate" indexed="true" stored="true" multiValued="false" /> 448 448 <field name="_searchPageRef" type="string" indexed="true" stored="true" multiValued="true" /> 449 <field name="_isPartOf" type="string" indexed="true" stored="true" multiValued="true" /> 450 <field name="_hasPart" type="string" indexed="true" stored="true" multiValued="true" /> 451 <field name="_hierarchyWeight" type="int" indexed="true" stored="true" multiValued="false" default='0'/> 449 452 <field name="metadataSource" type="metadataSource" indexed="false" stored="true" multiValued="true" /> 453 454 <!-- Field _version_ for update log (needed for partial updates) --> 455 <field name="_version_" type="long" indexed="true" stored="true"/> 450 456 451 457 <!-- Field for autocompletion (suggester) --> -
vlo/branches/vlo-ticket761/vlo-web-app
- Property svn:ignore
-
old new 1 1 target 2 nbactions-development_clone.xml
-
- Property svn:ignore
-
vlo/branches/vlo-ticket761/vlo-web-app/pom.xml
r6002 r6267 7 7 <groupId>eu.clarin.cmdi</groupId> 8 8 <artifactId>vlo</artifactId> 9 <version>3. 2-SNAPSHOT</version>9 <version>3.3-SNAPSHOT</version> 10 10 </parent> 11 11 … … 14 14 <artifactId>vlo-web-app</artifactId> 15 15 <packaging>war</packaging> 16 <version>3. 2-SNAPSHOT</version>16 <version>3.3-SNAPSHOT</version> 17 17 <name>VLO Web Application</name> 18 18 <description></description> … … 21 21 <wicket.version>6.19.0</wicket.version> 22 22 <spring.version>3.2.13.RELEASE</spring.version> 23 <jetty.version>8.1.1 6.v20140903</jetty.version>23 <jetty.version>8.1.17.v20150415</jetty.version> 24 24 <!-- selects the appender for the log4j root logger --> 25 25 <log4j.appender>File</log4j.appender> … … 150 150 <groupId>com.sun.jersey</groupId> 151 151 <artifactId>jersey-client</artifactId> 152 <version>1.1 8.3</version>152 <version>1.19</version> 153 153 </dependency> 154 154 <dependency> 155 155 <groupId>org.apache.commons</groupId> 156 156 <artifactId>commons-lang3</artifactId> 157 <version>3. 3.2</version>157 <version>3.4</version> 158 158 <scope>test</scope> 159 159 <type>jar</type> … … 163 163 <groupId>net.bull.javamelody</groupId> 164 164 <artifactId>javamelody-core</artifactId> 165 <version>1.5 5.0</version>165 <version>1.56.0</version> 166 166 <exclusions> 167 167 <exclusion> … … 174 174 </exclusion> 175 175 </exclusions> 176 </dependency> 177 <dependency> 178 <groupId>nl.mpi.corpusstructure</groupId> 179 <artifactId>corpus-structure-2-core</artifactId> 180 <version>1.1.6</version> 176 181 </dependency> 177 182 </dependencies> … … 297 302 <groupId>org.codehaus.mojo</groupId> 298 303 <artifactId>cobertura-maven-plugin</artifactId> 299 <version>2. 6</version>304 <version>2.7</version> 300 305 <configuration> 301 306 <formats> … … 331 336 <groupId>org.codehaus.mojo</groupId> 332 337 <artifactId>cobertura-maven-plugin</artifactId> 333 <version>2. 6</version>338 <version>2.7</version> 334 339 </plugin> 335 340 </plugins> -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/VloWicketApplication.java
r6046 r6267 1 1 package eu.clarin.cmdi.vlo; 2 2 3 import eu.clarin.cmdi.vlo.service.FacetDescriptionService; 3 4 import eu.clarin.cmdi.vlo.config.VloConfig; 5 import eu.clarin.cmdi.vlo.service.PermalinkService; 4 6 import eu.clarin.cmdi.vlo.service.XmlTransformationService; 5 7 import eu.clarin.cmdi.vlo.service.solr.SolrDocumentService; … … 40 42 @Inject 41 43 private FieldValueConverterProvider fieldValueConverterProvider; 44 @Inject 45 private FacetDescriptionService facetDescriptionService; 46 @Inject 47 private PermalinkService permalinkService; 42 48 @Inject 43 49 private VloConfig vloConfig; … … 148 154 return cmdiTransformationService; 149 155 } 150 156 151 157 public FieldValueConverterProvider getFieldValueConverterProvider() { 152 158 return fieldValueConverterProvider; 153 159 } 154 160 161 public FacetDescriptionService getFacetDescriptionService() { 162 return facetDescriptionService; 163 } 164 165 public PermalinkService getPermalinkService() { 166 return permalinkService; 167 } 168 155 169 } -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/config/VloServicesSpringConfig.java
r6023 r6267 19 19 import com.google.common.collect.Sets; 20 20 import eu.clarin.cmdi.vlo.LanguageCodeUtils; 21 import eu.clarin.cmdi.vlo.facets.FacetConceptsMarshaller; 21 22 import eu.clarin.cmdi.vlo.pojo.QueryFacetsSelection; 22 23 import eu.clarin.cmdi.vlo.pojo.SearchContext; 24 import eu.clarin.cmdi.vlo.service.FacetDescriptionService; 23 25 import eu.clarin.cmdi.vlo.service.FacetParameterMapper; 24 26 import eu.clarin.cmdi.vlo.service.FieldFilter; 25 27 import eu.clarin.cmdi.vlo.service.PageParametersConverter; 28 import eu.clarin.cmdi.vlo.service.PermalinkService; 26 29 import eu.clarin.cmdi.vlo.service.ResourceStringConverter; 27 30 import eu.clarin.cmdi.vlo.service.ResourceTypeCountingService; 28 31 import eu.clarin.cmdi.vlo.service.UriResolver; 29 32 import eu.clarin.cmdi.vlo.service.XmlTransformationService; 30 import eu.clarin.cmdi.vlo.service.handle.HandleClient;31 import eu.clarin.cmdi.vlo.service.handle.impl.HandleRestApiClient;32 33 import eu.clarin.cmdi.vlo.service.impl.DocumentParametersConverter; 33 34 import eu.clarin.cmdi.vlo.service.impl.ExclusiveFieldFilter; 35 import eu.clarin.cmdi.vlo.service.impl.FacetDescriptionServiceImpl; 34 36 import eu.clarin.cmdi.vlo.service.impl.FacetParameterMapperImpl; 35 37 import eu.clarin.cmdi.vlo.service.impl.InclusiveFieldFilter; 38 import eu.clarin.cmdi.vlo.service.impl.PermalinkServiceImpl; 36 39 import eu.clarin.cmdi.vlo.service.impl.QueryFacetsSelectionParametersConverter; 37 40 import eu.clarin.cmdi.vlo.service.impl.ResourceStringConverterImpl; … … 44 47 import java.util.Properties; 45 48 import javax.inject.Inject; 49 import javax.xml.bind.JAXBException; 46 50 import javax.xml.transform.OutputKeys; 47 51 import javax.xml.transform.Source; 48 52 import javax.xml.transform.TransformerConfigurationException; 49 53 import javax.xml.transform.stream.StreamSource; 54 import nl.mpi.archiving.corpusstructure.core.handle.CachingHandleResolver; 55 import nl.mpi.archiving.corpusstructure.core.handle.HandleApiResolver; 56 import nl.mpi.archiving.corpusstructure.core.handle.HandleResolver; 57 import nl.mpi.archiving.corpusstructure.core.handle.HttpHandleResolver; 50 58 import org.apache.solr.common.SolrDocument; 51 59 import org.springframework.context.annotation.Bean; … … 61 69 public class VloServicesSpringConfig { 62 70 71 /** 72 * Handle resolution cache expiry in seconds 73 */ 74 private static final int HANDLE_CACHE_EXPIRY = 3600; 75 63 76 @Inject 64 77 VloConfig vloConfig; 65 78 66 79 @Bean 67 80 public ResourceTypeCountingService resourceTypeCountingService() { 68 81 return new ResourceTypeCountingServiceImpl(resourceStringConverter()); 69 82 } 70 83 71 84 @Bean(name = "resourceStringConverter") 72 85 public ResourceStringConverter resourceStringConverter() { 73 86 return new ResourceStringConverterImpl(); 74 87 } 75 88 76 89 @Bean(name = "resolvingResourceStringConverter") 77 90 public ResourceStringConverter resolvingResourceStringConverter() { 78 91 return new ResourceStringConverterImpl(uriResolver()); 79 92 } 80 93 81 94 @Bean 82 95 public UriResolver uriResolver() { 83 return new UriResolverImpl(handle Client());96 return new UriResolverImpl(handleResolver()); 84 97 } 85 86 public Handle Client handleClient() {87 return new HandleRestApiClient();98 99 public HandleResolver handleResolver() { 100 return new CachingHandleResolver(new HttpHandleResolver(), HANDLE_CACHE_EXPIRY); 88 101 } 89 102 … … 92 105 return new FacetParameterMapperImpl(languageCodeUtils()); 93 106 } 94 107 95 108 @Bean(name = "queryParametersConverter") 96 109 public PageParametersConverter<QueryFacetsSelection> queryParametersConverter() { 97 110 return new QueryFacetsSelectionParametersConverter(vloConfig, facetParameterMapper()); 98 111 } 99 112 100 113 @Bean(name = "documentParamsConverter") 101 114 public PageParametersConverter<SolrDocument> documentParamsConverter() { 102 115 return new DocumentParametersConverter(); 103 116 } 104 117 105 118 @Bean(name = "searchContextParamsConverter") 106 119 public PageParametersConverter<SearchContext> searchContextParamsConverter() { 107 120 return new SearchContextParametersConverter(queryParametersConverter()); 108 121 } 109 122 110 123 @Bean 111 124 public XmlTransformationService cmdiTransformationService() throws TransformerConfigurationException { … … 118 131 return new XmlTransformationServiceImpl(xsltSource, transformationProperties); 119 132 } 120 133 121 134 @Bean(name = "basicPropertiesFilter") 122 135 public FieldFilter basicPropertiesFieldFilter() { … … 125 138 vloConfig.getTechnicalFields())); 126 139 } 127 140 128 141 @Bean(name = "searchResultPropertiesFilter") 129 142 public FieldFilter searchResultPropertiesFilter() { 130 143 return new InclusiveFieldFilter(vloConfig.getSearchResultFields()); 131 144 } 132 145 133 146 @Bean(name = "technicalPropertiesFilter") 134 147 public FieldFilter technicalPropertiesFieldFilter() { … … 136 149 vloConfig.getTechnicalFields()); 137 150 } 138 151 139 152 @Bean 140 153 public LanguageCodeUtils languageCodeUtils() { 141 154 return new LanguageCodeUtils(vloConfig); 142 155 } 143 156 144 157 @Bean 145 158 public FieldValueConverterProvider fieldValueConverters() { 146 159 return new FieldValueConverterProviderImpl(languageCodeUtils()); 147 160 } 148 161 162 @Bean 163 public FacetDescriptionService facetDescriptionsService() throws JAXBException { 164 return new FacetDescriptionServiceImpl(facetConceptsMarshaller(), vloConfig); 165 } 166 167 @Bean 168 public FacetConceptsMarshaller facetConceptsMarshaller() throws JAXBException { 169 return new FacetConceptsMarshaller(); 170 } 171 172 @Bean 173 public PermalinkService permalinkService() { 174 return new PermalinkServiceImpl(queryParametersConverter()); 175 } 176 149 177 } -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/config/VloSolrSpringConfig.java
r6087 r6267 118 118 FacetConstants.FIELD_LAST_SEEN, 119 119 FacetConstants.FIELD_CLARIN_PROFILE, 120 FacetConstants.FIELD_COMPLETE_METADATA 120 FacetConstants.FIELD_COMPLETE_METADATA, 121 FacetConstants.FIELD_SOLR_SCORE 121 122 ); 122 123 } -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/service/impl/UriResolverImpl.java
r5027 r6267 1 1 /* 2 * Copyright (C) 201 4CLARIN2 * Copyright (C) 2015 CLARIN 3 3 * 4 4 * This program is free software: you can redistribute it and/or modify … … 17 17 package eu.clarin.cmdi.vlo.service.impl; 18 18 19 import eu.clarin.cmdi.vlo.service.handle.impl.HandleRestApiClient;20 19 import static eu.clarin.cmdi.vlo.FacetConstants.HANDLE_PREFIX; 21 20 import static eu.clarin.cmdi.vlo.FacetConstants.HANDLE_PROXY; 22 import eu.clarin.cmdi.vlo.service.handle.HandleClient;23 21 import eu.clarin.cmdi.vlo.service.UriResolver; 22 import java.net.URI; 23 import java.net.URISyntaxException; 24 import nl.mpi.archiving.corpusstructure.core.handle.HandleResolver; 25 import nl.mpi.archiving.corpusstructure.core.handle.InvalidHandleException; 24 26 import org.slf4j.Logger; 25 27 import org.slf4j.LoggerFactory; … … 28 30 * Resolves a URI as follows: if the URI starts with the handle scheme or the 29 31 * handle proxy, the handle is extracted and passed on to this resolver's 30 * {@link Handle Client} and the result of {@link HandleClient#getUrl(java.lang.String)31 * } is returned ; otherwise the original URI is returned.32 * {@link HandleResolver} and the result of {@link HandleResolver#resolve(java.net.URI) 33 * } is returned (as String); otherwise the original URI is returned. 32 34 * 33 * TODO: add support for resolving URN:NBN <https://trac.clarin.eu/ticket/535> 34 * 35 * @author twagoo 35 * @author Twan Goosen <twan.goosen@mpi.nl> 36 36 */ 37 37 public class UriResolverImpl implements UriResolver { 38 38 39 private final static Logger logger = LoggerFactory.getLogger( HandleRestApiClient.class);39 private final static Logger logger = LoggerFactory.getLogger(UriResolverImpl.class); 40 40 41 private final Handle ClienthandleClient;41 private final HandleResolver handleClient; 42 42 43 public UriResolverImpl(Handle ClienthandleClient) {43 public UriResolverImpl(HandleResolver handleClient) { 44 44 this.handleClient = handleClient; 45 45 } … … 49 49 final String handle = getHandle(uri); 50 50 51 if (handle == null) { 52 return uri; 53 } else { 51 if (handle != null) { 54 52 logger.debug("Calling handle client to resolve handle [{}]", uri); 55 final String resolved = handleClient.getUrl(handle); 56 if (resolved == null) { 57 return uri; 58 } else { 59 return resolved; 53 try { 54 final URI resolved = handleClient.resolve(new URI(handle)); 55 if (resolved != null) { 56 return resolved.toString(); 57 } 58 } catch (InvalidHandleException ex) { 59 logger.warn("Invalid handle ecountered: {}", handle); 60 } catch (URISyntaxException ex) { 61 logger.warn("Invalid URI for handle: {}", handle); 60 62 } 61 63 } 64 // not a resolvable handle 65 return uri; 62 66 63 67 } 64 68 65 69 private String getHandle(String uri) { 66 final String handle;67 70 if (uri.startsWith(HANDLE_PREFIX)) { 68 handle = uri.substring(HANDLE_PREFIX.length());71 return uri; 69 72 } else if (uri.startsWith(HANDLE_PROXY)) { 70 handle =uri.substring(HANDLE_PROXY.length());73 return HANDLE_PREFIX + uri.substring(HANDLE_PROXY.length()); 71 74 } else { 72 handle =null;75 return null; 73 76 } 74 return handle;75 77 } 76 78 -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/components/LanguageInfoLink.java
r6112 r6267 19 19 import eu.clarin.cmdi.vlo.FacetConstants; 20 20 import eu.clarin.cmdi.vlo.config.VloConfig; 21 import static eu.clarin.cmdi.vlo.config.VloConfig.LANGUAGE_LINK_TEMPLATE_LANGUAGE_CODE_PLACEHOLDER; 21 22 import java.util.regex.Matcher; 22 23 import java.util.regex.Pattern; … … 39 40 * @author Twan Goosen <twan.goosen@mpi.nl> 40 41 * @see FacetConstants#FIELD_LANGUAGE_CODE 41 * @see VloConfig#getLanguageLink Prefix()42 * @see VloConfig#getLanguageLinkTemplate() 42 43 */ 43 44 public class LanguageInfoLink extends GenericPanel<String> { … … 64 65 return null; 65 66 } else { 66 return vloConfig.getLanguageLink Prefix() + languageCode;67 return vloConfig.getLanguageLinkTemplate().replace(LANGUAGE_LINK_TEMPLATE_LANGUAGE_CODE_PLACEHOLDER, languageCode); 67 68 } 68 69 } -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/model/FacetFieldSelectionModel.java
r4963 r6267 86 86 } 87 87 88 @Override 89 public String toString() { 90 return String.format("[Field: %s; Selection: %s]", facetFieldModel.getObject().getName(), selectionModel.getObject().toString()); 91 } 92 88 93 } -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/model/SolrFieldNameModel.java
r4663 r6267 17 17 package eu.clarin.cmdi.vlo.wicket.model; 18 18 19 import eu.clarin.cmdi.vlo.pojo.DocumentField;20 19 import org.apache.solr.client.solrj.response.FacetField; 21 20 import org.apache.wicket.Application; -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/AboutPage.html
r5912 r6267 75 75 <h3>Publications</h3> 76 76 <ul> 77 <li><a href="http://hdl.handle.net/11858/00-001M-0000-000F-85F4-5">Van Uytvanck, D., Stehouwer, H., & Lampen, L. (2012). Semantic metadata mapping in practice: The Virtual Language Observatory. In N. Calzolari (Ed.), Proceedings of the Eighth International Conference on Language Resources and Evaluation (LREC 2012), Istanbul, May 23rd-25th, 2012 (pp. 1029-1034). European Language Resources Association (ELRA).</a></li> 77 <li><a href="http://hdl.handle.net/11858/00-001M-0000-000F-85F4-5">Van Uytvanck, D., Stehouwer, H., & Lampen, L. (2012). Semantic metadata mapping in practice: The Virtual Language Observatory. In N. Calzolari (Ed.), Proceedings of the Eighth International Conference on Language Resources and Evaluation (LREC 2012), Istanbul, May 23rd-25th, 2012 (pp. 1029-1034). European Language Resources Association (ELRA).</a></li> 78 <li><a href="http://www.clarin.eu/sites/default/files/cac2014_submission_2_0.pdf">Goosen, T., & Eckart, T. (2014). Virtual Language Observatory 3.0: Whatâs New? CLARIN Annual Conference 2014, Soesterberg, Netherlands.</a></li> 78 79 </ul> 79 80 -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/FacetedSearchPage.java
r5205 r6267 1 1 package eu.clarin.cmdi.vlo.wicket.pages; 2 2 3 import eu.clarin.cmdi.vlo.wicket.model.PermaLinkModel; 3 4 import eu.clarin.cmdi.vlo.wicket.panels.SingleFacetPanel; 4 5 import eu.clarin.cmdi.vlo.config.VloConfig; … … 46 47 private Component collectionsPanel; 47 48 private Component navigation; 49 private Component searchForm; 48 50 49 51 public FacetedSearchPage(IModel<QueryFacetsSelection> queryModel) { … … 64 66 navigation = createNavigation("navigation"); 65 67 add(navigation); 66 67 add(createSearchForm("search")); 68 69 searchForm = createSearchForm("search"); 70 add(searchForm); 68 71 69 72 collectionsPanel = createCollectionsPanel("collections"); … … 92 95 93 96 }); 94 container.add(new TopLinksPanel("permalink", getModel()) {97 container.add(new TopLinksPanel("permalink", new PermaLinkModel(getPageClass(), getModel())) { 95 98 96 99 @Override … … 117 120 118 121 private SearchForm createSearchForm(String id) { 119 final SearchForm searchForm = new SearchForm(id, getModel()) {122 final SearchForm form = new SearchForm(id, getModel()) { 120 123 121 124 @Override … … 127 130 128 131 }; 129 return searchForm; 132 form.setOutputMarkupId(true); 133 return form; 130 134 } 131 135 … … 171 175 if (target != null) { // null if JavaScript disabled 172 176 target.add(navigation); 177 target.add(searchForm); 173 178 target.add(searchResultsPanel); 174 179 target.add(facetsPanel); … … 176 181 } 177 182 } 183 184 @Override 185 public IModel<String> getCanonicalUrlModel() { 186 return new PermaLinkModel(getPageClass(), getModel()); 187 } 178 188 } -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/RecordPage.java
r5315 r6267 17 17 package eu.clarin.cmdi.vlo.wicket.pages; 18 18 19 import eu.clarin.cmdi.vlo.wicket.model.PermaLinkModel; 19 20 import eu.clarin.cmdi.vlo.FacetConstants; 20 21 import eu.clarin.cmdi.vlo.VloWebAppParameters; … … 177 178 178 179 private TopLinksPanel createPermalink(String id, final WebMarkupContainer topNavigation) { 179 return new TopLinksPanel(id, selectionModel, getModel()) {180 return new TopLinksPanel(id, new PermaLinkModel(getPageClass(), selectionModel, getModel())) { 180 181 181 182 @Override … … 293 294 294 295 @Override 296 public IModel<String> getCanonicalUrlModel() { 297 // omit query in link for canonical URL (record page gets same canonical 298 // URL regardless of search term) 299 return new PermaLinkModel(getPageClass(), null, getModel()); 300 } 301 302 @Override 295 303 public void renderHead(IHeaderResponse response) { 296 304 super.renderHead(response); -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/SimpleSearchPage.java
r5205 r6267 69 69 70 70 navigation.add(new BookmarkablePageLink("breadcrumb", getApplication().getHomePage())); 71 navigation.add(new TopLinksPanel("topLinks" ));71 navigation.add(new TopLinksPanel("topLinks", null)); 72 72 73 73 // add a persistenet panel for selection of a value for the collection facet -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/VloBasePage.html
r6160 r6267 31 31 <meta name="viewport" content="width=device-width"/> 32 32 <meta wicket:id="pageDescription" name="description" content="" /> 33 <link wicket:id="canonicalUrl" rel="canonical" /> 33 34 </head> 34 35 -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/VloBasePage.java
r5315 r6267 17 17 package eu.clarin.cmdi.vlo.wicket.pages; 18 18 19 import com.google.common.base.Strings;20 19 import eu.clarin.cmdi.vlo.JavaScriptResources; 21 20 import eu.clarin.cmdi.vlo.VloWebAppParameters; … … 41 40 import org.slf4j.Logger; 42 41 import org.slf4j.LoggerFactory; 43 import org.springframework.util.StringUtils;44 42 45 43 /** … … 124 122 } 125 123 }); 124 125 add(new WebComponent("canonicalUrl") { 126 127 @Override 128 protected void onRender() { 129 final IModel<String> canonicalUrlModel = getCanonicalUrlModel(); 130 if (canonicalUrlModel != null) { 131 getResponse().write("<link rel=\"canonical\" href=\"" + canonicalUrlModel.getObject() + "\"/>"); 132 } 133 } 134 135 }); 126 136 } 127 137 … … 146 156 } 147 157 158 /** 159 * 160 * @return URL to include as a canonical HREF in the page header (null to 161 * omit such a reference) 162 */ 163 public IModel<String> getCanonicalUrlModel() { 164 return null; 165 } 166 148 167 @Override 149 168 public void renderHead(IHeaderResponse response) { … … 161 180 } 162 181 182 163 183 } -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/BreadCrumbPanel.html
r5224 r6267 30 30 <wicket:container wicket:id="query"> 31 31 > <a wicket:id="leavequery">Search: "<span wicket:id="content"></span>"</a> 32 <a wicket:id="removal" title="Remove query" class="breadcrumbunselect"><span>[Remove]</span></a> 32 33 </wicket:container> 33 34 <wicket:container wicket:id="facets"> 34 35 > <a wicket:id="leaveselection">Selections</a>: 35 36 <wicket:container wicket:id="facet"> 36 <span class="breadcrumbfacet"><wicket:container wicket:id="value">[VALUE]</wicket:container> <a wicket:id="removal" title="Remove selection" class="breadcrumbunselect"><span>[Remove]</span></a></span> 37 <span class="breadcrumbfacet"><wicket:container wicket:id="value">[VALUE]</wicket:container> 38 <a wicket:id="removal" title="Remove selection" class="breadcrumbunselect"><span>[Remove]</span></a></span> 37 39 </wicket:container> 38 40 </wicket:container> -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/BreadCrumbPanel.java
r6012 r6267 53 53 */ 54 54 public class BreadCrumbPanel extends GenericPanel<QueryFacetsSelection> { 55 55 56 56 @SpringBean(name = "queryParametersConverter") 57 57 private PageParametersConverter<QueryFacetsSelection> paramsConverter; 58 58 @SpringBean 59 59 private FieldValueConverterProvider fieldValueConverterProvider; 60 60 61 61 private final WebMarkupContainer query; 62 62 private final WebMarkupContainer facets; 63 63 64 64 public BreadCrumbPanel(String id, IModel<QueryFacetsSelection> model) { 65 65 super(id, model); … … 68 68 add(facets = createFacets(model, "facets")); 69 69 } 70 70 71 71 private WebMarkupContainer createQuery(final IModel<QueryFacetsSelection> selectionModel, String id) { 72 72 final WebMarkupContainer queryContainer = new WebMarkupContainer(id); 73 73 final Link link = new AjaxFallbackLink("leavequery") { 74 74 75 75 @Override 76 76 public void onClick(AjaxRequestTarget target) { … … 82 82 link.add(new Label("content", new PropertyModel(selectionModel, "query"))); 83 83 queryContainer.add(link); 84 85 queryContainer.add(new AjaxFallbackLink("removal") { 86 87 @Override 88 public void onClick(AjaxRequestTarget target) { 89 // get a copy of the current selection 90 final QueryFacetsSelection newSelection = selectionModel.getObject().getCopy(); 91 newSelection.setQuery(null); 92 onSelectionChanged(newSelection, target); 93 } 94 }); 84 95 return queryContainer; 85 96 } 86 97 87 98 private WebMarkupContainer createFacets(final IModel<QueryFacetsSelection> model, String id) { 88 99 final WebMarkupContainer facetsContainer = new WebMarkupContainer(id); 89 100 facetsContainer.add(new AjaxFallbackLink("leaveselection") { 90 101 91 102 @Override 92 103 public void onClick(AjaxRequestTarget target) { … … 98 109 final FacetSelectionProvider facetSelectionProvider = new FacetSelectionProvider(model); 99 110 facetsContainer.add(new DataView<Map.Entry<String, FacetSelection>>("facet", facetSelectionProvider) { 100 111 101 112 @Override 102 113 protected void populateItem(final Item<Map.Entry<String, FacetSelection>> item) { … … 104 115 // add a label for the selected facet value(s) 105 116 final Label valueLabel = new Label("value", new PropertyModel(selectionModel, "value")) { 106 117 107 118 @Override 108 119 public <C> IConverter<C> getConverter(Class<C> type) { … … 111 122 return (IConverter<C>) new SelectionConverter(facet, fieldValueConverterProvider.getConverter(facet)); 112 123 } 113 124 114 125 }; 115 126 // add facet name as title attribute so that it becomes available through a tooltip … … 120 131 // add a link for removal of the facet value selection 121 132 item.add(new AjaxFallbackLink("removal") { 122 133 123 134 @Override 124 135 public void onClick(AjaxRequestTarget target) { … … 133 144 } 134 145 }); 135 146 136 147 return facetsContainer; 137 148 } … … 148 159 setResponsePage(FacetedSearchPage.class, paramsConverter.toParameters(selection)); 149 160 } 150 161 151 162 @Override 152 163 protected void onConfigure() { 153 164 super.onConfigure(); 154 165 155 166 final String queryString = getModelObject().getQuery(); 156 167 final Map<String, FacetSelection> selection = getModelObject().getSelection(); 157 168 158 169 query.setVisible(queryString != null && !queryString.isEmpty()); 159 170 facets.setVisible(selection != null && !selection.isEmpty()); … … 165 176 */ 166 177 private class SelectionConverter implements IConverter<FacetSelection> { 167 178 168 179 private final String facet; 169 180 private final IConverter<String> valueConverter; 170 181 171 182 public SelectionConverter(String facet, IConverter<String> valueConverter) { 172 183 this.facet = facet; 173 184 this.valueConverter = valueConverter; 174 185 } 175 186 176 187 @Override 177 188 public FacetSelection convertToObject(String value, Locale locale) throws ConversionException { 178 189 throw new UnsupportedOperationException("Not supported yet."); 179 190 } 180 191 181 192 @Override 182 193 public String convertToString(FacetSelection selection, Locale locale) { … … 193 204 return facet; 194 205 } 195 196 } 197 206 207 } 208 198 209 private String getAnyValueString() { 199 210 if (FacetConstants.FIELD_SEARCH_SERVICE.equals(facet)) { … … 202 213 return "any " + facet; 203 214 } 204 215 205 216 public String getCollectionString(FacetSelection selection, String valueSeparator, Locale locale) { 206 217 final Collection<String> value = selection.getValues(); … … 219 230 } 220 231 } 221 232 222 233 private String getConvertedValue(String string, Locale locale) { 223 234 if (valueConverter != null) { … … 229 240 return string; 230 241 } 231 242 232 243 }; 233 244 } -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/ExpandablePanel.html
r4976 r6267 26 26 <a wicket:id="expand" class="expandfacet"><span>expand</span></a> 27 27 <a wicket:id="collapse" class="collapsefacet"><span>collapse</span></a> 28 <h1><a wicket:id="titleToggle" href="#">< wicket:container wicket:id="title">[TITLE]</wicket:container></a></h1>28 <h1><a wicket:id="titleToggle" href="#"><span wicket:id="title">[TITLE]</span></a></h1> 29 29 <wicket:child /> 30 30 </wicket:panel> -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/TopLinksPanel.java
r5135 r6267 17 17 package eu.clarin.cmdi.vlo.wicket.panels; 18 18 19 import eu.clarin.cmdi.vlo.FacetConstants;20 import eu.clarin.cmdi.vlo.VloWebAppParameters;21 19 import eu.clarin.cmdi.vlo.config.VloConfig; 22 import eu.clarin.cmdi.vlo.pojo.QueryFacetsSelection;23 import eu.clarin.cmdi.vlo.service.PageParametersConverter;24 import org.apache.solr.common.SolrDocument;25 20 import org.apache.wicket.Component; 26 import org.apache.wicket.Session;27 21 import org.apache.wicket.ajax.AjaxRequestTarget; 28 22 import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton; 29 import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxFallbackLink;30 23 import org.apache.wicket.markup.html.form.Form; 31 24 import org.apache.wicket.markup.html.form.TextField; … … 33 26 import org.apache.wicket.markup.html.link.Link; 34 27 import org.apache.wicket.markup.html.panel.GenericPanel; 35 import org.apache.wicket.model.AbstractReadOnlyModel;36 28 import org.apache.wicket.model.IModel; 37 29 import org.apache.wicket.model.Model; 38 import org.apache.wicket.request.Url;39 import org.apache.wicket.request.cycle.RequestCycle;40 30 import org.apache.wicket.request.http.handler.RedirectRequestHandler; 41 import org.apache.wicket.request.mapper.parameter.PageParameters;42 31 import org.apache.wicket.spring.injection.annot.SpringBean; 43 32 import org.apache.wicket.util.encoding.UrlEncoder; 33 import org.slf4j.LoggerFactory; 44 34 45 35 /** … … 56 46 * @author twagoo 57 47 */ 58 public class TopLinksPanel extends GenericPanel< QueryFacetsSelection> {48 public class TopLinksPanel extends GenericPanel<String> { 59 49 60 @SpringBean(name = "queryParametersConverter")61 private PageParametersConverter<QueryFacetsSelection> paramsConverter;62 50 @SpringBean 63 51 private VloConfig vloConfig; 64 52 65 private final IModel<SolrDocument> documentModel;66 53 private final Model<Boolean> linkVisibilityModel; 67 54 68 public TopLinksPanel(String id) { 69 this(id, null, null); 70 } 71 72 public TopLinksPanel(String id, final IModel<QueryFacetsSelection> selectionmodel) { 73 this(id, selectionmodel, null); 74 } 75 76 public TopLinksPanel(String id, final IModel<QueryFacetsSelection> selectionmodel, final IModel<SolrDocument> documentModel) { 77 super(id, selectionmodel); 78 this.documentModel = documentModel; 79 this.linkVisibilityModel = new Model<Boolean>(false); 80 81 // create a model that provides a link to the current page 82 final IModel<String> linkModel = new PermaLinkModel(selectionmodel, documentModel); 55 public TopLinksPanel(String id, final IModel<String> linkModel) { 56 super(id, linkModel); 57 this.linkVisibilityModel = new Model<>(false); 83 58 84 59 // action to link to request the permalink … … 110 85 @Override 111 86 protected void onConfigure() { 112 super.onConfigure();113 87 setVisible(TopLinksPanel.this.getModel() != null); 114 88 } … … 137 111 private TextField<String> createLinkField(String id, final IModel<String> linkModel) { 138 112 final TextField<String> linkField = new TextField<String>(id, linkModel) { 113 139 114 @Override 140 115 protected void onConfigure() { 141 super.onConfigure();142 116 setVisible(linkVisibilityModel.getObject()); 143 117 } … … 145 119 }; 146 120 return linkField; 147 }148 149 @Override150 public void detachModels() {151 super.detachModels();152 if (documentModel != null) {153 documentModel.detach();154 }155 121 } 156 122 … … 161 127 } 162 128 163 private class PermaLinkModel extends AbstractReadOnlyModel<String> { 164 165 private final IModel<QueryFacetsSelection> selectionmodel; 166 private final IModel<SolrDocument> documentModel; 167 168 public PermaLinkModel(IModel<QueryFacetsSelection> selectionmodel, IModel<SolrDocument> documentModel) { 169 this.selectionmodel = selectionmodel; 170 this.documentModel = documentModel; 171 } 172 173 @Override 174 public String getObject() { 175 final PageParameters params = new PageParameters(); 176 if (selectionmodel != null) { 177 params.mergeWith(paramsConverter.toParameters(selectionmodel.getObject())); 178 } 179 180 if (documentModel != null) { 181 params.add(VloWebAppParameters.DOCUMENT_ID, documentModel.getObject().getFirstValue(FacetConstants.FIELD_ID)); 182 } 183 184 final String style = Session.get().getStyle(); 185 if (style != null) { 186 params.add(VloWebAppParameters.THEME, style); 187 } 188 189 final CharSequence url = urlFor(getPage().getClass(), params); 190 final String absoluteUrl = RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(url)); 191 return absoluteUrl; 192 } 129 @Override 130 protected void onConfigure() { 131 LoggerFactory.getLogger(getClass()).debug("top links panel onconfigure"); 193 132 } 133 134 194 135 195 136 } -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/record/ResourceLinksPanel.html
r4904 r6267 25 25 <wicket:panel> 26 26 <h2>Resources</h2> 27 <wicket:container wicket:id="resource"> 28 <a class="resourceLink" wicket:id="showResource"> 29 <wicket:container wicket:id="filename">resource.txt</wicket:container> 30 <span wicket:id="details" class="recordresourcedetails"></span> 31 </a> 32 </wicket:container> 27 <div id="resourceList"> 28 <wicket:container wicket:id="resource"> 29 <a class="resourceLink" wicket:id="showResource"> 30 <wicket:container wicket:id="filename">resource.txt</wicket:container> 31 <span wicket:id="details" class="recordresourcedetails"></span> 32 </a> 33 </wicket:container> 34 </div> 35 <div wicket:id="paging" id="resourcespagination" class="resultpagination">[paging]</div> 33 36 </wicket:panel> 34 37 </body> -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/record/ResourceLinksPanel.java
r5165 r6267 26 26 import java.util.List; 27 27 import org.apache.wicket.ajax.AjaxRequestTarget; 28 import org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator; 28 29 import org.apache.wicket.markup.html.basic.Label; 29 30 import org.apache.wicket.markup.html.link.ExternalLink; 30 31 import org.apache.wicket.markup.html.list.ListItem; 31 import org.apache.wicket.markup.html.list. ListView;32 import org.apache.wicket.markup.html.list.PageableListView; 32 33 import org.apache.wicket.markup.html.panel.Panel; 33 34 import org.apache.wicket.model.IModel; … … 43 44 public class ResourceLinksPanel extends Panel { 44 45 46 private static final int ITEMS_PER_PAGE = 12; 47 45 48 @SpringBean(name = "resourceStringConverter") 46 49 private ResourceStringConverter resourceStringConverter; … … 55 58 public ResourceLinksPanel(String id, IModel<Collection<String>> model) { 56 59 super(id, model); 60 57 61 // list view that shows all resources as links that show a resource details panel when clicked 58 add(new ResourcesListView("resource", new CollectionListModel<String>(model))); 62 final ResourcesListView resourceListing = new ResourcesListView("resource", new CollectionListModel<String>(model)); 63 add(resourceListing); 64 65 // pagination 66 add(new AjaxPagingNavigator("paging", resourceListing) { 67 68 @Override 69 protected void onConfigure() { 70 setVisible(resourceListing.getPageCount() > 1); 71 } 72 73 }); 74 75 //For Ajax updating of resource listing when paging 76 setOutputMarkupId(true); 59 77 } 60 78 61 private class ResourcesListView extends ListView<String> {79 private class ResourcesListView extends PageableListView<String> { 62 80 63 81 public ResourcesListView(String id, IModel<? extends List<? extends String>> model) { 64 super(id, model );82 super(id, model, ITEMS_PER_PAGE); 65 83 setReuseItems(true); 66 84 } … … 69 87 protected void populateItem(ListItem<String> item) { 70 88 final ResourceInfoModel resourceInfoModel = new ResourceInfoModel(resourceStringConverter, item.getModel()); 71 89 72 90 // add a link that will show the resource details panel when clicked 73 74 91 // wrap href in model that transforms handle links 75 92 final IModel<String> linkModel = new HandleLinkModel(new PropertyModel(resourceInfoModel, "href")); -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/FacetPanel.java
r5140 r6267 17 17 package eu.clarin.cmdi.vlo.wicket.panels.search; 18 18 19 import eu.clarin.cmdi.vlo.wicket.model.SolrFieldDescriptionModel; 19 20 import eu.clarin.cmdi.vlo.pojo.ExpansionState; 20 21 import eu.clarin.cmdi.vlo.pojo.FacetFieldSelection; … … 27 28 import org.apache.solr.client.solrj.response.FacetField; 28 29 import org.apache.wicket.ajax.AjaxRequestTarget; 30 import org.apache.wicket.behavior.AttributeAppender; 29 31 import org.apache.wicket.markup.html.basic.Label; 30 32 import org.apache.wicket.model.IModel; 31 33 import org.apache.wicket.model.PropertyModel; 34 import org.slf4j.Logger; 35 import org.slf4j.LoggerFactory; 32 36 33 37 /** … … 40 44 */ 41 45 public abstract class FacetPanel extends ExpandablePanel<FacetFieldSelection> { 46 private final static Logger logger = LoggerFactory.getLogger(FacetPanel.class); 42 47 43 48 private final IModel<ExpansionState> expansionStateModel; … … 65 70 @Override 66 71 protected Label createTitleLabel(String id) { 67 return new Label(id, new SolrFieldNameModel(new PropertyModel(getModel(), "facetField.name"))); 72 final IModel<String> facetNameModel = new PropertyModel<>(getModel(), "facetField.name"); 73 final Label label = new Label(id, new SolrFieldNameModel(facetNameModel)); 74 label.add(new AttributeAppender("title", new SolrFieldDescriptionModel(facetNameModel))); 75 return label; 68 76 } 69 77 -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SearchResultItemPanel.html
r4937 r6267 24 24 <body> 25 25 <wicket:panel> 26 <div class="score" wicket:id="scoreContainer"> 27 Score: <span wicket:id="score">[score]</span> 28 </div> 26 29 <h3> 27 30 <a wicket:id="recordLink" href="record1.html"><wicket:container wicket:id="title" >[TITLE]</wicket:container></a> -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SearchResultItemPanel.java
r4998 r6267 18 18 19 19 import eu.clarin.cmdi.vlo.FacetConstants; 20 import eu.clarin.cmdi.vlo.config.VloConfig; 20 21 import eu.clarin.cmdi.vlo.pojo.ExpansionState; 21 22 import eu.clarin.cmdi.vlo.pojo.SearchContext; 22 23 import eu.clarin.cmdi.vlo.wicket.components.RecordPageLink; 23 24 import eu.clarin.cmdi.vlo.wicket.components.SolrFieldLabel; 25 import eu.clarin.cmdi.vlo.wicket.model.SolrFieldStringModel; 24 26 import org.apache.solr.common.SolrDocument; 27 import org.apache.wicket.MarkupContainer; 25 28 import org.apache.wicket.ajax.AjaxRequestTarget; 26 29 import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxFallbackLink; 30 import org.apache.wicket.markup.html.WebMarkupContainer; 27 31 import org.apache.wicket.markup.html.basic.Label; 28 32 import org.apache.wicket.markup.html.link.Link; … … 30 34 import org.apache.wicket.model.AbstractReadOnlyModel; 31 35 import org.apache.wicket.model.IModel; 36 import org.apache.wicket.spring.injection.annot.SpringBean; 32 37 33 38 /** … … 37 42 public class SearchResultItemPanel extends Panel { 38 43 44 @SpringBean 45 private VloConfig config; 46 39 47 private final Panel collapsedDetails; 40 48 private final Panel expandedDetails; … … 68 76 expandedDetails = new SearchResultItemExpandedPanel("expandedDetails", documentModel, selectionModel); 69 77 add(expandedDetails); 78 79 final MarkupContainer scoreContainer = new WebMarkupContainer("scoreContainer"); 80 scoreContainer.add(new Label("score", new SolrFieldStringModel(documentModel, FacetConstants.FIELD_SOLR_SCORE))); 81 scoreContainer.setVisible(config.isShowResultScores()); 82 add(scoreContainer); 70 83 71 84 setOutputMarkupId(true); -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SearchResultsPanel.html
r5352 r6267 29 29 <span wicket:id="resultCount" id="searchresultcount">604056 results</span> 30 30 <span wicket:id="resultPageIndicator" id="searchresultpagecount">Showing 1 to 25</span> 31 <div class=" searchresultpagination">31 <div class="resultpagination"> 32 32 <div wicket:id="pagingTop">[PAGING]</div> 33 33 </div> … … 40 40 </ul> 41 41 42 <div id="bottompagination" class=" searchresultpagination">42 <div id="bottompagination" class="resultpagination"> 43 43 <div wicket:id="pagingBottom">[PAGING]</div> 44 44 -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SearchResultsPanel.java
r5353 r6267 41 41 import org.apache.wicket.model.Model; 42 42 import org.apache.wicket.model.PropertyModel; 43 import org.apache.wicket.model.StringResourceModel;44 43 45 44 /** -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SimpleSearchBrowsePanel.java
r5032 r6267 24 24 import eu.clarin.cmdi.vlo.service.solr.SolrDocumentService; 25 25 import eu.clarin.cmdi.vlo.wicket.model.FacetFieldsModel; 26 import eu.clarin.cmdi.vlo.wicket.model.SolrFieldDescriptionModel; 26 27 import eu.clarin.cmdi.vlo.wicket.model.SolrFieldNameModel; 27 28 import eu.clarin.cmdi.vlo.wicket.pages.FacetedSearchPage; … … 30 31 import org.apache.wicket.ajax.AjaxRequestTarget; 31 32 import org.apache.wicket.ajax.markup.html.AjaxFallbackLink; 33 import org.apache.wicket.behavior.AttributeAppender; 32 34 import org.apache.wicket.markup.html.WebMarkupContainer; 33 35 import org.apache.wicket.markup.html.basic.Label; … … 164 166 } 165 167 }; 166 select.add(new Label("name", 167 // friendly facet name based on name in FacetField 168 new SolrFieldNameModel(new PropertyModel(item.getModel(), "name")))); 168 169 // add name label (with a description title attribute) 170 final PropertyModel facetNameModel = new PropertyModel(item.getModel(), "name"); 171 // wrap in field name model to get a friendly facet name based on name in FacetField 172 final Label name = new Label("name", new SolrFieldNameModel(facetNameModel)); 173 select.add(name); 174 175 // add title attribute to get the facet description in a tooltip 176 select.add(new AttributeAppender("title", new SolrFieldDescriptionModel(facetNameModel))); 177 169 178 item.add(select); 170 179 -
vlo/branches/vlo-ticket761/vlo-web-app/src/main/less/eu/clarin/cmdi/vlo/wicket/pages/inc/vlo-search.less
r5354 r6267 60 60 } 61 61 62 #searchresultsheader . searchresultpagination {62 #searchresultsheader .resultpagination { 63 63 padding: 0; 64 64 margin: 0; … … 69 69 } 70 70 71 #bottompagination { 71 .resultpagination { 72 73 span 74 { 75 padding-left: 1px; 76 padding-right: 1px 77 } 78 79 span.goto em { 80 font-weight: bold; 81 text-decoration: underline; 82 font-style: normal; 83 } 84 } 85 86 #bottompagination, #resourcespagination { 72 87 clear: both; 73 88 text-align: center; 74 89 padding: 1em 0; 75 }76 77 .searchresultpagination span78 {79 padding-left: 1px;80 padding-right: 1px81 }82 83 .searchresultpagination span.goto em {84 font-weight: bold;85 text-decoration: underline;86 font-style: normal;87 90 } 88 91 … … 105 108 border-bottom: 1px solid #999; 106 109 margin: 0px; 107 } 108 109 li.searchresultitem a { 110 color: #000; 111 } 112 113 li.searchresultitem h3 { 114 text-decoration: none; 115 float: left; 116 width: 75%; 117 font-weight: normal; 118 } 119 120 li.searchresultitem h3 a { 121 color: #000A83; 122 } 123 124 li.searchresultitem .searchresultcollection{ 125 width: 20%; 126 float: right; 127 text-align: right; 128 font-weight: bold; 110 111 a { 112 color: #000; 113 } 114 115 h3 { 116 text-decoration: none; 117 float: left; 118 width: 75%; 119 font-weight: normal; 120 } 121 122 h3 a { 123 color: #000A83; 124 } 125 126 .searchresultcollection{ 127 width: 20%; 128 float: right; 129 text-align: right; 130 font-weight: bold; 131 } 132 133 .score { 134 color: #999; 135 text-align: right; 136 } 129 137 } 130 138 -
vlo/branches/vlo-ticket761/vlo-web-app/src/test/java/eu/clarin/cmdi/vlo/service/impl/UriResolverImplTest.java
r4983 r6267 17 17 package eu.clarin.cmdi.vlo.service.impl; 18 18 19 import eu.clarin.cmdi.vlo.service.handle.HandleClient; 19 import java.net.URI; 20 import nl.mpi.archiving.corpusstructure.core.handle.HandleResolver; 21 import nl.mpi.archiving.corpusstructure.core.handle.InvalidHandleException; 20 22 import org.jmock.Expectations; 21 23 import static org.jmock.Expectations.returnValue; … … 34 36 private final Mockery context = new JUnit4Mockery(); 35 37 private UriResolverImpl instance; 36 private Handle ClienthandleClient;38 private HandleResolver handleClient; 37 39 38 40 @Before 39 41 public void setUp() { 40 handleClient = context.mock(Handle Client.class);42 handleClient = context.mock(HandleResolver.class); 41 43 instance = new UriResolverImpl(handleClient); 42 44 } 43 45 44 46 /** 45 * Test of resolve method, of class UriResolverImpl.47 * Test of resolve method, of class HandleClientUriResolverImpl. 46 48 */ 47 49 @Test … … 52 54 53 55 /** 54 * Test of resolve method, of class UriResolverImpl.56 * Test of resolve method, of class HandleClientUriResolverImpl. 55 57 */ 56 58 @Test 57 public void testResolveHandleScheme() {59 public void testResolveHandleScheme() throws InvalidHandleException { 58 60 context.checking(new Expectations() { 59 61 { 60 oneOf(handleClient). getUrl("1234/5678");61 will(returnValue( "http://www.clarin.eu"));62 oneOf(handleClient).resolve(URI.create("hdl:1234/5678")); 63 will(returnValue(URI.create("http://www.clarin.eu"))); 62 64 } 63 65 }); … … 67 69 68 70 /** 69 * Test of resolve method, of class UriResolverImpl.71 * Test of resolve method, of class HandleClientUriResolverImpl. 70 72 */ 71 73 @Test 72 public void testResolveHandleProxy() {74 public void testResolveHandleProxy() throws InvalidHandleException { 73 75 context.checking(new Expectations() { 74 76 { 75 oneOf(handleClient). getUrl("1234/5678");76 will(returnValue( "http://www.clarin.eu"));77 oneOf(handleClient).resolve(URI.create("hdl:1234/5678")); 78 will(returnValue(URI.create("http://www.clarin.eu"))); 77 79 } 78 80 }); -
vlo/branches/vlo-ticket761/vlo-web-app/src/test/java/eu/clarin/cmdi/vlo/wicket/pages/TestRecordPage.java
r5231 r6267 51 51 public void setUp() { 52 52 tester = new WicketTester(application); 53 53 54 document = new SolrDocument(); 55 document.setField(FacetConstants.FIELD_ID, "documentId"); 56 54 57 params = new PageParameters(); 55 58 params.set(VloWebAppParameters.DOCUMENT_ID, "documentId");
Note: See TracChangeset
for help on using the changeset viewer.