Sfoglia il codice sorgente

sismica administrations - sostituzione docpratica allegato variazione soggetti

master
Mattia Gosetto 4 anni fa
parent
commit
096838dd46
  1. 226
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SismicaAdministrationPortlet.java
  2. 4
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/sismica_administration/view.jsp

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

@ -7,18 +7,27 @@ 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.DocPratica; import it.tref.liferay.portos.bo.model.DocPratica;
import it.tref.liferay.portos.bo.model.Pagamento; import it.tref.liferay.portos.bo.model.Pagamento;
import it.tref.liferay.portos.bo.model.Soggetto;
import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil; import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ConfigurazioneServiceUtil; import it.tref.liferay.portos.bo.service.ConfigurazioneServiceUtil;
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.PagamentoLocalServiceUtil; import it.tref.liferay.portos.bo.service.PagamentoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.SoggettoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.SoggettoServiceUtil;
import it.tref.liferay.portos.bo.shared.bean.FirmeBean;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants; import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import it.tref.liferay.portos.bo.shared.util.FirmeUtil;
import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil;
import it.tref.liferay.portos.bo.util.PraticaUtil; import it.tref.liferay.portos.bo.util.PraticaUtil;
import it.tref.liferay.portos.bo.util.ValidazionePraticaUtil;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -34,15 +43,19 @@ import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.repository.model.FileEntry; import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.repository.model.Folder; import com.liferay.portal.kernel.repository.model.Folder;
import com.liferay.portal.kernel.servlet.SessionErrors;
import com.liferay.portal.kernel.upload.UploadPortletRequest; import com.liferay.portal.kernel.upload.UploadPortletRequest;
import com.liferay.portal.kernel.util.HttpUtil;
import com.liferay.portal.kernel.util.MimeTypesUtil; import com.liferay.portal.kernel.util.MimeTypesUtil;
import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.FileUtil; import com.liferay.portal.kernel.util.FileUtil;
import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.StringPool;
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.portal.util.PortalUtil; import com.liferay.portal.util.PortalUtil;
import com.liferay.portlet.documentlibrary.NoSuchFolderException; import com.liferay.portlet.documentlibrary.NoSuchFolderException;
@ -54,10 +67,11 @@ import com.liferay.util.bridges.mvc.MVCPortlet;
*/ */
public class SismicaAdministrationPortlet extends MVCPortlet { public class SismicaAdministrationPortlet extends MVCPortlet {
private static final Log _log = LogFactoryUtil.getLog(SismicaAdministrationPortlet.class); private static final Log _log = LogFactoryUtil
.getLog(SismicaAdministrationPortlet.class);
public void mostraConfigurazione(ActionRequest actionRequest, ActionResponse actionResponse) public void mostraConfigurazione(ActionRequest actionRequest,
throws SystemException { ActionResponse actionResponse) throws SystemException {
List<String> esito = new ArrayList<String>(); List<String> esito = new ArrayList<String>();
esito.add("<h3>Env</h3>"); esito.add("<h3>Env</h3>");
@ -66,24 +80,29 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
} }
esito.add("<h3>Properties</h3>"); esito.add("<h3>Properties</h3>");
for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) { for (Map.Entry<Object, Object> entry : System.getProperties()
.entrySet()) {
esito.add(entry.getKey() + "=" + entry.getValue()); esito.add(entry.getKey() + "=" + entry.getValue());
} }
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()])); actionResponse.setRenderParameter("esito",
esito.toArray(new String[esito.size()]));
} }
public void generaDocumenti(ActionRequest actionRequest, ActionResponse actionResponse) { public void generaDocumenti(ActionRequest actionRequest,
ThemeDisplay td = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ActionResponse actionResponse) {
ThemeDisplay td = (ThemeDisplay) actionRequest
.getAttribute(WebKeys.THEME_DISPLAY);
List<String> esito = new ArrayList<>(); List<String> esito = new ArrayList<>();
try { try {
esito = SismicaUtil.generaDocumenti(td.getCompanyId()); esito = SismicaUtil.generaDocumenti(td.getCompanyId());
} catch (PortalException | SystemException e) { } catch (PortalException | SystemException e) {
esito.add("Errore durante l'invio " + e.getMessage()); esito.add("Errore durante l'invio " + e.getMessage());
} }
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()])); actionResponse.setRenderParameter("esito",
esito.toArray(new String[esito.size()]));
} }
public void sostituisciDL(ActionRequest actionRequest, ActionResponse actionResponse) throws SystemException, PortalException, IOException { public void sostituisciDL(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
SismicaUtil.sostituisciDL(actionRequest, actionResponse); SismicaUtil.sostituisciDL(actionRequest, actionResponse);
long userId = 0; long userId = 0;
@ -140,12 +159,6 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
description = sourceFileName; description = sourceFileName;
mimeType = MimeTypesUtil.getContentType(sourceFileName); mimeType = MimeTypesUtil.getContentType(sourceFileName);
/*try {
DLAppLocalServiceUtil.deleteFileEntry(pratica.getDlFileEntryId());
} catch(PortalException e){
}*/
try { try {
fileEntry = DLAppLocalServiceUtil.getFileEntry(pratica.getDlFileEntryId()); fileEntry = DLAppLocalServiceUtil.getFileEntry(pratica.getDlFileEntryId());
fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(), fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(),
@ -189,13 +202,7 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
+ pagamento.getPagamentoId() + StringPool.UNDERLINE + sourceFileName; + pagamento.getPagamentoId() + StringPool.UNDERLINE + sourceFileName;
description = StringPool.BLANK; description = StringPool.BLANK;
mimeType = MimeTypesUtil.getContentType(sourceFileName); mimeType = MimeTypesUtil.getContentType(sourceFileName);
/*try {
DLAppLocalServiceUtil.deleteFileEntry(pagamento.getFileEntryId());
} catch(PortalException e){
}*/
try { try {
fileEntry = DLAppLocalServiceUtil.getFileEntry(pagamento.getFileEntryId()); fileEntry = DLAppLocalServiceUtil.getFileEntry(pagamento.getFileEntryId());
fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(), fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(),
@ -210,6 +217,99 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
PagamentoLocalServiceUtil.updatePagamento(pagamento); PagamentoLocalServiceUtil.updatePagamento(pagamento);
break; break;
case "var_soggetti_no_docpratica":
Soggetto soggetto = SoggettoLocalServiceUtil.getSoggetto(idOggetto);
DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(soggetto.getDettPraticaId());
long intPraticaId = dettPratica.getIntPraticaId();
serviceContext = ServiceContextFactory.getInstance(Soggetto.class.getName(), actionRequest);
byte[] content = null;
String jsonFirmatari = "";
boolean isSigned = false;
FirmeBean firmeBean = new FirmeBean();
User user = UserLocalServiceUtil.getUser(serviceContext.getUserId());
if (!firmeBean.allSignatures().contains(user.getScreenName())) {
jsonFirmatari = FirmeUtil.addFirma(firmeBean, user.getScreenName());
} else {
jsonFirmatari = FirmeUtil.serialize(firmeBean);
}
if (file.exists()) {
if (Validator.isNotNull(sourceFileName) && file != null) {
// validazione: solo alcune estensioni
String ext = FileUtil.getExtension(sourceFileName);
if (!ext.equalsIgnoreCase("p7m")
&& !ext.equalsIgnoreCase("pdf")) {
SessionErrors
.add(actionRequest,
"error.geniocivilefe.variazione-soggetto.allegato.ext.valid");
}
// lunghezza fissata a 200
if (sourceFileName.length() > 200) {
SessionErrors
.add(actionRequest,
"error.geniocivilefe.variazione-soggetto.allegato.length.valid");
}
} else if (!TipoSoggettoUtil.COMMITTENTE
.equalsIgnoreCase(soggetto.getTipologiaSoggetto())) {
SessionErrors
.add(actionRequest,
"error.geniocivilefe.variazione-soggetto.allegato.is.request");
}
if (!SessionErrors.isEmpty(actionRequest)) {
throw new SystemException(
"error.geniocivilefe.variazione-soggetto.allegato");
} else if (file != null) {
content = FileUtil.getBytes(file);
}
}
if (TipoSoggettoUtil.COMMITTENTE.equals(soggetto
.getTipologiaSoggetto())) {
String[] titolare = new String[] { dettPratica
.getCodiceFiscaleDelegatoCommittente() };
isSigned = ValidazionePraticaUtil.isAllegatoSignedBySubjects(
sourceFileName, content, serviceContext.getCompanyId(),
Arrays.asList(titolare), jsonFirmatari);
} else {
List<Soggetto> soggettiValidi = SoggettoServiceUtil
.getValidTmpByIntPratica(intPraticaId);
List<String> codiciFiscaliValidi = new ArrayList<String>();
for (Soggetto valido : soggettiValidi) {
if (!codiciFiscaliValidi
.contains(valido.getCodiceFiscale())
&& !valido.getCodiceFiscale().equalsIgnoreCase(
soggetto.getCodiceFiscale())) {
codiciFiscaliValidi.add(valido.getCodiceFiscale());
}
}
isSigned = ValidazionePraticaUtil
.isAllegatoSignedBySubjectsAndPerson(sourceFileName,
content, serviceContext.getCompanyId(),
codiciFiscaliValidi,
soggetto.getCodiceFiscale(), jsonFirmatari);
}
if(isSigned){
userId = PortalUtil.getUserId(actionRequest);
try {
SoggettoServiceUtil.allegaFileModifica(soggetto.getSoggettoId(), userId, intPraticaId, content, sourceFileName, jsonFirmatari,
serviceContext);
} catch (PortalException e) {
_log.error(e, e);
throw e;
}
}
break;
default: default:
break; break;
@ -218,79 +318,103 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
} }
public void resetFirme(ActionRequest actionRequest, ActionResponse actionResponse) { public void resetFirme(ActionRequest actionRequest,
ThemeDisplay td = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ActionResponse actionResponse) {
String numeroProgetto = ParamUtil.getString(actionRequest, "numeroProgetto"); ThemeDisplay td = (ThemeDisplay) actionRequest
.getAttribute(WebKeys.THEME_DISPLAY);
String numeroProgetto = ParamUtil.getString(actionRequest,
"numeroProgetto");
List<String> esito = new ArrayList<>(); List<String> esito = new ArrayList<>();
try { try {
esito = SismicaUtil.resetFirme(td.getCompanyId(), numeroProgetto); esito = SismicaUtil.resetFirme(td.getCompanyId(), numeroProgetto);
} catch (SystemException | PortalException e) { } catch (SystemException | PortalException e) {
esito.add("Errore durante l'invio " + e.getMessage()); esito.add("Errore durante l'invio " + e.getMessage());
} }
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()])); actionResponse.setRenderParameter("esito",
esito.toArray(new String[esito.size()]));
} }
public void reIndexFasciolo(ActionRequest actionRequest, ActionResponse actionResponse) public void reIndexFasciolo(ActionRequest actionRequest,
throws PortalException, SystemException { ActionResponse actionResponse) throws PortalException,
SystemException {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest
.getAttribute(WebKeys.THEME_DISPLAY);
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId"); long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId");
if (Validator.isNotNull(intPraticaId)) { if (Validator.isNotNull(intPraticaId)) {
IntPraticaLocalServiceUtil.reIndexFasciolo(intPraticaId, themeDisplay.getCompanyId()); IntPraticaLocalServiceUtil.reIndexFasciolo(intPraticaId,
themeDisplay.getCompanyId());
} }
String numeroProgetto = ParamUtil.getString(actionRequest, "numeroProgetto"); String numeroProgetto = ParamUtil.getString(actionRequest,
"numeroProgetto");
if (Validator.isNotNull(numeroProgetto)) { if (Validator.isNotNull(numeroProgetto)) {
IntPraticaLocalServiceUtil.reIndexFasciolo(numeroProgetto, themeDisplay.getCompanyId()); IntPraticaLocalServiceUtil.reIndexFasciolo(numeroProgetto,
themeDisplay.getCompanyId());
} }
} }
public void reIndexFascicoli(ActionRequest actionRequest, ActionResponse actionResponse) { public void reIndexFascicoli(ActionRequest actionRequest,
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ActionResponse actionResponse) {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest
.getAttribute(WebKeys.THEME_DISPLAY);
List<String> esito = null; List<String> esito = null;
esito = SismicaUtil.reIndexFascicoli(themeDisplay.getCompanyId()); esito = SismicaUtil.reIndexFascicoli(themeDisplay.getCompanyId());
if (esito != null) if (esito != null)
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()])); actionResponse.setRenderParameter("esito",
esito.toArray(new String[esito.size()]));
} }
public void lanciaSorteggio(ActionRequest actionRequest, ActionResponse actionResponse) { public void lanciaSorteggio(ActionRequest actionRequest,
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ActionResponse actionResponse) {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest
.getAttribute(WebKeys.THEME_DISPLAY);
List<String> esito = null; List<String> esito = null;
_log.info("Sorteggio lanciato manualmente"); _log.info("Sorteggio lanciato manualmente");
try { try {
esito = SorteggioPraticaUtil.sorteggio(themeDisplay.getCompanyId(), new Date()); esito = SorteggioPraticaUtil.sorteggio(themeDisplay.getCompanyId(),
new Date());
} catch (PortalException | SystemException 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()]));
} }
public void manutenzioneDatabase(ActionRequest actionRequest, ActionResponse actionResponse) public void manutenzioneDatabase(ActionRequest actionRequest,
throws PortalException, SystemException { ActionResponse actionResponse) throws PortalException,
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); SystemException {
ServiceContext serviceContext = ServiceContextFactory
.getInstance(actionRequest);
List<String> esito = PuliziaDatabase.pulisci(serviceContext); List<String> esito = PuliziaDatabase.pulisci(serviceContext);
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()])); actionResponse.setRenderParameter("esito",
esito.toArray(new String[esito.size()]));
} }
public void inviaAvviso(ActionRequest actionRequest, ActionResponse actionResponse) throws SystemException { public void inviaAvviso(ActionRequest actionRequest,
ActionResponse actionResponse) throws SystemException {
SismicaUtil.inviaAvviso(actionRequest, actionResponse); SismicaUtil.inviaAvviso(actionRequest, actionResponse);
} }
public void salvaDataProssimoSorteggio(ActionRequest actionRequest, ActionResponse actionResponse) public void salvaDataProssimoSorteggio(ActionRequest actionRequest,
throws PortalException, SystemException { ActionResponse actionResponse) throws PortalException,
SystemException {
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory
.getInstance(actionRequest);
serviceContext.setScopeGroupId(-1L); serviceContext.setScopeGroupId(-1L);
serviceContext.setCompanyId(serviceContext.getCompanyId()); serviceContext.setCompanyId(serviceContext.getCompanyId());
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Date dataProssimoSorteggio = ParamUtil.getDate(actionRequest, "dataProssimoSorteggio", sdf); Date dataProssimoSorteggio = ParamUtil.getDate(actionRequest,
"dataProssimoSorteggio", sdf);
ConfigurazioneServiceUtil.storeConfig("conf.geniocivile.sorteggio.data.prossimo.sorteggio", ConfigurazioneServiceUtil.storeConfig(
"conf.geniocivile.sorteggio.data.prossimo.sorteggio",
sdf.format(dataProssimoSorteggio), serviceContext); sdf.format(dataProssimoSorteggio), serviceContext);
} }

4
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/sismica_administration/view.jsp

@ -176,6 +176,10 @@ String dataProssimoSorteggio =
value="<%=DocPratica.class.getName()%>"></aui:option> value="<%=DocPratica.class.getName()%>"></aui:option>
<aui:option label="Pagamento (allegato)" selected="<%=oggetto.equals(Pagamento.class.getName())%>" <aui:option label="Pagamento (allegato)" selected="<%=oggetto.equals(Pagamento.class.getName())%>"
value="<%=Pagamento.class.getName()%>"></aui:option> value="<%=Pagamento.class.getName()%>"></aui:option>
<aui:option label="Variazione Soggetti (no DocPratica)" selected="<%=oggetto.equals(Pagamento.class.getName())%>"
value="var_soggetti_no_docpratica"></aui:option>
<aui:option label="Variazione Soggetti (solo FileEntry)" selected="<%=oggetto.equals(Pagamento.class.getName())%>"
value="var_soggetti_solo_fileentry"></aui:option>
</aui:select> </aui:select>
<aui:input type="file" name="file" label="File" /> <aui:input type="file" name="file" label="File" />
<aui:input name="classPK" label="Id oggetto"> <aui:input name="classPK" label="Id oggetto">

Caricamento…
Annulla
Salva