@ -19,9 +19,11 @@ import java.util.Date;
import java.util.List ;
import it.nextmind.liferay.portos.advanced.operation.util.AdvancedOperationUtil ;
import it.tref.liferay.portos.bo.model.ControlloPratica ;
import it.tref.liferay.portos.bo.model.DettPratica ;
import it.tref.liferay.portos.bo.model.DocPratica ;
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.DocPraticaLocalServiceUtil ;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil ;
@ -32,7 +34,26 @@ import javax.portlet.ActionResponse;
public class AdvancedOperationPortlet extends MVCPortlet {
private static final Log _log = LogFactoryUtil . getLog ( AdvancedOperationPortlet . class ) ;
public void deleteControlloPratica ( 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 ) {
List < ControlloPratica > controlloPraticaList =
ControlloPraticaLocalServiceUtil . findByIntPratica ( intPraticaId ) ;
for ( ControlloPratica cp : controlloPraticaList ) {
_log . info ( "AdvancedOperationPortlet --- Deleting ControlloPratica " + cp . getControlloPraticaId ( ) +
" of IntPraticaId " + intPraticaId ) ;
ControlloPraticaLocalServiceUtil . deleteControlloPratica ( cp ) ;
}
}
actionResponse . setRenderParameter ( "intPraticaId" , String . valueOf ( intPraticaId ) ) ;
}
public void reindexPratica ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
_checkIfUserIsCompanyAdmin ( actionRequest ) ;
@ -41,10 +62,12 @@ public class AdvancedOperationPortlet extends MVCPortlet {
long intPraticaId = ParamUtil . getLong ( actionRequest , "intPraticaId" , 0L ) ;
if ( intPraticaId ! = 0L ) {
_log . info ( "AdvancedOperationPortlet --- Reindexing fascicolo of IntPraticaId " + intPraticaId ) ;
IntPraticaLocalServiceUtil . reIndexFasciolo ( intPraticaId , themeDisplay . getCompanyId ( ) ) ;
}
actionResponse . setRenderParameter ( "intPraticaId" , String . valueOf ( intPraticaId ) ) ;
}
public void cambiaDataInizioLavori ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
_checkIfUserIsCompanyAdmin ( actionRequest ) ;
@ -53,7 +76,7 @@ public class AdvancedOperationPortlet extends MVCPortlet {
Date dataInizioLavoriOpera = ParamUtil . getDate ( actionRequest , "dataInizioLavoriOperaInput" ,
DateFormatFactoryUtil . getSimpleDateFormat ( "yyyy-MM-dd" ) , null ) ;
IntPratica intPratica = IntPraticaLocalServiceUtil . fetchIntPratica ( intPraticaId ) ;
_log . info ( "AdvancedOperationPortlet --- Changing DataInizioLavori on DettPraticas of IntPraticaId" + intPraticaId ) ;
List < DettPratica > dettPraticaListWithInizioLavori = AdvancedOperationUtil . fetchDettPraticaListWithInizioLavori ( intPratica ) ;
for ( DettPratica dettPratica : dettPraticaListWithInizioLavori ) {
dettPratica . setDataInizioLavoriOpera ( dataInizioLavoriOpera ) ;
@ -71,6 +94,7 @@ public class AdvancedOperationPortlet extends MVCPortlet {
boolean normLavoriInProprioFlag = ParamUtil . getBoolean ( actionRequest , "normLavoriInProprioFlag" ) ;
List < DettPratica > dettPraticaList = DettPraticaLocalServiceUtil . findByIntPraticaId ( intPraticaId ) ;
_log . info ( "AdvancedOperationPortlet --- Fixing NormLavoriInProprio flag of IntPraticaId " + intPraticaId ) ;
for ( DettPratica dettPratica : dettPraticaList ) {
if ( dettPratica . getNormLavoriInProprio ( ) = = normLavoriInProprioFlag ) {
dettPratica . setNormLavoriInProprio ( ! normLavoriInProprioFlag ) ;
@ -89,6 +113,7 @@ public class AdvancedOperationPortlet extends MVCPortlet {
boolean collaudoStaticoFlag = ParamUtil . getBoolean ( actionRequest , "collaudoStaticoFlag" ) ;
List < DettPratica > dettPraticaList = DettPraticaLocalServiceUtil . findByIntPraticaId ( intPraticaId ) ;
_log . info ( "AdvancedOperationPortlet --- Fixing CollaudoStatico flag of IntPraticaId " + intPraticaId ) ;
for ( DettPratica dettPratica : dettPraticaList ) {
if ( dettPratica . getCollaudoStatico ( ) = = collaudoStaticoFlag ) {
dettPratica . setCollaudoStatico ( ! collaudoStaticoFlag ) ;
@ -107,10 +132,14 @@ public class AdvancedOperationPortlet extends MVCPortlet {
IntPratica intPratica = IntPraticaLocalServiceUtil . fetchIntPratica ( intPraticaId ) ;
if ( WorkflowConstants . STATUS_DRAFT = = intPratica . getStatus ( ) ) {
_log . info ( "AdvancedOperationPortlet --- Fixing StatusPratica (From DRAFT to PENDING) "
+ "of IntPraticaId " + intPraticaId ) ;
intPratica . setStatus ( WorkflowConstants . STATUS_PENDING ) ;
intPratica . setModifiedDate ( new Date ( ) ) ;
IntPraticaLocalServiceUtil . updateIntPratica ( intPratica ) ;
} else {
_log . info ( "AdvancedOperationPortlet --- Impossible operation: Fixing StatusPratica (From DRAFT to PENDING) "
+ "of IntPraticaId " + intPraticaId ) ;
SessionErrors . add ( actionRequest , "operazione-impossibile" ) ;
}
actionResponse . setRenderParameter ( "intPraticaId" , String . valueOf ( intPraticaId ) ) ;
@ -124,6 +153,8 @@ public class AdvancedOperationPortlet extends MVCPortlet {
IntPratica intPratica = IntPraticaLocalServiceUtil . fetchIntPratica ( intPraticaId ) ;
if ( WorkflowConstants . STATUS_INCOMPLETE = = intPratica . getStatus ( ) ) {
_log . info ( "AdvancedOperationPortlet --- Recovering Pratica Vidimata (INCOMPLETE ==> DRAFT) "
+ "with IntPraticaId " + intPraticaId ) ;
_ripristinaPratica ( intPratica , WorkflowConstants . STATUS_DRAFT ) ;
} else {
SessionErrors . add ( actionRequest , "operazione-impossibile" ) ;
@ -138,8 +169,10 @@ public class AdvancedOperationPortlet extends MVCPortlet {
long intPraticaId = ParamUtil . getLong ( actionRequest , "intPraticaId" , - 1L ) ;
IntPratica intPratica = IntPraticaLocalServiceUtil . fetchIntPratica ( intPraticaId ) ;
if ( WorkflowConstants . STATUS_INCOMPLETE = = intPratica . getStatus ( ) ) {
_log . info ( "AdvancedOperationPortlet --- Recovering Pratica Vidimata (INCOMPLETE ==> APPROVED) "
+ "with IntPraticaId " + intPraticaId ) ;
_ripristinaPratica ( intPratica , WorkflowConstants . STATUS_APPROVED ) ;
} else {
SessionErrors . add ( actionRequest , "operazione-impossibile" ) ;
@ -155,7 +188,11 @@ public class AdvancedOperationPortlet extends MVCPortlet {
long intPraticaId = ParamUtil . getLong ( actionRequest , "intPraticaId" , - 1L ) ;
List < DocPratica > docPraticaOrfani = AdvancedOperationUtil . getDocPraticaOrfani ( intPraticaId ) ;
_log . info ( "AdvancedOperationPortlet --- Deleting Documenti Orfani "
+ "of IntPraticaId " + intPraticaId ) ;
for ( DocPratica docPratica : docPraticaOrfani ) {
_log . info ( "AdvancedOperationPortlet --- Deleting Documento Orfan " + docPratica . getDocPraticaId ( )
+ " of IntPraticaId " + intPraticaId ) ;
DocPraticaLocalServiceUtil . deleteDocPratica ( docPratica ) ;
}
actionResponse . setRenderParameter ( "intPraticaId" , String . valueOf ( intPraticaId ) ) ;