Salvatore La Manna 4 anni fa
parent
commit
1df39ecd3d
  1. 139
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/ManutenzioneDatabase.java
  2. 4
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties
  3. 36
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/page_riepilogo.jsp

139
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<String> pulisci(ServiceContext serviceContext, String mode) throws SystemException,
PortalException {
List<String> 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<String> svuotaDatabase(long companyId) throws SystemException, PortalException {
List<String> esito = new ArrayList<>();
@ -298,6 +319,78 @@ public class ManutenzioneDatabase {
return esito;
}
private static List<Long> avvisiFileEntries() throws SystemException {
List<Long> result = new ArrayList<>();
int start = 0;
List<Avviso> 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<Long> avvisiFileEntries = avvisiFileEntries();
long repositoryId = DLAppLocalServiceUtil.getFolder(folderId).getRepositoryId();
int start = 0;
int cancellati = 0;
List<FileEntry> 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<IntPratica> 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 {

4
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
##

36
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/page_riepilogo.jsp

@ -138,6 +138,42 @@
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-12">
<div class="module-group">
<liferay-ui:panel extended="false" defaultState="open" collapsible="false" title="fascicolo_title_ubicazione" >
<div class="container-fluid">
<div class="row">
<div class="col-sm-6 col-md-3">
<%= LanguageUtil.get(pageContext, "dp-dc-prov") %>
</div>
<div class="col-sm-6 col-md-3">
<strong><%=BeanPropertiesUtil.getString(provincia, "provincia")%></strong>
</div>
<div class="col-sm-6 col-md-3">
<%= LanguageUtil.get(pageContext, "dp-dc-comune") %>
</div>
<div class="col-sm-6 col-md-3">
<strong><%=BeanPropertiesUtil.getString(comune, "denominazione")%></strong>
</div>
<div class="col-sm-6 col-md-3">
<%= LanguageUtil.get(pageContext, "dp-dc-loc") %>
</div>
<div class="col-sm-6 col-md-3">
<strong><%=BeanPropertiesUtil.getString(dettPratica, "localita") %></strong>
</div>
<div class="col-sm-6 col-md-3">
<%= LanguageUtil.get(pageContext, "dp-dc-via") %>
</div>
<div class="col-sm-6 col-md-3">
<strong><%=BeanPropertiesUtil.getString(dettPratica, "via") %></strong>
</div>
</div>
</div>
</liferay-ui:panel>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-12">

Caricamento…
Annulla
Salva