Sfoglia il codice sorgente

add custom fields to trace back to kafka db

feature/kafka-integrator
Gabriele Zigurella 2 anni fa
parent
commit
a2bc766e43
  1. 6
      liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/api/QuarkusBridgeConstants.java
  2. 41
      liferay-plugins-sdk-6.2/portlets/quarkus-bridge-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/scheduler/QuarkusBridgeScheduler.java

6
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; package portos.nextmind.quarkus.bridge.api;
public class QuarkusBridgeConstants { public class QuarkusBridgeConstants {
public final static String HEADER_REQUEST = "HeaderPratica"; public final static String HEADER_REQUEST = "HeaderPratica";
public final static String BODY_REQUEST = "SportelloPratica"; public final static String BODY_REQUEST = "SportelloPratica";
public final static String codiceIstat = "cadastralCode"; public final static String codiceIstat = "cadastralCode";
@ -9,4 +10,9 @@ public class QuarkusBridgeConstants {
public final static String nome = "name"; public final static String nome = "name";
public final static String cognome = "surname"; public final static String cognome = "surname";
public final static String tipoProcedura = "proceedingType"; 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
} }

41
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.model.User;
import com.liferay.portal.service.CompanyLocalServiceUtil; import com.liferay.portal.service.CompanyLocalServiceUtil;
import com.liferay.portal.service.ServiceContext; 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.Comune;
import it.tref.liferay.portos.bo.model.DettPratica; import it.tref.liferay.portos.bo.model.DettPratica;
@ -94,7 +96,6 @@ public class QuarkusBridgeScheduler implements MessageListener {
// Recupera la procedura della pratica // Recupera la procedura della pratica
String tipoProcedura = Sportello.getString(QuarkusBridgeConstants.tipoProcedura); String tipoProcedura = Sportello.getString(QuarkusBridgeConstants.tipoProcedura);
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
serviceContext.setScopeGroupId(groupId); serviceContext.setScopeGroupId(groupId);
serviceContext.setCompanyId(companyId); serviceContext.setCompanyId(companyId);
@ -103,9 +104,9 @@ public class QuarkusBridgeScheduler implements MessageListener {
if(true) continue; if(true) continue;
// Aggiungi DettPratica // Aggiungi DettPratica ed IntPratica
long territorioId = territorio.getTerritorioId(); 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)){ if(!Constants.PRATICA_ZONE.containsKey(tipoProcedura)){
_log.error("#[!]# " + tipoProcedura + " is not a Valid TipoPratica"); _log.error("#[!]# " + tipoProcedura + " is not a Valid TipoPratica");
continue; continue;
@ -113,6 +114,38 @@ public class QuarkusBridgeScheduler implements MessageListener {
DettPratica dettPratica = DettPraticaLocalServiceUtil DettPratica dettPratica = DettPraticaLocalServiceUtil
.addDettPratica(territorioId, tipoProcedura, serviceContext); .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) { } catch (SystemException e) {
_log.error(e ,e); _log.error(e ,e);
} catch (PortalException e) { } catch (PortalException e) {
@ -134,6 +167,8 @@ public class QuarkusBridgeScheduler implements MessageListener {
try { try {
List<IntPratica> praticheDaAggiornare = IntPraticaLocalServiceUtil.dynamicQuery(query); List<IntPratica> praticheDaAggiornare = IntPraticaLocalServiceUtil.dynamicQuery(query);
//TODO: splittare le pratiche da aggiornare //TODO: splittare le pratiche da aggiornare
//TODO: ciclare per effettuare gli update delle singole pratiche
} catch (SystemException e) { } catch (SystemException e) {
_log.error(e,e); _log.error(e,e);
} }

Caricamento…
Annulla
Salva