From 77fc41e292646c3450b84a20ee8f13034455527c Mon Sep 17 00:00:00 2001 From: marcoalderighi Date: Wed, 10 May 2023 17:59:10 +0200 Subject: [PATCH] =?UTF-8?q?fix=20funzionalit=C3=A0=20per=20cambio=20assegn?= =?UTF-8?q?atario=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../portlet/AdvancedOperationPortlet.java | 15 +++++++-------- .../operation/util/AdvancedOperationUtil.java | 11 +++++++---- .../docroot/html/view.jsp | 11 +++++++++-- 3 files changed, 23 insertions(+), 14 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 462b610a..1b359ed5 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 @@ -174,20 +174,19 @@ public class AdvancedOperationPortlet extends MVCPortlet { public void cambiaIstruttore(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); - _log.info("== cambiaIstruttore == dentro"); long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); long istruttoreId = ParamUtil.getLong(actionRequest, "istruttoreId", -1L); IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); WorkflowTask lastTask = AdvancedOperationUtil.getLastTask(intPratica); if (lastTask != null && lastTask.getName().equalsIgnoreCase("Esito")) { - _log.info("== cambiaIstruttore == lastTask รจ esito"); List controlloPraticas = ControlloPraticaLocalServiceUtil.findByIntPratica(intPratica.getIntPraticaId()); - if(!controlloPraticas.isEmpty() && Validator.isNotNull(controlloPraticas.get(0))){ - _log.info("== cambiaIstruttore == controlloPratica trovato"); - _log.info("== cambiaIstruttore == istruttoreId: "+istruttoreId); - ControlloPratica controlloPratica = controlloPraticas.get(0); - WorkflowUtil.assegnaUltimoTask(intPratica.getCompanyId(), intPratica.getGroupId(), - istruttoreId, themeDisplay.getUserId(), controlloPratica); + if(!controlloPraticas.isEmpty()){ + for(ControlloPratica controlloPratica : controlloPraticas){ + if(controlloPratica.getStatus() == WorkflowConstants.STATUS_PENDING){ + WorkflowUtil.assegnaUltimoTask(intPratica.getCompanyId(), intPratica.getGroupId(), + istruttoreId, themeDisplay.getUserId(), controlloPratica); + } + } } } actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId)); 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 61699711..bc6e0f3c 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 @@ -174,10 +174,13 @@ public class AdvancedOperationUtil { if(Validator.isNotNull(intPratica)){ try { List controlloPraticas = ControlloPraticaLocalServiceUtil.findByIntPratica(intPratica.getIntPraticaId()); - if(!controlloPraticas.isEmpty() && Validator.isNotNull(controlloPraticas.get(0))){ - ControlloPratica controlloPratica = controlloPraticas.get(0); - return WorkflowUtil.getLastTask(controlloPratica.getCompanyId(), - controlloPratica.getGroupId(), null, controlloPratica); + if(!controlloPraticas.isEmpty()){ + for(ControlloPratica controlloPratica : controlloPraticas){ + if(controlloPratica.getStatus() == WorkflowConstants.STATUS_PENDING){ + return WorkflowUtil.getLastTask(controlloPratica.getCompanyId(), + controlloPratica.getGroupId(), null, controlloPratica); + } + } } }catch (SystemException | PortalException e){ _log.error(e,e); 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 92d411cf..0fbd02bc 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,4 @@ +<%@page import="com.liferay.portal.kernel.util.HtmlUtil"%> <%@page import="com.liferay.portal.service.UserLocalServiceUtil"%> <%@page import="com.liferay.portal.model.User"%> <%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%> @@ -475,7 +476,6 @@ if(intPratica.getStatusByUserId() != 0L ){ User tecnico = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId()); if (Validator.isNotNull(tecnico)) { - %>
@@ -511,7 +511,7 @@ <% - String functionCambiaIstruttore = "javascript:"+renderResponse.getNamespace()+"openConfirmationDialog('"+renderResponse.getNamespace()+"cambiaIstruttore','Sei sicuro di voler riassegnare la pratica all istruttore " + tecnico.getFullName() + " ?')"; + String functionCambiaIstruttore = "javascript:"+renderResponse.getNamespace()+"openConfirmationDialog('"+renderResponse.getNamespace()+"cambiaIstruttore','Sei sicuro di voler riassegnare la pratica all istruttore?')"; %> + +
+ + + +
+
<% } %>