diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/js/main.js b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/js/main.js
index 4cf3e5e3..3b569292 100644
--- a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/js/main.js
+++ b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/js/main.js
@@ -92,3 +92,14 @@ $('body').on('mouseup', 'label.radio', function(){
if(radio.length)
uncheck_radio_before_click(radio);
})
+
+if($('.cont_maps').length){
+ $('.cont_maps ul li').click(function(){
+ var map = mapItMap.getInstance();
+ setTimeout(function(){
+ map.updateSize();
+ if(map.layers.length > 0)
+ map.layers[0].redraw();
+ }, 100);
+ });
+}
\ No newline at end of file
diff --git a/liferay-plugins-sdk-6.2/portlets/portos-log-portlet/.tern-project b/liferay-plugins-sdk-6.2/portlets/portos-log-portlet/.tern-project
new file mode 100644
index 00000000..a185ba0d
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/portlets/portos-log-portlet/.tern-project
@@ -0,0 +1 @@
+{"ide":{"scriptPaths":[]},"plugins":{"aui":{},"liferay":{},"yui":{}},"libs":["ecma5","browser"]}
\ No newline at end of file
diff --git a/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/build.xml b/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/build.xml
index 9479e677..76de9c9c 100644
--- a/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/build.xml
+++ b/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/build.xml
@@ -2,5 +2,6 @@
\ No newline at end of file
diff --git a/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/WEB-INF/lib/tref-mapit-shared.jar b/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/WEB-INF/lib/tref-mapit-shared.jar
index 132e1a7d..39c715bb 100644
Binary files a/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/WEB-INF/lib/tref-mapit-shared.jar and b/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/WEB-INF/lib/tref-mapit-shared.jar differ
diff --git a/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/html/plugin/top.jsp b/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/html/plugin/top.jsp
index 5b6702c1..aa1f367c 100644
--- a/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/html/plugin/top.jsp
+++ b/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/html/plugin/top.jsp
@@ -6,27 +6,15 @@
<%@page import="com.liferay.portal.util.PortletKeys"%>
<%@page import="com.liferay.portlet.PortletURLFactoryUtil"%>
<%@include file="/html/plugin/init.jsp" %>
-
-
<%
- String contextName = getServletContext().getServletContextName();
- String portletNamespace = ParamUtil.getString(request, "mapitNamespace", "_1_WAR_portosfeportlet_");
+String contextName = getServletContext().getServletContextName();
+String portletNamespace = ParamUtil.getString(request, "mapitNamespace", "_1_WAR_portosfeportlet_");
+String verifyComune = ParamUtil.getString(request, "verifyComune", "true");
%>
-
-<%
-/* PortletURL popupURL = PortletURLFactoryUtil.create(request, "1_WAR_portosmapitplugin",
- plid, PortletRequest.RENDER_PHASE); */
-
-/* popupURL.setParameter("mvcPath", "/html/move_asset/popup.jsp");
-popupURL.setWindowState(LiferayWindowState.POP_UP);
-popupURL.setPortletMode(PortletMode.VIEW); */
-%>
-
-
@@ -95,7 +81,7 @@ popupURL.setPortletMode(PortletMode.VIEW); */
var portletNamespace = "<%= portletNamespace %>",
mapItMap;
-
+var verifyComune = <%= verifyComune %>;
Liferay.on('<%= "mapItMapReady" + StringPool.PERIOD + getServletContext().getServletContextName() %>', function(event) {
AUI().use('liferay-mapit-map', 'aui-io-request', function(A) {
@@ -107,106 +93,27 @@ Liferay.on('<%= "mapItMapReady" + StringPool.PERIOD + getServletContext().getSer
mapItMap = Liferay.MapItMap.get(portletId);
var latitude = AUI().one("#"+portletNamespace+"lat"),
- longitude = AUI().one("#"+portletNamespace+"long"),
- isEditable = AUI().one("#"+portletNamespace+"geoIsEditable").val() == "true";
+ longitude = AUI().one("#"+portletNamespace+"long");
+ var isEditable = AUI().one("#"+portletNamespace+"geoIsEditable");
+ isEditable = (undefined == isEditable) || (isEditable.val() == "true");
var editableLatitude = AUI().one("#"+portletNamespace+"lat_hidden"),
editableLongitude = AUI().one("#"+portletNamespace+"long_hidden"),
- editableZoom = AUI().one("#"+portletNamespace+"zoom");
+ editableZoom = AUI().one("#"+portletNamespace+"zoom");
- var extent = new OpenLayers.Bounds();
- extent.extend(new OpenLayers.LonLat(9.6771486410157, 44.486291328126));
- extent.extend(new OpenLayers.LonLat(12.431970418358, 42.214181342774));
+ var extent = new OpenLayers.Bounds();
+ extent.extend(new OpenLayers.LonLat(9.6771486410157, 44.486291328126));
+ extent.extend(new OpenLayers.LonLat(12.431970418358, 42.214181342774));
- var geographic = new OpenLayers.Projection("EPSG:4326");
+ var geographic = new OpenLayers.Projection("EPSG:4326");
var mercator = new OpenLayers.Projection( "EPSG:3857");
extent.transform(geographic,mercator );
- //mapItMap.addOption({restrictedExtent: extent});
-
- /* var boxes = new OpenLayers.Layer.Boxes("boxes");
- var box = new OpenLayers.Marker.Box(extent);
- boxes.addMarker(box);
- mapItMap.addWMSLayer(boxes); */
-
-
- var civici = new OpenLayers.Layer.WMS(
- 'Numeri Civici',
- 'http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmsosm_d&map_resolution=91&', {
- styles: 'etichette_blu',
- layers: 'rt_osm.civici.point', transparent: true},
- {isBaseLayer: false, visibility : false}
- );
- //mapItMap.addWMSLayer(civici);
-
- var comuni = new OpenLayers.Layer.WMS(
- 'Comuni',
- 'http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmsambamm&map_resolution=91', {
- styles: 'contorno_senza_etichette',
- layers: 'rt_ambamm.idcomuni.rt.poly', transparent: true},
- {isBaseLayer: false}
- );
- //mapItMap.addWMSLayer(comuni);
-
- var topografico = new OpenLayers.Layer.WMS(
- 'Topografico',
- 'http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmscartoteca&map_resolution=91&', {
- styles: 'senza_etichette',
- layers: 'rt_cartoteca.dbt.2k', transparent: true},
- {isBaseLayer: false, visibility : false}
- );
- //mapItMap.addWMSLayer(topografico);
-
- var rischio_bacini_regionali = new OpenLayers.Layer.WMS(
- 'Rischio Idrogeologico',
- 'http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmsperidr&map_resolution=91&language=ita&', {
- styles: 'default',
- layers: 'rt_peridr.rischio_bacini_regionali', transparent: true},
- {isBaseLayer: false, visibility : false}
- );
- //mapItMap.addWMSLayer(rischio_bacini_regionali);
-
- var catasto_strade = new OpenLayers.Layer.WMS(
- 'Strade',
- 'http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmscatasto&map_resolution=91&language=ita&', {
- styles: 'terra_di_siena_bruciata',
- layers: 'rt_cat.idcatstrade.rt', transparent: true},
- {isBaseLayer: false, visibility : false}
- );
- //mapItMap.addWMSLayer(catasto_strade);
-
- var catasto_fabbricati = new OpenLayers.Layer.WMS(
- 'Fabbricati',
- 'http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmscatasto&map_resolution=91&language=ita&', {
- styles: 'carminio_chiaro',
- layers: 'rt_cat.idcatfabbr.rt', transparent: true},
- {isBaseLayer: false, visibility : false}
- );
- //mapItMap.addWMSLayer(catasto_fabbricati);
-
- var catasto_fogli = new OpenLayers.Layer.WMS(
- 'Fogli Catastali',
- 'http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmscatasto&map_resolution=91&language=ita&', {
- styles: 'solo_contorno_viola_fine_con_etichette',
- layers: 'rt_cat.idcatbdfog.rt', transparent: true},
- {isBaseLayer: false, visibility : false}
- );
- //mapItMap.addWMSLayer(catasto_fogli);
-
- var catasto_particelle = new OpenLayers.Layer.WMS(
- 'Particelle Catastali',
- 'http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmscatasto&map_resolution=91&language=ita&', {
- styles: 'contorno_rosso_mattone_con_etichette',
- layers: 'rt_cat.idcatpart.rt', transparent: true},
- {isBaseLayer: false, visibility : false}
- );
- //mapItMap.addWMSLayer(catasto_particelle);
-
var markerStyle = {
- graphicHeight: 29,
- graphicWidth: 22,
- externalGraphic: '<%= getServletContext().getContextPath() + "/images/marker.png" %>'
- };
+ graphicHeight: 29,
+ graphicWidth: 22,
+ externalGraphic: '<%= getServletContext().getContextPath() + "/images/marker.png" %>'
+ };
var layerName = '
';
if(latitude.val()!="" && longitude.val()!=""){
@@ -216,7 +123,6 @@ Liferay.on('<%= "mapItMapReady" + StringPool.PERIOD + getServletContext().getSer
style: markerStyle
}];
mapItMap.addLayerPoints(layerName, point, true, {selectable: true, displayInLayerSwitcher: false});
- /* mapItMap.moveMap(longitude , latitude , mapItMap.getCurrentZoom()); */
var secureZoom = "8";
if(editableZoom != undefined && editableZoom != null){
var secureZoom =editableZoom.val()
@@ -225,54 +131,40 @@ Liferay.on('<%= "mapItMapReady" + StringPool.PERIOD + getServletContext().getSer
}
- if(isEditable){
-
+ if (isEditable) {
mapItMap.registerFunctionOnEvent("click", function (e) {
- var position = mapItMap.getPositionOnClick(e);
- var point_lat = position.lat;
- var point_long = position.lon;
- var zoom = mapItMap.getCurrentZoom();
- var newPoint = [ {
- lat: point_lat,
- lon: point_long,
- style: markerStyle
- }];
-
- mapItMap.addLayerPoints(layerName, newPoint, true, {});
- if (confirm("Vuoi aggiornare automaticamente i dati della localizzazione?") == true) {
- updateCoords(point_lat, point_long, zoom, true);
- }
- /* confirm("Vuoi aggiornare automaticamente i dati della localizzazione?",
- {x : point_lat, y : point_long, z : true}
- ) */
-
- });
+ var position = mapItMap.getPositionOnClick(e);
+ var point_lat = position.lat;
+ var point_long = position.lon;
+ var zoom = mapItMap.getCurrentZoom();
+ var newPoint = [ {
+ lat: point_lat,
+ lon: point_long,
+ style: markerStyle
+ }];
+ mapItMap.addLayerPoints(layerName, newPoint, true, {});
+ if (confirm("Vuoi aggiornare automaticamente i dati della localizzazione?")) {
+ updateCoords(point_lat, point_long, zoom, true);
+ }
+ });
mapItMap.attachDrag(layerName, {
on: {
complete: function(event) {
- /* console.log(mapItMap);
- console.log(event);
- console.log(mapItMap.getPositionOnClick(event)); */
+ var point_lat = event.latitude;
+ var point_long = event.longitude;
+ var zoom = mapItMap.getCurrentZoom();
- var point_lat = event.latitude;
- var point_long = event.longitude;
- var zoom = mapItMap.getCurrentZoom();
-
-
- if (confirm("Vuoi aggiornare automaticamente i dati della localizzazione?") == true) {
- updateCoords(point_lat, point_long, zoom, true);
- }
- /* confirm("Vuoi aggiornare automaticamente i dati della localizzazione?",
- {x : point_lat, y : point_long, z : true}
- ) */
+ if (confirm("Vuoi aggiornare automaticamente i dati della localizzazione?")) {
+ updateCoords(point_lat, point_long, zoom, true);
+ }
}
}
});
mapItMap.activateDrag("Pratica");
- var zoomEvent = function(){
- if(editableLatitude.val()!="" && editableLongitude.val()!=""){
+ var zoomEvent = function() {
+ if (editableLatitude.val() != "" && editableLongitude.val() != "") {
editableZoom.val(mapItMap.getCurrentZoom());
}
};
@@ -281,63 +173,37 @@ Liferay.on('<%= "mapItMapReady" + StringPool.PERIOD + getServletContext().getSer
}
Liferay.fire('mapIt-ready');
-
-
- /* featurePicker = new OpenLayers.Control.WMSGetFeatureInfo({
- url: 'http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmscatasto&map_resolution=91&language=ita&',
- title: 'Identify features by clicking',
- layers: [catasto_particelle, catasto_fogli],
- queryVisible: false,
- output:'features',
- eventListeners: {
- getfeatureinfo: function(event) {
- console.log(event);
- console.log(event.features);
- console.log(event.text);
- },
- nogetfeatureinfo: function(event) {
- console.err("No queriable layers found");
- }
-
- }
- });
-
- mapItMap.insertControl(featurePicker);
- featurePicker.activate();
- console.log("Activated"); */
-
- A.one("#
map").append('
');
- var lockButton = A.one('#
container_btn .bloccamap'),
- lockLayer = A.one('#
map .layermap'),
- latValue = editableLatitude != null ? editableLatitude.val() : latitude.val(),
- longValue = editableLongitude != null ? editableLongitude.val() : longitude.val(),
- locked = latValue!="" && longValue!="";
- lockMap(lockButton, lockLayer, latValue, longValue, !locked)
-
- A.one('#
container_btn .bloccamap').on('click', function(event){
- var nodeObject = event.currentTarget,
- locked = event.currentTarget.hasClass('fa-lock');
- lockMap(lockButton, lockLayer, latValue, longValue, locked);
- });
+ A.one("#
map").append('
');
+ var lockButton = A.one('#
container_btn .bloccamap'),
+ lockLayer = A.one('#
map .layermap'),
+ latValue = editableLatitude != null ? editableLatitude.val() : latitude.val(),
+ longValue = editableLongitude != null ? editableLongitude.val() : longitude.val(),
+ locked = latValue != "" && longValue != "";
+ lockMap(lockButton, lockLayer, latValue, longValue, !locked)
+
+ A.one('#
container_btn .bloccamap').on('click', function(event) {
+ var nodeObject = event.currentTarget,
+ locked = event.currentTarget.hasClass('fa-lock');
+ lockMap(lockButton, lockLayer, latValue, longValue, locked);
+ });
}
});
});
-function lockMap(lockButton, lockLayer, latitude, longitude, locked){
- if(locked){
+function lockMap(lockButton, lockLayer, latitude, longitude, locked) {
+ if (locked) {
lockButton.replaceClass('fa-lock', 'fa-unlock');
lockLayer.removeClass('activelayer');
} else {
lockButton.replaceClass('fa-unlock', 'fa-lock');
lockLayer.addClass('activelayer');
}
- if(latitude!="" && longitude!=""){
+ if (latitude != "" && longitude != "") {
mapItMap.moveMap(longitude, latitude, mapItMap.getCurrentZoom());
- //updateCoords(latitude, longitude, mapItMap.getCurrentZoom(), false);
var editableZoom = AUI().one("#"+portletNamespace+"zoom");
- if(editableZoom!=null){
+ if (editableZoom != null) {
editableZoom.val(mapItMap.getCurrentZoom());
}
}
@@ -351,16 +217,14 @@ Liferay.on('geolocation-ready',function(event) {
longitude = event.longitude,
full = event.fullAddress;
- if(latitude!="" && longitude!=""){
+ if (latitude != "" && longitude != "") {
var zoom = mapItMap.getCurrentZoom() > 8 ? mapItMap.getCurrentZoom() : 12;
- console.log(full);
- if(full){
- //zoom = 14;
+ if (full) {
var markerStyle = {
- graphicHeight: 29,
- graphicWidth: 22,
- externalGraphic: '<%= getServletContext().getContextPath() + "/images/marker.png" %>'
- };
+ graphicHeight: 29,
+ graphicWidth: 22,
+ externalGraphic: '<%= getServletContext().getContextPath() + "/images/marker.png" %>'
+ };
var layerName = '
';
var newlonLat = new OpenLayers.LonLat(longitude, latitude).transform( new OpenLayers.Projection("EPSG:3857") , new OpenLayers.Projection("EPSG:4326"));
@@ -373,155 +237,118 @@ Liferay.on('geolocation-ready',function(event) {
mapItMap.addLayerPoints(layerName, search_point, true, {});
updateCoords(latitude, longitude, zoom, false);
}
-
mapItMap.moveMap(longitude, latitude, zoom);
-
}
});
});
function updateCoords(lat_coord, long_coord, zoom_coord, fullUpdate, noTransform){
AUI().use('aui-io-request', function(A) {
- var latitude = AUI().one("#"+portletNamespace+"lat"),
- longitude = AUI().one("#"+portletNamespace+"long"),
- editableLatitude = AUI().one("#"+portletNamespace+"lat_hidden"),
- editableLongitude = AUI().one("#"+portletNamespace+"long_hidden"),
- editableZoom = AUI().one("#"+portletNamespace+"zoom"),
- city = AUI().one("#"+portletNamespace+"comune");
- address = AUI().one("#"+portletNamespace+"via");
+ var latitude = AUI().one("#" + portletNamespace + "lat"),
+ longitude = AUI().one("#" + portletNamespace + "long"),
+ editableLatitude = AUI().one("#" + portletNamespace + "lat_hidden"),
+ editableLongitude = AUI().one("#" + portletNamespace + "long_hidden"),
+ editableZoom = AUI().one("#" + portletNamespace + "zoom"),
+ city = AUI().one("#" + portletNamespace + "comune");
+ address = AUI().one("#" + portletNamespace + "via");
var newlonLat;
- if(fullUpdate){
- if(!noTransform)
+ if (fullUpdate) {
+ if (!noTransform) {
newlonLat = new OpenLayers.LonLat(long_coord, lat_coord).transform( new OpenLayers.Projection("EPSG:3857") , new OpenLayers.Projection("EPSG:4326"));
- else
+ } else {
newlonLat = new OpenLayers.LonLat(long_coord, lat_coord);
+ }
var markerStyle = {
- graphicHeight: 29,
- graphicWidth: 22,
- externalGraphic: '<%= getServletContext().getContextPath() + "/images/marker.png" %>'
- };
- var layerName = '
';
-
- var search_point = [ {
- lat: newlonLat.lat,
- lon: newlonLat.lon,
- style: markerStyle
- }];
- mapItMap.addLayerPoints(layerName, search_point, true, {});
+ graphicHeight: 29,
+ graphicWidth: 22,
+ externalGraphic: '<%= getServletContext().getContextPath() + "/images/marker.png" %>'
+ };
+ var layerName = '
';
- }else{
- newlonLat=new OpenLayers.LonLat(long_coord, lat_coord);
+ var search_point = [ {
+ lat: newlonLat.lat,
+ lon: newlonLat.lon,
+ style: markerStyle
+ }];
+ mapItMap.addLayerPoints(layerName, search_point, true, {});
+ } else {
+ newlonLat = new OpenLayers.LonLat(long_coord, lat_coord);
}
-
+
var url = "https://nominatim.openstreetmap.org/reverse?format=json&zoom=18&addressdetails=1"
+"&lat="+(newlonLat.lat)+"&lon="+(newlonLat.lon);
- if(fullUpdate){
+ if (fullUpdate) {
A.io.request(url, {
- dataType: 'json',
- on: {
- success: function() {
+ dataType: 'json',
+ on: {
+ success: function() {
+ var response = this.get('responseData'),
+ town = response.address.city != undefined
+ ? response.address.city
+ : (response.address.town != undefined
+ ? response.address.town
+ : response.address.village)
+ .replaceAll(' ', '-')
+ .toLowerCase();
- var response = this.get('responseData'),
- town = response.address.city!=undefined ? response.address.city : (response.address.town!=undefined ? response.address.town : response.address.village);
-
- if(city.val().toLowerCase().split(" ").join("_") != town.toLowerCase().split(" ").join("_")){
- alert("Attenzione!\nHai selezionato un punto esterno al comune di riferimento...");
- address.val("");
- } else {
-
- var fullAddress = '';
- if(response.address.road != undefined)
- fullAddress += response.address.road;
- else if(response.address.pedestrian != undefined)
- fullAddress += response.address.pedestrian;
-
- if(fullAddress != '')
- fullAddress += (response.address.house_number != undefined ? " " + response.address.house_number : "");
-
- address.val(fullAddress);
-
+ if (verifyComune && city.val().toLowerCase().split(" ").join("-") != town) {
+ alert("Attenzione!\nHai selezionato un punto esterno al comune di riferimento...");
+ address.val("");
+ } else {
+ var fullAddress = '';
+ if(response.address.road != undefined) {
+ fullAddress += response.address.road;
+ } else if (response.address.pedestrian != undefined) {
+ fullAddress += response.address.pedestrian;
+ }
+ if (fullAddress != '') {
+ fullAddress += (response.address.house_number != undefined ? " " + response.address.house_number : "");
+ }
+ address.val(fullAddress);
+ if (!verifyComune) {
+ var provincia = response.address.county.replaceAll(' ', '-').toLowerCase();
+ var province = window[portletNamespace + 'province'];
+ if (undefined != province[provincia]) {
+ AUI().use('event', 'node-event-simulate', function(A) {
+ A.one('#' + portletNamespace + 'provincia')
+ .set('value', province[provincia])
+ .simulate('change');
+ window[portletNamespace + 'comuneSelezionato'] = town.replaceAll(' ', '-').toLowerCase();
+ });
+ }
+ }
+ }
+ }
}
- }
- }
});
}
-
- /*editableLatitude.val(lat_coord);
- latitude.val(lat_coord);
- editableLongitude.val(long_coord);
- editableZoom.val(zoom_coord);
- longitude.val(long_coord);*/
editableLatitude.val(newlonLat.lat);
- latitude.val(newlonLat.lat);
- editableLongitude.val(newlonLat.lon);
- editableZoom.val(zoom_coord);
- longitude.val(newlonLat.lon);
-
+ latitude.val(newlonLat.lat);
+ editableLongitude.val(newlonLat.lon);
+ longitude.val(newlonLat.lon);
+ editableZoom.val(zoom_coord);
});
}
window.alert = function(msg){
- $('.customAlertMessage').text(msg);
- $('.customAlert').css('animation', 'fadeIn 0.3s linear');
- $('.customAlert').css('display', 'inline');
- setTimeout(function(){
- $('.customAlert').css('animation', 'none');
- }, 100);
+ $('.customAlertMessage').text(msg);
+ $('.customAlert').css('animation', 'fadeIn 0.3s linear');
+ $('.customAlert').css('display', 'inline');
+ setTimeout(function(){
+ $('.customAlert').css('animation', 'none');
+ }, 100);
};
-$(function(){
- $('.confirmButton').click(function(){
- $('.customAlert').css('animation', 'fadeOut 0.3s linear');
- setTimeout(function(){
- $('.customAlert').css('animation', 'none');
- $('.customAlert').css('display', 'none');
- }, 100);
- });
-});
-
-/*
-var globalGeolocationParams;
-window.confirm = function(msg, callback){
- $('.message').text(msg);
- $('.customConfirm').css('animation', 'fadeIn 0.3s linear');
- $('.customConfirm').css('display', 'inline');
- setTimeout(function(){
- $('.customConfirm').css('animation', 'none');
- }, 100);
-
- globalGeolocationParams = callback;
-};
-
-$(function(){
- $('.confirmButton').click(function(){
- $('.customAlert').css('animation', 'fadeOut 0.3s linear');
- setTimeout(function(){
- $('.customAlert').css('animation', 'none');
+$(function() {
+ $('.confirmButton').click(function() {
+ $('.customAlert').css('animation', 'fadeOut 0.3s linear');
+ setTimeout(function() {
+ $('.customAlert').css('animation', 'none');
$('.customAlert').css('display', 'none');
- }, 100);
- });
- $('.agreeButton').click(function(){
- console.log('agree');
- $('.customConfirm').css('animation', 'fadeOut 0.3s linear');
- setTimeout(function(){
- $('.customConfirm').css('animation', 'none');
- $('.customConfirm').css('display', 'none');
- }, 100);
-
- updateCoords(globalGeolocationParams.x, globalGeolocationParams.y, globalGeolocationParams.z);
-
- });
- $('.refuseButton').click(function(){
- console.log('refused');
- $('.customConfirm').css('animation', 'fadeOut 0.3s linear');
- setTimeout(function(){
- $('.customConfirm').css('animation', 'none');
- $('.customConfirm').css('display', 'none');
- }, 100);
- return;
+ }, 100);
});
-}); */
+});
\ No newline at end of file
diff --git a/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/images/marker.png b/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/images/marker.png
index cc9a4211..2f3946a6 100644
Binary files a/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/images/marker.png and b/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/images/marker.png differ
diff --git a/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/images/result.png b/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/images/result.png
new file mode 100644
index 00000000..4101f2bd
Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/docroot/images/result.png differ
diff --git a/liferay-plugins-sdk-6.2/shared/portos-bo-shared/src/it/tref/liferay/portos/bo/shared/util/ConfigurazioneConstants.java b/liferay-plugins-sdk-6.2/shared/portos-bo-shared/src/it/tref/liferay/portos/bo/shared/util/ConfigurazioneConstants.java
index 29127700..58553aed 100644
--- a/liferay-plugins-sdk-6.2/shared/portos-bo-shared/src/it/tref/liferay/portos/bo/shared/util/ConfigurazioneConstants.java
+++ b/liferay-plugins-sdk-6.2/shared/portos-bo-shared/src/it/tref/liferay/portos/bo/shared/util/ConfigurazioneConstants.java
@@ -25,4 +25,9 @@ public class ConfigurazioneConstants {
// nuove configurazioni
public static final String SCHEDULER_VERSIONING = "conf.geniocivile.scheduler.versioning";
public static final String IMPORTO_BOLLO = "conf.geniocivile.scheduler.iris.importobollo";
-}
\ No newline at end of file
+
+ public static final String MAPPE_URL_IFRAME_FE = "conf.sismica.mappe.iframe.url.fe";
+ public static final String MAPPE_URL_IFRAME_BO = "conf.sismica.mappe.iframe.url.bo";
+ public static final String MAPPE_SHARED_SECRET = "conf.sismica.mappe.secret";
+
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/.classpath b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/.classpath
new file mode 100644
index 00000000..2ac08420
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/.classpath
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/.gitignore b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/.gitignore
new file mode 100644
index 00000000..840e7d31
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/.gitignore
@@ -0,0 +1 @@
+/classes/
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/.project b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/.project
new file mode 100644
index 00000000..3e309bb0
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/.project
@@ -0,0 +1,17 @@
+
+
+ tref-mapit-shared
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/bin/.project b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/bin/.project
new file mode 100644
index 00000000..3e309bb0
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/bin/.project
@@ -0,0 +1,17 @@
+
+
+ tref-mapit-shared
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/build.xml b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/build.xml
new file mode 100644
index 00000000..1c7b3808
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/build.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/constants/Constants.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/constants/Constants.java
new file mode 100644
index 00000000..95997559
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/constants/Constants.java
@@ -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";
+ }
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/constants/DestinationNames.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/constants/DestinationNames.java
new file mode 100644
index 00000000..ac8c1eaa
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/constants/DestinationNames.java
@@ -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";
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/constants/PortletConfiguration.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/constants/PortletConfiguration.java
new file mode 100644
index 00000000..b649462e
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/constants/PortletConfiguration.java
@@ -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";
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/constants/WebKeys.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/constants/WebKeys.java
new file mode 100644
index 00000000..09e0c1aa
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/constants/WebKeys.java
@@ -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";
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/messaging/AssetResolverMessageListener.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/messaging/AssetResolverMessageListener.java
new file mode 100644
index 00000000..446feaaa
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/messaging/AssetResolverMessageListener.java
@@ -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
> _baseModelResolverMap = new ConcurrentHashMap>();
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/plugin/MapItPlugin.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/plugin/MapItPlugin.java
new file mode 100644
index 00000000..a0088aa6
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/plugin/MapItPlugin.java
@@ -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> getMapItPluginActions();
+
+ Set> getMapItPluginEvents();
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/plugin/action/MapItPluginAction.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/plugin/action/MapItPluginAction.java
new file mode 100644
index 00000000..59b91b3f
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/plugin/action/MapItPluginAction.java
@@ -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;
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/plugin/event/MapItPluginEvent.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/plugin/event/MapItPluginEvent.java
new file mode 100644
index 00000000..49be3321
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/plugin/event/MapItPluginEvent.java
@@ -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;
+ }
+ }
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/resolver/BaseModelResolver.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/resolver/BaseModelResolver.java
new file mode 100644
index 00000000..5ae1b909
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/resolver/BaseModelResolver.java
@@ -0,0 +1,7 @@
+package it.tref.liferay.mapit.resolver;
+
+import com.liferay.portal.model.BaseModel;
+
+public interface BaseModelResolver {
+ BaseModel getBaseModel(long paramLong1, long paramLong2);
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/resolver/asset/DLFileEntryResolver.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/resolver/asset/DLFileEntryResolver.java
new file mode 100644
index 00000000..787201a9
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/resolver/asset/DLFileEntryResolver.java
@@ -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 {
+ @Override
+ public BaseModel getBaseModel(long companyId, long classPK) {
+ try {
+ return DLFileEntryLocalServiceUtil.getDLFileEntry(classPK);
+ } catch (PortalException portalException) {
+ return null;
+ } catch (SystemException systemException) {
+ return null;
+ }
+ }
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/resolver/asset/JournalArticleResolver.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/resolver/asset/JournalArticleResolver.java
new file mode 100644
index 00000000..d0d640b8
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/resolver/asset/JournalArticleResolver.java
@@ -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 {
+ @Override
+ public BaseModel 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;
+ }
+ }
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/resolver/asset/WikiPageResolver.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/resolver/asset/WikiPageResolver.java
new file mode 100644
index 00000000..2353a325
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/resolver/asset/WikiPageResolver.java
@@ -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 {
+ @Override
+ public BaseModel 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;
+ }
+ }
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/template/TemplateVariableUtil.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/template/TemplateVariableUtil.java
new file mode 100644
index 00000000..66a51cf2
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/template/TemplateVariableUtil.java
@@ -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 getTemplateVariableGroups(String language) {
+ Map templateVariableGroups = new LinkedHashMap();
+ 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;
+ }
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/AssetUtil.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/AssetUtil.java
new file mode 100644
index 00000000..4e719a0f
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/AssetUtil.java
@@ -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 classNameIds = new ArrayList();
+ List 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 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 listClassNameIds = new ArrayList();
+ 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 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() };
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/ExpandoUtil.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/ExpandoUtil.java
new file mode 100644
index 00000000..76e1aad5
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/ExpandoUtil.java
@@ -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);
+ }
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/MapItUtil.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/MapItUtil.java
new file mode 100644
index 00000000..55822659
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/MapItUtil.java
@@ -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();
+ }
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/MapitHelperUtil.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/MapitHelperUtil.java
new file mode 100644
index 00000000..9909703f
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/MapitHelperUtil.java
@@ -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);
+}
diff --git a/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/SearchUtil.java b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/SearchUtil.java
new file mode 100644
index 00000000..6175da21
--- /dev/null
+++ b/liferay-plugins-sdk-6.2/shared/tref-mapit-shared/src/it/tref/liferay/mapit/util/SearchUtil.java
@@ -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 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();
+ 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;
+ }
+}