diff --git a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/portlet/AdvancedOperationPortlet.java b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/portlet/AdvancedOperationPortlet.java index 7b647154..87d5e867 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/portlet/AdvancedOperationPortlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/portlet/AdvancedOperationPortlet.java @@ -2,9 +2,6 @@ package it.nextmind.liferay.portos.advanced.operation.portlet; 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.search.Indexer; @@ -15,31 +12,25 @@ import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.util.WebKeys; import com.liferay.portal.kernel.workflow.WorkflowConstants; -import com.liferay.portal.kernel.workflow.WorkflowTask; +import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.theme.ThemeDisplay; import com.liferay.portal.util.PortalUtil; import com.liferay.util.bridges.mvc.MVCPortlet; import it.nextmind.liferay.portos.advanced.operation.util.AdvancedOperationUtil; import it.tref.liferay.portos.bo.model.ControlloPratica; +import it.tref.liferay.portos.bo.model.DettPratica; import it.tref.liferay.portos.bo.model.DocPratica; import it.tref.liferay.portos.bo.model.IntPratica; import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil; +import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil; -import it.tref.liferay.portos.bo.util.WorkflowUtil; -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.RenderRequest; -import javax.portlet.RenderResponse; -import javax.portlet.ResourceRequest; -import javax.portlet.ResourceResponse; public class AdvancedOperationPortlet extends MVCPortlet { private static class Privati { @@ -60,27 +51,47 @@ public class AdvancedOperationPortlet extends MVCPortlet { } - @Override - public void serveResource(ResourceRequest resourceRequest, - ResourceResponse resourceResponse) throws IOException, - PortletException { +// @Override +// public void serveResource(ResourceRequest resourceRequest, +// ResourceResponse resourceResponse) throws IOException, +// PortletException { +// +// String id = resourceRequest.getResourceID(); +// if ("brokenUO".equals(id)) { +// List brokenUOList = AdvancedOperationUtil.getBrokenUOList(); +// +// JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); +// for(IntPratica intPratica : brokenUOList){ +// JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); +// jsonObject.put("id", intPratica.getIntPraticaId()); +// jsonObject.put("UO", intPratica.getUnitaOperativa()); +// jsonObject.put("destUO", AdvancedOperationUtil.getDestinationUO(intPratica)); +// jsonArray.put(jsonObject); +// } +// writeJSON(resourceRequest, resourceResponse, jsonArray); +// } +// } + + public void fixUserID(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ + + Privati.checkIfUserIsCompanyAdmin(actionRequest); + + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); + IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); - String id = resourceRequest.getResourceID(); - if ("brokenUO".equals(id)) { - List brokenUOList = AdvancedOperationUtil.getBrokenUOList(); - - JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); - for(IntPratica intPratica : brokenUOList){ - JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); - jsonObject.put("id", intPratica.getIntPraticaId()); - jsonObject.put("UO", intPratica.getUnitaOperativa()); - jsonObject.put("destUO", AdvancedOperationUtil.getDestinationUO(intPratica)); - jsonArray.put(jsonObject); + if(!AdvancedOperationUtil.evalInt_Dett_UserID(intPratica)){ + DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastEditableByIntPratica(intPratica.getIntPraticaId()); + if(Validator.isNotNull(dettPratica)){ + long userId = intPratica.getUserId(); + dettPratica.setUserId(userId); + dettPratica.setUserName(UserLocalServiceUtil.getUser(userId).getScreenName()); + DettPraticaLocalServiceUtil.updateDettPratica(dettPratica); } - writeJSON(resourceRequest, resourceResponse, jsonArray); } + actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId)); } + public void fixStatusPratica(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ Privati.checkIfUserIsCompanyAdmin(actionRequest); diff --git a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/util/AdvancedOperationUtil.java b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/util/AdvancedOperationUtil.java index 937c74fb..cade4411 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/util/AdvancedOperationUtil.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/util/AdvancedOperationUtil.java @@ -1,6 +1,5 @@ package it.nextmind.liferay.portos.advanced.operation.util; -import com.liferay.portal.kernel.concurrent.ConcurrentHashSet; import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; @@ -15,7 +14,6 @@ import com.liferay.portal.model.WorkflowInstanceLink; import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.service.WorkflowInstanceLinkLocalServiceUtil; -import it.mwg.sismica.bo.shared.util.UnitaOperativeUtil; import it.mwg.sismica.bo.shared.util.UserUtil; import it.tref.liferay.portos.bo.model.ControlloPratica; import it.tref.liferay.portos.bo.model.DettPratica; @@ -114,6 +112,22 @@ public class AdvancedOperationUtil { return !P_.getDettPraticaList(intPraticaId).isEmpty(); } + public static boolean evalInt_Dett_UserID(IntPratica intPratica){ + return getLastDettPraticaUserID(intPratica) == intPratica.getUserId(); + } + + public static long getLastDettPraticaUserID(IntPratica intPratica){ + try { + DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastEditableByIntPratica(intPratica.getIntPraticaId()); + if(Validator.isNotNull(dettPratica)){ + return dettPratica.getUserId(); + } + } catch (SystemException e){ + _log.error(e,e); + } + return -1; + } + // public static boolean getNormLavoriInProprioFlag(long intPraticaId){ // List dettPraticaList = P_.getDettPraticaList(intPraticaId); // if(!dettPraticaList.isEmpty()){ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/html/view.jsp b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/html/view.jsp index fdab5c71..002ec25f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/html/view.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/html/view.jsp @@ -201,6 +201,30 @@ <% } %> + + <% if(AdvancedOperationUtil.hasDettPratica(intPraticaId) + && !AdvancedOperationUtil.evalInt_Dett_UserID(intPratica)){ + %> +
+ + + + + <% + String functionFixUserID = "javascript:"+renderResponse.getNamespace()+"openConfirmationDialog('"+renderResponse.getNamespace()+"fixUserID','Sei sicuro di voler cambiare lo User dell'ultimo dettPratica?')"; + %> + + + +
+ <% } %> <% if(AdvancedOperationUtil.evalUO(intPratica)){ %>