Salvatore La Manna
4 anni fa
70 ha cambiato i file con 3049 aggiunte e 1490 eliminazioni
File binario non mostrato.
@ -0,0 +1,61 @@ |
|||||||
|
package it.mwg.sismica.bo.util; |
||||||
|
|
||||||
|
import it.tref.liferay.portos.bo.model.Comune; |
||||||
|
import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil; |
||||||
|
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants; |
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException; |
||||||
|
import java.net.URLEncoder; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
import org.apache.commons.codec.digest.DigestUtils; |
||||||
|
import org.apache.commons.lang.StringUtils; |
||||||
|
|
||||||
|
import com.liferay.portal.kernel.exception.PortalException; |
||||||
|
import com.liferay.portal.kernel.exception.SystemException; |
||||||
|
import com.liferay.portal.kernel.log.Log; |
||||||
|
import com.liferay.portal.kernel.log.LogFactoryUtil; |
||||||
|
import com.liferay.portal.kernel.util.StringPool; |
||||||
|
|
||||||
|
public class MappeUtil { |
||||||
|
private final static Log _log = LogFactoryUtil.getLog(MappeUtil.class); |
||||||
|
|
||||||
|
public static String getUrlComune(String serverName, Comune comune) throws UnsupportedEncodingException, |
||||||
|
PortalException, SystemException { |
||||||
|
long companyId = comune.getCompanyId(); |
||||||
|
|
||||||
|
String sharedSecret = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(companyId, |
||||||
|
ConfigurazioneConstants.MAPPE_SHARED_SECRET); |
||||||
|
long date = new Date().getTime() / 1000; |
||||||
|
String auth = DigestUtils.sha256Hex(date + sharedSecret + serverName); |
||||||
|
|
||||||
|
String url = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(companyId, |
||||||
|
ConfigurazioneConstants.MAPPE_URL_IFRAME_FE).replace("{{COD_BELFIORE}}", |
||||||
|
urlEncode(comune.getCodiceBelfiore())); |
||||||
|
|
||||||
|
String query = StringPool.BLANK; |
||||||
|
String[] parti = StringUtils.split(url, StringPool.QUESTION); |
||||||
|
if (parti.length > 1) { |
||||||
|
query = parti[1]; |
||||||
|
} |
||||||
|
if (query == null) { |
||||||
|
query = StringPool.BLANK; |
||||||
|
} else if (!query.equals(StringPool.BLANK)) { |
||||||
|
query += StringPool.AMPERSAND; |
||||||
|
} |
||||||
|
query += "date=" + date + "&auth=" + auth; |
||||||
|
url = parti[0] + StringPool.QUESTION + query; |
||||||
|
_log.info(url); |
||||||
|
return url; |
||||||
|
} |
||||||
|
|
||||||
|
private static String urlEncode(String str) { |
||||||
|
String encoded; |
||||||
|
try { |
||||||
|
encoded = URLEncoder.encode(str, StringPool.UTF8); |
||||||
|
} catch (UnsupportedEncodingException e) { |
||||||
|
encoded = str; |
||||||
|
} |
||||||
|
return encoded; |
||||||
|
} |
||||||
|
} |
File diff soppresso perché troppo grande
Load Diff
@ -0,0 +1,100 @@ |
|||||||
|
package it.mwg.sismica.bo.portlet; |
||||||
|
|
||||||
|
import it.tref.liferay.portos.bo.model.Comune; |
||||||
|
import it.tref.liferay.portos.bo.model.Provincia; |
||||||
|
import it.tref.liferay.portos.bo.service.ComuneLocalServiceUtil; |
||||||
|
import it.tref.liferay.portos.bo.service.ProvinciaLocalServiceUtil; |
||||||
|
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import javax.portlet.ActionRequest; |
||||||
|
import javax.portlet.ActionResponse; |
||||||
|
import javax.portlet.PortletException; |
||||||
|
import javax.portlet.ResourceRequest; |
||||||
|
import javax.portlet.ResourceResponse; |
||||||
|
|
||||||
|
import com.liferay.portal.kernel.exception.PortalException; |
||||||
|
import com.liferay.portal.kernel.exception.SystemException; |
||||||
|
import com.liferay.portal.kernel.json.JSONArray; |
||||||
|
import com.liferay.portal.kernel.json.JSONFactoryUtil; |
||||||
|
import com.liferay.portal.kernel.json.JSONObject; |
||||||
|
import com.liferay.portal.kernel.log.Log; |
||||||
|
import com.liferay.portal.kernel.log.LogFactoryUtil; |
||||||
|
import com.liferay.portal.kernel.util.ParamUtil; |
||||||
|
import com.liferay.portal.kernel.util.StringPool; |
||||||
|
import com.liferay.portal.kernel.util.Validator; |
||||||
|
import com.liferay.portal.service.ServiceContext; |
||||||
|
import com.liferay.portal.service.ServiceContextFactory; |
||||||
|
import com.liferay.util.bridges.mvc.MVCPortlet; |
||||||
|
|
||||||
|
public class RicercaPosizionePortlet extends MVCPortlet { |
||||||
|
private static final Log _log = LogFactoryUtil.getLog(RicercaPosizionePortlet.class); |
||||||
|
|
||||||
|
@SuppressWarnings("serial") |
||||||
|
private static final List<String> campi = new ArrayList<String>() { |
||||||
|
{ |
||||||
|
add("provincia"); |
||||||
|
add("comune"); |
||||||
|
add("via"); |
||||||
|
add("lat"); |
||||||
|
add("long"); |
||||||
|
add("raggio"); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
public void ricerca(ActionRequest actionRequest, ActionResponse actionResponse) { |
||||||
|
// PortalUtil.copyRequestParameters(actionRequest, actionResponse);
|
||||||
|
for (String campo : campi) { |
||||||
|
String val = ParamUtil.getString(actionRequest, campo, StringPool.BLANK); |
||||||
|
actionResponse.setRenderParameter(campo, val); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) |
||||||
|
throws IOException, PortletException { |
||||||
|
String id = resourceRequest.getResourceID(); |
||||||
|
ServiceContext serviceContext; |
||||||
|
try { |
||||||
|
serviceContext = ServiceContextFactory.getInstance(resourceRequest); |
||||||
|
long companyId = serviceContext.getCompanyId(); |
||||||
|
JSONArray array = JSONFactoryUtil.createJSONArray(); |
||||||
|
switch (id) { |
||||||
|
case "province": |
||||||
|
for (String codice : TerritorioLocalServiceUtil.getActiveProvince()) { |
||||||
|
JSONObject object = JSONFactoryUtil.createJSONObject(); |
||||||
|
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(companyId, codice); |
||||||
|
object.put("id", provincia.getCodiceProvincia()); |
||||||
|
object.put("nome", provincia.getProvincia()); |
||||||
|
|
||||||
|
array.put(object); |
||||||
|
} |
||||||
|
writeJSON(resourceRequest, resourceResponse, array); |
||||||
|
break; |
||||||
|
case "comuni": |
||||||
|
String provinciaId = ParamUtil.getString(resourceRequest, "provinciaId"); |
||||||
|
if (Validator.isNotNull(provinciaId)) { |
||||||
|
List<Long> comuni = TerritorioLocalServiceUtil |
||||||
|
.getActiveComuniByCodiceProvincia(provinciaId); |
||||||
|
for (long comuneId : comuni) { |
||||||
|
JSONObject object = JSONFactoryUtil.createJSONObject(); |
||||||
|
Comune comune = ComuneLocalServiceUtil.getComune(comuneId); |
||||||
|
object.put("id", comune.getComuneId()); |
||||||
|
object.put("nome", comune.getDenominazione()); |
||||||
|
|
||||||
|
array.put(object); |
||||||
|
} |
||||||
|
} |
||||||
|
writeJSON(resourceRequest, resourceResponse, array); |
||||||
|
break; |
||||||
|
default: |
||||||
|
super.serveResource(resourceRequest, resourceResponse); |
||||||
|
} |
||||||
|
} catch (PortalException | SystemException e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,2 +1,3 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
||||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"/> |
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> |
||||||
|
</web-app> |
@ -0,0 +1,440 @@ |
|||||||
|
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> |
||||||
|
<%@include file="/html/init.jsp" %> |
||||||
|
<%@page import="com.liferay.portal.kernel.util.HtmlUtil"%> |
||||||
|
<%@page import="it.tref.liferay.portos.bo.shared.util.PortletKeys"%> |
||||||
|
<%@page import="it.tref.liferay.portos.bo.shared.util.TipoIntegrazioneUtil"%> |
||||||
|
<%@page import="it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil"%> |
||||||
|
<%@page import="it.tref.liferay.portos.bo.util.PraticaUtil"%> |
||||||
|
<%@page import="java.text.NumberFormat"%> |
||||||
|
<%@page import="java.text.DecimalFormat"%> |
||||||
|
<%@page import="java.util.ArrayList"%> |
||||||
|
<%@page import="java.util.Locale"%> |
||||||
|
<%@page import="javax.portlet.PortletURL"%> |
||||||
|
<% |
||||||
|
|
||||||
|
String codiceProvincia = ParamUtil.getString(request, "provincia", StringPool.BLANK); |
||||||
|
String idComune = ParamUtil.getString(request, "comune", StringPool.BLANK); |
||||||
|
String via = ParamUtil.getString(request, "via", StringPool.BLANK); |
||||||
|
String lat = ParamUtil.getString(request, "lat", StringPool.BLANK); |
||||||
|
String lng = ParamUtil.getString(request, "long", StringPool.BLANK); |
||||||
|
String raggio = ParamUtil.getString(request, "raggio", StringPool.BLANK); |
||||||
|
|
||||||
|
PortletURL iteratorURL = liferayPortletResponse.createRenderURL(); |
||||||
|
if (Validator.isNotNull(codiceProvincia)) { |
||||||
|
iteratorURL.setParameter("provincia", codiceProvincia); |
||||||
|
} |
||||||
|
if (Validator.isNotNull(idComune)) { |
||||||
|
iteratorURL.setParameter("comune", idComune); |
||||||
|
} |
||||||
|
if (Validator.isNotNull(via)) { |
||||||
|
iteratorURL.setParameter("via", via); |
||||||
|
} |
||||||
|
if (Validator.isNotNull(lat)) { |
||||||
|
iteratorURL.setParameter("lat", lat); |
||||||
|
} |
||||||
|
if (Validator.isNotNull(lng)) { |
||||||
|
iteratorURL.setParameter("long", lng); |
||||||
|
} |
||||||
|
if (Validator.isNotNull(raggio)) { |
||||||
|
iteratorURL.setParameter("raggio", raggio); |
||||||
|
} |
||||||
|
DecimalFormat fmt = (DecimalFormat) NumberFormat.getInstance(Locale.ITALY); |
||||||
|
boolean showNotes = false; |
||||||
|
int[] raggi = { 1, 2, 3, 5, 10 }; |
||||||
|
|
||||||
|
%> |
||||||
|
<div class="container-fluid"> |
||||||
|
<div class="row"> |
||||||
|
<div class="module-group"> |
||||||
|
<liferay-ui:panel extended="false" defaultState="open" collapsible="false" title="ricerca-posizione"> |
||||||
|
<div class="container-fluid"> |
||||||
|
<div class="row"> |
||||||
|
<div class="col-xs-6"> |
||||||
|
<liferay-portlet:actionURL name="ricerca" var="ricercaURL" /> |
||||||
|
<aui:form method="POST" name="ricerca" action="<%= ricercaURL %>"> |
||||||
|
<div class="row"> |
||||||
|
<div class="col-xs-12 col-md-6"> |
||||||
|
<aui:select name="provincia" label="dp-dc-prov" showEmptyOption="true"> |
||||||
|
</aui:select> |
||||||
|
</div> |
||||||
|
<div class="col-xs-12 col-md-6"> |
||||||
|
<aui:select name="comune" label="dp-dc-comune" showEmptyOption="true"> |
||||||
|
</aui:select> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="row"> |
||||||
|
<div class="col-xs-12"> |
||||||
|
<aui:input name="via" label="dp-dc-via" /> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="row"> |
||||||
|
<div class="col-xs-12"> |
||||||
|
<aui:button name="localizzaBtn" cssClass="btn btn-primary pull-right" onClick="localize(true)" value="Localizza"/> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="row"> |
||||||
|
<div class="col-xs-12 col-md-6"> |
||||||
|
<aui:input name="lat" label="dp-lat"/> |
||||||
|
</div> |
||||||
|
<div class="col-xs-12 col-md-6"> |
||||||
|
<aui:input name="long" label="dp-long"/> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="row"> |
||||||
|
<div class="col-xs-12 col-md-6"> |
||||||
|
<aui:select name="raggio" label="dp-raggio"> |
||||||
|
<% for (int i = 0; i < raggi.length; i++) { %> |
||||||
|
<aui:option value="<%= raggi[i] * 1000 %>"><%= raggi[i] %> Km</aui:option> |
||||||
|
<% } %> |
||||||
|
</aui:select> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<aui:button type="submit" value="search" /> |
||||||
|
</aui:form> |
||||||
|
</div> |
||||||
|
<div class="col-xs-6"> |
||||||
|
<c:set var="mapitNamespace" scope="request" value="<%= renderResponse.getNamespace() %>" /> |
||||||
|
<liferay-portlet:runtime portletName="<%= PortletKeys.MAPIT %>" |
||||||
|
queryString="&mapitNamespace=${mapitNamespace}&verifyComune=false" /> |
||||||
|
<aui:input type="hidden" name="geoIsEditable" value="true" /> |
||||||
|
<aui:input type="hidden" name="lat_hidden" value="" /> |
||||||
|
<aui:input type="hidden" name="long_hidden" value="" /> |
||||||
|
<aui:input type="hidden" name="zoom" value="12" /> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</liferay-ui:panel> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="row"> |
||||||
|
<liferay-ui:search-container emptyResultsMessage="no-entries-were-found" iteratorURL="<%= iteratorURL %>" > |
||||||
|
<% |
||||||
|
int indice = searchContainer.getStart(); |
||||||
|
double dlat = 0; |
||||||
|
double dlng = 0; |
||||||
|
List<IntPratica> pratiche; |
||||||
|
try { |
||||||
|
dlat = Double.valueOf(lat); |
||||||
|
dlng = Double.valueOf(lng); |
||||||
|
int iraggio = Integer.valueOf(raggio); |
||||||
|
pratiche = IntPraticaLocalServiceUtil.findByPosizione(dlat, dlng, iraggio, indice, |
||||||
|
searchContainer.getEnd()); |
||||||
|
searchContainer.setTotal(IntPraticaLocalServiceUtil.countByPosizione(dlat, dlng, iraggio)); |
||||||
|
showNotes = pratiche.size() > 0; |
||||||
|
} catch (Exception e) { |
||||||
|
pratiche = new ArrayList<IntPratica>(); |
||||||
|
searchContainer.setTotal(0); |
||||||
|
} |
||||||
|
%> |
||||||
|
<liferay-ui:search-container-results results="<%= pratiche %>" /> |
||||||
|
<liferay-ui:search-container-row className="it.tref.liferay.portos.bo.model.IntPratica" modelVar="pratica"> |
||||||
|
<% |
||||||
|
long intPraticaId = pratica.getIntPraticaId(); |
||||||
|
DettPratica dettaglio = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica( |
||||||
|
intPraticaId); |
||||||
|
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(pratica.getTerritorioId()); |
||||||
|
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId()); |
||||||
|
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(themeDisplay.getCompanyId(), |
||||||
|
comune.getCodiceProvincia()); |
||||||
|
|
||||||
|
Soggetto titolare = null; |
||||||
|
String committenti = StringPool.BLANK; |
||||||
|
String esito = StringPool.BLANK; |
||||||
|
|
||||||
|
if (Validator.isNotNull(dettaglio)) { |
||||||
|
List<Soggetto> titolari = SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale( |
||||||
|
intPraticaId, dettaglio.getCodiceFiscaleDelegatoCommittente()); |
||||||
|
if (!titolari.isEmpty()) { |
||||||
|
titolare = titolari.get(0); |
||||||
|
} |
||||||
|
StringBuilder builder = new StringBuilder(); |
||||||
|
List<Soggetto> soggetti = SoggettoLocalServiceUtil |
||||||
|
.findByIntPratica_TipologiaSoggetto(intPraticaId, TipoSoggettoUtil.COMMITTENTE); |
||||||
|
for (Soggetto soggetto : soggetti) { |
||||||
|
if (builder.length() > 0) { |
||||||
|
builder.append("<hr/>"); |
||||||
|
} |
||||||
|
builder.append(soggetto.getTitle()) |
||||||
|
.append("<br/>") |
||||||
|
.append(soggetto.getCodiceFiscale()); |
||||||
|
} |
||||||
|
committenti = builder.toString(); |
||||||
|
esito = LanguageUtil.get(pageContext, PraticaUtil.getStatoPraticaLabel( |
||||||
|
pratica.getStatoPratica(), intPraticaId)); |
||||||
|
} |
||||||
|
List<Avviso> avvisi = AvvisoLocalServiceUtil.findByIntPratica(intPraticaId, |
||||||
|
QueryUtil.ALL_POS, |
||||||
|
QueryUtil.ALL_POS, |
||||||
|
OrderByComparatorFactoryUtil.create("portos_bo_Avviso", "createDate", false)); |
||||||
|
int variantiCount = DettPraticaLocalServiceUtil.countCompletedByIntPraticaAndTipoPratica( |
||||||
|
intPraticaId, Arrays.asList(TipoIntegrazioneUtil.VARIANTE)); |
||||||
|
int integrazioniCount = DettPraticaLocalServiceUtil.countCompletedByIntPraticaAndTipoPratica( |
||||||
|
intPraticaId, Arrays.asList(TipoIntegrazioneUtil.RICHIESTA_INTEGRAZIONE)); |
||||||
|
%> |
||||||
|
|
||||||
|
<liferay-portlet:renderURL var="viewURL" > |
||||||
|
<liferay-portlet:param name="mvcPath" value="/html/fascicolo/view_fascicolo.jsp"/> |
||||||
|
<liferay-portlet:param name="intPraticaId" value="<%= String.valueOf(intPraticaId) %>" /> |
||||||
|
<liferay-portlet:param name="backURL" value="<%= iteratorURL.toString() %>" /> |
||||||
|
</liferay-portlet:renderURL> |
||||||
|
|
||||||
|
<liferay-ui:search-container-column-text name="#" cssClass="text-center"> |
||||||
|
<%= ++indice %> |
||||||
|
</liferay-ui:search-container-column-text> |
||||||
|
|
||||||
|
<liferay-ui:search-container-column-text name="distanza" title="distanza-tooltip" cssClass="text-center"> |
||||||
|
<%= fmt.format(pratica.getDistanzaOrtodromica()) %> |
||||||
|
</liferay-ui:search-container-column-text> |
||||||
|
|
||||||
|
<liferay-ui:search-container-column-text name="n-progetto" cssClass="text-nowrap"> |
||||||
|
<%= pratica.getTitle(locale, true) %> |
||||||
|
</liferay-ui:search-container-column-text> |
||||||
|
|
||||||
|
<liferay-ui:search-container-column-text name="titolare-digitale" href="<%= viewURL %>" cssClass="text-nowrap"> |
||||||
|
<c:if test="<%= Validator.isNotNull(titolare) %>"> |
||||||
|
<%= titolare.getTitle() %><br/><%= titolare.getCodiceFiscale() %> |
||||||
|
</c:if> |
||||||
|
</liferay-ui:search-container-column-text> |
||||||
|
|
||||||
|
<liferay-ui:search-container-column-text name="committenti" href="<%=viewURL %>"> |
||||||
|
<%= committenti %> |
||||||
|
</liferay-ui:search-container-column-text> |
||||||
|
|
||||||
|
<liferay-ui:search-container-column-text name="esito" href="<%=viewURL %>" cssClass="text-nowrap text-center middle-aligned"> |
||||||
|
<strong><%= LanguageUtil.get(pageContext, PraticaUtil.getStatoPraticaLabel(pratica.getStatoPratica(), intPraticaId)) %></strong> |
||||||
|
<span class="text-center display-block" style="margin-top:5px"> |
||||||
|
<% |
||||||
|
if (!avvisi.isEmpty()) { |
||||||
|
StringBuilder sb = new StringBuilder(); |
||||||
|
sb.append("<ul class='avvisi-tooltip'>"); |
||||||
|
for (Avviso avviso : avvisi) { |
||||||
|
sb.append("<li class='avviso-tooltip'>"); |
||||||
|
sb.append(LanguageUtil.get(pageContext, avviso.translateTipoDocumento())); |
||||||
|
sb.append("</li>"); |
||||||
|
} |
||||||
|
sb.append("</ul>"); |
||||||
|
%> |
||||||
|
<liferay-portlet:renderURL var="fascicoloAvvisiURL"> |
||||||
|
<liferay-portlet:param name="mvcPath" value="/html/fascicolo/view_fascicolo.jsp" /> |
||||||
|
<liferay-portlet:param name="intPraticaId" value="<%= String.valueOf(intPraticaId) %>" /> |
||||||
|
</liferay-portlet:renderURL> |
||||||
|
<a class="btn status-icon tooltip-info btn-action" |
||||||
|
title="<%= HtmlUtil.escapeAttribute(sb.toString()) %>" |
||||||
|
href="<%= fascicoloAvvisiURL.toString() + "#_" + PortletKeys.FASCICOLO |
||||||
|
+ "_tab=_" + PortletKeys.FASCICOLO + "_page_avvisi" %>"> |
||||||
|
<i class="fa fa-envelope relative"> |
||||||
|
<span class="fa-hover fa-top-right txt-bold"><%= avvisi.size() %></span> |
||||||
|
</i> |
||||||
|
</a> |
||||||
|
<% |
||||||
|
} |
||||||
|
%> |
||||||
|
<c:if test="<%= variantiCount > 0 %>"> |
||||||
|
<span class="btn status-icon tooltip-info btn-action" title="Varianti Presentate"> |
||||||
|
<span class="relative txt-bold status-icon-text"> |
||||||
|
V |
||||||
|
<span class="sup top-right txt-bold"><%= variantiCount %></span> |
||||||
|
</span> |
||||||
|
</span> |
||||||
|
</c:if> |
||||||
|
<c:if test="<%= integrazioniCount > 0 %>"> |
||||||
|
<span class="btn status-icon tooltip-info btn-action txt-bold" title="Integrazioni Presentate"> |
||||||
|
<span class="relative txt-bold status-icon-text"> |
||||||
|
I |
||||||
|
<span class="sup top-right txt-bold"><%= integrazioniCount %></span> |
||||||
|
</span> |
||||||
|
</span> |
||||||
|
</c:if> |
||||||
|
<c:if test="<%= pratica.isFineLavoriParziale() || pratica.isFineLavoriTotale() %>"> |
||||||
|
<c:if test="<%= !pratica.isFineLavoriTotale()%>"> |
||||||
|
<span class="btn status-icon tooltip-info btn-action" title="Fine Lavori Parziale presente"> |
||||||
|
<i class="fa fa-gavel relative"> |
||||||
|
<span class="fa-hover fa-top-right txt-orange txt-bold">P</span> |
||||||
|
</i> |
||||||
|
</span> |
||||||
|
</c:if> |
||||||
|
<c:if test="<%= pratica.isFineLavoriTotale()%>"> |
||||||
|
<span class="btn status-icon tooltip-info btn-action" title="Fine Lavori Totale presente"> |
||||||
|
<i class="fa fa-gavel relative"> |
||||||
|
<span class="fa-hover fa-top-right txt-green txt-bold">T</span> |
||||||
|
</i> |
||||||
|
</span> |
||||||
|
</c:if> |
||||||
|
</c:if> |
||||||
|
<c:if test="<%= pratica.isCollaudoParziale() || pratica.isCollaudoTotale() %>"> |
||||||
|
<c:if test="<%= !pratica.isCollaudoTotale() %>"> |
||||||
|
<span class="btn status-icon tooltip-info btn-action" title="Collaudo Parziale presente"> |
||||||
|
<i class="fa fa-briefcase relative"> |
||||||
|
<span class="fa-hover fa-top-right txt-orange txt-bold">P</span> |
||||||
|
</i> |
||||||
|
</span> |
||||||
|
</c:if> |
||||||
|
<c:if test="<%= pratica.isCollaudoTotale() %>"> |
||||||
|
<span class="btn status-icon tooltip-info btn-action" title="Collaudo Totale presente"> |
||||||
|
<i class="fa fa-briefcase relative"> |
||||||
|
<span class="fa-hover fa-top-right txt-green txt-bold">T</span> |
||||||
|
</i> |
||||||
|
</span> |
||||||
|
</c:if> |
||||||
|
</c:if> |
||||||
|
</span> |
||||||
|
</liferay-ui:search-container-column-text> |
||||||
|
|
||||||
|
<liferay-ui:search-container-column-text name="col-desc-interv"> |
||||||
|
Territorio: <strong><%= comune.getDenominazione() %> |
||||||
|
<%= (dettaglio == null || dettaglio.getLocalita().isEmpty()) ? |
||||||
|
"" : |
||||||
|
"(Loc. " + dettaglio.getLocalita() + ")" |
||||||
|
%> - <%= provincia.getProvincia() %></strong><br/> |
||||||
|
Localizzazione: <strong><%= dettaglio == null ? "" : dettaglio.getVia() %></strong><br/> |
||||||
|
<strong><%= LanguageUtil.get(pageContext, "tipo_procedura_" + pratica.getTipoProcedura()) %></strong><br/><br/> |
||||||
|
<%= dettaglio == null ? "" : dettaglio.getDescLongIntervento() %> |
||||||
|
</liferay-ui:search-container-column-text> |
||||||
|
</liferay-ui:search-container-row> |
||||||
|
<liferay-ui:search-iterator paginate="true" /> |
||||||
|
</liferay-ui:search-container> |
||||||
|
<c:if test="<%= showNotes %>"> |
||||||
|
<div class="col-xs-12"> |
||||||
|
<br/> |
||||||
|
<small> |
||||||
|
Note:<br/> |
||||||
|
<%= LanguageUtil.get(pageContext, "distanza-tooltip") %> |
||||||
|
</small> |
||||||
|
</div> |
||||||
|
</c:if> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<script> |
||||||
|
var <portlet:namespace/>comuneSelezionato = ''; |
||||||
|
|
||||||
|
Liferay.on('mapIt-ready',function(event) { |
||||||
|
AUI().one('#_<%= PortletKeys.MAPIT %>_container_btn .bloccamap').set('disabled', false).removeClass('disabled'); |
||||||
|
}); |
||||||
|
|
||||||
|
function localize(showAlert) { |
||||||
|
AUI().use('aui-io-request', function(A) { |
||||||
|
|
||||||
|
var indirizzo = AUI().one('#<portlet:namespace/>via').val().trim() |
||||||
|
var comune = AUI().one('#<portlet:namespace/>comune option:selected'); |
||||||
|
if (undefined == comune) { |
||||||
|
comune = ''; |
||||||
|
} else { |
||||||
|
comune = comune.text().trim(); |
||||||
|
} |
||||||
|
var provincia = AUI().one('#<portlet:namespace/>provincia option:selected'); |
||||||
|
if (undefined == provincia) { |
||||||
|
provincia = ''; |
||||||
|
} else { |
||||||
|
provincia = provincia.text().trim(); |
||||||
|
} |
||||||
|
|
||||||
|
var localization = [indirizzo, comune, provincia]; |
||||||
|
|
||||||
|
var url = 'https://nominatim.openstreetmap.org/search?format=json&addressdetails=0&q=' |
||||||
|
+ encodeURIComponent(localization.join(' ')); |
||||||
|
|
||||||
|
A.io.request(url, { |
||||||
|
dataType: 'json', |
||||||
|
on: { |
||||||
|
success: function() { |
||||||
|
var response = this.get('responseData'); |
||||||
|
if (response.length == 0) { |
||||||
|
if (showAlert) { |
||||||
|
alert('Nessun risultato per i dati immessi'); |
||||||
|
} |
||||||
|
} else if (response && response[0]) { |
||||||
|
Liferay.fire( |
||||||
|
'geolocation-ready', |
||||||
|
{ |
||||||
|
latitude: response[0].lat, |
||||||
|
longitude : response[0].lon, |
||||||
|
fullAddress : indirizzo !== '' |
||||||
|
} |
||||||
|
); |
||||||
|
} |
||||||
|
}, |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
YUI().use( |
||||||
|
'aui-tooltip', |
||||||
|
function(Y) { |
||||||
|
new Y.TooltipDelegate({ |
||||||
|
trigger: '.tooltip-info', |
||||||
|
position: 'top', |
||||||
|
cssClass: 'tooltip-help', |
||||||
|
html: true, |
||||||
|
opacity: 1, |
||||||
|
}); |
||||||
|
} |
||||||
|
); |
||||||
|
</script> |
||||||
|
<liferay-portlet:resourceURL id="province" var="getProvinceURL" /> |
||||||
|
<liferay-portlet:resourceURL id="comuni" var="getComuniURL" /> |
||||||
|
<aui:script use="aui-io-request,liferay-dynamic-select"> |
||||||
|
var getProvince = function(callback) { |
||||||
|
A.io.request( |
||||||
|
'<%= getProvinceURL %>', |
||||||
|
{ |
||||||
|
dataType: 'json', |
||||||
|
on: { |
||||||
|
success: function() { |
||||||
|
var data = this.get('responseData'); |
||||||
|
<portlet:namespace/>province = {}; |
||||||
|
for (var i = 0; i < data.length; i++) { |
||||||
|
<portlet:namespace/>province[data[i].nome.replaceAll(' ', '-').toLowerCase()] = data[i].id; |
||||||
|
} |
||||||
|
callback(data); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
); |
||||||
|
}; |
||||||
|
|
||||||
|
var getComuni = function(callback, provinciaId) { |
||||||
|
A.io.request( |
||||||
|
'<%= getComuniURL %>', |
||||||
|
{ |
||||||
|
dataType: 'json', |
||||||
|
data: { |
||||||
|
<portlet:namespace />provinciaId: provinciaId |
||||||
|
}, |
||||||
|
on: { |
||||||
|
success: function() { |
||||||
|
var data = this.get('responseData'); |
||||||
|
callback(data); |
||||||
|
if ('' !== <portlet:namespace/>comuneSelezionato) { |
||||||
|
for (var i = 0; i < data.length; i++) { |
||||||
|
if (data[i].nome.replaceAll(' ', '-').toLowerCase() === <portlet:namespace/>comuneSelezionato) { |
||||||
|
A.one('#<portlet:namespace/>comune').set('value', data[i].id); |
||||||
|
} |
||||||
|
} |
||||||
|
<portlet:namespace/>comuneSelezionato = ''; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
); |
||||||
|
}; |
||||||
|
new Liferay.DynamicSelect([ |
||||||
|
{ |
||||||
|
select: '<portlet:namespace />provincia', |
||||||
|
selectData: getProvince, |
||||||
|
selectDesc: 'nome', |
||||||
|
selectId: 'id', |
||||||
|
selectSort: true, |
||||||
|
selectVal: '<%= codiceProvincia %>', |
||||||
|
}, |
||||||
|
{ |
||||||
|
select: '<portlet:namespace />comune', |
||||||
|
selectData: getComuni, |
||||||
|
selectDesc: 'nome', |
||||||
|
selectId: 'id', |
||||||
|
selectSort: true, |
||||||
|
selectDisableOnEmpty: true, |
||||||
|
selectVal: '<%= idComune %>', |
||||||
|
}, |
||||||
|
]); |
||||||
|
</aui:script> |
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
@ -1,572 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8" ?> |
|
||||||
|
|
||||||
<taglib xmlns="http://java.sun.com/xml/ns/javaee" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
||||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd" |
|
||||||
version="2.1"> |
|
||||||
|
|
||||||
<description>JSTL 1.2 core library</description> |
|
||||||
<display-name>JSTL core</display-name> |
|
||||||
<tlib-version>1.2</tlib-version> |
|
||||||
<short-name>c</short-name> |
|
||||||
<uri>http://java.sun.com/jsp/jstl/core</uri> |
|
||||||
|
|
||||||
<validator> |
|
||||||
<description> |
|
||||||
Provides core validation features for JSTL tags. |
|
||||||
</description> |
|
||||||
<validator-class> |
|
||||||
org.apache.taglibs.standard.tlv.JstlCoreTLV |
|
||||||
</validator-class> |
|
||||||
</validator> |
|
||||||
|
|
||||||
<tag> |
|
||||||
<description> |
|
||||||
Catches any Throwable that occurs in its body and optionally |
|
||||||
exposes it. |
|
||||||
</description> |
|
||||||
<name>catch</name> |
|
||||||
<tag-class>org.apache.taglibs.standard.tag.common.core.CatchTag</tag-class> |
|
||||||
<body-content>JSP</body-content> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the exported scoped variable for the |
|
||||||
exception thrown from a nested action. The type of the |
|
||||||
scoped variable is the type of the exception thrown. |
|
||||||
</description> |
|
||||||
<name>var</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
</tag> |
|
||||||
|
|
||||||
<tag> |
|
||||||
<description> |
|
||||||
Simple conditional tag that establishes a context for |
|
||||||
mutually exclusive conditional operations, marked by |
|
||||||
<when> and <otherwise> |
|
||||||
</description> |
|
||||||
<name>choose</name> |
|
||||||
<tag-class>com.liferay.taglib.core.ChooseTag</tag-class> |
|
||||||
<body-content>JSP</body-content> |
|
||||||
</tag> |
|
||||||
|
|
||||||
<tag> |
|
||||||
<description> |
|
||||||
Simple conditional tag, which evalutes its body if the |
|
||||||
supplied condition is true and optionally exposes a Boolean |
|
||||||
scripting variable representing the evaluation of this condition |
|
||||||
</description> |
|
||||||
<name>if</name> |
|
||||||
<tag-class>com.liferay.taglib.core.IfTag</tag-class> |
|
||||||
<body-content>JSP</body-content> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
The test condition that determines whether or |
|
||||||
not the body content should be processed. |
|
||||||
</description> |
|
||||||
<name>test</name> |
|
||||||
<required>true</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
<type>boolean</type> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the exported scoped variable for the |
|
||||||
resulting value of the test condition. The type |
|
||||||
of the scoped variable is Boolean. |
|
||||||
</description> |
|
||||||
<name>var</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Scope for var. |
|
||||||
</description> |
|
||||||
<name>scope</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
</tag> |
|
||||||
|
|
||||||
<tag> |
|
||||||
<description> |
|
||||||
Retrieves an absolute or relative URL and exposes its contents |
|
||||||
to either the page, a String in 'var', or a Reader in 'varReader'. |
|
||||||
</description> |
|
||||||
<name>import</name> |
|
||||||
<tag-class>org.apache.taglibs.standard.tag.rt.core.ImportTag</tag-class> |
|
||||||
<tei-class>org.apache.taglibs.standard.tei.ImportTEI</tei-class> |
|
||||||
<body-content>JSP</body-content> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
The URL of the resource to import. |
|
||||||
</description> |
|
||||||
<name>url</name> |
|
||||||
<required>true</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the exported scoped variable for the |
|
||||||
resource's content. The type of the scoped |
|
||||||
variable is String. |
|
||||||
</description> |
|
||||||
<name>var</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Scope for var. |
|
||||||
</description> |
|
||||||
<name>scope</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the exported scoped variable for the |
|
||||||
resource's content. The type of the scoped |
|
||||||
variable is Reader. |
|
||||||
</description> |
|
||||||
<name>varReader</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the context when accessing a relative |
|
||||||
URL resource that belongs to a foreign |
|
||||||
context. |
|
||||||
</description> |
|
||||||
<name>context</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Character encoding of the content at the input |
|
||||||
resource. |
|
||||||
</description> |
|
||||||
<name>charEncoding</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
</tag> |
|
||||||
|
|
||||||
<tag> |
|
||||||
<description> |
|
||||||
The basic iteration tag, accepting many different |
|
||||||
collection types and supporting subsetting and other |
|
||||||
functionality |
|
||||||
</description> |
|
||||||
<name>forEach</name> |
|
||||||
<tag-class>org.apache.taglibs.standard.tag.rt.core.ForEachTag</tag-class> |
|
||||||
<tei-class>org.apache.taglibs.standard.tei.ForEachTEI</tei-class> |
|
||||||
<body-content>JSP</body-content> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Collection of items to iterate over. |
|
||||||
</description> |
|
||||||
<name>items</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
<type>java.lang.Object</type> |
|
||||||
<deferred-value> |
|
||||||
<type>java.lang.Object</type> |
|
||||||
</deferred-value> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
If items specified: |
|
||||||
Iteration begins at the item located at the |
|
||||||
specified index. First item of the collection has |
|
||||||
index 0. |
|
||||||
If items not specified: |
|
||||||
Iteration begins with index set at the value |
|
||||||
specified. |
|
||||||
</description> |
|
||||||
<name>begin</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
<type>int</type> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
If items specified: |
|
||||||
Iteration ends at the item located at the |
|
||||||
specified index (inclusive). |
|
||||||
If items not specified: |
|
||||||
Iteration ends when index reaches the value |
|
||||||
specified. |
|
||||||
</description> |
|
||||||
<name>end</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
<type>int</type> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Iteration will only process every step items of |
|
||||||
the collection, starting with the first one. |
|
||||||
</description> |
|
||||||
<name>step</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
<type>int</type> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the exported scoped variable for the |
|
||||||
current item of the iteration. This scoped |
|
||||||
variable has nested visibility. Its type depends |
|
||||||
on the object of the underlying collection. |
|
||||||
</description> |
|
||||||
<name>var</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the exported scoped variable for the |
|
||||||
status of the iteration. Object exported is of type |
|
||||||
javax.servlet.jsp.jstl.core.LoopTagStatus. This scoped variable has nested |
|
||||||
visibility. |
|
||||||
</description> |
|
||||||
<name>varStatus</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
</tag> |
|
||||||
|
|
||||||
<tag> |
|
||||||
<description> |
|
||||||
Iterates over tokens, separated by the supplied delimeters |
|
||||||
</description> |
|
||||||
<name>forTokens</name> |
|
||||||
<tag-class>org.apache.taglibs.standard.tag.rt.core.ForTokensTag</tag-class> |
|
||||||
<body-content>JSP</body-content> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
String of tokens to iterate over. |
|
||||||
</description> |
|
||||||
<name>items</name> |
|
||||||
<required>true</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
<type>java.lang.String</type> |
|
||||||
<deferred-value> |
|
||||||
<type>java.lang.String</type> |
|
||||||
</deferred-value> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
The set of delimiters (the characters that |
|
||||||
separate the tokens in the string). |
|
||||||
</description> |
|
||||||
<name>delims</name> |
|
||||||
<required>true</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
<type>java.lang.String</type> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Iteration begins at the token located at the |
|
||||||
specified index. First token has index 0. |
|
||||||
</description> |
|
||||||
<name>begin</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
<type>int</type> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Iteration ends at the token located at the |
|
||||||
specified index (inclusive). |
|
||||||
</description> |
|
||||||
<name>end</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
<type>int</type> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Iteration will only process every step tokens |
|
||||||
of the string, starting with the first one. |
|
||||||
</description> |
|
||||||
<name>step</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
<type>int</type> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the exported scoped variable for the |
|
||||||
current item of the iteration. This scoped |
|
||||||
variable has nested visibility. |
|
||||||
</description> |
|
||||||
<name>var</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the exported scoped variable for the |
|
||||||
status of the iteration. Object exported is of |
|
||||||
type |
|
||||||
javax.servlet.jsp.jstl.core.LoopTag |
|
||||||
Status. This scoped variable has nested |
|
||||||
visibility. |
|
||||||
</description> |
|
||||||
<name>varStatus</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
</tag> |
|
||||||
|
|
||||||
<tag> |
|
||||||
<description> |
|
||||||
Like <%= ... >, but for expressions. |
|
||||||
</description> |
|
||||||
<name>out</name> |
|
||||||
<tag-class>org.apache.taglibs.standard.tag.rt.core.OutTag</tag-class> |
|
||||||
<body-content>JSP</body-content> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Expression to be evaluated. |
|
||||||
</description> |
|
||||||
<name>value</name> |
|
||||||
<required>true</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Default value if the resulting value is null. |
|
||||||
</description> |
|
||||||
<name>default</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Determines whether characters <,>,&,'," in the |
|
||||||
resulting string should be converted to their |
|
||||||
corresponding character entity codes. Default value is |
|
||||||
true. |
|
||||||
</description> |
|
||||||
<name>escapeXml</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
</tag> |
|
||||||
|
|
||||||
|
|
||||||
<tag> |
|
||||||
<description> |
|
||||||
Subtag of <choose> that follows <when> tags |
|
||||||
and runs only if all of the prior conditions evaluated to |
|
||||||
'false' |
|
||||||
</description> |
|
||||||
<name>otherwise</name> |
|
||||||
<tag-class>com.liferay.taglib.core.OtherwiseTag</tag-class> |
|
||||||
<body-content>JSP</body-content> |
|
||||||
</tag> |
|
||||||
|
|
||||||
<tag> |
|
||||||
<description> |
|
||||||
Adds a parameter to a containing 'import' tag's URL. |
|
||||||
</description> |
|
||||||
<name>param</name> |
|
||||||
<tag-class>org.apache.taglibs.standard.tag.rt.core.ParamTag</tag-class> |
|
||||||
<body-content>JSP</body-content> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the query string parameter. |
|
||||||
</description> |
|
||||||
<name>name</name> |
|
||||||
<required>true</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Value of the parameter. |
|
||||||
</description> |
|
||||||
<name>value</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
</tag> |
|
||||||
|
|
||||||
<tag> |
|
||||||
<description> |
|
||||||
Redirects to a new URL. |
|
||||||
</description> |
|
||||||
<name>redirect</name> |
|
||||||
<tag-class>org.apache.taglibs.standard.tag.rt.core.RedirectTag</tag-class> |
|
||||||
<body-content>JSP</body-content> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
The URL of the resource to redirect to. |
|
||||||
</description> |
|
||||||
<name>url</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the context when redirecting to a relative URL |
|
||||||
resource that belongs to a foreign context. |
|
||||||
</description> |
|
||||||
<name>context</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
</tag> |
|
||||||
|
|
||||||
<tag> |
|
||||||
<description> |
|
||||||
Removes a scoped variable (from a particular scope, if specified). |
|
||||||
</description> |
|
||||||
<name>remove</name> |
|
||||||
<tag-class>org.apache.taglibs.standard.tag.common.core.RemoveTag</tag-class> |
|
||||||
<body-content>empty</body-content> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the scoped variable to be removed. |
|
||||||
</description> |
|
||||||
<name>var</name> |
|
||||||
<required>true</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Scope for var. |
|
||||||
</description> |
|
||||||
<name>scope</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
</tag> |
|
||||||
|
|
||||||
<tag> |
|
||||||
<description> |
|
||||||
Sets the result of an expression evaluation in a 'scope' |
|
||||||
</description> |
|
||||||
<name>set</name> |
|
||||||
<tag-class>org.apache.taglibs.standard.tag.rt.core.SetTag</tag-class> |
|
||||||
<body-content>JSP</body-content> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the exported scoped variable to hold the value |
|
||||||
specified in the action. The type of the scoped variable is |
|
||||||
whatever type the value expression evaluates to. |
|
||||||
</description> |
|
||||||
<name>var</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Expression to be evaluated. |
|
||||||
</description> |
|
||||||
<name>value</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
<deferred-value> |
|
||||||
<type>java.lang.Object</type> |
|
||||||
</deferred-value> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Target object whose property will be set. Must evaluate to |
|
||||||
a JavaBeans object with setter property property, or to a |
|
||||||
java.util.Map object. |
|
||||||
</description> |
|
||||||
<name>target</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the property to be set in the target object. |
|
||||||
</description> |
|
||||||
<name>property</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Scope for var. |
|
||||||
</description> |
|
||||||
<name>scope</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
</tag> |
|
||||||
|
|
||||||
<tag> |
|
||||||
<description> |
|
||||||
Creates a URL with optional query parameters. |
|
||||||
</description> |
|
||||||
<name>url</name> |
|
||||||
<tag-class>org.apache.taglibs.standard.tag.rt.core.UrlTag</tag-class> |
|
||||||
<body-content>JSP</body-content> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the exported scoped variable for the |
|
||||||
processed url. The type of the scoped variable is |
|
||||||
String. |
|
||||||
</description> |
|
||||||
<name>var</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Scope for var. |
|
||||||
</description> |
|
||||||
<name>scope</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>false</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
URL to be processed. |
|
||||||
</description> |
|
||||||
<name>value</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
Name of the context when specifying a relative URL |
|
||||||
resource that belongs to a foreign context. |
|
||||||
</description> |
|
||||||
<name>context</name> |
|
||||||
<required>false</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
</attribute> |
|
||||||
</tag> |
|
||||||
|
|
||||||
<tag> |
|
||||||
<description> |
|
||||||
Subtag of <choose> that includes its body if its |
|
||||||
condition evalutes to 'true' |
|
||||||
</description> |
|
||||||
<name>when</name> |
|
||||||
<tag-class>com.liferay.taglib.core.WhenTag</tag-class> |
|
||||||
<body-content>JSP</body-content> |
|
||||||
<attribute> |
|
||||||
<description> |
|
||||||
The test condition that determines whether or not the |
|
||||||
body content should be processed. |
|
||||||
</description> |
|
||||||
<name>test</name> |
|
||||||
<required>true</required> |
|
||||||
<rtexprvalue>true</rtexprvalue> |
|
||||||
<type>boolean</type> |
|
||||||
</attribute> |
|
||||||
</tag> |
|
||||||
|
|
||||||
</taglib> |
|
@ -1 +1 @@ |
|||||||
b2c2a2163a9e57f49e684a33bc7d0817 |
5ae48f34ca95a715172797941f9c2717 |
||||||
|
File binario non mostrato.
@ -0,0 +1,18 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<classpath> |
||||||
|
<classpathentry kind="src" path="src"/> |
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_80"/> |
||||||
|
<classpathentry kind="lib" path="/home/portos/bin/liferay-portal-6.2-ce-ga6/tomcat-7.0.62/lib/ext/portlet.jar"/> |
||||||
|
<classpathentry kind="lib" path="/home/portos/bin/liferay-portal-6.2-ce-ga6/tomcat-7.0.62/lib/ext/portal-service.jar" sourcepath="/home/portos/sources/liferay-portal-src-6.2-ce-ga6"> |
||||||
|
<attributes> |
||||||
|
<attribute name="javadoc_location" value="file:/home/portos/sources/liferay-javadocs-all/"/> |
||||||
|
</attributes> |
||||||
|
</classpathentry> |
||||||
|
<classpathentry kind="lib" path="/home/portos/bin/liferay-portal-6.2-ce-ga6/tomcat-7.0.62/webapps/ROOT/WEB-INF/lib/util-taglib.jar" sourcepath="/home/portos/sources/liferay-portal-src-6.2-ce-ga6"> |
||||||
|
<attributes> |
||||||
|
<attribute name="javadoc_location" value="file:/home/portos/sources/liferay-javadocs-all/"/> |
||||||
|
</attributes> |
||||||
|
</classpathentry> |
||||||
|
<classpathentry kind="lib" path="/home/portos/bin/liferay-portal-6.2-ce-ga6/tomcat-7.0.62/lib/servlet-api.jar"/> |
||||||
|
<classpathentry kind="output" path="classes"/> |
||||||
|
</classpath> |
@ -0,0 +1 @@ |
|||||||
|
/classes/ |
@ -0,0 +1,17 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<projectDescription> |
||||||
|
<name>tref-mapit-shared</name> |
||||||
|
<comment></comment> |
||||||
|
<projects> |
||||||
|
</projects> |
||||||
|
<buildSpec> |
||||||
|
<buildCommand> |
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name> |
||||||
|
<arguments> |
||||||
|
</arguments> |
||||||
|
</buildCommand> |
||||||
|
</buildSpec> |
||||||
|
<natures> |
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature> |
||||||
|
</natures> |
||||||
|
</projectDescription> |
@ -0,0 +1,7 @@ |
|||||||
|
<?xml version="1.0"?> |
||||||
|
<!DOCTYPE project> |
||||||
|
|
||||||
|
<project name="tref-mapit-shared" basedir="." default="deploy"> |
||||||
|
<property name="plugin.version" value="1" /> |
||||||
|
<import file="../build-common-shared.xml" /> |
||||||
|
</project> |
@ -0,0 +1,47 @@ |
|||||||
|
package it.tref.liferay.mapit.constants; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
public interface Constants extends com.liferay.portal.kernel.util.Constants { |
||||||
|
public static final int MAX_SEARCH_RESULT = 4000; |
||||||
|
public static final String MIN_DECIMAL_INDEX = "000000000"; |
||||||
|
public static final String MIN_INTERO_INDEX = "000"; |
||||||
|
public static final String MAX_LAT_INDEX = "180"; |
||||||
|
public static final String MIN_LAT_INDEX = "000"; |
||||||
|
public static final String ZERO_LAT_INDEX = "090"; |
||||||
|
public static final String MAX_LON_INDEX = "360"; |
||||||
|
public static final String MIN_LON_INDEX = "000"; |
||||||
|
public static final String ZERO_LON_INDEX = "180"; |
||||||
|
public static final BigDecimal MAX_LON = (new BigDecimal(180)).setScale(0); |
||||||
|
public static final BigDecimal MIN_LON = (new BigDecimal(-180)).setScale(0); |
||||||
|
public static final BigDecimal MAX_LAT = (new BigDecimal(90)).setScale(0); |
||||||
|
public static final BigDecimal MIN_LAT = (new BigDecimal(-90)).setScale(0); |
||||||
|
public static final String COORDINATE_SEPARATOR = "."; |
||||||
|
public static final String NULL_VALUE = "-1"; |
||||||
|
public static final String EXPANDO_TABLE_NAME = "CUSTOM_FIELDS"; |
||||||
|
public static final String EXPANDO_COLUMN_NAME_LAT = "MAPIT_LAT"; |
||||||
|
public static final String EXPANDO_COLUMN_NAME_LAT_HIDDEN = "MAPIT_LAT_HIDDEN"; |
||||||
|
public static final String EXPANDO_COLUMN_NAME_LON = "MAPIT_LON"; |
||||||
|
public static final String EXPANDO_COLUMN_NAME_LON_HIDDEN = "MAPIT_LON_HIDDEN"; |
||||||
|
|
||||||
|
public static class MapTypeValue { |
||||||
|
public static final String OPEN_STREET_MAP = "1"; |
||||||
|
public static final String GOOGLE_MAP = "2"; |
||||||
|
public static final String BING_MAP = "3"; |
||||||
|
public static final String BASE_MAP = "4"; |
||||||
|
public static final String BASE_MAP_LABEL = "5"; |
||||||
|
public static final String IMAGE = "6"; |
||||||
|
} |
||||||
|
|
||||||
|
public static class ZoomTypeValue { |
||||||
|
public static final String SIMPLE = "0"; |
||||||
|
public static final String COMPACT = "1"; |
||||||
|
public static final String FULL = "2"; |
||||||
|
} |
||||||
|
|
||||||
|
public static class ZoomType { |
||||||
|
public static final String SIMPLE = "simple"; |
||||||
|
public static final String COMPACT = "compact"; |
||||||
|
public static final String FULL = "full"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,6 @@ |
|||||||
|
package it.tref.liferay.mapit.constants; |
||||||
|
|
||||||
|
public interface DestinationNames extends com.liferay.portal.kernel.messaging.DestinationNames { |
||||||
|
public static final String ASSET_RESOLVER_PREFIX = "liferay/mapit/assetresolver/"; |
||||||
|
public static final String DESTINATION_RESOLVER = "liferay/mapit/destinationresolver"; |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
package it.tref.liferay.mapit.constants; |
||||||
|
|
||||||
|
public class PortletConfiguration { |
||||||
|
public static final String CENTER_LAT = "centerlat"; |
||||||
|
public static final String CENTER_LON = "centerlon"; |
||||||
|
public static final String GEO_BROWSER = "geobrowser"; |
||||||
|
public static final String IGNORE_VIEW = "ignoreView"; |
||||||
|
public static final String SAVE_LAST_POSITION = "savelastposition"; |
||||||
|
public static final String SHOW_MAP_CODE = "showmapcode"; |
||||||
|
public static final String HEIGHT = "height"; |
||||||
|
public static final String ZOOM_FACTOR = "zoomfactor"; |
||||||
|
public static final String MAP_TYPE = "maptype"; |
||||||
|
public static final String API_KEY = "apikey"; |
||||||
|
public static final String API_VERSION = "apiversion"; |
||||||
|
public static final String MAP_STYLES = "mapStyles"; |
||||||
|
public static final String CLASS_NAME_IDS = "classNameIds"; |
||||||
|
public static final String PLUGIN_IDS = "pluginIds"; |
||||||
|
public static final String IGNORE_BBOX = "ignoreBbox"; |
||||||
|
public static final String LAYER_SWITCH = "controllayerswitch"; |
||||||
|
public static final String ZOOM_TYPE = "controlzoomtype"; |
||||||
|
public static final String FULL_SCREEN = "controlfullscreen"; |
||||||
|
public static final String NAV_TOOLBAR = "controlnavtoolbar"; |
||||||
|
public static final String MOUSE_POSITION = "controlmouseposition"; |
||||||
|
public static final String SCALE = "controlscale"; |
||||||
|
public static final String HOME = "controlhome"; |
||||||
|
public static final String OVERVIEW_MAP = "controloverviewmap"; |
||||||
|
public static final String NO_POPUP = "popunopopup"; |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
package it.tref.liferay.mapit.constants; |
||||||
|
|
||||||
|
public interface WebKeys extends com.liferay.portal.kernel.util.WebKeys { |
||||||
|
public static final String PLUGIN_PORTLET_PREFERENCES = "PLUGIN_PORTLET_PREFERENCES"; |
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
package it.tref.liferay.mapit.messaging; |
||||||
|
|
||||||
|
import com.liferay.portal.kernel.messaging.BaseMessageListener; |
||||||
|
import com.liferay.portal.kernel.messaging.Message; |
||||||
|
import com.liferay.portal.kernel.messaging.MessageBusUtil; |
||||||
|
import com.liferay.portal.kernel.util.StringUtil; |
||||||
|
import com.liferay.portal.model.BaseModel; |
||||||
|
import com.liferay.portlet.documentlibrary.model.DLFileEntry; |
||||||
|
import com.liferay.portlet.journal.model.JournalArticle; |
||||||
|
import com.liferay.portlet.wiki.model.WikiPage; |
||||||
|
import it.tref.liferay.mapit.resolver.BaseModelResolver; |
||||||
|
import it.tref.liferay.mapit.resolver.asset.DLFileEntryResolver; |
||||||
|
import it.tref.liferay.mapit.resolver.asset.JournalArticleResolver; |
||||||
|
import it.tref.liferay.mapit.resolver.asset.WikiPageResolver; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.concurrent.ConcurrentHashMap; |
||||||
|
|
||||||
|
public class AssetResolverMessageListener extends BaseMessageListener { |
||||||
|
public AssetResolverMessageListener() { |
||||||
|
_baseModelResolverMap.put(DLFileEntry.class.getName(), new DLFileEntryResolver()); |
||||||
|
_baseModelResolverMap.put(WikiPage.class.getName(), new WikiPageResolver()); |
||||||
|
_baseModelResolverMap.put(JournalArticle.class.getName(), new JournalArticleResolver()); |
||||||
|
} |
||||||
|
|
||||||
|
protected void doReceive(Message message) throws Exception { |
||||||
|
long companyId = message.getLong("companyId"); |
||||||
|
long classPK = message.getLong("entryClassPK"); |
||||||
|
String className = StringUtil.extractLast(message.getDestinationName(), "/"); |
||||||
|
BaseModelResolver<?> baseModelResolver = _baseModelResolverMap.get(className); |
||||||
|
BaseModel<?> baseModel = null; |
||||||
|
if (baseModelResolver != null) |
||||||
|
baseModel = baseModelResolver.getBaseModel(companyId, classPK); |
||||||
|
Message responseMessage = MessageBusUtil.createResponseMessage(message, baseModel); |
||||||
|
MessageBusUtil.sendMessage(message.getResponseDestinationName(), responseMessage); |
||||||
|
} |
||||||
|
|
||||||
|
private static Map<String, BaseModelResolver<?>> _baseModelResolverMap = new ConcurrentHashMap<String, BaseModelResolver<?>>(); |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
package it.tref.liferay.mapit.plugin; |
||||||
|
|
||||||
|
import it.tref.liferay.mapit.plugin.action.MapItPluginAction; |
||||||
|
import it.tref.liferay.mapit.plugin.event.MapItPluginEvent; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
public interface MapItPlugin { |
||||||
|
String getPortalConfigurationPortletId(); |
||||||
|
|
||||||
|
String getSiteConfigurationPortletId(); |
||||||
|
|
||||||
|
String getPortletConfigurationJsp(); |
||||||
|
|
||||||
|
String getTopJspPage(); |
||||||
|
|
||||||
|
String getBottomJspPage(); |
||||||
|
|
||||||
|
Set<Class<? extends MapItPluginAction>> getMapItPluginActions(); |
||||||
|
|
||||||
|
Set<Class<? extends MapItPluginEvent>> getMapItPluginEvents(); |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
package it.tref.liferay.mapit.plugin.action; |
||||||
|
|
||||||
|
import javax.portlet.PortletException; |
||||||
|
import javax.portlet.PortletPreferences; |
||||||
|
import javax.portlet.ResourceRequest; |
||||||
|
import javax.portlet.ResourceResponse; |
||||||
|
|
||||||
|
public interface MapItPluginAction { |
||||||
|
String getResourceId(); |
||||||
|
|
||||||
|
void execute(ResourceRequest paramResourceRequest, ResourceResponse paramResourceResponse, |
||||||
|
PortletPreferences paramPortletPreferences) throws PortletException; |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
package it.tref.liferay.mapit.plugin.event; |
||||||
|
|
||||||
|
public interface MapItPluginEvent { |
||||||
|
MapItPluginEventType getEventType(); |
||||||
|
|
||||||
|
String getDestinationName(); |
||||||
|
|
||||||
|
public enum MapItPluginEventType { |
||||||
|
ON_FEATURE_CLICK("onFeatureClick"), ON_ICON_DISPLAY("onIconDisplay"); |
||||||
|
|
||||||
|
private String _value; |
||||||
|
|
||||||
|
public static MapItPluginEventType parse(String value) { |
||||||
|
if (ON_FEATURE_CLICK.getValue().equals(value)) |
||||||
|
return ON_FEATURE_CLICK; |
||||||
|
if (ON_ICON_DISPLAY.getValue().equals(value)) |
||||||
|
return ON_ICON_DISPLAY; |
||||||
|
throw new IllegalArgumentException("Invalid value " + value); |
||||||
|
} |
||||||
|
|
||||||
|
public String getValue() { |
||||||
|
return _value; |
||||||
|
} |
||||||
|
|
||||||
|
MapItPluginEventType(String value) { |
||||||
|
_value = value; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return _value; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,7 @@ |
|||||||
|
package it.tref.liferay.mapit.resolver; |
||||||
|
|
||||||
|
import com.liferay.portal.model.BaseModel; |
||||||
|
|
||||||
|
public interface BaseModelResolver<T> { |
||||||
|
BaseModel<T> getBaseModel(long paramLong1, long paramLong2); |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
package it.tref.liferay.mapit.resolver.asset; |
||||||
|
|
||||||
|
import it.tref.liferay.mapit.resolver.BaseModelResolver; |
||||||
|
|
||||||
|
import com.liferay.portal.kernel.exception.PortalException; |
||||||
|
import com.liferay.portal.kernel.exception.SystemException; |
||||||
|
import com.liferay.portal.model.BaseModel; |
||||||
|
import com.liferay.portlet.documentlibrary.model.DLFileEntry; |
||||||
|
import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil; |
||||||
|
|
||||||
|
public class DLFileEntryResolver implements BaseModelResolver<DLFileEntry> { |
||||||
|
@Override |
||||||
|
public BaseModel<DLFileEntry> getBaseModel(long companyId, long classPK) { |
||||||
|
try { |
||||||
|
return DLFileEntryLocalServiceUtil.getDLFileEntry(classPK); |
||||||
|
} catch (PortalException portalException) { |
||||||
|
return null; |
||||||
|
} catch (SystemException systemException) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
package it.tref.liferay.mapit.resolver.asset; |
||||||
|
|
||||||
|
import it.tref.liferay.mapit.resolver.BaseModelResolver; |
||||||
|
|
||||||
|
import com.liferay.portal.kernel.exception.PortalException; |
||||||
|
import com.liferay.portal.kernel.exception.SystemException; |
||||||
|
import com.liferay.portal.model.BaseModel; |
||||||
|
import com.liferay.portlet.journal.model.JournalArticle; |
||||||
|
import com.liferay.portlet.journal.model.JournalArticleResource; |
||||||
|
import com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil; |
||||||
|
import com.liferay.portlet.journal.service.JournalArticleResourceLocalServiceUtil; |
||||||
|
|
||||||
|
public class JournalArticleResolver implements BaseModelResolver<JournalArticle> { |
||||||
|
@Override |
||||||
|
public BaseModel<JournalArticle> getBaseModel(long companyId, long classPK) { |
||||||
|
try { |
||||||
|
JournalArticleResource journalArticleResource = JournalArticleResourceLocalServiceUtil |
||||||
|
.getJournalArticleResource(classPK); |
||||||
|
return JournalArticleLocalServiceUtil.getArticle( |
||||||
|
journalArticleResource.getGroupId(), journalArticleResource.getArticleId()); |
||||||
|
} catch (PortalException portalException) { |
||||||
|
return null; |
||||||
|
} catch (SystemException systemException) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
package it.tref.liferay.mapit.resolver.asset; |
||||||
|
|
||||||
|
import it.tref.liferay.mapit.resolver.BaseModelResolver; |
||||||
|
|
||||||
|
import com.liferay.portal.kernel.exception.PortalException; |
||||||
|
import com.liferay.portal.kernel.exception.SystemException; |
||||||
|
import com.liferay.portal.model.BaseModel; |
||||||
|
import com.liferay.portlet.wiki.model.WikiPage; |
||||||
|
import com.liferay.portlet.wiki.model.WikiPageResource; |
||||||
|
import com.liferay.portlet.wiki.service.WikiPageLocalServiceUtil; |
||||||
|
import com.liferay.portlet.wiki.service.WikiPageResourceLocalServiceUtil; |
||||||
|
|
||||||
|
public class WikiPageResolver implements BaseModelResolver<WikiPage> { |
||||||
|
@Override |
||||||
|
public BaseModel<WikiPage> getBaseModel(long companyId, long classPK) { |
||||||
|
try { |
||||||
|
WikiPageResource wikiPageResource = WikiPageResourceLocalServiceUtil.getWikiPageResource(classPK); |
||||||
|
return WikiPageLocalServiceUtil.getPage(wikiPageResource |
||||||
|
.getResourcePrimKey()); |
||||||
|
} catch (PortalException portalException) { |
||||||
|
return null; |
||||||
|
} catch (SystemException systemException) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
package it.tref.liferay.mapit.template; |
||||||
|
|
||||||
|
import it.tref.liferay.mapit.util.MapitHelperUtil; |
||||||
|
|
||||||
|
import java.util.LinkedHashMap; |
||||||
|
import java.util.Locale; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import javax.portlet.PortletRequest; |
||||||
|
import javax.portlet.RenderRequest; |
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
|
||||||
|
import com.liferay.portal.kernel.template.TemplateVariableGroup; |
||||||
|
import com.liferay.portal.theme.ThemeDisplay; |
||||||
|
import com.liferay.taglib.util.VelocityTaglib; |
||||||
|
|
||||||
|
public class TemplateVariableUtil { |
||||||
|
public static Map<String, TemplateVariableGroup> getTemplateVariableGroups(String language) { |
||||||
|
Map<String, TemplateVariableGroup> templateVariableGroups = new LinkedHashMap<String, TemplateVariableGroup>(); |
||||||
|
TemplateVariableGroup fieldsTemplateVariableGroup = new TemplateVariableGroup("fields"); |
||||||
|
fieldsTemplateVariableGroup.addVariable("entry", null, "entry"); |
||||||
|
templateVariableGroups.put("fields", fieldsTemplateVariableGroup); |
||||||
|
TemplateVariableGroup generalVariablesTemplateVariableGroup = new TemplateVariableGroup( |
||||||
|
"general-variables"); |
||||||
|
generalVariablesTemplateVariableGroup.addVariable("current-url", String.class, "currentURL"); |
||||||
|
generalVariablesTemplateVariableGroup.addVariable("locale", Locale.class, "locale"); |
||||||
|
generalVariablesTemplateVariableGroup |
||||||
|
.addVariable("theme-display", ThemeDisplay.class, "themeDisplay"); |
||||||
|
templateVariableGroups.put("general-variables", generalVariablesTemplateVariableGroup); |
||||||
|
TemplateVariableGroup utilTemplateVariableGroup = new TemplateVariableGroup("util"); |
||||||
|
utilTemplateVariableGroup.addVariable("http-request", HttpServletRequest.class, "request"); |
||||||
|
if (language.equals("vm")) |
||||||
|
utilTemplateVariableGroup.addVariable("liferay-taglib", VelocityTaglib.class, "taglibLiferay"); |
||||||
|
utilTemplateVariableGroup.addVariable("render-request", RenderRequest.class, "renderRequest"); |
||||||
|
utilTemplateVariableGroup.addVariable("render-response", PortletRequest.class, "renderResponse"); |
||||||
|
templateVariableGroups.put("util", utilTemplateVariableGroup); |
||||||
|
TemplateVariableGroup utilMapItTemplateVariableGroup = new TemplateVariableGroup("mapit-util"); |
||||||
|
utilMapItTemplateVariableGroup.addVariable("mapit-helper-util", MapitHelperUtil.class, |
||||||
|
"mapItHelperUtil"); |
||||||
|
templateVariableGroups.put("mapit-util", utilMapItTemplateVariableGroup); |
||||||
|
return templateVariableGroups; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,162 @@ |
|||||||
|
package it.tref.liferay.mapit.util; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import javax.portlet.PortletMode; |
||||||
|
import javax.portlet.PortletRequest; |
||||||
|
|
||||||
|
import com.liferay.portal.kernel.plugin.PluginPackage; |
||||||
|
import com.liferay.portal.kernel.portlet.LiferayPortletRequest; |
||||||
|
import com.liferay.portal.kernel.portlet.LiferayPortletURL; |
||||||
|
import com.liferay.portal.kernel.portlet.LiferayWindowState; |
||||||
|
import com.liferay.portal.kernel.search.BooleanClause; |
||||||
|
import com.liferay.portal.kernel.search.BooleanClauseFactoryUtil; |
||||||
|
import com.liferay.portal.kernel.search.BooleanClauseOccur; |
||||||
|
import com.liferay.portal.kernel.search.BooleanQuery; |
||||||
|
import com.liferay.portal.kernel.search.BooleanQueryFactoryUtil; |
||||||
|
import com.liferay.portal.kernel.search.Hits; |
||||||
|
import com.liferay.portal.kernel.search.Indexer; |
||||||
|
import com.liferay.portal.kernel.search.IndexerRegistryUtil; |
||||||
|
import com.liferay.portal.kernel.search.SearchContext; |
||||||
|
import com.liferay.portal.kernel.search.SearchException; |
||||||
|
import com.liferay.portal.kernel.util.ArrayUtil; |
||||||
|
import com.liferay.portal.kernel.util.Validator; |
||||||
|
import com.liferay.portal.model.Contact; |
||||||
|
import com.liferay.portal.theme.ThemeDisplay; |
||||||
|
import com.liferay.portal.util.PortalUtil; |
||||||
|
import com.liferay.portlet.PortletURLFactoryUtil; |
||||||
|
import com.liferay.portlet.asset.AssetRendererFactoryRegistryUtil; |
||||||
|
import com.liferay.portlet.asset.model.AssetEntry; |
||||||
|
import com.liferay.portlet.asset.model.AssetRenderer; |
||||||
|
import com.liferay.portlet.asset.model.AssetRendererFactory; |
||||||
|
import com.liferay.portlet.trash.model.TrashEntry; |
||||||
|
|
||||||
|
public class AssetUtil { |
||||||
|
public static long[] getAvailableClassNameIds(long companyId) { |
||||||
|
List<Long> classNameIds = new ArrayList<Long>(); |
||||||
|
List<AssetRendererFactory> assetRendererFactories = AssetRendererFactoryRegistryUtil |
||||||
|
.getAssetRendererFactories(companyId); |
||||||
|
for (AssetRendererFactory assetRendererFactory : assetRendererFactories) { |
||||||
|
if (ExpandoUtil.hasCustomFields(companyId, assetRendererFactory.getClassNameId()) |
||||||
|
&& !ArrayUtil.contains(_EXCLUDED_CLASS_NAMES, |
||||||
|
assetRendererFactory.getClassName())) |
||||||
|
classNameIds.add(Long.valueOf(assetRendererFactory.getClassNameId())); |
||||||
|
} |
||||||
|
List<Indexer> indexers = IndexerRegistryUtil.getIndexers(); |
||||||
|
for (Indexer indexer : indexers) { |
||||||
|
if (indexer.getClassNames() != null) { |
||||||
|
byte b; |
||||||
|
int i; |
||||||
|
String[] arrayOfString; |
||||||
|
for (i = (arrayOfString = indexer.getClassNames()).length, b = 0; b < i;) { |
||||||
|
String className = arrayOfString[b]; |
||||||
|
if (!ArrayUtil.contains(_EXCLUDED_CLASS_NAMES, className)) { |
||||||
|
long classNameId = PortalUtil.getClassNameId(className); |
||||||
|
if (!classNameIds.contains(Long.valueOf(classNameId))) |
||||||
|
classNameIds.add(Long.valueOf(classNameId)); |
||||||
|
} |
||||||
|
b++; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return toArray(classNameIds); |
||||||
|
} |
||||||
|
|
||||||
|
public static long[] getAvailableIndexerClassNameIds(long companyId) { |
||||||
|
return getAvailableIndexerClassNameIds(companyId, true); |
||||||
|
} |
||||||
|
|
||||||
|
public static long[] getAvailableIndexerClassNameIds(long companyId, boolean indexer) { |
||||||
|
List<Long> listClassNameIds = new ArrayList<Long>(); |
||||||
|
long[] availableClassNameIds = getAvailableClassNameIds(companyId); |
||||||
|
byte b; |
||||||
|
int i; |
||||||
|
long[] arrayOfLong1; |
||||||
|
for (i = (arrayOfLong1 = availableClassNameIds).length, b = 0; b < i;) { |
||||||
|
long classNameId = arrayOfLong1[b]; |
||||||
|
boolean hasIndexer = hasIndexer(PortalUtil.getClassName(classNameId)); |
||||||
|
if (hasIndexer && indexer) { |
||||||
|
listClassNameIds.add(Long.valueOf(classNameId)); |
||||||
|
} else if (!hasIndexer && !indexer) { |
||||||
|
listClassNameIds.add(Long.valueOf(classNameId)); |
||||||
|
} |
||||||
|
b++; |
||||||
|
} |
||||||
|
return toArray(listClassNameIds); |
||||||
|
} |
||||||
|
|
||||||
|
public static boolean hasIndexer(String className) { |
||||||
|
Indexer indexer = IndexerRegistryUtil.getIndexer(className); |
||||||
|
return (indexer != null); |
||||||
|
} |
||||||
|
|
||||||
|
public static String getIconPath(PortletRequest request, String className) { |
||||||
|
AssetRendererFactory assetRendererFactory = AssetRendererFactoryRegistryUtil |
||||||
|
.getAssetRendererFactoryByClassName(className); |
||||||
|
if (assetRendererFactory != null) |
||||||
|
return assetRendererFactory.getIconPath(request); |
||||||
|
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute("LIFERAY_SHARED_THEME_DISPLAY"); |
||||||
|
return String.valueOf(themeDisplay.getPathThemeImages()) + "/common/page.png"; |
||||||
|
} |
||||||
|
|
||||||
|
public static String getAssetViewURL(LiferayPortletRequest liferayPortletRequest, |
||||||
|
ThemeDisplay themeDisplay, AssetEntry assetEntry) throws Exception { |
||||||
|
LiferayPortletURL liferayPortletURL = PortletURLFactoryUtil.create( |
||||||
|
liferayPortletRequest, "101", themeDisplay.getPlid(), "RENDER_PHASE"); |
||||||
|
liferayPortletURL.setParameter("struts_action", "/asset_publisher/view_content"); |
||||||
|
liferayPortletURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId())); |
||||||
|
liferayPortletURL.setParameter("redirect", ""); |
||||||
|
AssetRendererFactory assetRendererFactory = assetEntry.getAssetRendererFactory(); |
||||||
|
AssetRenderer assetRenderer = assetEntry.getAssetRenderer(); |
||||||
|
liferayPortletURL.setParameter("type", assetRendererFactory.getType()); |
||||||
|
if (Validator.isNotNull(assetRenderer.getUrlTitle())) |
||||||
|
liferayPortletURL.setParameter("urlTitle", assetRenderer.getUrlTitle()); |
||||||
|
liferayPortletURL.setParameter("redirect", "%23"); |
||||||
|
liferayPortletURL.setWindowState(LiferayWindowState.POP_UP); |
||||||
|
liferayPortletURL.setPortletMode(PortletMode.VIEW); |
||||||
|
return liferayPortletURL.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
public static String render(LiferayPortletRequest liferayPortletRequest, ThemeDisplay themeDisplay, |
||||||
|
long classNameId, long classPK) throws Exception { |
||||||
|
LiferayPortletURL liferayPortletURL = PortletURLFactoryUtil.create( |
||||||
|
liferayPortletRequest, themeDisplay.getPortletDisplay().getId(), |
||||||
|
themeDisplay.getPlid(), "RENDER_PHASE"); |
||||||
|
liferayPortletURL.setParameter("classNameId", String.valueOf(classNameId)); |
||||||
|
liferayPortletURL.setParameter("classPK", String.valueOf(classPK)); |
||||||
|
liferayPortletURL.setParameter("mvcPath", "/html/map/asset_popup.jsp"); |
||||||
|
liferayPortletURL.setPortletMode(PortletMode.VIEW); |
||||||
|
liferayPortletURL.setWindowState(LiferayWindowState.POP_UP); |
||||||
|
return liferayPortletURL.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
public static String getTitleByIndexer(long companyId, String className, long classPK) |
||||||
|
throws SearchException { |
||||||
|
Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(className); |
||||||
|
SearchContext searchContext = new SearchContext(); |
||||||
|
searchContext.setCompanyId(companyId); |
||||||
|
BooleanQuery booleanQueryDocument = BooleanQueryFactoryUtil.create(searchContext); |
||||||
|
booleanQueryDocument.addRequiredTerm("entryClassName", className); |
||||||
|
booleanQueryDocument.addRequiredTerm("entryClassPK", classPK); |
||||||
|
BooleanClause booleanClause = BooleanClauseFactoryUtil.create(searchContext, |
||||||
|
booleanQueryDocument, BooleanClauseOccur.SHOULD.getName()); |
||||||
|
searchContext.setBooleanClauses(new BooleanClause[] { booleanClause }); |
||||||
|
Hits hits = indexer.search(searchContext); |
||||||
|
String title = hits.getDocs()[0].get("title"); |
||||||
|
if (Validator.isNull(title)) |
||||||
|
title = hits.getDocs()[0].get("name"); |
||||||
|
return title; |
||||||
|
} |
||||||
|
|
||||||
|
private static long[] toArray(List<Long> list) { |
||||||
|
long[] ids = new long[list.size()]; |
||||||
|
int index = 0; |
||||||
|
for (Long id : list) |
||||||
|
ids[index++] = id.longValue(); |
||||||
|
return ids; |
||||||
|
} |
||||||
|
|
||||||
|
private static final String[] _EXCLUDED_CLASS_NAMES = new String[] { Contact.class.getName(), |
||||||
|
TrashEntry.class.getName(), PluginPackage.class.getName() }; |
||||||
|
} |
@ -0,0 +1,124 @@ |
|||||||
|
package it.tref.liferay.mapit.util; |
||||||
|
|
||||||
|
import com.liferay.portal.kernel.exception.PortalException; |
||||||
|
import com.liferay.portal.kernel.exception.SystemException; |
||||||
|
import com.liferay.portal.kernel.util.UnicodeProperties; |
||||||
|
import com.liferay.portal.kernel.util.Validator; |
||||||
|
import com.liferay.portlet.expando.model.ExpandoColumn; |
||||||
|
import com.liferay.portlet.expando.model.ExpandoTable; |
||||||
|
import com.liferay.portlet.expando.service.ExpandoColumnLocalServiceUtil; |
||||||
|
import com.liferay.portlet.expando.service.ExpandoTableLocalServiceUtil; |
||||||
|
|
||||||
|
public class ExpandoUtil { |
||||||
|
public static ExpandoColumn addExpandoIfNotExists(long companyId, long classNameId, String name, |
||||||
|
boolean indexable, boolean hidden) throws SystemException { |
||||||
|
ExpandoTable expandoTable = null; |
||||||
|
try { |
||||||
|
expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, classNameId, "CUSTOM_FIELDS"); |
||||||
|
} catch (PortalException portalException) { |
||||||
|
try { |
||||||
|
expandoTable = ExpandoTableLocalServiceUtil.addTable(companyId, classNameId, "CUSTOM_FIELDS"); |
||||||
|
} catch (PortalException portalException1) { |
||||||
|
} |
||||||
|
} |
||||||
|
ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil |
||||||
|
.getColumn(expandoTable.getTableId(), name); |
||||||
|
if (expandoColumn == null) |
||||||
|
try { |
||||||
|
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), name, 15); |
||||||
|
expandoColumn = updateExpando(expandoColumn, indexable, hidden); |
||||||
|
} catch (PortalException portalException) { |
||||||
|
} |
||||||
|
return expandoColumn; |
||||||
|
} |
||||||
|
|
||||||
|
public static ExpandoColumn updateExpando(long companyId, long classNameId, String name, |
||||||
|
boolean indexable, boolean hidden) throws SystemException { |
||||||
|
ExpandoColumn expandoColumn = null; |
||||||
|
try { |
||||||
|
ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, classNameId, |
||||||
|
"CUSTOM_FIELDS"); |
||||||
|
expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(expandoTable.getTableId(), name); |
||||||
|
if (expandoColumn == null) |
||||||
|
expandoColumn = updateExpando(expandoColumn, indexable, hidden); |
||||||
|
} catch (PortalException portalException) { |
||||||
|
} |
||||||
|
return expandoColumn; |
||||||
|
} |
||||||
|
|
||||||
|
public static void deleteExpando(long companyId, long classNameId, String name) throws SystemException { |
||||||
|
try { |
||||||
|
ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, classNameId, |
||||||
|
"CUSTOM_FIELDS"); |
||||||
|
ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(expandoTable.getTableId(), |
||||||
|
name); |
||||||
|
ExpandoColumnLocalServiceUtil.deleteColumn(expandoColumn.getColumnId()); |
||||||
|
} catch (PortalException portalException) { |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static boolean exists(long companyId, long classNameId, String name) { |
||||||
|
try { |
||||||
|
ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(companyId, classNameId, |
||||||
|
"CUSTOM_FIELDS", name); |
||||||
|
return (expandoColumn != null); |
||||||
|
} catch (SystemException systemException) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static boolean isType(long companyId, long classNameId, String name) { |
||||||
|
try { |
||||||
|
ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(companyId, classNameId, |
||||||
|
"CUSTOM_FIELDS", name); |
||||||
|
return (expandoColumn != null && expandoColumn.getType() == 15); |
||||||
|
} catch (SystemException systemException) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static boolean isIndexed(long companyId, long classNameId, String name) { |
||||||
|
try { |
||||||
|
ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(companyId, classNameId, |
||||||
|
"CUSTOM_FIELDS", name); |
||||||
|
if (expandoColumn != null) { |
||||||
|
UnicodeProperties typeSettingsProperties = expandoColumn.getTypeSettingsProperties(); |
||||||
|
String indexType = typeSettingsProperties.get("index-type"); |
||||||
|
if (Validator.isNotNull(indexType) && indexType.equals(String.valueOf(1))) |
||||||
|
return true; |
||||||
|
return false; |
||||||
|
} |
||||||
|
} catch (SystemException systemException) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
public static boolean hasCustomFields(long companyId, long classNameId) { |
||||||
|
boolean existsLat = (exists(companyId, classNameId, "MAPIT_LAT") && exists(companyId, classNameId, |
||||||
|
"MAPIT_LAT_HIDDEN")); |
||||||
|
boolean existsLon = (exists(companyId, classNameId, "MAPIT_LON") && exists(companyId, classNameId, |
||||||
|
"MAPIT_LON_HIDDEN")); |
||||||
|
if (existsLat && existsLon) { |
||||||
|
boolean isTypeLat = (isType(companyId, classNameId, "MAPIT_LAT") && isType(companyId, |
||||||
|
classNameId, "MAPIT_LAT_HIDDEN")); |
||||||
|
boolean isIndexedLat = isIndexed(companyId, classNameId, "MAPIT_LAT_HIDDEN"); |
||||||
|
boolean isTypeLon = (isType(companyId, classNameId, "MAPIT_LON") && isType(companyId, |
||||||
|
classNameId, "MAPIT_LON_HIDDEN")); |
||||||
|
boolean isIndexedLon = isIndexed(companyId, classNameId, "MAPIT_LON_HIDDEN"); |
||||||
|
return (existsLat && existsLon && isTypeLat && isTypeLon && isIndexedLat && isIndexedLon); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
private static ExpandoColumn updateExpando(ExpandoColumn expandoColumn, boolean indexable, boolean hidden) |
||||||
|
throws SystemException { |
||||||
|
UnicodeProperties typeSettingsProperties = expandoColumn.getTypeSettingsProperties(); |
||||||
|
if (indexable) |
||||||
|
typeSettingsProperties.put("index-type", String.valueOf(1)); |
||||||
|
if (hidden) |
||||||
|
typeSettingsProperties.put("hidden", String.valueOf(true)); |
||||||
|
expandoColumn.setTypeSettingsProperties(typeSettingsProperties); |
||||||
|
return ExpandoColumnLocalServiceUtil.updateExpandoColumn(expandoColumn); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,68 @@ |
|||||||
|
package it.tref.liferay.mapit.util; |
||||||
|
|
||||||
|
import it.tref.liferay.mapit.constants.Constants; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.math.RoundingMode; |
||||||
|
|
||||||
|
public class MapItUtil { |
||||||
|
public static String encodeLat(String coordinate) { |
||||||
|
return encodeCoordinate(coordinate, Constants.MAX_LAT); |
||||||
|
} |
||||||
|
|
||||||
|
public static String encodeLon(String coordinate) { |
||||||
|
return encodeCoordinate(coordinate, Constants.MAX_LON); |
||||||
|
} |
||||||
|
|
||||||
|
private static String encodeCoordinate(String coordinate, BigDecimal max) { |
||||||
|
try { |
||||||
|
coordinate = coordinate.replaceAll(",", "."); |
||||||
|
coordinate = coordinate.replaceAll("[.]", "."); |
||||||
|
String[] part = coordinate.split("[.]"); |
||||||
|
if (part[0].length() > "000".length() + 1) |
||||||
|
part[0] = part[0].substring(0, "000".length() + 1); |
||||||
|
BigDecimal fat = (new BigDecimal(String.valueOf(part[0]) |
||||||
|
+ ((part.length > 1) ? ("." + part[1]) : ".000000000"))).add(max); |
||||||
|
String coordinateString = fat.setScale("000000000".length(), RoundingMode.HALF_DOWN) |
||||||
|
.toPlainString(); |
||||||
|
if (fat.compareTo(max.multiply(new BigDecimal(2))) == 1) { |
||||||
|
fat = max.multiply(new BigDecimal(2)); |
||||||
|
coordinateString = fat.setScale("000000000".length()).toPlainString(); |
||||||
|
} else if (fat.compareTo(new BigDecimal(0)) == -1) { |
||||||
|
fat = new BigDecimal(0); |
||||||
|
coordinateString = "000.000000000"; |
||||||
|
} |
||||||
|
return leftPad(coordinateString, "000000000".length() + "000".length() + ".".length(), "0"); |
||||||
|
} catch (NumberFormatException numberFormatException) { |
||||||
|
return "-1"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static String decodeLat(String coordinate) { |
||||||
|
return decodeCoordinate(coordinate, Constants.MAX_LAT); |
||||||
|
} |
||||||
|
|
||||||
|
public static String decodeLon(String coordinate) { |
||||||
|
return decodeCoordinate(coordinate, Constants.MAX_LON); |
||||||
|
} |
||||||
|
|
||||||
|
private static String decodeCoordinate(String coordinate, BigDecimal max) { |
||||||
|
try { |
||||||
|
if (coordinate.equals("-1")) |
||||||
|
return ""; |
||||||
|
String[] part = coordinate.split("[.]"); |
||||||
|
BigDecimal current = new BigDecimal(String.valueOf(part[0]) |
||||||
|
+ ((part.length > 1) ? ("." + part[1]) : ".000000000")); |
||||||
|
return current.subtract(max).setScale("000000000".length()).toPlainString().replace(".", "."); |
||||||
|
} catch (NumberFormatException numberFormatException) { |
||||||
|
return "-1"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static String leftPad(String s, int size, String str) { |
||||||
|
StringBuilder stringBuilder = new StringBuilder(s); |
||||||
|
while (stringBuilder.length() < size) |
||||||
|
stringBuilder.insert(0, str); |
||||||
|
return stringBuilder.toString(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
package it.tref.liferay.mapit.util; |
||||||
|
|
||||||
|
import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil; |
||||||
|
import com.liferay.portal.kernel.bean.PortletBeanLocatorUtil; |
||||||
|
import com.liferay.portal.kernel.log.Log; |
||||||
|
import com.liferay.portal.kernel.log.LogFactoryUtil; |
||||||
|
|
||||||
|
public class MapitHelperUtil { |
||||||
|
public static Object findService(String serviceName) { |
||||||
|
Object bean = null; |
||||||
|
try { |
||||||
|
bean = PortalBeanLocatorUtil.locate(serviceName); |
||||||
|
} catch (Exception e) { |
||||||
|
_log.error(e, e); |
||||||
|
} |
||||||
|
return bean; |
||||||
|
} |
||||||
|
|
||||||
|
public static Object findService(String servletContextName, String serviceName) { |
||||||
|
Object bean = null; |
||||||
|
try { |
||||||
|
bean = PortletBeanLocatorUtil.locate(servletContextName, serviceName); |
||||||
|
} catch (Exception e) { |
||||||
|
_log.error(e, e); |
||||||
|
} |
||||||
|
return bean; |
||||||
|
} |
||||||
|
|
||||||
|
private static Log _log = LogFactoryUtil.getLog(MapitHelperUtil.class); |
||||||
|
} |
@ -0,0 +1,190 @@ |
|||||||
|
package it.tref.liferay.mapit.util; |
||||||
|
|
||||||
|
import it.tref.liferay.mapit.constants.Constants; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Locale; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import com.liferay.portal.kernel.dao.orm.QueryUtil; |
||||||
|
import com.liferay.portal.kernel.exception.SystemException; |
||||||
|
import com.liferay.portal.kernel.search.BooleanClause; |
||||||
|
import com.liferay.portal.kernel.search.BooleanClauseFactoryUtil; |
||||||
|
import com.liferay.portal.kernel.search.BooleanClauseOccur; |
||||||
|
import com.liferay.portal.kernel.search.BooleanQuery; |
||||||
|
import com.liferay.portal.kernel.search.BooleanQueryFactoryUtil; |
||||||
|
import com.liferay.portal.kernel.search.Document; |
||||||
|
import com.liferay.portal.kernel.search.Hits; |
||||||
|
import com.liferay.portal.kernel.search.Indexer; |
||||||
|
import com.liferay.portal.kernel.search.IndexerRegistryUtil; |
||||||
|
import com.liferay.portal.kernel.search.ParseException; |
||||||
|
import com.liferay.portal.kernel.search.Query; |
||||||
|
import com.liferay.portal.kernel.search.QueryConfig; |
||||||
|
import com.liferay.portal.kernel.search.SearchContext; |
||||||
|
import com.liferay.portal.kernel.search.SearchEngineUtil; |
||||||
|
import com.liferay.portal.kernel.search.Sort; |
||||||
|
import com.liferay.portal.kernel.search.StringQueryFactoryUtil; |
||||||
|
import com.liferay.portal.kernel.util.ClassResolverUtil; |
||||||
|
import com.liferay.portal.kernel.util.GetterUtil; |
||||||
|
import com.liferay.portal.kernel.util.PortalClassLoaderUtil; |
||||||
|
import com.liferay.portal.kernel.util.ReflectionUtil; |
||||||
|
import com.liferay.portal.kernel.util.Validator; |
||||||
|
import com.liferay.portal.service.ServiceContext; |
||||||
|
import com.liferay.portal.util.PortalUtil; |
||||||
|
import com.liferay.portlet.asset.service.persistence.AssetEntryQuery; |
||||||
|
import com.liferay.portlet.expando.util.ExpandoBridgeIndexerUtil; |
||||||
|
|
||||||
|
public class SearchUtil { |
||||||
|
public static Hits search(String stringQuery, int start, int end, String orderByCol1, |
||||||
|
String orderByType1, String orderByCol2, String orderByType2, double[] bbox, |
||||||
|
boolean viewAllAssetts, ServiceContext serviceContext) throws Exception { |
||||||
|
BooleanQuery booleanQuery = null; |
||||||
|
SearchContext searchContext = new SearchContext(); |
||||||
|
searchContext.setCompanyId(serviceContext.getCompanyId()); |
||||||
|
if (start == 0 && end == 0) { |
||||||
|
start = QueryUtil.ALL_POS; |
||||||
|
end = QueryUtil.ALL_POS; |
||||||
|
} |
||||||
|
Query query = StringQueryFactoryUtil.create(stringQuery); |
||||||
|
if (bbox == null) |
||||||
|
bbox = new double[] { Constants.MIN_LON.doubleValue(), Constants.MIN_LAT.doubleValue(), |
||||||
|
Constants.MAX_LON.doubleValue(), Constants.MAX_LAT.doubleValue() }; |
||||||
|
if (viewAllAssetts) { |
||||||
|
BooleanQuery booleanQuery1 = getBooleanQueryBbox(bbox, searchContext); |
||||||
|
booleanQuery1.add(query, BooleanClauseOccur.MUST); |
||||||
|
booleanQuery = booleanQuery1; |
||||||
|
} else { |
||||||
|
searchContext.setStart(start); |
||||||
|
searchContext.setEnd(end); |
||||||
|
} |
||||||
|
if (Validator.isNotNull(orderByCol1) && Validator.isNotNull(orderByCol2)) { |
||||||
|
AssetEntryQuery assetEntryQuery = new AssetEntryQuery(); |
||||||
|
assetEntryQuery.setOrderByCol1(orderByCol1); |
||||||
|
assetEntryQuery.setOrderByCol2(orderByCol2); |
||||||
|
assetEntryQuery.setOrderByType1(orderByType1); |
||||||
|
assetEntryQuery.setOrderByType2(orderByType2); |
||||||
|
Class<?> clazz = ClassResolverUtil.resolve("com.liferay.portlet.asset.util.AssetUtil", |
||||||
|
PortalClassLoaderUtil.getClassLoader()); |
||||||
|
searchContext.setSorts((Sort[]) ReflectionUtil.getDeclaredMethod(clazz, "getSorts", |
||||||
|
new Class[] { AssetEntryQuery.class, Locale.class }).invoke(null, |
||||||
|
new Object[] { assetEntryQuery, serviceContext.getLocale() })); |
||||||
|
} |
||||||
|
Hits hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||||
|
if (!viewAllAssetts) |
||||||
|
if (hits.getLength() > 0) { |
||||||
|
searchContext.setStart(QueryUtil.ALL_POS); |
||||||
|
searchContext.setEnd(QueryUtil.ALL_POS); |
||||||
|
BooleanQuery booleanQuery1 = getBooleanQueryBbox(bbox, searchContext); |
||||||
|
booleanQuery1.add(booleanQuery, BooleanClauseOccur.MUST); |
||||||
|
BooleanQuery booleanQueryHits = BooleanQueryFactoryUtil.create(searchContext); |
||||||
|
for (int i = 0; i < (hits.getDocs()).length; i++) { |
||||||
|
Document document = hits.doc(i); |
||||||
|
String className = document.get("entryClassName"); |
||||||
|
long classPK = GetterUtil.getLong(document.get("entryClassPK")); |
||||||
|
BooleanQuery booleanQueryDocument = BooleanQueryFactoryUtil.create(searchContext); |
||||||
|
booleanQueryDocument.addRequiredTerm("entryClassName", className); |
||||||
|
booleanQueryDocument.addRequiredTerm("entryClassPK", classPK); |
||||||
|
booleanQueryHits.add(booleanQueryDocument, BooleanClauseOccur.SHOULD); |
||||||
|
} |
||||||
|
booleanQuery1.add(booleanQueryHits, BooleanClauseOccur.MUST); |
||||||
|
hits = SearchEngineUtil.search(searchContext, booleanQuery1); |
||||||
|
} |
||||||
|
return hits; |
||||||
|
} |
||||||
|
|
||||||
|
public static Hits search(long companyId, long groupId, long classNameId, |
||||||
|
Map<String, Serializable> attributes, int start, int end, Sort sort, double[] bbox) |
||||||
|
throws SystemException { |
||||||
|
try { |
||||||
|
String className = PortalUtil.getClassName(classNameId); |
||||||
|
Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(className); |
||||||
|
if (attributes != null) |
||||||
|
attributes = new HashMap<String, Serializable>(); |
||||||
|
if (start == 0 && end == 0) { |
||||||
|
start = QueryUtil.ALL_POS; |
||||||
|
end = QueryUtil.ALL_POS; |
||||||
|
} |
||||||
|
SearchContext searchContext = new SearchContext(); |
||||||
|
searchContext.setAndSearch(true); |
||||||
|
searchContext.setAttributes(attributes); |
||||||
|
searchContext.setGroupIds(new long[] { groupId }); |
||||||
|
if (bbox == null) |
||||||
|
bbox = new double[] { Constants.MIN_LON.doubleValue(), Constants.MIN_LAT.doubleValue(), |
||||||
|
Constants.MAX_LON.doubleValue(), Constants.MAX_LAT.doubleValue() }; |
||||||
|
BooleanClause booleanClause = BooleanClauseFactoryUtil.create(searchContext, |
||||||
|
getBooleanQueryBbox(bbox, searchContext), BooleanClauseOccur.MUST.getName()); |
||||||
|
searchContext.setBooleanClauses(new BooleanClause[] { booleanClause }); |
||||||
|
searchContext.setCompanyId(companyId); |
||||||
|
searchContext.setStart(start); |
||||||
|
searchContext.setEnd(end); |
||||||
|
if (sort != null) |
||||||
|
searchContext.setSorts(new Sort[] { sort }); |
||||||
|
QueryConfig queryConfig = new QueryConfig(); |
||||||
|
queryConfig.setHighlightEnabled(false); |
||||||
|
queryConfig.setScoreEnabled(false); |
||||||
|
searchContext.setQueryConfig(queryConfig); |
||||||
|
return indexer.search(searchContext); |
||||||
|
} catch (Exception e) { |
||||||
|
throw new SystemException(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static BooleanQuery getBooleanQueryBbox(double[] bbox, SearchContext searchContext) |
||||||
|
throws ParseException { |
||||||
|
double minLon = bbox[0]; |
||||||
|
double minLat = bbox[1]; |
||||||
|
double maxLon = bbox[2]; |
||||||
|
double maxLat = bbox[3]; |
||||||
|
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||||
|
BooleanQuery booleanQueryLat = createBooleanQueryRangeTerm( |
||||||
|
ExpandoBridgeIndexerUtil.encodeFieldName("MAPIT_LAT_HIDDEN"), |
||||||
|
MapItUtil.encodeLat(String.valueOf(minLat)), MapItUtil.encodeLat(String.valueOf(maxLat)), |
||||||
|
searchContext); |
||||||
|
booleanQuery.add(booleanQueryLat, BooleanClauseOccur.MUST); |
||||||
|
if (minLon < GetterUtil.getDouble(Constants.MIN_LON) |
||||||
|
|| maxLon > GetterUtil.getDouble(Constants.MAX_LON)) { |
||||||
|
BooleanQuery booleanQueryLon = null; |
||||||
|
if (minLon < GetterUtil.getDouble(Constants.MIN_LON)) { |
||||||
|
minLon -= GetterUtil.getDouble(String.valueOf(Constants.MIN_LON)) * 2.0D; |
||||||
|
String[][] range = { |
||||||
|
{ MapItUtil.encodeLon(String.valueOf(minLon)), |
||||||
|
MapItUtil.encodeLon(String.valueOf(Constants.MAX_LON)) }, |
||||||
|
{ "-" + MapItUtil.encodeLon(String.valueOf(Constants.MAX_LON)), |
||||||
|
MapItUtil.encodeLon(String.valueOf(maxLon)) } }; |
||||||
|
booleanQueryLon = createBooleanQueryRangeTerm( |
||||||
|
ExpandoBridgeIndexerUtil.encodeFieldName("MAPIT_LON_HIDDEN"), range, searchContext); |
||||||
|
} else { |
||||||
|
maxLon -= GetterUtil.getDouble(String.valueOf(Constants.MAX_LON)) * 2.0D; |
||||||
|
String[][] range = { |
||||||
|
{ MapItUtil.encodeLon(String.valueOf(minLon)), |
||||||
|
MapItUtil.encodeLon(String.valueOf(Constants.MAX_LON)) }, |
||||||
|
{ "-" + MapItUtil.encodeLon(String.valueOf(Constants.MAX_LON)), |
||||||
|
MapItUtil.encodeLon(String.valueOf(maxLon)) } }; |
||||||
|
booleanQueryLon = createBooleanQueryRangeTerm( |
||||||
|
ExpandoBridgeIndexerUtil.encodeFieldName("MAPIT_LON_HIDDEN"), range, searchContext); |
||||||
|
} |
||||||
|
booleanQuery.add(booleanQueryLon, BooleanClauseOccur.MUST); |
||||||
|
} else { |
||||||
|
BooleanQuery booleanQueryLon = createBooleanQueryRangeTerm( |
||||||
|
ExpandoBridgeIndexerUtil.encodeFieldName("MAPIT_LON_HIDDEN"), |
||||||
|
MapItUtil.encodeLon(String.valueOf(minLon)), MapItUtil.encodeLon(String.valueOf(maxLon)), |
||||||
|
searchContext); |
||||||
|
booleanQuery.add(booleanQueryLon, BooleanClauseOccur.MUST); |
||||||
|
} |
||||||
|
return booleanQuery; |
||||||
|
} |
||||||
|
|
||||||
|
private static BooleanQuery createBooleanQueryRangeTerm(String field, String min, String max, |
||||||
|
SearchContext searchContext) { |
||||||
|
return createBooleanQueryRangeTerm(field, new String[][] { { min, max }, }, searchContext); |
||||||
|
} |
||||||
|
|
||||||
|
private static BooleanQuery createBooleanQueryRangeTerm(String field, String[][] range, |
||||||
|
SearchContext searchContext) { |
||||||
|
BooleanQuery query = BooleanQueryFactoryUtil.create(searchContext); |
||||||
|
for (int i = 0; i < range.length; i++) |
||||||
|
query.addRangeTerm(field, range[i][0], range[i][1]); |
||||||
|
return query; |
||||||
|
} |
||||||
|
} |
Caricamento…
Reference in new issue