Sfoglia il codice sorgente

Fix view.jsp sorteggio

master
Salvatore La Manna 5 anni fa
parent
commit
d411a66de8
  1. 10
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/liferay-portlet.xml
  2. 3
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/SorteggioLocalService.java
  3. 55
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/SorteggioLocalServiceClp.java
  4. 5
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/SorteggioLocalServiceUtil.java
  5. 6
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/SorteggioLocalServiceWrapper.java
  6. 3
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/AvvisoUtil.java
  7. 2
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/content/Language.properties
  8. 84
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/scheduler/SchedulerSorteggio.java
  9. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/scheduler/SchedulerWorkflow.java
  10. 334
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/SorteggioPraticaUtil.java
  11. 17
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/PortosAdministrationPortlet.java
  12. 149
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/scheduler/SchedulerPratiche.java
  13. 155
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/scheduler/SchedulerSorteggio.java
  14. 24
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/base/SorteggioLocalServiceClpInvoker.java
  15. 9
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AvvisoLocalServiceImpl.java
  16. 8
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/SorteggioLocalServiceImpl.java
  17. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/AllegatoManualePersistenceImpl.java
  18. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/AsseverazionePersistenceImpl.java
  19. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/AvvisoPersistenceImpl.java
  20. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/CollaudoPersistenceImpl.java
  21. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/ComunePersistenceImpl.java
  22. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/ComunicazionePersistenceImpl.java
  23. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/ConfigurazionePersistenceImpl.java
  24. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/ControlloPraticaPersistenceImpl.java
  25. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/DelegaPersistenceImpl.java
  26. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/DettPraticaPersistenceImpl.java
  27. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/DocAggiuntivaPersistenceImpl.java
  28. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/DocPraticaPersistenceImpl.java
  29. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/FineLavoriPersistenceImpl.java
  30. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/HistoryWorkflowActionPersistenceImpl.java
  31. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/IUVPersistenceImpl.java
  32. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/InfoFascicoloPersistenceImpl.java
  33. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/IntPraticaPersistenceImpl.java
  34. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/PagamentoPersistenceImpl.java
  35. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/ParereGeologoPersistenceImpl.java
  36. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/ProvinciaPersistenceImpl.java
  37. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/SoggettoPersistenceImpl.java
  38. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/SorteggioPersistenceImpl.java
  39. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/StoricoSoggettoPraticaPersistenceImpl.java
  40. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/TempisticaPersistenceImpl.java
  41. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/TerritorioPersistenceImpl.java
  42. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/UtentePortosPersistenceImpl.java
  43. 753
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/util/SorteggioPraticaUtil.java
  44. 4
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties
  45. 34
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/sorteggio/view.jsp

10
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/liferay-portlet.xml

@ -39,12 +39,12 @@
</trigger> </trigger>
</scheduler-entry> </scheduler-entry>
<scheduler-entry> <scheduler-entry>
<scheduler-event-listener-class>it.tref.liferay.portos.bo.scheduler.SchedulerSorteggio</scheduler-event-listener-class> <scheduler-description>Sorteggio Pratiche</scheduler-description>
<scheduler-event-listener-class>it.mwg.sismica.bo.scheduler.SchedulerSorteggio</scheduler-event-listener-class>
<trigger> <trigger>
<simple> <cron>
<simple-trigger-value>1</simple-trigger-value> <cron-trigger-value>0 3 * * * ?</cron-trigger-value>
<time-unit>minute</time-unit> </cron>
</simple>
</trigger> </trigger>
</scheduler-entry> </scheduler-entry>
<scheduler-entry> <scheduler-entry>

3
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/SorteggioLocalService.java

