Sfoglia il codice sorgente

handle DATA_READ operations and INSTANCE_READ operation

feature/kafka-integrator
Gabriele Zigurella 2 anni fa
parent
commit
63bd9ef5f9
  1. 96
      liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/liferay/documents/util/AllegatiUtil.java
  2. 28
      liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/liferay/entities/util/DescrizioneUtil.java
  3. 21
      liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/liferay/entities/util/DestinazioneUtil.java
  4. 69
      liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/liferay/entities/util/TipologiaCostruttivaUtil.java
  5. 68
      liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/liferay/entities/util/TipologieInterventoUtil.java
  6. 74
      liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/liferay/roles/util/SoggettiUtil.java
  7. 121
      liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/scheduler/QuarkusBridgeScheduler.java

96
liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/liferay/documents/util/AllegatiUtil.java

@ -2,23 +2,24 @@ package portos.nextmind.liferay.documents.util;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONArray;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
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.Base64;
import com.liferay.portal.kernel.util.MimeTypesUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.RoleConstants;
import com.liferay.portal.model.User;
import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil;
import com.liferay.portal.security.permission.PermissionThreadLocal;
import com.liferay.portal.service.RoleLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portlet.documentlibrary.NoSuchFolderException;
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
import it.tref.liferay.portos.bo.model.DettPratica;
import it.tref.liferay.portos.bo.model.IntPratica;
@ -30,11 +31,100 @@ import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import it.tref.liferay.portos.bo.util.PraticaUtil;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.List;
public class AllegatiUtil {
static Log _log = LogFactoryUtil.getLog(AllegatiUtil.class);
public static JSONArray recuperaDocumentiAllegatiPratica(long intPraticaId){
JSONArray attachments = JSONFactoryUtil.createJSONArray();
try{
DettPratica dettPratica = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId).get(0);
IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId);
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
long companyId = territorio.getCompanyId();
long defaultFolderId = ConfigurazioneLocalServiceUtil
.findByC_ChiaveLong(companyId, ConfigurazioneConstants.ATTACHMENT_FOLDER_ID);
Folder defaultFolder = DLAppLocalServiceUtil.getFolder(defaultFolderId);
String folderName = PraticaUtil.getFolderName(dettPratica.getDettPraticaId());
Folder folder = DLAppLocalServiceUtil.getFolder(defaultFolder.getRepositoryId(),
defaultFolder.getFolderId(), folderName);
//TODO: tree path per recupero file
List<DLFileEntry> files = DLFileEntryLocalServiceUtil
.getFileEntries(folder.getGroupId(), folder.getFolderId());
for(DLFileEntry file : files){
JSONObject object = JSONFactoryUtil.createJSONObject();
String fileName = file.getTitle();
String type = file.getTitle();
String[] parts = file.getTitle().split(StringPool.UNDERLINE, 3);
if(parts.length >= 3){
fileName = parts[2];
type = parts[0].concat(StringPool.UNDERLINE).concat(parts[1]);
}
InputStream ioFile = DLFileEntryLocalServiceUtil.getFileAsStream(file.getFileEntryId(), file.getLatestFileVersion(true).getVersion());
// Calculate file Digest
byte[] digest = calculateSHA256Digest(ioFile);
String sha256 = bytesToHex(digest);
// Encode file
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = ioFile.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
byte[] data = outputStream.toByteArray();
String content = Base64.encode(data);
object.put("file", content);
object.put("fileName", fileName);
object.put("mimeType", file.getMimeType());
object.put("sha256", sha256);
object.put("type", type);
ioFile.close();
outputStream.close();
}
}catch(Exception e){
_log.error(e, e);
}
return attachments;
}
private static String bytesToHex(byte[] bytes) {
StringBuilder hexString = new StringBuilder();
for (byte b : bytes) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
}
private static byte[] calculateSHA256Digest(InputStream inputStream) throws NoSuchAlgorithmException, IOException {
MessageDigest sha256Digest = MessageDigest.getInstance("SHA-256");
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
sha256Digest.update(buffer, 0, bytesRead);
}
return sha256Digest.digest();
}
public static FileEntry aggiungiDocumentoPratica(JSONObject file, long intPraticaId){
FileEntry fileEntry = null;
try {

28
liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/liferay/entities/util/DescrizioneUtil.java

@ -2,6 +2,8 @@ package portos.nextmind.liferay.entities.util;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONArray;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
@ -41,4 +43,30 @@ public class DescrizioneUtil {
_log.error(e, e);
}
}
public static JSONArray getDescrizione(long intPraticaId){
JSONArray description = JSONFactoryUtil.createJSONArray();
try {
List<DettPratica> dettPraticasByIntPratica = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId);
for(DettPratica pratica : dettPraticasByIntPratica){
JSONObject object = JSONFactoryUtil.createJSONObject();
object.put("address", pratica.getVia());
JSONObject cadastralCoordinates = JSONFactoryUtil.createJSONObject();
cadastralCoordinates.put("particle", pratica.getDcParticelle());
cadastralCoordinates.put("sheet", pratica.getDcFoglio());
object.put("cadastralCoordinates", cadastralCoordinates);
object.put("location", pratica.getLocalita());
object.put("subject", pratica.getDcAllegato()); // TODO: analizzare se corrisponde a subject?
description.put(object);
}
} catch (RuntimeException | SystemException e) {
_log.error(e, e);
}
return description;
}
}

