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