@ -64,7 +64,6 @@ import com.liferay.portal.kernel.cache.CacheRegistryUtil;
import com.liferay.portal.kernel.cache.MultiVMPoolUtil ;
import com.liferay.portal.kernel.cache.MultiVMPoolUtil ;
import com.liferay.portal.kernel.cache.SingleVMPoolUtil ;
import com.liferay.portal.kernel.cache.SingleVMPoolUtil ;
import com.liferay.portal.kernel.dao.jdbc.DataAccess ;
import com.liferay.portal.kernel.dao.jdbc.DataAccess ;
import com.liferay.portal.kernel.dao.orm.QueryUtil ;
import com.liferay.portal.kernel.exception.PortalException ;
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 ;
@ -165,9 +164,6 @@ public class ManutenzioneDatabase {
ZoneSismicheUtil zone = new ZoneSismicheUtil ( serviceContext ) ;
ZoneSismicheUtil zone = new ZoneSismicheUtil ( serviceContext ) ;
esitoLog ( esito , zone . aggiornaComuni ( companyId ) ) ;
esitoLog ( esito , zone . aggiornaComuni ( companyId ) ) ;
}
}
if ( mode . contains ( "!Riduzione!" ) ) {
esitoLog ( esito , riduzione ( companyId , mode . substring ( 11 ) ) ) ;
}
if ( mode . contains ( "!Pulisci!" ) ) {
if ( mode . contains ( "!Pulisci!" ) ) {
if ( mode . contains ( "!DocumentLibrary!" ) ) {
if ( mode . contains ( "!DocumentLibrary!" ) ) {
esitoLog ( esito , puliziaDocumentLibrary ( companyId ) ) ;
esitoLog ( esito , puliziaDocumentLibrary ( companyId ) ) ;
@ -184,9 +180,9 @@ public class ManutenzioneDatabase {
esitoLog ( esito , svuotaIntPraticaDettPratica ( ) ) ;
esitoLog ( esito , svuotaIntPraticaDettPratica ( ) ) ;
}
}
if ( mode . contains ( "!User!" ) ) {
if ( mode . contains ( "!User!" ) ) {
esito . addAll ( svuotaUser ( companyId ) ) ;
esitoLog ( esito , svuotaUser ( companyId ) ) ;
}
}
esito . addAll ( svuotaDatabase ( companyId ) ) ;
esitoLog ( esito , svuotaDatabase ( companyId ) ) ;
if ( mode . contains ( "!Reset!" ) ) {
if ( mode . contains ( "!Reset!" ) ) {
ConfigurazioneLocalServiceUtil . storeConfig ( Constants . NUMERO_PROGETTO_KEY_DB , "1" , serviceContext ) ;
ConfigurazioneLocalServiceUtil . storeConfig ( Constants . NUMERO_PROGETTO_KEY_DB , "1" , serviceContext ) ;
}
}
@ -199,30 +195,7 @@ public class ManutenzioneDatabase {
return esito ;
return esito ;
}
}
private static List < String > riduzione ( long companyId , String rimaste ) throws SystemException , PortalException {
// !Riduzione!107043,107023,106983,106793,104938,77853
List < String > esito = new ArrayList < > ( ) ;
try {
Connection connection = DataAccess . getUpgradeOptimizedConnection ( ) ;
Statement s = connection . createStatement ( ) ;
String condizione = "numeroprogetto IN ('" + StringUtil . merge ( StringUtil . split ( rimaste , ',' ) , "','" ) + "')" ;
String sql = "DELETE FROM portos_bo_intpratica WHERE NOT " + condizione ;
int i = s . executeUpdate ( sql ) ;
esitoLog ( esito , "Cancellate " + i + " IntPratica" ) ;
sql = "DELETE FROM portos_bo_dettpratica WHERE intpraticaid NOT IN ("
+ "SELECT intpraticaid FROM portos_bo_intpratica WHERE " + condizione + ')' ;
i = s . executeUpdate ( sql ) ;
esitoLog ( esito , "Cancellate " + i + " DettPratica" ) ;
} catch ( SQLException e ) {
e . printStackTrace ( ) ;
}
esito . addAll ( svuotaDatabase ( companyId ) ) ;
return esito ;
}
private static void clearCache ( ) {
private static void clearCache ( ) {
try {
try {
SingleVMPoolUtil . clear ( ) ;
SingleVMPoolUtil . clear ( ) ;
MultiVMPoolUtil . clear ( ) ;
MultiVMPoolUtil . clear ( ) ;
@ -236,7 +209,7 @@ public class ManutenzioneDatabase {
List < String > esito = new ArrayList < > ( ) ;
List < String > esito = new ArrayList < > ( ) ;
esitoLog ( esito , svuotaDettPratica ( ) ) ;
esitoLog ( esito , svuotaDettPratica ( ) ) ;
esitoLog ( esito , svuotaAllegatoManuale ( ) ) ;
esitoLog ( esito , svuotaAllegatoManuale ( ) ) ;
// esitoLog(esito, svuotaAssetEntry(companyId));
esitoLog ( esito , svuotaAssetEntry ( companyId ) ) ;
esitoLog ( esito , svuotaAsseverazione ( ) ) ;
esitoLog ( esito , svuotaAsseverazione ( ) ) ;
esitoLog ( esito , svuotaAvviso ( companyId ) ) ;
esitoLog ( esito , svuotaAvviso ( companyId ) ) ;
esitoLog ( esito , svuotaCollaudo ( ) ) ;
esitoLog ( esito , svuotaCollaudo ( ) ) ;
@ -250,29 +223,28 @@ public class ManutenzioneDatabase {
esitoLog ( esito , svuotaFineLavori ( ) ) ;
esitoLog ( esito , svuotaFineLavori ( ) ) ;
esitoLog ( esito , svuotaGroup ( companyId ) ) ;
esitoLog ( esito , svuotaGroup ( companyId ) ) ;
esitoLog ( esito , svuotaHistoryWorkflowAction ( ) ) ;
esitoLog ( esito , svuotaHistoryWorkflowAction ( ) ) ;
// esitoLog(esito, svuotaMBDiscussion(companyId));
esitoLog ( esito , svuotaMBDiscussion ( companyId ) ) ;
// esitoLog(esito, svuotaMBMessage(companyId));
esitoLog ( esito , svuotaMBMessage ( companyId ) ) ;
// esitoLog(esito, svuotaMBThread());
esitoLog ( esito , svuotaMBThread ( ) ) ;
esitoLog ( esito , svuotaPagamento ( companyId ) ) ;
esitoLog ( esito , svuotaPagamento ( companyId ) ) ;
esitoLog ( esito , svuotaParereGeologo ( ) ) ;
esitoLog ( esito , svuotaParereGeologo ( ) ) ;
esitoLog ( esito , svuotaRatingsEntry ( ) ) ;
esitoLog ( esito , svuotaRatingsEntry ( ) ) ;
esitoLog ( esito , svuotaRatingsStats ( companyId ) ) ;
esitoLog ( esito , svuotaRatingsStats ( companyId ) ) ;
// esitoLog(esito, svuotaResourcePermission(companyId));
esitoLog ( esito , svuotaResourcePermission ( companyId ) ) ;
esitoLog ( esito , svuotaSoggetto ( ) ) ;
esitoLog ( esito , svuotaSoggetto ( ) ) ;
esitoLog ( esito , svuotaSorteggio ( ) ) ;
esitoLog ( esito , svuotaSorteggio ( ) ) ;
esitoLog ( esito , svuotaStoricoSoggettoPratica ( ) ) ;
esitoLog ( esito , svuotaStoricoSoggettoPratica ( ) ) ;
esitoLog ( esito , svuotaSyncDLObject ( ) ) ;
esitoLog ( esito , svuotaSyncDLObject ( ) ) ;
esitoLog ( esito , svuotaSystemEvent ( companyId ) ) ;
esitoLog ( esito , svuotaSystemEvent ( companyId ) ) ;
esitoLog ( esito , svuotaTempistica ( ) ) ;
esitoLog ( esito , svuotaTempistica ( ) ) ;
esito . addAll ( svuotaUser ( companyId ) ) ;
esitoLog ( esito , svuotaWorkflowInstance ( ) ) ;
esitoLog ( esito , svuotaWorkflowInstance ( ) ) ;
return esito ;
return esito ;
}
}
private static List < String > puliziaDocumentLibrary ( long companyId ) {
private static List < String > puliziaDocumentLibrary ( long companyId ) {
List < String > esito = new ArrayList < > ( ) ;
List < String > esito = new ArrayList < > ( ) ;
Set < String > parentFolderNames = new HashSet < > ( ) ;
Set < String > parentFolderNames = new HashSet < > ( ) ;
try {
try {
long allegatiFolderId = ConfigurazioneLocalServiceUtil . findByC_ChiaveLong ( companyId ,
long allegatiFolderId = ConfigurazioneLocalServiceUtil . findByC_ChiaveLong ( companyId ,
ConfigurazioneConstants . ATTACHMENT_FOLDER_ID ) ;
ConfigurazioneConstants . ATTACHMENT_FOLDER_ID ) ;
@ -282,6 +254,7 @@ public class ManutenzioneDatabase {
List < DLFolder > folders ;
List < DLFolder > folders ;
do {
do {
folders = DLFolderLocalServiceUtil . getDLFolders ( start , start + SLICE ) ;
folders = DLFolderLocalServiceUtil . getDLFolders ( start , start + SLICE ) ;
int rimossi = 0 ;
totali + = folders . size ( ) ;
totali + = folders . size ( ) ;
for ( DLFolder folder : folders ) {
for ( DLFolder folder : folders ) {
DLFolder parent = folder . getParentFolder ( ) ;
DLFolder parent = folder . getParentFolder ( ) ;
@ -306,6 +279,7 @@ public class ManutenzioneDatabase {
_log . info ( "Cancello la cartella " + folder . getName ( ) ) ;
_log . info ( "Cancello la cartella " + folder . getName ( ) ) ;
DLAppLocalServiceUtil . deleteFolder ( folder . getFolderId ( ) ) ;
DLAppLocalServiceUtil . deleteFolder ( folder . getFolderId ( ) ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
} else {
} else {
_log . info ( "Mantengo la cartella " + folder . getName ( ) ) ;
_log . info ( "Mantengo la cartella " + folder . getName ( ) ) ;
@ -320,13 +294,14 @@ public class ManutenzioneDatabase {
_log . info ( "Cancello la cartella " + folder . getName ( ) ) ;
_log . info ( "Cancello la cartella " + folder . getName ( ) ) ;
DLAppLocalServiceUtil . deleteFolder ( folder . getFolderId ( ) ) ;
DLAppLocalServiceUtil . deleteFolder ( folder . getFolderId ( ) ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
} else {
} else {
_log . info ( "Non allegato " + folder . getName ( ) + " in " + parent . getName ( ) ) ;
_log . info ( "Non allegato " + folder . getName ( ) + " in " + parent . getName ( ) ) ;
}
}
}
}
}
}
start + = folders . size ( ) ;
start + = folders . size ( ) - rimossi ;
} while ( folders . size ( ) > 0 ) ;
} while ( folders . size ( ) > 0 ) ;
esitoLog ( esito , "Analizzate " + totali + " cartelle, cancellate " + cancellati ) ;
esitoLog ( esito , "Analizzate " + totali + " cartelle, cancellate " + cancellati ) ;
} catch ( PortalException | SystemException e ) {
} catch ( PortalException | SystemException e ) {
@ -339,7 +314,6 @@ public class ManutenzioneDatabase {
}
}
private static List < Long > avvisiFileEntries ( ) throws SystemException {
private static List < Long > avvisiFileEntries ( ) throws SystemException {
List < Long > result = new ArrayList < > ( ) ;
List < Long > result = new ArrayList < > ( ) ;
int start = 0 ;
int start = 0 ;
List < Avviso > avvisi = null ;
List < Avviso > avvisi = null ;
@ -356,13 +330,13 @@ public class ManutenzioneDatabase {
}
}
private static String puliziaAllegati ( long companyId , long folderId ) throws SystemException , PortalException {
private static String puliziaAllegati ( long companyId , long folderId ) throws SystemException , PortalException {
List < Long > avvisiFileEntries = avvisiFileEntries ( ) ;
List < Long > avvisiFileEntries = avvisiFileEntries ( ) ;
long repositoryId = DLAppLocalServiceUtil . getFolder ( folderId ) . getRepositoryId ( ) ;
long repositoryId = DLAppLocalServiceUtil . getFolder ( folderId ) . getRepositoryId ( ) ;
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < FileEntry > fileEntries = null ;
List < FileEntry > fileEntries = null ;
do {
do {
int rimossi = 0 ;
fileEntries = DLAppServiceUtil . getFileEntries ( repositoryId , folderId , start , start + SLICE ) ;
fileEntries = DLAppServiceUtil . getFileEntries ( repositoryId , folderId , start , start + SLICE ) ;
for ( FileEntry fileEntry : fileEntries ) {
for ( FileEntry fileEntry : fileEntries ) {
String [ ] parti = StringUtil . split ( fileEntry . getTitle ( ) . replaceAll ( "\\.p7m$" , StringPool . BLANK ) , '_' ) ;
String [ ] parti = StringUtil . split ( fileEntry . getTitle ( ) . replaceAll ( "\\.p7m$" , StringPool . BLANK ) , '_' ) ;
@ -392,6 +366,7 @@ public class ManutenzioneDatabase {
if ( ! esiste ( DETTPRATICA_CLASS_NAME , id1 ) ) {
if ( ! esiste ( DETTPRATICA_CLASS_NAME , id1 ) ) {
DLAppLocalServiceUtil . deleteFileEntry ( fileEntry . getFileEntryId ( ) ) ;
DLAppLocalServiceUtil . deleteFileEntry ( fileEntry . getFileEntryId ( ) ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
break ;
break ;
case "AI_B" :
case "AI_B" :
@ -402,6 +377,7 @@ public class ManutenzioneDatabase {
if ( ! avvisiFileEntries . contains ( fileEntry . getFileEntryId ( ) ) ) {
if ( ! avvisiFileEntries . contains ( fileEntry . getFileEntryId ( ) ) ) {
DLAppLocalServiceUtil . deleteFileEntry ( fileEntry . getFileEntryId ( ) ) ;
DLAppLocalServiceUtil . deleteFileEntry ( fileEntry . getFileEntryId ( ) ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
break ;
break ;
default :
default :
@ -413,17 +389,17 @@ public class ManutenzioneDatabase {
_log . info ( "Nome sconosciuto " + fileEntry . getTitle ( ) ) ;
_log . info ( "Nome sconosciuto " + fileEntry . getTitle ( ) ) ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( fileEntries . size ( ) > 0 ) ;
} while ( fileEntries . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " File orfani" ;
return "Cancellati " + cancellati + " File orfani" ;
}
}
private static String svuotaAllegatoManuale ( ) throws SystemException {
private static String svuotaAllegatoManuale ( ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < AllegatoManuale > allegatiManuali = null ;
List < AllegatoManuale > allegatiManuali = null ;
do {
do {
int rimossi = 0 ;
allegatiManuali = AllegatoManualeLocalServiceUtil . getAllegatoManuales ( start , start + SLICE ) ;
allegatiManuali = AllegatoManualeLocalServiceUtil . getAllegatoManuales ( start , start + SLICE ) ;
for ( AllegatoManuale allegatoManuale : allegatiManuali ) {
for ( AllegatoManuale allegatoManuale : allegatiManuali ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , allegatoManuale . getIntPraticaId ( ) )
if ( ! esiste ( INTPRATICA_CLASS_NAME , allegatoManuale . getIntPraticaId ( ) )
@ -432,19 +408,20 @@ public class ManutenzioneDatabase {
deleteFileEntry ( allegatoManuale . getFileEntryId ( ) ) ;
deleteFileEntry ( allegatoManuale . getFileEntryId ( ) ) ;
AllegatoManualeLocalServiceUtil . deleteAllegatoManuale ( allegatoManuale ) ;
AllegatoManualeLocalServiceUtil . deleteAllegatoManuale ( allegatoManuale ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( allegatiManuali . size ( ) > 0 ) ;
} while ( allegatiManuali . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " AllegatoManuale" ;
return "Cancellati " + cancellati + " AllegatoManuale" ;
}
}
private static String svuotaAssetEntry ( long companyId ) throws SystemException {
private static String svuotaAssetEntry ( long companyId ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < AssetEntry > assetEntries = null ;
List < AssetEntry > assetEntries = null ;
do {
do {
int rimossi = 0 ;
assetEntries = AssetEntryLocalServiceUtil . getAssetEntries ( start , start + SLICE ) ;
assetEntries = AssetEntryLocalServiceUtil . getAssetEntries ( start , start + SLICE ) ;
for ( AssetEntry assetEntry : assetEntries ) {
for ( AssetEntry assetEntry : assetEntries ) {
String className = assetEntry . getClassName ( ) ;
String className = assetEntry . getClassName ( ) ;
@ -454,19 +431,20 @@ public class ManutenzioneDatabase {
if ( ! esiste ( className , assetEntry . getClassPK ( ) , companyId ) ) {
if ( ! esiste ( className , assetEntry . getClassPK ( ) , companyId ) ) {
AssetEntryLocalServiceUtil . deleteAssetEntry ( assetEntry ) ;
AssetEntryLocalServiceUtil . deleteAssetEntry ( assetEntry ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( assetEntries . size ( ) > 0 ) ;
} while ( assetEntries . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " AssetEntry" ;
return "Cancellati " + cancellati + " AssetEntry" ;
}
}
private static String svuotaAsseverazione ( ) throws SystemException {
private static String svuotaAsseverazione ( ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < Asseverazione > asseverazioni = null ;
List < Asseverazione > asseverazioni = null ;
do {
do {
int rimossi = 0 ;
asseverazioni = AsseverazioneLocalServiceUtil . getAsseveraziones ( start , start + SLICE ) ;
asseverazioni = AsseverazioneLocalServiceUtil . getAsseveraziones ( start , start + SLICE ) ;
for ( Asseverazione asseverazione : asseverazioni ) {
for ( Asseverazione asseverazione : asseverazioni ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , asseverazione . getIntPraticaId ( ) )
if ( ! esiste ( INTPRATICA_CLASS_NAME , asseverazione . getIntPraticaId ( ) )
@ -474,19 +452,20 @@ public class ManutenzioneDatabase {
deleteFileEntry ( asseverazione . getFileEntryId ( ) ) ;
deleteFileEntry ( asseverazione . getFileEntryId ( ) ) ;
AsseverazioneLocalServiceUtil . deleteAsseverazione ( asseverazione ) ;
AsseverazioneLocalServiceUtil . deleteAsseverazione ( asseverazione ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( asseverazioni . size ( ) > 0 ) ;
} while ( asseverazioni . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " Asseverazione" ;
return "Cancellati " + cancellati + " Asseverazione" ;
}
}
private static String svuotaAvviso ( long companyId ) throws SystemException {
private static String svuotaAvviso ( long companyId ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < Avviso > avvisi = null ;
List < Avviso > avvisi = null ;
do {
do {
int rimossi = 0 ;
avvisi = AvvisoLocalServiceUtil . getAvvisos ( start , start + SLICE ) ;
avvisi = AvvisoLocalServiceUtil . getAvvisos ( start , start + SLICE ) ;
for ( Avviso avviso : avvisi ) {
for ( Avviso avviso : avvisi ) {
if ( ! esiste ( avviso . getClassName ( ) , avviso . getClassPk ( ) , companyId )
if ( ! esiste ( avviso . getClassName ( ) , avviso . getClassPk ( ) , companyId )
@ -496,111 +475,117 @@ public class ManutenzioneDatabase {
deleteFileEntry ( avviso . getFileEntryIdProtocollo ( ) ) ;
deleteFileEntry ( avviso . getFileEntryIdProtocollo ( ) ) ;
AvvisoLocalServiceUtil . deleteAvviso ( avviso ) ;
AvvisoLocalServiceUtil . deleteAvviso ( avviso ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( avvisi . size ( ) > 0 ) ;
} while ( avvisi . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " Avviso" ;
return "Cancellati " + cancellati + " Avviso" ;
}
}
private static String svuotaCollaudo ( ) throws SystemException , PortalException {
private static String svuotaCollaudo ( ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < Collaudo > collaudi = null ;
List < Collaudo > collaudi = null ;
do {
do {
int rimossi = 0 ;
collaudi = CollaudoLocalServiceUtil . getCollaudos ( start , start + SLICE ) ;
collaudi = CollaudoLocalServiceUtil . getCollaudos ( start , start + SLICE ) ;
for ( Collaudo collaudo : collaudi ) {
for ( Collaudo collaudo : collaudi ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , collaudo . getIntPraticaId ( ) ) ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , collaudo . getIntPraticaId ( ) ) ) {
CollaudoLocalServiceUtil . deleteCollaudo ( collaudo ) ;
CollaudoLocalServiceUtil . deleteCollaudo ( collaudo ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( collaudi . size ( ) > 0 ) ;
} while ( collaudi . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " Collaudo" ;
return "Cancellati " + cancellati + " Collaudo" ;
}
}
private static String svuotaContact ( long companyId ) throws SystemException , PortalException {
private static String svuotaContact ( long companyId ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < Contact > contacts = null ;
List < Contact > contacts = null ;
do {
do {
int rimossi = 0 ;
contacts = ContactLocalServiceUtil . getContacts ( start , start + SLICE ) ;
contacts = ContactLocalServiceUtil . getContacts ( start , start + SLICE ) ;
for ( Contact contact : contacts ) {
for ( Contact contact : contacts ) {
if ( ! esiste ( contact . getClassName ( ) , contact . getClassPK ( ) , companyId ) ) {
if ( ! esiste ( contact . getClassName ( ) , contact . getClassPK ( ) , companyId ) ) {
ContactLocalServiceUtil . deleteContact ( contact ) ;
ContactLocalServiceUtil . deleteContact ( contact ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( contacts . size ( ) > 0 ) ;
} while ( contacts . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " Contact" ;
return "Cancellati " + cancellati + " Contact" ;
}
}
private static String svuotaControlloPratica ( ) throws SystemException , PortalException {
private static String svuotaControlloPratica ( ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < ControlloPratica > controlliPratiche = null ;
List < ControlloPratica > controlliPratiche = null ;
do {
do {
int rimossi = 0 ;
controlliPratiche = ControlloPraticaLocalServiceUtil . getControlloPraticas ( start , start + SLICE ) ;
controlliPratiche = ControlloPraticaLocalServiceUtil . getControlloPraticas ( start , start + SLICE ) ;
for ( ControlloPratica controlloPratica : controlliPratiche ) {
for ( ControlloPratica controlloPratica : controlliPratiche ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , controlloPratica . getIntPraticaId ( ) )
if ( ! esiste ( INTPRATICA_CLASS_NAME , controlloPratica . getIntPraticaId ( ) )
| | ! esiste ( DETTPRATICA_CLASS_NAME , controlloPratica . getDettPraticaId ( ) ) ) {
| | ! esiste ( DETTPRATICA_CLASS_NAME , controlloPratica . getDettPraticaId ( ) ) ) {
ControlloPraticaLocalServiceUtil . deleteControlloPratica ( controlloPratica ) ;
ControlloPraticaLocalServiceUtil . deleteControlloPratica ( controlloPratica ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( controlliPratiche . size ( ) > 0 ) ;
} while ( controlliPratiche . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " ControlloPratica" ;
return "Cancellati " + cancellati + " ControlloPratica" ;
}
}
private static String svuotaDelega ( ) throws SystemException , PortalException {
private static String svuotaDelega ( ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < Delega > deleghe = null ;
List < Delega > deleghe = null ;
do {
do {
int rimossi = 0 ;
deleghe = DelegaLocalServiceUtil . getDelegas ( start , start + SLICE ) ;
deleghe = DelegaLocalServiceUtil . getDelegas ( start , start + SLICE ) ;
for ( Delega delega : deleghe ) {
for ( Delega delega : deleghe ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , delega . getIntPraticaId ( ) )
if ( ! esiste ( INTPRATICA_CLASS_NAME , delega . getIntPraticaId ( ) )
| | ! esiste ( DETTPRATICA_CLASS_NAME , delega . getDettPraticaId ( ) ) ) {
| | ! esiste ( DETTPRATICA_CLASS_NAME , delega . getDettPraticaId ( ) ) ) {
DelegaLocalServiceUtil . deleteDelega ( delega ) ;
DelegaLocalServiceUtil . deleteDelega ( delega ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( deleghe . size ( ) > 0 ) ;
} while ( deleghe . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " Delega" ;
return "Cancellati " + cancellati + " Delega" ;
}
}
private static String svuotaDettPratica ( ) throws SystemException , PortalException {
private static String svuotaDettPratica ( ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < DettPratica > dettPratiche = null ;
List < DettPratica > dettPratiche = null ;
do {
do {
int rimossi = 0 ;
dettPratiche = DettPraticaLocalServiceUtil . getDettPraticas ( start , start + SLICE ) ;
dettPratiche = DettPraticaLocalServiceUtil . getDettPraticas ( start , start + SLICE ) ;
for ( DettPratica dettPratica : dettPratiche ) {
for ( DettPratica dettPratica : dettPratiche ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , dettPratica . getIntPraticaId ( ) ) ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , dettPratica . getIntPraticaId ( ) ) ) {
DettPraticaLocalServiceUtil . deleteDettPratica ( dettPratica ) ;
DettPraticaLocalServiceUtil . deleteDettPratica ( dettPratica ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( dettPratiche . size ( ) > 0 ) ;
} while ( dettPratiche . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " DettPratica" ;
return "Cancellati " + cancellati + " DettPratica" ;
}
}
private static String svuotaDocAggiuntiva ( ) throws SystemException , PortalException {
private static String svuotaDocAggiuntiva ( ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < DocAggiuntiva > docAggiuntive = null ;
List < DocAggiuntiva > docAggiuntive = null ;
do {
do {
int rimossi = 0 ;
docAggiuntive = DocAggiuntivaLocalServiceUtil . getDocAggiuntivas ( start , start + SLICE ) ;
docAggiuntive = DocAggiuntivaLocalServiceUtil . getDocAggiuntivas ( start , start + SLICE ) ;
for ( DocAggiuntiva docAggiuntiva : docAggiuntive ) {
for ( DocAggiuntiva docAggiuntiva : docAggiuntive ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , docAggiuntiva . getIntPraticaId ( ) )
if ( ! esiste ( INTPRATICA_CLASS_NAME , docAggiuntiva . getIntPraticaId ( ) )
@ -608,19 +593,20 @@ public class ManutenzioneDatabase {
deleteFileEntry ( docAggiuntiva . getFileEntryId ( ) ) ;
deleteFileEntry ( docAggiuntiva . getFileEntryId ( ) ) ;
DocAggiuntivaLocalServiceUtil . deleteDocAggiuntiva ( docAggiuntiva ) ;
DocAggiuntivaLocalServiceUtil . deleteDocAggiuntiva ( docAggiuntiva ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( docAggiuntive . size ( ) > 0 ) ;
} while ( docAggiuntive . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " DocAggiuntiva" ;
return "Cancellati " + cancellati + " DocAggiuntiva" ;
}
}
private static String svuotaDocPratica ( long companyId ) throws SystemException , PortalException {
private static String svuotaDocPratica ( long companyId ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < DocPratica > docPratiche = null ;
List < DocPratica > docPratiche = null ;
do {
do {
int rimossi = 0 ;
docPratiche = DocPraticaLocalServiceUtil . getDocPraticas ( start , start + SLICE ) ;
docPratiche = DocPraticaLocalServiceUtil . getDocPraticas ( start , start + SLICE ) ;
for ( DocPratica docPratica : docPratiche ) {
for ( DocPratica docPratica : docPratiche ) {
if ( ! esiste ( docPratica . getClassName ( ) , docPratica . getClassPk ( ) , companyId )
if ( ! esiste ( docPratica . getClassName ( ) , docPratica . getClassPk ( ) , companyId )
@ -628,71 +614,74 @@ public class ManutenzioneDatabase {
deleteFileEntry ( docPratica . getDlFileEntryId ( ) ) ;
deleteFileEntry ( docPratica . getDlFileEntryId ( ) ) ;
DocPraticaLocalServiceUtil . deleteDocPratica ( docPratica ) ;
DocPraticaLocalServiceUtil . deleteDocPratica ( docPratica ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( docPratiche . size ( ) > 0 ) ;
} while ( docPratiche . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " DocPratica" ;
return "Cancellati " + cancellati + " DocPratica" ;
}
}
private static String svuotaEmail ( long companyId ) throws SystemException , PortalException {
private static String svuotaEmail ( long companyId ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < Email > emails = null ;
List < Email > emails = null ;
do {
do {
int rimossi = 0 ;
emails = EmailLocalServiceUtil . getEmails ( start , start + SLICE ) ;
emails = EmailLocalServiceUtil . getEmails ( start , start + SLICE ) ;
for ( Email email : emails ) {
for ( Email email : emails ) {
if ( ! esiste ( email . getClassName ( ) , email . getClassPK ( ) , companyId ) ) {
if ( ! esiste ( email . getClassName ( ) , email . getClassPK ( ) , companyId ) ) {
EmailLocalServiceUtil . deleteEmail ( email ) ;
EmailLocalServiceUtil . deleteEmail ( email ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( emails . size ( ) > 0 ) ;
} while ( emails . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " Email" ;
return "Cancellati " + cancellati + " Email" ;
}
}
private static String svuotaEmailAttachment ( ) throws SystemException , PortalException {
private static String svuotaEmailAttachment ( ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < EmailAttachment > emailAttachments = null ;
List < EmailAttachment > emailAttachments = null ;
do {
do {
int rimossi = 0 ;
emailAttachments = EmailAttachmentLocalServiceUtil . getEmailAttachments ( start , start + SLICE ) ;
emailAttachments = EmailAttachmentLocalServiceUtil . getEmailAttachments ( start , start + SLICE ) ;
for ( EmailAttachment emailAttachment : emailAttachments ) {
for ( EmailAttachment emailAttachment : emailAttachments ) {
if ( ! esiste ( EMAIL_CLASS_NAME , emailAttachment . getEmailId ( ) ) ) {
if ( ! esiste ( EMAIL_CLASS_NAME , emailAttachment . getEmailId ( ) ) ) {
deleteFileEntry ( emailAttachment . getFileEntryId ( ) ) ;
deleteFileEntry ( emailAttachment . getFileEntryId ( ) ) ;
EmailAttachmentLocalServiceUtil . deleteEmailAttachment ( emailAttachment ) ;
EmailAttachmentLocalServiceUtil . deleteEmailAttachment ( emailAttachment ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( emailAttachments . size ( ) > 0 ) ;
} while ( emailAttachments . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " EmailAttachment" ;
return "Cancellati " + cancellati + " EmailAttachment" ;
}
}
private static String svuotaFineLavori ( ) throws SystemException , PortalException {
private static String svuotaFineLavori ( ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < FineLavori > finiLavori = null ;
List < FineLavori > finiLavori = null ;
do {
do {
int rimossi = 0 ;
finiLavori = FineLavoriLocalServiceUtil . getFineLavoris ( start , start + SLICE ) ;
finiLavori = FineLavoriLocalServiceUtil . getFineLavoris ( start , start + SLICE ) ;
for ( FineLavori fineLavori : finiLavori ) {
for ( FineLavori fineLavori : finiLavori ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , fineLavori . getIntPraticaId ( ) ) ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , fineLavori . getIntPraticaId ( ) ) ) {
FineLavoriLocalServiceUtil . deleteFineLavori ( fineLavori ) ;
FineLavoriLocalServiceUtil . deleteFineLavori ( fineLavori ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( finiLavori . size ( ) > 0 ) ;
} while ( finiLavori . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " FineLavori" ;
return "Cancellati " + cancellati + " FineLavori" ;
}
}
// Troncare le tabelle è l'unico modo possibile
// Troncare le tabelle è l'unico modo possibile
private static String svuotaIntPraticaDettPratica ( ) {
private static String svuotaIntPraticaDettPratica ( ) {
int i = 0 ;
int i = 0 ;
int d = 0 ;
int d = 0 ;
try {
try {
@ -700,56 +689,56 @@ public class ManutenzioneDatabase {
Statement s = connection . createStatement ( ) ;
Statement s = connection . createStatement ( ) ;
i = s . executeUpdate ( "DELETE FROM portos_bo_intpratica" ) ;
i = s . executeUpdate ( "DELETE FROM portos_bo_intpratica" ) ;
d = s . executeUpdate ( "DELETE FROM portos_bo_dettpratica" ) ;
d = s . executeUpdate ( "DELETE FROM portos_bo_dettpratica" ) ;
} catch ( SQLException e ) {
} catch ( SQLException e ) { }
e . printStackTrace ( ) ;
}
clearCache ( ) ;
clearCache ( ) ;
return "Cancellati " + i + " IntPratica, " + d + " DettPratica" ;
return "Cancellati " + i + " IntPratica, " + d + " DettPratica" ;
}
}
private static String svuotaGroup ( long companyId ) throws SystemException , PortalException {
private static String svuotaGroup ( long companyId ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < Group > groups = null ;
List < Group > groups = null ;
do {
do {
int rimossi = 0 ;
groups = GroupLocalServiceUtil . getGroups ( start , start + SLICE ) ;
groups = GroupLocalServiceUtil . getGroups ( start , start + SLICE ) ;
for ( Group group : groups ) {
for ( Group group : groups ) {
if ( ! esiste ( group . getClassName ( ) , group . getClassPK ( ) , companyId ) ) {
if ( ! esiste ( group . getClassName ( ) , group . getClassPK ( ) , companyId ) ) {
GroupLocalServiceUtil . deleteGroup ( group ) ;
GroupLocalServiceUtil . deleteGroup ( group ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( groups . size ( ) > 0 ) ;
} while ( groups . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " Group" ;
return "Cancellati " + cancellati + " Group" ;
}
}
private static String svuotaHistoryWorkflowAction ( ) throws SystemException {
private static String svuotaHistoryWorkflowAction ( ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < HistoryWorkflowAction > actions = null ;
List < HistoryWorkflowAction > actions = null ;
do {
do {
int rimossi = 0 ;
actions = HistoryWorkflowActionLocalServiceUtil . getHistoryWorkflowActions ( start , start + SLICE ) ;
actions = HistoryWorkflowActionLocalServiceUtil . getHistoryWorkflowActions ( start , start + SLICE ) ;
for ( HistoryWorkflowAction action : actions ) {
for ( HistoryWorkflowAction action : actions ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , action . getIntPraticaId ( ) )
if ( ! esiste ( INTPRATICA_CLASS_NAME , action . getIntPraticaId ( ) )
| | ! esiste ( DETTPRATICA_CLASS_NAME , action . getDettPraticaId ( ) ) ) {
| | ! esiste ( DETTPRATICA_CLASS_NAME , action . getDettPraticaId ( ) ) ) {
HistoryWorkflowActionLocalServiceUtil . deleteHistoryWorkflowAction ( action ) ;
HistoryWorkflowActionLocalServiceUtil . deleteHistoryWorkflowAction ( action ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( actions . size ( ) > 0 ) ;
} while ( actions . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " HistoryWorkflowAction" ;
return "Cancellati " + cancellati + " HistoryWorkflowAction" ;
}
}
private static String svuotaMBDiscussion ( long companyId ) throws SystemException {
private static String svuotaMBDiscussion ( long companyId ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < MBDiscussion > mbDiscussions = null ;
List < MBDiscussion > mbDiscussions = null ;
do {
do {
int rimossi = 0 ;
mbDiscussions = MBDiscussionLocalServiceUtil . getMBDiscussions ( start , start + SLICE ) ;
mbDiscussions = MBDiscussionLocalServiceUtil . getMBDiscussions ( start , start + SLICE ) ;
for ( MBDiscussion mbDiscussion : mbDiscussions ) {
for ( MBDiscussion mbDiscussion : mbDiscussions ) {
if ( ! esiste ( mbDiscussion . getClassName ( ) , mbDiscussion . getClassPK ( ) , companyId )
if ( ! esiste ( mbDiscussion . getClassName ( ) , mbDiscussion . getClassPK ( ) , companyId )
@ -757,19 +746,20 @@ public class ManutenzioneDatabase {
| | ! esiste ( GROUP_CLASS_NAME , mbDiscussion . getGroupId ( ) ) ) {
| | ! esiste ( GROUP_CLASS_NAME , mbDiscussion . getGroupId ( ) ) ) {
MBDiscussionLocalServiceUtil . deleteMBDiscussion ( mbDiscussion ) ;
MBDiscussionLocalServiceUtil . deleteMBDiscussion ( mbDiscussion ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( mbDiscussions . size ( ) > 0 ) ;
} while ( mbDiscussions . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " MBDiscussion" ;
return "Cancellati " + cancellati + " MBDiscussion" ;
}
}
private static String svuotaMBMessage ( long companyId ) throws SystemException {
private static String svuotaMBMessage ( long companyId ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < MBMessage > mbMessages = null ;
List < MBMessage > mbMessages = null ;
do {
do {
int rimossi = 0 ;
mbMessages = MBMessageLocalServiceUtil . getMBMessages ( start , start + SLICE ) ;
mbMessages = MBMessageLocalServiceUtil . getMBMessages ( start , start + SLICE ) ;
for ( MBMessage mbMessage : mbMessages ) {
for ( MBMessage mbMessage : mbMessages ) {
if ( ! esiste ( mbMessage . getClassName ( ) , mbMessage . getClassPK ( ) , companyId )
if ( ! esiste ( mbMessage . getClassName ( ) , mbMessage . getClassPK ( ) , companyId )
@ -777,38 +767,40 @@ public class ManutenzioneDatabase {
| | ! esiste ( GROUP_CLASS_NAME , mbMessage . getGroupId ( ) ) ) {
| | ! esiste ( GROUP_CLASS_NAME , mbMessage . getGroupId ( ) ) ) {
MBMessageLocalServiceUtil . deleteMBMessage ( mbMessage ) ;
MBMessageLocalServiceUtil . deleteMBMessage ( mbMessage ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( mbMessages . size ( ) > 0 ) ;
} while ( mbMessages . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " MBMessage" ;
return "Cancellati " + cancellati + " MBMessage" ;
}
}
private static String svuotaMBThread ( ) throws SystemException {
private static String svuotaMBThread ( ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < MBThread > mbThreads = null ;
List < MBThread > mbThreads = null ;
do {
do {
int rimossi = 0 ;
mbThreads = MBThreadLocalServiceUtil . getMBThreads ( start , start + SLICE ) ;
mbThreads = MBThreadLocalServiceUtil . getMBThreads ( start , start + SLICE ) ;
for ( MBThread mbThread : mbThreads ) {
for ( MBThread mbThread : mbThreads ) {
if ( ! esiste ( MBMESSAGE_CLASS_NAME , mbThread . getRootMessageId ( ) )
if ( ! esiste ( MBMESSAGE_CLASS_NAME , mbThread . getRootMessageId ( ) )
| | ! esiste ( GROUP_CLASS_NAME , mbThread . getGroupId ( ) ) ) {
| | ! esiste ( GROUP_CLASS_NAME , mbThread . getGroupId ( ) ) ) {
MBThreadLocalServiceUtil . deleteMBThread ( mbThread ) ;
MBThreadLocalServiceUtil . deleteMBThread ( mbThread ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( mbThreads . size ( ) > 0 ) ;
} while ( mbThreads . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " MBThread" ;
return "Cancellati " + cancellati + " MBThread" ;
}
}
private static String svuotaPagamento ( long companyId ) throws SystemException , PortalException {
private static String svuotaPagamento ( long companyId ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < Pagamento > pagamenti = null ;
List < Pagamento > pagamenti = null ;
do {
do {
int rimossi = 0 ;
pagamenti = PagamentoLocalServiceUtil . getPagamentos ( start , start + SLICE ) ;
pagamenti = PagamentoLocalServiceUtil . getPagamentos ( start , start + SLICE ) ;
for ( Pagamento pagamento : pagamenti ) {
for ( Pagamento pagamento : pagamenti ) {
if ( ! esiste ( pagamento . getClassName ( ) , pagamento . getClassPk ( ) , companyId )
if ( ! esiste ( pagamento . getClassName ( ) , pagamento . getClassPk ( ) , companyId )
@ -816,19 +808,20 @@ public class ManutenzioneDatabase {
deleteFileEntry ( pagamento . getFileEntryId ( ) ) ;
deleteFileEntry ( pagamento . getFileEntryId ( ) ) ;
PagamentoLocalServiceUtil . deletePagamento ( pagamento ) ;
PagamentoLocalServiceUtil . deletePagamento ( pagamento ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( pagamenti . size ( ) > 0 ) ;
} while ( pagamenti . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " Pagamento" ;
return "Cancellati " + cancellati + " Pagamento" ;
}
}
private static String svuotaParereGeologo ( ) throws SystemException {
private static String svuotaParereGeologo ( ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < ParereGeologo > pareriGeologo = null ;
List < ParereGeologo > pareriGeologo = null ;
do {
do {
int rimossi = 0 ;
pareriGeologo = ParereGeologoLocalServiceUtil . getParereGeologos ( start , start + SLICE ) ;
pareriGeologo = ParereGeologoLocalServiceUtil . getParereGeologos ( start , start + SLICE ) ;
for ( ParereGeologo parereGeologo : pareriGeologo ) {
for ( ParereGeologo parereGeologo : pareriGeologo ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , parereGeologo . getIntPraticaId ( ) )
if ( ! esiste ( INTPRATICA_CLASS_NAME , parereGeologo . getIntPraticaId ( ) )
@ -836,55 +829,58 @@ public class ManutenzioneDatabase {
deleteFileEntry ( parereGeologo . getFileEntryId ( ) ) ;
deleteFileEntry ( parereGeologo . getFileEntryId ( ) ) ;
ParereGeologoLocalServiceUtil . deleteParereGeologo ( parereGeologo ) ;
ParereGeologoLocalServiceUtil . deleteParereGeologo ( parereGeologo ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( pareriGeologo . size ( ) > 0 ) ;
} while ( pareriGeologo . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " ParereGeologo" ;
return "Cancellati " + cancellati + " ParereGeologo" ;
}
}
private static String svuotaRatingsEntry ( ) throws SystemException {
private static String svuotaRatingsEntry ( ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < RatingsEntry > entries = null ;
List < RatingsEntry > entries = null ;
do {
do {
int rimossi = 0 ;
entries = RatingsEntryLocalServiceUtil . getRatingsEntries ( start , start + SLICE ) ;
entries = RatingsEntryLocalServiceUtil . getRatingsEntries ( start , start + SLICE ) ;
for ( RatingsEntry entry : entries ) {
for ( RatingsEntry entry : entries ) {
if ( ! esiste ( entry . getClassName ( ) , entry . getClassPK ( ) ) ) {
if ( ! esiste ( entry . getClassName ( ) , entry . getClassPK ( ) ) ) {
RatingsEntryLocalServiceUtil . deleteRatingsEntry ( entry ) ;
RatingsEntryLocalServiceUtil . deleteRatingsEntry ( entry ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( entries . size ( ) > 0 ) ;
} while ( entries . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " RatingsEntry" ;
return "Cancellati " + cancellati + " RatingsEntry" ;
}
}
private static String svuotaRatingsStats ( long companyId ) throws SystemException {
private static String svuotaRatingsStats ( long companyId ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < RatingsStats > ratingsStatses = null ;
List < RatingsStats > ratingsStatses = null ;
do {
do {
int rimossi = 0 ;
ratingsStatses = RatingsStatsLocalServiceUtil . getRatingsStatses ( start , start + SLICE ) ;
ratingsStatses = RatingsStatsLocalServiceUtil . getRatingsStatses ( start , start + SLICE ) ;
for ( RatingsStats ratingsStats : ratingsStatses ) {
for ( RatingsStats ratingsStats : ratingsStatses ) {
if ( ! esiste ( ratingsStats . getClassName ( ) , ratingsStats . getClassPK ( ) , companyId ) ) {
if ( ! esiste ( ratingsStats . getClassName ( ) , ratingsStats . getClassPK ( ) , companyId ) ) {
RatingsStatsLocalServiceUtil . deleteRatingsStats ( ratingsStats ) ;
RatingsStatsLocalServiceUtil . deleteRatingsStats ( ratingsStats ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( ratingsStatses . size ( ) > 0 ) ;
} while ( ratingsStatses . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " RatingsStats" ;
return "Cancellati " + cancellati + " RatingsStats" ;
}
}
private static String svuotaResourcePermission ( long companyId ) throws SystemException {
private static String svuotaResourcePermission ( long companyId ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < ResourcePermission > resourcePermissions = null ;
List < ResourcePermission > resourcePermissions = null ;
do {
do {
int rimossi = 0 ;
resourcePermissions = ResourcePermissionLocalServiceUtil . getResourcePermissions ( start , start + SLICE ) ;
resourcePermissions = ResourcePermissionLocalServiceUtil . getResourcePermissions ( start , start + SLICE ) ;
for ( ResourcePermission resourcePermission : resourcePermissions ) {
for ( ResourcePermission resourcePermission : resourcePermissions ) {
long classPK = 0 ;
long classPK = 0 ;
@ -900,23 +896,24 @@ public class ManutenzioneDatabase {
if ( ! esiste ( resourcePermission . getName ( ) , classPK ) ) {
if ( ! esiste ( resourcePermission . getName ( ) , classPK ) ) {
ResourcePermissionLocalServiceUtil . deleteResourcePermission ( resourcePermission ) ;
ResourcePermissionLocalServiceUtil . deleteResourcePermission ( resourcePermission ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
break ;
break ;
}
}
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( resourcePermissions . size ( ) > 0 ) ;
} while ( resourcePermissions . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " ResourcePermission" ;
return "Cancellati " + cancellati + " ResourcePermission" ;
}
}
private static String svuotaSoggetto ( ) throws SystemException , PortalException {
private static String svuotaSoggetto ( ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
int docPraticaCancellati = 0 ;
int docPraticaCancellati = 0 ;
List < Soggetto > soggetti = null ;
List < Soggetto > soggetti = null ;
do {
do {
int rimossi = 0 ;
soggetti = SoggettoLocalServiceUtil . getSoggettos ( start , start + SLICE ) ;
soggetti = SoggettoLocalServiceUtil . getSoggettos ( start , start + SLICE ) ;
for ( Soggetto soggetto : soggetti ) {
for ( Soggetto soggetto : soggetti ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , soggetto . getIntPraticaId ( ) )
if ( ! esiste ( INTPRATICA_CLASS_NAME , soggetto . getIntPraticaId ( ) )
@ -932,75 +929,79 @@ public class ManutenzioneDatabase {
}
}
SoggettoLocalServiceUtil . deleteSoggetto ( soggetto ) ;
SoggettoLocalServiceUtil . deleteSoggetto ( soggetto ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( soggetti . size ( ) > 0 ) ;
} while ( soggetti . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " Soggetto, " + docPraticaCancellati + " DocPratica" ;
return "Cancellati " + cancellati + " Soggetto, " + docPraticaCancellati + " DocPratica" ;
}
}
private static String svuotaSorteggio ( ) throws SystemException {
private static String svuotaSorteggio ( ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < Sorteggio > sorteggi = null ;
List < Sorteggio > sorteggi = null ;
do {
do {
int rimossi = 0 ;
sorteggi = SorteggioLocalServiceUtil . getSorteggios ( start , start + SLICE ) ;
sorteggi = SorteggioLocalServiceUtil . getSorteggios ( start , start + SLICE ) ;
for ( Sorteggio sorteggio : sorteggi ) {
for ( Sorteggio sorteggio : sorteggi ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , sorteggio . getIntPraticaId ( ) )
if ( ! esiste ( INTPRATICA_CLASS_NAME , sorteggio . getIntPraticaId ( ) )
| | ! esiste ( DETTPRATICA_CLASS_NAME , sorteggio . getDettPraticaId ( ) ) ) {
| | ! esiste ( DETTPRATICA_CLASS_NAME , sorteggio . getDettPraticaId ( ) ) ) {
SorteggioLocalServiceUtil . deleteSorteggio ( sorteggio ) ;
SorteggioLocalServiceUtil . deleteSorteggio ( sorteggio ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( sorteggi . size ( ) > 0 ) ;
} while ( sorteggi . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " Sorteggio" ;
return "Cancellati " + cancellati + " Sorteggio" ;
}
}
private static String svuotaStoricoSoggettoPratica ( ) throws SystemException {
private static String svuotaStoricoSoggettoPratica ( ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < StoricoSoggettoPratica > storicoSoggettiPratiche = null ;
List < StoricoSoggettoPratica > storicoSoggettiPratiche = null ;
do {
do {
int rimossi = 0 ;
storicoSoggettiPratiche = StoricoSoggettoPraticaLocalServiceUtil . getStoricoSoggettoPraticas ( start , start
storicoSoggettiPratiche = StoricoSoggettoPraticaLocalServiceUtil . getStoricoSoggettoPraticas ( start , start
+ SLICE ) ;
+ SLICE ) ;
for ( StoricoSoggettoPratica storicoSoggettoPratica : storicoSoggettiPratiche ) {
for ( StoricoSoggettoPratica storicoSoggettoPratica : storicoSoggettiPratiche ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , storicoSoggettoPratica . getIntPraticaId ( ) ) ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , storicoSoggettoPratica . getIntPraticaId ( ) ) ) {
StoricoSoggettoPraticaLocalServiceUtil . deleteStoricoSoggettoPratica ( storicoSoggettoPratica ) ;
StoricoSoggettoPraticaLocalServiceUtil . deleteStoricoSoggettoPratica ( storicoSoggettoPratica ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( storicoSoggettiPratiche . size ( ) > 0 ) ;
} while ( storicoSoggettiPratiche . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " StoricoSoggettoPratica" ;
return "Cancellati " + cancellati + " StoricoSoggettoPratica" ;
}
}
private static String svuotaSystemEvent ( long companyId ) throws SystemException {
private static String svuotaSystemEvent ( long companyId ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < SystemEvent > systemEvents = null ;
List < SystemEvent > systemEvents = null ;
do {
do {
int rimossi = 0 ;
systemEvents = SystemEventLocalServiceUtil . getSystemEvents ( start , start + SLICE ) ;
systemEvents = SystemEventLocalServiceUtil . getSystemEvents ( start , start + SLICE ) ;
for ( SystemEvent systemEvent : systemEvents ) {
for ( SystemEvent systemEvent : systemEvents ) {
if ( ! esiste ( systemEvent . getClassName ( ) , systemEvent . getClassPK ( ) , companyId ) ) {
if ( ! esiste ( systemEvent . getClassName ( ) , systemEvent . getClassPK ( ) , companyId ) ) {
SystemEventLocalServiceUtil . deleteSystemEvent ( systemEvent ) ;
SystemEventLocalServiceUtil . deleteSystemEvent ( systemEvent ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( systemEvents . size ( ) > 0 ) ;
} while ( systemEvents . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " SystemEvent" ;
return "Cancellati " + cancellati + " SystemEvent" ;
}
}
private static String svuotaSyncDLObject ( ) throws SystemException {
private static String svuotaSyncDLObject ( ) throws SystemException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < SyncDLObject > syncDLObjects = null ;
List < SyncDLObject > syncDLObjects = null ;
do {
do {
int rimossi = 0 ;
syncDLObjects = SyncDLObjectLocalServiceUtil . getSyncDLObjects ( start , start + SLICE ) ;
syncDLObjects = SyncDLObjectLocalServiceUtil . getSyncDLObjects ( start , start + SLICE ) ;
for ( SyncDLObject syncDLObject : syncDLObjects ) {
for ( SyncDLObject syncDLObject : syncDLObjects ) {
String className = null ;
String className = null ;
@ -1015,72 +1016,58 @@ public class ManutenzioneDatabase {
if ( ! esiste ( className , syncDLObject . getTypePK ( ) ) ) {
if ( ! esiste ( className , syncDLObject . getTypePK ( ) ) ) {
SyncDLObjectLocalServiceUtil . deleteSyncDLObject ( syncDLObject ) ;
SyncDLObjectLocalServiceUtil . deleteSyncDLObject ( syncDLObject ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( syncDLObjects . size ( ) > 0 ) ;
} while ( syncDLObjects . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " SyncDLObject" ;
return "Cancellati " + cancellati + " SyncDLObject" ;
}
}
private static String svuotaTempistica ( ) throws SystemException , PortalException {
private static String svuotaTempistica ( ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < Tempistica > tempistiche = null ;
List < Tempistica > tempistiche = null ;
do {
do {
int rimossi = 0 ;
tempistiche = TempisticaLocalServiceUtil . getTempisticas ( start , start + SLICE ) ;
tempistiche = TempisticaLocalServiceUtil . getTempisticas ( start , start + SLICE ) ;
for ( Tempistica tempistica : tempistiche ) {
for ( Tempistica tempistica : tempistiche ) {
if ( ! esiste ( INTPRATICA_CLASS_NAME , tempistica . getIntPraticaId ( ) )
if ( ! esiste ( INTPRATICA_CLASS_NAME , tempistica . getIntPraticaId ( ) )
| | ! esiste ( DETTPRATICA_CLASS_NAME , tempistica . getDettPraticaId ( ) ) ) {
| | ! esiste ( DETTPRATICA_CLASS_NAME , tempistica . getDettPraticaId ( ) ) ) {
TempisticaLocalServiceUtil . deleteTempistica ( tempistica ) ;
TempisticaLocalServiceUtil . deleteTempistica ( tempistica ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( tempistiche . size ( ) > 0 ) ;
} while ( tempistiche . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " Tempistica" ;
return "Cancellati " + cancellati + " Tempistica" ;
}
}
private static List < String > svuotaUser ( long companyId ) throws SystemException , PortalException {
private static String svuotaUser ( long companyId ) throws SystemException , PortalException {
List < String > esito = new ArrayList < > ( ) ;
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < User > users = null ;
List < User > users = null ;
Role adminRole = RoleLocalServiceUtil . getRole ( companyId , RoleConstants . ADMINISTRATOR ) ;
Role adminRole = RoleLocalServiceUtil . getRole ( companyId , RoleConstants . ADMINISTRATOR ) ;
Set < String > soggetti = new HashSet < > ( ) ;
for ( Soggetto soggetto : SoggettoLocalServiceUtil . getSoggettos ( QueryUtil . ALL_POS , QueryUtil . ALL_POS ) ) {
soggetti . add ( soggetto . getCodiceFiscaleDelegato ( ) . toLowerCase ( ) ) ;
soggetti . add ( soggetto . getCodiceFiscale ( ) . toLowerCase ( ) ) ;
}
for ( IntPratica pratica : IntPraticaLocalServiceUtil . getIntPraticas ( QueryUtil . ALL_POS , QueryUtil . ALL_POS ) ) {
soggetti . add ( pratica . getUserName ( ) . toLowerCase ( ) ) ;
}
do {
do {
int rimossi = 0 ;
users = UserLocalServiceUtil . getUsers ( start , start + SLICE ) ;
users = UserLocalServiceUtil . getUsers ( start , start + SLICE ) ;
for ( User user : users ) {
for ( User user : users ) {
if ( soggetti . contains ( user . getScreenName ( ) . toLowerCase ( ) ) | | user . getRoles ( ) . contains ( adminRole )
if ( user . getRoles ( ) . contains ( adminRole ) ) {
| | ( user . getOrganizationIds ( ) . length > 0 ) | | user . getDefaultUser ( ) ) { } else {
_log . info ( "Non cancello utente " + user . getFullName ( ) ) ;
try {
UserLocalServiceUtil . deleteUser ( user ) ;
} catch ( Exception e ) {
esitoLog ( esito , "Errore utente " + user . getFullName ( ) + ": " + e . getMessage ( ) ) ;
}
cancellati + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( users . size ( ) > 0 ) ;
} while ( users . size ( ) > 0 ) ;
esitoLog ( esito , "Cancellati " + cancellati + " User" ) ;
return "Cancellati " + cancellati + " User" ;
return esito ;
}
}
private static String svuotaWorkflowInstance ( ) throws SystemException , PortalException {
private static String svuotaWorkflowInstance ( ) throws SystemException , PortalException {
int start = 0 ;
int start = 0 ;
int cancellati = 0 ;
int cancellati = 0 ;
List < WorkflowInstanceLink > links = null ;
List < WorkflowInstanceLink > links = null ;
do {
do {
int rimossi = 0 ;
links = WorkflowInstanceLinkLocalServiceUtil . getWorkflowInstanceLinks ( start , start + SLICE ) ;
links = WorkflowInstanceLinkLocalServiceUtil . getWorkflowInstanceLinks ( start , start + SLICE ) ;
for ( WorkflowInstanceLink link : links ) {
for ( WorkflowInstanceLink link : links ) {
if ( ! esiste ( link . getClassName ( ) , link . getClassPK ( ) ) ) {
if ( ! esiste ( link . getClassName ( ) , link . getClassPK ( ) ) ) {
@ -1097,20 +1084,19 @@ public class ManutenzioneDatabase {
instance . getWorkflowInstanceId ( ) ) ;
instance . getWorkflowInstanceId ( ) ) ;
}
}
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE ;
start + = SLICE - rimossi ;
} while ( links . size ( ) > 0 ) ;
} while ( links . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " WorkflowInstance" ;
return "Cancellati " + cancellati + " WorkflowInstance" ;
}
}
private static boolean esiste ( String className , long classPK ) throws SystemException {
private static boolean esiste ( String className , long classPK ) throws SystemException {
return esiste ( className , classPK , 0 ) ;
return esiste ( className , classPK , 0 ) ;
}
}
private static boolean esiste ( String className , long classPK , long companyId ) throws SystemException {
private static boolean esiste ( String className , long classPK , long companyId ) throws SystemException {
if ( 0 ! = classPK & & Validator . isNotNull ( className ) ) {
if ( 0 ! = classPK & & Validator . isNotNull ( className ) ) {
try {
try {
if ( ALLEGATOMANUALE_CLASS_NAME . equals ( className ) ) {
if ( ALLEGATOMANUALE_CLASS_NAME . equals ( className ) ) {
@ -1207,7 +1193,7 @@ public class ManutenzioneDatabase {
WorkflowInstanceManagerUtil . getWorkflowInstance ( companyId , classPK ) ;
WorkflowInstanceManagerUtil . getWorkflowInstance ( companyId , classPK ) ;
}
}
} else {
} else {
if ( className . contains ( StringPool . PERIOD ) ) {
if ( className . contains ( "." ) ) {
switch ( className ) {
switch ( className ) {
case "com.liferay.portlet.blogs" :
case "com.liferay.portlet.blogs" :
case "com.liferay.portlet.documentlibrary" :
case "com.liferay.portlet.documentlibrary" :
@ -1230,7 +1216,6 @@ public class ManutenzioneDatabase {
}
}
private static void deleteFileEntry ( long fileEntryId ) throws SystemException {
private static void deleteFileEntry ( long fileEntryId ) throws SystemException {
try {
try {
DLAppLocalServiceUtil . deleteFileEntry ( fileEntryId ) ;
DLAppLocalServiceUtil . deleteFileEntry ( fileEntryId ) ;
} catch ( PortalException e ) { }
} catch ( PortalException e ) { }
@ -1244,7 +1229,6 @@ public class ManutenzioneDatabase {
}
}
private static void esitoLog ( List < String > esito , String msg ) {
private static void esitoLog ( List < String > esito , String msg ) {
_log . info ( msg ) ;
_log . info ( msg ) ;
esito . add ( msg ) ;
esito . add ( msg ) ;
}
}