21
liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/liferay/entities/util/DestinazioneUtil.java

@ -1,6 +1,8 @@
package portos.nextmind.liferay.entities.util;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONArray;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
@ -28,4 +30,23 @@ public class DestinazioneUtil {
_log.error(e, e);
}
}
public static JSONArray getDestinazione(long intPraticaId){
JSONArray destination = JSONFactoryUtil.createJSONArray();
try {
List<DettPratica> dettPraticasByIntPratica = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId);
for(DettPratica pratica : dettPraticasByIntPratica){
JSONObject object = JSONFactoryUtil.createJSONObject();
object.put("destinationType", pratica.getDestinazione());
if(pratica.getDestinazione().contentEquals("I0Z")){
object.put("i0zDescription", pratica.getDestinazioneAltroIntervento());
}
destination.put(object);
}
} catch (RuntimeException | SystemException e) {
_log.error(e, e);
}
return destination;
}
}

69
liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/liferay/entities/util/TipologiaCostruttivaUtil.java

@ -2,6 +2,8 @@ package portos.nextmind.liferay.entities.util;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONArray;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
@ -137,4 +139,71 @@ public class TipologiaCostruttivaUtil {
_log.error(e, e);
}
}
private static JSONObject serializeInMuratura(DettPratica pratica){
JSONObject masonry = JSONFactoryUtil.createJSONObject();
masonry.put("checked", pratica.getTcInMuratura());
JSONObject item = JSONFactoryUtil.createJSONObject();
if(pratica.getTcInMuratura()){
item.put("mixed", pratica.getTcInMuraturaMista());
item.put("ordinary", pratica.getTcInMuraturaOrdinaria());
item.put("reinforced", pratica.getTcInMuraturaArmata());
}
masonry.put("item", item);
return masonry;
}
private static JSONObject serializeAltraTipologia(DettPratica pratica){
JSONObject otherConstructionType = JSONFactoryUtil.createJSONObject();
otherConstructionType.put("checked", pratica.getTcAltro());
JSONObject item = JSONFactoryUtil.createJSONObject();
if(pratica.getTcAltro()){
item.put("description", pratica.getTcAltroDescrizione());
}
otherConstructionType.put("item", item);
return otherConstructionType;
}
private static JSONObject serializeInCementoArmato(DettPratica pratica){
JSONObject reinforcedConcrete = JSONFactoryUtil.createJSONObject();
reinforcedConcrete.put("checked", pratica.getTcInCA());
JSONObject item = JSONFactoryUtil.createJSONObject();
if(pratica.getTcInCA()){
item.put("inSitu", pratica.getTcInOpera());
item.put("prefabricated", pratica.getTcPrefabbricato());
}
reinforcedConcrete.put("item", item);
return reinforcedConcrete;
}
private static JSONObject serializeInAcciaio(DettPratica pratica){
JSONObject steel = JSONFactoryUtil.createJSONObject();
steel.put("checked", pratica.getTcInAcciaio());
JSONObject item = JSONFactoryUtil.createJSONObject();
if(pratica.getTcInAcciaio()){
item.put("mixed", pratica.getTcMista());
}
steel.put("item", item);
return steel;
}
public static JSONArray getTipologiaCostruttiva(long intPraticaId){
JSONArray result = JSONFactoryUtil.createJSONArray();
try {
List<DettPratica> dettPraticas = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId);
for(DettPratica pratica : dettPraticas){
JSONObject object = JSONFactoryUtil.createJSONObject();
object.put("masonry", serializeInMuratura(pratica));
object.put("otherConstructionType", serializeAltraTipologia(pratica));
object.put("reinforcedConcrete", serializeInCementoArmato(pratica));
object.put("steel", serializeInAcciaio(pratica));
object.put("wood", pratica.getTcInLegno());
result.put(object);
}
} catch (SystemException e) {
_log.error(e, e);
}
return result;
}
}

