Changeset 4669
- Timestamp:
- 03/11/14 16:39:52 (10 years ago)
- Location:
- vlo/branches/vlo-3.0/vlo-web-app
- Files:
-
- 3 added
- 6 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-3.0/vlo-web-app/pom.xml
r4651 r4669 137 137 <artifactId>guava</artifactId> 138 138 <version>16.0.1</version> 139 </dependency> 140 <dependency> 141 <groupId>net.sf.saxon</groupId> 142 <artifactId>Saxon-HE</artifactId> 143 <version>9.5.1-4</version> 144 <type>jar</type> 139 145 </dependency> 140 146 </dependencies> -
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/VloWicketApplication.java
r4661 r4669 1 1 package eu.clarin.cmdi.vlo; 2 2 3 import eu.clarin.cmdi.vlo.service.XmlTransformationService; 3 4 import eu.clarin.cmdi.vlo.service.solr.SolrDocumentService; 4 5 import eu.clarin.cmdi.vlo.wicket.pages.FacetedSearchPage; … … 24 25 @Autowired 25 26 private SolrDocumentService documentService; 27 @Autowired 28 private XmlTransformationService cmdiTransformationService; 26 29 27 30 private ApplicationContext applicationContext; … … 74 77 } 75 78 79 /** 80 * 81 * @return a service that retrieves SolrDocuments from the attached index 82 */ 76 83 public SolrDocumentService getDocumentService() { 77 84 return documentService; 78 85 } 79 86 87 /** 88 * 89 * @return a service that transforms CMDI documents to HTML representations 90 */ 91 public XmlTransformationService getCmdiTransformationService() { 92 return cmdiTransformationService; 93 } 94 80 95 } -
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/config/VloSpringConfig.java
r4661 r4669 27 27 import eu.clarin.cmdi.vlo.service.ResourceStringConverter; 28 28 import eu.clarin.cmdi.vlo.service.ResourceTypeCountingService; 29 import eu.clarin.cmdi.vlo.service.XmlTransformationService; 29 30 import eu.clarin.cmdi.vlo.service.solr.SearchResultsDao; 30 31 import eu.clarin.cmdi.vlo.service.solr.SolrDocumentService; … … 33 34 import eu.clarin.cmdi.vlo.service.impl.ResourceStringConverterImpl; 34 35 import eu.clarin.cmdi.vlo.service.impl.ResourceTypeCountingServiceImpl; 36 import eu.clarin.cmdi.vlo.service.impl.XmlTransformationServiceImpl; 35 37 import eu.clarin.cmdi.vlo.service.solr.impl.SearchResultsDaoImpl; 36 38 import eu.clarin.cmdi.vlo.service.solr.impl.SolrDocumentQueryFactoryImpl; … … 39 41 import eu.clarin.cmdi.vlo.service.solr.impl.SolrFacetQueryFactoryImpl; 40 42 import java.io.IOException; 43 import java.util.Properties; 44 import javax.xml.transform.OutputKeys; 45 import javax.xml.transform.Source; 46 import javax.xml.transform.TransformerConfigurationException; 47 import javax.xml.transform.stream.StreamSource; 41 48 import org.apache.solr.client.solrj.SolrServer; 42 49 import org.apache.solr.client.solrj.impl.HttpSolrServer; … … 125 132 } 126 133 134 @Bean 135 public XmlTransformationService cmdiTransformationService() throws TransformerConfigurationException { 136 final Source xsltSource = new StreamSource(getClass().getResourceAsStream("/cmdi2xhtml.xsl")); 137 //TODO: Read properties from file?? 138 final Properties transformationProperties = new Properties(); 139 transformationProperties.setProperty(OutputKeys.METHOD, "html"); 140 transformationProperties.setProperty(OutputKeys.INDENT, "yes"); 141 transformationProperties.setProperty(OutputKeys.ENCODING, "UTF-8"); 142 return new XmlTransformationServiceImpl(xsltSource, transformationProperties); 143 } 144 127 145 @Bean(name = "basicPropertiesFilter") 128 146 public FieldFilter basicPropertiesFieldFilter() { -
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/model/XsltModel.java
r4660 r4669 1 1 /* 2 * To change this license header, choose License Headers in Project Properties. 3 * To change this template file, choose Tools | Templates 4 * and open the template in the editor. 2 * Copyright (C) 2014 CLARIN 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 5 16 */ 6 package eu.clarin.cmdi.vlo. pages;17 package eu.clarin.cmdi.vlo.wicket.model; 7 18 19 import eu.clarin.cmdi.vlo.VloWicketApplication; 8 20 import java.io.IOException; 9 21 import java.io.InputStreamReader; 10 22 import java.io.StringWriter; 11 23 import java.net.URL; 24 import javax.xml.transform.TransformerException; 12 25 import javax.xml.transform.stream.StreamSource; 13 26 import net.sf.saxon.s9api.Processor; … … 18 31 import net.sf.saxon.s9api.XsltExecutable; 19 32 import net.sf.saxon.s9api.XsltTransformer; 33 import org.apache.wicket.model.IModel; 20 34 import org.apache.wicket.model.LoadableDetachableModel; 21 35 import org.slf4j.Logger; … … 29 43 * @author twagoo 30 44 */ 31 public class CmdiXsltModel extends LoadableDetachableModel<String> {45 public class XsltModel extends LoadableDetachableModel<String> { 32 46 33 private final static Logger LOG = LoggerFactory.getLogger(CmdiXsltModel.class); 34 35 private final URL xslFile = getClass().getResource("/eu/clarin/cmdi/vlo/pages/cmdi2xhtml.xsl"); 36 private final URL metadataUrl; 47 private final static Logger logger = LoggerFactory.getLogger(XsltModel.class); 48 private final IModel<URL> metadataUrl; 37 49 38 50 /** … … 40 52 * @param metadataUrl URL of the metadata file to be presented 41 53 */ 42 public CmdiXsltModel(URLmetadataUrl) {54 public XsltModel(IModel<URL> metadataUrl) { 43 55 this.metadataUrl = metadataUrl; 44 56 } … … 51 63 @Override 52 64 protected String load() { 53 final Processor proc = new Processor(false);54 final XsltCompiler comp = proc.newXsltCompiler();55 56 final StringWriter strWriter = new StringWriter();65 final URL object = metadataUrl.getObject(); 66 if (object == null) { 67 return ""; 68 } 57 69 try { 58 final XsltExecutable exp = comp.compile(new StreamSource(xslFile.getFile())); 59 final XdmNode source = proc.newDocumentBuilder().build( 60 new StreamSource(new InputStreamReader(metadataUrl.openStream()))); 61 final Serializer out = new Serializer(); 62 out.setOutputProperty(Serializer.Property.METHOD, "html"); 63 out.setOutputProperty(Serializer.Property.INDENT, "yes"); 64 out.setOutputProperty(Serializer.Property.ENCODING, "UTF-8"); 65 out.setOutputWriter(strWriter); 66 final XsltTransformer trans = exp.load(); 67 68 trans.setInitialContextNode(source); 69 trans.setDestination(out); 70 trans.transform(); 71 return (strWriter.toString()); 72 } catch (SaxonApiException e) { 73 LOG.error("Couldn't transform CMDI metadata at {}: ", metadataUrl, e); 74 return ("<b>Could not load complete CMDI metadata</b>"); 75 } catch (IOException e) { 76 LOG.error("Couldn't read CMDI metadata at {}: ", metadataUrl, e); 70 return VloWicketApplication.get().getCmdiTransformationService().transformXml(object); 71 } catch (TransformerException ex) { 72 logger.error("Could not transform {}", object, ex); 77 73 return ("<b>Could not load complete CMDI metadata</b>"); 78 74 } -
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/RecordPage.html
r4653 r4669 71 71 <a href="#" id="hiderecordcmdi" class="recordhidelink">Hide all metadata fields</a> 72 72 </p> 73 <div id="recordcmdi"> 74 <h2>CMDI Metadata</h2> 75 <!--<p><a href="#" id="recordcmditoggle">View/Hide CMDI metadata</a></p>--> 76 <article xmlns:cmd="http://www.clarin.eu/cmd/" xmlns:fn="http://www.w3.org/2005/xpath-functions" style="background-color:#EEEEEE"> 77 <div class="endgame"> 78 <p> 79 <h1>Resources</h1> 80 <table> 81 <caption>Resources</caption> 82 <thead> 83 <tr> 84 <th class="attribute">Reference to resource</th> 85 <th class="attribute">Resource description</th> 86 <th class="attribute">Resource MIME type</th> 87 <th class="attribute">Resource Proxy ID</th> 88 </tr> 89 </thead> 90 <tbody class="attributesTbody"> 91 <tr> 92 <td class="attributeValue"><a href="http://dspace.library.uu.nl/handle/1874/205294">http://dspace.library.uu.nl/handle/1874/205294</a></td> 93 <td class="attributeValue">LandingPage</td> 94 <td class="attributeValue">text/html</td> 95 <td class="attributeValue">h.1874.205294</td> 96 </tr> 97 <tr> 98 <td class="attributeValue"><a href="http://dspace.library.uu.nl/bitstream/1874/205294/1/Masterthesis+Carolyn+van+de+Wall.docx">http://dspace.library.uu.nl/bitstream/1874/205294/1/Masterthesis+Carolyn+van+de+Wall.docx</a></td> 99 <td class="attributeValue">Resource</td> 100 <td class="attributeValue">application/octet-stream</td> 101 <td class="attributeValue">h.1874.205294.1</td> 102 </tr> 103 </tbody> 104 </table> 105 </p> 106 </div> 107 <p> 108 <h1>Metadata content</h1> 109 <ul> 110 <li><code class="node">mods 111 <div class="attributes">version="3.2" 112 113 </div></code><ul> 114 <ul> 115 <li><code class="node">edboOverlap </code><div class="Component_tree_node_content"><code class="leaf">no</code></div> 116 </li> 117 <li><code class="node">machineReadable </code><div class="Component_tree_node_content"><code class="leaf">unknown</code></div> 118 </li> 119 <li><code class="node">typeOfResource </code><div class="Component_tree_node_content"><code class="leaf">text</code></div> 120 </li> 121 <li><code class="node">genre </code><div class="Component_tree_node_content"><code class="leaf">info:eu-repo/semantics/masterThesis</code></div> 122 </li> 123 <li><code class="node">titleInfo </code><ul> 124 <ul> 125 <li><code class="node">title </code><div class="Component_tree_node_content"><code class="leaf">" De professionaliteit van medisch specialisten onder de loep"</code></div> 126 </li> 127 </ul> 128 </ul> 129 </li> 130 <li><code class="node">name 131 <div class="attributes">ID="n205294_aut_1" 132 type="personal" 133 134 </div></code><ul> 135 <ul> 136 <li><code class="node">namePart 137 <div class="attributes">type="family" 138 139 </div></code><div class="Component_tree_node_content"><code class="leaf">Wall</code></div> 140 </li> 141 <li><code class="node">namePart 142 <div class="attributes">type="given" 143 144 </div></code><div class="Component_tree_node_content"><code class="leaf"> C.J. van de</code></div> 145 </li> 146 <li><code class="node">role </code><ul> 147 <ul> 148 <li><code class="node">roleTerm 149 <div class="attributes">authority="marcrelator" 150 type="code" 151 152 </div></code><div class="Component_tree_node_content"><code class="leaf">aut</code></div> 153 </li> 154 </ul> 155 </ul> 156 </li> 157 </ul> 158 </ul> 159 </li> 160 <li><code class="node">name 161 <div class="attributes">ID="n205294_ths_1" 162 type="personal" 163 164 </div></code><ul> 165 <ul> 166 <li><code class="node">namePart 167 <div class="attributes">type="family" 168 169 </div></code><div class="Component_tree_node_content"><code class="leaf">Knies</code></div> 170 </li> 171 <li><code class="node">namePart 172 <div class="attributes">type="given" 173 174 </div></code><div class="Component_tree_node_content"><code class="leaf"> E.</code></div> 175 </li> 176 <li><code class="node">role </code><ul> 177 <ul> 178 <li><code class="node">roleTerm 179 <div class="attributes">authority="marcrelator" 180 type="code" 181 182 </div></code><div class="Component_tree_node_content"><code class="leaf">ths</code></div> 183 </li> 184 </ul> 185 </ul> 186 </li> 187 </ul> 188 </ul> 189 </li> 190 <li><code class="node">originInfo </code><ul> 191 <ul> 192 <li><code class="node">dateCreated 193 <div class="attributes">encoding="iso8601" 194 195 </div></code><div class="Component_tree_node_content"><code class="leaf">2011-03-31</code></div> 196 </li> 197 <li><code class="node">dateCreated 198 <div class="attributes">encoding="iso8601" 199 200 </div></code><div class="Component_tree_node_content"><code class="leaf">2011-05-31</code></div> 201 </li> 202 </ul> 203 </ul> 204 </li> 205 <li><code class="node">language </code><ul> 206 <ul> 207 <li><code class="node">languageTerm 208 <div class="attributes">authority="rfc3066" 209 type="code" 210 211 </div></code><div class="Component_tree_node_content"><code class="leaf">nl</code></div> 212 </li> 213 </ul> 214 </ul> 215 </li> 216 <li><code class="node">subject </code><ul> 217 <ul> 218 <li><code class="node">topic </code><div class="Component_tree_node_content"><code class="leaf">professionaliteit, ziekenhuis, medisch specialisten, management, Klink, loondienst, 219 maatschappen, autonomie, kwaliteit zorg, motivatie, ondersteunend personeel</code></div> 220 </li> 221 </ul> 222 </ul> 223 </li> 224 </ul> 225 </ul> 226 </li> 227 </ul> 228 </p> 229 </article> 230 </div> <!-- recordcmdi --> 73 <div wicket:id="cmdi" id="recordcmdi">[CMDI metadata]</div> 231 74 232 75 <p id="recordtechnicaldetailstoggle" class="recordtogglelinks"> -
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/RecordPage.java
r4661 r4669 27 27 import eu.clarin.cmdi.vlo.wicket.model.SolrFieldModel; 28 28 import eu.clarin.cmdi.vlo.wicket.model.SolrFieldStringModel; 29 import eu.clarin.cmdi.vlo.wicket.model.UrlFromStringModel; 30 import eu.clarin.cmdi.vlo.wicket.model.XsltModel; 29 31 import eu.clarin.cmdi.vlo.wicket.provider.DocumentFieldsProvider; 30 32 import org.apache.solr.common.SolrDocument; 33 import org.apache.wicket.markup.html.basic.Label; 31 34 import org.apache.wicket.markup.html.link.ExternalLink; 32 35 import org.apache.wicket.model.IModel; … … 52 55 public RecordPage(PageParameters params) { 53 56 super(params); 54 57 55 58 final SolrDocumentModel documentModel = new SolrDocumentModel(params.get("docId").toString()); 56 59 setModel(documentModel); 57 60 58 61 final QueryFacetsSelection selection = selectionParametersConverter.fromParameters(params); 59 62 this.contextModel = Model.of(selection); 60 61 addComponents( documentModel);63 64 addComponents(); 62 65 } 63 66 … … 65 68 super(documentModel); 66 69 this.contextModel = contextModel; 67 addComponents( documentModel);70 addComponents(); 68 71 } 69 72 70 private void addComponents(IModel<SolrDocument> documentModel) { 71 add(new SolrFieldLabel("name", documentModel, FacetConstants.FIELD_NAME, "Unnamed record")); 72 add(createLandingPageLink("landingPageLink", documentModel)); 73 add(new FieldsTablePanel("documentProperties", new DocumentFieldsProvider(documentModel, basicPropertiesFilter))); 74 add(new ResourceLinksPanel("resources", new SolrFieldModel<String>(documentModel, FacetConstants.FIELD_RESOURCE))); 75 add(new FieldsTablePanel("technicalProperties", new DocumentFieldsProvider(documentModel, technicalPropertiesFilter))); 73 private void addComponents() { 74 // General information section 75 add(new SolrFieldLabel("name", getModel(), FacetConstants.FIELD_NAME, "Unnamed record")); 76 add(createLandingPageLink("landingPageLink")); 77 add(new FieldsTablePanel("documentProperties", new DocumentFieldsProvider(getModel(), basicPropertiesFilter))); 78 79 // Resources section 80 add(new ResourceLinksPanel("resources", new SolrFieldModel<String>(getModel(), FacetConstants.FIELD_RESOURCE))); 81 82 // Technical section 83 add(createCmdiContent("cmdi")); 84 add(new FieldsTablePanel("technicalProperties", new DocumentFieldsProvider(getModel(), technicalPropertiesFilter))); 76 85 } 77 86 78 private ExternalLink createLandingPageLink(String id , IModel<SolrDocument> documentModel) {79 final SolrFieldStringModel landingPageHrefModel = new SolrFieldStringModel( documentModel, FacetConstants.FIELD_LANDINGPAGE);87 private ExternalLink createLandingPageLink(String id) { 88 final SolrFieldStringModel landingPageHrefModel = new SolrFieldStringModel(getModel(), FacetConstants.FIELD_LANDINGPAGE); 80 89 // add landing page link 81 90 final ExternalLink landingPageLink = new ExternalLink(id, landingPageHrefModel) { … … 91 100 } 92 101 102 private Label createCmdiContent(String id) { 103 final IModel<String> locationModel = new SolrFieldStringModel(getModel(), FacetConstants.FIELD_FILENAME); 104 final UrlFromStringModel locationUrlModel = new UrlFromStringModel(locationModel); 105 final Label cmdiContentLabel = new Label(id, new XsltModel(locationUrlModel)); 106 cmdiContentLabel.setEscapeModelStrings(false); 107 return cmdiContentLabel; 108 } 109 93 110 @Override 94 111 public void detachModels() { -
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/provider/FacetFieldValuesProvider.java
r4666 r4669 35 35 * SOLR) present on a {@link FacetField}, sortable by either count or name 36 36 * 37 * TODO: Add option to hide values with only 1 record (as in VLO 2.x) 38 * 37 39 * @see FieldValuesOrder 38 40 * @author twagoo
Note: See TracChangeset
for help on using the changeset viewer.