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