Mercurial > hg > ismi-richfaces
changeset 157:2522985f44af
add "query builder" button to entityDetails form.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 20 Oct 2017 12:44:15 +0200 |
parents | d305a1b3e4c9 |
children | 92c4c9f7312a c89eefa59835 |
files | src/main/java/de/mpiwg/itgroup/ismi/entry/beans/ApplicationBean.java src/main/resources/openmind.properties.template src/main/webapp/browse/entityDetails.xhtml |
diffstat | 3 files changed, 33 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/ApplicationBean.java Fri Oct 20 12:42:28 2017 +0200 +++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/ApplicationBean.java Fri Oct 20 12:44:15 2017 +0200 @@ -1,6 +1,9 @@ package de.mpiwg.itgroup.ismi.entry.beans; import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -9,11 +12,11 @@ import javax.faces.model.SelectItem; import javax.servlet.http.HttpServletRequest; +import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.mpi.openmind.cache.WrapperService; import org.mpi.openmind.configuration.ConfigurationService; -import org.mpi.openmind.repository.bo.Attribute; import org.mpi.openmind.repository.bo.Entity; import org.mpi.openmind.repository.services.ServiceRegistry; import org.mpi.openmind.search.SearchService; @@ -106,6 +109,29 @@ return sb.toString(); } + /** + * Returns a URL to the configured QueryBrowser webapp with the query set to the given id. + * + * @param id + * @return + */ + public String generateQueryBrowserUrlForId(Long id) { + String baseUrl = this.getConfService().getQueryBrowserUrl(); + // generate id_is query for id + String query = String.format("[[\"id_is\",{\"value\":%d}]]", id); + try { + // encode URL and base64 + String encquery = URLEncoder.encode(query, StandardCharsets.UTF_8.toString()); + String b64query = Base64.encodeBase64String(encquery.getBytes()); + String url = baseUrl + "#" + b64query; + return url; + } catch (UnsupportedEncodingException e) { + // this shouldn't happen + logger.error(e); + } + return null; + } + public static String CURRENT_WITNESS = "CurrentWitness"; public static String CURRENT_CODEX = "CurrentCodex"; public static String CURRENT_TEXT = "CurrentText";
--- a/src/main/resources/openmind.properties.template Fri Oct 20 12:42:28 2017 +0200 +++ b/src/main/resources/openmind.properties.template Fri Oct 20 12:44:15 2017 +0200 @@ -1,4 +1,5 @@ scheduling-path=/tmp/ #scheduling-path=/home/jurzua/ismi/automatic-backup scheduling-enable=false -debug-modus=false \ No newline at end of file +debug-modus=false +query-browser-url=https://ismi.mpiwg-berlin.mpg.de/static-ismi/ng2-query-ismi/
--- a/src/main/webapp/browse/entityDetails.xhtml Fri Oct 20 12:42:28 2017 +0200 +++ b/src/main/webapp/browse/entityDetails.xhtml Fri Oct 20 12:44:15 2017 +0200 @@ -50,17 +50,16 @@ rendered="#{Session.canEdit}" action="#{Session.entDetailsForm.actionEdit}" style="margin-right: 20px;" /> - <h:commandButton value="Get previous versions" - title="Get previous versions" rendered="#{Session.canEdit}" - image="#{ApplicationBean1.imgVersions32}" - actionListener="#{Session.entDetailsForm.listenerGetPreviousVersions}" - style="margin-right: 20px;" /> <h:commandButton value="Remove" title="Remove this entity" rendered="#{Session.canDelete}" image="#{ApplicationBean1.imgRemove32}" onclick="if(!confirm('Do you really want to remove this entity?')){ return; };" action="#{Session.entDetailsForm.listenerDeleteEntity}" style="margin-right: 20px;" /> + <h:commandButton value="Query Builder" + onclick="window.open('#{ApplicationBean1.generateQueryBrowserUrlForId(Session.entDetailsForm.entity.id)}')" + title="Start Query Builder with this id" + type="button"/> </h:panelGroup> <h:outputText value="Modified by: #{Session.entDetailsForm.entity.user} - Last modification: #{Session.entDetailsForm.entity.timeStamp}"