Sfoglia il codice sorgente

aggiunta funzionalità per fix user ID su AOP

feature/fix_soggetti
marcoalderighi 2 anni fa
parent
commit
3e2c74784b
  1. 20
      liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/portlet/AdvancedOperationPortlet.java
  2. 116
      liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/util/AdvancedOperationUtil.java
  3. 27
      liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/html/view.jsp

20
liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/portlet/AdvancedOperationPortlet.java

@ -12,6 +12,7 @@ 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;
@ -192,6 +193,25 @@ public class AdvancedOperationPortlet extends MVCPortlet {
actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId));
}
public void fixUserID(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{
_checkIfUserIsCompanyAdmin(actionRequest);
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L);
IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId);
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);
}
}
actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId));
}
public void ripristinaPraticaConforme(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{
_checkIfUserIsCompanyAdmin(actionRequest);

116
liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/util/AdvancedOperationUtil.java

@ -32,8 +32,8 @@ import java.util.List;
public class AdvancedOperationUtil {
public static final int[] STATUS_ARRAY =
{WorkflowConstants.STATUS_DRAFT, WorkflowConstants.STATUS_INACTIVE, WorkflowConstants.STATUS_PENDING};
public static final int[] STATUS_ARRAY = { WorkflowConstants.STATUS_DRAFT,
WorkflowConstants.STATUS_INACTIVE, WorkflowConstants.STATUS_PENDING };
public static boolean isNotWorkflowManuallyStarted(IntPratica intPratica) {
switch (intPratica.getStatoPratica()) {
@ -47,12 +47,13 @@ public class AdvancedOperationUtil {
}
public static boolean hasControlloPratica_ProceduraC(IntPratica intPratica) {
if(Constants.PROCEDURA_C.equalsIgnoreCase(intPratica.getTipoProcedura())){
if (Constants.PROCEDURA_C.equalsIgnoreCase(intPratica
.getTipoProcedura())) {
try {
long intPraticaId = intPratica.getIntPraticaId();
for (int i : STATUS_ARRAY) {
List<ControlloPratica> controlloPraticas =
ControlloPraticaLocalServiceUtil.findByIntPraticaId_Status(intPraticaId, i);
List<ControlloPratica> controlloPraticas = ControlloPraticaLocalServiceUtil
.findByIntPraticaId_Status(intPraticaId, i);
if (!controlloPraticas.isEmpty()) {
return true;
}
@ -71,11 +72,14 @@ public class AdvancedOperationUtil {
}
try {
ControlloPratica controlloPratica = null;
List<ControlloPratica> controlloPraticaList =
ControlloPraticaLocalServiceUtil.findByIntPraticaId_Status(intPratica.getIntPraticaId(), intPratica.getStatus());
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())) {
if (Validator.isNull(controlloPratica)
|| cp.getCreateDate().after(
controlloPratica.getCreateDate())) {
controlloPratica = cp;
}
}
@ -84,15 +88,21 @@ public class AdvancedOperationUtil {
} else {
return null;
}
WorkflowInstanceLink workflowInstanceLink = WorkflowInstanceLinkLocalServiceUtil.fetchWorkflowInstanceLink(
controlloPratica.getCompanyId(),controlloPratica.getGroupId(), ControlloPratica.class.getName(),
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);
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);
@ -110,10 +120,13 @@ public class AdvancedOperationUtil {
public static List<DocPratica> getDocPraticaOrfani(long intPraticaId) {
List<DocPratica> docPraticaOrfaniList = new ArrayList<DocPratica>();
try {
List<DocPratica> docPraticaList = DocPraticaLocalServiceUtil.findByIntPratica(intPraticaId);
List<DocPratica> docPraticaList = DocPraticaLocalServiceUtil
.findByIntPratica(intPraticaId);
for (DocPratica docPratica : docPraticaList) {
if(Validator.isNull(DettPraticaLocalServiceUtil.fetchDettPratica(docPratica.getClassPk()))
&& DettPratica.class.getName().equals(docPratica.getClassName())){
if (Validator.isNull(DettPraticaLocalServiceUtil
.fetchDettPratica(docPratica.getClassPk()))
&& DettPratica.class.getName().equals(
docPratica.getClassName())) {
docPraticaOrfaniList.add(docPratica);
}
}
@ -144,12 +157,15 @@ public class AdvancedOperationUtil {
return false;
}
public static String getLavoriInEconomiaBtnLabel(boolean normLavoriInProprioFlag){
return normLavoriInProprioFlag ? "Rimuovi flag normLavoriInProprio" : "Aggiungi flag normLavoriInProprio";
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";
return collaudoStaticoFlag ? "Rimuovi flag collaudoStatico"
: "Aggiungi flag collaudoStatico";
}
public static boolean isStatoPraticaIN(IntPratica intPratica) {
@ -163,7 +179,8 @@ public class AdvancedOperationUtil {
long currentAssignee = 0;
WorkflowTask lastTask = getLastTask(intPratica);
if (Validator.isNotNull(lastTask)) {
if(it.tref.liferay.portos.bo.util.WorkflowConstants.WORKFLOW_TASKNAME_ESITO.equalsIgnoreCase(lastTask.getName())){
if (it.tref.liferay.portos.bo.util.WorkflowConstants.WORKFLOW_TASKNAME_ESITO
.equalsIgnoreCase(lastTask.getName())) {
currentAssignee = lastTask.getAssigneeUserId();
}
}
@ -173,12 +190,15 @@ public class AdvancedOperationUtil {
public static WorkflowTask getLastTask(IntPratica intPratica) {
if (Validator.isNotNull(intPratica)) {
try {
List<ControlloPratica> controlloPraticas = ControlloPraticaLocalServiceUtil.findByIntPratica(intPratica.getIntPraticaId());
List<ControlloPratica> controlloPraticas = ControlloPraticaLocalServiceUtil
.findByIntPratica(intPratica.getIntPraticaId());
if (!controlloPraticas.isEmpty()) {
for (ControlloPratica controlloPratica : controlloPraticas) {
if (controlloPratica.getStatus() == WorkflowConstants.STATUS_PENDING) {
return WorkflowUtil.getLastTask(controlloPratica.getCompanyId(),
controlloPratica.getGroupId(), null, controlloPratica);
return WorkflowUtil.getLastTask(
controlloPratica.getCompanyId(),
controlloPratica.getGroupId(), null,
controlloPratica);
}
}
}
@ -189,17 +209,21 @@ public class AdvancedOperationUtil {
return null;
}
public static boolean evalCurrentAssignee(IntPratica intPratica, User tecnico){
public static boolean evalCurrentAssignee(IntPratica intPratica,
User tecnico) {
WorkflowTask lastTask = getLastTask(intPratica);
if(Validator.isNotNull(lastTask) && lastTask.getName().equalsIgnoreCase("Esito")){
return tecnico.getUserId() != lastTask.getAssigneeUserId() || lastTask.getAssigneeUserId() == 0;
if (Validator.isNotNull(lastTask)
&& lastTask.getName().equalsIgnoreCase("Esito")) {
return tecnico.getUserId() != lastTask.getAssigneeUserId()
|| lastTask.getAssigneeUserId() == 0;
}
return false;
}
public static boolean isWorkFlowCompleted(ControlloPratica controlloPratica) {
try {
WorkflowTask task = WorkflowUtil.getLastTask(controlloPratica.getCompanyId(),
WorkflowTask task = WorkflowUtil.getLastTask(
controlloPratica.getCompanyId(),
controlloPratica.getGroupId(), null, controlloPratica);
return task.isCompleted();
} catch (PortalException | SystemException e) {
@ -208,13 +232,18 @@ public class AdvancedOperationUtil {
return false;
}
public static List<DettPratica> fetchDettPraticaListWithInizioLavori(IntPratica intPratica){
public static List<DettPratica> fetchDettPraticaListWithInizioLavori(
IntPratica intPratica) {
if (Validator.isNotNull(intPratica)) {
DynamicQuery dynamicQuery = DettPraticaLocalServiceUtil.dynamicQuery();
dynamicQuery.add(RestrictionsFactoryUtil.eq("intPraticaId", intPratica.getIntPraticaId()));
dynamicQuery.add(RestrictionsFactoryUtil.isNotNull("dataInizioLavoriOpera"));
DynamicQuery dynamicQuery = DettPraticaLocalServiceUtil
.dynamicQuery();
dynamicQuery.add(RestrictionsFactoryUtil.eq("intPraticaId",
intPratica.getIntPraticaId()));
dynamicQuery.add(RestrictionsFactoryUtil
.isNotNull("dataInizioLavoriOpera"));
try {
return (List<DettPratica>) DettPraticaLocalServiceUtil.dynamicQuery(dynamicQuery);
return (List<DettPratica>) DettPraticaLocalServiceUtil
.dynamicQuery(dynamicQuery);
} catch (SystemException e) {
_log.error(e, e);
return null;
@ -226,16 +255,34 @@ public class AdvancedOperationUtil {
public static Date fetchDataInizioLavoriOpera(IntPratica intPratica) {
List<DettPratica> dettPraticaListWithInizioLavori = fetchDettPraticaListWithInizioLavori(intPratica);
if (!dettPraticaListWithInizioLavori.isEmpty()) {
return dettPraticaListWithInizioLavori.get(0).getDataInizioLavoriOpera();
return dettPraticaListWithInizioLavori.get(0)
.getDataInizioLavoriOpera();
}
return null;
}
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;
}
private static List<DettPratica> _getDettPraticaList(long intPraticaId) {
List<DettPratica> dettPraticaList = new ArrayList<DettPratica>();
try {
dettPraticaList = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId);
dettPraticaList = DettPraticaLocalServiceUtil
.findByIntPraticaId(intPraticaId);
} catch (SystemException e) {
_log.error(e, e);
}
@ -243,5 +290,6 @@ public class AdvancedOperationUtil {
return dettPraticaList;
}
private static final Log _log = LogFactoryUtil.getLog(AdvancedOperationUtil.class);
private static final Log _log = LogFactoryUtil
.getLog(AdvancedOperationUtil.class);
}

27
liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/html/view.jsp

@ -245,6 +245,30 @@
</div>
<% } %>
<% if(AdvancedOperationUtil.hasDettPratica(intPraticaId)
&& !AdvancedOperationUtil.evalInt_Dett_UserID(intPratica)){
%>
<div style="margin-right: 50px;">
<liferay-portlet:actionURL
name="fixUserID"
var="fixUserIDURL" >
<liferay-portlet:param name="intPraticaId" value="<%= String.valueOf(intPraticaId) %>"/>
<liferay-portlet:param name="mvcPath" value="/html/view.jsp"/>
</liferay-portlet:actionURL>
<%
String functionFixUserID = "javascript:"+renderResponse.getNamespace()+"openConfirmationDialog('"+renderResponse.getNamespace()+"fixUserID','Sei sicuro di voler cambiare lo User dell'ultimo dettPratica?')";
%>
<aui:form action="<%= fixUserIDURL %>" method="post" name="fixCollaudoStatico">
<aui:button
name="fixUserIDBtn"
cssClass="btn-primary"
type="button"
value="FIXA User ID"
onClick='<%= functionFixUserID %>'/>
</aui:form>
</div>
<% } %>
<% if(AdvancedOperationUtil.isStatoPraticaIN(intPratica)){ %>
<div style="margin-right: 50px;">
<liferay-portlet:actionURL
@ -639,7 +663,8 @@
}
%>
</aui:row>
<c:if test="<%= ControlloPraticaLocalServiceUtil.countByIntPratica(intPraticaId) > 1 %>">
<c:if test="<%= !ControlloPraticaLocalServiceUtil.findByIntPratica(intPraticaId).isEmpty() &&
ControlloPraticaLocalServiceUtil.findByIntPratica(intPraticaId).size() > 1 %>">
<aui:row id="controlloPraticaDiv">
<div class="module-group">
<liferay-ui:panel title="CONTROLLO PRATICA" collapsible="false" extended="true">

Caricamento…
Annulla
Salva