@ -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 ) ;
}
}