68
liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/liferay/entities/util/TipologieInterventoUtil.java

@ -2,6 +2,8 @@ package portos.nextmind.liferay.entities.util;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONArray;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
@ -76,6 +78,7 @@ public class TipologieInterventoUtil {
//TODO: check obbligo documento A24 o asseverazione di esclusione/non assoggettabilità
// al procedimento di verifica preventiva dell’interesse archeologico
if(publicWork.has("item")){
//Boolean publicFunding = ??? //TODO: capire quale campo tiene traccia di Finanziamento Pubblico ai sensi del D.Lgs. 18/04/2016 n. 50
String description = publicWork.getJSONObject("item").getString("description");
pratica.setIntervFinPubDesc(description);
String notQualifying = publicWork.getJSONObject("item").getString("notQualifying");
@ -140,4 +143,69 @@ public class TipologieInterventoUtil {
_log.error(e, e);
}
}
public static JSONArray getTipologiaIntervento(long intPraticaId){
JSONArray tipologiaIntervento = JSONFactoryUtil.createJSONArray();
try {
List<DettPratica> dettPraticasByIntPratica = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId);
for(DettPratica pratica : dettPraticasByIntPratica){
JSONObject projectType = JSONFactoryUtil.createJSONObject();
projectType.put("existingConstructions", pratica.getTcCostruzioniEsistenti());
projectType.put("newConstruction", pratica.getTcNuovaCostruzione());
projectType.put("newPertainingConstruction", pratica.getTcNuovaCostruzionePertinenza());
projectType.put("noExcavationWorks", pratica.getTcNoOpereEscavazione());
projectType.put("ordinaryExtraordinaryMaintenance", pratica.getTcManutOrdStraord());
projectType.put("otherType", pratica.getTcAltriInterventi());
if(pratica.getTcAltriInterventi()){
projectType.put("otherTypeDescription", pratica.getTcAltriInterventiDesc());
}
JSONObject regulatory = JSONFactoryUtil.createJSONObject();
JSONObject churchHeritage = JSONFactoryUtil.createJSONObject();
churchHeritage.put("checked", pratica.getBeneDiocesi());
if(pratica.getBeneDiocesi()){
long diocesiId = pratica.getDiocesiId();
if(diocesiId < 10) {
churchHeritage.put("item", "D0"+diocesiId);
} else {
churchHeritage.put("item", "D"+diocesiId);
}
}
regulatory.put("churchHeritage", churchHeritage);
regulatory.put("contractorAppointment", pratica.getNominaImpresa());
regulatory.put("exemptFromExpenses", pratica.getNormEsenteSpese());
regulatory.put("exemptFromStampFree", pratica.getNormEsenteBollo());
JSONObject publicWork = JSONFactoryUtil.createJSONObject();
publicWork.put("checked", pratica.getLavoriPubblici());
JSONObject publicFunding = JSONFactoryUtil.createJSONObject();
//publicFunding.put("checked", pratica.get) //TODO: capire quale campo tiene traccia di Finanziamento Pubblico ai sensi del D.Lgs. 18/04/2016 n. 50
publicFunding.put("description", pratica.getIntervFinPubDesc());
if(pratica.getIntervInAreaDiInteresse()){
publicFunding.put("notQualifying", "AREA_DI_INTERESSE");
}
if(pratica.getIntervNonModificante()){
publicFunding.put("notQualifying", "NON_MODIFICANTE");
}
if(pratica.getIntervNonAssoggettabile()){
publicFunding.put("notQualifying", "NON_ASSOGGETTABILE");
}
publicWork.put("item", publicFunding);
regulatory.put("publicWork", publicWork);
regulatory.put("testerAppointment", pratica.getNominaCollaudatore() ? "SUBORDINATE" : "UNNECESSARY");
if(!pratica.getNominaCollaudatore()){
regulatory.put("localAction", pratica.getNormDm2018());
}
regulatory.put("worksManagerAppointment", pratica.getNominaDirettoreLavori() ? "SUBORDINATE" : "UNNECESSARY");
JSONObject object = JSONFactoryUtil.createJSONObject();
object.put("projectType", projectType);
object.put("regulatory", regulatory);
tipologiaIntervento.put(object);
}
} catch (RuntimeException | SystemException e) {
_log.error(e, e);
}
return tipologiaIntervento;
}
}

