diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/ManutenzioneDatabase.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/ManutenzioneDatabase.java index aca061de..bf18f88e 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/ManutenzioneDatabase.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/ManutenzioneDatabase.java @@ -41,6 +41,8 @@ import it.tref.liferay.portos.bo.service.SorteggioLocalServiceUtil; import it.tref.liferay.portos.bo.service.StoricoSoggettoPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.TempisticaLocalServiceUtil; import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants; +import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants; +import it.tref.liferay.portos.bo.util.AvvisoUtil; import it.tref.liferay.portos.bo.util.Constants; import it.tref.liferay.portos.mailmanager.model.Email; import it.tref.liferay.portos.mailmanager.model.EmailAttachment; @@ -50,6 +52,9 @@ import it.tref.liferay.portos.mailmanager.service.EmailAttachmentLocalServiceUti import it.tref.liferay.portos.mailmanager.service.EmailLocalServiceUtil; import it.tref.liferay.portos.mailmanager.service.EmailTemplateLocalServiceUtil; +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -58,11 +63,14 @@ import java.util.Set; import com.liferay.portal.kernel.cache.CacheRegistryUtil; import com.liferay.portal.kernel.cache.MultiVMPoolUtil; import com.liferay.portal.kernel.cache.SingleVMPoolUtil; +import com.liferay.portal.kernel.dao.jdbc.DataAccess; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; +import com.liferay.portal.kernel.repository.model.FileEntry; import com.liferay.portal.kernel.servlet.DirectServletRegistryUtil; +import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.StringUtil; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.workflow.WorkflowInstance; @@ -108,6 +116,7 @@ import com.liferay.portlet.documentlibrary.model.DLFileEntryType; import com.liferay.portlet.documentlibrary.model.DLFolder; import com.liferay.portlet.documentlibrary.model.DLSyncConstants; import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil; +import com.liferay.portlet.documentlibrary.service.DLAppServiceUtil; import com.liferay.portlet.documentlibrary.service.DLFileEntryTypeLocalServiceUtil; import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil; import com.liferay.portlet.dynamicdatamapping.model.DDMStructure; @@ -158,11 +167,19 @@ public class ManutenzioneDatabase { public static List pulisci(ServiceContext serviceContext, String mode) throws SystemException, PortalException { List esito = new ArrayList<>(); + long companyId = serviceContext.getCompanyId(); if (mode.contains("!Pulisci!")) { - long companyId = serviceContext.getCompanyId(); esito.addAll(puliziaDocumentLibrary(companyId)); + esitoLog( + esito, + puliziaAllegati(companyId, ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, + ConfigurazioneConstants.ATTACHMENT_FOLDER_ID))); + esitoLog( + esito, + puliziaAllegati(companyId, ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, + AvvisoUtil.getAllTipoDocumentoFolderProps().get(StatoPraticaConstants.CONFORME)))); if (mode.contains("!IntPratica!")) { - esitoLog(esito, svuotaIntPratica()); + esitoLog(esito, svuotaIntPraticaDettPratica()); } if (mode.contains("!User!")) { esitoLog(esito, svuotaUser(companyId)); @@ -172,13 +189,7 @@ public class ManutenzioneDatabase { ConfigurazioneLocalServiceUtil.storeConfig(Constants.NUMERO_PROGETTO_KEY_DB, "1", serviceContext); } - try { - SingleVMPoolUtil.clear(); - MultiVMPoolUtil.clear(); - CacheRegistryUtil.clear(); - DirectServletRegistryUtil.clearServlets(); - } catch (IllegalStateException e) { - } + clearCache(); _log.info("Elaborazione completata correttamente."); } else if (mode.contains("!Integrazioni!")) { SismicaUtil.integrazioniScadute(); @@ -188,6 +199,16 @@ public class ManutenzioneDatabase { return esito; } + private static void clearCache() { + try { + SingleVMPoolUtil.clear(); + MultiVMPoolUtil.clear(); + CacheRegistryUtil.clear(); + DirectServletRegistryUtil.clearServlets(); + } catch (IllegalStateException e) { + } + } + private static List svuotaDatabase(long companyId) throws SystemException, PortalException { List esito = new ArrayList<>(); @@ -298,6 +319,78 @@ public class ManutenzioneDatabase { return esito; } + private static List avvisiFileEntries() throws SystemException { + List result = new ArrayList<>(); + int start = 0; + List avvisi = null; + do { + avvisi = AvvisoLocalServiceUtil.getAvvisos(start, start + SLICE); + for (Avviso avviso : avvisi) { + result.add(avviso.getFileEntryIdBase()); + result.add(avviso.getFileEntryIdProtocollo()); + result.add(avviso.getFileEntryIdInvio()); + } + start += SLICE; + } while (avvisi.size() > 0); + return result; + } + + private static String puliziaAllegati(long companyId, long folderId) throws SystemException, + PortalException { + List avvisiFileEntries = avvisiFileEntries(); + long repositoryId = DLAppLocalServiceUtil.getFolder(folderId).getRepositoryId(); + int start = 0; + int cancellati = 0; + List fileEntries = null; + do { + int rimossi = 0; + fileEntries = DLAppServiceUtil.getFileEntries(repositoryId, folderId, start, start + SLICE); + for (FileEntry fileEntry : fileEntries) { + String[] parti = StringUtil.split(fileEntry.getTitle(), StringPool.UNDERLINE); + String strId1 = parti[0]; + String tipo = StringPool.BLANK; + String strId2 = StringPool.BLANK; + switch (parti.length) { + case 3: + tipo = parti[1]; + strId2 = parti[2]; + break; + case 4: + tipo = parti[1] + StringPool.UNDERLINE + parti[2]; + strId2 = parti[3]; + break; + } + if ((strId1.length() == 10) && (strId2.length() > 0) && SismicaUtil.isLong(strId1) + && SismicaUtil.isLong(strId2)) { + long id1 = Long.parseLong(strId1); + switch (tipo) { + case "AS": + if (!esiste(DETTPRATICA_CLASS_NAME, id1)) { + DLAppLocalServiceUtil.deleteFileEntry(fileEntry.getFileEntryId()); + cancellati++; + rimossi++; + } + break; + case "CO_B": + if (!avvisiFileEntries.contains(fileEntry.getFileEntryId())) { + DLAppLocalServiceUtil.deleteFileEntry(fileEntry.getFileEntryId()); + cancellati++; + rimossi++; + } + break; + default: + _log.info("Tipo sconosciuto " + tipo + " (" + fileEntry.getTitle() + ")"); + break; + } + } else { + _log.info("Nome sconosciuto " + fileEntry.getTitle()); + } + } + start += SLICE - rimossi; + } while (fileEntries.size() > 0); + return "Cancellati " + cancellati + " File orfani"; + } + private static String svuotaAllegatoManuale() throws SystemException { int start = 0; int cancellati = 0; @@ -583,21 +676,19 @@ public class ManutenzioneDatabase { return "Cancellati " + cancellati + " FineLavori"; } - private static String svuotaIntPratica() throws SystemException, PortalException { - int start = 0; - int cancellati = 0; - List intPratiche = null; - do { - int rimossi = 0; - intPratiche = IntPraticaLocalServiceUtil.getIntPraticas(start, start + SLICE); - for (IntPratica intPratica : intPratiche) { - IntPraticaLocalServiceUtil.deleteIntPratica(intPratica, true); - cancellati++; - rimossi++; - } - start += SLICE - rimossi; - } while (intPratiche.size() > 0); - return "Cancellati " + cancellati + " IntPratica"; + // Troncare le tabelle รจ l'unico modo possibile + private static String svuotaIntPraticaDettPratica() { + int i = 0; + int d = 0; + try { + Connection connection = DataAccess.getUpgradeOptimizedConnection(); + Statement s = connection.createStatement(); + i = s.executeUpdate("DELETE FROM portos_bo_intpratica"); + d = s.executeUpdate("DELETE FROM portos_bo_dettpratica"); + } catch (SQLException e) { + } + clearCache(); + return "Cancellati " + i + " IntPratica, " + d + " DettPratica"; } private static String svuotaGroup(long companyId) throws SystemException, PortalException { diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties index 1d29b3cc..5914dd29 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties @@ -13,8 +13,8 @@ ## build.namespace=portos_bo - build.number=2519 - build.date=1604417083352 + build.number=2520 + build.date=1605540160967 build.auto.upgrade=true ## diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/page_riepilogo.jsp b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/page_riepilogo.jsp index bb40c6c1..e3eef794 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/page_riepilogo.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/page_riepilogo.jsp @@ -138,6 +138,42 @@ +
+
+
+ +
+
+
+ <%= LanguageUtil.get(pageContext, "dp-dc-prov") %> +
+
+ <%=BeanPropertiesUtil.getString(provincia, "provincia")%> +
+
+ <%= LanguageUtil.get(pageContext, "dp-dc-comune") %> +
+
+ <%=BeanPropertiesUtil.getString(comune, "denominazione")%> +
+
+ <%= LanguageUtil.get(pageContext, "dp-dc-loc") %> +
+
+ <%=BeanPropertiesUtil.getString(dettPratica, "localita") %> +
+
+ <%= LanguageUtil.get(pageContext, "dp-dc-via") %> +
+
+ <%=BeanPropertiesUtil.getString(dettPratica, "via") %> +
+
+
+
+
+
+