@ -64,6 +64,7 @@ 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 ;
@ -164,6 +165,9 @@ 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 ) ) ;
@ -180,9 +184,9 @@ public class ManutenzioneDatabase {
esitoLog ( esito , svuotaIntPraticaDettPratica ( ) ) ;
esitoLog ( esito , svuotaIntPraticaDettPratica ( ) ) ;
}
}
if ( mode . contains ( "!User!" ) ) {
if ( mode . contains ( "!User!" ) ) {
esitoLog ( esito , svuotaUser ( companyId ) ) ;
esito . addAll ( svuotaUser ( companyId ) ) ;
}
}
esitoLog ( esito , svuotaDatabase ( companyId ) ) ;
esito . addAll ( 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 ) ;
}
}
@ -195,7 +199,30 @@ 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 ( ) ;
@ -209,7 +236,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 ( ) ) ;
@ -223,28 +250,29 @@ 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 ) ;
@ -254,7 +282,6 @@ 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 ( ) ;
@ -279,7 +306,6 @@ 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 ( ) ) ;
@ -294,14 +320,13 @@ 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 ( ) - rimossi ;
start + = folders . size ( ) ;
} 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 ) {
@ -314,6 +339,7 @@ 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 ;
@ -330,13 +356,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 ) , '_' ) ;
@ -366,7 +392,6 @@ 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" :
@ -377,7 +402,6 @@ 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 :
@ -389,17 +413,17 @@ public class ManutenzioneDatabase {
_log . info ( "Nome sconosciuto " + fileEntry . getTitle ( ) ) ;
_log . info ( "Nome sconosciuto " + fileEntry . getTitle ( ) ) ;
}
}
}
}
start + = SLICE - rimossi ;
start + = SLICE ;
} 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 ( ) )
@ -408,20 +432,19 @@ public class ManutenzioneDatabase {
deleteFileEntry ( allegatoManuale . getFileEntryId ( ) ) ;
deleteFileEntry ( allegatoManuale . getFileEntryId ( ) ) ;
AllegatoManualeLocalServiceUtil . deleteAllegatoManuale ( allegatoManuale ) ;
AllegatoManualeLocalServiceUtil . deleteAllegatoManuale ( allegatoManuale ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE - rimossi ;
start + = SLICE ;
} 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 ( ) ;
@ -431,20 +454,19 @@ 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 - rimossi ;
start + = SLICE ;
} 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 ( ) )
@ -452,20 +474,19 @@ public class ManutenzioneDatabase {
deleteFileEntry ( asseverazione . getFileEntryId ( ) ) ;
deleteFileEntry ( asseverazione . getFileEntryId ( ) ) ;
AsseverazioneLocalServiceUtil . deleteAsseverazione ( asseverazione ) ;
AsseverazioneLocalServiceUtil . deleteAsseverazione ( asseverazione ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE - rimossi ;
start + = SLICE ;
} 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 )
@ -475,117 +496,111 @@ public class ManutenzioneDatabase {
deleteFileEntry ( avviso . getFileEntryIdProtocollo ( ) ) ;
deleteFileEntry ( avviso . getFileEntryIdProtocollo ( ) ) ;
AvvisoLocalServiceUtil . deleteAvviso ( avviso ) ;
AvvisoLocalServiceUtil . deleteAvviso ( avviso ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 ( ) )
@ -593,20 +608,19 @@ public class ManutenzioneDatabase {
deleteFileEntry ( docAggiuntiva . getFileEntryId ( ) ) ;
deleteFileEntry ( docAggiuntiva . getFileEntryId ( ) ) ;
DocAggiuntivaLocalServiceUtil . deleteDocAggiuntiva ( docAggiuntiva ) ;
DocAggiuntivaLocalServiceUtil . deleteDocAggiuntiva ( docAggiuntiva ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE - rimossi ;
start + = SLICE ;
} 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 )
@ -614,74 +628,71 @@ public class ManutenzioneDatabase {
deleteFileEntry ( docPratica . getDlFileEntryId ( ) ) ;
deleteFileEntry ( docPratica . getDlFileEntryId ( ) ) ;
DocPraticaLocalServiceUtil . deleteDocPratica ( docPratica ) ;
DocPraticaLocalServiceUtil . deleteDocPratica ( docPratica ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 {
@ -689,56 +700,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 - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 )
@ -746,20 +757,19 @@ 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 - rimossi ;
start + = SLICE ;
} 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 )
@ -767,40 +777,38 @@ 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 - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 )
@ -808,20 +816,19 @@ public class ManutenzioneDatabase {
deleteFileEntry ( pagamento . getFileEntryId ( ) ) ;
deleteFileEntry ( pagamento . getFileEntryId ( ) ) ;
PagamentoLocalServiceUtil . deletePagamento ( pagamento ) ;
PagamentoLocalServiceUtil . deletePagamento ( pagamento ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE - rimossi ;
start + = SLICE ;
} 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 ( ) )
@ -829,58 +836,55 @@ public class ManutenzioneDatabase {
deleteFileEntry ( parereGeologo . getFileEntryId ( ) ) ;
deleteFileEntry ( parereGeologo . getFileEntryId ( ) ) ;
ParereGeologoLocalServiceUtil . deleteParereGeologo ( parereGeologo ) ;
ParereGeologoLocalServiceUtil . deleteParereGeologo ( parereGeologo ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 ;
@ -896,24 +900,23 @@ 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 - rimossi ;
start + = SLICE ;
} 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 ( ) )
@ -929,79 +932,75 @@ public class ManutenzioneDatabase {
}
}
SoggettoLocalServiceUtil . deleteSoggetto ( soggetto ) ;
SoggettoLocalServiceUtil . deleteSoggetto ( soggetto ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} 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 ;
@ -1016,58 +1015,72 @@ public class ManutenzioneDatabase {
if ( ! esiste ( className , syncDLObject . getTypePK ( ) ) ) {
if ( ! esiste ( className , syncDLObject . getTypePK ( ) ) ) {
SyncDLObjectLocalServiceUtil . deleteSyncDLObject ( syncDLObject ) ;
SyncDLObjectLocalServiceUtil . deleteSyncDLObject ( syncDLObject ) ;
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE - rimossi ;
start + = SLICE ;
} 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 - rimossi ;
start + = SLICE ;
} while ( tempistiche . size ( ) > 0 ) ;
} while ( tempistiche . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " Tempistica" ;
return "Cancellati " + cancellati + " Tempistica" ;
}
}
private static String svuotaUser ( long companyId ) throws SystemException , PortalException {
private static List < 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 ( user . getRoles ( ) . contains ( adminRole ) ) {
if ( soggetti . contains ( user . getScreenName ( ) . toLowerCase ( ) ) | | user . getRoles ( ) . contains ( adminRole )
_log . info ( "Non cancello utente " + user . getFullName ( ) ) ;
| | ( user . getOrganizationIds ( ) . length > 0 ) | | user . getDefaultUser ( ) ) { } else {
try {
UserLocalServiceUtil . deleteUser ( user ) ;
} catch ( Exception e ) {
esitoLog ( esito , "Errore utente " + user . getFullName ( ) + ": " + e . getMessage ( ) ) ;
}
cancellati + + ;
}
}
}
}
start + = SLICE - rimossi ;
start + = SLICE ;
} while ( users . size ( ) > 0 ) ;
} while ( users . size ( ) > 0 ) ;
return "Cancellati " + cancellati + " User" ;
esitoLog ( esito , "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 ( ) ) ) {
@ -1084,19 +1097,20 @@ public class ManutenzioneDatabase {
instance . getWorkflowInstanceId ( ) ) ;
instance . getWorkflowInstanceId ( ) ) ;
}
}
cancellati + + ;
cancellati + + ;
rimossi + + ;
}
}
}
}
start + = SLICE - rimossi ;
start + = SLICE ;
} 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 ) ) {
@ -1193,7 +1207,7 @@ public class ManutenzioneDatabase {
WorkflowInstanceManagerUtil . getWorkflowInstance ( companyId , classPK ) ;
WorkflowInstanceManagerUtil . getWorkflowInstance ( companyId , classPK ) ;
}
}
} else {
} else {
if ( className . contains ( "." ) ) {
if ( className . contains ( StringPool . PERIOD ) ) {
switch ( className ) {
switch ( className ) {
case "com.liferay.portlet.blogs" :
case "com.liferay.portlet.blogs" :
case "com.liferay.portlet.documentlibrary" :
case "com.liferay.portlet.documentlibrary" :
@ -1216,6 +1230,7 @@ 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 ) { }
@ -1229,6 +1244,7 @@ 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 ) ;
}
}