use of org.odpi.openmetadata.connector.sas.event.model.catalog.definition.Definition in project egeria-connector-sas-viya by odpi.
the class RepositoryEventMapper method processEvent.
/**
* Method to pass an event received on topic.
*
* @param event inbound event
*/
@Override
public void processEvent(String event) {
log.info("Processing event: {}", event);
CatalogEventPayload eventPayload;
try {
eventPayload = this.mapper.readValue(event, CatalogEventPayload.class);
} catch (IOException e) {
log.warn("Could not parse event payload", e);
return;
}
log.info("Received integration event for Catalog operation: {}", eventPayload.getOperation());
// Convert event payload into SASCatalogObject that rest of application uses
SASCatalogObject catalogObject = new SASCatalogObject();
String type;
if (eventPayload.getType().equals(CatalogEventPayload.TYPE_INSTANCE)) {
Instance instance = eventPayload.getInstance();
Definition definition = eventPayload.getDefinition();
type = instance.getInstanceType();
catalogObject.guid = instance.getId();
catalogObject.defId = instance.getDefinitionId();
catalogObject.addInstance(instance);
catalogObject.addDefinition(definition);
} else if (eventPayload.getType().equals(CatalogEventPayload.TYPE_DEFINITION)) {
Definition definition = eventPayload.getDefinition();
type = definition.getDefinitionType();
catalogObject.guid = definition.getId();
catalogObject.defId = definition.getId();
catalogObject.addDefinition(definition);
} else {
log.warn("Invalid catalog object type: " + eventPayload.getType());
return;
}
if (eventPayload.getOperation().startsWith(CREATE) && type.equals(CatalogType.ENTITY)) {
processNewEntity(catalogObject);
} else if (eventPayload.getOperation().startsWith(UPDATE) && type.equals(CatalogType.ENTITY)) {
processUpdatedEntity(catalogObject);
} else if (eventPayload.getOperation().startsWith(DELETE) && type.equals(CatalogType.ENTITY)) {
processRemovedEntity(catalogObject);
} else if (eventPayload.getOperation().startsWith(CREATE) && type.equals(CatalogType.RELATIONSHIP)) {
processNewRelationship(catalogObject);
} else if (eventPayload.getOperation().startsWith(UPDATE) && type.equals(CatalogType.RELATIONSHIP)) {
processUpdatedRelationship(catalogObject);
} else if (eventPayload.getOperation().startsWith(DELETE) && type.equals(CatalogType.RELATIONSHIP)) {
processRemovedRelationship(catalogObject);
} else {
log.info("Event processing does not support operation, {}, for type, {}", eventPayload.getOperation(), type);
}
}
Aggregations