From efdefef4e6443d75f7b0fbfa7a76bf5fcdd2af0a Mon Sep 17 00:00:00 2001 From: Luigi Asprino Date: Mon, 27 Jan 2020 18:17:38 +0100 Subject: [PATCH 1/6] Removed LodLive link from footer --- src/main/webapp/WEB-INF/views/inc/footer.jsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/WEB-INF/views/inc/footer.jsp b/src/main/webapp/WEB-INF/views/inc/footer.jsp index 4f89c60..7a12268 100644 --- a/src/main/webapp/WEB-INF/views/inc/footer.jsp +++ b/src/main/webapp/WEB-INF/views/inc/footer.jsp @@ -13,9 +13,9 @@
  • ${conf.getEndPointUrl()}
  • -
  • + -
  • ${list} +
  • ${list} ${ele.key}, From fcdd73155d71e30a75e30a915980391046e654b0 Mon Sep 17 00:00:00 2001 From: Luigi Asprino Date: Mon, 27 Jan 2020 19:46:09 +0100 Subject: [PATCH 2/6] lodliveUrl parameterized --- .../lodview/conf/ConfigurationBean.java | 38 ++++- .../controllers/ResourceController.java | 85 +++++++---- src/main/webapp/WEB-INF/conf.ttl | 135 +++++++++--------- src/main/webapp/WEB-INF/views/resource.jsp | 8 +- 4 files changed, 161 insertions(+), 105 deletions(-) diff --git a/src/main/java/org/dvcama/lodview/conf/ConfigurationBean.java b/src/main/java/org/dvcama/lodview/conf/ConfigurationBean.java index e05c0a4..f038abb 100644 --- a/src/main/java/org/dvcama/lodview/conf/ConfigurationBean.java +++ b/src/main/java/org/dvcama/lodview/conf/ConfigurationBean.java @@ -33,6 +33,7 @@ public class ConfigurationBean implements ServletContextAware, Cloneable { private String httpRedirectSuffix; private String httpRedirectPrefix; private String endPointUrl; + private String lodliveUrl; private String IRInamespace; private String contentEncoding; private String staticResourceURL; @@ -43,7 +44,10 @@ public class ConfigurationBean implements ServletContextAware, Cloneable { private String authPassword = null; private String defaultInverseBehaviour = "collapse"; - private List defaultQueries = null, defaultRawDataQueries = null, defaultInversesQueries = null, defaultInversesTest = null, defaultInversesCountQueries = null, typeProperties = null, audioProperties = null, imageProperties = null, videoProperties = null, linkingProperties = null, titleProperties = null, descriptionProperties = null, longitudeProperties = null, latitudeProperties = null; + private List defaultQueries = null, defaultRawDataQueries = null, defaultInversesQueries = null, + defaultInversesTest = null, defaultInversesCountQueries = null, typeProperties = null, + audioProperties = null, imageProperties = null, videoProperties = null, linkingProperties = null, + titleProperties = null, descriptionProperties = null, longitudeProperties = null, latitudeProperties = null; private List colorPair = null, skipDomains = null, mainOntologiesPrefixes = null; private Map colorPairMatcher = null; @@ -65,6 +69,7 @@ public void populateBean() throws IOException, Exception { confModel = RDFDataMgr.loadModel(configFile.getAbsolutePath()); endPointUrl = getSingleConfValue("endpoint"); + lodliveUrl = getSingleConfValue("lodliveUrl"); endPointType = getSingleConfValue("endpointType", ""); authPassword = getSingleConfValue("authPassword"); authUsername = getSingleConfValue("authUsername"); @@ -120,10 +125,12 @@ public void populateBean() throws IOException, Exception { private Map populateColorPairMatcher() { Map result = new HashMap(); - ResIterator iter = confModel.listSubjectsWithProperty(confModel.createProperty(confModel.getNsPrefixURI("conf"), "hasColorPair")); + ResIterator iter = confModel + .listSubjectsWithProperty(confModel.createProperty(confModel.getNsPrefixURI("conf"), "hasColorPair")); while (iter.hasNext()) { Resource res = iter.next(); - NodeIterator values = confModel.listObjectsOfProperty(res, confModel.createProperty(confModel.getNsPrefixURI("conf"), "hasColorPair")); + NodeIterator values = confModel.listObjectsOfProperty(res, + confModel.createProperty(confModel.getNsPrefixURI("conf"), "hasColorPair")); while (values.hasNext()) { RDFNode node = values.next(); result.put(res.toString(), node.toString()); @@ -138,7 +145,8 @@ private String getSingleConfValue(String prop) { } private String getSingleConfValue(String prop, String defaultValue) { - NodeIterator iter = confModel.listObjectsOfProperty(confModel.createProperty(confModel.getNsPrefixURI("conf"), prop)); + NodeIterator iter = confModel + .listObjectsOfProperty(confModel.createProperty(confModel.getNsPrefixURI("conf"), prop)); while (iter.hasNext()) { RDFNode node = iter.next(); return node.toString(); @@ -148,7 +156,8 @@ private String getSingleConfValue(String prop, String defaultValue) { private List getMultiConfValue(String prop) { List result = new ArrayList(); - NodeIterator iter = confModel.listObjectsOfProperty(confModel.createProperty(confModel.getNsPrefixURI("conf"), prop)); + NodeIterator iter = confModel + .listObjectsOfProperty(confModel.createProperty(confModel.getNsPrefixURI("conf"), prop)); while (iter.hasNext()) { RDFNode node = iter.next(); result.add(node.toString()); @@ -195,6 +204,10 @@ public String getEndPointUrl() { return endPointUrl; } + public String getLodliveUrl() { + return lodliveUrl; + } + public List getDefaultQueries() { return defaultQueries; } @@ -315,8 +328,19 @@ public Object clone() { @Override public String toString() { - return "ConfigurationBean [confModel=" + confModel + ", context=" + context + ", confFile=" + confFile + ", endPointUrl=" + endPointUrl + ", IRInamespace=" + IRInamespace + ", contentEncoding=" + contentEncoding + ", staticResourceURL=" + staticResourceURL + ", preferredLanguage=" + preferredLanguage + ", publicUrlPrefix=" + publicUrlPrefix + ", authUsername=" + authUsername + ", authPassword=" + authPassword + ", defaultInverseBehaviour=" + defaultInverseBehaviour + ", defaultQueries=" + defaultQueries + ", defaultRawDataQueries=" + defaultRawDataQueries + ", defaultInversesQueries=" + defaultInversesQueries + ", defaultInversesTest=" + defaultInversesTest + ", defaultInversesCountQueries=" + defaultInversesCountQueries + ", typeProperties=" + typeProperties - + ", imageProperties=" + imageProperties + ", audioProperties=" + audioProperties + ", videoProperties=" + videoProperties + ", linkingProperties=" + linkingProperties + ", titleProperties=" + titleProperties + ", descriptionProperties=" + descriptionProperties + ", longitudeProperties=" + longitudeProperties + ", latitudeProperties=" + latitudeProperties + ", colorPair=" + colorPair + ", skipDomains=" + skipDomains + ", rand=" + rand + "]"; + return "ConfigurationBean [confModel=" + confModel + ", context=" + context + ", confFile=" + confFile + + ", endPointUrl=" + endPointUrl + ", IRInamespace=" + IRInamespace + ", contentEncoding=" + + contentEncoding + ", staticResourceURL=" + staticResourceURL + ", preferredLanguage=" + + preferredLanguage + ", publicUrlPrefix=" + publicUrlPrefix + ", authUsername=" + authUsername + + ", authPassword=" + authPassword + ", defaultInverseBehaviour=" + defaultInverseBehaviour + + ", defaultQueries=" + defaultQueries + ", defaultRawDataQueries=" + defaultRawDataQueries + + ", defaultInversesQueries=" + defaultInversesQueries + ", defaultInversesTest=" + defaultInversesTest + + ", defaultInversesCountQueries=" + defaultInversesCountQueries + ", typeProperties=" + typeProperties + + ", imageProperties=" + imageProperties + ", audioProperties=" + audioProperties + ", videoProperties=" + + videoProperties + ", linkingProperties=" + linkingProperties + ", titleProperties=" + titleProperties + + ", descriptionProperties=" + descriptionProperties + ", longitudeProperties=" + longitudeProperties + + ", latitudeProperties=" + latitudeProperties + ", colorPair=" + colorPair + ", skipDomains=" + + skipDomains + ", rand=" + rand + "]"; } public String getHomeUrl() { diff --git a/src/main/java/org/dvcama/lodview/controllers/ResourceController.java b/src/main/java/org/dvcama/lodview/controllers/ResourceController.java index ef58fb4..7420e46 100644 --- a/src/main/java/org/dvcama/lodview/controllers/ResourceController.java +++ b/src/main/java/org/dvcama/lodview/controllers/ResourceController.java @@ -71,7 +71,9 @@ public ResourceController(MessageSource messageSource, OntologyBean ontoBean) { } @RequestMapping(value = { "{path:(?!staticResources).*$}", "{path:(?!staticResources).*$}/**" }) - public Object resourceController(ModelMap model, HttpServletRequest req, HttpServletResponse res, Locale locale, @RequestParam(value = "output", defaultValue = "") String output, @CookieValue(value = "colorPair", defaultValue = "") String colorPair) throws UnsupportedEncodingException { + public Object resourceController(ModelMap model, HttpServletRequest req, HttpServletResponse res, Locale locale, + @RequestParam(value = "output", defaultValue = "") String output, + @CookieValue(value = "colorPair", defaultValue = "") String colorPair) throws UnsupportedEncodingException { if (colorPair.equals("")) { colorPair = conf.getRandomColorPair(); Cookie c = new Cookie("colorPair", colorPair); @@ -81,7 +83,8 @@ public Object resourceController(ModelMap model, HttpServletRequest req, HttpSer return resource(conf, model, req, res, locale, output, "", colorPair); } - public Object resource(ConfigurationBean conf, ModelMap model, HttpServletRequest req, HttpServletResponse res, Locale locale, String output, String forceIRI, String colorPair) throws UnsupportedEncodingException { + public Object resource(ConfigurationBean conf, ModelMap model, HttpServletRequest req, HttpServletResponse res, + Locale locale, String output, String forceIRI, String colorPair) throws UnsupportedEncodingException { model.addAttribute("conf", conf); @@ -167,7 +170,8 @@ public Object resource(ConfigurationBean conf, ModelMap model, HttpServletReques */ if (requestUrl.matches(".+\\.(ntriples|n3|json|rdf)")) { String outputType = ""; - String newUrl = requestUrl.replaceFirst("/data/", "/resource/").replaceAll("\\.(ntriples|n3|json|rdf)$", ""); + String newUrl = requestUrl.replaceFirst("/data/", "/resource/").replaceAll("\\.(ntriples|n3|json|rdf)$", + ""); RedirectView r = new RedirectView(); r.setExposeModelAttributes(false); if (requestUrl.endsWith(".ntriples")) { @@ -179,7 +183,8 @@ public Object resource(ConfigurationBean conf, ModelMap model, HttpServletReques } else if (requestUrl.endsWith(".rdf")) { outputType = "application/rdf+xml"; } - r.setUrl(newUrl + "?" + (req.getQueryString() != null ? req.getQueryString() + "&" : "") + "output=" + outputType); + r.setUrl(newUrl + "?" + (req.getQueryString() != null ? req.getQueryString() + "&" : "") + "output=" + + outputType); return r; } } @@ -221,7 +226,7 @@ public Object resource(ConfigurationBean conf, ModelMap model, HttpServletReques if (redirect && !redirected) { return redirect(req, IRIsuffix); } else { - return htmlResource(model, IRI, colorPair, locale, req, res); + return htmlResource(model, conf, IRI, colorPair, locale, req, res); } } else { return new ErrorController(conf).error406(res, model, colorPair); @@ -232,15 +237,18 @@ public Object resource(ConfigurationBean conf, ModelMap model, HttpServletReques } catch (Exception e) { e.printStackTrace(); if (e.getMessage() != null && e.getMessage().startsWith("404")) { - return new ErrorController(conf).error404(res, model, e.getMessage(), colorPair, IRI, conf.getEndPointUrl()); + return new ErrorController(conf).error404(res, model, e.getMessage(), colorPair, IRI, + conf.getEndPointUrl()); } else { - return new ErrorController(conf).error500(res, model, e.getMessage(), colorPair, IRI, conf.getEndPointUrl()); + return new ErrorController(conf).error500(res, model, e.getMessage(), colorPair, IRI, + conf.getEndPointUrl()); } } } - private String htmlResource(ModelMap model, String IRI, String colorPair, Locale locale, HttpServletRequest req, HttpServletResponse res) throws Exception { + private String htmlResource(ModelMap model, ConfigurationBean conf, String IRI, String colorPair, Locale locale, + HttpServletRequest req, HttpServletResponse res) throws Exception { model.addAttribute("contextPath", new UrlPathHelper().getContextPath(req)); ResultBean r = new ResourceBuilder(messageSource).buildHtmlResource(IRI, locale, conf, ontoBean); model.addAttribute("colorPair", Misc.guessColor(colorPair, r, conf)); @@ -248,15 +256,17 @@ private String htmlResource(ModelMap model, String IRI, String colorPair, Locale model.addAttribute("ontoBean", ontoBean); addDataLinks(IRI, model, req, locale); - addLodliveLink(locale, model, IRI); + addLodliveLink(locale, model, IRI, conf.getLodliveUrl()); enrichResponse(model, r, req, res); return "resource"; } - private void addDataLinks(String IRI, ModelMap model, HttpServletRequest req, Locale locale) throws UnsupportedEncodingException { + private void addDataLinks(String IRI, ModelMap model, HttpServletRequest req, Locale locale) + throws UnsupportedEncodingException { Map> rawdatalinks = new LinkedHashMap>(); - String queryString = (req.getQueryString() != null ? "&" + req.getQueryString().replaceAll("&", "&") : ""); + String queryString = (req.getQueryString() != null ? "&" + req.getQueryString().replaceAll("&", "&") + : ""); if (conf.getRedirectionStrategy().equals("pubby")) { @@ -280,20 +290,24 @@ private void addDataLinks(String IRI, ModelMap model, HttpServletRequest req, Lo if (conf.getEndPointType().equals("virtuoso")) { { Map list = new LinkedHashMap(); - list.put("atom", conf.getEndPointUrl() + "?output=application%2Fatom%2Bxml&query=DESCRIBE+%3C" + IRI + "%3E"); - list.put("json", conf.getEndPointUrl() + "?output=application%2Fodata%2Bjson&query=DESCRIBE+%3C" + IRI + "%3E"); + list.put("atom", conf.getEndPointUrl() + "?output=application%2Fatom%2Bxml&query=DESCRIBE+%3C" + IRI + + "%3E"); + list.put("json", conf.getEndPointUrl() + "?output=application%2Fodata%2Bjson&query=DESCRIBE+%3C" + + IRI + "%3E"); rawdatalinks.put("odata:", list); } { Map list = new LinkedHashMap(); list.put("html", conf.getEndPointUrl() + "?output=text%2Fhtml&query=DESCRIBE+%3C" + IRI + "%3E"); - list.put("json", conf.getEndPointUrl() + "?output=application%2Fmicrodata%2Bjson&query=DESCRIBE+%3C" + IRI + "%3E"); + list.put("json", conf.getEndPointUrl() + "?output=application%2Fmicrodata%2Bjson&query=DESCRIBE+%3C" + + IRI + "%3E"); rawdatalinks.put("microdata:", list); } { Map list = new LinkedHashMap(); list.put("csv", conf.getEndPointUrl() + "?output=text%2Fcsv&query=DESCRIBE+%3C" + IRI + "%3E"); - list.put("cxml", conf.getEndPointUrl() + "?output=format=text%2Fcxml&query=DESCRIBE+%3C" + IRI + "%3E"); + list.put("cxml", + conf.getEndPointUrl() + "?output=format=text%2Fcxml&query=DESCRIBE+%3C" + IRI + "%3E"); rawdatalinks.put("rawdata:", list); } } @@ -312,9 +326,11 @@ private RedirectView redirect(HttpServletRequest req, String IRIsuffix) throws U // prefix mode String redirectUrl = conf.getHttpRedirectPrefix().replaceAll("^/", ""); if (conf.getRedirectionStrategy().equals("pubby")) { - r.setUrl(conf.getPublicUrlPrefix() + redirectUrl + IRIsuffix.replaceAll("^resource/", "") + (req.getQueryString() != null ? "?" + req.getQueryString() : "")); + r.setUrl(conf.getPublicUrlPrefix() + redirectUrl + IRIsuffix.replaceAll("^resource/", "") + + (req.getQueryString() != null ? "?" + req.getQueryString() : "")); } else { - r.setUrl(conf.getPublicUrlPrefix().replaceAll(IRIsuffix + "$", "") + redirectUrl + IRIsuffix + (req.getQueryString() != null ? "?" + req.getQueryString() : "")); + r.setUrl(conf.getPublicUrlPrefix().replaceAll(IRIsuffix + "$", "") + redirectUrl + IRIsuffix + + (req.getQueryString() != null ? "?" + req.getQueryString() : "")); } } else { // suffix mode @@ -325,15 +341,18 @@ private RedirectView redirect(HttpServletRequest req, String IRIsuffix) throws U // redirectUrl += URLEncoder.encode(string, "UTF-8") + "/"; // } // redirectUrl = redirectUrl.replaceAll("/$", ""); - r.setUrl(req.getRequestURL() + redirectUrl + (req.getQueryString() != null ? "?" + req.getQueryString() : "")); + r.setUrl(req.getRequestURL() + redirectUrl + + (req.getQueryString() != null ? "?" + req.getQueryString() : "")); } return r; } - private void addLodliveLink(Locale locale, ModelMap model, String IRI) { - if (locale.getLanguage().equals("it")) { + private void addLodliveLink(Locale locale, ModelMap model, String IRI, String lodlive) { + if (lodlive != null) { + model.addAttribute("lodliveUrl", lodlive + IRI.replaceAll("#", "%23")); + } else if (locale.getLanguage().equals("it")) { model.addAttribute("lodliveUrl", "http://lodlive.it?" + IRI.replaceAll("#", "%23")); } else if (locale.getLanguage().equals("fr")) { model.addAttribute("lodliveUrl", "http://fr.lodlive.it?" + IRI.replaceAll("#", "%23")); @@ -350,10 +369,13 @@ private void enrichResponse(ModelMap model, ResultBean r, HttpServletRequest req res.addHeader("Link", "<" + publicUrl + ">; rel=\"about\""); @SuppressWarnings("unchecked") - Map> rawdatalinks = (LinkedHashMap>) model.get("rawdatalinks"); + Map> rawdatalinks = (LinkedHashMap>) model + .get("rawdatalinks"); for (String k : rawdatalinks.keySet()) { for (String k1 : rawdatalinks.get(k).keySet()) { - res.addHeader("Link", "<" + rawdatalinks.get(k).get(k1) + ">; rel=\"alternate\"; type=\"application/rdf+xml\"; title=\"Structured Descriptor Document (" + k1 + ")\""); + res.addHeader("Link", "<" + rawdatalinks.get(k).get(k1) + + ">; rel=\"alternate\"; type=\"application/rdf+xml\"; title=\"Structured Descriptor Document (" + + k1 + ")\""); } } try { @@ -366,11 +388,15 @@ private void enrichResponse(ModelMap model, ResultBean r, HttpServletRequest req } @RequestMapping(value = "/rawdata") - public ResponseEntity resourceRawController(ModelMap model, @RequestParam(value = "IRI") String IRI, @RequestParam(value = "sparql") String sparql, @RequestParam(value = "contentType", defaultValue = "application/rdf+xml") String contentType) { + public ResponseEntity resourceRawController(ModelMap model, @RequestParam(value = "IRI") String IRI, + @RequestParam(value = "sparql") String sparql, + @RequestParam(value = "contentType", defaultValue = "application/rdf+xml") String contentType) { return resourceRaw(conf, model, IRI, sparql, contentType); } - public ResponseEntity resourceRaw(ConfigurationBean conf, ModelMap model, @RequestParam(value = "IRI") String IRI, @RequestParam(value = "sparql") String sparql, @RequestParam(value = "contentType", defaultValue = "application/rdf+xml") String contentType) { + public ResponseEntity resourceRaw(ConfigurationBean conf, ModelMap model, + @RequestParam(value = "IRI") String IRI, @RequestParam(value = "sparql") String sparql, + @RequestParam(value = "contentType", defaultValue = "application/rdf+xml") String contentType) { // System.out.println("ResourceController.resourceRaw()"); contentType = contentType.replaceAll("([a-zA-Z]) ([a-zA-Z])", "$1+$2"); Lang lang = RDFLanguages.contentTypeToLang(contentType); @@ -383,11 +409,16 @@ public ResponseEntity resourceRaw(ConfigurationBean conf, ModelMap model try { m.read(IRI); } catch (Exception e) { - throw new Exception(messageSource.getMessage("error.noContentNegotiation", null, "sorry but content negotiation is not supported by the IRI", Locale.ENGLISH)); + throw new Exception(messageSource.getMessage("error.noContentNegotiation", null, + "sorry but content negotiation is not supported by the IRI", Locale.ENGLISH)); } - return new ResponseEntity(new ResourceBuilder(messageSource).buildRDFResource(IRI, m, lang, conf), headers, HttpStatus.OK); + return new ResponseEntity( + new ResourceBuilder(messageSource).buildRDFResource(IRI, m, lang, conf), headers, + HttpStatus.OK); } else { - return new ResponseEntity(new ResourceBuilder(messageSource).buildRDFResource(IRI, sparql, lang, conf), headers, HttpStatus.OK); + return new ResponseEntity( + new ResourceBuilder(messageSource).buildRDFResource(IRI, sparql, lang, conf), headers, + HttpStatus.OK); } } catch (Exception e) { diff --git a/src/main/webapp/WEB-INF/conf.ttl b/src/main/webapp/WEB-INF/conf.ttl index d65fa94..c379384 100644 --- a/src/main/webapp/WEB-INF/conf.ttl +++ b/src/main/webapp/WEB-INF/conf.ttl @@ -5,14 +5,14 @@ @prefix xsd: . @prefix owl: . @prefix dc: . -@prefix dcterms: . +@prefix dcterms: . @prefix foaf: . @prefix skos: . @prefix geo: . -@prefix ocd: . +@prefix ocd: . @prefix units: . -@prefix geonames: . -@prefix void: . +@prefix geonames: . +@prefix void: . @prefix dbpedia-owl: . @prefix yago: . @prefix gml: . @@ -26,9 +26,9 @@ @prefix ibc: . @prefix bio: . @prefix ods: . -@prefix shoah: . -@prefix bibo: . -@prefix org: . +@prefix shoah: . +@prefix bibo: . +@prefix org: . @prefix bbc: . @prefix npg: . @prefix prism21: . @@ -58,23 +58,24 @@ ## first of all ## IRIs namespace we use to replace the webapp base (eg. http://localhost:8080/lodview/), an -## installation on dbpedia domain should use - +## installation on dbpedia domain should use + conf:IRInamespace ; ## EndPoint conf:endpoint ; - conf:endpointType "virtuoso"; ## just "virtuoso" is handled right now, this will add some "rawdata" + conf:lodliveUrl ; + conf:endpointType "virtuoso"; ## just "virtuoso" is handled right now, this will add some "rawdata" ## options in the footer, leave this blank if you don't want these links ########## give it a try opening http://localhost:8080/lodview/Rome ## we don't like it so much, but you can set a prefix to activate 303 redirects -## to the HTML representation of the resources, live it blank if you want to +## to the HTML representation of the resources, live it blank if you want to ## use the "pure content negotiation mode", WARNING use suffix OR prefix, not both - + conf:httpRedirectSuffix ".html"; ## or eg. ".html"; ##conf:httpRedirectPrefix "/page/"; ## or eg. ""; @@ -87,54 +88,54 @@ ## mode configurations - + conf:contentEncoding "UTF-8"; - - ## base64 HTTP authentication to the endpoint + + ## base64 HTTP authentication to the endpoint conf:authUsername ""; conf:authPassword ""; - - + + ## default query used to get direct properties, you can add a "FROM" clause here, -## ${IRI} will be replaced, it's always recommended to specify a limit for the query +## ${IRI} will be replaced, it's always recommended to specify a limit for the query ## the query can be seplified removing the last 2 unions to improve performance (usually not needed) - conf:defaultQueries """select distinct ?s ?p ?o { - {<${IRI}> ?p ?o} - UNION - {<${IRI}> ?p1 ?s . FILTER(isBlank(?s)) . ?s ?p ?o} - UNION + conf:defaultQueries """select distinct ?s ?p ?o { + {<${IRI}> ?p ?o} + UNION + {<${IRI}> ?p1 ?s . FILTER(isBlank(?s)) . ?s ?p ?o} + UNION {<${IRI}> ?p1 ?s1 . FILTER(isBlank(?s1)) . ?s1 ?p2 ?s . FILTER(isBlank(?s)) . ?s ?p ?o} - UNION - {<${IRI}> ?p1 ?s1 . FILTER(isBlank(?s1)) . ?s1 ?p2 ?s2 . FILTER(isBlank(?s2)) . ?s2 ?p3 ?s . FILTER(isBlank(?s)) . ?s ?p ?o} + UNION + {<${IRI}> ?p1 ?s1 . FILTER(isBlank(?s1)) . ?s1 ?p2 ?s2 . FILTER(isBlank(?s2)) . ?s2 ?p3 ?s . FILTER(isBlank(?s)) . ?s ?p ?o} } LIMIT 10000""" ; -## default query used to get resource to be included in serializations different -## from HTML, it's always recommended to specify a limit for the query +## default query used to get resource to be included in serializations different +## from HTML, it's always recommended to specify a limit for the query ## ${IRI} will be replaced ## the query can be seplified removing the last 2 unions to improve performance (usually not needed) - - conf:defaultRawDataQueries """select distinct ?s ?p ?o { - {<${IRI}> ?p ?o} - UNION - {<${IRI}> ?p1 ?s . FILTER(isBlank(?s)) . ?s ?p ?o} - UNION + + conf:defaultRawDataQueries """select distinct ?s ?p ?o { + {<${IRI}> ?p ?o} + UNION + {<${IRI}> ?p1 ?s . FILTER(isBlank(?s)) . ?s ?p ?o} + UNION {<${IRI}> ?p1 ?s1 . FILTER(isBlank(?s1)) . ?s1 ?p2 ?s . FILTER(isBlank(?s)) . ?s ?p ?o} - UNION - {<${IRI}> ?p1 ?s1 . FILTER(isBlank(?s1)) . ?s1 ?p2 ?s2 . FILTER(isBlank(?s2)) . ?s2 ?p3 ?s . FILTER(isBlank(?s)) . ?s ?p ?o} + UNION + {<${IRI}> ?p1 ?s1 . FILTER(isBlank(?s1)) . ?s1 ?p2 ?s2 . FILTER(isBlank(?s2)) . ?s2 ?p3 ?s . FILTER(isBlank(?s)) . ?s ?p ?o} } LIMIT 10000""" ; ## default query used to extract inverse relations - conf:defaultInversesQueries "select distinct ?p {?p <${PROPERTY}> <${IRI}>.} OFFSET ${STARTFROM} LIMIT 10"; + conf:defaultInversesQueries "select distinct ?p {?p <${PROPERTY}> <${IRI}>.} OFFSET ${STARTFROM} LIMIT 10"; conf:defaultInversesCountQueries "select (count(distinct ?s) AS ?o) ?p {?s ?p <${IRI}>. FILTER(!isBlank(?s))} GROUP BY ?p LIMIT 100"; conf:defaultInversesTest "ASK {?s ?p <${IRI}>}"; ## define if inverse relations have to be automatically opened (open|close) - conf:defaultInverseBehaviour "close"; + conf:defaultInverseBehaviour "close"; ######################################################################################## ######################## configuring the webapp ######################## @@ -155,37 +156,37 @@ conf:homeUrl ; - -## static resources publishing point, "staticResources/" is needed if you are going -## to serve static content within the web application, probably on a production -## environment you have to change "http://localhost:8080/lodview/" to something like + +## static resources publishing point, "staticResources/" is needed if you are going +## to serve static content within the web application, probably on a production +## environment you have to change "http://localhost:8080/lodview/" to something like ## "http://data.yourdomain.com/staticResources/", on a test environment you can set it ## at - + conf:staticResourceURL ; - + ## choosing the lower class in hierarchy to put it on the top right of the page ## put in mainOntologies the prefixes you need to filter the resource's classes ## you need also to add the ontology file in WEB-INF/ontologies -## leave conf:mainOntologies blank if you don't want lodlive do this job +## leave conf:mainOntologies blank if you don't want lodlive do this job -## conf:mainOntologiesPrefixes YOUR-PREFIX:; +## conf:mainOntologiesPrefixes YOUR-PREFIX:; ## document specific property used in the HTML resource page, it's possible to use ## prefixes or not conf:typeProperties rdf:type; - - conf:titleProperties dc:title , dcterms:title, rdfs:label , , - , , - gn:officialName , gn:name , rdf:value , foaf:surname , , ; - - conf:descriptionProperties rdfs:comment , dc:description , dcterms:description , + + conf:titleProperties dc:title , dcterms:title, rdfs:label , , + , , + gn:officialName , gn:name , rdf:value , foaf:surname , , ; + + conf:descriptionProperties rdfs:comment , dc:description , dcterms:description , dc:description , skos:definition , ; - + conf:imageProperties foaf:depiction , , crm-owl:P138i_has_representation , ; - + conf:longitudeProperties geo:long; conf:latitudeProperties geo:lat; conf:linkingProperties owl:sameAs , skos:exactMatch , gn:locatedIn , ; @@ -194,35 +195,35 @@ conf:audioProperties ; ## preferred language for title and description ("auto" for delegate to the client) - + conf:preferredLanguage "auto"; ## eg. "en" or "it" ## interface colors, choose a pair or a list for random colors conf:colorPair "#c3a116-#ac8c13" , "#914848-#7d3e3e" , "#8a4e6a-#77435c" , "#ac8cb0-#967999" , - "#715287-#624775" , "#606592-#53577e" , "#7eb9be-#6da2a7" , "#5b8a97-#4f7783" , + "#715287-#624775" , "#606592-#53577e" , "#7eb9be-#6da2a7" , "#5b8a97-#4f7783" , "#86b692-#749f7e" , "#528775-#477565" , "#6d8058-#5e6f4c" , "#a1a72e-#8c9128" , "#c77e20-#ad6e1c" ; - + #### or bind classes and colors -## +## ## conf:colorPair conf:byClass; - + ## license information (will be added at the very end of the page) - conf:license "" ; ## eg. "Licensed under Creative Commons Attribution 4.0 International (CC BY 4.0)" ; - + conf:license "" ; ## eg. "Licensed under Creative Commons Attribution 4.0 International (CC BY 4.0)" ; + ## just a marker to insert a point on the last row - + conf:last ".". - + #### uncomment only if you have configured "colors by class" ## ## conf:hasColorPair "#c3a116-#ac8c13". -## ontology:Place conf:hasColorPair "#715287-#624775". -## conf:hasColorPair "#914848-#7d3e3e". -## conf:hasColorPair "#6d8058-#5e6f4c". -## conf:hasColorPair "#5b8a97-#4f7783". -## conf:hasColorPair "#528775-#477565". +## ontology:Place conf:hasColorPair "#715287-#624775". +## conf:hasColorPair "#914848-#7d3e3e". +## conf:hasColorPair "#6d8058-#5e6f4c". +## conf:hasColorPair "#5b8a97-#4f7783". +## conf:hasColorPair "#528775-#477565". diff --git a/src/main/webapp/WEB-INF/views/resource.jsp b/src/main/webapp/WEB-INF/views/resource.jsp index 30f3dec..4f30d5b 100644 --- a/src/main/webapp/WEB-INF/views/resource.jsp +++ b/src/main/webapp/WEB-INF/views/resource.jsp @@ -4,7 +4,7 @@ <%@include file="inc/header.jsp"%>
    -
    +
    @@ -22,12 +22,12 @@ - +
    - +
    @@ -192,4 +192,4 @@
    - \ No newline at end of file + From 8632d79322dd026c7cd1ac7e04b127caa7340827 Mon Sep 17 00:00:00 2001 From: Luigi Asprino Date: Mon, 27 Jan 2020 19:54:55 +0100 Subject: [PATCH 3/6] lodliveUrl fixed --- .../java/org/dvcama/lodview/controllers/ResourceController.java | 2 +- src/main/webapp/WEB-INF/views/resource.jsp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/dvcama/lodview/controllers/ResourceController.java b/src/main/java/org/dvcama/lodview/controllers/ResourceController.java index 7420e46..2d0b48f 100644 --- a/src/main/java/org/dvcama/lodview/controllers/ResourceController.java +++ b/src/main/java/org/dvcama/lodview/controllers/ResourceController.java @@ -351,7 +351,7 @@ private RedirectView redirect(HttpServletRequest req, String IRIsuffix) throws U private void addLodliveLink(Locale locale, ModelMap model, String IRI, String lodlive) { if (lodlive != null) { - model.addAttribute("lodliveUrl", lodlive + IRI.replaceAll("#", "%23")); + model.addAttribute("lodliveUrl", lodlive + "?" + IRI.replaceAll("#", "%23")); } else if (locale.getLanguage().equals("it")) { model.addAttribute("lodliveUrl", "http://lodlive.it?" + IRI.replaceAll("#", "%23")); } else if (locale.getLanguage().equals("fr")) { diff --git a/src/main/webapp/WEB-INF/views/resource.jsp b/src/main/webapp/WEB-INF/views/resource.jsp index 4f30d5b..aad808d 100644 --- a/src/main/webapp/WEB-INF/views/resource.jsp +++ b/src/main/webapp/WEB-INF/views/resource.jsp @@ -24,7 +24,7 @@
    - +
    From f27d060bcc5a725adf3e18cfa2353d5bcc1c9f21 Mon Sep 17 00:00:00 2001 From: Luigi Asprino Date: Mon, 27 Jan 2020 21:27:23 +0100 Subject: [PATCH 4/6] Parameterized LodLiveURL --- .../java/org/dvcama/lodview/controllers/ResourceController.java | 2 -- src/main/webapp/WEB-INF/views/inc/footer.jsp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/dvcama/lodview/controllers/ResourceController.java b/src/main/java/org/dvcama/lodview/controllers/ResourceController.java index 2d0b48f..f3b05af 100644 --- a/src/main/java/org/dvcama/lodview/controllers/ResourceController.java +++ b/src/main/java/org/dvcama/lodview/controllers/ResourceController.java @@ -3,7 +3,6 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.LinkedHashMap; -import java.util.List; import java.util.Locale; import java.util.Map; @@ -30,7 +29,6 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.CookieValue; - import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.view.RedirectView; diff --git a/src/main/webapp/WEB-INF/views/inc/footer.jsp b/src/main/webapp/WEB-INF/views/inc/footer.jsp index 7a12268..49d4267 100644 --- a/src/main/webapp/WEB-INF/views/inc/footer.jsp +++ b/src/main/webapp/WEB-INF/views/inc/footer.jsp @@ -13,7 +13,7 @@
  • ${conf.getEndPointUrl()}
  • - +
  • ${list} From 577b51096b3bcfbe3d4dae07d8417f3b213e7f09 Mon Sep 17 00:00:00 2001 From: Luigi Asprino Date: Mon, 27 Jan 2020 21:27:23 +0100 Subject: [PATCH 5/6] Parameterized LodLiveURL --- .../java/org/dvcama/lodview/controllers/ResourceController.java | 2 -- src/main/webapp/WEB-INF/conf.ttl | 2 +- src/main/webapp/WEB-INF/views/inc/footer.jsp | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/dvcama/lodview/controllers/ResourceController.java b/src/main/java/org/dvcama/lodview/controllers/ResourceController.java index 2d0b48f..f3b05af 100644 --- a/src/main/java/org/dvcama/lodview/controllers/ResourceController.java +++ b/src/main/java/org/dvcama/lodview/controllers/ResourceController.java @@ -3,7 +3,6 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.LinkedHashMap; -import java.util.List; import java.util.Locale; import java.util.Map; @@ -30,7 +29,6 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.CookieValue; - import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.view.RedirectView; diff --git a/src/main/webapp/WEB-INF/conf.ttl b/src/main/webapp/WEB-INF/conf.ttl index c379384..4aed36a 100644 --- a/src/main/webapp/WEB-INF/conf.ttl +++ b/src/main/webapp/WEB-INF/conf.ttl @@ -65,7 +65,7 @@ ## EndPoint conf:endpoint ; - conf:lodliveUrl ; + #conf:lodliveUrl ; conf:endpointType "virtuoso"; ## just "virtuoso" is handled right now, this will add some "rawdata" ## options in the footer, leave this blank if you don't want these links diff --git a/src/main/webapp/WEB-INF/views/inc/footer.jsp b/src/main/webapp/WEB-INF/views/inc/footer.jsp index 7a12268..49d4267 100644 --- a/src/main/webapp/WEB-INF/views/inc/footer.jsp +++ b/src/main/webapp/WEB-INF/views/inc/footer.jsp @@ -13,7 +13,7 @@
  • ${conf.getEndPointUrl()}
  • - +
  • ${list} From 2801abb093b3eac04fe3d7c22be97fc41f3899d1 Mon Sep 17 00:00:00 2001 From: Luigi Asprino Date: Wed, 29 Jan 2020 15:28:54 +0100 Subject: [PATCH 6/6] Conflict Resolved --- .../java/org/dvcama/lodview/conf/ConfigurationBean.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/dvcama/lodview/conf/ConfigurationBean.java b/src/main/java/org/dvcama/lodview/conf/ConfigurationBean.java index f038abb..38dc08d 100644 --- a/src/main/java/org/dvcama/lodview/conf/ConfigurationBean.java +++ b/src/main/java/org/dvcama/lodview/conf/ConfigurationBean.java @@ -44,10 +44,11 @@ public class ConfigurationBean implements ServletContextAware, Cloneable { private String authPassword = null; private String defaultInverseBehaviour = "collapse"; - private List defaultQueries = null, defaultRawDataQueries = null, defaultInversesQueries = null, - defaultInversesTest = null, defaultInversesCountQueries = null, typeProperties = null, - audioProperties = null, imageProperties = null, videoProperties = null, linkingProperties = null, - titleProperties = null, descriptionProperties = null, longitudeProperties = null, latitudeProperties = null; + public enum ColorStrategy {RANDOM, CLASS, PREFIX} + private ColorStrategy colorStrategy = ColorStrategy.RANDOM; + public ColorStrategy getColorStrategy() {return colorStrategy;} + + private List defaultQueries = null, defaultRawDataQueries = null, defaultInversesQueries = null, defaultInversesTest = null, defaultInversesCountQueries = null, typeProperties = null, audioProperties = null, imageProperties = null, videoProperties = null, linkingProperties = null, titleProperties = null, descriptionProperties = null, longitudeProperties = null, latitudeProperties = null; private List colorPair = null, skipDomains = null, mainOntologiesPrefixes = null; private Map colorPairMatcher = null;