diff --git a/liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/api/QuarkusBridgeConstants.java b/liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/api/QuarkusBridgeConstants.java index 708f2723..f3ae0ff3 100644 --- a/liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/api/QuarkusBridgeConstants.java +++ b/liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/api/QuarkusBridgeConstants.java @@ -1,6 +1,7 @@ package portos.nextmind.quarkus.bridge.api; public class QuarkusBridgeConstants { + public final static String HEADER_REQUEST = "HeaderPratica"; public final static String BODY_REQUEST = "SportelloPratica"; public final static String codiceIstat = "cadastralCode"; @@ -9,4 +10,9 @@ public class QuarkusBridgeConstants { public final static String nome = "name"; public final static String cognome = "surname"; public final static String tipoProcedura = "proceedingType"; + public final static String instanceId = "instanceId"; + public final static String correlationId = "correlationId"; + public final static String clientId = "clientId"; + public final static String recordId = "id"; // The generated id in the external database + } diff --git a/liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/scheduler/QuarkusBridgeScheduler.java b/liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/scheduler/QuarkusBridgeScheduler.java index 4c364739..3c68eb87 100644 --- a/liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/scheduler/QuarkusBridgeScheduler.java +++ b/liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/scheduler/QuarkusBridgeScheduler.java @@ -18,6 +18,8 @@ import com.liferay.portal.model.Company; import com.liferay.portal.model.User; import com.liferay.portal.service.CompanyLocalServiceUtil; import com.liferay.portal.service.ServiceContext; +import com.liferay.portlet.expando.model.ExpandoBridge; +import com.liferay.portlet.expando.model.ExpandoColumnConstants; import it.tref.liferay.portos.bo.model.Comune; import it.tref.liferay.portos.bo.model.DettPratica; @@ -94,7 +96,6 @@ public class QuarkusBridgeScheduler implements MessageListener { // Recupera la procedura della pratica String tipoProcedura = Sportello.getString(QuarkusBridgeConstants.tipoProcedura); - ServiceContext serviceContext = new ServiceContext(); serviceContext.setScopeGroupId(groupId); serviceContext.setCompanyId(companyId); @@ -103,9 +104,9 @@ public class QuarkusBridgeScheduler implements MessageListener { if(true) continue; - // Aggiungi DettPratica + // Aggiungi DettPratica ed IntPratica long territorioId = territorio.getTerritorioId(); - //TODO: verifica che la procedura non esista già + //TODO: verifica che la pratica non esista già if(!Constants.PRATICA_ZONE.containsKey(tipoProcedura)){ _log.error("#[!]# " + tipoProcedura + " is not a Valid TipoPratica"); continue; @@ -113,6 +114,38 @@ public class QuarkusBridgeScheduler implements MessageListener { DettPratica dettPratica = DettPraticaLocalServiceUtil .addDettPratica(territorioId, tipoProcedura, serviceContext); + // Add custom fields to IntPratica to fetch future updates from Kafka + IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(dettPratica.getIntPraticaId()); + + ExpandoBridge customFieldsExpando = intPratica.getExpandoBridge(); + customFieldsExpando.addAttribute(QuarkusBridgeConstants.instanceId, + ExpandoColumnConstants.STRING); + customFieldsExpando.addAttribute(QuarkusBridgeConstants.correlationId, + ExpandoColumnConstants.STRING); + customFieldsExpando.addAttribute(QuarkusBridgeConstants.clientId, + ExpandoColumnConstants.STRING); + customFieldsExpando.addAttribute("HeaderSportelloId", ExpandoColumnConstants.LONG); + customFieldsExpando.addAttribute("SportelloId", ExpandoColumnConstants.LONG); + + String instanceId = Header.getString(QuarkusBridgeConstants.instanceId); + String correlationId = Header.getString(QuarkusBridgeConstants.correlationId); + String clientId = Header.getString(QuarkusBridgeConstants.clientId); + + Long headerSportelloId = Header.getLong(QuarkusBridgeConstants.recordId); + Long sportelloId = Sportello.getLong(QuarkusBridgeConstants.recordId); + + customFieldsExpando.setAttribute(QuarkusBridgeConstants.correlationId, correlationId); + customFieldsExpando.setAttribute(QuarkusBridgeConstants.instanceId, instanceId); + customFieldsExpando.setAttribute(QuarkusBridgeConstants.clientId, clientId); + + customFieldsExpando.setAttribute("HeaderSportelloId", headerSportelloId); + customFieldsExpando.setAttribute("SportelloId", sportelloId); + + intPratica.setExpandoBridgeAttributes(customFieldsExpando); + + // Persist changes to custom fields + IntPraticaLocalServiceUtil.updateIntPratica(intPratica); + } catch (SystemException e) { _log.error(e ,e); } catch (PortalException e) { @@ -134,6 +167,8 @@ public class QuarkusBridgeScheduler implements MessageListener { try { List praticheDaAggiornare = IntPraticaLocalServiceUtil.dynamicQuery(query); //TODO: splittare le pratiche da aggiornare + + //TODO: ciclare per effettuare gli update delle singole pratiche } catch (SystemException e) { _log.error(e,e); }