@ -32,12 +32,12 @@ 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 ( ) ) {
case StatoPraticaConstants . VIDIMATA :
case StatoPraticaConstants . VIDIMATA :
case StatoPraticaConstants . AUTORIZZATA :
case StatoPraticaConstants . AUTORIZZATA :
case StatoPraticaConstants . CONFORME :
case StatoPraticaConstants . CONFORME :
return true ;
return true ;
@ -46,19 +46,20 @@ 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
try {
. getTipoProcedura ( ) ) ) {
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 ;
}
}
}
}
} catch ( SystemException e ) {
} catch ( SystemException e ) {
_log . error ( e , e ) ;
_log . error ( e , e ) ;
return false ;
return false ;
}
}
}
}
@ -66,182 +67,229 @@ public class AdvancedOperationUtil {
}
}
public static List < WorkflowTask > getListaTask ( IntPratica intPratica ) {
public static List < WorkflowTask > getListaTask ( IntPratica intPratica ) {
if ( Validator . isNull ( intPratica ) ) {
if ( Validator . isNull ( intPratica ) ) {
return null ;
return null ;
}
}
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 ( ) ,
if ( controlloPraticaList . size ( ) > 1 ) {
intPratica . getStatus ( ) ) ;
for ( ControlloPratica cp : controlloPraticaList ) {
if ( controlloPraticaList . size ( ) > 1 ) {
if ( Validator . isNull ( controlloPratica ) | | cp . getCreateDate ( ) . after ( controlloPratica . getCreateDate ( ) ) ) {
for ( ControlloPratica cp : controlloPraticaList ) {
if ( Validator . isNull ( controlloPratica )
| | cp . getCreateDate ( ) . after (
controlloPratica . getCreateDate ( ) ) ) {
controlloPratica = cp ;
controlloPratica = cp ;
}
}
}
}
} else if ( controlloPraticaList . size ( ) = = 1 ) {
} else if ( controlloPraticaList . size ( ) = = 1 ) {
controlloPratica = controlloPraticaList . get ( 0 ) ;
controlloPratica = controlloPraticaList . get ( 0 ) ;
} else {
} else {
return null ;
return null ;
}
}
WorkflowInstanceLink workflowInstanceLink = WorkflowInstanceLinkLocalServiceUtil . fetchWorkflowInstanceLink (
WorkflowInstanceLink workflowInstanceLink = WorkflowInstanceLinkLocalServiceUtil
controlloPratica . getCompanyId ( ) , controlloPratica . getGroupId ( ) , ControlloPratica . class . getName ( ) ,
. fetchWorkflowInstanceLink ( controlloPratica . getCompanyId ( ) ,
controlloPratica . getPrimaryKey ( ) ) ;
controlloPratica . getGroupId ( ) ,
ControlloPratica . class . getName ( ) ,
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 ) ;
return null ;
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 {
List < DocPratica > docPraticaList = DocPraticaLocalServiceUtil . findByIntPratica ( intPraticaId ) ;
List < DocPratica > docPraticaList = DocPraticaLocalServiceUtil
for ( DocPratica docPratica : docPraticaList ) {
. findByIntPratica ( intPraticaId ) ;
if ( Validator . isNull ( DettPraticaLocalServiceUtil . fetchDettPratica ( docPratica . getClassPk ( ) ) )
for ( DocPratica docPratica : docPraticaList ) {
& & DettPratica . class . getName ( ) . equals ( docPratica . getClassName ( ) ) ) {
if ( Validator . isNull ( DettPraticaLocalServiceUtil
. fetchDettPratica ( docPratica . getClassPk ( ) ) )
& & DettPratica . class . getName ( ) . equals (
docPratica . getClassName ( ) ) ) {
docPraticaOrfaniList . add ( docPratica ) ;
docPraticaOrfaniList . add ( docPratica ) ;
}
}
}
}
} catch ( SystemException e ) {
} catch ( SystemException e ) {
_log . error ( e , e ) ;
_log . error ( e , e ) ;
}
}
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 ( ) ) {
return dettPraticaList . get ( 0 ) . getNormLavoriInProprio ( ) ;
return dettPraticaList . get ( 0 ) . getNormLavoriInProprio ( ) ;
}
}
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 ( ) ) {
return dettPraticaList . get ( 0 ) . getCollaudoStatico ( ) ;
return dettPraticaList . get ( 0 ) . getCollaudoStatico ( ) ;
}
}
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 ) {
if ( Validator . isNotNull ( intPratica ) ) {
if ( Validator . isNotNull ( intPratica ) ) {
return "IN" . equals ( intPratica . getStatoPratica ( ) ) ;
return "IN" . equals ( intPratica . getStatoPratica ( ) ) ;
}
}
return false ;
return false ;
}
}
public static long getCurrentAssignee ( IntPratica intPratica ) {
public static long getCurrentAssignee ( IntPratica intPratica ) {
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 ( ) ;
}
}
}
}
return currentAssignee ;
return currentAssignee ;
}
}
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
if ( ! controlloPraticas . isEmpty ( ) ) {
. findByIntPratica ( intPratica . getIntPraticaId ( ) ) ;
for ( ControlloPratica controlloPratica : controlloPraticas ) {
if ( ! controlloPraticas . isEmpty ( ) ) {
if ( controlloPratica . getStatus ( ) = = WorkflowConstants . STATUS_PENDING ) {
for ( ControlloPratica controlloPratica : controlloPraticas ) {
return WorkflowUtil . getLastTask ( controlloPratica . getCompanyId ( ) ,
if ( controlloPratica . getStatus ( ) = = WorkflowConstants . STATUS_PENDING ) {
controlloPratica . getGroupId ( ) , null , controlloPratica ) ;
return WorkflowUtil . getLastTask (
controlloPratica . getCompanyId ( ) ,
controlloPratica . getGroupId ( ) , null ,
controlloPratica ) ;
}
}
}
}
}
}
} catch ( SystemException | PortalException e ) {
} catch ( SystemException | PortalException e ) {
_log . error ( e , e ) ;
_log . error ( e , e ) ;
}
}
}
}
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 ) {
_log . error ( e , e ) ;
_log . error ( e , e ) ;
}
}
return false ;
return false ;
}
}
public static List < DettPratica > fetchDettPraticaListWithInizioLavori ( IntPratica intPratica ) {
public static List < DettPratica > fetchDettPraticaListWithInizioLavori (
if ( Validator . isNotNull ( intPratica ) ) {
IntPratica intPratica ) {
DynamicQuery dynamicQuery = DettPraticaLocalServiceUtil . dynamicQuery ( ) ;
if ( Validator . isNotNull ( intPratica ) ) {
dynamicQuery . add ( RestrictionsFactoryUtil . eq ( "intPraticaId" , intPratica . getIntPraticaId ( ) ) ) ;
DynamicQuery dynamicQuery = DettPraticaLocalServiceUtil
dynamicQuery . add ( RestrictionsFactoryUtil . isNotNull ( "dataInizioLavoriOpera" ) ) ;
. dynamicQuery ( ) ;
try {
dynamicQuery . add ( RestrictionsFactoryUtil . eq ( "intPraticaId" ,
return ( List < DettPratica > ) DettPraticaLocalServiceUtil . dynamicQuery ( dynamicQuery ) ;
intPratica . getIntPraticaId ( ) ) ) ;
} catch ( SystemException e ) {
dynamicQuery . add ( RestrictionsFactoryUtil
_log . error ( e , e ) ;
. isNotNull ( "dataInizioLavoriOpera" ) ) ;
try {
return ( List < DettPratica > ) DettPraticaLocalServiceUtil
. dynamicQuery ( dynamicQuery ) ;
} catch ( SystemException e ) {
_log . error ( e , e ) ;
return null ;
return null ;
}
}
}
}
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 ( ) ) {
return dettPraticaListWithInizioLavori . get ( 0 ) . getDataInizioLavoriOpera ( ) ;
return dettPraticaListWithInizioLavori . get ( 0 )
. getDataInizioLavoriOpera ( ) ;
}
}
return null ;
return null ;
}
}
private static List < DettPratica > _getDettPraticaList ( long intPraticaId ) {
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 > ( ) ;
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 ) ;
}
}