Sfoglia il codice sorgente

aggiunte funzionalità per gestione attività e reindex pratica

develop
marcoalderighi 2 anni fa
parent
commit
c19621fa17
  1. 36
      liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/portlet/AdvancedOperationPortlet.java
  2. 75
      liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/util/AdvancedOperationUtil.java
  3. 106
      liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/html/view.jsp

36
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 { public class AdvancedOperationPortlet extends MVCPortlet {
private static final Log _log = LogFactoryUtil.getLog(AdvancedOperationPortlet.class); 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); _checkIfUserIsCompanyAdmin(actionRequest);
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L);
Date dataInizioLavoriOpera = ParamUtil.getDate(actionRequest, "dataInizioLavoriOperaInput", Date dataInizioLavoriOpera = ParamUtil.getDate(actionRequest, "dataInizioLavoriOperaInput",
DateFormatFactoryUtil.getSimpleDateFormat("yyyy-MM-dd"), null); DateFormatFactoryUtil.getSimpleDateFormat("yyyy-MM-dd"), null);
IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId);
List<DettPratica> dettPraticaListWithInizioLavori = AdvancedOperationUtil.fetchDettPraticaListWithInizioLavori(intPratica); List<DettPratica> dettPraticaListWithInizioLavori = AdvancedOperationUtil.fetchDettPraticaListWithInizioLavori(intPratica);
for(DettPratica dettPratica : dettPraticaListWithInizioLavori){ for(DettPratica dettPratica : dettPraticaListWithInizioLavori){
dettPratica.setDataInizioLavoriOpera(dataInizioLavoriOpera); dettPratica.setDataInizioLavoriOpera(dataInizioLavoriOpera);
@ -68,14 +80,14 @@ public class AdvancedOperationPortlet extends MVCPortlet {
} }
actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId)); actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId));
} }
public void fixCollaudoStatico(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ public void fixCollaudoStatico(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{
_checkIfUserIsCompanyAdmin(actionRequest); _checkIfUserIsCompanyAdmin(actionRequest);
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L);
boolean collaudoStaticoFlag = ParamUtil.getBoolean(actionRequest, "collaudoStaticoFlag"); boolean collaudoStaticoFlag = ParamUtil.getBoolean(actionRequest, "collaudoStaticoFlag");
List<DettPratica> dettPraticaList = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId); List<DettPratica> dettPraticaList = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId);
for(DettPratica dettPratica : dettPraticaList){ for(DettPratica dettPratica : dettPraticaList){
if(dettPratica.getCollaudoStatico() == collaudoStaticoFlag){ if(dettPratica.getCollaudoStatico() == collaudoStaticoFlag){
@ -88,7 +100,7 @@ public class AdvancedOperationPortlet extends MVCPortlet {
} }
public void fixStatusPratica(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ public void fixStatusPratica(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{
_checkIfUserIsCompanyAdmin(actionRequest); _checkIfUserIsCompanyAdmin(actionRequest);
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L);
@ -126,7 +138,7 @@ public class AdvancedOperationPortlet extends MVCPortlet {
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L);
IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId);
if(WorkflowConstants.STATUS_INCOMPLETE == intPratica.getStatus()){ if(WorkflowConstants.STATUS_INCOMPLETE == intPratica.getStatus()){
_ripristinaPratica(intPratica, WorkflowConstants.STATUS_APPROVED); _ripristinaPratica(intPratica, WorkflowConstants.STATUS_APPROVED);
} else { } else {
@ -169,7 +181,7 @@ public class AdvancedOperationPortlet extends MVCPortlet {
PortalUtil.copyRequestParameters(actionRequest, actionResponse); PortalUtil.copyRequestParameters(actionRequest, actionResponse);
} }
} }
private void _checkIfUserIsCompanyAdmin(ActionRequest actionRequest) throws Exception{ private void _checkIfUserIsCompanyAdmin(ActionRequest actionRequest) throws Exception{
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
if(!PortalUtil.isCompanyAdmin(themeDisplay.getUser())){ if(!PortalUtil.isCompanyAdmin(themeDisplay.getUser())){
@ -177,11 +189,11 @@ public class AdvancedOperationPortlet extends MVCPortlet {
throw new Exception("Action permitted to CompanyAdmins only"); throw new Exception("Action permitted to CompanyAdmins only");
} }
} }
private void _ripristinaPratica(IntPratica intPratica, int status) throws PortalException, SystemException{ private void _ripristinaPratica(IntPratica intPratica, int status) throws PortalException, SystemException{
long docPraticaAnnullamentoId = intPratica.getDocPraticaAnnullamentoId(); long docPraticaAnnullamentoId = intPratica.getDocPraticaAnnullamentoId();
IntPraticaLocalServiceUtil.deleteFileAnnullamento(docPraticaAnnullamentoId); IntPraticaLocalServiceUtil.deleteFileAnnullamento(docPraticaAnnullamentoId);
IntPraticaLocalServiceUtil.updateStatus(intPratica.getIntPraticaId(), status); IntPraticaLocalServiceUtil.updateStatus(intPratica.getIntPraticaId(), status);
} }
} }

75
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; package it.nextmind.liferay.portos.advanced.operation.util;
import com.liferay.portal.kernel.dao.orm.DynamicQuery; 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.dao.orm.RestrictionsFactoryUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.workflow.WorkflowConstants; 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.DettPratica;
import it.tref.liferay.portos.bo.model.DocPratica; import it.tref.liferay.portos.bo.model.DocPratica;
import it.tref.liferay.portos.bo.model.IntPratica; 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.DettPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil;
@ -19,16 +27,49 @@ import java.util.Date;
import java.util.List; import java.util.List;
public class AdvancedOperationUtil { public class AdvancedOperationUtil {
public static List<WorkflowTask> getListaTask(IntPratica intPratica) {
if(Validator.isNull(intPratica)){
return null;
}
try {
ControlloPratica controlloPratica = null;
List<ControlloPratica> 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<WorkflowTask> 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){ public static boolean isPraticaAnnullata(IntPratica intPratica){
if(Validator.isNotNull(intPratica)){ if(Validator.isNotNull(intPratica)){
return WorkflowConstants.STATUS_INACTIVE == intPratica.getStatus(); return WorkflowConstants.STATUS_INACTIVE == intPratica.getStatus();
} }
return false; return false;
} }
public static List<DocPratica> getDocPraticaOrfani(long intPraticaId){ public static List<DocPratica> getDocPraticaOrfani(long intPraticaId){
List<DocPratica> docPraticaOrfaniList = new ArrayList<DocPratica>(); List<DocPratica> docPraticaOrfaniList = new ArrayList<DocPratica>();
try { try {
@ -44,12 +85,12 @@ public class AdvancedOperationUtil {
} }
return docPraticaOrfaniList; return docPraticaOrfaniList;
} }
public static boolean hasDettPratica(long intPraticaId){ public static boolean hasDettPratica(long intPraticaId){
return !_getDettPraticaList(intPraticaId).isEmpty(); return !_getDettPraticaList(intPraticaId).isEmpty();
} }
public static boolean getNormLavoriInProprioFlag(long intPraticaId){ public static boolean getNormLavoriInProprioFlag(long intPraticaId){
List<DettPratica> dettPraticaList = _getDettPraticaList(intPraticaId); List<DettPratica> dettPraticaList = _getDettPraticaList(intPraticaId);
if(!dettPraticaList.isEmpty()){ if(!dettPraticaList.isEmpty()){
@ -57,7 +98,7 @@ public class AdvancedOperationUtil {
} }
return false; return false;
} }
public static boolean getCollaudoStaticoFlag(long intPraticaId){ public static boolean getCollaudoStaticoFlag(long intPraticaId){
List<DettPratica> dettPraticaList = _getDettPraticaList(intPraticaId); List<DettPratica> dettPraticaList = _getDettPraticaList(intPraticaId);
if(!dettPraticaList.isEmpty()){ if(!dettPraticaList.isEmpty()){
@ -65,22 +106,22 @@ public class AdvancedOperationUtil {
} }
return false; return false;
} }
public static String getLavoriInEconomiaBtnLabel(boolean normLavoriInProprioFlag){ public static String getLavoriInEconomiaBtnLabel(boolean normLavoriInProprioFlag){
return normLavoriInProprioFlag ? "Rimuovi flag normLavoriInProprio" : "Aggiungi flag normLavoriInProprio"; return normLavoriInProprioFlag ? "Rimuovi flag normLavoriInProprio" : "Aggiungi flag normLavoriInProprio";
} }
public static String getCollaudoStaticoBtnLabel(boolean collaudoStaticoFlag){ public static String getCollaudoStaticoBtnLabel(boolean collaudoStaticoFlag){
return collaudoStaticoFlag ? "Rimuovi flag collaudoStatico" : "Aggiungi flag collaudoStatico"; return collaudoStaticoFlag ? "Rimuovi flag collaudoStatico" : "Aggiungi flag collaudoStatico";
} }
public static boolean isStatoPraticaIN(IntPratica intPratica){ public static boolean isStatoPraticaIN(IntPratica intPratica){
if(Validator.isNotNull(intPratica)){ if(Validator.isNotNull(intPratica)){
return "IN".equals(intPratica.getStatoPratica()); return "IN".equals(intPratica.getStatoPratica());
} }
return false; return false;
} }
public static List<DettPratica> fetchDettPraticaListWithInizioLavori(IntPratica intPratica){ public static List<DettPratica> fetchDettPraticaListWithInizioLavori(IntPratica intPratica){
if(Validator.isNotNull(intPratica)){ if(Validator.isNotNull(intPratica)){
DynamicQuery dynamicQuery = DettPraticaLocalServiceUtil.dynamicQuery(); DynamicQuery dynamicQuery = DettPraticaLocalServiceUtil.dynamicQuery();
@ -95,7 +136,7 @@ public class AdvancedOperationUtil {
} }
return null; return null;
} }
public static Date fetchDataInizioLavoriOpera(IntPratica intPratica){ public static Date fetchDataInizioLavoriOpera(IntPratica intPratica){
List<DettPratica> dettPraticaListWithInizioLavori = fetchDettPraticaListWithInizioLavori(intPratica); List<DettPratica> dettPraticaListWithInizioLavori = fetchDettPraticaListWithInizioLavori(intPratica);
if(!dettPraticaListWithInizioLavori.isEmpty()){ if(!dettPraticaListWithInizioLavori.isEmpty()){
@ -103,18 +144,18 @@ public class AdvancedOperationUtil {
} }
return null; return null;
} }
private static List<DettPratica> _getDettPraticaList(long intPraticaId){ private static List<DettPratica> _getDettPraticaList(long intPraticaId){
List<DettPratica> dettPraticaList = new ArrayList<DettPratica>(); List<DettPratica> dettPraticaList = new ArrayList<DettPratica>();
try { try {
dettPraticaList = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId); dettPraticaList = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId);
} catch (SystemException e) { } catch (SystemException e) {
_log.error(e,e); _log.error(e,e);
} }
return dettPraticaList; return dettPraticaList;
} }
private static final Log _log = LogFactoryUtil.getLog(AdvancedOperationUtil.class); private static final Log _log = LogFactoryUtil.getLog(AdvancedOperationUtil.class);
} }

106
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.service.DettPraticaLocalServiceUtil"%>
<%@page import="it.tref.liferay.portos.bo.model.DettPratica"%> <%@page import="it.tref.liferay.portos.bo.model.DettPratica"%>
<%@page import="it.tref.liferay.portos.bo.util.SoggettiUtil"%> <%@page import="it.tref.liferay.portos.bo.util.SoggettiUtil"%>
@ -273,6 +290,31 @@
</aui:row> </aui:row>
</liferay-ui:panel> </liferay-ui:panel>
</div> </div>
<div class="module-group">
<liferay-ui:panel title="REINDICIZZAZIONE" extended="true" collapsible="false">
<aui:row>
<liferay-portlet:actionURL
name="reindexPratica"
var="reindexPraticaURL" >
<liferay-portlet:param name="intPraticaId" value="<%= String.valueOf(intPraticaId) %>"/>
<liferay-portlet:param name="mvcPath" value="/html/view.jsp"/>
</liferay-portlet:actionURL>
<%
String functionReindex = "javascript:"+renderResponse.getNamespace()+"openConfirmationDialog('"+renderResponse.getNamespace()+"reindexPratica','Sei sicuro di voler reindicizzare questa pratica?')";
%>
<aui:form action="<%= reindexPraticaURL %>" method="post" name="reindexPratica">
<aui:button
type="button"
cssClass="btn-primary"
name="reindexPraticaBtn"
onClick='<%= functionReindex %>'
value="Reindicizza Pratica"
>
</aui:button>
</aui:form>
</aui:row>
</liferay-ui:panel>
</div>
<div class="module-group"> <div class="module-group">
<liferay-ui:panel title="IMPERSONAMENTO" extended="true" collapsible="false"> <liferay-ui:panel title="IMPERSONAMENTO" extended="true" collapsible="false">
<aui:row> <aui:row>
@ -300,6 +342,7 @@
<liferay-ui:icon <liferay-ui:icon
id="impersonaSoggettiBtn" id="impersonaSoggettiBtn"
image="team_icon" image="team_icon"
message="Visualizza Soggetti"
target="_blank" target="_blank"
> >
</liferay-ui:icon> </liferay-ui:icon>
@ -348,6 +391,69 @@
<% } %> <% } %>
</liferay-ui:panel> </liferay-ui:panel>
</div> </div>
<div class="module-group">
<%
List<WorkflowTask> listaTask = AdvancedOperationUtil.getListaTask(intPratica);
if(Validator.isNotNull(listaTask)){
%>
<liferay-ui:panel title="GESTIONE ATTIVITÀ" extended="true" collapsible="false">
<aui:row>
<div style="display:flex;">
<div style=" margin-right: 15px;">
<p><b>Gestisci ultima attività:</b></p>
</div>
<%
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);
%>
<div title='<%= LanguageUtil.get(pageContext,"workflow-action-manage") %>' class="tooltip-info">
<liferay-ui:icon
useDialog="true"
image="action_right"
message="Gestisci Attività"
url='<%= workflowTaskURL.toString() + "&controlPanelCategory=my" %>'
/>
</div>
</div>
</aui:row>
<%
if(intPratica.getStatusByUserId() != 0L ){
User tecnico = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId());
if (Validator.isNotNull(tecnico)) {
%>
<aui:row>
<div style="display:flex;">
<liferay-security:doAsURL
doAsUserId="<%= tecnico.getUserId() %>"
var="impersonateIstruttoreURL">
</liferay-security:doAsURL>
<div style=" margin-right: 15px;">
<p><b>Impersona Istruttore:</b></p>
</div>
<liferay-ui:icon
image="impersonate_user"
target="_blank"
message="Impersona Istruttore"
url="<%= impersonateIstruttoreURL %>">
</liferay-ui:icon>
</div>
</aui:row>
<%
}
}
%>
</liferay-ui:panel>
<%
}
%>
</div>
</aui:row> </aui:row>
<aui:row id="docPraticaDiv"> <aui:row id="docPraticaDiv">
<div class="module-group"> <div class="module-group">

Caricamento…
Annulla
Salva