From 3834130499ad1d5e0003400e01f06173eb622e0d Mon Sep 17 00:00:00 2001 From: Salvatore La Manna Date: Tue, 22 Dec 2020 09:34:51 +0100 Subject: [PATCH] Correzione bug visualizzazione per allegati con classi diverse da DettPratica, FineLavori o Collaudo --- .../sismica/bo/util/ManutenzioneDatabase.java | 113 +++++++++++++++++- .../service/impl/AvvisoLocalServiceImpl.java | 10 -- .../docroot/html/allegatipratica/view.jsp | 12 +- 3 files changed, 121 insertions(+), 14 deletions(-) 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 ff0261fc..858d18ba 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 @@ -15,6 +15,7 @@ import it.tref.liferay.portos.bo.model.DettPratica; import it.tref.liferay.portos.bo.model.DocAggiuntiva; import it.tref.liferay.portos.bo.model.DocPratica; import it.tref.liferay.portos.bo.model.FineLavori; +import it.tref.liferay.portos.bo.model.HistoryWorkflowAction; import it.tref.liferay.portos.bo.model.IntPratica; import it.tref.liferay.portos.bo.model.Pagamento; import it.tref.liferay.portos.bo.model.ParereGeologo; @@ -33,6 +34,7 @@ import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DocAggiuntivaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.FineLavoriLocalServiceUtil; +import it.tref.liferay.portos.bo.service.HistoryWorkflowActionLocalServiceUtil; import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.PagamentoLocalServiceUtil; import it.tref.liferay.portos.bo.service.ParereGeologoLocalServiceUtil; @@ -91,6 +93,7 @@ import com.liferay.portal.model.RoleConstants; import com.liferay.portal.model.SystemEvent; import com.liferay.portal.model.User; import com.liferay.portal.model.UserPersonalSite; +import com.liferay.portal.model.WorkflowInstanceLink; import com.liferay.portal.service.CompanyLocalServiceUtil; import com.liferay.portal.service.ContactLocalServiceUtil; import com.liferay.portal.service.EmailAddressLocalServiceUtil; @@ -105,6 +108,7 @@ import com.liferay.portal.service.RoleLocalServiceUtil; import com.liferay.portal.service.ServiceContext; import com.liferay.portal.service.SystemEventLocalServiceUtil; import com.liferay.portal.service.UserLocalServiceUtil; +import com.liferay.portal.service.WorkflowInstanceLinkLocalServiceUtil; import com.liferay.portlet.asset.model.AssetEntry; import com.liferay.portlet.asset.model.AssetTag; import com.liferay.portlet.asset.model.AssetVocabulary; @@ -137,7 +141,9 @@ import com.liferay.portlet.messageboards.model.MBThread; import com.liferay.portlet.messageboards.service.MBDiscussionLocalServiceUtil; import com.liferay.portlet.messageboards.service.MBMessageLocalServiceUtil; import com.liferay.portlet.messageboards.service.MBThreadLocalServiceUtil; +import com.liferay.portlet.ratings.model.RatingsEntry; import com.liferay.portlet.ratings.model.RatingsStats; +import com.liferay.portlet.ratings.service.RatingsEntryLocalServiceUtil; import com.liferay.portlet.ratings.service.RatingsStatsLocalServiceUtil; import com.liferay.portlet.wiki.model.WikiNode; import com.liferay.portlet.wiki.service.WikiNodeLocalServiceUtil; @@ -215,18 +221,22 @@ public class ManutenzioneDatabase { esitoLog(esito, svuotaEmailAttachment()); esitoLog(esito, svuotaFineLavori()); esitoLog(esito, svuotaGroup(companyId)); + esitoLog(esito, svuotaHistoryWorkflowAction()); esitoLog(esito, svuotaMBDiscussion(companyId)); esitoLog(esito, svuotaMBMessage(companyId)); esitoLog(esito, svuotaMBThread()); esitoLog(esito, svuotaPagamento(companyId)); esitoLog(esito, svuotaParereGeologo()); + esitoLog(esito, svuotaRatingsEntry()); esitoLog(esito, svuotaRatingsStats(companyId)); esitoLog(esito, svuotaResourcePermission(companyId)); esitoLog(esito, svuotaSoggetto()); + esitoLog(esito, svuotaSorteggio()); esitoLog(esito, svuotaStoricoSoggettoPratica()); esitoLog(esito, svuotaSyncDLObject()); esitoLog(esito, svuotaSystemEvent(companyId)); esitoLog(esito, svuotaTempistica()); + esitoLog(esito, svuotaWorkflowInstance()); return esito; } @@ -333,7 +343,8 @@ public class ManutenzioneDatabase { int rimossi = 0; fileEntries = DLAppServiceUtil.getFileEntries(repositoryId, folderId, start, start + SLICE); for (FileEntry fileEntry : fileEntries) { - String[] parti = StringUtil.split(fileEntry.getTitle(), '_'); + String[] parti = StringUtil.split(fileEntry.getTitle() + .replaceAll("\\.p7m$", StringPool.BLANK), '_'); String strId1 = parti[0]; String tipo = StringPool.BLANK; String strId2 = StringPool.BLANK; @@ -346,6 +357,11 @@ public class ManutenzioneDatabase { tipo = parti[1] + StringPool.UNDERLINE + parti[2]; strId2 = parti[3]; break; + case 5: + if (parti[4].equals("protocollato")) { + tipo = parti[1] + StringPool.UNDERLINE + parti[2]; + strId2 = parti[3]; + } } if ((strId1.length() == 10) && (strId2.length() > 0) && SismicaUtil.isLong(strId1) && SismicaUtil.isLong(strId2)) { @@ -358,7 +374,11 @@ public class ManutenzioneDatabase { rimossi++; } break; + case "AI_B": case "CO_B": + case "IN_B": + case "IN_F": + case "MA_F": if (!avvisiFileEntries.contains(fileEntry.getFileEntryId())) { DLAppLocalServiceUtil.deleteFileEntry(fileEntry.getFileEntryId()); cancellati++; @@ -366,6 +386,7 @@ public class ManutenzioneDatabase { } break; default: + _log.info("T " + System.currentTimeMillis()); _log.info("Tipo sconosciuto " + tipo + " (" + fileEntry.getTitle() + ")"); break; } @@ -697,6 +718,26 @@ public class ManutenzioneDatabase { return "Cancellati " + cancellati + " Group"; } + private static String svuotaHistoryWorkflowAction() throws SystemException { + int start = 0; + int cancellati = 0; + List actions = null; + do { + int rimossi = 0; + actions = HistoryWorkflowActionLocalServiceUtil.getHistoryWorkflowActions(start, start + SLICE); + for (HistoryWorkflowAction action : actions) { + if (!esiste(INTPRATICA_CLASS_NAME, action.getIntPraticaId()) + || !esiste(DETTPRATICA_CLASS_NAME, action.getDettPraticaId())) { + HistoryWorkflowActionLocalServiceUtil.deleteHistoryWorkflowAction(action); + cancellati++; + rimossi++; + } + } + start += SLICE - rimossi; + } while (actions.size() > 0); + return "Cancellati " + cancellati + " HistoryWorkflowAction"; + } + private static String svuotaMBDiscussion(long companyId) throws SystemException { int start = 0; int cancellati = 0; @@ -801,6 +842,25 @@ public class ManutenzioneDatabase { return "Cancellati " + cancellati + " ParereGeologo"; } + private static String svuotaRatingsEntry() throws SystemException { + int start = 0; + int cancellati = 0; + List entries = null; + do { + int rimossi = 0; + entries = RatingsEntryLocalServiceUtil.getRatingsEntries(start, start + SLICE); + for (RatingsEntry entry : entries) { + if (!esiste(entry.getClassName(), entry.getClassPK())) { + RatingsEntryLocalServiceUtil.deleteRatingsEntry(entry); + cancellati++; + rimossi++; + } + } + start += SLICE - rimossi; + } while (entries.size() > 0); + return "Cancellati " + cancellati + " RatingsEntry"; + } + private static String svuotaRatingsStats(long companyId) throws SystemException { int start = 0; int cancellati = 0; @@ -885,6 +945,26 @@ public class ManutenzioneDatabase { return "Cancellati " + cancellati + " Soggetto, " + docPraticaCancellati + " DocPratica"; } + private static String svuotaSorteggio() throws SystemException { + int start = 0; + int cancellati = 0; + List sorteggi = null; + do { + int rimossi = 0; + sorteggi = SorteggioLocalServiceUtil.getSorteggios(start, start + SLICE); + for (Sorteggio sorteggio : sorteggi) { + if (!esiste(INTPRATICA_CLASS_NAME, sorteggio.getIntPraticaId()) + || !esiste(DETTPRATICA_CLASS_NAME, sorteggio.getDettPraticaId())) { + SorteggioLocalServiceUtil.deleteSorteggio(sorteggio); + cancellati++; + rimossi++; + } + } + start += SLICE - rimossi; + } while (sorteggi.size() > 0); + return "Cancellati " + cancellati + " Sorteggio"; + } + private static String svuotaStoricoSoggettoPratica() throws SystemException { int start = 0; int cancellati = 0; @@ -991,6 +1071,37 @@ public class ManutenzioneDatabase { return "Cancellati " + cancellati + " User"; } + private static String svuotaWorkflowInstance() throws SystemException, PortalException { + int start = 0; + int cancellati = 0; + List links = null; + do { + int rimossi = 0; + links = WorkflowInstanceLinkLocalServiceUtil.getWorkflowInstanceLinks(start, start + SLICE); + for (WorkflowInstanceLink link : links) { + if (!esiste(link.getClassName(), link.getClassPK())) { + _log.info("Manca " + link.getClassName() + " " + link.getClassPK()); + WorkflowInstance instance = null; + try { + instance = WorkflowInstanceManagerUtil.getWorkflowInstance(link.getCompanyId(), + link.getWorkflowInstanceId()); + } catch (PortalException e) { + } + if (Validator.isNull(instance)) { + WorkflowInstanceLinkLocalServiceUtil.deleteWorkflowInstanceLink(link); + } else { + WorkflowInstanceManagerUtil.deleteWorkflowInstance(link.getCompanyId(), + instance.getWorkflowInstanceId()); + } + cancellati++; + rimossi++; + } + } + start += SLICE - rimossi; + } while (links.size() > 0); + return "Cancellati " + cancellati + " WorkflowInstance"; + } + private static boolean esiste(String className, long classPK) throws SystemException { return esiste(className, classPK, 0); } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AvvisoLocalServiceImpl.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AvvisoLocalServiceImpl.java index 4bbe83b1..370a211d 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AvvisoLocalServiceImpl.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AvvisoLocalServiceImpl.java @@ -995,16 +995,6 @@ public class AvvisoLocalServiceImpl extends AvvisoLocalServiceBaseImpl { public String getFileNameAvviso(long classPk, String tipoDocumento, Long idAvviso, String doc) { - // boolean docBase, boolean docFirma, boolean docControfirma - // String doc = StringPool.BLANK; - // if (docBase) { - // doc = "B"; - // } else if (docFirma) { - // doc = "F"; - // } else if (docControfirma) { - // doc = "C"; - // } - String filename = StringUtils.leftPad(String.valueOf(classPk), 10, '0') + (Validator.isNotNull(tipoDocumento) ? StringPool.UNDERLINE + tipoDocumento : StringPool.BLANK) + StringPool.UNDERLINE + doc + StringPool.UNDERLINE diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/allegatipratica/view.jsp b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/allegatipratica/view.jsp index 10b99f69..352b204f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/allegatipratica/view.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/allegatipratica/view.jsp @@ -335,7 +335,10 @@ for (String codiceDoc:tipologiaAllegati) { if (!dettPraticas.containsKey(pk)) { dettPraticas.put(pk, DettPraticaLocalServiceUtil.fetchDettPratica(pk)); } - adding = dettPraticas.get(pk).getFullDescription(); + DettPratica dettPratica = dettPraticas.get(pk); + if (Validator.isNotNull(dettPratica)) { + adding = dettPratica.getFullDescription(); + } } out.print(adding); %> @@ -349,7 +352,10 @@ for (String codiceDoc:tipologiaAllegati) { if (!dettPraticas.containsKey(pk)) { dettPraticas.put(pk, DettPraticaLocalServiceUtil.fetchDettPratica(pk)); } - out.print(dettPraticas.get(pk).getFullDescription()); + DettPratica dettPratica = dettPraticas.get(pk); + if (Validator.isNotNull(dettPratica)) { + out.print(dettPratica.getFullDescription()); + } } %> @@ -364,7 +370,7 @@ for (String codiceDoc:tipologiaAllegati) { dettPraticas.put(pk, DettPraticaLocalServiceUtil.fetchDettPratica(pk)); } DettPratica dett = dettPraticas.get(pk); - if (dett != null) { + if (Validator.isNotNull(dett)) { if (dett.getIntegrazione() == 0) { out.print("Pratica Originale"); } else {