Search in sources :

Example 1 with Definition

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);
    }
}
Also used : SASCatalogObject(org.odpi.openmetadata.connector.sas.repository.connector.mapping.SASCatalogObject) CatalogEventPayload(org.odpi.openmetadata.connector.sas.event.model.catalog.CatalogEventPayload) Instance(org.odpi.openmetadata.connector.sas.event.model.catalog.instance.Instance) Definition(org.odpi.openmetadata.connector.sas.event.model.catalog.definition.Definition) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 CatalogEventPayload (org.odpi.openmetadata.connector.sas.event.model.catalog.CatalogEventPayload)1 Definition (org.odpi.openmetadata.connector.sas.event.model.catalog.definition.Definition)1 Instance (org.odpi.openmetadata.connector.sas.event.model.catalog.instance.Instance)1 SASCatalogObject (org.odpi.openmetadata.connector.sas.repository.connector.mapping.SASCatalogObject)1