|
|
@ -5,24 +5,40 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package it.mwg.sismica.bo.util; |
|
|
|
package it.mwg.sismica.bo.util; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import it.tref.liferay.portos.bo.model.ControlloPratica; |
|
|
|
import it.tref.liferay.portos.bo.model.DettPratica; |
|
|
|
import it.tref.liferay.portos.bo.model.DettPratica; |
|
|
|
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil; |
|
|
|
import java.sql.Connection; |
|
|
|
|
|
|
|
import java.sql.SQLException; |
|
|
|
|
|
|
|
import java.sql.Statement; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.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; |
|
|
|
import com.liferay.portal.kernel.log.LogFactoryUtil; |
|
|
|
import com.liferay.portal.kernel.log.LogFactoryUtil; |
|
|
|
|
|
|
|
import com.liferay.portal.kernel.servlet.DirectServletRegistryUtil; |
|
|
|
import com.liferay.portal.kernel.util.StringUtil; |
|
|
|
import com.liferay.portal.kernel.util.StringUtil; |
|
|
|
import com.liferay.portal.kernel.util.Validator; |
|
|
|
import com.liferay.portal.kernel.util.Validator; |
|
|
|
|
|
|
|
import com.liferay.portal.model.Group; |
|
|
|
|
|
|
|
import com.liferay.portal.model.Organization; |
|
|
|
|
|
|
|
import com.liferay.portal.model.User; |
|
|
|
|
|
|
|
import com.liferay.portal.service.ClassNameLocalServiceUtil; |
|
|
|
import com.liferay.portal.service.ServiceContext; |
|
|
|
import com.liferay.portal.service.ServiceContext; |
|
|
|
|
|
|
|
import com.liferay.portlet.documentlibrary.model.DLFileEntry; |
|
|
|
|
|
|
|
import com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata; |
|
|
|
import com.liferay.portlet.documentlibrary.model.DLFolder; |
|
|
|
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.DLAppLocalServiceUtil; |
|
|
|
import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil; |
|
|
|
|
|
|
|
import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil; |
|
|
|
import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil; |
|
|
|
|
|
|
|
import com.liferay.portlet.dynamicdatamapping.model.DDMContent; |
|
|
|
|
|
|
|
import com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink; |
|
|
|
|
|
|
|
import com.liferay.portlet.messageboards.model.MBDiscussion; |
|
|
|
|
|
|
|
|
|
|
|
public class PuliziaDatabase { |
|
|
|
public class PuliziaDatabase { |
|
|
|
private static final Log _log = LogFactoryUtil.getLog(PuliziaDatabase.class); |
|
|
|
private static final Log _log = LogFactoryUtil.getLog(PuliziaDatabase.class); |
|
|
@ -30,40 +46,202 @@ public class PuliziaDatabase { |
|
|
|
|
|
|
|
|
|
|
|
public static List<String> pulisci(ServiceContext serviceContext) { |
|
|
|
public static List<String> pulisci(ServiceContext serviceContext) { |
|
|
|
List<String> esito = new ArrayList<>(); |
|
|
|
List<String> esito = new ArrayList<>(); |
|
|
|
esito.addAll(eliminaDettPraticheOrfane()); |
|
|
|
|
|
|
|
esito.addAll(puliziaDocumentLibrary()); |
|
|
|
esito.addAll(puliziaDocumentLibrary()); |
|
|
|
return esito; |
|
|
|
esito.addAll(svuotaDatabase(serviceContext)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
SingleVMPoolUtil.clear(); |
|
|
|
|
|
|
|
MultiVMPoolUtil.clear(); |
|
|
|
|
|
|
|
CacheRegistryUtil.clear(); |
|
|
|
|
|
|
|
DirectServletRegistryUtil.clearServlets(); |
|
|
|
|
|
|
|
} catch (IllegalStateException e) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static List<String> |
|
|
|
return esito; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static List<String> eliminaDettPraticheOrfane() { |
|
|
|
private static List<String> svuotaDatabase(ServiceContext serviceContext) { |
|
|
|
List<String> esito = new ArrayList<>(); |
|
|
|
List<String> esito = new ArrayList<>(); |
|
|
|
int cancellati = 0; |
|
|
|
int rows = 0; |
|
|
|
int start = 0; |
|
|
|
|
|
|
|
int totali = 0; |
|
|
|
|
|
|
|
List<DettPratica> dettPratiche; |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
do { |
|
|
|
Connection connection = DataAccess.getUpgradeOptimizedConnection(); |
|
|
|
dettPratiche = DettPraticaLocalServiceUtil.getDettPraticas(start, start + SLICE); |
|
|
|
Statement s = connection.createStatement(); |
|
|
|
int rimossi = 0; |
|
|
|
|
|
|
|
totali += dettPratiche.size(); |
|
|
|
long controlloPraticaClassNameId = ClassNameLocalServiceUtil.getClassName( |
|
|
|
for (DettPratica dettPratica : dettPratiche) { |
|
|
|
ControlloPratica.class.getName()).getClassNameId(); |
|
|
|
try { |
|
|
|
long dettPraticaClassNameId = ClassNameLocalServiceUtil.getClassName(DettPratica.class.getName()) |
|
|
|
IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId()); |
|
|
|
.getClassNameId(); |
|
|
|
} catch (PortalException e) { |
|
|
|
long ddmContentClassNameId = ClassNameLocalServiceUtil.getClassName(DDMContent.class.getName()) |
|
|
|
_log.info("Cancello DettPratica orfana " + dettPratica.getDettPraticaId()); |
|
|
|
.getClassNameId(); |
|
|
|
cancellati++; |
|
|
|
long dlFileEntryClassNameId = ClassNameLocalServiceUtil.getClassName(DLFileEntry.class.getName()) |
|
|
|
rimossi++; |
|
|
|
.getClassNameId(); |
|
|
|
DettPraticaLocalServiceUtil.deleteDettPratica(dettPratica); |
|
|
|
long dlFileEntryMetadataClassNameId = ClassNameLocalServiceUtil.getClassName( |
|
|
|
} |
|
|
|
DLFileEntryMetadata.class.getName()).getClassNameId(); |
|
|
|
} |
|
|
|
long dlFolderClassNameId = ClassNameLocalServiceUtil.getClassName(DLFolder.class.getName()) |
|
|
|
start += dettPratiche.size() - rimossi; |
|
|
|
.getClassNameId(); |
|
|
|
} while (dettPratiche.size() > 0); |
|
|
|
long groupClassNameId = ClassNameLocalServiceUtil.getClassName(Group.class.getName()) |
|
|
|
} catch (PortalException | SystemException e) { |
|
|
|
.getClassNameId(); |
|
|
|
esitoLog(esito, e.getMessage()); |
|
|
|
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"); |
|
|
|
|
|
|
|
} catch (SQLException | SystemException e) { |
|
|
|
|
|
|
|
esitoLog(esito, "Interrotto per errore: " + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
esitoLog(esito, "Analizzate " + totali + " DettPratica, cancellate " + cancellati); |
|
|
|
|
|
|
|
return esito; |
|
|
|
return esito; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|