74
liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/liferay/roles/util/SoggettiUtil.java

@ -43,49 +43,99 @@ public class SoggettiUtil {
String fieldOfActivity = null;
switch(role){
case Titolare_Digitale:
String cfTitolare = ""; //TODO: capire quale codice fiscale prendere
List<Soggetto> TitolareSubjects = SoggettoLocalServiceUtil
.findByDettPratica_CodiceFiscale(pratica.getDettPraticaId(), cfTitolare);
for(Soggetto titolare : TitolareSubjects){
result.put(serializePerson(titolare, true));
}
break;
case Collaudatore:
String cfCollaudatore = pratica.getCodiceFiscalePrincipaleCollaudatore();
List<Soggetto> CollaudatoreSubjects = SoggettoLocalServiceUtil
.findByDettPratica_CodiceFiscale(pratica.getDettPraticaId(), cfCollaudatore);
for(Soggetto collaudatore : CollaudatoreSubjects){
result.put(serializePerson(collaudatore, true));
}
break;
case Committente:
String cfCommittente = pratica.getCodiceFiscalePrincipaleCommittente();
List<Soggetto> CommittenteSubjects = SoggettoLocalServiceUtil
.findByDettPratica_CodiceFiscale(pratica.getDettPraticaId(), cfCommittente);
for(Soggetto committente : CommittenteSubjects){
result.put(serializePerson(committente, false));
}
break;
case Direttore_Lavori:
String cfDirettoreLavori = pratica.getCodiceFiscalePrincipaleDirettoreLavori();
List<Soggetto> DirettoreSubjects = SoggettoLocalServiceUtil
.findByDettPratica_CodiceFiscale(pratica.getDettPraticaId(), cfDirettoreLavori);
for(Soggetto direttore : DirettoreSubjects){
result.put(serializePerson(direttore, true));
}
break;
case Ditta_Esecutrice:
String taxCodeDitta = pratica.getCodiceFiscalePrincipaleDitta();
List<Soggetto> DittaSubjects = SoggettoLocalServiceUtil
.findByDettPratica_CodiceFiscale(pratica.getDettPraticaId(), taxCodeDitta);
for(Soggetto ditta : DittaSubjects){
result.put(serializePerson(ditta, false));
}
break;
case Geologo:
String cfGeologo = pratica.getCodiceFiscalePrincipaleGeologo();
List<Soggetto> GeologoSubjects = SoggettoLocalServiceUtil
.findByDettPratica_CodiceFiscale(pratica.getDettPraticaId(), cfGeologo);
for(Soggetto geologo : GeologoSubjects){
result.put(serializePerson(geologo, true));
}
break;
case Progettista:
String cfProgettista = pratica.getCodiceFiscalePrincipaleProgettista();
List<Soggetto> ProgettistaSubjects = SoggettoLocalServiceUtil
.findByDettPratica_CodiceFiscale(pratica.getDettPraticaId(), cfProgettista);
for(Soggetto storico : ProgettistaSubjects){
result.put(serializePerson(storico, true));
}
break;
case Archeologo:
String cfArcheologo = pratica.getCodiceFiscalePrincipaleArcheologo();
List<Soggetto> ArcheologoSubjects = SoggettoLocalServiceUtil
.findByDettPratica_CodiceFiscale(pratica.getDettPraticaId(), cfArcheologo);
for(Soggetto archeologo : ArcheologoSubjects){
result.put(serializePerson(archeologo, true));
}
break;
case AltroProfBeniCulturali:
String cfProfBeniCulturali = ""; //TODO: capire quale codice fiscale prendere
List<Soggetto> ProfBeniCulturaliSubjects = SoggettoLocalServiceUtil
.findByDettPratica_CodiceFiscale(pratica.getDettPraticaId(), cfProfBeniCulturali);
for(Soggetto prof : ProfBeniCulturaliSubjects){
result.put(serializePerson(prof, true));
}
break;
case Restauratore:
String cfRestauratore = pratica.getCodiceFiscalePrincipaleRestauratore();
List<Soggetto> RestauratoreSubjects = SoggettoLocalServiceUtil
.findByDettPratica_CodiceFiscale(pratica.getDettPraticaId(), cfRestauratore);
for(Soggetto restauratore : RestauratoreSubjects){
result.put(serializePerson(restauratore, true));
}
break;
case Storico_Arte:
String cf = pratica.getCodiceFiscalePrincipaleStoricoArte();
String cfStoricoArte = pratica.getCodiceFiscalePrincipaleStoricoArte();
List<Soggetto> storicoArteSubjects = SoggettoLocalServiceUtil
.findByDettPratica_CodiceFiscale(pratica.getDettPraticaId(), cf);
.findByDettPratica_CodiceFiscale(pratica.getDettPraticaId(), cfStoricoArte);
for(Soggetto storico : storicoArteSubjects){
result.put(serializePerson(storico, true));
}

121
liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/scheduler/QuarkusBridgeScheduler.java

@ -28,6 +28,7 @@ import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.Territorio;
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.protocollo.model.Protocollo.TipoProtocollo;
import it.tref.liferay.portos.bo.shared.util.Constants;
import java.util.ArrayList;
@ -164,8 +165,9 @@ public class QuarkusBridgeScheduler implements MessageListener {
return object;
}
private JSONObject prepareUpdateBatch(long companyId){
private JSONObject prepareReadBatch(long companyId){
final String clientContext = "PAESAGGISTICA";
JSONObject readBatchResult = JSONFactoryUtil.createJSONObject();
DynamicQuery query = IntPraticaLocalServiceUtil.dynamicQuery();
query.add(RestrictionsFactoryUtil.eq("companyId", companyId));
//TODO: scoprire in quali stati possono essere le pratiche ed ottimizzare la query
@ -178,6 +180,7 @@ public class QuarkusBridgeScheduler implements MessageListener {
long intPraticaId = intPratica.getIntPraticaId();
String praticaId = String.valueOf(intPraticaId);
JSONObject object = QuarkusBridgeMessageFactoryUtil.writeUpdateData(clientContext, praticaId);
JSONArray readPartialResult = JSONFactoryUtil.createJSONArray();
_log.debug(object.toString());
JSONArray aggiornamentiPratiche = object.getJSONArray("result");
for(int i = 0; i < aggiornamentiPratiche.length(); i++){
@ -188,33 +191,96 @@ public class QuarkusBridgeScheduler implements MessageListener {
String payloadContentType = Sportello.getString(QuarkusBridgeConstants.tipoContenuto);
JSONObject payload = Sportello.getJSONObject(QuarkusBridgeConstants.contenuto);
switch(payloadContentType){
case "INSTANCE_DELETE":
_log.debug("Checking if we can delete Instance of Pratica with Id " + intPraticaId);
if (PraticaValidator.canDeletePratica(intPratica.getIntPraticaId())){
_log.debug("Deleting Instance of Pratica with Id " + intPraticaId);
IntPraticaLocalServiceUtil.deleteIntPratica(intPratica, false);
} else _log.debug("Cannot delete Instance of Pratica with Id "+ intPraticaId);
case "INSTANCE_READ":
JSONObject instance = serializeInstance(intPratica, clientContext);
instance.put("esito", true);
readPartialResult.put(instance);
break;
case "DATA_READ":
_log.debug("Reading current Data from database for Pratica with Id "+ intPraticaId);
JSONObject currentData = readData(payload, intPraticaId);
if(currentData.length() == 0){
currentData.put("esito", false);
_log.error("Unable to read Data from database for Pratica with Id "+ intPraticaId);
} else {
//TODO: send payload to Quarkus Middleware
currentData.put("esito", true);
}
readPartialResult.put(currentData);
break;
case "COMPLIANCE_READ":
//TODO: validare i dati
break;
default:
_log.debug(pratica.toString());
break;
}
}
readBatchResult.put("results_".concat(praticaId), readPartialResult);
}
} catch (Exception e) {
_log.error(e,e);
}
return readBatchResult;
}
private JSONObject serializeInstance(IntPratica pratica, String context){
JSONObject INSTANCE = JSONFactoryUtil.createJSONObject();
INSTANCE.put("context", context);
String url = "" ;
//TODO: retrieve url for json answer
INSTANCE.put("url", url);
String instanceId = String.valueOf(pratica.getIntPraticaId());
INSTANCE.put("instanceId", instanceId);
String ipaCode = "";
//TODO: retrieve ipaCode
String clientId = "";
//TODO: retrieve clientId
String proceedingType = pratica.getTipoProcedura();
INSTANCE.put("proceedingType", proceedingType);
return INSTANCE;
}
private JSONObject prepareUpdateBatch(long companyId){
final String clientContext = "PAESAGGISTICA";
DynamicQuery query = IntPraticaLocalServiceUtil.dynamicQuery();
query.add(RestrictionsFactoryUtil.eq("companyId", companyId));
//TODO: scoprire in quali stati possono essere le pratiche ed ottimizzare la query
try {
List<IntPratica> praticheDaAggiornare = IntPraticaLocalServiceUtil.dynamicQuery(query);
//TODO: splittare le pratiche da aggiornare
//TODO: ciclare per effettuare gli update delle singole pratiche
for(IntPratica intPratica : praticheDaAggiornare){
long intPraticaId = intPratica.getIntPraticaId();
String praticaId = String.valueOf(intPraticaId);
JSONObject object = QuarkusBridgeMessageFactoryUtil.writeUpdateData(clientContext, praticaId);
_log.debug(object.toString());
JSONArray aggiornamentiPratiche = object.getJSONArray("result");
for(int i = 0; i < aggiornamentiPratiche.length(); i++){
JSONObject pratica = aggiornamentiPratiche.getJSONObject(i);
JSONObject Header = pratica.getJSONObject(QuarkusBridgeConstants.HEADER_REQUEST);
JSONObject Sportello = pratica.getJSONObject(QuarkusBridgeConstants.BODY_REQUEST);
String payloadContentType = Sportello.getString(QuarkusBridgeConstants.tipoContenuto);
JSONObject payload = Sportello.getJSONObject(QuarkusBridgeConstants.contenuto);
switch(payloadContentType){
case "INSTANCE_DELETE": // Elimina la pratica
_log.debug("Checking if we can delete Instance of Pratica with Id " + intPraticaId);
if (PraticaValidator.canDeletePratica(intPratica.getIntPraticaId())){
_log.debug("Deleting Instance of Pratica with Id " + intPraticaId);
IntPraticaLocalServiceUtil.deleteIntPratica(intPratica, false);
} else _log.debug("Cannot delete Instance of Pratica with Id "+ intPraticaId);
break;
case "DATA_WRITE":
case "DATA_WRITE": // Aggiorna i dati dei campi del DettPratica associato ad IntPratica
_log.debug("Writing new data to database for Pratica with Id "+ intPraticaId);
writeData(payload, intPraticaId);
_log.debug("Data written to database for Pratica with Id "+ intPraticaId);
break;
case "DATA_DELETE":
case "DATA_DELETE": // Elimina i dati dei campi del DettPratica associato ad IntPratica
//TODO: eliminazione dati dentro entità
break;
case "COMPLIANCE_READ":
//TODO: validare i dati
break;
default:
_log.debug(pratica.toString());
break;
@ -233,21 +299,36 @@ public class QuarkusBridgeScheduler implements MessageListener {
String dataType = payload.getJSONObject("data").getString("dataType");
switch(dataType){
case QuarkusBridgeConstants.DataTypes.MAIN_DETAILS:
//TODO: leggere da DB i dati di
// - Tipologia Costruttiva
// - Descrizione
// - Destinazione
// - Tipologia di Intervento
JSONArray TC = TipologiaCostruttivaUtil.getTipologiaCostruttiva(intPraticaId);
if(TC.length() > 0) result.put("constructionType", TC.getJSONObject(0));
JSONArray description = DescrizioneUtil.getDescrizione(intPraticaId);
if(description.length() > 0) result.put("description", description.getJSONObject(0));
JSONArray destination = DestinazioneUtil.getDestinazione(intPraticaId);
if(destination.length() > 0) result.put("destination", destination.getJSONObject(0));
JSONArray tipoInterventoANDNormativa = TipologieInterventoUtil.getTipologiaIntervento(intPraticaId);
if(tipoInterventoANDNormativa.length() > 0) {
result.put("projectType", tipoInterventoANDNormativa.getJSONObject(0)
.getJSONObject("projectType"));
result.put("regulatory", tipoInterventoANDNormativa.getJSONObject(0)
.getJSONObject("regulatory"));
}
break;
case QuarkusBridgeConstants.DataTypes.ACTORS:
JSONArray actors = payload.getJSONArray("actors");
JSONArray partial = JSONFactoryUtil.createJSONArray();
for(int i = 0; i < actors.length() ; i++){
JSONObject soggetto = actors.getJSONObject(i);
SoggettiUtil.getSoggetto(soggetto, intPraticaId);
JSONArray actor = SoggettiUtil.getSoggetto(soggetto, intPraticaId);
if(actor.length() > 0) partial.put(actor.getJSONObject(0));
}
result.put("actors", partial);
break;
case QuarkusBridgeConstants.DataTypes.ATTACHMENTS_WITH_FILE:
//TODO: leggere da Document and Media Library i documenti della pratica
JSONArray attachments = AllegatiUtil.recuperaDocumentiAllegatiPratica(intPraticaId);
result.put("attachments", attachments);
break;
case QuarkusBridgeConstants.DataTypes.WORK_DESCRIPTION:
//TODO: aspettare che vengano definite le buildingMetrics

Caricamento…
Annulla
Salva