|
|
|
@ -16,7 +16,6 @@ import it.tref.liferay.portos.bo.model.IntPratica;
|
|
|
|
|
import it.tref.liferay.portos.bo.model.Pagamento; |
|
|
|
|
import it.tref.liferay.portos.bo.model.ParereGeologo; |
|
|
|
|
import it.tref.liferay.portos.bo.model.Territorio; |
|
|
|
|
import it.tref.liferay.portos.bo.model.impl.AvvisoImpl; |
|
|
|
|
import it.tref.liferay.portos.bo.service.AllegatoManualeLocalServiceUtil; |
|
|
|
|
import it.tref.liferay.portos.bo.service.AsseverazioneLocalServiceUtil; |
|
|
|
|
import it.tref.liferay.portos.bo.service.AvvisoLocalServiceUtil; |
|
|
|
@ -35,16 +34,11 @@ import it.tref.liferay.portos.bo.util.AvvisoUtil;
|
|
|
|
|
import it.tref.liferay.portos.bo.util.Constants; |
|
|
|
|
import it.tref.liferay.portos.bo.util.WorkflowConstants; |
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.Serializable; |
|
|
|
|
import java.sql.Connection; |
|
|
|
|
import java.sql.SQLException; |
|
|
|
|
import java.sql.Statement; |
|
|
|
|
import java.text.ParseException; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Calendar; |
|
|
|
|
import java.util.Collection; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.LinkedHashMap; |
|
|
|
@ -53,13 +47,8 @@ import java.util.Map;
|
|
|
|
|
import java.util.Map.Entry; |
|
|
|
|
import java.util.TreeMap; |
|
|
|
|
|
|
|
|
|
import org.apache.commons.io.IOUtils; |
|
|
|
|
|
|
|
|
|
import com.itextpdf.text.pdf.codec.Base64.InputStream; |
|
|
|
|
import com.liferay.counter.service.CounterLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.NoSuchRepositoryEntryException; |
|
|
|
|
import com.liferay.portal.NoSuchResourcePermissionException; |
|
|
|
|
import com.liferay.portal.kernel.dao.jdbc.DataAccess; |
|
|
|
|
import com.liferay.portal.kernel.dao.orm.QueryUtil; |
|
|
|
|
import com.liferay.portal.kernel.exception.PortalException; |
|
|
|
|
import com.liferay.portal.kernel.exception.SystemException; |
|
|
|
@ -79,44 +68,31 @@ import com.liferay.portal.kernel.workflow.WorkflowInstance;
|
|
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowInstanceManagerUtil; |
|
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowTask; |
|
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowTaskManagerUtil; |
|
|
|
|
import com.liferay.portal.model.Group; |
|
|
|
|
import com.liferay.portal.model.Organization; |
|
|
|
|
import com.liferay.portal.model.ResourceAction; |
|
|
|
|
import com.liferay.portal.model.ResourceConstants; |
|
|
|
|
import com.liferay.portal.model.ResourcePermission; |
|
|
|
|
import com.liferay.portal.model.Role; |
|
|
|
|
import com.liferay.portal.model.RoleConstants; |
|
|
|
|
import com.liferay.portal.model.User; |
|
|
|
|
import com.liferay.portal.security.auth.PrincipalException; |
|
|
|
|
import com.liferay.portal.security.auth.PrincipalThreadLocal; |
|
|
|
|
import com.liferay.portal.security.permission.ActionKeys; |
|
|
|
|
import com.liferay.portal.security.permission.PermissionChecker; |
|
|
|
|
import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil; |
|
|
|
|
import com.liferay.portal.security.permission.PermissionThreadLocal; |
|
|
|
|
import com.liferay.portal.service.GroupLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.service.OrganizationLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.service.ResourceActionLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.service.ResourcePermissionLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.service.RoleLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.service.ServiceContext; |
|
|
|
|
import com.liferay.portal.service.UserLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.model.KaleoInstance; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.model.KaleoInstanceToken; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstance; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.model.KaleoTaskInstanceToken; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.service.KaleoInstanceLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.service.KaleoInstanceTokenLocalService; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.service.KaleoInstanceTokenLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.service.KaleoTaskAssignmentInstanceLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.service.KaleoTaskInstanceTokenLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.service.persistence.KaleoInstanceTokenUtil; |
|
|
|
|
import com.liferay.portlet.documentlibrary.NoSuchFileEntryException; |
|
|
|
|
import com.liferay.portlet.documentlibrary.model.DLFileEntry; |
|
|
|
|
import com.liferay.portlet.documentlibrary.model.DLFolder; |
|
|
|
|
import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil; |
|
|
|
|
import com.liferay.portlet.documentlibrary.service.DLAppServiceUtil; |
|
|
|
|
import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil; |
|
|
|
|
import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil; |
|
|
|
|
|
|
|
|
|
public class SismicaUtil { |
|
|
|
|
private final static Log _log = LogFactoryUtil.getLog(SismicaUtil.class); |
|
|
|
@ -439,6 +415,22 @@ public class SismicaUtil {
|
|
|
|
|
List<Avviso> avvisi = null; |
|
|
|
|
List<Avviso> totali = null; |
|
|
|
|
String stato = pratica.getStatoPratica(); |
|
|
|
|
|
|
|
|
|
// Avvisi conformi
|
|
|
|
|
try { |
|
|
|
|
avvisi = AvvisoLocalServiceUtil.findByIntPraticaId_tipoDocumento( |
|
|
|
|
pratica.getIntPraticaId(), StatoPraticaConstants.CONFORME); |
|
|
|
|
} catch (SystemException e) { |
|
|
|
|
avvisi = new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tutti gli avvisi
|
|
|
|
|
try { |
|
|
|
|
totali = AvvisoLocalServiceUtil.findByIntPratica(pratica.getIntPraticaId(), |
|
|
|
|
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); |
|
|
|
|
} catch (SystemException e) { |
|
|
|
|
totali = new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
if (Validator.isNotNull(stato) && Validator.isNotNull(pratica.getTipoProcedura()) |
|
|
|
|
&& pratica.getTipoPratica().equalsIgnoreCase(Constants.TIPO_PRATICA_DEPOSITO)) { |
|
|
|
|
|
|
|
|
@ -451,22 +443,6 @@ public class SismicaUtil {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (Validator.isNotNull(dettPratica)) { |
|
|
|
|
// Avvisi conformi
|
|
|
|
|
try { |
|
|
|
|
avvisi = AvvisoLocalServiceUtil.findByIntPraticaId_tipoDocumento( |
|
|
|
|
pratica.getIntPraticaId(), StatoPraticaConstants.CONFORME); |
|
|
|
|
} catch (SystemException e) { |
|
|
|
|
avvisi = new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tutti gli avvisi
|
|
|
|
|
try { |
|
|
|
|
totali = AvvisoLocalServiceUtil.findByIntPratica(pratica.getIntPraticaId(), |
|
|
|
|
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); |
|
|
|
|
} catch (SystemException e) { |
|
|
|
|
totali = new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Controllo pratica
|
|
|
|
|
List<ControlloPratica> controlli = null; |
|
|
|
|
try { |
|
|
|
@ -480,24 +456,18 @@ public class SismicaUtil {
|
|
|
|
|
controllo = controlli.get(controlli.size() - 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
boolean totaliOk = (totali.size() == 0) |
|
|
|
|
|| ((totali.size() == 1) && totali.get(0).getTipoDocumento() |
|
|
|
|
.equalsIgnoreCase(StatoPraticaConstants.VIDIMATA)); |
|
|
|
|
if ((avvisi.size() == 0 && stato.equalsIgnoreCase(StatoPraticaConstants.VIDIMATA)) |
|
|
|
|
|| (totali.size() <= 1 && stato |
|
|
|
|
.equalsIgnoreCase(StatoPraticaConstants.CONFORME))) { |
|
|
|
|
|| (totaliOk && stato.equalsIgnoreCase(StatoPraticaConstants.CONFORME))) { |
|
|
|
|
|
|
|
|
|
_log.info("Pratica " + pratica.getNumeroProgetto() + "avvisi.size() = " |
|
|
|
|
+ avvisi.size() + ", stato = " + stato); |
|
|
|
|
ServiceContext serviceContext = new ServiceContext(); |
|
|
|
|
serviceContext.setCompanyId(dettPratica.getCompanyId()); |
|
|
|
|
serviceContext.setScopeGroupId(dettPratica.getGroupId()); |
|
|
|
|
serviceContext.setUserId(dettPratica.getUserId()); |
|
|
|
|
|
|
|
|
|
if (Validator.isNull(controllo)) { |
|
|
|
|
esito.add("Progetto: " + pratica.getNumeroProgetto() + " (" |
|
|
|
|
+ pratica.getIntPraticaId() + "), procedura=" |
|
|
|
|
+ pratica.getTipoProcedura() + ", avvisi=" + totali.size() |
|
|
|
|
+ ", stato=" + pratica.getStatoPratica() + ", controlli=" |
|
|
|
|
+ controlli.size()); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
controllo = ControlloPraticaLocalServiceUtil.addControlloPratica( |
|
|
|
|
dettPratica.getGroupId(), dettPratica.getUserId(), |
|
|
|
@ -521,6 +491,16 @@ public class SismicaUtil {
|
|
|
|
|
fileEntryIdTemplate = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_log.info("Pratica " |
|
|
|
|
+ pratica.getNumeroProgetto() |
|
|
|
|
+ ", totali.size() = " |
|
|
|
|
+ totali.size() |
|
|
|
|
+ (totali.size() > 0 ? ", totali(0) = " |
|
|
|
|
+ totali.get(0).getTipoDocumento() : "") |
|
|
|
|
+ ", avvisi.size() = " + avvisi.size() + ", stato = " + stato |
|
|
|
|
+ ", controllo = " + controllo.getPrimaryKey() |
|
|
|
|
+ ", fileEntryIdTemplate = " + fileEntryIdTemplate); |
|
|
|
|
|
|
|
|
|
if (Validator.isNotNull(fileEntryIdTemplate)) { |
|
|
|
|
try { |
|
|
|
|
if (!pratica.getTipoProcedura().equalsIgnoreCase( |
|
|
|
|