@ -5,30 +5,26 @@ 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.servlet.SessionErrors ;
import com.liferay.portal.kernel.servlet.SessionErrors ;
import com.liferay.portal.kernel.util.ArrayUtil ;
import com.liferay.portal.kernel.util.DateFormatFactoryUtil ;
import com.liferay.portal.kernel.util.ParamUtil ;
import com.liferay.portal.kernel.util.ParamUtil ;
import com.liferay.portal.kernel.util.Validator ;
import com.liferay.portal.kernel.util.Validator ;
import com.liferay.portal.kernel.util.WebKeys ;
import com.liferay.portal.kernel.util.WebKeys ;
import com.liferay.portal.kernel.workflow.WorkflowConstants ;
import com.liferay.portal.kernel.workflow.WorkflowConstants ;
import com.liferay.portal.service.UserLocalServiceUtil ;
import com.liferay.portal.theme.ThemeDisplay ;
import com.liferay.portal.theme.ThemeDisplay ;
import com.liferay.portal.util.PortalUtil ;
import com.liferay.portal.util.PortalUtil ;
import com.liferay.util.bridges.mvc.MVCPortlet ;
import com.liferay.util.bridges.mvc.MVCPortlet ;
import java.util.Date ;
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 ;
import java.util.Arrays ;
import java.util.Date ;
import java.util.List ;
import javax.portlet.ActionRequest ;
import javax.portlet.ActionRequest ;
import javax.portlet.ActionResponse ;
import javax.portlet.ActionResponse ;
@ -36,62 +32,20 @@ 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 ) ;
long intPraticaId = ParamUtil . getLong ( actionRequest , "intPraticaId" , 0L ) ;
if ( intPraticaId ! = 0L ) {
List < ControlloPratica > controlloPraticaList =
ControlloPraticaLocalServiceUtil . findByIntPratica ( intPraticaId ) ;
if ( _log . isDebugEnabled ( ) ) {
_log . debug ( "AdvancedOperationPortlet --- There are " + controlloPraticaList . size ( ) + " ControlloPratica" ) ;
}
for ( ControlloPratica cp : controlloPraticaList ) {
if ( _log . isDebugEnabled ( ) ) {
_log . debug ( "AdvancedOperationPortlet --- Cycling... ControlloPraticaID " + cp . getCompanyId ( )
+ " Status " + cp . getStatus ( ) ) ;
}
if ( ArrayUtil . contains ( AdvancedOperationUtil . STATUS_ARRAY , cp . getStatus ( ) ) ) {
_log . info ( "AdvancedOperationPortlet --- Deleting ControlloPratica " + cp . getControlloPraticaId ( ) +
" with Status " + cp . getStatus ( ) + " of IntPraticaId " + intPraticaId ) ;
ControlloPraticaLocalServiceUtil . deleteControlloPratica ( cp ) ;
}
}
}
actionResponse . setRenderParameter ( "intPraticaId" , String . valueOf ( intPraticaId ) ) ;
}
public void reindexPratica ( 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 ) {
_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 {
public void cambiaDataInizioLavori ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
_checkIfUserIsCompanyAdmin ( actionRequest ) ;
_checkIfUserIsCompanyAdmin ( actionRequest ) ;
long intPraticaId = ParamUtil . getLong ( actionRequest , "intPraticaId" , - 1L ) ;
long intPraticaId = ParamUtil . getLong ( actionRequest , "intPraticaId" , - 1L ) ;
Date dataInizioLavoriOpera = ParamUtil . getDate ( actionRequest , "dataInizioLavoriOperaInput" ,
Date dataInizioLavoriOpera = ParamUtil . getDate ( actionRequest , "dataInizioLavoriOperaInput" , 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 ) ;
dettPratica . setModifiedDate ( new Date ( ) ) ;
dettPratica . setModifiedDate ( new Date ( ) ) ;
DettPraticaLocalServiceUtil . updateDettPratica ( dettPratica ) ;
DettPraticaLocalServiceUtil . updateDettPratica ( dettPratica ) ;
}
}
actionResponse . setRenderParameter ( "intPraticaId" , String . valueOf ( intPraticaId ) ) ;
}
}
public void fixNormLavoriInProprio ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
public void fixNormLavoriInProprio ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
@ -102,7 +56,6 @@ 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 ) ;
@ -110,7 +63,6 @@ public class AdvancedOperationPortlet extends MVCPortlet {
DettPraticaLocalServiceUtil . updateDettPratica ( dettPratica ) ;
DettPraticaLocalServiceUtil . updateDettPratica ( dettPratica ) ;
}
}
}
}
actionResponse . setRenderParameter ( "intPraticaId" , String . valueOf ( intPraticaId ) ) ;
}
}
public void fixCollaudoStatico ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
public void fixCollaudoStatico ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
@ -121,7 +73,6 @@ 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 ) ;
@ -129,7 +80,6 @@ public class AdvancedOperationPortlet extends MVCPortlet {
DettPraticaLocalServiceUtil . updateDettPratica ( dettPratica ) ;
DettPraticaLocalServiceUtil . updateDettPratica ( dettPratica ) ;
}
}
}
}
actionResponse . setRenderParameter ( "intPraticaId" , String . valueOf ( intPraticaId ) ) ;
}
}
public void fixStatusPratica ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
public void fixStatusPratica ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
@ -140,17 +90,10 @@ 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) "
IntPraticaLocalServiceUtil . updateStatus ( intPraticaId , WorkflowConstants . STATUS_PENDING ) ;
+ "of IntPraticaId " + intPraticaId ) ;
intPratica . setStatus ( WorkflowConstants . STATUS_PENDING ) ;
intPratica . setModifiedDate ( new Date ( ) ) ;
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 ) ) ;
}
}
public void ripristinaPraticaVidimata ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
public void ripristinaPraticaVidimata ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
@ -161,14 +104,11 @@ 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" ) ;
throw new Exception ( "This Pratica is not in status=5, action RIPRISTINA is not available" ) ;
throw new Exception ( "This Pratica is not in status=5, action RIPRISTINA is not available" ) ;
}
}
actionResponse . setRenderParameter ( "intPraticaId" , String . valueOf ( intPraticaId ) ) ;
}
}
public void ripristinaPraticaConforme ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
public void ripristinaPraticaConforme ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
@ -179,14 +119,11 @@ 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" ) ;
throw new Exception ( "This Pratica is not in status=5, action RIPRISTINA is not available" ) ;
throw new Exception ( "This Pratica is not in status=5, action RIPRISTINA is not available" ) ;
}
}
actionResponse . setRenderParameter ( "intPraticaId" , String . valueOf ( intPraticaId ) ) ;
}
}
public void deleteDocPratica ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
public void deleteDocPratica ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
@ -196,14 +133,9 @@ 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 ) ) ;
}
}
public void findIntPratica ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {
public void findIntPratica ( ActionRequest actionRequest , ActionResponse actionResponse ) throws Exception {