Sfoglia il codice sorgente

Inizio fix generazione documenti

master
Salvatore La Manna 4 anni fa
parent
commit
d2b5e1faa8
  1. BIN
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar
  2. BIN
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar
  3. 378
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/PuliziaDatabase.java
  4. 61
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/SismicaUtil.java

BIN
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar

File binario non mostrato.

BIN
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar

File binario non mostrato.

378
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/PuliziaDatabase.java

@ -99,10 +99,6 @@ public class PuliziaDatabase {
public static List<String> pulisci2(ServiceContext serviceContext) { public static List<String> pulisci2(ServiceContext serviceContext) {
List<String> esito = new ArrayList<>(); List<String> esito = new ArrayList<>();
esito.addAll(puliziaPreliminare());
esito.addAll(puliziaDocumentLibrary());
esito.addAll(svuotaDatabase(serviceContext));
try { try {
SingleVMPoolUtil.clear(); SingleVMPoolUtil.clear();
MultiVMPoolUtil.clear(); MultiVMPoolUtil.clear();
@ -115,380 +111,6 @@ public class PuliziaDatabase {
return esito; return esito;
} }
private static List<String> puliziaPreliminare() {
List<String> esito = new ArrayList<>();
try {
Connection connection = DataAccess.getUpgradeOptimizedConnection();
Statement s = connection.createStatement();
int rows = s.executeUpdate("DELETE FROM portos_bo_intpratica WHERE intpraticaid IN ("
+ "SELECT intpraticaid FROM portos_bo_intpratica i "
+ "LEFT JOIN group_ g ON i.groupid=g.groupid WHERE g.groupid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_intpratica");
rows = s.executeUpdate("DELETE FROM portos_bo_dettpratica WHERE dettpraticaid IN ("
+ "SELECT dettpraticaid FROM portos_bo_dettpratica d "
+ "LEFT JOIN portos_bo_intpratica i ON d.intpraticaid=i.intpraticaid "
+ "WHERE i.intpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_dettpratica");
rows = s.executeUpdate("DELETE FROM portos_bo_controllopratica WHERE controllopraticaid IN ("
+ "SELECT controllopraticaid FROM portos_bo_controllopratica c "
+ "LEFT JOIN portos_bo_intpratica i ON c.intpraticaid=i.intpraticaid "
+ "WHERE i.intpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_controllopratica");
rows = s.executeUpdate("DELETE FROM portos_bo_collaudo WHERE collaudoid IN ("
+ "SELECT collaudoid FROM portos_bo_collaudo c "
+ "LEFT JOIN portos_bo_intpratica i ON c.intpraticaid=i.intpraticaid "
+ "WHERE i.intpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_collaudo");
rows = s.executeUpdate("DELETE FROM portos_bo_delega WHERE delegaid IN ("
+ "SELECT delegaid FROM portos_bo_delega d "
+ "LEFT JOIN portos_bo_dettpratica dp ON d.dettpraticaid=dp.dettpraticaid "
+ "WHERE dp.dettpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_delega");
rows = s.executeUpdate("DELETE FROM portos_bo_finelavori WHERE finelavoriid IN ("
+ "SELECT finelavoriid FROM portos_bo_finelavori f "
+ "LEFT JOIN portos_bo_intpratica i ON f.intpraticaid=i.intpraticaid "
+ "WHERE i.intpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_finelavori");
rows = s.executeUpdate("DELETE FROM portos_bo_soggetto WHERE soggettoid IN ("
+ "SELECT soggettoid FROM portos_bo_soggetto s "
+ "LEFT JOIN portos_bo_dettpratica d ON s.dettpraticaid=d.dettpraticaid "
+ "WHERE d.dettpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_soggetto");
int cancellati = 0;
int start = 0;
int totali = 0;
List<DocAggiuntiva> docs = null;
do {
docs = DocAggiuntivaLocalServiceUtil.getDocAggiuntivas(start, start + SLICE);
int rimossi = 0;
for (DocAggiuntiva doc : docs) {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(doc.getIntPraticaId());
DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(doc
.getDettPraticaId());
if (Validator.isNull(intPratica) || Validator.isNull(dettPratica)) {
DocAggiuntivaLocalServiceUtil.deleteDocAggiuntiva(doc);
cancellati++;
rimossi++;
}
}
totali += docs.size();
start += SLICE - rimossi;
} while (docs.size() > 0);
esitoLog(esito, "Analizzati " + totali + " DocAggiuntiva, cancellati " + cancellati);
cancellati = 0;
start = 0;
totali = 0;
List<DocPratica> docs2 = null;
do {
docs2 = DocPraticaLocalServiceUtil.getDocPraticas(start, start + SLICE);
int rimossi = 0;
for (DocPratica doc : docs2) {
boolean rimuovi = false;
if (Collaudo.class.getName().equals(doc.getClassName())) {
Collaudo collaudo = null;
try {
collaudo = CollaudoLocalServiceUtil.getCollaudo(doc.getClassPk());
} catch (PortalException e) {
}
rimuovi = Validator.isNull(collaudo);
} else if (Delega.class.getName().equals(doc.getClassName())) {
Delega delega = null;
try {
delega = DelegaLocalServiceUtil.getDelega(doc.getClassPk());
} catch (PortalException e) {
}
rimuovi = Validator.isNull(delega);
} else if (DettPratica.class.getName().equals(doc.getClassName())) {
DettPratica dettPratica = null;
try {
dettPratica = DettPraticaLocalServiceUtil.getDettPratica(doc.getClassPk());
} catch (PortalException e) {
}
rimuovi = Validator.isNull(dettPratica);
} else if (FineLavori.class.getName().equals(doc.getClassName())) {
FineLavori fineLavori = null;
try {
fineLavori = FineLavoriLocalServiceUtil.getFineLavori(doc.getClassPk());
} catch (PortalException e) {
}
rimuovi = Validator.isNull(fineLavori);
} else if (IntPratica.class.getName().equals(doc.getClassName())) {
IntPratica intPratica = null;
try {
intPratica = IntPraticaLocalServiceUtil.getIntPratica(doc.getClassPk());
} catch (PortalException e) {
}
rimuovi = Validator.isNull(intPratica);
} else if (Soggetto.class.getName().equals(doc.getClassName())) {
Soggetto soggetto = null;
try {
soggetto = SoggettoLocalServiceUtil.getSoggetto(doc.getClassPk());
} catch (PortalException e) {
}
rimuovi = Validator.isNull(soggetto);
}
if (rimuovi) {
DocPraticaLocalServiceUtil.deleteDocPratica(doc);
cancellati++;
rimossi++;
}
}
totali += docs2.size();
start += SLICE - rimossi;
} while (docs2.size() > 0);
esitoLog(esito, "Analizzati " + totali + " DocPratica, cancellati " + cancellati);
} catch (PortalException | SQLException | SystemException e) {
esitoLog(esito, "Interrotto per errore: " + e.getMessage());
}
return esito;
}
private static List<String> svuotaDatabase(ServiceContext serviceContext) {
List<String> esito = new ArrayList<>();
int rows = 0;
try {
Connection connection = DataAccess.getUpgradeOptimizedConnection();
Statement s = connection.createStatement();
long controlloPraticaClassNameId = ClassNameLocalServiceUtil.getClassName(
ControlloPratica.class.getName()).getClassNameId();
long dettPraticaClassNameId = ClassNameLocalServiceUtil.getClassName(DettPratica.class.getName())
.getClassNameId();
long ddmContentClassNameId = ClassNameLocalServiceUtil.getClassName(DDMContent.class.getName())
.getClassNameId();
long dlFileEntryClassNameId = ClassNameLocalServiceUtil.getClassName(DLFileEntry.class.getName())
.getClassNameId();
long dlFileEntryMetadataClassNameId = ClassNameLocalServiceUtil.getClassName(
DLFileEntryMetadata.class.getName()).getClassNameId();
long dlFolderClassNameId = ClassNameLocalServiceUtil.getClassName(DLFolder.class.getName())
.getClassNameId();
long groupClassNameId = ClassNameLocalServiceUtil.getClassName(Group.class.getName())
.getClassNameId();
long mbDiscussionClassNameId = ClassNameLocalServiceUtil.getClassName(
MBDiscussion.class.getName()).getClassNameId();
long organizationClassNameId = ClassNameLocalServiceUtil.getClassName(
Organization.class.getName()).getClassNameId();
long userClassNameId = ClassNameLocalServiceUtil.getClassName(User.class.getName())
.getClassNameId();
rows = s.executeUpdate("DELETE FROM portos_bo_avviso WHERE avvisoid IN ("
+ "SELECT avvisoid FROM portos_bo_avviso a LEFT JOIN portos_bo_dettpratica d "
+ "ON a.classpk=d.dettpraticaid WHERE classname='" + DettPratica.class.getName()
+ "' AND d.dettpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_avviso");
rows = s.executeUpdate("DELETE FROM group_ WHERE groupid IN (SELECT groupid FROM group_ "
+ "LEFT JOIN user_ ON group_.classpk=user_.userid WHERE classnameid=" + userClassNameId
+ " AND user_.userid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da group_");
rows = s.executeUpdate("DELETE FROM contact_ WHERE contactid IN ("
+ "SELECT c.contactid FROM contact_ c LEFT JOIN user_ u "
+ "ON c.contactid=u.contactid WHERE u.userid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da contact_");
rows = s.executeUpdate("DELETE FROM usergroup WHERE usergroupid IN ("
+ "SELECT usergroupid FROM usergroup g LEFT JOIN user_ u ON g.userid=u.userid "
+ "WHERE u.userid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da usergroup");
rows = s.executeUpdate("DELETE FROM usergrouprole WHERE userid IN ("
+ "SELECT DISTINCT x.userid FROM usergrouprole x "
+ "LEFT JOIN user_ u ON x.userid=u.userid " + "WHERE u.userid IS NULL) OR groupid IN ("
+ "SELECT DISTINCT x.groupid FROM usergrouprole x "
+ "LEFT JOIN group_ g ON x.groupid=g.groupid "
+ "WHERE g.groupid IS NULL) OR roleid IN ("
+ "SELECT DISTINCT x.roleid FROM usergrouprole x "
+ "LEFT JOIN role_ r ON x.roleid=r.roleid " + "WHERE r.roleid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da usergrouprole");
rows = s.executeUpdate("DELETE FROM ddmcontent WHERE contentid IN ("
+ "SELECT contentid FROM ddmcontent LEFT JOIN dlfileentrymetadata "
+ "ON ddmcontent.contentid=dlfileentrymetadata.ddmstorageid WHERE name='"
+ DDMStorageLink.class.getName()
+ "' AND dlfileentrymetadata.fileentrymetadataid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da ddmcontent");
rows = s.executeUpdate("DELETE FROM assetentry WHERE entryid IN ("
+ "SELECT entryid FROM assetentry a LEFT JOIN dlfileentry b "
+ "ON a.classpk=b.fileentryid WHERE a.classnameid=" + dlFileEntryClassNameId
+ " AND b.fileentryid IS NULL)");
rows += s.executeUpdate("DELETE FROM assetentry WHERE entryid IN ("
+ "SELECT entryid FROM assetentry a LEFT JOIN dlfolder b ON a.classpk=b.folderid "
+ "WHERE a.classnameid=" + dlFolderClassNameId + " AND b.folderid IS NULL)");
rows += s.executeUpdate("DELETE FROM assetentry WHERE entryid IN ("
+ "SELECT entryid FROM assetentry a LEFT JOIN group_ b ON a.classpk=b.groupid "
+ "WHERE a.classnameid=" + groupClassNameId + " AND b.groupid IS NULL)");
rows += s.executeUpdate("DELETE FROM assetentry WHERE entryid IN ("
+ "SELECT entryid FROM assetentry a LEFT JOIN mbdiscussion b "
+ "ON a.classpk=b.discussionid WHERE a.classnameid=" + mbDiscussionClassNameId
+ " AND b.discussionid IS NULL)");
rows += s.executeUpdate("DELETE FROM assetentry WHERE entryid IN ("
+ "SELECT entryid FROM assetentry a LEFT JOIN organization_ b "
+ "ON a.classpk=b.organizationid WHERE a.classnameid=" + organizationClassNameId
+ " AND b.organizationid IS NULL)");
rows += s.executeUpdate("DELETE FROM assetentry WHERE entryid IN ("
+ "SELECT entryid FROM assetentry a LEFT JOIN portos_bo_controllopratica b "
+ "ON a.classpk=b.controllopraticaid WHERE a.classnameid=" + controlloPraticaClassNameId
+ " AND b.controllopraticaid IS NULL)");
rows += s.executeUpdate("DELETE FROM assetentry WHERE entryid IN ("
+ "SELECT entryid FROM assetentry a LEFT JOIN portos_bo_dettpratica b "
+ "ON a.classpk=b.dettpraticaid WHERE a.classnameid=" + dettPraticaClassNameId
+ " AND b.dettpraticaid IS NULL)");
rows += s.executeUpdate("DELETE FROM assetentry WHERE entryid IN ("
+ "SELECT entryid FROM assetentry a LEFT JOIN user_ b ON a.classpk=b.userid "
+ "WHERE a.classnameid=" + userClassNameId + " AND b.userid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da assetentry");
rows = s.executeUpdate("DELETE FROM resourcepermission WHERE resourcepermissionid IN ("
+ "SELECT resourcepermissionid FROM resourcepermission a LEFT JOIN dlfileentry b "
+ "ON a.primkey=b.fileentryid::TEXT WHERE a.name='" + DLFileEntry.class.getName()
+ "' AND b.fileentryid IS NULL)");
rows += s.executeUpdate("DELETE FROM resourcepermission WHERE resourcepermissionid IN ("
+ "SELECT resourcepermissionid FROM resourcepermission a LEFT JOIN dlfolder b "
+ "ON a.primkey=b.folderid::TEXT WHERE a.name='" + DLFolder.class.getName()
+ "' AND b.folderid IS NULL)");
rows += s.executeUpdate("DELETE FROM resourcepermission WHERE resourcepermissionid IN ("
+ "SELECT resourcepermissionid FROM resourcepermission a "
+ "LEFT JOIN portos_bo_controllopratica b "
+ "ON a.primkey=b.controllopraticaid::TEXT WHERE a.name='"
+ ControlloPratica.class.getName() + "' AND b.controllopraticaid IS NULL)");
rows += s.executeUpdate("DELETE FROM resourcepermission WHERE resourcepermissionid IN ("
+ "SELECT resourcepermissionid FROM resourcepermission a LEFT JOIN user_ b "
+ "ON a.primkey=b.userid::TEXT WHERE a.name='" + User.class.getName()
+ "' AND b.userid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da resourcepermission");
rows = s.executeUpdate("DELETE FROM syncdlobject WHERE syncdlobjectid IN ("
+ "SELECT syncdlobjectid FROM syncdlobject LEFT JOIN dlfileentry "
+ "ON syncdlobject.typepk=dlfileentry.fileentryid WHERE type_='"
+ DLSyncConstants.TYPE_FILE + "' AND dlfileentry.fileentryid IS NULL)");
rows += s.executeUpdate("DELETE FROM syncdlobject WHERE syncdlobjectid IN ("
+ "SELECT syncdlobjectid FROM syncdlobject LEFT JOIN dlfolder "
+ "ON syncdlobject.typepk=dlfolder.folderid WHERE type_='" + DLSyncConstants.TYPE_FOLDER
+ "' AND dlfolder.folderid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da syncdlobject");
rows = s.executeUpdate("DELETE FROM ratingsstats WHERE statsid IN ("
+ "SELECT statsid FROM ratingsstats a LEFT JOIN dlfileentry b "
+ "ON a.classpk=b.fileentryid WHERE a.classnameid=" + dlFileEntryClassNameId
+ " AND b.fileentryid IS NULL)");
rows += s.executeUpdate("DELETE FROM ratingsstats WHERE statsid IN ("
+ "SELECT statsid FROM ratingsstats a LEFT JOIN dlfolder b "
+ "ON a.classpk=b.folderid WHERE a.classnameid=" + dlFolderClassNameId
+ " AND b.folderid IS NULL)");
rows += s.executeUpdate("DELETE FROM ratingsstats WHERE statsid IN ("
+ "SELECT statsid FROM ratingsstats a LEFT JOIN portos_bo_controllopratica b "
+ "ON a.classpk=b.controllopraticaid WHERE a.classnameid=" + controlloPraticaClassNameId
+ " AND b.controllopraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da ratingsstats");
rows = s.executeUpdate("DELETE FROM mbmessage WHERE messageid IN ("
+ "SELECT messageid FROM mbmessage a LEFT JOIN dlfileentry b "
+ "ON a.classpk=b.fileentryid WHERE a.classnameid=" + dlFileEntryClassNameId
+ " AND b.fileentryid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da mbmessage");
rows = s.executeUpdate("DELETE FROM mbdiscussion WHERE discussionid IN ("
+ "SELECT discussionid FROM mbdiscussion a LEFT JOIN dlfileentry b "
+ "ON a.classpk=b.fileentryid WHERE a.classnameid=" + dlFileEntryClassNameId
+ " AND b.fileentryid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da mbdiscussion");
rows = s.executeUpdate("DELETE FROM mbthread WHERE threadid IN ("
+ "SELECT DISTINCT mbthread.threadid FROM mbthread LEFT JOIN mbmessage "
+ "ON mbthread.threadid=mbmessage.threadid WHERE mbmessage.messageid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da mbthread");
rows = s.executeUpdate("DELETE FROM dlfileentrymetadata WHERE fileentrymetadataid IN ("
+ "SELECT fileentrymetadataid FROM dlfileentrymetadata a LEFT JOIN dlfileentry b "
+ "ON a.fileentryid=b.fileentryid WHERE b.fileentryid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da dlfileentrymetadata");
rows = s.executeUpdate("DELETE FROM ddmstructurelink WHERE structurelinkid IN ("
+ "SELECT structurelinkid FROM ddmstructurelink a LEFT JOIN dlfileentrymetadata b "
+ "ON a.classpk=b.fileentrymetadataid WHERE a.classnameid="
+ dlFileEntryMetadataClassNameId + " AND b.fileentrymetadataid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da ddmstructurelink");
rows = s.executeUpdate("DELETE FROM ddmstoragelink WHERE storagelinkid IN ("
+ "SELECT storagelinkid FROM ddmstoragelink a LEFT JOIN ddmcontent b "
+ "ON a.classpk=b.contentid WHERE a.classnameid=" + ddmContentClassNameId
+ " AND b.contentid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da ddmstoragelink");
rows = s.executeUpdate("DELETE FROM socialactivity WHERE activityid IN ("
+ "SELECT activityid FROM socialactivity a LEFT JOIN dlfileentry b "
+ "ON a.classpk=b.fileentryid WHERE a.classnameid=" + dlFileEntryClassNameId
+ " AND b.fileentryid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da socialactivity");
rows = s.executeUpdate("DELETE FROM systemevent WHERE systemeventid IN ("
+ "SELECT systemeventid FROM systemevent a LEFT JOIN dlfileentry b "
+ "ON a.classpk=b.fileentryid WHERE a.classnameid=" + dlFileEntryClassNameId
+ " AND b.fileentryid IS NULL)");
rows += s.executeUpdate("DELETE FROM systemevent WHERE systemeventid IN ("
+ "SELECT systemeventid FROM systemevent a LEFT JOIN dlfolder b "
+ "ON a.classpk=b.folderid WHERE a.classnameid=" + dlFolderClassNameId
+ " AND b.folderid IS NULL)");
rows += s.executeUpdate("DELETE FROM systemevent WHERE systemeventid IN ("
+ "SELECT systemeventid FROM systemevent a LEFT JOIN portos_bo_controllopratica b "
+ "ON a.classpk=b.controllopraticaid WHERE a.classnameid=" + controlloPraticaClassNameId
+ " AND b.controllopraticaid IS NULL)");
rows += s.executeUpdate("DELETE FROM systemevent WHERE systemeventid IN ("
+ "SELECT systemeventid FROM systemevent a LEFT JOIN portos_bo_dettpratica b "
+ "ON a.classpk=b.dettpraticaid WHERE a.classnameid=" + dettPraticaClassNameId
+ " AND b.dettpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da systemevent");
} catch (SQLException | SystemException e) {
esitoLog(esito, "Interrotto per errore: " + e.getMessage());
}
return esito;
}
private static List<String> puliziaDocumentLibrary() {
List<String> esito = new ArrayList<>();
try {
int cancellati = 0;
int start = 0;
int totali = 0;
List<DLFolder> folders;
do {
folders = DLFolderLocalServiceUtil.getDLFolders(start, start + SLICE);
int rimossi = 0;
totali += folders.size();
for (DLFolder folder : folders) {
DLFolder parent = folder.getParentFolder();
if (Validator.isNotNull(parent)) {
switch (parent.getName()) {
case "Allegati":
long[] ids = StringUtil.split(folder.getName(), "_", 0L);
if ((ids.length == 2) && (ids[0] == ids[1])) {
try {
DettPraticaLocalServiceUtil.getDettPratica(ids[0]);
} catch (PortalException e) {
_log.info("Cancello la cartella " + folder.getName());
cancellati++;
rimossi++;
DLAppLocalServiceUtil.deleteFolder(folder.getFolderId());
}
}
break;
}
}
}
start += folders.size() - rimossi;
} while (folders.size() > 0);
esitoLog(esito, "Analizzate " + totali + " cartelle, cancellate " + cancellati);
} catch (PortalException | SystemException e) {
esitoLog(esito, "Errore durante l'elaborazione. " + e.getMessage());
}
return esito;
}
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);

61
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/SismicaUtil.java

@ -435,25 +435,39 @@ public class SismicaUtil {
esito.add("Errore caricamento intPratiche: " + e.getMessage()); esito.add("Errore caricamento intPratiche: " + e.getMessage());
} }
start += SLICE; start += SLICE;
List<Avviso> avvisi = null;
for (IntPratica pratica : pratiche) { for (IntPratica pratica : pratiche) {
List<Avviso> avvisi = null;
List<Avviso> totali = null;
String stato = pratica.getStatoPratica(); String stato = pratica.getStatoPratica();
if (Validator.isNotNull(stato) && Validator.isNotNull(pratica.getTipoProcedura()) if (Validator.isNotNull(stato) && Validator.isNotNull(pratica.getTipoProcedura())
&& pratica.getTipoPratica().equalsIgnoreCase(Constants.TIPO_PRATICA_DEPOSITO)) { && pratica.getTipoPratica().equalsIgnoreCase(Constants.TIPO_PRATICA_DEPOSITO)) {
// Dettaglio pratica
DettPratica dettPratica = null;
try {
dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(pratica
.getIntPraticaId());
} catch (SystemException e) {
}
if (Validator.isNotNull(dettPratica)) {
// Avvisi conformi
try { try {
avvisi = AvvisoLocalServiceUtil.findByIntPraticaId_tipoDocumento( avvisi = AvvisoLocalServiceUtil.findByIntPraticaId_tipoDocumento(
pratica.getIntPraticaId(), StatoPraticaConstants.CONFORME); pratica.getIntPraticaId(), StatoPraticaConstants.CONFORME);
} catch (SystemException e) { } catch (SystemException e) {
esito.add("Errore caricamento avvisi: " + e.getMessage()); avvisi = new ArrayList<>();
} }
List<Avviso> totali = null;
// Tutti gli avvisi
try { try {
totali = AvvisoLocalServiceUtil.findByIntPratica(pratica.getIntPraticaId(), totali = AvvisoLocalServiceUtil.findByIntPratica(pratica.getIntPraticaId(),
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
} catch (SystemException e) { } catch (SystemException e) {
totali = new ArrayList<>(); totali = new ArrayList<>();
} }
if ((avvisi.size() == 0) && stato.equalsIgnoreCase(StatoPraticaConstants.VIDIMATA)) {
// Controllo pratica
List<ControlloPratica> controlli = null; List<ControlloPratica> controlli = null;
try { try {
controlli = ControlloPraticaLocalServiceUtil.findByIntPratica(pratica controlli = ControlloPraticaLocalServiceUtil.findByIntPratica(pratica
@ -461,35 +475,36 @@ public class SismicaUtil {
} catch (SystemException e) { } catch (SystemException e) {
controlli = new ArrayList<>(); controlli = new ArrayList<>();
} }
if (pratica.getStatoPratica().equals(StatoPraticaConstants.VIDIMATA) ControlloPratica controllo = null;
&& (controlli.size() == 0)) { if (controlli.size() > 0) {
esito.add("Progetto: " + pratica.getNumeroProgetto() + " (" controllo = controlli.get(controlli.size() - 1);
+ pratica.getIntPraticaId() + "), procedura="
+ pratica.getTipoProcedura() + ", avvisi=" + totali.size() + ", stato="
+ pratica.getStatoPratica() + ", controlli=" + controlli.size());
DettPratica dettPratica;
try {
dettPratica = DettPraticaLocalServiceUtil
.getLastCompletedByIntPratica(pratica.getIntPraticaId());
} catch (SystemException e) {
dettPratica = null;
} }
if (Validator.isNotNull(dettPratica)) { if ((avvisi.size() == 0 && stato.equalsIgnoreCase(StatoPraticaConstants.VIDIMATA))
|| (totali.size() <= 1 && stato
.equalsIgnoreCase(StatoPraticaConstants.CONFORME))) {
_log.info("Pratica " + pratica.getNumeroProgetto() + "avvisi.size() = "
+ avvisi.size() + ", stato = " + stato);
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(dettPratica.getCompanyId()); serviceContext.setCompanyId(dettPratica.getCompanyId());
serviceContext.setScopeGroupId(dettPratica.getGroupId()); serviceContext.setScopeGroupId(dettPratica.getGroupId());
serviceContext.setUserId(dettPratica.getUserId()); serviceContext.setUserId(dettPratica.getUserId());
ControlloPratica controllo; if (Validator.isNull(controllo)) {
esito.add("Progetto: " + pratica.getNumeroProgetto() + " ("
+ pratica.getIntPraticaId() + "), procedura="
+ pratica.getTipoProcedura() + ", avvisi=" + totali.size()
+ ", stato=" + pratica.getStatoPratica() + ", controlli="
+ controlli.size());
try { try {
controllo = ControlloPraticaLocalServiceUtil.addControlloPratica( controllo = ControlloPraticaLocalServiceUtil.addControlloPratica(
dettPratica.getGroupId(), dettPratica.getUserId(), dettPratica.getGroupId(), dettPratica.getUserId(),
pratica.getIntPraticaId(), dettPratica.getDettPraticaId(), false, pratica.getIntPraticaId(), dettPratica.getDettPraticaId(), false,
serviceContext); serviceContext);
} catch (PortalException | SystemException e) { } catch (PortalException | SystemException e) {
controllo = null; }
} }
if (Validator.isNotNull(controllo)) { if (Validator.isNotNull(controllo)) {
controllo.setStatus(WorkflowConstants.STATUS_APPROVED); controllo.setStatus(WorkflowConstants.STATUS_APPROVED);
@ -500,9 +515,8 @@ public class SismicaUtil {
long fileEntryIdTemplate; long fileEntryIdTemplate;
try { try {
fileEntryIdTemplate = ConfigurazioneLocalServiceUtil fileEntryIdTemplate = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(
.findByC_ChiaveLong(companyId, companyId, "conf.geniocivile.avviso.template.id.deposito.B2");
"conf.geniocivile.avviso.template.id.deposito.B2");
} catch (SystemException e) { } catch (SystemException e) {
fileEntryIdTemplate = 0; fileEntryIdTemplate = 0;
} }
@ -526,7 +540,6 @@ public class SismicaUtil {
} }
} }
} }
}
} else if ((totali.size() == 2) && (avvisi.size() > 0) } else if ((totali.size() == 2) && (avvisi.size() > 0)
&& stato.equalsIgnoreCase(StatoPraticaConstants.SOTTOPOSTA_A_PARERE)) { && stato.equalsIgnoreCase(StatoPraticaConstants.SOTTOPOSTA_A_PARERE)) {
esito.add("Rendo conforme: " + pratica.getNumeroProgetto()); esito.add("Rendo conforme: " + pratica.getNumeroProgetto());

Caricamento…
Annulla
Salva