@ -438,9 +438,6 @@ public interface SorteggioLocalService extends BaseLocalService,
public long findTipoPraticaIdSorteggioPraticaEsterna(long praticaEsternaId) public long findTipoPraticaIdSorteggioPraticaEsterna(long praticaEsternaId)
throws com.liferay.portal.kernel.exception.SystemException; throws com.liferay.portal.kernel.exception.SystemException;
public java.util.List<java.lang.String> sorteggio(long companyId,
java.util.Date dtSorteggio) throws java.lang.Exception;
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public java.util.List<it.tref.liferay.portos.bo.model.Sorteggio> search( public java.util.List<it.tref.liferay.portos.bo.model.Sorteggio> search(
java.lang.Long groupId, java.lang.String anno, java.lang.String mese, java.lang.Long groupId, java.lang.String anno, java.lang.String mese,

55
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/SorteggioLocalServiceClp.java

@ -267,22 +267,18 @@ public class SorteggioLocalServiceClp implements SorteggioLocalService {
_methodParameterTypes46 = new String[] { "long" }; _methodParameterTypes46 = new String[] { "long" };
_methodName47 = "sorteggio"; _methodName47 = "search";
_methodParameterTypes47 = new String[] { "long", "java.util.Date" }; _methodParameterTypes47 = new String[] {
_methodName48 = "search";
_methodParameterTypes48 = new String[] {
"java.lang.Long", "java.lang.String", "java.lang.String", "int", "java.lang.Long", "java.lang.String", "java.lang.String", "int",
"java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String",
"java.lang.String", "java.lang.Long", "java.lang.String", "int", "java.lang.String", "java.lang.Long", "java.lang.String", "int",
"int" "int"
}; };
_methodName49 = "count"; _methodName48 = "count";
_methodParameterTypes49 = new String[] { _methodParameterTypes48 = new String[] {
"java.lang.Long", "java.lang.String", "java.lang.String", "int", "java.lang.Long", "java.lang.String", "java.lang.String", "int",
"java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String",
"java.lang.String", "java.lang.Long", "java.lang.String" "java.lang.String", "java.lang.Long", "java.lang.String"
@ -1891,39 +1887,6 @@ public class SorteggioLocalServiceClp implements SorteggioLocalService {
return ((Long)returnObj).longValue(); return ((Long)returnObj).longValue();
} }
@Override
public java.util.List<java.lang.String> sorteggio(long companyId,
java.util.Date dtSorteggio) throws java.lang.Exception {
Object returnObj = null;
try {
returnObj = _invokableLocalService.invokeMethod(_methodName47,
_methodParameterTypes47,
new Object[] {
companyId,
ClpSerializer.translateInput(dtSorteggio)
});
}
catch (Throwable t) {
t = ClpSerializer.translateThrowable(t);
if (t instanceof java.lang.Exception) {
throw (java.lang.Exception)t;
}
if (t instanceof RuntimeException) {
throw (RuntimeException)t;
}
else {
throw new RuntimeException(t.getClass().getName() +
" is not a valid exception");
}
}
return (java.util.List<java.lang.String>)ClpSerializer.translateOutput(returnObj);
}
@Override @Override
public java.util.List<it.tref.liferay.portos.bo.model.Sorteggio> search( public java.util.List<it.tref.liferay.portos.bo.model.Sorteggio> search(
java.lang.Long groupId, java.lang.String anno, java.lang.String mese, java.lang.Long groupId, java.lang.String anno, java.lang.String mese,
@ -1934,8 +1897,8 @@ public class SorteggioLocalServiceClp implements SorteggioLocalService {
Object returnObj = null; Object returnObj = null;
try { try {
returnObj = _invokableLocalService.invokeMethod(_methodName48, returnObj = _invokableLocalService.invokeMethod(_methodName47,
_methodParameterTypes48, _methodParameterTypes47,
new Object[] { new Object[] {
ClpSerializer.translateInput(groupId), ClpSerializer.translateInput(groupId),
@ -1991,8 +1954,8 @@ public class SorteggioLocalServiceClp implements SorteggioLocalService {
Object returnObj = null; Object returnObj = null;
try { try {
returnObj = _invokableLocalService.invokeMethod(_methodName49, returnObj = _invokableLocalService.invokeMethod(_methodName48,
_methodParameterTypes49, _methodParameterTypes48,
new Object[] { new Object[] {
ClpSerializer.translateInput(groupId), ClpSerializer.translateInput(groupId),
@ -2131,6 +2094,4 @@ public class SorteggioLocalServiceClp implements SorteggioLocalService {
private String[] _methodParameterTypes47; private String[] _methodParameterTypes47;
private String _methodName48; private String _methodName48;
private String[] _methodParameterTypes48; private String[] _methodParameterTypes48;
private String _methodName49;
private String[] _methodParameterTypes49;
} }

5
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/SorteggioLocalServiceUtil.java

@ -529,11 +529,6 @@ public class SorteggioLocalServiceUtil {
.findTipoPraticaIdSorteggioPraticaEsterna(praticaEsternaId); .findTipoPraticaIdSorteggioPraticaEsterna(praticaEsternaId);
} }
public static java.util.List<java.lang.String> sorteggio(long companyId,
java.util.Date dtSorteggio) throws java.lang.Exception {
return getService().sorteggio(companyId, dtSorteggio);
}
public static java.util.List<it.tref.liferay.portos.bo.model.Sorteggio> search( public static java.util.List<it.tref.liferay.portos.bo.model.Sorteggio> search(
java.lang.Long groupId, java.lang.String anno, java.lang.String mese, java.lang.Long groupId, java.lang.String anno, java.lang.String mese,
int settimana, java.lang.String committente, java.lang.String tecnico, int settimana, java.lang.String committente, java.lang.String tecnico,

6
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/SorteggioLocalServiceWrapper.java

@ -567,12 +567,6 @@ public class SorteggioLocalServiceWrapper implements SorteggioLocalService,
return _sorteggioLocalService.findTipoPraticaIdSorteggioPraticaEsterna(praticaEsternaId); return _sorteggioLocalService.findTipoPraticaIdSorteggioPraticaEsterna(praticaEsternaId);
} }
@Override
public java.util.List<java.lang.String> sorteggio(long companyId,
java.util.Date dtSorteggio) throws java.lang.Exception {
return _sorteggioLocalService.sorteggio(companyId, dtSorteggio);
}
@Override @Override
public java.util.List<it.tref.liferay.portos.bo.model.Sorteggio> search( public java.util.List<it.tref.liferay.portos.bo.model.Sorteggio> search(
java.lang.Long groupId, java.lang.String anno, java.lang.String mese, java.lang.Long groupId, java.lang.String anno, java.lang.String mese,

3
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/AvvisoUtil.java

@ -177,8 +177,9 @@ public class AvvisoUtil {
allTipoDocumentoFileTemplateProps.put("DPA", "conf.geniocivile.avviso.template.id.deposito.A"); allTipoDocumentoFileTemplateProps.put("DPA", "conf.geniocivile.avviso.template.id.deposito.A");
allTipoDocumentoFileTemplateProps.put("DPB", "conf.geniocivile.avviso.template.id.deposito.B"); allTipoDocumentoFileTemplateProps.put("DPB", "conf.geniocivile.avviso.template.id.deposito.B");
allTipoDocumentoFileTemplateProps.put("DPB1", "conf.geniocivile.avviso.template.id.deposito.B1"); allTipoDocumentoFileTemplateProps.put("DPB1", "conf.geniocivile.avviso.template.id.deposito.B1");
allTipoDocumentoFileTemplateProps.put("DPC", "conf.geniocivile.avviso.template.id.deposito.C");
allTipoDocumentoFileTemplateProps.put("DPB2", "conf.geniocivile.avviso.template.id.deposito.B2"); allTipoDocumentoFileTemplateProps.put("DPB2", "conf.geniocivile.avviso.template.id.deposito.B2");
allTipoDocumentoFileTemplateProps.put("DPC", "conf.geniocivile.avviso.template.id.deposito.C");
allTipoDocumentoFileTemplateProps.put("DPPS", "conf.geniocivile.avviso.template.id.deposito.PS");
allTipoDocumentoFileTemplateProps.put("DPS", "conf.geniocivile.avviso.template.id.deposito.S"); allTipoDocumentoFileTemplateProps.put("DPS", "conf.geniocivile.avviso.template.id.deposito.S");
/* /*
* allTipoDocumentoFileTemplateProps.put(StatoPraticaConstants. * allTipoDocumentoFileTemplateProps.put(StatoPraticaConstants.

2
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/content/Language.properties

@ -180,6 +180,8 @@ conf.geniocivile.avviso.template.id.deposito.B = Template ricevuta deposito mod.
conf.geniocivile.avviso.template.id.deposito.B1 = Template ricevuta deposito mod. B1 conf.geniocivile.avviso.template.id.deposito.B1 = Template ricevuta deposito mod. B1
conf.geniocivile.avviso.template.id.deposito.C = Template ricevuta deposito mod. C conf.geniocivile.avviso.template.id.deposito.C = Template ricevuta deposito mod. C
conf.geniocivile.avviso.template.id.deposito.B2 = Template ricevuta deposito mod. B2 conf.geniocivile.avviso.template.id.deposito.B2 = Template ricevuta deposito mod. B2
conf.geniocivile.avviso.template.id.deposito.PS = Template Avvisio Avvio di procedimento dopo sorteggio
conf.geniocivile.avviso.template.id.deposito.S = Template avviso di sorteggio
#Configurazione Allegati #Configurazione Allegati
conf.geniocivile.attachment.folder.id = Folder Allegati conf.geniocivile.attachment.folder.id = Folder Allegati

84
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/scheduler/SchedulerSorteggio.java

@ -0,0 +1,84 @@
package it.mwg.sismica.bo.scheduler;
import it.mwg.sismica.bo.util.SorteggioPraticaUtil;
import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ConfigurazioneServiceUtil;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
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.messaging.Message;
import com.liferay.portal.kernel.messaging.MessageListener;
import com.liferay.portal.kernel.messaging.MessageListenerException;
import com.liferay.portal.model.Company;
import com.liferay.portal.model.Role;
import com.liferay.portal.model.RoleConstants;
import com.liferay.portal.model.User;
import com.liferay.portal.service.CompanyLocalServiceUtil;
import com.liferay.portal.service.RoleLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.UserLocalServiceUtil;
public class SchedulerSorteggio implements MessageListener {
private static final Log _log = LogFactoryUtil.getLog(SchedulerSorteggio.class);
private static final Lock lock = new ReentrantLock();
@Override
public void receive(Message message) throws MessageListenerException {
if (lock.tryLock()) {
Date dt = new Date();
try {
for (Company company : CompanyLocalServiceUtil.getCompanies()) {
long companyId = company.getCompanyId();
if (isGiornoSorteggio(companyId, dt)) {
_log.info("Sorteggio da scheduler");
SorteggioPraticaUtil.sorteggio(companyId, dt);
Role role = RoleLocalServiceUtil.getRole(companyId, RoleConstants.ADMINISTRATOR);
User user = UserLocalServiceUtil.getRoleUsers(role.getRoleId(), 0, 1).get(0);
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId);
serviceContext.setScopeGroupId(company.getGroupId());
serviceContext.setUserId(user.getUserId());
Calendar calendar = Calendar.getInstance();
calendar.setTime(dt);
calendar.add(Calendar.DAY_OF_MONTH, 7);
ConfigurazioneServiceUtil.storeConfig(
"conf.geniocivile.sorteggio.data.prossimo.sorteggio", new SimpleDateFormat(
"dd/MM/yyyy").format(calendar.getTime()), serviceContext);
}
}
} catch (SystemException | ParseException | PortalException e) {
_log.error("error", e);
}
lock.unlock();
}
}
private static boolean isGiornoSorteggio(long companyId, Date dt) throws SystemException, ParseException {
Calendar calendar = Calendar.getInstance();
calendar.setTime(dt);
int dowOggi = calendar.get(Calendar.DAY_OF_WEEK);
int oraOggi = calendar.get(Calendar.HOUR_OF_DAY);
int dowSorteggio = Integer.parseInt(ConfigurazioneLocalServiceUtil.findByC_ChiaveString(companyId,
ConfigurazioneConstants.DAY_OF_WEEK_SORTEGGIO));
int oraSorteggio = Integer.parseInt(ConfigurazioneLocalServiceUtil.findByC_ChiaveString(companyId,
ConfigurazioneConstants.HOUR_OF_DAY_SORTEGGIO));
return (dowOggi == dowSorteggio) && (oraOggi == oraSorteggio);
}
}

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/scheduler/SchedulerWorkflow.java

@ -30,6 +30,7 @@ public class SchedulerWorkflow implements MessageListener {
private static final Log _log = LogFactoryUtil.getLog(SchedulerWorkflow.class); private static final Log _log = LogFactoryUtil.getLog(SchedulerWorkflow.class);
private static final Lock lock = new ReentrantLock(); private static final Lock lock = new ReentrantLock();
@Override
public void receive(Message message) throws MessageListenerException { public void receive(Message message) throws MessageListenerException {
if (lock.tryLock()) { if (lock.tryLock()) {
_log.info("Inizio elaborazione"); _log.info("Inizio elaborazione");

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

@ -0,0 +1,334 @@
package it.mwg.sismica.bo.util;
import it.tref.liferay.portos.bo.model.Comune;
import it.tref.liferay.portos.bo.model.ControlloPratica;
import it.tref.liferay.portos.bo.model.DettPratica;
import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.Provincia;
import it.tref.liferay.portos.bo.model.Soggetto;
import it.tref.liferay.portos.bo.model.Territorio;
import it.tref.liferay.portos.bo.service.AvvisoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ComuneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ProvinciaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.SoggettoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.SorteggioLocalServiceUtil;
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants;
import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil;
import it.tref.liferay.portos.bo.util.AvvisoUtil;
import it.tref.liferay.portos.report.shared.constants.ReportConstants;
import it.tref.liferay.portos.report.shared.dto.ReportDto;
import it.tref.liferay.portos.report.shared.util.ReportUtil;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.lang.time.DateUtils;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.repository.model.Folder;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.Company;
import com.liferay.portal.model.Role;
import com.liferay.portal.model.RoleConstants;
import com.liferay.portal.service.CompanyLocalServiceUtil;
import com.liferay.portal.service.RoleLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
public class SorteggioPraticaUtil {
private static final Lock lock = new ReentrantLock();
public static final String DATE_TIME_FORMAT = "dd/MM/yyyy HH:mm:ss";
public final static String APERTO = "APERTO";
public final static String CHIUSO = "CHIUSO";
private static final String FOLDER_SORTEGGIO = "Report_Sorteggio";
private static final String FILE_ENTRY_TEMPLATE_SORTEGGIO = "Sorteggio";
/**
*
* Implementazione della procedura di sorteggio secondo i requisiti della
* Regione Siciliana.
*
* @author Manifattura Web Group per Regione Siciliana
* @param companyId
* @param dtSorteggio
* @throws PortalException
* @throws SystemException
*/
public static List<String> sorteggio(long companyId, Date dtSorteggio) throws PortalException,
SystemException {
List<String> esito = new ArrayList<>();
if (lock.tryLock()) {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_FORMAT);
esito.add("Sorteggio iniziato in data " + sdf.format(dtSorteggio) + ".<br><br>");
Map<String, List<IntPratica>> sorteggiabili = IntPraticaLocalServiceUtil.findSorteggiabiliNew(
companyId, dtSorteggio);
int numeroSorteggiabili = 0;
for (Map.Entry<String, List<IntPratica>> s : sorteggiabili.entrySet()) {
numeroSorteggiabili += s.getValue().size();
}
esito.add("<h1>" + numeroSorteggiabili + " pratiche sottoposte a sorteggio.</h1>");
SecureRandom rnd = new SecureRandom();
List<IntPratica> sorteggiate = new ArrayList<>();
for (Map.Entry<String, List<IntPratica>> s : sorteggiabili.entrySet()) {
String codiceProvincia = s.getKey();
List<IntPratica> elenco = s.getValue();
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(companyId, codiceProvincia);
long numeroSorteggiate = (long) Math.ceil(0.1 * elenco.size());
String testoSorteggio;
if (numeroSorteggiate > 1) {
testoSorteggio = "saranno estratte " + numeroSorteggiate + " pratiche";
} else {
testoSorteggio = "sarà estratta 1 pratica";
}
esito.add("<h2><small>(" + sdf.format(new Date()) + ")</small> Provincia di "
+ provincia.getProvincia() + " " + elenco.size() + " pratiche, " + testoSorteggio
+ ".</h2><ol>");
Map<Integer, IntPratica> ordinate = new HashMap<>();
int chiave;
for (IntPratica pratica : elenco) {
do {
chiave = rnd.nextInt();
} while (ordinate.containsKey(chiave));
ordinate.put(chiave, pratica);
}
TreeMap<Integer, IntPratica> mescolate = new TreeMap<Integer, IntPratica>(ordinate);
long contatore = 0;
for (Map.Entry<Integer, IntPratica> m : mescolate.entrySet()) {
IntPratica pratica = m.getValue();
long intPraticaId = pratica.getIntPraticaId();
DettPratica dettPratica = DettPraticaLocalServiceUtil
.getLastCompletedByIntPratica(intPraticaId);
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(dettPratica.getCompanyId());
serviceContext.setScopeGroupId(dettPratica.getGroupId());
serviceContext.setUserId(dettPratica.getUserId());
if (contatore++ < numeroSorteggiate) {
sorteggiate.add(pratica);
esito.add("<li>Sorteggiata: " + pratica.getNumeroProgetto() + " (id " + intPraticaId
+ ") del " + sdf.format(pratica.getDtPratica()) + " (" + m.getKey()
+ ")</li>");
} else {
pratica.setDtSorteggio(dtSorteggio);
IntPraticaLocalServiceUtil.updateIntPratica(pratica);
esito.add("<li>Non sorteggiata: " + pratica.getNumeroProgetto() + " (id "
+ intPraticaId + ") del " + sdf.format(pratica.getDtPratica()) + " ("
+ m.getKey() + ")</li>");
}
}
esito.add("</ol>");
}
if (sorteggiate.size() > 0) {
saveSorteggio(companyId, sorteggiate, dtSorteggio);
}
esito.add("Sorteggio terminato in data " + sdf.format(new Date()) + ".<br><br>");
creaReportSorteggio(companyId, dtSorteggio, esito);
// Salvataggio data ultimo sorteggio
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId);
serviceContext.setScopeGroupId(-1L);
serviceContext.setUserId(UserLocalServiceUtil.getDefaultUserId(companyId));
ConfigurazioneLocalServiceUtil.storeConfig(ConfigurazioneConstants.DATE_ULTIMO_SORTEGGIO,
sdf.format(dtSorteggio), serviceContext);
lock.unlock();
}
return esito;
}
private static FileEntry creaReportSorteggio(long companyId, Date dtSorteggio, List<String> contenuto)
throws PortalException, SystemException {
Role role = RoleLocalServiceUtil.getRole(companyId, RoleConstants.ADMINISTRATOR);
long userId = UserLocalServiceUtil.getRoleUsers(role.getRoleId(), 0, 1).get(0).getUserId();
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Folder folderTemplate = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Template");
FileEntry fileEntryTemplate = DLAppLocalServiceUtil.getFileEntry(folderTemplate.getGroupId(),
folderTemplate.getFolderId(), FILE_ENTRY_TEMPLATE_SORTEGGIO);
Folder folderReport = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO);
StringBuilder sb = new StringBuilder(contenuto.size());
for (String riga : contenuto) {
sb.append(riga);
}
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("html", sb.toString());
ReportDto reportDto = new ReportDto();
reportDto.setFileEntryIds(new long[] { fileEntryTemplate.getFileEntryId() });
reportDto.setFolderId(folderReport.getFolderId());
reportDto.setFileName(reportFileName(companyId, dtSorteggio));
reportDto.setHeader("");
reportDto.setHeaderHeight(1);
reportDto.setFooter("");
reportDto.setFooterHeight(40);
reportDto.setParameters(parameters);
reportDto.setShowNumberOfPage(true);
reportDto.setType(ReportConstants.ReportType.VELOCITY_TO_PDF.toString());
String resourcePath = SorteggioPraticaUtil.class.getName().replaceAll("\\w+\\.", "../")
.replace(SorteggioPraticaUtil.class.getSimpleName(), "resource/asseverazioni");
reportDto.setPortalURL(SorteggioPraticaUtil.class.getResource(resourcePath).getPath());
ReportUtil.generateReport(companyId, userId, reportDto, null);
return null;
}
private static String reportFileName(long companyId, Date dtSorteggio) {
Calendar calSorteggio = DateUtils.toCalendar(dtSorteggio);
String anno = String.valueOf(calSorteggio.get(Calendar.YEAR));
int settimana = calSorteggio.get(Calendar.WEEK_OF_YEAR);
return reportFileName(companyId, anno, settimana);
}
private static String reportFileName(long companyId, String anno, int settimana) {
return "Sorteggio_" + settimana + "_" + anno + "_" + companyId;
}
/**
* @author Manifattura Web Group per Regione Siciliana
*
* @param companyId
* @param pratiche
* Lista di pratiche sorteggiate
* @param dtSorteggio
* Data del sorteggio
* @throws PortalException
* @throws SystemException
*/
private static void saveSorteggio(long companyId, List<IntPratica> pratiche, Date dtSorteggio)
throws PortalException, SystemException {
long numeroEstrazione = 1;
for (IntPratica pratica : pratiche) {
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(pratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId());
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(),
comune.getCodiceProvincia());
DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(pratica
.getIntPraticaId());
String committente = "";
List<Soggetto> soggetti = SoggettoLocalServiceUtil
.findByIntPratica_TipologiaSoggetto_Aggiuntivo_Rimosso(pratica.getIntPraticaId(),
TipoSoggettoUtil.COMMITTENTE, false, false);
if (soggetti.size() > 0) {
Soggetto soggetto = soggetti.get(0);
// Bug 32771
if (Validator.isNotNull(soggetto.getNome()) && Validator.isNotNull(soggetto.getCognome()))
committente = soggetto.getNome() + " " + soggetto.getCognome();
else if (Validator.isNotNull(soggetto.getDenominazione()))
committente = soggetto.getDenominazione();
else
committente = soggetto.getLegaleRap();
}
// anno, mese, settimana della data sorteggio
Calendar calSorteggio = Calendar.getInstance();
calSorteggio.setTime(dtSorteggio);
String anno = String.valueOf(calSorteggio.get(Calendar.YEAR));
String mese = String.format("%02d", calSorteggio.get(Calendar.MONTH) + 1);
int settimana = calSorteggio.get(Calendar.WEEK_OF_YEAR);
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(dettPratica.getCompanyId());
serviceContext.setScopeGroupId(dettPratica.getGroupId());
serviceContext.setUserId(dettPratica.getUserId());
SorteggioLocalServiceUtil.addSorteggio(pratica.getIntPraticaId(), dettPratica.getDettPraticaId(),
anno, mese, settimana, dtSorteggio, "", APERTO, "", numeroEstrazione++,
pratica.getNumeroProgetto(), committente, comune.getDenominazione(),
provincia.getProvincia(), false, pratica.getIntPraticaId(), false, serviceContext);
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil.addControlloPratica(
pratica.getGroupId(), pratica.getUserId(), pratica.getIntPraticaId(),
dettPratica.getDettPraticaId(), true, serviceContext);
long fileEntryIdTemplate = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(
serviceContext.getCompanyId(), "conf.geniocivile.avviso.template.id.deposito.S");
AvvisoLocalServiceUtil.addAvviso(pratica.getIntPraticaId(), "Avviso di sorteggio", dtSorteggio,
AvvisoUtil.TIPO_AVVISO_DIRETTO, StatoPraticaConstants.SOTTOPOSTA_A_PARERE,
fileEntryIdTemplate, dettPratica.getDettPraticaId(), DettPratica.class.getName(),
controlloPratica.getControlloPraticaId(), serviceContext);
IntPraticaLocalServiceUtil.updateIntPraticaSorteggio(pratica.getIntPraticaId(), dtSorteggio,
StatoPraticaConstants.SOTTOPOSTA_A_PARERE);
}
}
public static FileEntry getFileEntrySorteggio(long companyId, long groupId, Date dtSorteggio)
throws PortalException, SystemException {
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Folder folder = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO);
String fileName = reportFileName(companyId, dtSorteggio);
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(groupId, folder.getFolderId(), fileName);
return fileEntry;
}
public static FileEntry getFileEntrySorteggio(long companyId, long groupId, int settimana, String anno)
throws PortalException, SystemException {
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Folder folder = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO);
String fileName = reportFileName(companyId, anno, settimana);
return DLAppLocalServiceUtil.getFileEntry(groupId, folder.getFolderId(), fileName);
}
}

17
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/PortosAdministrationPortlet.java

@ -2,13 +2,12 @@ package it.tref.liferay.portos.bo.portlet;
import it.mwg.sismica.bo.util.PuliziaDatabase; import it.mwg.sismica.bo.util.PuliziaDatabase;
import it.mwg.sismica.bo.util.SismicaUtil; import it.mwg.sismica.bo.util.SismicaUtil;
import it.mwg.sismica.bo.util.SorteggioPraticaUtil;
import it.tref.liferay.portos.bo.model.ControlloPratica; 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.model.IntPratica; import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.Sorteggio; import it.tref.liferay.portos.bo.model.Sorteggio;
import it.tref.liferay.portos.bo.model.Territorio; import it.tref.liferay.portos.bo.model.Territorio;
import it.tref.liferay.portos.bo.service.AsseverazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.AvvisoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ConfigurazioneServiceUtil; import it.tref.liferay.portos.bo.service.ConfigurazioneServiceUtil;
import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
@ -33,10 +32,8 @@ import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.util.WebKeys; import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.model.User;
import com.liferay.portal.service.ServiceContext; import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.ServiceContextFactory; import com.liferay.portal.service.ServiceContextFactory;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.theme.ThemeDisplay; import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.util.bridges.mvc.MVCPortlet; import com.liferay.util.bridges.mvc.MVCPortlet;
@ -114,21 +111,17 @@ public class PortosAdministrationPortlet extends MVCPortlet {
} }
public void lanciaSorteggio(ActionRequest actionRequest, ActionResponse actionResponse) { public void lanciaSorteggio(ActionRequest actionRequest, ActionResponse actionResponse) {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
List<String> esito = null; List<String> esito = null;
try {
Date now = new Date();
_log.info("Sorteggio lanciato manualmente"); _log.info("Sorteggio lanciato manualmente");
esito = SorteggioLocalServiceUtil.sorteggio(themeDisplay.getCompanyId(), now); try {
esito = SorteggioPraticaUtil.sorteggio(themeDisplay.getCompanyId(), new Date());
} catch (Exception e) { } catch (PortalException | SystemException e) {
_log.error("error", e); _log.error("error", e);
} }
if (esito != null) if (esito != null)
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()])); actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()]));
// avvioWorkflowSorteggiate();
} }
public void testInterno(ActionRequest actionRequest, ActionResponse actionResponse) { public void testInterno(ActionRequest actionRequest, ActionResponse actionResponse) {

149
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/scheduler/SchedulerPratiche.java

@ -1,4 +1,3 @@
package it.tref.liferay.portos.bo.scheduler; package it.tref.liferay.portos.bo.scheduler;
import it.tref.liferay.portos.bo.model.Collaudo; import it.tref.liferay.portos.bo.model.Collaudo;
@ -71,7 +70,8 @@ public class SchedulerPratiche implements MessageListener {
for (int cursor = 0; cursor <= count; cursor += SIZE) { for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<IntPratica> intPratiche = IntPraticaLocalServiceUtil.findFascicoliNotProgetto(cursor, cursor + SIZE); List<IntPratica> intPratiche = IntPraticaLocalServiceUtil.findFascicoliNotProgetto(
cursor, cursor + SIZE);
for (IntPratica intPratica : intPratiche) { for (IntPratica intPratica : intPratiche) {
@ -79,7 +79,8 @@ public class SchedulerPratiche implements MessageListener {
User user = UserLocalServiceUtil.getUser(intPratica.getUserId()); User user = UserLocalServiceUtil.getUser(intPratica.getUserId());
PrincipalThreadLocal.setName(user.getUserId()); PrincipalThreadLocal.setName(user.getUserId());
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil
.create(user);
PermissionThreadLocal.setPermissionChecker(permissionChecker); PermissionThreadLocal.setPermissionChecker(permissionChecker);
assegnaNumeroProgetto(intPratica); assegnaNumeroProgetto(intPratica);
@ -104,8 +105,8 @@ public class SchedulerPratiche implements MessageListener {
for (int cursor = 0; cursor <= count; cursor += SIZE) { for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<DettPratica> dettPratiche = List<DettPratica> dettPratiche = DettPraticaLocalServiceUtil
DettPraticaLocalServiceUtil.findPraticheCompleteNotProtocollo(cursor, cursor + SIZE); .findPraticheCompleteNotProtocollo(cursor, cursor + SIZE);
for (DettPratica dettPratica : dettPratiche) { for (DettPratica dettPratica : dettPratiche) {
@ -113,10 +114,12 @@ public class SchedulerPratiche implements MessageListener {
User user = UserLocalServiceUtil.getUser(dettPratica.getUserId()); User user = UserLocalServiceUtil.getUser(dettPratica.getUserId());
PrincipalThreadLocal.setName(user.getUserId()); PrincipalThreadLocal.setName(user.getUserId());
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil
.create(user);
PermissionThreadLocal.setPermissionChecker(permissionChecker); PermissionThreadLocal.setPermissionChecker(permissionChecker);
protocollazione(dettPratica.getCompanyId(), dettPratica.getGroupId(), dettPratica); protocollazione(dettPratica.getCompanyId(), dettPratica.getGroupId(),
dettPratica);
} catch (Exception e) { } catch (Exception e) {
_log.error("Error DettPraticaId=" + dettPratica.getDettPraticaId(), e); _log.error("Error DettPraticaId=" + dettPratica.getDettPraticaId(), e);
@ -138,8 +141,8 @@ public class SchedulerPratiche implements MessageListener {
for (int cursor = 0; cursor <= count; cursor += SIZE) { for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<FineLavori> fineLavoris = List<FineLavori> fineLavoris = FineLavoriLocalServiceUtil
FineLavoriLocalServiceUtil.findFineLavoriCompleteNotProtocollo(cursor, cursor + SIZE); .findFineLavoriCompleteNotProtocollo(cursor, cursor + SIZE);
for (FineLavori fineLavori : fineLavoris) { for (FineLavori fineLavori : fineLavoris) {
@ -147,10 +150,12 @@ public class SchedulerPratiche implements MessageListener {
User user = UserLocalServiceUtil.getUser(fineLavori.getUserId()); User user = UserLocalServiceUtil.getUser(fineLavori.getUserId());
PrincipalThreadLocal.setName(user.getUserId()); PrincipalThreadLocal.setName(user.getUserId());
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil
.create(user);
PermissionThreadLocal.setPermissionChecker(permissionChecker); PermissionThreadLocal.setPermissionChecker(permissionChecker);
protocollazione(fineLavori.getCompanyId(), fineLavori.getGroupId(), fineLavori); protocollazione(fineLavori.getCompanyId(), fineLavori.getGroupId(),
fineLavori);
} catch (Exception e) { } catch (Exception e) {
_log.error("Error fineLavoriId=" + fineLavori.getFineLavoriId(), e); _log.error("Error fineLavoriId=" + fineLavori.getFineLavoriId(), e);
@ -172,8 +177,8 @@ public class SchedulerPratiche implements MessageListener {
for (int cursor = 0; cursor <= count; cursor += SIZE) { for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<FineLavori> fineLavoris = List<FineLavori> fineLavoris = FineLavoriLocalServiceUtil
FineLavoriLocalServiceUtil.findFineLavoriCompleteNotGestite(cursor, cursor + SIZE); .findFineLavoriCompleteNotGestite(cursor, cursor + SIZE);
for (FineLavori fineLavori : fineLavoris) { for (FineLavori fineLavori : fineLavoris) {
@ -181,10 +186,12 @@ public class SchedulerPratiche implements MessageListener {
User user = UserLocalServiceUtil.getUser(fineLavori.getUserId()); User user = UserLocalServiceUtil.getUser(fineLavori.getUserId());
PrincipalThreadLocal.setName(user.getUserId()); PrincipalThreadLocal.setName(user.getUserId());
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil
.create(user);
PermissionThreadLocal.setPermissionChecker(permissionChecker); PermissionThreadLocal.setPermissionChecker(permissionChecker);
creaAvvisoVidimazione(fineLavori.getCompanyId(), fineLavori.getGroupId(), fineLavori.getUserId(), creaAvvisoVidimazione(fineLavori.getCompanyId(), fineLavori.getGroupId(),
fineLavori.getIntPraticaId(), fineLavori.getFineLavoriId(), FineLavori.class.getName()); fineLavori.getUserId(), fineLavori.getIntPraticaId(),
fineLavori.getFineLavoriId(), FineLavori.class.getName());
fineLavori.setGestita(true); fineLavori.setGestita(true);
FineLavoriLocalServiceUtil.updateFineLavori(fineLavori); FineLavoriLocalServiceUtil.updateFineLavori(fineLavori);
@ -208,7 +215,8 @@ public class SchedulerPratiche implements MessageListener {
for (int cursor = 0; cursor <= count; cursor += SIZE) { for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<Collaudo> collaudi = CollaudoLocalServiceUtil.findCollaudiCompletiNotProtocollo(cursor, cursor + SIZE); List<Collaudo> collaudi = CollaudoLocalServiceUtil.findCollaudiCompletiNotProtocollo(
cursor, cursor + SIZE);
for (Collaudo collaudo : collaudi) { for (Collaudo collaudo : collaudi) {
@ -216,7 +224,8 @@ public class SchedulerPratiche implements MessageListener {
User user = UserLocalServiceUtil.getUser(collaudo.getUserId()); User user = UserLocalServiceUtil.getUser(collaudo.getUserId());
PrincipalThreadLocal.setName(user.getUserId()); PrincipalThreadLocal.setName(user.getUserId());
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil
.create(user);
PermissionThreadLocal.setPermissionChecker(permissionChecker); PermissionThreadLocal.setPermissionChecker(permissionChecker);
protocollazione(collaudo.getCompanyId(), collaudo.getGroupId(), collaudo); protocollazione(collaudo.getCompanyId(), collaudo.getGroupId(), collaudo);
@ -240,7 +249,8 @@ public class SchedulerPratiche implements MessageListener {
for (int cursor = 0; cursor <= count; cursor += SIZE) { for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<Collaudo> collaudi = CollaudoLocalServiceUtil.findCollaudiCompletiNotGestiti(cursor, cursor + SIZE); List<Collaudo> collaudi = CollaudoLocalServiceUtil.findCollaudiCompletiNotGestiti(
cursor, cursor + SIZE);
for (Collaudo collaudo : collaudi) { for (Collaudo collaudo : collaudi) {
@ -248,10 +258,12 @@ public class SchedulerPratiche implements MessageListener {
User user = UserLocalServiceUtil.getUser(collaudo.getUserId()); User user = UserLocalServiceUtil.getUser(collaudo.getUserId());
PrincipalThreadLocal.setName(user.getUserId()); PrincipalThreadLocal.setName(user.getUserId());
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil
.create(user);
PermissionThreadLocal.setPermissionChecker(permissionChecker); PermissionThreadLocal.setPermissionChecker(permissionChecker);
creaAvvisoVidimazione(collaudo.getCompanyId(), collaudo.getGroupId(), collaudo.getUserId(), creaAvvisoVidimazione(collaudo.getCompanyId(), collaudo.getGroupId(),
collaudo.getIntPraticaId(), collaudo.getCollaudoId(), Collaudo.class.getName()); collaudo.getUserId(), collaudo.getIntPraticaId(),
collaudo.getCollaudoId(), Collaudo.class.getName());
collaudo.setGestita(true); collaudo.setGestita(true);
CollaudoLocalServiceUtil.updateCollaudo(collaudo); CollaudoLocalServiceUtil.updateCollaudo(collaudo);
@ -273,8 +285,8 @@ public class SchedulerPratiche implements MessageListener {
for (int cursor = 0; cursor <= count; cursor += SIZE) { for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<DettPratica> dettPratiche = List<DettPratica> dettPratiche = DettPraticaLocalServiceUtil
DettPraticaLocalServiceUtil.findPraticheCompleteNotGestite(cursor, cursor + SIZE); .findPraticheCompleteNotGestite(cursor, cursor + SIZE);
for (DettPratica dettPratica : dettPratiche) { for (DettPratica dettPratica : dettPratiche) {
@ -282,7 +294,8 @@ public class SchedulerPratiche implements MessageListener {
User user = UserLocalServiceUtil.getUser(dettPratica.getUserId()); User user = UserLocalServiceUtil.getUser(dettPratica.getUserId());
PrincipalThreadLocal.setName(user.getUserId()); PrincipalThreadLocal.setName(user.getUserId());
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil
.create(user);
PermissionThreadLocal.setPermissionChecker(permissionChecker); PermissionThreadLocal.setPermissionChecker(permissionChecker);
gestionePratica(dettPratica); gestionePratica(dettPratica);
@ -297,28 +310,27 @@ public class SchedulerPratiche implements MessageListener {
} }
} }
// versionamento // versionamento
count = DettPraticaLocalServiceUtil.countPraticheCompletateNonversionate(); count = DettPraticaLocalServiceUtil.countPraticheCompletateNonversionate();
if (count > 0) { if (count > 0) {
for (Company company : CompanyLocalServiceUtil.getCompanies()) { for (Company company : CompanyLocalServiceUtil.getCompanies()) {
String condition = String condition = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(
ConfigurazioneLocalServiceUtil.findByC_ChiaveString(company.getCompanyId(), company.getCompanyId(), ConfigurazioneConstants.SCHEDULER_VERSIONING);
ConfigurazioneConstants.SCHEDULER_VERSIONING);
if (Boolean.parseBoolean(condition)) { if (Boolean.parseBoolean(condition)) {
for (int cursor = 0; cursor <= count; cursor += SIZE) { for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<DettPratica> dettPratiche = List<DettPratica> dettPratiche = DettPraticaLocalServiceUtil
DettPraticaLocalServiceUtil.findPraticheCompletateNonVersionate(cursor, cursor + SIZE); .findPraticheCompletateNonVersionate(cursor, cursor + SIZE);
for (DettPratica dettPratica : dettPratiche) { for (DettPratica dettPratica : dettPratiche) {
try { try {
DettPraticaServiceUtil.sendToVersioning(dettPratica.getDettPraticaId(), dettPratica.getCompanyId()); DettPraticaServiceUtil.sendToVersioning(
dettPratica.getDettPraticaId(), dettPratica.getCompanyId());
} catch (Exception e) { } catch (Exception e) {
_log.error("Error", e); _log.error("Error", e);
@ -342,8 +354,8 @@ public class SchedulerPratiche implements MessageListener {
} }
} }
private void creaAvvisoVidimazione(long companyId, long groupId, long userId, long intPraticaId, long classPk, private void creaAvvisoVidimazione(long companyId, long groupId, long userId, long intPraticaId,
String className) throws SystemException, PortalException { long classPk, String className) throws SystemException, PortalException {
String descLong = StringPool.BLANK; String descLong = StringPool.BLANK;
Date dtAvviso = new Date(); Date dtAvviso = new Date();
String tipoAvviso = AvvisoUtil.TIPO_AVVISO_DIRETTO; String tipoAvviso = AvvisoUtil.TIPO_AVVISO_DIRETTO;
@ -359,8 +371,10 @@ public class SchedulerPratiche implements MessageListener {
propertiesTemplateType = StatoPraticaConstants.VARIAZIONE_SOGGETTI; propertiesTemplateType = StatoPraticaConstants.VARIAZIONE_SOGGETTI;
} }
} }
String propertiesTemplate = AvvisoUtil.getAllTipoDocumentoFileTemplateProps().get(propertiesTemplateType); String propertiesTemplate = AvvisoUtil.getAllTipoDocumentoFileTemplateProps().get(
long fileEntryIdTemplate = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, propertiesTemplate); propertiesTemplateType);
long fileEntryIdTemplate = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId,
propertiesTemplate);
long controlloPraticaId = 0l; long controlloPraticaId = 0l;
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
@ -368,12 +382,13 @@ public class SchedulerPratiche implements MessageListener {
serviceContext.setScopeGroupId(groupId); serviceContext.setScopeGroupId(groupId);
serviceContext.setUserId(userId); serviceContext.setUserId(userId);
AvvisoLocalServiceUtil.addAvviso(intPraticaId, descLong, dtAvviso, tipoAvviso, tipoDocumento, fileEntryIdTemplate, AvvisoLocalServiceUtil.addAvviso(intPraticaId, descLong, dtAvviso, tipoAvviso, tipoDocumento,
classPk, className, controlloPraticaId, serviceContext); fileEntryIdTemplate, classPk, className, controlloPraticaId, serviceContext);
} }
private IntPratica assegnaNumeroProgetto(IntPratica intPratica) throws PortalException, SystemException { private IntPratica assegnaNumeroProgetto(IntPratica intPratica) throws PortalException, SystemException {
// in caso di errore successivo alla protocollazione salto questa operazione // in caso di errore successivo alla protocollazione salto questa
// operazione
if (Validator.isNull(intPratica.getNumeroProgetto())) { if (Validator.isNull(intPratica.getNumeroProgetto())) {
intPratica = IntPraticaLocalServiceUtil.addNumeroProgetto(intPratica.getIntPraticaId()); intPratica = IntPraticaLocalServiceUtil.addNumeroProgetto(intPratica.getIntPraticaId());
@ -395,7 +410,8 @@ public class SchedulerPratiche implements MessageListener {
String tipoIntegrazione = dettPratica.getTipoIntegrazione(); String tipoIntegrazione = dettPratica.getTipoIntegrazione();
// 1o Avviso di ricezione corretta o in errore della pratica // 1o Avviso di ricezione corretta o in errore della pratica
int count = AvvisoLocalServiceUtil.countAvvisoByClassPk_ClassName(dettPratica.getDettPraticaId(), DettPratica.class.getName()); int count = AvvisoLocalServiceUtil.countAvvisoByClassPk_ClassName(dettPratica.getDettPraticaId(),
DettPratica.class.getName());
// in caso di errore non genere un nuovo avviso // in caso di errore non genere un nuovo avviso
if (count == 0) { if (count == 0) {
// tutte le integrazioni eccetto annulla valida // tutte le integrazioni eccetto annulla valida
@ -417,17 +433,22 @@ public class SchedulerPratiche implements MessageListener {
} else if (TipoIntegrazioneUtil.VARIAZIONE_SOGGETTO.equals(tipoIntegrazione)) { } else if (TipoIntegrazioneUtil.VARIAZIONE_SOGGETTO.equals(tipoIntegrazione)) {
String propertiesTemplateType = StatoPraticaConstants.VARIAZIONE_SOGGETTI; String propertiesTemplateType = StatoPraticaConstants.VARIAZIONE_SOGGETTI;
String propertiesTemplate = AvvisoUtil.getAllTipoDocumentoFileTemplateProps().get(propertiesTemplateType); String propertiesTemplate = AvvisoUtil.getAllTipoDocumentoFileTemplateProps().get(
long fileEntryIdTemplate = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(serviceContext.getCompanyId(), propertiesTemplate); propertiesTemplateType);
long fileEntryIdTemplate = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(
serviceContext.getCompanyId(), propertiesTemplate);
AvvisoLocalServiceUtil.addAvviso(dettPratica.getIntPraticaId(), StringPool.BLANK, new Date(), AvvisoUtil.TIPO_AVVISO_DIRETTO, StatoPraticaConstants.VIDIMATA, fileEntryIdTemplate, AvvisoLocalServiceUtil.addAvviso(dettPratica.getIntPraticaId(), StringPool.BLANK,
dettPratica.getDettPraticaId(), DettPratica.class.getName(), 0l, serviceContext); new Date(), AvvisoUtil.TIPO_AVVISO_DIRETTO, StatoPraticaConstants.VIDIMATA,
fileEntryIdTemplate, dettPratica.getDettPraticaId(), DettPratica.class.getName(),
0l, serviceContext);
} }
} else { } else {
// avviso standard da stato pratica // avviso standard da stato pratica
AvvisoLocalServiceUtil.createStandardAvvisoPratica(intPratica, dettPratica.getDettPraticaId(), AvvisoLocalServiceUtil.createStandardAvvisoPratica(intPratica,
DettPratica.class.getName(), serviceContext, AvvisoUtil.TIPO_AVVISO_DIRETTO, StringPool.BLANK, 0l); dettPratica.getDettPraticaId(), DettPratica.class.getName(), serviceContext,
AvvisoUtil.TIPO_AVVISO_DIRETTO, StringPool.BLANK, 0l);
} }
} }
@ -439,14 +460,16 @@ public class SchedulerPratiche implements MessageListener {
ControlloPraticaLocalServiceUtil.gestioneWFVarianti(cp); ControlloPraticaLocalServiceUtil.gestioneWFVarianti(cp);
} }
dettPratica = DettPraticaLocalServiceUtil.updateDettPraticaGestita(dettPratica.getDettPraticaId(),
dettPratica = DettPraticaLocalServiceUtil.updateDettPraticaGestita(dettPratica.getDettPraticaId(), true); true);
DettPraticaLocalServiceUtil.updateAsset(dettPratica, null, true); DettPraticaLocalServiceUtil.updateAsset(dettPratica, null, true);
} }
private DettPratica protocollazione(long companyId, long groupId, DettPratica dettPratica) throws Exception { private DettPratica protocollazione(long companyId, long groupId, DettPratica dettPratica)
throws Exception {
// in caso di errore successivo alla protocollazione salto questa operazione // in caso di errore successivo alla protocollazione salto questa
// operazione
if (Validator.isNull(dettPratica.getProtocollo())) { if (Validator.isNull(dettPratica.getProtocollo())) {
String protocollo = null; String protocollo = null;
@ -457,7 +480,8 @@ public class SchedulerPratiche implements MessageListener {
throw new Exception("errore nella protocollazione pratica"); throw new Exception("errore nella protocollazione pratica");
} }
dettPratica = DettPraticaLocalServiceUtil.updateDettPraticaProtocollo(dettPratica.getDettPraticaId(), protocollo); dettPratica = DettPraticaLocalServiceUtil.updateDettPraticaProtocollo(
dettPratica.getDettPraticaId(), protocollo);
} }
return dettPratica; return dettPratica;
@ -465,10 +489,10 @@ public class SchedulerPratiche implements MessageListener {
private FineLavori protocollazione(long companyId, long groupId, FineLavori fineLavori) throws Exception { private FineLavori protocollazione(long companyId, long groupId, FineLavori fineLavori) throws Exception {
// in caso di errore successivo alla protocollazione salto questa operazione // in caso di errore successivo alla protocollazione salto questa
// operazione
if (Validator.isNull(fineLavori.getProtocollo())) { if (Validator.isNull(fineLavori.getProtocollo())) {
String protocollo = null; String protocollo = null;
String title = fineLavori.getFineLavoriId() + "_" + System.currentTimeMillis(); String title = fineLavori.getFineLavoriId() + "_" + System.currentTimeMillis();
@ -477,7 +501,8 @@ public class SchedulerPratiche implements MessageListener {
throw new Exception("errore nella protocollazione fine lavori"); throw new Exception("errore nella protocollazione fine lavori");
} }
fineLavori = FineLavoriLocalServiceUtil.updateFineLavoriProtocollo(fineLavori.getFineLavoriId(), protocollo); fineLavori = FineLavoriLocalServiceUtil.updateFineLavoriProtocollo(fineLavori.getFineLavoriId(),
protocollo);
} }
return fineLavori; return fineLavori;
@ -485,10 +510,10 @@ public class SchedulerPratiche implements MessageListener {
private Collaudo protocollazione(long companyId, long groupId, Collaudo collaudo) throws Exception { private Collaudo protocollazione(long companyId, long groupId, Collaudo collaudo) throws Exception {
// in caso di errore successivo alla protocollazione salto questa operazione // in caso di errore successivo alla protocollazione salto questa
// operazione
if (Validator.isNull(collaudo.getProtocollo())) { if (Validator.isNull(collaudo.getProtocollo())) {
String protocollo = null; String protocollo = null;
String title = collaudo.getCollaudoId() + "_" + System.currentTimeMillis(); String title = collaudo.getCollaudoId() + "_" + System.currentTimeMillis();
@ -497,22 +522,24 @@ public class SchedulerPratiche implements MessageListener {
throw new Exception("errore nella protocollazione collaudo"); throw new Exception("errore nella protocollazione collaudo");
} }
collaudo = CollaudoLocalServiceUtil.updateCollaudoProtocollo(collaudo.getCollaudoId(), protocollo); collaudo = CollaudoLocalServiceUtil
.updateCollaudoProtocollo(collaudo.getCollaudoId(), protocollo);
} }
return collaudo; return collaudo;
} }
private ControlloPratica avvioWorkflow(DettPratica dettPratica, long userId, ServiceContext serviceContext) throws Exception { private ControlloPratica avvioWorkflow(DettPratica dettPratica, long userId, ServiceContext serviceContext)
throws Exception {
if (dettPratica.isCompleta() && !dettPratica.isGestita()) { if (dettPratica.isCompleta() && !dettPratica.isGestita()) {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId()); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId());
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
if (WorkflowUtil.needToStartWorkflow(dettPratica)) { if (WorkflowUtil.needToStartWorkflow(dettPratica)) {
boolean updateFlagControlloObbligatorio = true; boolean updateFlagControlloObbligatorio = true;
// ADT: bug id=7 gestione workflow // ADT: bug id=7 gestione workflow
ControlloPratica cp=ControlloPraticaLocalServiceUtil.addControlloPratica(territorio.getGroupId(), userId, ControlloPratica cp = ControlloPraticaLocalServiceUtil.addControlloPratica(
intPratica.getIntPraticaId(), dettPratica.getDettPraticaId(), updateFlagControlloObbligatorio, territorio.getGroupId(), userId, intPratica.getIntPraticaId(),
serviceContext); dettPratica.getDettPraticaId(), updateFlagControlloObbligatorio, serviceContext);
return cp; return cp;
} }
} }

155
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/scheduler/SchedulerSorteggio.java

@ -1,155 +0,0 @@
package it.tref.liferay.portos.bo.scheduler;
import it.tref.liferay.portos.bo.model.ControlloPratica;
import it.tref.liferay.portos.bo.model.DettPratica;
import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.Territorio;
import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.SorteggioLocalServiceUtil;
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil;
import it.tref.liferay.portos.bo.util.SorteggioPraticaUtil;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.messaging.Message;
import com.liferay.portal.kernel.messaging.MessageListener;
import com.liferay.portal.kernel.messaging.MessageListenerException;
import com.liferay.portal.model.Company;
import com.liferay.portal.service.CompanyLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.util.portlet.PortletProps;
public class SchedulerSorteggio implements MessageListener {
private static final Log _log = LogFactoryUtil.getLog(SchedulerSorteggio.class);
private static final Lock lock = new ReentrantLock();
@Override
public void receive(Message message) throws MessageListenerException {
if (lock.tryLock()) {
sorteggio();
lock.unlock();
}
}
private void sorteggio() {
try {
String defaultCompany = PortletProps.get("portos.default.company");
for (Company company : CompanyLocalServiceUtil.getCompanies()) {
long companyId = company.getCompanyId();
Date now = new Date();
if (SorteggioPraticaUtil.isGiornoSorteggio(companyId, now)) {
// _log.info("È giorno di sorteggio per la compagnia " + companyId);
// SorteggioLocalServiceUtil.sorteggio(companyId, now);
}
}
} catch (Exception e) {
_log.error("error", e);
}
}
private void avvioWorkflowSorteggiate() {
try {
// int count =
// SorteggioLocalServiceUtil.countDettPraticaWorkflowNonAvviato();
// if (count > 0) {
// for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<Long> dettPraticaIds = SorteggioLocalServiceUtil.getDettPraticaWorkflowNonAvviato(-1, -1);
for (Long dettPraticaId : dettPraticaIds) {
DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(dettPraticaId);
long intPraticaId = dettPratica.getIntPraticaId();
ServiceContext serviceContext = getServiceContext(dettPratica);
avvioWorkflow(intPraticaId, dettPratica, serviceContext);
}
// }
// }
} catch (Exception e) {
_log.error("error", e);
}
}
// TODO sanatoriaRimossa
// private void avvioWorkflowSanatoriaDepositoOpereNonConformi() {
// try {
// int count =
// WorkflowUtil.countIntPraticaIdsPerAvvioWorkflowSanatoriaDepositoOpereNonConformi();
// if (count > 0) {
// for (int cursor = 0; cursor <= count; cursor += SIZE) {
// List<Long> intPraticaIds =
// WorkflowUtil.findIntPraticaIdsPerAvvioWorkflowSanatoriaDepositoOpereNonConformi(cursor,
// cursor
// + SIZE);
// for (Long intPraticaId : intPraticaIds) {
// DettPratica dettPratica =
// DettPraticaLocalServiceUtil.getLastDettPratica(intPraticaId);
// ServiceContext serviceContext = getServiceContext(dettPratica);
// avvioWorkflow(intPraticaId, dettPratica, serviceContext);
// }
// }
// }
// } catch (Exception e) {
// _log.error("error", e);
// }
// }
//
// private void avvioWorkflowSanatoriaDepositoOpereConformi() {
// try {
// int count =
// WorkflowUtil.countIntPraticaIdsPerAvvioWorkflowSanatoriaDepositoOpereConformi();
// if (count > 0) {
// for (int cursor = 0; cursor <= count; cursor += SIZE) {
// List<Long> intPraticaIds =
// WorkflowUtil.findIntPraticaIdsPerAvvioWorkflowSanatoriaDepositoOpereConformi(cursor,
// cursor +
// SIZE);
// for (Long intPraticaId : intPraticaIds) {
// DettPratica dettPratica =
// DettPraticaLocalServiceUtil.getLastDettPratica(intPraticaId);
// ServiceContext serviceContext = getServiceContext(dettPratica);
// avvioWorkflow(intPraticaId, dettPratica, serviceContext);
// }
// }
// }
// } catch (Exception e) {
// _log.error("error", e);
// }
// }
private void avvioWorkflow(long intPraticaId, DettPratica dettPratica, ServiceContext serviceContext)
throws Exception {
long userId = dettPratica.getUserId();
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId());
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
ControlloPratica cp = ControlloPraticaLocalServiceUtil.addControlloPratica(territorio.getGroupId(),
userId, intPratica.getIntPraticaId(), dettPratica.getDettPraticaId(), false, serviceContext);
// ADT: bug id=7 gestione workflow
ControlloPraticaLocalServiceUtil.gestioneWFVarianti(cp);
}
private ServiceContext getServiceContext(DettPratica dettPratica) {
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(dettPratica.getCompanyId());
serviceContext.setScopeGroupId(dettPratica.getGroupId());
serviceContext.setUserId(dettPratica.getUserId());
return serviceContext;
}
}

24
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/base/SorteggioLocalServiceClpInvoker.java

@ -267,22 +267,18 @@ public class SorteggioLocalServiceClpInvoker {
_methodParameterTypes225 = new String[] { "long" }; _methodParameterTypes225 = new String[] { "long" };
_methodName226 = "sorteggio"; _methodName226 = "search";
_methodParameterTypes226 = new String[] { "long", "java.util.Date" }; _methodParameterTypes226 = new String[] {
_methodName227 = "search";
_methodParameterTypes227 = new String[] {
"java.lang.Long", "java.lang.String", "java.lang.String", "int", "java.lang.Long", "java.lang.String", "java.lang.String", "int",
"java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String",
"java.lang.String", "java.lang.Long", "java.lang.String", "int", "java.lang.String", "java.lang.Long", "java.lang.String", "int",
"int" "int"
}; };
_methodName228 = "count"; _methodName227 = "count";
_methodParameterTypes228 = new String[] { _methodParameterTypes227 = new String[] {
"java.lang.Long", "java.lang.String", "java.lang.String", "int", "java.lang.Long", "java.lang.String", "java.lang.String", "int",
"java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String",
"java.lang.String", "java.lang.Long", "java.lang.String" "java.lang.String", "java.lang.Long", "java.lang.String"
@ -610,12 +606,6 @@ public class SorteggioLocalServiceClpInvoker {
if (_methodName226.equals(name) && if (_methodName226.equals(name) &&
Arrays.deepEquals(_methodParameterTypes226, parameterTypes)) { Arrays.deepEquals(_methodParameterTypes226, parameterTypes)) {
return SorteggioLocalServiceUtil.sorteggio(((Long)arguments[0]).longValue(),
(java.util.Date)arguments[1]);
}
if (_methodName227.equals(name) &&
Arrays.deepEquals(_methodParameterTypes227, parameterTypes)) {
return SorteggioLocalServiceUtil.search((java.lang.Long)arguments[0], return SorteggioLocalServiceUtil.search((java.lang.Long)arguments[0],
(java.lang.String)arguments[1], (java.lang.String)arguments[2], (java.lang.String)arguments[1], (java.lang.String)arguments[2],
((Integer)arguments[3]).intValue(), ((Integer)arguments[3]).intValue(),
@ -626,8 +616,8 @@ public class SorteggioLocalServiceClpInvoker {
((Integer)arguments[11]).intValue()); ((Integer)arguments[11]).intValue());
} }
if (_methodName228.equals(name) && if (_methodName227.equals(name) &&
Arrays.deepEquals(_methodParameterTypes228, parameterTypes)) { Arrays.deepEquals(_methodParameterTypes227, parameterTypes)) {
return SorteggioLocalServiceUtil.count((java.lang.Long)arguments[0], return SorteggioLocalServiceUtil.count((java.lang.Long)arguments[0],
(java.lang.String)arguments[1], (java.lang.String)arguments[2], (java.lang.String)arguments[1], (java.lang.String)arguments[2],
((Integer)arguments[3]).intValue(), ((Integer)arguments[3]).intValue(),
@ -735,6 +725,4 @@ public class SorteggioLocalServiceClpInvoker {
private String[] _methodParameterTypes226; private String[] _methodParameterTypes226;
private String _methodName227; private String _methodName227;
private String[] _methodParameterTypes227; private String[] _methodParameterTypes227;
private String _methodName228;
private String[] _methodParameterTypes228;
} }

9
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AvvisoLocalServiceImpl.java

@ -116,14 +116,21 @@ public class AvvisoLocalServiceImpl extends AvvisoLocalServiceBaseImpl {
} }
String propertiesTemplate = null; String propertiesTemplate = null;
String tipoProcedura = intPratica.getTipoProcedura();
switch (statoPratica) { switch (statoPratica) {
case StatoPraticaConstants.VIDIMATA: case StatoPraticaConstants.VIDIMATA:
String tipoProcedura = intPratica.getTipoProcedura();
if (null == tipoProcedura) if (null == tipoProcedura)
tipoProcedura = Constants.PROCEDURA_A; tipoProcedura = Constants.PROCEDURA_A;
propertiesTemplate = AvvisoUtil.getAllTipoDocumentoFileTemplateProps().get( propertiesTemplate = AvvisoUtil.getAllTipoDocumentoFileTemplateProps().get(
"DP" + tipoProcedura); "DP" + tipoProcedura);
break; break;
case StatoPraticaConstants.SOTTOPOSTA_A_PARERE:
if (Validator.isNull(tipoProcedura) || tipoProcedura.equalsIgnoreCase(Constants.PROCEDURA_A)) {
propertiesTemplate = AvvisoUtil.getAllTipoDocumentoFileTemplateProps().get(statoPratica);
} else {
propertiesTemplate = AvvisoUtil.getAllTipoDocumentoFileTemplateProps().get("DPPS");
}
break;
default: default:
propertiesTemplate = AvvisoUtil.getAllTipoDocumentoFileTemplateProps().get(statoPratica); propertiesTemplate = AvvisoUtil.getAllTipoDocumentoFileTemplateProps().get(statoPratica);
} }

8
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/SorteggioLocalServiceImpl.java

@ -12,9 +12,9 @@
package it.tref.liferay.portos.bo.service.impl; package it.tref.liferay.portos.bo.service.impl;
import it.mwg.sismica.bo.util.SorteggioPraticaUtil;
import it.tref.liferay.portos.bo.model.Sorteggio; import it.tref.liferay.portos.bo.model.Sorteggio;
import it.tref.liferay.portos.bo.service.base.SorteggioLocalServiceBaseImpl; import it.tref.liferay.portos.bo.service.base.SorteggioLocalServiceBaseImpl;
import it.tref.liferay.portos.bo.util.SorteggioPraticaUtil;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -390,12 +390,6 @@ public class SorteggioLocalServiceImpl extends SorteggioLocalServiceBaseImpl {
} }
public List<String> sorteggio(long companyId, Date dtSorteggio) throws Exception {
return SorteggioPraticaUtil.sorteggio(companyId, dtSorteggio);
}
// Bug 32653 // Bug 32653
public List<Sorteggio> search(Long groupId, String anno, String mese, int settimana, String committente, public List<Sorteggio> search(Long groupId, String anno, String mese, int settimana, String committente,
String tecnico, String comune, String pratica, Long numeroEstrazione, String provincia, String tecnico, String comune, String pratica, Long numeroEstrazione, String provincia,

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/AllegatoManualePersistenceImpl.java

@ -45,6 +45,7 @@ import it.tref.liferay.portos.bo.NoSuchAllegatoManualeException;
import it.tref.liferay.portos.bo.model.AllegatoManuale; import it.tref.liferay.portos.bo.model.AllegatoManuale;
import it.tref.liferay.portos.bo.model.impl.AllegatoManualeImpl; import it.tref.liferay.portos.bo.model.impl.AllegatoManualeImpl;
import it.tref.liferay.portos.bo.model.impl.AllegatoManualeModelImpl; import it.tref.liferay.portos.bo.model.impl.AllegatoManualeModelImpl;
import it.tref.liferay.portos.bo.service.persistence.AllegatoManualePersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/AsseverazionePersistenceImpl.java

@ -46,6 +46,7 @@ import it.tref.liferay.portos.bo.NoSuchAsseverazioneException;
import it.tref.liferay.portos.bo.model.Asseverazione; import it.tref.liferay.portos.bo.model.Asseverazione;
import it.tref.liferay.portos.bo.model.impl.AsseverazioneImpl; import it.tref.liferay.portos.bo.model.impl.AsseverazioneImpl;
import it.tref.liferay.portos.bo.model.impl.AsseverazioneModelImpl; import it.tref.liferay.portos.bo.model.impl.AsseverazioneModelImpl;
import it.tref.liferay.portos.bo.service.persistence.AsseverazionePersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/AvvisoPersistenceImpl.java

@ -46,6 +46,7 @@ import it.tref.liferay.portos.bo.NoSuchAvvisoException;
import it.tref.liferay.portos.bo.model.Avviso; import it.tref.liferay.portos.bo.model.Avviso;
import it.tref.liferay.portos.bo.model.impl.AvvisoImpl; import it.tref.liferay.portos.bo.model.impl.AvvisoImpl;
import it.tref.liferay.portos.bo.model.impl.AvvisoModelImpl; import it.tref.liferay.portos.bo.model.impl.AvvisoModelImpl;
import it.tref.liferay.portos.bo.service.persistence.AvvisoPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/CollaudoPersistenceImpl.java

@ -45,6 +45,7 @@ import it.tref.liferay.portos.bo.NoSuchCollaudoException;
import it.tref.liferay.portos.bo.model.Collaudo; import it.tref.liferay.portos.bo.model.Collaudo;
import it.tref.liferay.portos.bo.model.impl.CollaudoImpl; import it.tref.liferay.portos.bo.model.impl.CollaudoImpl;
import it.tref.liferay.portos.bo.model.impl.CollaudoModelImpl; import it.tref.liferay.portos.bo.model.impl.CollaudoModelImpl;
import it.tref.liferay.portos.bo.service.persistence.CollaudoPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/ComunePersistenceImpl.java

@ -46,6 +46,7 @@ import it.tref.liferay.portos.bo.NoSuchComuneException;
import it.tref.liferay.portos.bo.model.Comune; import it.tref.liferay.portos.bo.model.Comune;
import it.tref.liferay.portos.bo.model.impl.ComuneImpl; import it.tref.liferay.portos.bo.model.impl.ComuneImpl;
import it.tref.liferay.portos.bo.model.impl.ComuneModelImpl; import it.tref.liferay.portos.bo.model.impl.ComuneModelImpl;
import it.tref.liferay.portos.bo.service.persistence.ComunePersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/ComunicazionePersistenceImpl.java

@ -45,6 +45,7 @@ import it.tref.liferay.portos.bo.NoSuchComunicazioneException;
import it.tref.liferay.portos.bo.model.Comunicazione; import it.tref.liferay.portos.bo.model.Comunicazione;
import it.tref.liferay.portos.bo.model.impl.ComunicazioneImpl; import it.tref.liferay.portos.bo.model.impl.ComunicazioneImpl;
import it.tref.liferay.portos.bo.model.impl.ComunicazioneModelImpl; import it.tref.liferay.portos.bo.model.impl.ComunicazioneModelImpl;
import it.tref.liferay.portos.bo.service.persistence.ComunicazionePersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/ConfigurazionePersistenceImpl.java

@ -45,6 +45,7 @@ import it.tref.liferay.portos.bo.NoSuchConfigurazioneException;
import it.tref.liferay.portos.bo.model.Configurazione; import it.tref.liferay.portos.bo.model.Configurazione;
import it.tref.liferay.portos.bo.model.impl.ConfigurazioneImpl; import it.tref.liferay.portos.bo.model.impl.ConfigurazioneImpl;
import it.tref.liferay.portos.bo.model.impl.ConfigurazioneModelImpl; import it.tref.liferay.portos.bo.model.impl.ConfigurazioneModelImpl;
import it.tref.liferay.portos.bo.service.persistence.ConfigurazionePersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/ControlloPraticaPersistenceImpl.java

@ -45,6 +45,7 @@ import it.tref.liferay.portos.bo.NoSuchControlloPraticaException;
import it.tref.liferay.portos.bo.model.ControlloPratica; import it.tref.liferay.portos.bo.model.ControlloPratica;
import it.tref.liferay.portos.bo.model.impl.ControlloPraticaImpl; import it.tref.liferay.portos.bo.model.impl.ControlloPraticaImpl;
import it.tref.liferay.portos.bo.model.impl.ControlloPraticaModelImpl; import it.tref.liferay.portos.bo.model.impl.ControlloPraticaModelImpl;
import it.tref.liferay.portos.bo.service.persistence.ControlloPraticaPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/DelegaPersistenceImpl.java

@ -46,6 +46,7 @@ import it.tref.liferay.portos.bo.NoSuchDelegaException;
import it.tref.liferay.portos.bo.model.Delega; import it.tref.liferay.portos.bo.model.Delega;
import it.tref.liferay.portos.bo.model.impl.DelegaImpl; import it.tref.liferay.portos.bo.model.impl.DelegaImpl;
import it.tref.liferay.portos.bo.model.impl.DelegaModelImpl; import it.tref.liferay.portos.bo.model.impl.DelegaModelImpl;
import it.tref.liferay.portos.bo.service.persistence.DelegaPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/DettPraticaPersistenceImpl.java

@ -45,6 +45,7 @@ import it.tref.liferay.portos.bo.NoSuchDettPraticaException;
import it.tref.liferay.portos.bo.model.DettPratica; import it.tref.liferay.portos.bo.model.DettPratica;
import it.tref.liferay.portos.bo.model.impl.DettPraticaImpl; import it.tref.liferay.portos.bo.model.impl.DettPraticaImpl;
import it.tref.liferay.portos.bo.model.impl.DettPraticaModelImpl; import it.tref.liferay.portos.bo.model.impl.DettPraticaModelImpl;
import it.tref.liferay.portos.bo.service.persistence.DettPraticaPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/DocAggiuntivaPersistenceImpl.java

@ -45,6 +45,7 @@ import it.tref.liferay.portos.bo.NoSuchDocAggiuntivaException;
import it.tref.liferay.portos.bo.model.DocAggiuntiva; import it.tref.liferay.portos.bo.model.DocAggiuntiva;
import it.tref.liferay.portos.bo.model.impl.DocAggiuntivaImpl; import it.tref.liferay.portos.bo.model.impl.DocAggiuntivaImpl;
import it.tref.liferay.portos.bo.model.impl.DocAggiuntivaModelImpl; import it.tref.liferay.portos.bo.model.impl.DocAggiuntivaModelImpl;
import it.tref.liferay.portos.bo.service.persistence.DocAggiuntivaPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/DocPraticaPersistenceImpl.java

@ -46,6 +46,7 @@ import it.tref.liferay.portos.bo.NoSuchDocPraticaException;
import it.tref.liferay.portos.bo.model.DocPratica; import it.tref.liferay.portos.bo.model.DocPratica;
import it.tref.liferay.portos.bo.model.impl.DocPraticaImpl; import it.tref.liferay.portos.bo.model.impl.DocPraticaImpl;
import it.tref.liferay.portos.bo.model.impl.DocPraticaModelImpl; import it.tref.liferay.portos.bo.model.impl.DocPraticaModelImpl;
import it.tref.liferay.portos.bo.service.persistence.DocPraticaPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/FineLavoriPersistenceImpl.java

@ -45,6 +45,7 @@ import it.tref.liferay.portos.bo.NoSuchFineLavoriException;
import it.tref.liferay.portos.bo.model.FineLavori; import it.tref.liferay.portos.bo.model.FineLavori;
import it.tref.liferay.portos.bo.model.impl.FineLavoriImpl; import it.tref.liferay.portos.bo.model.impl.FineLavoriImpl;
import it.tref.liferay.portos.bo.model.impl.FineLavoriModelImpl; import it.tref.liferay.portos.bo.model.impl.FineLavoriModelImpl;
import it.tref.liferay.portos.bo.service.persistence.FineLavoriPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/HistoryWorkflowActionPersistenceImpl.java

@ -42,6 +42,7 @@ import it.tref.liferay.portos.bo.NoSuchHistoryWorkflowActionException;
import it.tref.liferay.portos.bo.model.HistoryWorkflowAction; import it.tref.liferay.portos.bo.model.HistoryWorkflowAction;
import it.tref.liferay.portos.bo.model.impl.HistoryWorkflowActionImpl; import it.tref.liferay.portos.bo.model.impl.HistoryWorkflowActionImpl;
import it.tref.liferay.portos.bo.model.impl.HistoryWorkflowActionModelImpl; import it.tref.liferay.portos.bo.model.impl.HistoryWorkflowActionModelImpl;
import it.tref.liferay.portos.bo.service.persistence.HistoryWorkflowActionPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/IUVPersistenceImpl.java

@ -46,6 +46,7 @@ import it.tref.liferay.portos.bo.NoSuchIUVException;
import it.tref.liferay.portos.bo.model.IUV; import it.tref.liferay.portos.bo.model.IUV;
import it.tref.liferay.portos.bo.model.impl.IUVImpl; import it.tref.liferay.portos.bo.model.impl.IUVImpl;
import it.tref.liferay.portos.bo.model.impl.IUVModelImpl; import it.tref.liferay.portos.bo.model.impl.IUVModelImpl;
import it.tref.liferay.portos.bo.service.persistence.IUVPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/InfoFascicoloPersistenceImpl.java

@ -45,6 +45,7 @@ import it.tref.liferay.portos.bo.NoSuchInfoFascicoloException;
import it.tref.liferay.portos.bo.model.InfoFascicolo; import it.tref.liferay.portos.bo.model.InfoFascicolo;
import it.tref.liferay.portos.bo.model.impl.InfoFascicoloImpl; import it.tref.liferay.portos.bo.model.impl.InfoFascicoloImpl;
import it.tref.liferay.portos.bo.model.impl.InfoFascicoloModelImpl; import it.tref.liferay.portos.bo.model.impl.InfoFascicoloModelImpl;
import it.tref.liferay.portos.bo.service.persistence.InfoFascicoloPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/IntPraticaPersistenceImpl.java

@ -48,6 +48,7 @@ import it.tref.liferay.portos.bo.NoSuchIntPraticaException;
import it.tref.liferay.portos.bo.model.IntPratica; import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.impl.IntPraticaImpl; import it.tref.liferay.portos.bo.model.impl.IntPraticaImpl;
import it.tref.liferay.portos.bo.model.impl.IntPraticaModelImpl; import it.tref.liferay.portos.bo.model.impl.IntPraticaModelImpl;
import it.tref.liferay.portos.bo.service.persistence.IntPraticaPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/PagamentoPersistenceImpl.java

@ -46,6 +46,7 @@ import it.tref.liferay.portos.bo.NoSuchPagamentoException;
import it.tref.liferay.portos.bo.model.Pagamento; import it.tref.liferay.portos.bo.model.Pagamento;
import it.tref.liferay.portos.bo.model.impl.PagamentoImpl; import it.tref.liferay.portos.bo.model.impl.PagamentoImpl;
import it.tref.liferay.portos.bo.model.impl.PagamentoModelImpl; import it.tref.liferay.portos.bo.model.impl.PagamentoModelImpl;
import it.tref.liferay.portos.bo.service.persistence.PagamentoPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/ParereGeologoPersistenceImpl.java

@ -45,6 +45,7 @@ import it.tref.liferay.portos.bo.NoSuchParereGeologoException;
import it.tref.liferay.portos.bo.model.ParereGeologo; import it.tref.liferay.portos.bo.model.ParereGeologo;
import it.tref.liferay.portos.bo.model.impl.ParereGeologoImpl; import it.tref.liferay.portos.bo.model.impl.ParereGeologoImpl;
import it.tref.liferay.portos.bo.model.impl.ParereGeologoModelImpl; import it.tref.liferay.portos.bo.model.impl.ParereGeologoModelImpl;
import it.tref.liferay.portos.bo.service.persistence.ParereGeologoPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/ProvinciaPersistenceImpl.java

@ -43,6 +43,7 @@ import it.tref.liferay.portos.bo.NoSuchProvinciaException;
import it.tref.liferay.portos.bo.model.Provincia; import it.tref.liferay.portos.bo.model.Provincia;
import it.tref.liferay.portos.bo.model.impl.ProvinciaImpl; import it.tref.liferay.portos.bo.model.impl.ProvinciaImpl;
import it.tref.liferay.portos.bo.model.impl.ProvinciaModelImpl; import it.tref.liferay.portos.bo.model.impl.ProvinciaModelImpl;
import it.tref.liferay.portos.bo.service.persistence.ProvinciaPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/SoggettoPersistenceImpl.java

@ -45,6 +45,7 @@ import it.tref.liferay.portos.bo.NoSuchSoggettoException;
import it.tref.liferay.portos.bo.model.Soggetto; import it.tref.liferay.portos.bo.model.Soggetto;
import it.tref.liferay.portos.bo.model.impl.SoggettoImpl; import it.tref.liferay.portos.bo.model.impl.SoggettoImpl;
import it.tref.liferay.portos.bo.model.impl.SoggettoModelImpl; import it.tref.liferay.portos.bo.model.impl.SoggettoModelImpl;
import it.tref.liferay.portos.bo.service.persistence.SoggettoPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/SorteggioPersistenceImpl.java

@ -45,6 +45,7 @@ import it.tref.liferay.portos.bo.NoSuchSorteggioException;
import it.tref.liferay.portos.bo.model.Sorteggio; import it.tref.liferay.portos.bo.model.Sorteggio;
import it.tref.liferay.portos.bo.model.impl.SorteggioImpl; import it.tref.liferay.portos.bo.model.impl.SorteggioImpl;
import it.tref.liferay.portos.bo.model.impl.SorteggioModelImpl; import it.tref.liferay.portos.bo.model.impl.SorteggioModelImpl;
import it.tref.liferay.portos.bo.service.persistence.SorteggioPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/StoricoSoggettoPraticaPersistenceImpl.java

@ -42,6 +42,7 @@ import it.tref.liferay.portos.bo.NoSuchStoricoSoggettoPraticaException;
import it.tref.liferay.portos.bo.model.StoricoSoggettoPratica; import it.tref.liferay.portos.bo.model.StoricoSoggettoPratica;
import it.tref.liferay.portos.bo.model.impl.StoricoSoggettoPraticaImpl; import it.tref.liferay.portos.bo.model.impl.StoricoSoggettoPraticaImpl;
import it.tref.liferay.portos.bo.model.impl.StoricoSoggettoPraticaModelImpl; import it.tref.liferay.portos.bo.model.impl.StoricoSoggettoPraticaModelImpl;
import it.tref.liferay.portos.bo.service.persistence.StoricoSoggettoPraticaPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/TempisticaPersistenceImpl.java

@ -45,6 +45,7 @@ import it.tref.liferay.portos.bo.NoSuchTempisticaException;
import it.tref.liferay.portos.bo.model.Tempistica; import it.tref.liferay.portos.bo.model.Tempistica;
import it.tref.liferay.portos.bo.model.impl.TempisticaImpl; import it.tref.liferay.portos.bo.model.impl.TempisticaImpl;
import it.tref.liferay.portos.bo.model.impl.TempisticaModelImpl; import it.tref.liferay.portos.bo.model.impl.TempisticaModelImpl;
import it.tref.liferay.portos.bo.service.persistence.TempisticaPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/TerritorioPersistenceImpl.java

@ -44,6 +44,7 @@ import it.tref.liferay.portos.bo.NoSuchTerritorioException;
import it.tref.liferay.portos.bo.model.Territorio; import it.tref.liferay.portos.bo.model.Territorio;
import it.tref.liferay.portos.bo.model.impl.TerritorioImpl; import it.tref.liferay.portos.bo.model.impl.TerritorioImpl;
import it.tref.liferay.portos.bo.model.impl.TerritorioModelImpl; import it.tref.liferay.portos.bo.model.impl.TerritorioModelImpl;
import it.tref.liferay.portos.bo.service.persistence.TerritorioPersistence;
import java.io.Serializable; import java.io.Serializable;

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/persistence/UtentePortosPersistenceImpl.java

@ -43,6 +43,7 @@ import it.tref.liferay.portos.bo.NoSuchUtentePortosException;
import it.tref.liferay.portos.bo.model.UtentePortos; import it.tref.liferay.portos.bo.model.UtentePortos;
import it.tref.liferay.portos.bo.model.impl.UtentePortosImpl; import it.tref.liferay.portos.bo.model.impl.UtentePortosImpl;
import it.tref.liferay.portos.bo.model.impl.UtentePortosModelImpl; import it.tref.liferay.portos.bo.model.impl.UtentePortosModelImpl;
import it.tref.liferay.portos.bo.service.persistence.UtentePortosPersistence;
import java.io.Serializable; import java.io.Serializable;

753
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/util/SorteggioPraticaUtil.java

@ -1,753 +0,0 @@
package it.tref.liferay.portos.bo.util;
import it.tref.liferay.portos.bo.model.Comune;
import it.tref.liferay.portos.bo.model.ControlloPratica;
import it.tref.liferay.portos.bo.model.DettPratica;
import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.Provincia;
import it.tref.liferay.portos.bo.model.Soggetto;
import it.tref.liferay.portos.bo.model.Sorteggio;
import it.tref.liferay.portos.bo.model.Territorio;
import it.tref.liferay.portos.bo.report.builder.bean.ReportSorteggioBean;
import it.tref.liferay.portos.bo.report.builder.builder.ReportSorteggioBeanBuilder;
import it.tref.liferay.portos.bo.service.AvvisoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ComuneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ProvinciaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.SoggettoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.SorteggioLocalServiceUtil;
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import it.tref.liferay.portos.bo.shared.util.FascicoloURLUtil;
import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants;
import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil;
import it.tref.liferay.portos.mailmanager.shared.messaging.util.MailManagerUtil;
import it.tref.liferay.portos.report.shared.constants.ReportConstants;
import it.tref.liferay.portos.report.shared.dto.ReportDto;
import it.tref.liferay.portos.report.shared.dto.ReportResultDto;
import it.tref.liferay.portos.report.shared.util.ReportUtil;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.text.MessageFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.language.LanguageUtil;
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.repository.model.Folder;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.LocaleUtil;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.model.Company;
import com.liferay.portal.model.Role;
import com.liferay.portal.model.RoleConstants;
import com.liferay.portal.service.CompanyLocalServiceUtil;
import com.liferay.portal.service.RoleLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portlet.documentlibrary.NoSuchFileException;
import com.liferay.portlet.documentlibrary.model.DLFolder;
import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
public class SorteggioPraticaUtil {
private static Log _log = LogFactoryUtil.getLog(SorteggioPraticaUtil.class);
public static final String DATE_TIME_FORMAT = "dd/MM/yyyy HH:mm:ss";
public final static String APERTO = "APERTO";
public final static String CHIUSO = "CHIUSO";
private static final String FOLDER_TEMPLATE_SORTEGGIO = "Template_Sorteggio";
private static final String FOLDER_SORTEGGIO = "Report_Sorteggio";
private static final String FILE_ENTRY_TEMPLATE_SORTEGGIO = "Sorteggio";
private static final String FILE_ENTRY_SORTEGGIO = "Sorteggio_{0}_{1}_{2}";
private static final String FILE_ENTRY_SORTEGGIO_OLD = "Sorteggio_{0}_{1}_{2}_{3}";
public static Date getDataSorteggio(long companyId, boolean next) throws SystemException {
Date dtSorteggio = null;
// Date dtSorteggio = new Date();
Integer dayOfWeekSorteggio = GetterUtil.getInteger(ConfigurazioneLocalServiceUtil
.findByC_ChiaveString(companyId, ConfigurazioneConstants.DAY_OF_WEEK_SORTEGGIO));
Integer startDaySorteggio = GetterUtil.getInteger(ConfigurazioneLocalServiceUtil
.findByC_ChiaveString(companyId, ConfigurazioneConstants.START_DAY_SORTEGGIO));
if (dayOfWeekSorteggio > 0 && dayOfWeekSorteggio <= 7 && startDaySorteggio > 0
&& startDaySorteggio <= 28) {
Calendar calendarSorteggio = Calendar.getInstance();
calendarSorteggio.set(Calendar.DATE, startDaySorteggio);
if (next) {
calendarSorteggio.add(Calendar.MONTH, 1);
}
while (calendarSorteggio.get(Calendar.DAY_OF_WEEK) != dayOfWeekSorteggio) {
calendarSorteggio.add(Calendar.DATE, 1);
}
// se festività -> prossima settimana
if (FestivitaUtil.isFestivo(calendarSorteggio.getTime())) {
calendarSorteggio.add(Calendar.WEEK_OF_YEAR, 1);
}
dtSorteggio = DateUtils.truncate(calendarSorteggio, Calendar.DATE).getTime();
}
return dtSorteggio;
}
public static boolean isGiornoSorteggio(long companyId, Date dt) throws SystemException, ParseException {
Date dtUltimoSorteggio = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss")
.parse(ConfigurazioneLocalServiceUtil.findByC_ChiaveString(companyId,
ConfigurazioneConstants.DATE_ULTIMO_SORTEGGIO));
// Almeno 3 giorni dall'ultimo sorteggio
if (dt.getTime() - dtUltimoSorteggio.getTime() > 3 * 24 * 60 * 60 * 1000) {
int dowOggi = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
int dowSorteggio = Integer.parseInt(ConfigurazioneLocalServiceUtil.findByC_ChiaveString(
companyId, ConfigurazioneConstants.DAY_OF_WEEK_SORTEGGIO));
if (dowOggi == dowSorteggio) {
}
}
return true;
}
/**
*
* Implementazione della procedura di sorteggio secondo i requisiti della
* Regione Siciliana.
*
* @author Manifattura Web Group per Regione Siciliana
* @param companyId
* @param dtSorteggio
* @throws PortalException
* @throws SystemException
*/
public static List<String> sorteggio(long companyId, Date dtSorteggio) throws PortalException,
SystemException {
List<String> esito = new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
esito.add("Sorteggio iniziato in data " + sdf.format(dtSorteggio) + ".<br><br>");
Map<String, List<IntPratica>> sorteggiabili = IntPraticaLocalServiceUtil.findSorteggiabiliNew(
companyId, dtSorteggio);
int numeroSorteggiabili = 0;
for (Map.Entry<String, List<IntPratica>> s : sorteggiabili.entrySet()) {
numeroSorteggiabili += s.getValue().size();
}
esito.add("<h1>" + numeroSorteggiabili + " pratiche sottoposte a sorteggio.</h1>");
SecureRandom rnd = new SecureRandom();
List<IntPratica> sorteggiate = new ArrayList<>();
for (Map.Entry<String, List<IntPratica>> s : sorteggiabili.entrySet()) {
String codiceProvincia = s.getKey();
List<IntPratica> elenco = s.getValue();
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(companyId, codiceProvincia);
long numeroSorteggiate = (long) Math.ceil(0.1 * elenco.size());
String testoSorteggio;
if (numeroSorteggiate > 1) {
testoSorteggio = "saranno estratte " + numeroSorteggiate + " pratiche";
} else {
testoSorteggio = "sarà estratta 1 pratica";
}
esito.add("<h2>Provincia di " + provincia.getProvincia() + " " + elenco.size()
+ " pratiche, " + testoSorteggio + ".</h2><ol>");
Map<Integer, IntPratica> ordinate = new HashMap<>();
int chiave;
for (IntPratica pratica : elenco) {
do {
chiave = rnd.nextInt();
} while (ordinate.containsKey(chiave));
ordinate.put(chiave, pratica);
}
TreeMap<Integer, IntPratica> mescolate = new TreeMap<Integer, IntPratica>(ordinate);
long contatore = 0;
long fileEntryIdTemplate = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId,
"conf.geniocivile.avviso.template.id.deposito.B2");
for (Map.Entry<Integer, IntPratica> m : mescolate.entrySet()) {
IntPratica pratica = m.getValue();
long intPraticaId = pratica.getIntPraticaId();
DettPratica dettPratica = DettPraticaLocalServiceUtil
.getLastCompletedByIntPratica(intPraticaId);
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(dettPratica.getCompanyId());
serviceContext.setScopeGroupId(dettPratica.getGroupId());
serviceContext.setUserId(dettPratica.getUserId());
if (contatore++ < numeroSorteggiate) {
sorteggiate.add(pratica);
esito.add("<li>Sorteggiata: " + pratica.getNumeroProgetto() + " (id " + intPraticaId
+ ") del " + sdf.format(pratica.getDtPratica()) + " (" + m.getKey() + ")</li>");
} else {
pratica.setDtSorteggio(dtSorteggio);
IntPraticaLocalServiceUtil.updateIntPratica(pratica);
esito.add("<li>Non sorteggiata: " + pratica.getNumeroProgetto() + " (id " + intPraticaId
+ ") del " + sdf.format(pratica.getDtPratica()) + " (" + m.getKey() + ")</li>");
}
}
esito.add("</ol>");
}
if (sorteggiate.size() > 0) {
saveSorteggio(companyId, sorteggiate, dtSorteggio);
}
esito.add("Sorteggio terminato in data " + sdf.format(dtSorteggio) + ".<br><br>");
creaReportSorteggio(companyId, dtSorteggio, esito);
// Salvataggio data ultimo sorteggio
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId);
serviceContext.setScopeGroupId(-1L);
serviceContext.setUserId(UserLocalServiceUtil.getDefaultUserId(companyId));
SimpleDateFormat simpleDateTimeFormat = new SimpleDateFormat(DATE_TIME_FORMAT);
esito.add("Sorteggio eseguito in data " + simpleDateTimeFormat.format(dtSorteggio));
ConfigurazioneLocalServiceUtil.storeConfig(ConfigurazioneConstants.DATE_ULTIMO_SORTEGGIO,
simpleDateTimeFormat.format(dtSorteggio), serviceContext);
// Log su file
String path = PropsUtil.get("liferay.home") + "/sorteggi";
try {
File folder = new File(path);
if (!folder.exists()) {
folder.mkdirs();
}
FileWriter writer = new FileWriter(path + "/sorteggio-"
+ new SimpleDateFormat("yyyy-MM-dd").format(dtSorteggio) + ".txt");
for (String string : esito)
writer.write(string + "\n");
writer.close();
} catch (IOException e) {
_log.error("Errore durante il salvataggio del report " + e.getMessage());
}
return esito;
}
private static FileEntry creaReportSorteggio(long companyId, Date dtSorteggio, List<String> contenuto)
throws PortalException, SystemException {
Role role = RoleLocalServiceUtil.getRole(companyId, RoleConstants.ADMINISTRATOR);
long userId = UserLocalServiceUtil.getRoleUsers(role.getRoleId(), 0, 1).get(0).getUserId();
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Folder folderTemplate = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Template");
FileEntry fileEntryTemplate = DLAppLocalServiceUtil.getFileEntry(folderTemplate.getGroupId(),
folderTemplate.getFolderId(), FILE_ENTRY_TEMPLATE_SORTEGGIO);
Folder folderReport = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO);
StringBuilder sb = new StringBuilder(contenuto.size());
for (String riga : contenuto) {
sb.append(riga);
}
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("html", sb.toString());
ReportDto reportDto = new ReportDto();
reportDto.setFileEntryIds(new long[] { fileEntryTemplate.getFileEntryId() });
reportDto.setFolderId(folderReport.getFolderId());
reportDto.setFileName(reportFileName(companyId, dtSorteggio));
reportDto.setHeader("");
reportDto.setHeaderHeight(1);
reportDto.setFooter("");
reportDto.setFooterHeight(40);
reportDto.setParameters(parameters);
reportDto.setShowNumberOfPage(true);
reportDto.setType(ReportConstants.ReportType.VELOCITY_TO_PDF.toString());
String resourcePath = SorteggioPraticaUtil.class.getName().replaceAll("\\w+\\.", "../")
.replace(SorteggioPraticaUtil.class.getSimpleName(), "resource/asseverazioni");
reportDto.setPortalURL(SorteggioPraticaUtil.class.getResource(resourcePath).getPath());
ReportUtil.generateReport(companyId, userId, reportDto, null);
return null;
}
private static String reportFileName(long companyId, Date dtSorteggio) {
Calendar calSorteggio = DateUtils.toCalendar(dtSorteggio);
String anno = String.valueOf(calSorteggio.get(Calendar.YEAR));
int settimana = calSorteggio.get(Calendar.WEEK_OF_YEAR);
return reportFileName(companyId, anno, settimana);
}
private static String reportFileName(long companyId, String anno, int settimana) {
return "Sorteggio_" + settimana + "_" + anno + "_" + companyId;
}
private static void invioMailSorteggio(IntPratica intPratica, DettPratica dettPratica,
ServiceContext serviceContext) {
try {
long intPraticaId = intPratica.getIntPraticaId();
List<Soggetto> soggetti = SoggettoLocalServiceUtil.getValidByIntPratica(intPraticaId);
List<String> toList = new ArrayList<String>();
for (Soggetto soggetto : soggetti) {
toList.add(soggetto.getEmail());
}
String[] to = toList.toArray(new String[toList.size()]);
String[] cc = new String[0];
String[] ccn = new String[0];
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId());
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(),
territorio.getCodiceProvincia());
String url = FascicoloURLUtil.getFascicoloFEViewURL(intPratica.getCompanyId(), intPraticaId,
"/html/fascicolofe/view_fascicolo.jsp", "");
JSONObject templateVariables = JSONFactoryUtil.createJSONObject();
templateVariables.put("comune", comune.getDenominazione());
templateVariables.put("intervento", dettPratica.getDescLongIntervento());
templateVariables.put("link", url);
templateVariables.put("praticaNum", intPratica.getNumeroProgetto());
templateVariables.put("provincia", provincia.getProvincia());
templateVariables.put("tipoPratica",
LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-" + intPratica.getTipoPratica()));
MailManagerUtil.sendMailByTemplatName(intPratica.getClass().getName(), intPraticaId,
"NOTIFICA-SORTEGGIO", to, cc, ccn, templateVariables, null, serviceContext);
} catch (PortalException | SystemException e) {
_log.error("Errore durante l'invio mail sorteggio della pratica " + intPratica.getIntPraticaId(),
e);
}
}
/**
* @author Manifattura Web Group per Regione Siciliana
*
* @param companyId
* @param pratiche
* Lista di pratiche sorteggiate
* @param dtSorteggio
* Data del sorteggio
* @throws PortalException
* @throws SystemException
*/
private static void saveSorteggio(long companyId, List<IntPratica> pratiche, Date dtSorteggio)
throws PortalException, SystemException {
long numeroEstrazione = 1;
for (IntPratica pratica : pratiche) {
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(pratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId());
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(),
comune.getCodiceProvincia());
DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(pratica
.getIntPraticaId());
String committente = "";
List<Soggetto> soggetti = SoggettoLocalServiceUtil
.findByIntPratica_TipologiaSoggetto_Aggiuntivo_Rimosso(pratica.getIntPraticaId(),
TipoSoggettoUtil.COMMITTENTE, false, false);
if (soggetti.size() > 0) {
Soggetto soggetto = soggetti.get(0);
// Bug 32771
if (Validator.isNotNull(soggetto.getNome()) && Validator.isNotNull(soggetto.getCognome()))
committente = soggetto.getNome() + " " + soggetto.getCognome();
else if (Validator.isNotNull(soggetto.getDenominazione()))
committente = soggetto.getDenominazione();
else
committente = soggetto.getLegaleRap();
}
// anno, mese, settimana della data sorteggio
Calendar calSorteggio = Calendar.getInstance();
calSorteggio.setTime(dtSorteggio);
String anno = String.valueOf(calSorteggio.get(Calendar.YEAR));
String mese = String.format("%02d", calSorteggio.get(Calendar.MONTH) + 1);
int settimana = calSorteggio.get(Calendar.WEEK_OF_YEAR);
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(dettPratica.getCompanyId());
serviceContext.setScopeGroupId(dettPratica.getGroupId());
serviceContext.setUserId(dettPratica.getUserId());
SorteggioLocalServiceUtil.addSorteggio(pratica.getIntPraticaId(), dettPratica.getDettPraticaId(),
anno, mese, settimana, dtSorteggio, "", APERTO, "", numeroEstrazione++,
pratica.getNumeroProgetto(), committente, comune.getDenominazione(),
provincia.getProvincia(), false, pratica.getIntPraticaId(), false, serviceContext);
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil.addControlloPratica(
pratica.getGroupId(), pratica.getUserId(), pratica.getIntPraticaId(),
dettPratica.getDettPraticaId(), true, serviceContext);
long fileEntryIdTemplate = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(
serviceContext.getCompanyId(), "conf.geniocivile.avviso.template.id.deposito.S");
AvvisoLocalServiceUtil.addAvviso(pratica.getIntPraticaId(), "Avviso di sorteggio", dtSorteggio,
AvvisoUtil.TIPO_AVVISO_DIRETTO, StatoPraticaConstants.SOTTOPOSTA_A_PARERE,
fileEntryIdTemplate, dettPratica.getDettPraticaId(), DettPratica.class.getName(),
controlloPratica.getControlloPraticaId(), serviceContext);
IntPraticaLocalServiceUtil.updateIntPraticaSorteggio(pratica.getIntPraticaId(), dtSorteggio,
StatoPraticaConstants.SOTTOPOSTA_A_PARERE);
}
}
private static void saveSorteggio(long companyId, long[] numeroEstrazione, List<Object[]> pratiche,
Date dtSorteggio, boolean mesePrecedente, boolean disabled) throws Exception {
for (Object[] pratica : pratiche) {
long praticaId = (Long) pratica[0];
boolean esterna = (Boolean) pratica[1];
long territorioId = (Long) pratica[2];
String numeroProgetto = (String) pratica[3];
String committente = (String) pratica[4];
long dettPraticaId = 0L;
long intPraticaId = 0L;
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(territorioId);
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId());
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(),
comune.getCodiceProvincia());
if (!esterna) {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(praticaId);
intPraticaId = intPratica.getIntPraticaId();
DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPratica
.getIntPraticaId());
dettPraticaId = dettPratica.getDettPraticaId();
List<Soggetto> soggetti = SoggettoLocalServiceUtil
.findByIntPratica_TipologiaSoggetto_Aggiuntivo_Rimosso(intPratica.getIntPraticaId(),
TipoSoggettoUtil.COMMITTENTE, false, false);
if (soggetti.size() > 0) {
// Bug 32771
if (Validator.isNotNull(soggetti.get(0).getNome())
&& Validator.isNotNull(soggetti.get(0).getCognome()))
committente = soggetti.get(0).getNome() + StringPool.SPACE
+ soggetti.get(0).getCognome();
else
committente = Validator.isNotNull(soggetti.get(0).getDenominazione()) ? soggetti.get(
0).getDenominazione() : soggetti.get(0).getLegaleRap();
}
}
// anno, mese della data sorteggio
Calendar calSorteggio = DateUtils.toCalendar(dtSorteggio);
String anno = String.valueOf(calSorteggio.get(Calendar.YEAR));
String mese = StringUtils.leftPad(String.valueOf(calSorteggio.get(Calendar.MONTH) + 1), 2, '0');
int settimana = calSorteggio.get(Calendar.WEEK_OF_YEAR);
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId);
serviceContext.setScopeGroupId(territorio.getGroupId());
serviceContext.setUserId(UserLocalServiceUtil.getDefaultUserId(companyId));
SorteggioLocalServiceUtil.addSorteggio(intPraticaId, dettPraticaId, anno, mese, settimana,
dtSorteggio, StringPool.BLANK, APERTO, StringPool.BLANK, numeroEstrazione[0]++,
numeroProgetto, committente, comune.getDenominazione(), provincia.getProvincia(),
esterna, (!esterna ? 0L : praticaId), mesePrecedente, serviceContext);
if (!esterna) {
IntPraticaLocalServiceUtil.updateIntPraticaSorteggio(praticaId, dtSorteggio);
} else {
SorteggioLocalServiceUtil.updateDataSorteggioPraticaEsterna(praticaId, dtSorteggio);
}
}
}
public static Date getDateMinSorteggioAnno(Date dt) {
Date[] rangeAnno = rangeSorteggioAnno(getMeseSorteggio(dt));
return rangeAnno[0];
}
public static FileEntry getFileEntrySorteggio(long companyId, long groupId, Date dtSorteggio)
throws PortalException, SystemException {
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Folder folder = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO);
String fileName = reportFileName(companyId, dtSorteggio);
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(groupId, folder.getFolderId(), fileName);
return fileEntry;
}
public static FileEntry getFileEntrySorteggio(long companyId, long groupId, int settimana, String anno)
throws PortalException, SystemException {
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Folder folder = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO);
String fileName = reportFileName(companyId, anno, settimana);
return DLAppLocalServiceUtil.getFileEntry(groupId, folder.getFolderId(), fileName);
}
/*
* Metodi Utilità
*/
private static void generateReport(long companyId, Date dtSorteggio, long gropuId) throws Exception {
Role role = RoleLocalServiceUtil.getRole(companyId, RoleConstants.ADMINISTRATOR);
long userId = UserLocalServiceUtil.getRoleUsers(role.getRoleId(), 0, 1).get(0).getUserId();
// anno, mese della data sorteggio
Calendar calSorteggio = DateUtils.toCalendar(dtSorteggio);
String anno = String.valueOf(calSorteggio.get(Calendar.YEAR));
String mese = StringUtils.leftPad(String.valueOf(calSorteggio.get(Calendar.MONTH) + 1), 2, '0');
int settimana = calSorteggio.get(Calendar.WEEK_OF_YEAR);
List<Sorteggio> sorteggios = new ArrayList<Sorteggio>(
SorteggioLocalServiceUtil.findByGroupId_Anno_Mese_Settimana(gropuId, anno, mese, settimana));
List<ReportSorteggioBean> reportSorteggioBeans = new ArrayList<ReportSorteggioBean>(sorteggios.size());
for (Sorteggio sorteggio : sorteggios) {
ReportSorteggioBean bean = ReportSorteggioBeanBuilder.build(sorteggio);
reportSorteggioBeans.add(bean);
}
Collections.sort(reportSorteggioBeans, new Comparator<ReportSorteggioBean>() {
@Override
public int compare(ReportSorteggioBean b1, ReportSorteggioBean b2) {
int compare = new Long(b1.getNumeroEstrazione()).compareTo(new Long(b2.getNumeroEstrazione()));
int compareProvincia = b1.getProvincia().compareTo(b2.getProvincia());
if (compareProvincia == 0) {
if (compare == 0) {
if (Validator.isNull(b1.getFascia())) {
return -1;
}
compare = b1.getFascia().compareTo(b2.getFascia());
if (compare == 0) {
return new Long(b1.getPratica()).compareTo(new Long(b2.getPratica()));
}
return compare;
}
return compare;
}
return compareProvincia;
}
});
// vuoto per forzare visualizzazione
if (reportSorteggioBeans.isEmpty()) {
reportSorteggioBeans.add(new ReportSorteggioBean());
}
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Folder folderTemplate = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_TEMPLATE_SORTEGGIO);
FileEntry fileEntryTemplate = DLAppLocalServiceUtil.getFileEntry(folderTemplate.getGroupId(),
folderTemplate.getFolderId(), FILE_ENTRY_TEMPLATE_SORTEGGIO);
String fileName = MessageFormat.format(FILE_ENTRY_SORTEGGIO, mese, anno, gropuId);
Folder folder = null;
try {
folder = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO);
} catch (PortalException e) {
folder = DLAppLocalServiceUtil.addFolder(userId, company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO, StringPool.BLANK,
new ServiceContext());
}
Map<String, Object> paramaters = new HashMap<String, Object>();
paramaters.put("DATA_SORTEGGIO",
new SimpleDateFormat("MMMM yyyy", java.util.Locale.ITALY).format(dtSorteggio));
int fasciaAMese = 0;
int fasciaAMesiPrec = 0;
int fasciaBMese = 0;
int fasciaBMesiPrec = 0;
int fasciaCMese = 0;
int fasciaCMesiPrec = 0;
// Task 32561
int zona4Mese = 0;
int zona4MesePrec = 0;
for (ReportSorteggioBean bean : reportSorteggioBeans) {
if (Validator.isNotNull(bean.getFascia())) {
if (bean.getFascia().equals(Constants.FASCIA_A)) {
if (bean.getFase().equals("1")) {
fasciaAMese++;
} else if (bean.getFase().equals("2")) {
fasciaAMesiPrec++;
}
} else if (bean.getFascia().equals(Constants.FASCIA_B)) {
if (bean.getFase().equals("1")) {
fasciaBMese++;
} else if (bean.getFase().equals("2")) {
fasciaBMesiPrec++;
}
} else if (bean.getFascia().equals(Constants.FASCIA_C)) {
if (bean.getFase().equals("1")) {
fasciaCMese++;
} else if (bean.getFase().equals("2")) {
fasciaCMesiPrec++;
}
}
}
// Task 32561
if (Validator.isNotNull(bean.getZona())) {
if (("livorno".equalsIgnoreCase(bean.getProvincia()) || "grosseto".equalsIgnoreCase(bean
.getProvincia())) && bean.getZona().equals(Constants.ZONA_4)) {
if (bean.getFase().equals("1")) {
zona4Mese++;
} else if (bean.getFase().equals("2")) {
zona4MesePrec++;
}
}
}
}
paramaters.put("FASCIA_A_MESE", fasciaAMese);
paramaters.put("FASCIA_A_MESI_PREC", fasciaAMesiPrec);
paramaters.put("FASCIA_B_MESE", fasciaBMese);
paramaters.put("FASCIA_B_MESI_PREC", fasciaBMesiPrec);
paramaters.put("FASCIA_C_MESE", fasciaCMese);
paramaters.put("FASCIA_C_MESI_PREC", fasciaCMesiPrec);
// Task 32561
paramaters.put("ZONA_4_MESE", zona4Mese);
paramaters.put("ZONA_4_MESE_PREC", zona4MesePrec);
// ServiceContext serviceContext = new ServiceContext();
// serviceContext.setCompanyId(companyId);
// serviceContext.setScopeGroupId(groupId);
// serviceContext.setUserId(userId);
ReportDto reportDto = new ReportDto();
reportDto.setFileEntryIds(new long[] { fileEntryTemplate.getFileEntryId() });
reportDto.setFolderId(folder.getFolderId());
reportDto.setFileName(fileName);
reportDto.setParameters(paramaters);
// reportDto.setDataSource(reportSorteggioBeans);
reportDto.setShowNumberOfPage(true);
reportDto.setType(ReportConstants.ReportType.JRXML_TO_PDF.toString());
ReportResultDto result = ReportUtil
.generateReport(companyId, userId, reportDto, reportSorteggioBeans);
long idFileEntry = result.getFileEntryIds()[0];
/*
* Message messageReport = new Message();
* messageReport.put(ReportConstants.FILE_ENTRY_ID_TEMPLATE,
* fileEntryTemplate.getFileEntryId());
* messageReport.put(ReportConstants.FOLDER_ID_REPORT,
* folder.getFolderId()); messageReport.put(ReportConstants.REPORT_NAME,
* fileName); messageReport.put(ReportConstants.SERVICE_CONTEXT,
* serviceContext); messageReport.put(ReportConstants.REPORT_PARAMETERS,
* paramaters); messageReport.put(ReportConstants.REPORT_DATASOURCE,
* reportSorteggioBeans); long idFileEntry = (Long)
* MessageBusUtil.sendSynchronousMessage(ReportDestinationNames.SYNC,
* messageReport, 1);
*/
if (Validator.isNull(idFileEntry)) {
throw new NoSuchFileException();
}
}
private static String getMeseSorteggio(Date dtSorteggio) {
Calendar calendar = getSorteggio(dtSorteggio);
return StringUtils.leftPad(String.valueOf(calendar.get(Calendar.MONTH) + 1), 2, '0');
}
private static Calendar getSorteggio(Date dtSorteggio) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(dtSorteggio);
calendar.add(Calendar.MONTH, -1);
return calendar;
}
private static Date[] rangeSorteggioAnno(String mese) {
// min
Calendar calMin = getCalendarNoTimeFirstDay();
if (mese.equalsIgnoreCase("12")) {
calMin.add(Calendar.YEAR, -1);
}
calMin.set(Calendar.MONTH, (Integer.parseInt(mese) - 1));
calMin.add(Calendar.MONTH, -11);
// max
Calendar calMax = getCalendarNoTimeFirstDay();
if (mese.equalsIgnoreCase("12")) {
calMax.add(Calendar.YEAR, -1);
}
calMax.set(Calendar.MONTH, (Integer.parseInt(mese) - 1));
return new Date[] { calMin.getTime(), calMax.getTime() };
}
private static Calendar getCalendarNoTimeFirstDay() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DATE, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal;
}
}

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.namespace=portos_bo
build.number=2301 build.number=2315
build.date=1591708070626 build.date=1591805875908
build.auto.upgrade=true build.auto.upgrade=true
## ##

34
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/sorteggio/view.jsp

@ -4,7 +4,7 @@
<%@page import="it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants"%> <%@page import="it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants"%>
<%@page import="com.liferay.portlet.PortletURLUtil"%> <%@page import="com.liferay.portlet.PortletURLUtil"%>
<%@page import="javax.portlet.PortletURL"%> <%@page import="javax.portlet.PortletURL"%>
<%@page import="it.tref.liferay.portos.bo.util.SorteggioPraticaUtil"%> <%@page import="it.mwg.sismica.bo.util.SorteggioPraticaUtil"%>
<%@page import="com.liferay.portlet.documentlibrary.util.DLUtil"%> <%@page import="com.liferay.portlet.documentlibrary.util.DLUtil"%>
<%@page import="com.liferay.portal.kernel.repository.model.FileEntry"%> <%@page import="com.liferay.portal.kernel.repository.model.FileEntry"%>
<%@page import="com.liferay.portal.kernel.exception.PortalException"%> <%@page import="com.liferay.portal.kernel.exception.PortalException"%>
@ -30,21 +30,6 @@
<% <%
long companyId = company.getCompanyId(); long companyId = company.getCompanyId();
long groupId = themeDisplay.getScopeGroupId(); long groupId = themeDisplay.getScopeGroupId();
int dayOfWeekSorteggioParam = GetterUtil.getInteger(
ConfigurazioneLocalServiceUtil.findByC_ChiaveString(companyId, ConfigurazioneConstants.DAY_OF_WEEK_SORTEGGIO));
int startDaySorteggioParam =GetterUtil.getInteger(
ConfigurazioneLocalServiceUtil.findByC_ChiaveString(companyId, ConfigurazioneConstants.START_DAY_SORTEGGIO));
//boolean sistemaConfigurato = dayOfWeekSorteggioParam>0 && dayOfWeekSorteggioParam<=7 && startDaySorteggioParam>0 && startDaySorteggioParam<=28;
boolean sistemaConfigurato = dayOfWeekSorteggioParam>0 && dayOfWeekSorteggioParam<=7;
%>
<c:if test="<%=!sistemaConfigurato %>">
<label class="label label-warn"> Sistema di sorteggio non configurato</label>
</c:if>
<c:if test="<%=sistemaConfigurato %>">
<%
Date dtSorteggio = SorteggioPraticaUtil.getDataSorteggio(companyId, false);
String dataUltimoSorteggioString = ConfigurazioneLocalServiceUtil.findByC_ChiaveString( String dataUltimoSorteggioString = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(
companyId, ConfigurazioneConstants.DATE_ULTIMO_SORTEGGIO); companyId, ConfigurazioneConstants.DATE_ULTIMO_SORTEGGIO);
@ -55,11 +40,6 @@ if (Validator.isNotNull(dataUltimoSorteggioString)) {
dtUltimoSorteggio = DateUtils.truncate( dtUltimoSorteggio = DateUtils.truncate(
new SimpleDateFormat(SorteggioPraticaUtil.DATE_TIME_FORMAT).parse( new SimpleDateFormat(SorteggioPraticaUtil.DATE_TIME_FORMAT).parse(
dataUltimoSorteggioString), Calendar.DATE); dataUltimoSorteggioString), Calendar.DATE);
if (now.compareTo(dtUltimoSorteggio) >= 0
&& DateUtils.toCalendar(now).get(Calendar.MONTH) ==
DateUtils.toCalendar(dtUltimoSorteggio).get(Calendar.MONTH)) {
dtSorteggio = SorteggioPraticaUtil.getDataSorteggio(companyId, true);
}
} }
DateFormat formatDtSorteggio = DateFormat.getDateInstance(DateFormat.FULL, locale); DateFormat formatDtSorteggio = DateFormat.getDateInstance(DateFormat.FULL, locale);
@ -95,16 +75,6 @@ String provincia = ParamUtil.getString(renderRequest, "provincia");
String[] mesi = CalendarUtil.getMonths(locale); String[] mesi = CalendarUtil.getMonths(locale);
/* String meseN = StringPool.BLANK;
if (Validator.isNotNull(mese)) {
meseN = "00";
for (int i=0;i<mesi.length;i++) {
if (mesi[i].equalsIgnoreCase(mese)) {
meseN = StringUtils.leftPad(String.valueOf(i+1), 2, '0');
break;
}
}
} */
boolean isPublicLayout = layout.isPublicLayout(); boolean isPublicLayout = layout.isPublicLayout();
%> %>
@ -429,5 +399,3 @@ boolean isPublicLayout = layout.isPublicLayout();
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</div> </div>
</c:if>

Caricamento…
Annulla
Salva