From c19621fa1793ebcaf16caba86fcb48760242dedc Mon Sep 17 00:00:00 2001 From: marcoalderighi Date: Mon, 13 Mar 2023 17:06:39 +0100 Subject: [PATCH] =?UTF-8?q?aggiunte=20funzionalit=C3=A0=20per=20gestione?= =?UTF-8?q?=20attivit=C3=A0=20e=20reindex=20pratica?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../portlet/AdvancedOperationPortlet.java | 36 ++++-- .../operation/util/AdvancedOperationUtil.java | 75 ++++++++++--- .../docroot/html/view.jsp | 106 ++++++++++++++++++ 3 files changed, 188 insertions(+), 29 deletions(-) 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 82f1018c..a3554eb6 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 @@ -32,16 +32,28 @@ import javax.portlet.ActionResponse; public class AdvancedOperationPortlet extends MVCPortlet { private static final Log _log = LogFactoryUtil.getLog(AdvancedOperationPortlet.class); - - public void cambiaDataInizioLavori(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ + + public void reindexPratica(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ + + _checkIfUserIsCompanyAdmin(actionRequest); + ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); + + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0L); + if (intPraticaId != 0L) { + IntPraticaLocalServiceUtil.reIndexFasciolo(intPraticaId, themeDisplay.getCompanyId()); + } + + } + public void cambiaDataInizioLavori(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ + _checkIfUserIsCompanyAdmin(actionRequest); long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); Date dataInizioLavoriOpera = ParamUtil.getDate(actionRequest, "dataInizioLavoriOperaInput", DateFormatFactoryUtil.getSimpleDateFormat("yyyy-MM-dd"), null); IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); - + List dettPraticaListWithInizioLavori = AdvancedOperationUtil.fetchDettPraticaListWithInizioLavori(intPratica); for(DettPratica dettPratica : dettPraticaListWithInizioLavori){ dettPratica.setDataInizioLavoriOpera(dataInizioLavoriOpera); @@ -68,14 +80,14 @@ public class AdvancedOperationPortlet extends MVCPortlet { } actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId)); } - + public void fixCollaudoStatico(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ - + _checkIfUserIsCompanyAdmin(actionRequest); - + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); boolean collaudoStaticoFlag = ParamUtil.getBoolean(actionRequest, "collaudoStaticoFlag"); - + List dettPraticaList = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId); for(DettPratica dettPratica : dettPraticaList){ if(dettPratica.getCollaudoStatico() == collaudoStaticoFlag){ @@ -88,7 +100,7 @@ public class AdvancedOperationPortlet extends MVCPortlet { } public void fixStatusPratica(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ - + _checkIfUserIsCompanyAdmin(actionRequest); long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); @@ -126,7 +138,7 @@ public class AdvancedOperationPortlet extends MVCPortlet { long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); - + if(WorkflowConstants.STATUS_INCOMPLETE == intPratica.getStatus()){ _ripristinaPratica(intPratica, WorkflowConstants.STATUS_APPROVED); } else { @@ -169,7 +181,7 @@ public class AdvancedOperationPortlet extends MVCPortlet { PortalUtil.copyRequestParameters(actionRequest, actionResponse); } } - + private void _checkIfUserIsCompanyAdmin(ActionRequest actionRequest) throws Exception{ ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); if(!PortalUtil.isCompanyAdmin(themeDisplay.getUser())){ @@ -177,11 +189,11 @@ public class AdvancedOperationPortlet extends MVCPortlet { throw new Exception("Action permitted to CompanyAdmins only"); } } - + private void _ripristinaPratica(IntPratica intPratica, int status) throws PortalException, SystemException{ long docPraticaAnnullamentoId = intPratica.getDocPraticaAnnullamentoId(); IntPraticaLocalServiceUtil.deleteFileAnnullamento(docPraticaAnnullamentoId); IntPraticaLocalServiceUtil.updateStatus(intPratica.getIntPraticaId(), status); } - + } 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 4c90c892..244e9548 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,16 +1,24 @@ package it.nextmind.liferay.portos.advanced.operation.util; import com.liferay.portal.kernel.dao.orm.DynamicQuery; +import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil; +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.Validator; import com.liferay.portal.kernel.workflow.WorkflowConstants; +import com.liferay.portal.kernel.workflow.WorkflowTask; +import com.liferay.portal.kernel.workflow.WorkflowTaskManagerUtil; +import com.liferay.portal.model.WorkflowInstanceLink; +import com.liferay.portal.service.WorkflowInstanceLinkLocalServiceUtil; +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; @@ -19,16 +27,49 @@ import java.util.Date; import java.util.List; public class AdvancedOperationUtil { - - - + + public static List getListaTask(IntPratica intPratica) { + if(Validator.isNull(intPratica)){ + return null; + } + try { + ControlloPratica controlloPratica = null; + List controlloPraticaList = + ControlloPraticaLocalServiceUtil.findByIntPraticaId_Status(intPratica.getIntPraticaId(), intPratica.getStatus()); + if(controlloPraticaList.size() > 1){ + for(ControlloPratica cp : controlloPraticaList){ + if(Validator.isNull(controlloPratica) || cp.getCreateDate().after(controlloPratica.getCreateDate())) { + controlloPratica = cp; + } + } + } else if(controlloPraticaList.size() == 1){ + controlloPratica = controlloPraticaList.get(0); + } else { + return null; + } + WorkflowInstanceLink workflowInstanceLink = WorkflowInstanceLinkLocalServiceUtil.fetchWorkflowInstanceLink( + controlloPratica.getCompanyId(),controlloPratica.getGroupId(), ControlloPratica.class.getName(), + controlloPratica.getPrimaryKey()); + List listaTask = null; + if (workflowInstanceLink == null) { + return null; + } else { + return listaTask = WorkflowTaskManagerUtil.getWorkflowTasksByWorkflowInstance(controlloPratica.getCompanyId(), null, + workflowInstanceLink.getWorkflowInstanceId(), false, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); + } + } catch (SystemException | PortalException e){ + _log.error(e,e); + return null; + } + } + public static boolean isPraticaAnnullata(IntPratica intPratica){ if(Validator.isNotNull(intPratica)){ return WorkflowConstants.STATUS_INACTIVE == intPratica.getStatus(); } return false; } - + public static List getDocPraticaOrfani(long intPraticaId){ List docPraticaOrfaniList = new ArrayList(); try { @@ -44,12 +85,12 @@ public class AdvancedOperationUtil { } return docPraticaOrfaniList; } - + public static boolean hasDettPratica(long intPraticaId){ - + return !_getDettPraticaList(intPraticaId).isEmpty(); } - + public static boolean getNormLavoriInProprioFlag(long intPraticaId){ List dettPraticaList = _getDettPraticaList(intPraticaId); if(!dettPraticaList.isEmpty()){ @@ -57,7 +98,7 @@ public class AdvancedOperationUtil { } return false; } - + public static boolean getCollaudoStaticoFlag(long intPraticaId){ List dettPraticaList = _getDettPraticaList(intPraticaId); if(!dettPraticaList.isEmpty()){ @@ -65,22 +106,22 @@ public class AdvancedOperationUtil { } return false; } - + public static String getLavoriInEconomiaBtnLabel(boolean normLavoriInProprioFlag){ return normLavoriInProprioFlag ? "Rimuovi flag normLavoriInProprio" : "Aggiungi flag normLavoriInProprio"; } - + public static String getCollaudoStaticoBtnLabel(boolean collaudoStaticoFlag){ return collaudoStaticoFlag ? "Rimuovi flag collaudoStatico" : "Aggiungi flag collaudoStatico"; } - + public static boolean isStatoPraticaIN(IntPratica intPratica){ if(Validator.isNotNull(intPratica)){ return "IN".equals(intPratica.getStatoPratica()); } return false; } - + public static List fetchDettPraticaListWithInizioLavori(IntPratica intPratica){ if(Validator.isNotNull(intPratica)){ DynamicQuery dynamicQuery = DettPraticaLocalServiceUtil.dynamicQuery(); @@ -95,7 +136,7 @@ public class AdvancedOperationUtil { } return null; } - + public static Date fetchDataInizioLavoriOpera(IntPratica intPratica){ List dettPraticaListWithInizioLavori = fetchDettPraticaListWithInizioLavori(intPratica); if(!dettPraticaListWithInizioLavori.isEmpty()){ @@ -103,18 +144,18 @@ public class AdvancedOperationUtil { } return null; } - + private static List _getDettPraticaList(long intPraticaId){ List dettPraticaList = new ArrayList(); - + try { dettPraticaList = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId); } catch (SystemException e) { _log.error(e,e); } - + return dettPraticaList; } - + private static final Log _log = LogFactoryUtil.getLog(AdvancedOperationUtil.class); } 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 1634057c..12811305 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 @@ -1,3 +1,20 @@ +<%@page import="com.liferay.portal.service.UserLocalServiceUtil"%> +<%@page import="com.liferay.portal.model.User"%> +<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%> +<%@page import="javax.portlet.PortletMode"%> +<%@page import="com.liferay.portal.util.PortletKeys"%> +<%@page import="javax.portlet.PortletRequest"%> +<%@page import="javax.portlet.PortletURL"%> +<%@page import="com.liferay.portal.model.Group"%> +<%@page import="com.liferay.portlet.PortletURLFactoryUtil"%> +<%@page import="com.liferay.portal.service.LayoutLocalServiceUtil"%> +<%@page import="com.liferay.portal.model.GroupConstants"%> +<%@page import="com.liferay.portal.service.GroupLocalServiceUtil"%> +<%@page import="it.tref.liferay.portos.bo.model.ControlloPratica"%> +<%@page import="it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil"%> +<%@page import="com.liferay.portal.service.WorkflowInstanceLinkLocalServiceUtil"%> +<%@page import="com.liferay.portal.model.WorkflowInstanceLink"%> +<%@page import="com.liferay.portal.kernel.workflow.WorkflowTask"%> <%@page import="it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil"%> <%@page import="it.tref.liferay.portos.bo.model.DettPratica"%> <%@page import="it.tref.liferay.portos.bo.util.SoggettiUtil"%> @@ -273,6 +290,31 @@ +
+ + + + + + + <% + String functionReindex = "javascript:"+renderResponse.getNamespace()+"openConfirmationDialog('"+renderResponse.getNamespace()+"reindexPratica','Sei sicuro di voler reindicizzare questa pratica?')"; + %> + + + + + + +
@@ -300,6 +342,7 @@ @@ -348,6 +391,69 @@ <% } %>
+
+ <% + List listaTask = AdvancedOperationUtil.getListaTask(intPratica); + if(Validator.isNotNull(listaTask)){ + %> + + +
+
+

Gestisci ultima attivitą:

+
+ <% + Group controlPanelGroup = GroupLocalServiceUtil.getGroup(company.getCompanyId(), GroupConstants.CONTROL_PANEL); + long controlPanelPlid = LayoutLocalServiceUtil.getDefaultPlid(controlPanelGroup.getGroupId(),true); + PortletURL workflowTaskURL = PortletURLFactoryUtil.create(request, PortletKeys.MY_WORKFLOW_TASKS, + controlPanelPlid, PortletRequest.RENDER_PHASE); + workflowTaskURL.setParameter("struts_action", "/my_workflow_tasks/edit_workflow_task"); + workflowTaskURL.setParameter("workflowTaskId", String.valueOf(listaTask.get(0).getWorkflowTaskId())); + workflowTaskURL.setPortletMode(PortletMode.VIEW); + workflowTaskURL.setWindowState(LiferayWindowState.POP_UP); + %> +
+ +
+
+
+ <% + if(intPratica.getStatusByUserId() != 0L ){ + User tecnico = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId()); + if (Validator.isNotNull(tecnico)) { + + %> + +
+ + +
+

Impersona Istruttore:

+
+ + +
+
+ <% + } + } + %> +
+ <% + } + %> +