From 63a06802baeb653a5a9d75233a0fa112225a9f88 Mon Sep 17 00:00:00 2001 From: Christopher Grote Date: Mon, 3 Aug 2020 09:06:53 +0100 Subject: [PATCH 1/3] Adds details on user roles required for the connectors Signed-off-by: Christopher Grote --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e19a115..8ceb952e 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,8 @@ For example payloads and endpoints, see the [Postman samples](samples). "userId": "{{igc_user}}", "clearPassword": "{{igc_password}}", "configurationProperties": { - "defaultZones": [ "default" ] + "defaultZones": [ "default" ], + "enableEventMapper": false } } ``` @@ -217,8 +218,17 @@ For example payloads and endpoints, see the [Postman samples](samples). POST https://localhost:9443/open-metadata/admin-services/users/admin/servers/myserver/local-repository/mode/repository-proxy/connection ``` + To operate, the IGC user credentials must have (at a minimum) the following roles within Information Server: + `Suite User` and `Information Governance Catalog User`. (These are both read-only, non-administrative roles.) + You can optionally also provide a list of zone names that will be used as default zones for all Assets retrieved from IGC through the proxy (in the example above this is a single zone called `default`). + + The `enableEventMapper` configuration property can be used to enable the _experimental_ event mapper, which consumes + events that are generated by IGC. By default (when this configuration property is not specified) this is disabled, + and it should be treated as experimental even when enabled. When enabled, the IGC user credentials provided for the + connector must have administrative authority to be able to automatically create the objects used by this + experimental capability. Note that you also need to provide the `connectorProvider` parameter, set to the name of the IGC connectorProvider class (value as given above). @@ -338,6 +348,11 @@ For example payloads and endpoints, see the [Postman samples](samples). POST https://localhost:9443/open-metadata/admin-services/users/admin/servers/datastage_proxy/data-engine-proxy-service/configuration ``` + To operate, the Information Server user credentials must have (at a minimum) the following roles: + `Suite User`, `Information Governance Catalog User`, and `Information Governance Catalog Glossary Author`. + (The first two are both read-only, non-administrative roles, while the last allows synchronization objects + to be created to track the last synchronization point of the DataStage job information.) + Note that you need to provide the `connectorProvider` parameter, set to the name of the DataStage connectorProvider class (value as given above). From 5891889f40686620bccf1562edbf79171ba2f6e5 Mon Sep 17 00:00:00 2001 From: Christopher Grote Date: Tue, 4 Aug 2020 14:54:55 +0100 Subject: [PATCH 2/3] Implements a basic cache for IGC objects that can be used across a single Egeria REST request (that could be many IGC REST requests) to improve performance Signed-off-by: Christopher Grote --- README.md | 5 +- .../mapping/BaseMapping.java | 6 +- .../mapping/SchemaTypeMapping.java | 2 +- .../model/DataStageCache.java | 11 +- .../IGCOMRSRepositoryEventMapper.java | 179 +++++++++++------- .../IGCOMRSMetadataCollection.java | 38 +++- .../IGCRepositoryHelper.java | 52 +++-- .../mapping/EntityMappingInstance.java | 19 +- .../AssetZoneMembershipMapper.java | 3 + .../ClassificationMapping.java | 8 +- .../ConfidentialityMapper.java | 5 +- .../classifications/PrimaryKeyMapper.java | 3 + .../mapping/classifications/Spine_Mapper.java | 3 + .../classifications/SubjectAreaMapper.java | 3 + .../entities/ContactDetailsMapper.java | 7 +- .../mapping/entities/DataClassMapper.java | 13 +- .../mapping/entities/DataFileMapper.java | 7 +- .../mapping/entities/EndpointMapper.java | 15 +- .../mapping/entities/EntityMapping.java | 46 +++-- .../entities/GlossaryCategoryMapper.java | 6 +- .../mapping/entities/GlossaryMapper.java | 11 +- .../mapping/entities/GlossaryTermMapper.java | 5 +- .../entities/GovernanceDefinitionMapper.java | 6 +- .../mapping/entities/NoteEntryMapper.java | 7 +- .../mapping/entities/ReferenceableMapper.java | 7 +- .../entities/SchemaAttributeMapper.java | 6 +- .../mapping/entities/SchemaElementMapper.java | 11 +- .../mapping/entities/SchemaTypeMapper.java | 8 +- .../AttachedNoteLogEntryMapper.java | 13 +- .../relationships/CategoryAnchorMapper.java | 20 +- .../CategoryHierarchyLinkMapper.java | 11 +- .../ConnectionEndpointMapper.java | 20 +- .../DataClassAssignmentMapper.java | 25 ++- .../relationships/RelationshipMapping.java | 77 +++++++- .../SemanticAssignmentMapper.java | 7 +- .../relationships/TermAnchorMapper.java | 20 +- .../TermCategorizationMapper.java | 5 +- .../repositoryconnector/ConnectorTest.java | 31 ++- .../ibm/igc/clientlibrary/IGCRestClient.java | 49 +++-- .../igc/clientlibrary/cache/ObjectCache.java | 35 ++++ .../clientlibrary/model/common/Reference.java | 6 +- .../ibm/igc/clientlibrary/ClientTest.java | 5 +- 42 files changed, 594 insertions(+), 222 deletions(-) create mode 100644 igc-clientlibrary/src/main/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/cache/ObjectCache.java diff --git a/README.md b/README.md index 8ceb952e..a9fd97e3 100644 --- a/README.md +++ b/README.md @@ -351,7 +351,10 @@ For example payloads and endpoints, see the [Postman samples](samples). To operate, the Information Server user credentials must have (at a minimum) the following roles: `Suite User`, `Information Governance Catalog User`, and `Information Governance Catalog Glossary Author`. (The first two are both read-only, non-administrative roles, while the last allows synchronization objects - to be created to track the last synchronization point of the DataStage job information.) + to be created to track the last synchronization point of the DataStage job information.) Finally, if using the + connector option to include virtual assets (`"includeVirtualAssets": true`), the user will also need the + `Information Governance Catalog Information Asset Author` role, as this role is needed to be able to retrieve the + full details of virtual assets. Note that you need to provide the `connectorProvider` parameter, set to the name of the DataStage connectorProvider class (value as given above). diff --git a/datastage-adapter/src/main/java/org/odpi/egeria/connectors/ibm/datastage/dataengineconnector/mapping/BaseMapping.java b/datastage-adapter/src/main/java/org/odpi/egeria/connectors/ibm/datastage/dataengineconnector/mapping/BaseMapping.java index 974ecf55..802609c8 100644 --- a/datastage-adapter/src/main/java/org/odpi/egeria/connectors/ibm/datastage/dataengineconnector/mapping/BaseMapping.java +++ b/datastage-adapter/src/main/java/org/odpi/egeria/connectors/ibm/datastage/dataengineconnector/mapping/BaseMapping.java @@ -41,7 +41,7 @@ String getDescription(InformationAsset igcObj) { */ String getFullyQualifiedName(Reference igcObj) { if (igcObj != null) { - Identity identity = igcObj.getIdentity(igcRestClient); + Identity identity = igcObj.getIdentity(igcRestClient, cache.getIgcCache()); if (identity != null) { return identity.toString(); } @@ -58,7 +58,7 @@ String getFullyQualifiedName(Reference igcObj) { String getParentQualifiedName(Reference igcObj) { String parentQN = null; if (igcObj != null) { - Identity thisObjIdentity = igcObj.getIdentity(igcRestClient); + Identity thisObjIdentity = igcObj.getIdentity(igcRestClient, cache.getIgcCache()); Identity parentObjIdentity = thisObjIdentity.getParentIdentity(); if (parentObjIdentity != null) { parentQN = parentObjIdentity.toString(); @@ -76,7 +76,7 @@ String getParentQualifiedName(Reference igcObj) { String getParentDisplayName(Reference igcObj) { String parentDN = null; if (igcObj != null) { - Identity thisObjIdentity = igcObj.getIdentity(igcRestClient); + Identity thisObjIdentity = igcObj.getIdentity(igcRestClient, cache.getIgcCache()); Identity parentObjIdentity = thisObjIdentity.getParentIdentity(); if (parentObjIdentity != null) { parentDN = parentObjIdentity.getName(); diff --git a/datastage-adapter/src/main/java/org/odpi/egeria/connectors/ibm/datastage/dataengineconnector/mapping/SchemaTypeMapping.java b/datastage-adapter/src/main/java/org/odpi/egeria/connectors/ibm/datastage/dataengineconnector/mapping/SchemaTypeMapping.java index efdeefe3..22b13719 100644 --- a/datastage-adapter/src/main/java/org/odpi/egeria/connectors/ibm/datastage/dataengineconnector/mapping/SchemaTypeMapping.java +++ b/datastage-adapter/src/main/java/org/odpi/egeria/connectors/ibm/datastage/dataengineconnector/mapping/SchemaTypeMapping.java @@ -56,7 +56,7 @@ public SchemaTypeMapping(DataStageCache cache, Identity storeIdentity) { schemaType = null; if (link != null) { schemaType = new SchemaType(); - schemaType.setQualifiedName(link.getIdentity(igcRestClient).toString() + stageNameSuffix); + schemaType.setQualifiedName(link.getIdentity(igcRestClient, cache.getIgcCache()).toString() + stageNameSuffix); schemaType.setDisplayName(link.getId()); schemaType.setAuthor(link.getModifiedBy()); AttributeMapping attributeMapping = new AttributeMapping(cache, job, link, stageNameSuffix); diff --git a/datastage-adapter/src/main/java/org/odpi/egeria/connectors/ibm/datastage/dataengineconnector/model/DataStageCache.java b/datastage-adapter/src/main/java/org/odpi/egeria/connectors/ibm/datastage/dataengineconnector/model/DataStageCache.java index 6b6b120e..c71af66c 100644 --- a/datastage-adapter/src/main/java/org/odpi/egeria/connectors/ibm/datastage/dataengineconnector/model/DataStageCache.java +++ b/datastage-adapter/src/main/java/org/odpi/egeria/connectors/ibm/datastage/dataengineconnector/model/DataStageCache.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.datastage.dataengineconnector.DataStageConstants; import org.odpi.egeria.connectors.ibm.datastage.dataengineconnector.mapping.ProcessMapping; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.*; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Identity; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; @@ -32,6 +33,7 @@ public class DataStageCache { private Map> storeToColumns; private IGCRestClient igcRestClient; + private ObjectCache igcCache; private Date from; private Date to; private List limitToProjects; @@ -44,6 +46,7 @@ public class DataStageCache { * @param limitToProjects limit the cached jobs to only those in the provided list of projects */ public DataStageCache(Date from, Date to, List limitToProjects) { + this.igcCache = new ObjectCache(); this.ridToJob = new HashMap<>(); this.ridToProcess = new HashMap<>(); this.storeToIdentity = new HashMap<>(); @@ -75,6 +78,12 @@ public void initialize(IGCRestClient igcRestClient) { */ public Date getTo() { return to; } + /** + * Retrieve the embedded cache of IGC objects. + * @return ObjectCache + */ + public ObjectCache getIgcCache() { return igcCache; } + /** * {@inheritDoc} */ @@ -232,7 +241,7 @@ public List getFieldsForStore(InformationAsset store if (fields != null) { storeToColumns.put(rid, fields); if (!fields.isEmpty()) { - Identity storeIdentity = fields.get(0).getIdentity(igcRestClient).getParentIdentity(); + Identity storeIdentity = fields.get(0).getIdentity(igcRestClient, igcCache).getParentIdentity(); String storeId = storeIdentity.getRid(); storeToIdentity.put(storeId, storeIdentity); } diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/eventmapper/IGCOMRSRepositoryEventMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/eventmapper/IGCOMRSRepositoryEventMapper.java index f17456f2..e9d7dbff 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/eventmapper/IGCOMRSRepositoryEventMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/eventmapper/IGCOMRSRepositoryEventMapper.java @@ -10,6 +10,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.events.*; @@ -197,10 +198,11 @@ public void run() { @Override public void processEvent(String event) { log.debug("Processing event: {}", event); + ObjectCache cache = new ObjectCache(); if (igcVersion.isEqualTo(IGCVersionEnum.V11702) || igcVersion.isHigherThan(IGCVersionEnum.V11702)) { - processEventV117(event); + processEventV117(event, cache); } else { - processEventV115(event); + processEventV115(event, cache); } } @@ -209,25 +211,26 @@ public void processEvent(String event) { * Basically this method will simply route between processing IMAM events and normal asset events. * * @param event inbound event + * @param cache a cache of information that may already have been retrieved about the provided object */ - private void processEventV115(String event) { + private void processEventV115(String event, ObjectCache cache) { try { InfosphereEvents eventObj = this.mapper.readValue(event, InfosphereEvents.class); if (eventObj != null) { switch (eventObj.getEventType()) { case "IMAM_SHARE_EVENT": - processIMAMShareEventV115((InfosphereEventsIMAMEvent) eventObj); + processIMAMShareEventV115((InfosphereEventsIMAMEvent) eventObj, cache); break; case "DC_CREATE_EVENT": case "DC_MERGED_EVENT": - processDataConnectionEventV115((InfosphereEventsDCEvent) eventObj); + processDataConnectionEventV115((InfosphereEventsDCEvent) eventObj, cache); break; case "IA_COLUMN_CLASSIFIED_EVENT": case "IA_COLUMN_ANALYZED_EVENT": case "IA_TABLE_RESULTS_PUBLISHED": case "IA_COLUMN_FAILED_EVENT": - processIAEventV115((InfosphereEventsIAEvent) eventObj); + processIAEventV115((InfosphereEventsIAEvent) eventObj, cache); break; case "IA_PROJECT_CREATED_EVENT": case "IA_TABLE_ADDED_TO_PROJECT": @@ -264,7 +267,7 @@ private void processEventV115(String event) { log.info("Found OMRS Stub event, skipping."); break; default: - processAssetEventV115((InfosphereEventsAssetEvent) eventObj); + processAssetEventV115((InfosphereEventsAssetEvent) eventObj, cache); break; } } @@ -278,8 +281,9 @@ private void processEventV115(String event) { * Processes IMAM_SHARE_EVENT events from v11.5 of Information Server. * * @param event inbound event + * @param cache a cache of information that may already have been retrieved about the provided object */ - private void processIMAMShareEventV115(InfosphereEventsIMAMEvent event) { + private void processIMAMShareEventV115(InfosphereEventsIMAMEvent event, ObjectCache cache) { Map createdRIDs = getRIDsAndTypesFromEventString(event.getCreatedRIDs()); Map updatedRIDs = getRIDsAndTypesFromEventString(event.getMergedRIDs()); @@ -287,17 +291,17 @@ private void processIMAMShareEventV115(InfosphereEventsIMAMEvent event) { // Start by creating any entities needed by the new RIDs for (Map.Entry entry : createdRIDs.entrySet()) { - processAsset(entry.getKey(), entry.getValue()); + processAsset(cache, entry.getKey(), entry.getValue()); } // Then iterate through any updated entities for (Map.Entry entry : updatedRIDs.entrySet()) { - processAsset(entry.getKey(), entry.getValue()); + processAsset(cache, entry.getKey(), entry.getValue()); } // Then iterate through any deleted entities for (Map.Entry entry : deletedRIDs.entrySet()) { - sendPurgedEntity(entry.getValue(), entry.getKey()); + sendPurgedEntity(entry.getValue(), entry.getKey(), cache); } } @@ -305,15 +309,16 @@ private void processIMAMShareEventV115(InfosphereEventsIMAMEvent event) { /** * Processes Data Connection events from v11.5 of Information Server. * @param event the data connection event to process + * @param cache a cache of information that may already have been retrieved about the provided object */ - private void processDataConnectionEventV115(InfosphereEventsDCEvent event) { + private void processDataConnectionEventV115(InfosphereEventsDCEvent event, ObjectCache cache) { String action = event.getEventType(); if (action.equals(InfosphereEventsDCEvent.ACTION_CREATE)) { - processAsset(event.getCreatedRID(), "data_connection"); + processAsset(cache, event.getCreatedRID(), "data_connection"); } else if (action.equals(InfosphereEventsDCEvent.ACTION_MODIFY)) { - processAsset(event.getMergedRID(), "data_connection"); + processAsset(cache, event.getMergedRID(), "data_connection"); } } @@ -322,8 +327,9 @@ private void processDataConnectionEventV115(InfosphereEventsDCEvent event) { * Processes all asset-specific events from v11.5 of Information Server. * * @param event inbound event + * @param cache a cache of information that may already have been retrieved about the provided object */ - private void processAssetEventV115(InfosphereEventsAssetEvent event) { + private void processAssetEventV115(InfosphereEventsAssetEvent event, ObjectCache cache) { String assetRid = event.getAssetRid(); String action = event.getAction(); @@ -336,7 +342,7 @@ private void processAssetEventV115(InfosphereEventsAssetEvent event) { String igcAssetDisplayName = event.getAssetType(); if (igcAssetDisplayName != null && !igcAssetDisplayName.equals("OMRS Stub")) { String igcAssetType = igcRepositoryHelper.getIgcAssetTypeForAssetName(igcAssetDisplayName); - processAsset(assetRid, igcAssetType); + processAsset(cache, assetRid, igcAssetType); } break; case InfosphereEventsAssetEvent.ACTION_ASSIGNED_RELATIONSHIP: @@ -357,8 +363,9 @@ private void processAssetEventV115(InfosphereEventsAssetEvent event) { * Processes all process-able Information Analyzer events from v11.5 of Information Server. * * @param event inbound event + * @param cache a cache of information that may already have been retrieved about the provided object */ - private void processIAEventV115(InfosphereEventsIAEvent event) { + private void processIAEventV115(InfosphereEventsIAEvent event, ObjectCache cache) { String action = event.getEventType(); @@ -391,7 +398,7 @@ private void processIAEventV115(InfosphereEventsIAEvent event) { break; } // First process the containing asset itself - processAsset(containerRid, containerAsset.getType()); + processAsset(cache, containerRid, containerAsset.getType()); // We should also check the columns / file fields within the table / file for changes to be processed, // as the relationship itself between column and table may not change but there may be // new classifications on the columns / fields from the publication @@ -403,7 +410,7 @@ private void processIAEventV115(InfosphereEventsIAEvent event) { List allSubAssets = igcRestClient.getAllPages(null, subAssets); log.debug("Processing {} child assets from IA publication: {}", subAssets.getPaging().getNumTotal(), containerRid); for (Reference child : allSubAssets) { - processAsset(child.getId(), child.getType()); + processAsset(cache, child.getId(), child.getType()); } } else { log.warn("Unable to find any sub-assets for IA published container '{}': {}", containerRid, event); @@ -423,13 +430,14 @@ private void processIAEventV115(InfosphereEventsIAEvent event) { * * @param asset the IGC asset for which to retrieve an EntityDetail object * @param guid the IGC GUID to use for the asset + * @param cache a cache of information that may already have been retrieved about the provided object * @return EntityDetail */ - private EntityDetail getEntityDetailForAssetWithGUID(Reference asset, IGCEntityGuid guid) { + private EntityDetail getEntityDetailForAssetWithGUID(Reference asset, IGCEntityGuid guid, ObjectCache cache) { EntityDetail detail = null; try { - detail = igcRepositoryHelper.getEntityDetailFromFullAsset(localServerUserId, guid, asset); + detail = igcRepositoryHelper.getEntityDetailFromFullAsset(cache, localServerUserId, guid, asset); } catch (EntityNotKnownException e) { log.error("Unable to find EntityDetail for GUID: {}", guid, e); } catch (RepositoryErrorException e) { @@ -446,9 +454,10 @@ private EntityDetail getEntityDetailForAssetWithGUID(Reference asset, IGCEntityG * * @param stub the OMRS stub for which to retrieve an EntityDetail object * @param guid the IGC GUID to use for the asset + * @param cache a cache of information that may already have been retrieved about the provided object * @return EntityDetail */ - private EntityDetail getEntityDetailForStubWithGUID(OMRSStub stub, IGCEntityGuid guid) { + private EntityDetail getEntityDetailForStubWithGUID(OMRSStub stub, IGCEntityGuid guid, ObjectCache cache) { EntityDetail detail = null; log.debug("Retrieving EntityDetail for stub: {}", stub); @@ -460,7 +469,7 @@ private EntityDetail getEntityDetailForStubWithGUID(OMRSStub stub, IGCEntityGuid } log.debug(" ... retrieved asset from stub: {}", asset); try { - detail = igcRepositoryHelper.getEntityDetailFromFullAsset(localServerUserId, guid, asset); + detail = igcRepositoryHelper.getEntityDetailFromFullAsset(cache, localServerUserId, guid, asset); } catch (EntityNotKnownException e) { log.error("Unable to find EntityDetail for stub with GUID: {}", guid, e); } catch (RepositoryErrorException e) { @@ -520,11 +529,12 @@ private Map getRIDsAndTypesFromEventString(String payload) { * Note that this will process events for all assets (generated and non-generated) based on the provided IGC asset * details. * + * @param cache a cache of information that may already have been retrieved about the provided object * @param rid the Repository ID (RID) of the asset in question * @param assetType the type of asset (ie. if provided in the event payload) */ - private void processAsset(String rid, String assetType) { - processAsset(rid, assetType, null, null); + private void processAsset(ObjectCache cache, String rid, String assetType) { + processAsset(cache, rid, assetType, null, null); } /** @@ -534,13 +544,18 @@ private void processAsset(String rid, String assetType) { * If 'limitToPrefix' is specified, this will only process events for generated IGC assets whose prefix matches * the provided value. * + * @param cache a cache of information that may already have been retrieved about the provided object * @param rid the Repository ID (RID) of the asset in question * @param assetType the type of asset (ie. if provided in the event payload) * @param relationshipGUID the relationship GUID that triggered this asset to be processed (or null if not triggered * by relationship being processed) * @param limitToPrefix if specified, limit the relationships to only those where the asset is prefixed by this prefix */ - private void processAsset(String rid, String assetType, IGCRelationshipGuid relationshipGUID, String limitToPrefix) { + private void processAsset(ObjectCache cache, + String rid, + String assetType, + IGCRelationshipGuid relationshipGUID, + String limitToPrefix) { // TODO: make use of 'limitToPrefix' to limit processing to only generated entities @@ -553,7 +568,7 @@ private void processAsset(String rid, String assetType, IGCRelationshipGuid rela // TODO: currently only possible if we also know the assetType if (assetType != null) { // this should also ensure that any generated entities are purged - sendPurgedEntity(assetType, rid); + sendPurgedEntity(assetType, rid, cache); } else { log.warn("No asset type was provided for purged RID {} -- cannot generate purgeEntity event.", rid); } @@ -570,7 +585,7 @@ private void processAsset(String rid, String assetType, IGCRelationshipGuid rela if (stub == null) { // If there is no stub, we need to treat this as a new entity log.debug("Creating a new entity and stub for: {}", latestVersion.getId()); - sendNewEntity(latestVersion); + sendNewEntity(latestVersion, cache); } else if (!changedProperties.isEmpty()) { // Otherwise, it should be treated as an updated entity, but only if there was some change if (log.isDebugEnabled()) { @@ -583,7 +598,7 @@ private void processAsset(String rid, String assetType, IGCRelationshipGuid rela log.debug(" ... before: {}", stub.getPayload()); log.debug(" ... now: {}", igcRestClient.getValueAsJSON(latestVersion)); } - sendUpdatedEntity(latestVersion, stub); + sendUpdatedEntity(latestVersion, stub, cache); } else { log.info("Skipping asset - no changes detected: {}", latestVersion.getId()); } @@ -617,6 +632,7 @@ private void processAsset(String rid, String assetType, IGCRelationshipGuid rela for (RelationshipMapping relationshipMapping : relationshipMap.get(igcProperty)) { processRelationships( relationshipMapping, + cache, latestVersion, changesForProperty, relationshipGUID @@ -636,12 +652,14 @@ private void processAsset(String rid, String assetType, IGCRelationshipGuid rela * asset has already been published as an event before the relationship is published. * * @param relationshipMapping the relationship mapping defining the IGC and OMRS properties and relationship type + * @param cache a cache of information that may already have been retrieved about the provided object * @param latestVersion the latest version of the IGC asset from which to get the relationship(s) * @param changesForProperty the list of changes for the IGC relationship property being processed * @param relationshipTriggerGUID the GUID of the relationship that triggered this processing (or null if not * triggered initially by the processing of another relationship) */ private void processRelationships(RelationshipMapping relationshipMapping, + ObjectCache cache, Reference latestVersion, List changesForProperty, IGCRelationshipGuid relationshipTriggerGUID) { @@ -666,6 +684,7 @@ private void processRelationships(RelationshipMapping relationshipMapping, relationshipMapping, latestVersion, relatedAsset, + cache, referenceListProperties, change, relationshipTriggerGUID @@ -679,6 +698,7 @@ private void processRelationships(RelationshipMapping relationshipMapping, relationshipMapping, latestVersion, relatedAsset, + cache, referenceListProperties, change, relationshipTriggerGUID @@ -712,6 +732,7 @@ private void processRelationships(RelationshipMapping relationshipMapping, * @param relationshipMapping the relationship mapping through which to translate the relationship * @param latestVersion the latest version (non-stub) for one end of the relationship * @param relatedAsset the latest version (non-stub) for the other end of the relationship + * @param cache a cache of information that may already have been retrieved about the provided object * @param referenceListProperties the list of IGC property names that contain reference lists * @param change the JSON Patch entry indicating a specific change (always from the perspective of latestVersion) * @param relationshipTriggerGUID passthrough of GUID for relationship that triggered this process (if not triggered @@ -720,6 +741,7 @@ private void processRelationships(RelationshipMapping relationshipMapping, private void processOneOrMoreRelationships(RelationshipMapping relationshipMapping, Reference latestVersion, Reference relatedAsset, + ObjectCache cache, List referenceListProperties, ChangeSet.Change change, IGCRelationshipGuid relationshipTriggerGUID) { @@ -747,42 +769,42 @@ private void processOneOrMoreRelationships(RelationshipMapping relationshipMappi String relationshipLevelType = relationshipMapping.getRelationshipLevelIgcAsset(); if (latestVersionType.equals(relationshipLevelType)) { relationshipLevelRid = latestVersionRID; - proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(latestVersion, igcRestClient); - proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(latestVersion, igcRestClient); + proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(latestVersion, igcRestClient, cache); + proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(latestVersion, igcRestClient, cache); } else if (relatedAssetType.equals(relationshipLevelType)) { relationshipLevelRid = relatedRID; - proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(relatedAsset, igcRestClient); - proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(relatedAsset, igcRestClient); + proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(relatedAsset, igcRestClient, cache); + proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(relatedAsset, igcRestClient, cache); } } else if (relationshipMapping.sameTypeOnBothEnds() && !relationshipMapping.samePropertiesOnBothEnds()) { String igcPropertyName = change.getIgcPropertyName(); log.debug(" ... relationship is the same on both ends, but property differs: {}", igcPropertyName); if (pmOne.getIgcRelationshipProperties().contains(igcPropertyName)) { log.debug(" ... proxy mapping 1 contains the property, setting 1 from '{}' and 2 from '{}'", latestVersion.getName(), relatedAsset.getName()); - proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(latestVersion, igcRestClient); - proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(relatedAsset, igcRestClient); + proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(latestVersion, igcRestClient, cache); + proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(relatedAsset, igcRestClient, cache); } else if (pmTwo.getIgcRelationshipProperties().contains(igcPropertyName)) { log.debug(" ... proxy mapping 2 contains the property, setting 1 from '{}' and 2 from '{}'", relatedAsset.getName(), latestVersion.getName()); - proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(relatedAsset, igcRestClient); - proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(latestVersion, igcRestClient); + proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(relatedAsset, igcRestClient, cache); + proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(latestVersion, igcRestClient, cache); } } else if (relationshipMapping.sameTypeOnBothEnds() || (pmOne.matchesAssetType(latestVersionType) && pmTwo.matchesAssetType(relatedAssetType))) { - proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(latestVersion, igcRestClient); - proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(relatedAsset, igcRestClient); + proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(latestVersion, igcRestClient, cache); + proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(relatedAsset, igcRestClient, cache); } else if (pmTwo.matchesAssetType(latestVersionType) && pmOne.matchesAssetType(relatedAssetType)) { - proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(relatedAsset, igcRestClient); - proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(latestVersion, igcRestClient); + proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(relatedAsset, igcRestClient, cache); + proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(latestVersion, igcRestClient, cache); } else if (relationshipMapping.hasLinkingAsset()) { String linkingType = relationshipMapping.getLinkingAssetType(); if ( (latestVersionType.equals(linkingType) && pmTwo.matchesAssetType(relatedAssetType)) || (relatedAssetType.equals(linkingType) && pmOne.matchesAssetType(latestVersionType)) ) { - proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(latestVersion, igcRestClient); - proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(relatedAsset, igcRestClient); + proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(latestVersion, igcRestClient, cache); + proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(relatedAsset, igcRestClient, cache); } else if ( (relatedAssetType.equals(linkingType) && pmTwo.matchesAssetType(latestVersionType)) || (latestVersionType.equals(linkingType) && pmOne.matchesAssetType(relatedAssetType)) ) { - proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(relatedAsset, igcRestClient); - proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(latestVersion, igcRestClient); + proxyOnes = relationshipMapping.getProxyOneAssetFromAsset(relatedAsset, igcRestClient, cache); + proxyTwos = relationshipMapping.getProxyTwoAssetFromAsset(latestVersion, igcRestClient, cache); } else { log.warn("Unable to match assets to proxies through linking asset '{}' for guids {} and {} through relationship type {} -- skipped, but this is likely indicative of a problem with the mapping.", linkingType, latestVersion.getId(), relatedAsset.getId(), omrsRelationshipType); } @@ -798,6 +820,7 @@ private void processOneOrMoreRelationships(RelationshipMapping relationshipMappi relationshipMapping, proxyOne, proxyTwo, + cache, referenceListProperties, change, relationshipLevelRid, @@ -820,6 +843,7 @@ private void processOneOrMoreRelationships(RelationshipMapping relationshipMappi * @param relationshipMapping the relationship mapping through which to translate the relationship * @param proxyOne the latest version (non-stub) for one end of the relationship * @param proxyTwo the latest version (non-stub) for the other end of the relationship + * @param cache a cache of information that may already have been retrieved about the provided object * @param referenceListProperties the list of IGC property names that contain reference lists * @param change the JSON Patch entry indicating a specific change * @param relationshipLevelRid the RID of the relationship-level asset (if any, or null if none) @@ -829,6 +853,7 @@ private void processOneOrMoreRelationships(RelationshipMapping relationshipMappi private void processSingleRelationship(RelationshipMapping relationshipMapping, Reference proxyOne, Reference proxyTwo, + ObjectCache cache, List referenceListProperties, ChangeSet.Change change, String relationshipLevelRid, @@ -843,7 +868,7 @@ private void processSingleRelationship(RelationshipMapping relationshipMapping, // and only if the relationship mapping considers this an actual relationship to include if (relatedRID != null && !relatedRID.equals("null") - && relationshipMapping.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, proxyOne, proxyTwo)) { + && relationshipMapping.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, cache, proxyOne, proxyTwo)) { log.debug("processSingleRelationship processing between {} and {} for type: {}", latestVersionRID, relatedRID, omrsRelationshipType); @@ -876,6 +901,7 @@ private void processSingleRelationship(RelationshipMapping relationshipMapping, sendPurgedRelationship( relationshipMapping, relationshipDef, + cache, igcRelationshipGuid, change.getIgcPropertyName(), proxyOne, @@ -891,7 +917,7 @@ private void processSingleRelationship(RelationshipMapping relationshipMapping, IGCEntityGuid igcEntityGuid2 = RelationshipMapping.getProxyTwoGuidFromRelationship( igcRepositoryHelper, igcRelationshipGuid); - processAsset(igcEntityGuid2.getRid(), + processAsset(cache, igcEntityGuid2.getRid(), pmTwo.getIgcAssetType(), igcRelationshipGuid, igcEntityGuid2.getGeneratedPrefix()); @@ -902,7 +928,7 @@ private void processSingleRelationship(RelationshipMapping relationshipMapping, IGCEntityGuid igcEntityGuid1 = RelationshipMapping.getProxyOneGuidFromRelationship( igcRepositoryHelper, igcRelationshipGuid); - processAsset(igcEntityGuid1.getRid(), + processAsset(cache, igcEntityGuid1.getRid(), pmOne.getIgcAssetType(), igcRelationshipGuid, igcEntityGuid1.getGeneratedPrefix()); @@ -924,12 +950,12 @@ private void processSingleRelationship(RelationshipMapping relationshipMapping, String proxyTwoType = proxyTwo.getType(); if (!IGCRestConstants.getRelationshipLevelTypes().contains(proxyTwoType)) { - processAsset(relatedRID, proxyTwo.getType(), igcRelationshipGuid, igcRelationshipGuid.getGeneratedPrefix2()); + processAsset(cache, relatedRID, proxyTwo.getType(), igcRelationshipGuid, igcRelationshipGuid.getGeneratedPrefix2()); } else { log.debug(" ... proxy two was a relationship-level type, not processing it as an asset: {}", proxyTwoType); } if (!IGCRestConstants.getRelationshipLevelTypes().contains(proxyOneType)) { - processAsset(latestVersionRID, proxyOne.getType(), igcRelationshipGuid, igcRelationshipGuid.getGeneratedPrefix1()); + processAsset(cache, latestVersionRID, proxyOne.getType(), igcRelationshipGuid, igcRelationshipGuid.getGeneratedPrefix1()); } else { log.debug(" ... proxy one was a relationship-level type, not processing it as an asset: {}", proxyOneType); } @@ -943,6 +969,7 @@ private void processSingleRelationship(RelationshipMapping relationshipMapping, sendReplacedRelationship( relationshipMapping, relationship, + cache, proxyOne, proxyTwo, relationshipLevelRid, @@ -1083,6 +1110,7 @@ private void sendUpdatedRelationship(Relationship relationship, OMRSStub stub) { * * @param relationshipMapping the mapping to use for translating this relationship * @param relationship the new relationship + * @param cache a cache of information that may already have been retrieved about the provided object * @param proxyOne the IGC asset used as proxyOne of the new relationship * @param proxyTwo the IGC asset used as proxyTwo of the new relationship * @param relationshipLevelRid the RID of the IGC asset that exists at relationship-level, or null if none @@ -1091,6 +1119,7 @@ private void sendUpdatedRelationship(Relationship relationship, OMRSStub stub) { */ private void sendReplacedRelationship(RelationshipMapping relationshipMapping, Relationship relationship, + ObjectCache cache, Reference proxyOne, Reference proxyTwo, String relationshipLevelRid, @@ -1136,6 +1165,7 @@ private void sendReplacedRelationship(RelationshipMapping relationshipMapping, sendPurgedRelationship( relationshipMapping, relationshipDef, + cache, oldRelationshipGUID, igcPropertyName, oldProxyOne, @@ -1162,6 +1192,7 @@ private void sendReplacedRelationship(RelationshipMapping relationshipMapping, * * @param relationshipMapping the relationship mapping to use to determine what to delete and purge * @param relationshipDef the OMRS relationship definition + * @param cache a cache of information that may already have been retrieved about the provided object * @param relationshipGUID the IGC GUID of the relationship to be deleted and purged * @param igcPropertyName the name of the IGC property holding the relationship * @param proxyOne IGC asset for end one of the relationship @@ -1169,6 +1200,7 @@ private void sendReplacedRelationship(RelationshipMapping relationshipMapping, */ private void sendPurgedRelationship(RelationshipMapping relationshipMapping, RelationshipDef relationshipDef, + ObjectCache cache, IGCRelationshipGuid relationshipGUID, String igcPropertyName, Reference proxyOne, @@ -1194,6 +1226,7 @@ private void sendPurgedRelationship(RelationshipMapping relationshipMapping, igcomrsRepositoryConnector, relationshipMapping, relationshipDef, + cache, getIgcAssetFromStubPayload(stubOne), getIgcAssetFromStubPayload(stubTwo), igcPropertyName, @@ -1222,8 +1255,9 @@ private void sendPurgedRelationship(RelationshipMapping relationshipMapping, * Send an event out on OMRS topic for a new entity. * * @param asset the IGC asset for which we should send a new entity event + * @param cache a cache of information that may already have been retrieved about the provided object */ - private void sendNewEntity(Reference asset) { + private void sendNewEntity(Reference asset, ObjectCache cache) { boolean atLeastOneEvent = false; @@ -1232,7 +1266,7 @@ private void sendNewEntity(Reference asset) { for (EntityMapping referenceableMapper : referenceableMappers) { String ridPrefix = referenceableMapper.getIgcRidPrefix(); IGCEntityGuid igcEntityGuid = igcRepositoryHelper.getEntityGuid(asset.getType(), ridPrefix, asset.getId()); - EntityDetail detail = getEntityDetailForAssetWithGUID(asset, igcEntityGuid); + EntityDetail detail = getEntityDetailForAssetWithGUID(asset, igcEntityGuid, cache); if (detail != null) { atLeastOneEvent = true; repositoryEventProcessor.processNewEntityEvent( @@ -1269,8 +1303,9 @@ private void sendNewEntity(Reference asset) { * * @param latestVersion the IGC asset for which we should send an updated entity event, in its current state * @param stub the OMRS stub for the asset, containing the last version for which we successfully sent an event + * @param cache a cache of information that may already have been retrieved about the provided object */ - private void sendUpdatedEntity(Reference latestVersion, OMRSStub stub) { + private void sendUpdatedEntity(Reference latestVersion, OMRSStub stub, ObjectCache cache) { boolean atLeastOneEvent = false; @@ -1280,10 +1315,10 @@ private void sendUpdatedEntity(Reference latestVersion, OMRSStub stub) { // Generated entities MUST have a prefix, so if there is no prefix ignore that mapper String ridPrefix = referenceableMapper.getIgcRidPrefix(); IGCEntityGuid igcEntityGuid = igcRepositoryHelper.getEntityGuid(latestVersion.getType(), ridPrefix, latestVersion.getId()); - EntityDetail detail = getEntityDetailForAssetWithGUID(latestVersion, igcEntityGuid); + EntityDetail detail = getEntityDetailForAssetWithGUID(latestVersion, igcEntityGuid, cache); if (detail != null) { atLeastOneEvent = true; - EntityDetail last = getEntityDetailForStubWithGUID(stub, igcEntityGuid); + EntityDetail last = getEntityDetailForStubWithGUID(stub, igcEntityGuid, cache); repositoryEventProcessor.processUpdatedEntityEvent( sourceName, metadataCollectionId, @@ -1417,8 +1452,8 @@ private void sendRemovedClassification(EntityDetail detail) { ); } - private void sendPurgedEntity(String igcAssetType, String rid) { - sendPurgedEntity(igcAssetType, rid, new HashSet<>()); + private void sendPurgedEntity(String igcAssetType, String rid, ObjectCache cache) { + sendPurgedEntity(igcAssetType, rid, new HashSet<>(), cache); } /** @@ -1426,8 +1461,10 @@ private void sendPurgedEntity(String igcAssetType, String rid) { * * @param igcAssetType the IGC asset type (ie. translated from the ASSET_TYPE from the event) * @param rid the IGC Repository ID (RID) of the asset + * @param alreadyPurgedRids set of RIDs that have already been purged + * @param cache a cache of information that may already have been retrieved about the provided object */ - private void sendPurgedEntity(String igcAssetType, String rid, Set alreadyPurgedRids) { + private void sendPurgedEntity(String igcAssetType, String rid, Set alreadyPurgedRids, ObjectCache cache) { if (alreadyPurgedRids.contains(rid)) { log.debug("Received RID has already been purged -- skipping: {}", rid); @@ -1447,7 +1484,7 @@ private void sendPurgedEntity(String igcAssetType, String rid, Set alrea for (EntityMapping referenceableMapper : referenceableMappers) { log.debug("Checking via: {}", referenceableMapper.getClass().getName()); - if (referenceableMapper.isOmrsType(igcRestClient, fromObject)) { + if (referenceableMapper.isOmrsType(igcRestClient, cache, fromObject)) { List purgeMarkers = new ArrayList<>(); String ridPrefix = referenceableMapper.getIgcRidPrefix(); @@ -1486,12 +1523,12 @@ private void sendPurgedEntity(String igcAssetType, String rid, Set alrea if (pmOne.matchesAssetType(igcAssetType)) { log.debug(" ... setting 'from' to end1: {}", igcAssetType); propertyNames = pmOne.getIgcRelationshipProperties(); - endOne.addAll(relationshipMapping.getProxyOneAssetFromAsset(fromObject, igcRestClient)); + endOne.addAll(relationshipMapping.getProxyOneAssetFromAsset(fromObject, igcRestClient, cache)); iterateOnOne = true; } else if (pmTwo.matchesAssetType(igcAssetType)) { log.debug(" ... setting 'from' to end2: {}", igcAssetType); propertyNames = pmTwo.getIgcRelationshipProperties(); - endTwo.addAll(relationshipMapping.getProxyTwoAssetFromAsset(fromObject, igcRestClient)); + endTwo.addAll(relationshipMapping.getProxyTwoAssetFromAsset(fromObject, igcRestClient, cache)); iterateOnOne = false; } else if (!relationshipMapping.isSelfReferencing()) { log.warn("Unable to match the purged entity '{}' to either end of relationship: {}", igcAssetType, relationshipDef.getName()); @@ -1515,6 +1552,7 @@ private void sendPurgedEntity(String igcAssetType, String rid, Set alrea cascadeRelationshipPurge( relationshipMapping, relationshipDef, + cache, endOne, endTwo, relationship, @@ -1528,6 +1566,7 @@ private void sendPurgedEntity(String igcAssetType, String rid, Set alrea cascadeRelationshipPurge( relationshipMapping, relationshipDef, + cache, endOne, endTwo, relationship, @@ -1551,11 +1590,11 @@ private void sendPurgedEntity(String igcAssetType, String rid, Set alrea // Recurse on any purges we've marked for (PurgeMarker purgeMarker : purgeMarkers) { - recurseOnContainedEntities(purgeMarker, alreadyPurgedRids); + recurseOnContainedEntities(purgeMarker, alreadyPurgedRids, cache); } // Then remove the entity itself - EntityDetail detail = getEntityDetailForStubWithGUID(stub, igcEntityGuid); + EntityDetail detail = getEntityDetailForStubWithGUID(stub, igcEntityGuid, cache); if (detail != null) { log.debug(" ... purging entity: {}", igcEntityGuid); repositoryEventProcessor.processDeletePurgedEntityEvent( @@ -1593,8 +1632,9 @@ private void sendPurgedEntity(String igcAssetType, String rid, Set alrea * * @param marker the marker indicating what was purged * @param alreadyPurgedRids a set of RIDs for entities that have already been purged + * @param cache a cache of information that may already have been retrieved about the provided object */ - private void recurseOnContainedEntities(PurgeMarker marker, Set alreadyPurgedRids) { + private void recurseOnContainedEntities(PurgeMarker marker, Set alreadyPurgedRids, ObjectCache cache) { RelationshipMapping relationshipMapping = marker.getMapping(); Reference parentObject = marker.getTriggerObject(); @@ -1623,14 +1663,14 @@ private void recurseOnContainedEntities(PurgeMarker marker, Set alreadyP Reference relationship = (Reference) relatedResult; if (!relationship.getId().equals(parentRid)) { log.debug(" ... purging child entity: {}", relationship.getId()); - sendPurgedEntity(relationship.getType(), relationship.getId(), alreadyPurgedRids); + sendPurgedEntity(relationship.getType(), relationship.getId(), alreadyPurgedRids, cache); } } else if (relatedResult instanceof ItemList) { ItemList relationships = (ItemList) relatedResult; for (Reference relationship : relationships.getItems()) { if (!relationship.getId().equals(parentRid)) { log.debug(" ... purging child entity: {}", relationship.getId()); - sendPurgedEntity(relationship.getType(), relationship.getId(), alreadyPurgedRids); + sendPurgedEntity(relationship.getType(), relationship.getId(), alreadyPurgedRids, cache); } } } @@ -1642,6 +1682,7 @@ private void recurseOnContainedEntities(PurgeMarker marker, Set alreadyP private void cascadeRelationshipPurge(RelationshipMapping relationshipMapping, RelationshipDef relationshipDef, + ObjectCache cache, List endOne, List endTwo, Reference relatedObject, @@ -1664,6 +1705,7 @@ private void cascadeRelationshipPurge(RelationshipMapping relationshipMapping, sendPurgedRelationship( relationshipMapping, relationshipDef, + cache, relGuid, propertyName, one, @@ -1686,6 +1728,7 @@ private void cascadeRelationshipPurge(RelationshipMapping relationshipMapping, sendPurgedRelationship( relationshipMapping, relationshipDef, + cache, relGuid, propertyName, relatedObject, @@ -1701,10 +1744,10 @@ private void cascadeRelationshipPurge(RelationshipMapping relationshipMapping, * * @param event inbound event */ - private void processEventV117(String event) { + private void processEventV117(String event, ObjectCache cache) { // TODO: implement processEventV117 log.debug("Not yet implemented as v11.7-specific -- backing to v11.5 processing: {}", event); - processEventV115(event); + processEventV115(event, cache); } /** diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSMetadataCollection.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSMetadataCollection.java index 77132fc7..573bce67 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSMetadataCollection.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSMetadataCollection.java @@ -6,6 +6,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Identity; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearch; @@ -712,6 +713,8 @@ public EntitySummary getEntitySummary(String userId, String guid) throws log.debug("getEntitySummary with guid = {}", guid); + ObjectCache cache = new ObjectCache(); + // Lookup the basic asset based on the RID (strip off prefix (indicating a generated type), if there) IGCEntityGuid igcGuid = IGCEntityGuid.fromGuid(guid); if (igcGuid == null) { @@ -731,6 +734,7 @@ public EntitySummary getEntitySummary(String userId, String guid) throws // Otherwise, retrieve the mapping dynamically based on the type of asset EntityMappingInstance entityMap = igcRepositoryHelper.getMappingInstanceForParameters( + cache, igcGuid.getAssetType(), igcGuid.getRid(), prefix, @@ -738,7 +742,7 @@ public EntitySummary getEntitySummary(String userId, String guid) throws if (entityMap != null) { // 2. Apply the mapping to the object, and retrieve the resulting EntityDetail - summary = EntityMapping.getEntitySummary(entityMap); + summary = EntityMapping.getEntitySummary(entityMap, cache); } else { raiseRepositoryErrorException(IGCOMRSErrorCode.TYPEDEF_NOT_MAPPED, methodName, prefix + igcType, repositoryName); } @@ -767,7 +771,7 @@ public EntityDetail getEntityDetail(String userId, String guid) throws raiseEntityNotKnownException(IGCOMRSErrorCode.ENTITY_NOT_KNOWN, methodName, guid, "", repositoryName); } - return igcRepositoryHelper.getEntityDetail(userId, igcGuid); + return igcRepositoryHelper.getEntityDetail(new ObjectCache(), userId, igcGuid); } @@ -831,6 +835,7 @@ public List getRelationshipsForEntity(String userId, ); ArrayList alRelationships = new ArrayList<>(); + ObjectCache cache = new ObjectCache(); // Immediately throw unimplemented exception if trying to retrieve historical view if (asOfTime != null) { @@ -852,6 +857,7 @@ public List getRelationshipsForEntity(String userId, // Ensure the entity actually exists (if not, throw error to that effect) EntityMappingInstance entityMap = igcRepositoryHelper.getMappingInstanceForParameters( + cache, igcType, rid, prefix, @@ -863,6 +869,7 @@ public List getRelationshipsForEntity(String userId, EntityMapping.getMappedRelationships( igcGuid, entityMap, + cache, relationshipTypeGUID, fromRelationshipElement, sequencingOrder, @@ -885,6 +892,7 @@ public List getRelationshipsForEntity(String userId, * @param userId making the request * @param entityTypeGUID type of entity instance to which to limit results * @param entitySubtypeGUIDs subtype of entity instances to which to limit results + * @param cache a cache of information that may already have been retrieved about the provided object * @param matchClassifications classification-based conditions to which to match results * @param qualifiedNameToFind the regex of the qualified name to find * @param matchCriteria the match criteria for the qualified name @@ -901,6 +909,7 @@ public List getRelationshipsForEntity(String userId, private List findEntitiesByQualifiedName(String userId, String entityTypeGUID, List entitySubtypeGUIDs, + ObjectCache cache, SearchClassifications matchClassifications, String qualifiedNameToFind, MatchCriteria matchCriteria, @@ -980,6 +989,7 @@ private List findEntitiesByQualifiedName(String userId, igcRepositoryHelper.processResultsForMapping( mapper, entityDetails, + cache, userId, entityTypeGUID, entitySubtypeGUIDs, @@ -1018,6 +1028,7 @@ private List findEntitiesByQualifiedName(String userId, igcRepositoryHelper.processResultsForMapping( mapper, entityDetails, + cache, userId, entityTypeGUID, entitySubtypeGUIDs, @@ -1107,6 +1118,7 @@ public List findEntities(String userId, ); ArrayList entityDetails = new ArrayList<>(); + ObjectCache cache = new ObjectCache(); // Immediately throw unimplemented exception if trying to retrieve historical view if (asOfTime != null) { @@ -1129,6 +1141,7 @@ public List findEntities(String userId, userId, entityTypeGUID, entitySubtypeGUIDs, + cache, matchClassifications, qualifiedNameToFind, matchProperties.getMatchCriteria(), @@ -1156,6 +1169,7 @@ public List findEntities(String userId, igcRepositoryHelper.processResultsForMapping( mapping, entityDetails, + cache, userId, entityTypeGUID, entitySubtypeGUIDs, @@ -1249,6 +1263,7 @@ public List findEntitiesByProperty(String userId, ); List entityDetails = new ArrayList<>(); + ObjectCache cache = new ObjectCache(); // Immediately throw unimplemented exception if trying to retrieve historical view if (asOfTime != null) { @@ -1272,6 +1287,7 @@ public List findEntitiesByProperty(String userId, userId, entityTypeGUID, null, + cache, matchClassifications, qualifiedNameToFind, matchCriteria, @@ -1299,6 +1315,7 @@ public List findEntitiesByProperty(String userId, igcRepositoryHelper.processResultsForMapping( mapping, entityDetails, + cache, userId, entityTypeGUID, null, @@ -1393,6 +1410,7 @@ public List findEntitiesByClassification(String userId, ); ArrayList entityDetails = new ArrayList<>(); + ObjectCache cache = new ObjectCache(); // Immediately throw unimplemented exception if trying to retrieve historical view if (asOfTime != null) { @@ -1467,6 +1485,7 @@ public List findEntitiesByClassification(String userId, mapping, this.igcRestClient.search(igcSearch), entityDetails, + cache, null, null, pageSize, @@ -1556,6 +1575,7 @@ public List findEntitiesByPropertyValue(String userId, ); ArrayList entityDetails = new ArrayList<>(); + ObjectCache cache = new ObjectCache(); // Immediately throw unimplemented exception if trying to retrieve historical view if (asOfTime != null) { @@ -1733,6 +1753,7 @@ public List findEntitiesByPropertyValue(String userId, mapping, this.igcRestClient.search(igcSearch), entityDetails, + cache, null, searchCriteria, pageSize, @@ -1791,6 +1812,8 @@ public Relationship getRelationship(String userId, String guid) throws log.debug("Looking up relationship: {}", guid); + ObjectCache cache = new ObjectCache(); + // Translate the key properties of the GUID into IGC-retrievables IGCRelationshipGuid igcRelationshipGuid = IGCRelationshipGuid.fromGuid(guid); if (igcRelationshipGuid == null) { @@ -1820,8 +1843,8 @@ public Relationship getRelationship(String userId, String guid) throws relationshipAssetType, relationshipAssetType ); - proxyOne = relationshipMapping.getProxyOneAssetFromAsset(relationshipAsset, igcRestClient).get(0); - proxyTwo = relationshipMapping.getProxyTwoAssetFromAsset(relationshipAsset, igcRestClient).get(0); + proxyOne = relationshipMapping.getProxyOneAssetFromAsset(relationshipAsset, igcRestClient, cache).get(0); + proxyTwo = relationshipMapping.getProxyTwoAssetFromAsset(relationshipAsset, igcRestClient, cache).get(0); mappings.add(relationshipMapping); } else { @@ -1834,7 +1857,7 @@ public Relationship getRelationship(String userId, String guid) throws proxyOneType, proxyTwoType ); - proxyOne = relationshipMapping.getProxyOneAssetFromAsset(oneEnd, igcRestClient).get(0); + proxyOne = relationshipMapping.getProxyOneAssetFromAsset(oneEnd, igcRestClient, cache).get(0); // TODO: why no getProxyTwoAssetFromAsset here? mappings.add(relationshipMapping); @@ -1854,6 +1877,7 @@ public Relationship getRelationship(String userId, String guid) throws igcomrsRepositoryConnector, relationships, mappings, + cache, relationshipTypeDef.getGUID(), proxyOne, proxyTwo, @@ -1920,6 +1944,7 @@ public List findRelationshipsByProperty(String userId, pageSize); List relationships = new ArrayList<>(); + ObjectCache cache = new ObjectCache(); // Immediately throw unimplemented exception if trying to retrieve historical view if (asOfTime != null) { @@ -1956,6 +1981,7 @@ public List findRelationshipsByProperty(String userId, igcRepositoryHelper.processResults(mapping, igcRestClient.search(igcSearch), relationships, + cache, pageSize, userId); } @@ -2004,6 +2030,7 @@ public List findRelationshipsByPropertyValue(String userId, pageSize); List relationships = new ArrayList<>(); + ObjectCache cache = new ObjectCache(); // Immediately throw unimplemented exception if trying to retrieve historical view if (asOfTime != null) { @@ -2030,6 +2057,7 @@ public List findRelationshipsByPropertyValue(String userId, igcRepositoryHelper.processResults(mapping, igcRestClient.search(igcSearch), relationships, + cache, pageSize, userId); } diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCRepositoryHelper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCRepositoryHelper.java index 38c3ad61..1c8c6e53 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCRepositoryHelper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCRepositoryHelper.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.auditlog.IGCOMRSErrorCode; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Identity; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Paging; @@ -362,6 +363,7 @@ public Map> getIgcPropertiesToRelationshipMapp * * @param mapping the mapping to use for running the search * @param entityDetails the list of results to append into + * @param cache a cache of information that may already have been retrieved about the provided object * @param userId unique identifier for requesting user * @param entityTypeGUID the GUID of the entity type that was requested as part of the search (or null for all) * @param entitySubtypeGUIDs optional list of GUIDs of subtypes by which to further limit results @@ -380,6 +382,7 @@ public Map> getIgcPropertiesToRelationshipMapp */ void processResultsForMapping(EntityMapping mapping, List entityDetails, + ObjectCache cache, String userId, String entityTypeGUID, List entitySubtypeGUIDs, @@ -502,6 +505,7 @@ void processResultsForMapping(EntityMapping mapping, mapping, this.igcRestClient.search(igcSearch), entityDetails, + cache, matchProperties, null, pageSize, @@ -600,6 +604,7 @@ void setPagingForSearch(IGCSearch igcSearch, int beginAt, int pageSize) { * @param mapper the EntityMapping that should be used to translate the results * @param results the IGC search results * @param entityDetails the list of EntityDetails to append + * @param cache a cache of information that may already have been retrieved about the provided object * @param matchProperties the set of properties that should be matched (or null if none) * @param searchCriteria the string search criteria that should be matched (or null if none) * @param pageSize the number of results per page (0 for all results) @@ -608,6 +613,7 @@ void setPagingForSearch(IGCSearch igcSearch, int beginAt, int pageSize) { void processResults(EntityMapping mapper, ItemList results, List entityDetails, + ObjectCache cache, SearchProperties matchProperties, String searchCriteria, int pageSize, @@ -635,7 +641,7 @@ void processResults(EntityMapping mapper, idToLookup = new IGCEntityGuid(metadataCollectionId, reference.getType(), reference.getId()); } try { - ed = getEntityDetailFromFullAsset(userId, idToLookup, reference); + ed = getEntityDetailFromFullAsset(cache, userId, idToLookup, reference); } catch (EntityNotKnownException e) { log.error("Unable to find entity: {}", idToLookup, e); } @@ -652,7 +658,7 @@ void processResults(EntityMapping mapper, // If we haven't filled a page of results (because we needed to skip some above), recurse... if (results.hasMorePages() && entityDetails.size() < pageSize) { ItemList nextPage = igcRestClient.getNextPage(null, results); - processResults(mapper, nextPage, entityDetails, matchProperties, searchCriteria, pageSize, userId); + processResults(mapper, nextPage, entityDetails, cache, matchProperties, searchCriteria, pageSize, userId); } } @@ -663,6 +669,7 @@ void processResults(EntityMapping mapper, * @param mapper the EntityMapping that should be used to translate the results * @param results the IGC search results * @param relationships the list of Relationships to append + * @param cache a cache of information that may already have been retrieved about the provided object * @param pageSize the number of results per page (0 for all results) * @param userId the user making the request */ @@ -670,6 +677,7 @@ void processResults(EntityMapping mapper, void processResults(RelationshipMapping mapper, ItemList results, List relationships, + ObjectCache cache, int pageSize, String userId) throws RepositoryErrorException { @@ -724,13 +732,13 @@ void processResults(RelationshipMapping mapper, if (otherEnd instanceof Reference) { Reference other = (Reference) otherEnd; if (other.getType() != null) { - endOnes.addAll(mapper.getProxyOneAssetFromAsset(other, igcRestClient)); + endOnes.addAll(mapper.getProxyOneAssetFromAsset(other, igcRestClient, cache)); } } else if (otherEnd instanceof ItemList) { ItemList otherEnds = (ItemList) otherEnd; List allOtherEnds = igcRestClient.getAllPages(igcPropertyName, otherEnds); for (Reference other : allOtherEnds) { - endOnes.addAll(mapper.getProxyOneAssetFromAsset(other, igcRestClient)); + endOnes.addAll(mapper.getProxyOneAssetFromAsset(other, igcRestClient, cache)); } } else { log.warn("Not a relationship, skipping: {}", otherEnd); @@ -745,7 +753,7 @@ void processResults(RelationshipMapping mapper, String endTwoType = endTwo.getType(); if (endOneType != null && !endOneType.equals(DEFAULT_IGC_TYPE) && endTwoType != null && !endTwoType.equals(DEFAULT_IGC_TYPE) - && mapper.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, endOne, endTwo)) { + && mapper.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, cache, endOne, endTwo)) { // We do not need a property name when the proxy order is known... IGCRelationshipGuid idToLookup = RelationshipMapping.getRelationshipGUID( this, @@ -785,7 +793,7 @@ void processResults(RelationshipMapping mapper, // If we haven't filled a page of results (because we needed to skip some above), recurse... if (results.hasMorePages() && relationships.size() < pageSize) { ItemList nextPage = igcRestClient.getNextPage(null, results); - processResults(mapper, nextPage, relationships, pageSize, userId); + processResults(mapper, nextPage, relationships, cache, pageSize, userId); } } @@ -1155,6 +1163,7 @@ public static String getPrefixFromGeneratedQualifiedName(String qualifiedName) { * Note: this method assumes that the provided IGC object is already fully-populated for an EntityDetail, * so will avoid any further retrieval of information. * + * @param cache a cache of information that may already have been retrieved about the provided object * @param userId unique identifier for requesting user. * @param guid unique IGC identifier for the entity. * @param asset the IGC asset for which an EntityDetail should be constructed. @@ -1163,7 +1172,7 @@ public static String getPrefixFromGeneratedQualifiedName(String qualifiedName) { * the metadata collection is stored. * @throws EntityNotKnownException the entity cannot be found in IGC */ - public EntityDetail getEntityDetailFromFullAsset(String userId, IGCEntityGuid guid, Reference asset) + public EntityDetail getEntityDetailFromFullAsset(ObjectCache cache, String userId, IGCEntityGuid guid, Reference asset) throws RepositoryErrorException, EntityNotKnownException { final String methodName = "getEntityDetailFromFullAsset"; @@ -1171,9 +1180,9 @@ public EntityDetail getEntityDetailFromFullAsset(String userId, IGCEntityGuid gu validateGuidAndType(guid, methodName); // Otherwise, retrieve the mapping dynamically based on the type of asset - EntityMappingInstance entityMap = getMappingInstanceForParameters(guid, asset, userId); + EntityMappingInstance entityMap = getMappingInstanceForParameters(cache, guid, asset, userId); - return getEntityDetailFromMapInstance(entityMap, guid.getGeneratedPrefix(), guid.getAssetType(), methodName); + return getEntityDetailFromMapInstance(cache, entityMap, guid.getGeneratedPrefix(), guid.getAssetType(), methodName); } @@ -1207,6 +1216,7 @@ private void validateGuidAndType(IGCEntityGuid guid, /** * Apply the mapping to the object and retrieve the resulting EntityDetail. + * @param cache a cache of information that may already have been retrieved about the provided object * @param mappingInstance the mapping instance to apply * @param prefix the IGC prefix (or null if none) * @param igcType the IGC object type @@ -1214,14 +1224,15 @@ private void validateGuidAndType(IGCEntityGuid guid, * @return EntityDetail * @throws RepositoryErrorException if there is no mapping for the type */ - private EntityDetail getEntityDetailFromMapInstance(EntityMappingInstance mappingInstance, + private EntityDetail getEntityDetailFromMapInstance(ObjectCache cache, + EntityMappingInstance mappingInstance, String prefix, String igcType, String methodName) throws RepositoryErrorException { EntityDetail detail = null; if (mappingInstance != null) { - detail = EntityMapping.getEntityDetail(mappingInstance); + detail = EntityMapping.getEntityDetail(cache, mappingInstance); } else { raiseRepositoryErrorException(IGCOMRSErrorCode.TYPEDEF_NOT_MAPPED, methodName, (prefix == null ? "" : prefix) + igcType, repositoryName); } @@ -1232,6 +1243,7 @@ private EntityDetail getEntityDetailFromMapInstance(EntityMappingInstance mappin /** * Return the header, classifications and properties of a specific entity, using the provided IGC GUID. * + * @param cache a cache of information that may already have been retrieved about the provided object * @param userId unique identifier for requesting user. * @param guid unique IGC identifier for the entity. * @return EntityDetail structure. @@ -1239,7 +1251,7 @@ private EntityDetail getEntityDetailFromMapInstance(EntityMappingInstance mappin * the metadata collection is stored. * @throws EntityNotKnownException the entity cannot be found in IGC */ - public EntityDetail getEntityDetail(String userId, IGCEntityGuid guid) + public EntityDetail getEntityDetail(ObjectCache cache, String userId, IGCEntityGuid guid) throws RepositoryErrorException, EntityNotKnownException { final String methodName = "getEntityDetail"; @@ -1251,24 +1263,27 @@ public EntityDetail getEntityDetail(String userId, IGCEntityGuid guid) // Otherwise, retrieve the mapping dynamically based on the type of asset EntityMappingInstance entityMap = getMappingInstanceForParameters( + cache, igcType, guid.getRid(), prefix, userId); - return getEntityDetailFromMapInstance(entityMap, prefix, igcType, methodName); + return getEntityDetailFromMapInstance(cache, entityMap, prefix, igcType, methodName); } /** * Retrieves an instance of a mapping that can be used for the provided parameters (or null if none exists). * + * @param cache a cache of information that may already have been retrieved about the provided object * @param guid the IGC GUID for the entity to be mapped * @param asset the IGC object to be mapped * @param userId the user making the request * @return EntityMappingInstance */ - private EntityMappingInstance getMappingInstanceForParameters(IGCEntityGuid guid, + private EntityMappingInstance getMappingInstanceForParameters(ObjectCache cache, + IGCEntityGuid guid, Reference asset, String userId) { log.debug("Looking for mapper for retrieved asset with guid {}", guid); @@ -1280,6 +1295,7 @@ private EntityMappingInstance getMappingInstanceForParameters(IGCEntityGuid guid entityMap = new EntityMappingInstance( found, igcomrsRepositoryConnector, + cache, asset, userId ); @@ -1294,13 +1310,18 @@ private EntityMappingInstance getMappingInstanceForParameters(IGCEntityGuid guid /** * Retrieves an instance of a mapping that can be used for the provided parameters (or null if none exists). * + * @param cache a cache of information that may already have been retrieved about the provided object * @param igcAssetType the type of IGC asset to be mapped * @param rid the Repository ID (RID) of the IGC asset to be mapped * @param prefix the prefix used for the asset (if any; null otherwise) * @param userId the user making the request * @return EntityMappingInstance */ - public EntityMappingInstance getMappingInstanceForParameters(String igcAssetType, String rid, String prefix, String userId) { + public EntityMappingInstance getMappingInstanceForParameters(ObjectCache cache, + String igcAssetType, + String rid, + String prefix, + String userId) { log.debug("Looking for mapper for type {} with prefix {}", igcAssetType, prefix); @@ -1311,6 +1332,7 @@ public EntityMappingInstance getMappingInstanceForParameters(String igcAssetType entityMap = new EntityMappingInstance( found, igcomrsRepositoryConnector, + cache, igcAssetType, rid, userId diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/EntityMappingInstance.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/EntityMappingInstance.java index c16118a8..b03d2e7d 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/EntityMappingInstance.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/EntityMappingInstance.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.auditlog.IGCOMRSErrorCode; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.repositoryconnector.IGCOMRSMetadataCollection; import org.odpi.egeria.connectors.ibm.igc.repositoryconnector.IGCOMRSRepositoryConnector; @@ -70,12 +71,14 @@ private EntityMappingInstance(EntityMapping mapping, * * @param mapping the definition of the mapping to carry out * @param igcomrsRepositoryConnector connectivity to an IGC repository + * @param cache a cache of information that may already have been retrieved about the provided object * @param igcEntityType the type of IGC object for which to carry out a mapping * @param igcEntityRid the RID of the IGC object for which to carry out a mapping * @param userId the user through which to do the mapping */ public EntityMappingInstance(EntityMapping mapping, IGCOMRSRepositoryConnector igcomrsRepositoryConnector, + ObjectCache cache, String igcEntityType, String igcEntityRid, String userId) { @@ -99,7 +102,7 @@ public EntityMappingInstance(EntityMapping mapping, // (if not needed the 'getBaseIgcAssetFromAlternative' is effectively a NOOP and gives back same object) // We need to make use of mapping.getBaseIgcAssetFromAlternative() here before we attempt to retrieve the // entity itself, as we may (very rarely) need to retrieve a different entity type than what we've been given - Reference simple = mapping.getBaseIgcAssetFromAlternative(igcEntityType, igcEntityRid, igcomrsRepositoryConnector); + Reference simple = mapping.getBaseIgcAssetFromAlternative(igcEntityType, igcEntityRid, igcomrsRepositoryConnector, cache); if (simple != null) { this.igcEntityType = simple.getType(); this.igcEntityRid = simple.getId(); @@ -112,11 +115,13 @@ public EntityMappingInstance(EntityMapping mapping, * * @param mapping the definition of the mapping to carry out * @param igcomrsRepositoryConnector connectivity to an IGC repository + * @param cache a cache of information that may already have been retrieved about the provided object * @param igcEntity the already-retrieved IGC object for which to carry out a mapping * @param userId the user through which to do the mapping */ public EntityMappingInstance(EntityMapping mapping, IGCOMRSRepositoryConnector igcomrsRepositoryConnector, + ObjectCache cache, Reference igcEntity, String userId) { this(mapping, igcomrsRepositoryConnector); @@ -132,7 +137,7 @@ public EntityMappingInstance(EntityMapping mapping, // (if not needed the 'getBaseIgcAssetFromAlternative' is effectively a NOOP and gives back same object) // We need to make use of mapping.getBaseIgcAssetFromAlternative() here before we attempt to retrieve the // entity itself, as we may (very rarely) need to retrieve a different entity type than what we've been given - Reference simple = mapping.getBaseIgcAssetFromAlternative(igcEntityType, igcEntityRid, igcomrsRepositoryConnector); + Reference simple = mapping.getBaseIgcAssetFromAlternative(igcEntityType, igcEntityRid, igcomrsRepositoryConnector, cache); if (simple != null && !simple.getId().equals(igcEntityRid)) { // If the base asset has changed, record the new details and reset the status as not yet retrieved this.igcEntityType = simple.getType(); @@ -221,10 +226,11 @@ public final void updateOmrsDetailWithProperties(InstanceProperties instanceProp /** * Retrieve the OMRS EntitySummary for which this mapping exists. * + * @param cache a cache of information that may already have been retrieved about the provided object * @return EntitySummary */ - public final EntitySummary getOmrsSummary() { - if (mapping.isOmrsType(igcomrsRepositoryConnector.getIGCRestClient(), igcEntity)) { + public final EntitySummary getOmrsSummary(ObjectCache cache) { + if (mapping.isOmrsType(igcomrsRepositoryConnector.getIGCRestClient(), cache, igcEntity)) { return omrsSummary; } else { return null; @@ -234,10 +240,11 @@ public final EntitySummary getOmrsSummary() { /** * Retrieve the OMRS EntityDetail for which this mapping exists. * + * @param cache a cache of information that may already have been retrieved about the provided object * @return EntityDetail */ - public final EntityDetail getOmrsDetail() { - if (mapping.isOmrsType(igcomrsRepositoryConnector.getIGCRestClient(), igcEntity)) { + public final EntityDetail getOmrsDetail(ObjectCache cache) { + if (mapping.isOmrsType(igcomrsRepositoryConnector.getIGCRestClient(), cache, igcEntity)) { return omrsDetail; } else { return null; diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/AssetZoneMembershipMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/AssetZoneMembershipMapper.java index c44d9385..3aded9da 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/AssetZoneMembershipMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/AssetZoneMembershipMapper.java @@ -3,6 +3,7 @@ package org.odpi.egeria.connectors.ibm.igc.repositoryconnector.mapping.classifications; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.repositoryconnector.IGCOMRSRepositoryConnector; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Classification; @@ -65,12 +66,14 @@ protected AssetZoneMembershipMapper(String igcAssetType, * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param classifications the list of classifications to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the IGC object against which the classification should exist * @param userId the user requesting the mapped classifications */ @Override public void addMappedOMRSClassifications(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List classifications, + ObjectCache cache, Reference fromIgcObject, String userId) { OMRSRepositoryHelper repositoryHelper = igcomrsRepositoryConnector.getRepositoryHelper(); diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/ClassificationMapping.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/ClassificationMapping.java index bd49a905..4cdffc3e 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/ClassificationMapping.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/ClassificationMapping.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.auditlog.IGCOMRSErrorCode; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Identity; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchConditionSet; @@ -73,13 +74,14 @@ public ClassificationMapping(String igcAssetType, * or not (false). * * @param igcRestClient connectivity to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @param igcObject the IGC object to check * @return boolean */ - public static boolean isClassification(IGCRestClient igcRestClient, Reference igcObject) { + public static boolean isClassification(IGCRestClient igcRestClient, ObjectCache cache, Reference igcObject) { String assetType = IGCRestConstants.getAssetTypeForSearch(igcObject.getType()); if (assetType.equals("category") || assetType.equals("term")) { - Identity identity = igcObject.getIdentity(igcRestClient); + Identity identity = igcObject.getIdentity(igcRestClient, cache); Identity rootIdentity = identity.getUltimateParentIdentity(); if (rootIdentity != null) { return rootIdentity.getName().equals("Classifications"); @@ -245,11 +247,13 @@ public final void addSimplePropertyMapping(String igcPropertyName, String omrsPr * * @param igcomrsRepositoryConnector connectivity to the IGC repository via OMRS connector * @param classifications the list of classifications to which new classifications should be added + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the IGC object from which to determine the classifications * @param userId the user requesting the classifications (currently unused) */ public void addMappedOMRSClassifications(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List classifications, + ObjectCache cache, Reference fromIgcObject, String userId) { try { diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/ConfidentialityMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/ConfidentialityMapper.java index e2460538..36d260f7 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/ConfidentialityMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/ConfidentialityMapper.java @@ -6,6 +6,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.MainObject; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.Term; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Identity; @@ -75,12 +76,14 @@ protected ConfidentialityMapper() { * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param classifications the list of classifications to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the IGC object for which the classification should exist * @param userId the user requesting the mapped classifications */ @Override public void addMappedOMRSClassifications(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List classifications, + ObjectCache cache, Reference fromIgcObject, String userId) { @@ -98,7 +101,7 @@ public void addMappedOMRSClassifications(IGCOMRSRepositoryConnector igcomrsRepos for (Term assignedTerm : allAssignedTerms) { // Retrieve the identity characteristics (ie. the parent category) of the related term - Identity termIdentity = assignedTerm.getIdentity(igcRestClient); + Identity termIdentity = assignedTerm.getIdentity(igcRestClient, cache); Identity catIdentity = termIdentity.getParentIdentity(); // Only do something with the assigned term if its immediate parent category is named diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/PrimaryKeyMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/PrimaryKeyMapper.java index 23faeffc..92d1b377 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/PrimaryKeyMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/PrimaryKeyMapper.java @@ -6,6 +6,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.CandidateKey; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.DatabaseColumn; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; @@ -60,12 +61,14 @@ protected PrimaryKeyMapper() { * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param classifications the list of classifications to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the IGC object for which the classification should exist * @param userId the user requesting the mapped classifications */ @Override public void addMappedOMRSClassifications(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List classifications, + ObjectCache cache, Reference fromIgcObject, String userId) { diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/Spine_Mapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/Spine_Mapper.java index f636767c..a9b0e457 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/Spine_Mapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/Spine_Mapper.java @@ -3,6 +3,7 @@ package org.odpi.egeria.connectors.ibm.igc.repositoryconnector.mapping.classifications; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.Category; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.Term; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; @@ -44,12 +45,14 @@ protected Spine_Mapper(String omrsClassificationType) { * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param classifications the list of classifications to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the IGC object for which the classification should exist * @param userId the user requesting the mapped classifications */ @Override public void addMappedOMRSClassifications(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List classifications, + ObjectCache cache, Reference fromIgcObject, String userId) { diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/SubjectAreaMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/SubjectAreaMapper.java index 36f4cd4d..1d5d5353 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/SubjectAreaMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/classifications/SubjectAreaMapper.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.Category; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.Term; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; @@ -58,12 +59,14 @@ protected SubjectAreaMapper() { * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param classifications the list of classifications to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the IGC object for which the classification should exist * @param userId the user requesing the mapped classifications */ @Override public void addMappedOMRSClassifications(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List classifications, + ObjectCache cache, Reference fromIgcObject, String userId) { diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/ContactDetailsMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/ContactDetailsMapper.java index b45669a3..76dcd442 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/ContactDetailsMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/ContactDetailsMapper.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchCondition; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchConditionSet; @@ -58,15 +59,17 @@ protected ContactDetailsMapper() { /** * Implement any complex property mappings that cannot be simply mapped one-to-one. * + * @param cache a cache of information that may already have been retrieved about the provided object * @param entityMap the instantiation of a mapping to carry out * @param instanceProperties the instance properties to which to add the complex-mapped properties * @return InstanceProperties */ @Override - protected InstanceProperties complexPropertyMappings(EntityMappingInstance entityMap, + protected InstanceProperties complexPropertyMappings(ObjectCache cache, + EntityMappingInstance entityMap, InstanceProperties instanceProperties) { - instanceProperties = super.complexPropertyMappings(entityMap, instanceProperties); + instanceProperties = super.complexPropertyMappings(cache, entityMap, instanceProperties); final String methodName = "complexPropertyMappings"; diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/DataClassMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/DataClassMapper.java index e447c5da..27ad3719 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/DataClassMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/DataClassMapper.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.DataClass; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.Filter; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; @@ -107,19 +108,21 @@ protected DataClassMapper(IGCVersionEnum version) { * @param igcAssetType the type of the classification asset to translate into a data_class asset * @param igcRid the RID of the classification asset to translate into a data_class asset * @param igcomrsRepositoryConnector connectivity to IGC repository + * @param cache a cache of information that may already have been retrieved about the provided object * @return Reference - the data_class asset */ @Override public Reference getBaseIgcAssetFromAlternative(String igcAssetType, String igcRid, - IGCOMRSRepositoryConnector igcomrsRepositoryConnector) { + IGCOMRSRepositoryConnector igcomrsRepositoryConnector, + ObjectCache cache) { IGCRestClient igcRestClient = igcomrsRepositoryConnector.getIGCRestClient(); if (igcAssetType.equals("classification")) { // In some versions it is not possible to search for 'classification' assets, so generally will be safer // to retrieve the entire object by ID (they are small objects anyway so hopefully no significant negative // performance impact of doing so) return DataClassAssignmentMapper.getInstance(igcomrsRepositoryConnector.getIGCVersion()).getProxyTwoAssetFromAsset( - igcRestClient.getAssetById(igcRid), igcRestClient).get(0); + igcRestClient.getAssetById(igcRid), igcRestClient, cache).get(0); } else { return igcRestClient.getAssetWithSubsetOfProperties(igcRid, igcAssetType, igcRestClient.getAllPropertiesForType(igcAssetType)); } @@ -128,15 +131,17 @@ public Reference getBaseIgcAssetFromAlternative(String igcAssetType, /** * Implement any complex property mappings that cannot be simply mapped one-to-one. * + * @param cache a cache of information that may already have been retrieved about the provided object * @param entityMap the instantiation of a mapping to carry out * @param instanceProperties the instance properties to which to add the complex-mapped properties * @return InstanceProperties */ @Override - protected InstanceProperties complexPropertyMappings(EntityMappingInstance entityMap, + protected InstanceProperties complexPropertyMappings(ObjectCache cache, + EntityMappingInstance entityMap, InstanceProperties instanceProperties) { - instanceProperties = super.complexPropertyMappings(entityMap, instanceProperties); + instanceProperties = super.complexPropertyMappings(cache, entityMap, instanceProperties); final String methodName = "complexPropertyMappings"; diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/DataFileMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/DataFileMapper.java index 21b45347..3f18dc1c 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/DataFileMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/DataFileMapper.java @@ -4,6 +4,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchCondition; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchConditionSet; @@ -58,15 +59,17 @@ protected DataFileMapper() { /** * Implement any complex property mappings that cannot be simply mapped one-to-one. * + * @param cache a cache of information that may already have been retrieved about the provided object * @param entityMap the instantiation of a mapping to carry out * @param instanceProperties the instance properties to which to add the complex-mapped properties * @return InstanceProperties */ @Override - protected InstanceProperties complexPropertyMappings(EntityMappingInstance entityMap, + protected InstanceProperties complexPropertyMappings(ObjectCache cache, + EntityMappingInstance entityMap, InstanceProperties instanceProperties) { - instanceProperties = super.complexPropertyMappings(entityMap, instanceProperties); + instanceProperties = super.complexPropertyMappings(cache, entityMap, instanceProperties); final String methodName = "complexPropertyMappings"; diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/EndpointMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/EndpointMapper.java index ee1f40c9..0a426794 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/EndpointMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/EndpointMapper.java @@ -4,6 +4,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.Host; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; @@ -72,12 +73,14 @@ protected EndpointMapper() { * @param otherAssetType the type of the host_(engine) asset to translate into a host asset * @param otherAssetRid the RID of the host_(engine) asset to translate into a host asset * @param igcomrsRepositoryConnector connectivity to IGC repository + * @param cache a cache of information that may already have been retrieved about the provided object * @return Reference - the host asset */ @Override public Reference getBaseIgcAssetFromAlternative(String otherAssetType, String otherAssetRid, - IGCOMRSRepositoryConnector igcomrsRepositoryConnector) { + IGCOMRSRepositoryConnector igcomrsRepositoryConnector, + ObjectCache cache) { if (otherAssetType.equals("host_(engine)")) { IGCSearchCondition igcSearchCondition = new IGCSearchCondition("_id", "=", otherAssetRid); IGCSearchConditionSet igcSearchConditionSet = new IGCSearchConditionSet(igcSearchCondition); @@ -89,26 +92,28 @@ public Reference getBaseIgcAssetFromAlternative(String otherAssetType, return hosts.getItems().get(0); } else { log.warn("Unable to translate host_(engine) to host, returning host_(engine)."); - return super.getBaseIgcAssetFromAlternative(otherAssetType, otherAssetRid, igcomrsRepositoryConnector); + return super.getBaseIgcAssetFromAlternative(otherAssetType, otherAssetRid, igcomrsRepositoryConnector, cache); } } else { log.debug("Not a host_(engine) asset, just returning as-is: {}", otherAssetType); - return super.getBaseIgcAssetFromAlternative(otherAssetType, otherAssetRid, igcomrsRepositoryConnector); + return super.getBaseIgcAssetFromAlternative(otherAssetType, otherAssetRid, igcomrsRepositoryConnector, cache); } } /** * Implement any complex property mappings that cannot be simply mapped one-to-one. * + * @param cache a cache of information that may already have been retrieved about the provided object * @param entityMap the instantiation of a mapping to carry out * @param instanceProperties the instance properties to which to add the complex-mapped properties * @return InstanceProperties */ @Override - protected InstanceProperties complexPropertyMappings(EntityMappingInstance entityMap, + protected InstanceProperties complexPropertyMappings(ObjectCache cache, + EntityMappingInstance entityMap, InstanceProperties instanceProperties) { - instanceProperties = super.complexPropertyMappings(entityMap, instanceProperties); + instanceProperties = super.complexPropertyMappings(cache, entityMap, instanceProperties); final String methodName = "complexPropertyMappings"; diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/EntityMapping.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/EntityMapping.java index 968cebfd..317e4895 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/EntityMapping.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/EntityMapping.java @@ -4,6 +4,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchConditionSet; import org.odpi.egeria.connectors.ibm.igc.auditlog.IGCOMRSErrorCode; @@ -191,10 +192,11 @@ public final boolean matchesAssetType(String igcAssetType) { * simply returns true directly. * * @param igcRestClient connectivity to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @param igcObject the IGC object to check matches the OMRS type or not * @return boolean */ - public boolean isOmrsType(IGCRestClient igcRestClient, Reference igcObject) { + public boolean isOmrsType(IGCRestClient igcRestClient, ObjectCache cache, Reference igcObject) { return true; } @@ -459,11 +461,13 @@ public final void addClassificationMapper(ClassificationMapping classificationMa * @param igcAssetType the IGC asset type of the alternative asset to translate into a base asset * @param igcRid the IGC Repository ID (RID) of the alternative asset to translate into a base asset * @param igcomrsRepositoryConnector connectivity to IGC repository + * @param cache a cache of information that may already have been retrieved about the provided object * @return Reference - a stripped-down base asset containing only the ID and Type */ public Reference getBaseIgcAssetFromAlternative(String igcAssetType, String igcRid, - IGCOMRSRepositoryConnector igcomrsRepositoryConnector) { + IGCOMRSRepositoryConnector igcomrsRepositoryConnector, + ObjectCache cache) { Reference simple = new Reference(); simple.setId(igcRid); simple.setType(igcAssetType); @@ -473,11 +477,13 @@ public Reference getBaseIgcAssetFromAlternative(String igcAssetType, /** * This method needs to be overridden to define complex property mapping logic (if any). * + * @param cache a cache of information that may already have been retrieved about the provided object * @param entityMap the instantiation of a mapping to carry out * @param instanceProperties the instance properties to which to add the complex-mapped properties * @return InstanceProperties */ - protected InstanceProperties complexPropertyMappings(EntityMappingInstance entityMap, + protected InstanceProperties complexPropertyMappings(ObjectCache cache, + EntityMappingInstance entityMap, InstanceProperties instanceProperties) { // Nothing to do -- no complex properties by default // (only modification details, but because we want those on EntitySummary as well they're handled elsewhere) @@ -544,9 +550,12 @@ public IGCSearchConditionSet getIGCSearchCriteria() { /** * Simple utility function to avoid implementing shared EntitySummary and EntityDetail setup twice. * + * @param cache a cache of information that may already have been retrieved about the provided object * @param entityMap the instantiation of a mapping to carry out + * @param omrsObj the summary object to setup */ - private static void setupEntityObj(EntityMappingInstance entityMap, + private static void setupEntityObj(ObjectCache cache, + EntityMappingInstance entityMap, EntitySummary omrsObj) { Reference igcEntity = entityMap.getIgcEntity(); @@ -573,6 +582,7 @@ private static void setupEntityObj(EntityMappingInstance entityMap, classificationMapping.addMappedOMRSClassifications( igcomrsRepositoryConnector, omrsClassifications, + cache, igcEntity, userId ); @@ -611,9 +621,10 @@ public final List getAllPropertiesForEntitySummary(IGCRestClient igcRest * Map the IGC entity to an OMRS EntitySummary object. * * @param entityMap the instantiation of a mapping to carry out + * @param cache a cache of information that may already have been retrieved about the provided object * @return EntitySummary */ - public static final EntitySummary getEntitySummary(EntityMappingInstance entityMap) { + public static final EntitySummary getEntitySummary(EntityMappingInstance entityMap, ObjectCache cache) { EntityMapping mapping = entityMap.getMapping(); IGCRestClient igcRestClient = entityMap.getRepositoryConnector().getIGCRestClient(); @@ -623,11 +634,11 @@ public static final EntitySummary getEntitySummary(EntityMappingInstance entityM } entityMap.initializeEntitySummary(); - EntitySummary preliminary = entityMap.getOmrsSummary(); + EntitySummary preliminary = entityMap.getOmrsSummary(cache); if (preliminary != null) { - setupEntityObj(entityMap, preliminary); + setupEntityObj(cache, entityMap, preliminary); } - return entityMap.getOmrsSummary(); + return entityMap.getOmrsSummary(cache); } @@ -661,10 +672,11 @@ public final List getAllPropertiesForEntityDetail(IGCRestClient igcRestC /** * Map the IGC entity to an OMRS EntityDetail object. * + * @param cache a cache of information that may already have been retrieved about the provided object * @param entityMap the instantiation of a mapping to carry out * @return EntityDetail */ - public static final EntityDetail getEntityDetail(EntityMappingInstance entityMap) { + public static EntityDetail getEntityDetail(ObjectCache cache, EntityMappingInstance entityMap) { EntityMapping mapping = entityMap.getMapping(); IGCRestClient igcRestClient = entityMap.getRepositoryConnector().getIGCRestClient(); @@ -681,27 +693,28 @@ public static final EntityDetail getEntityDetail(EntityMappingInstance entityMap // Handle any super-generic mappings first entityMap.initializeEntityDetail(); - EntityDetail preliminary = entityMap.getOmrsDetail(); + EntityDetail preliminary = entityMap.getOmrsDetail(cache); if (preliminary != null) { // Then handle any generic mappings and classifications - setupEntityObj(entityMap, preliminary); + setupEntityObj(cache, entityMap, preliminary); // Use reflection to apply POJO-specific mappings - InstanceProperties instanceProperties = getMappedInstanceProperties(entityMap); + InstanceProperties instanceProperties = getMappedInstanceProperties(cache, entityMap); entityMap.updateOmrsDetailWithProperties(instanceProperties); } - return entityMap.getOmrsDetail(); + return entityMap.getOmrsDetail(cache); } /** * Retrieves the InstanceProperties based on the mappings provided. * + * @param cache a cache of information that may already have been retrieved about the provided object * @param entityMap the instantiation of a mapping to carry out * @return InstanceProperties */ - private static InstanceProperties getMappedInstanceProperties(EntityMappingInstance entityMap) { + private static InstanceProperties getMappedInstanceProperties(ObjectCache cache, EntityMappingInstance entityMap) { final String methodName = "getMappedInstanceProperties"; @@ -760,7 +773,7 @@ private static InstanceProperties getMappedInstanceProperties(EntityMappingInsta } // Finally we'll apply any complex property mappings - mapping.complexPropertyMappings(entityMap, instanceProperties); + mapping.complexPropertyMappings(cache, entityMap, instanceProperties); return instanceProperties; @@ -771,6 +784,7 @@ private static InstanceProperties getMappedInstanceProperties(EntityMappingInsta * * @param igcGuid the IGC GUID of the entity for which to retrieve the mapped relationships * @param entityMap the instantiation of a mapping to carry out + * @param cache a cache of information that may already have been retrieved about the provided object * @param relationshipTypeGUID String GUID of the the type of relationship required (null for all). * @param fromRelationshipElement the starting element number of the relationships to return. * This is used when retrieving elements @@ -785,6 +799,7 @@ private static InstanceProperties getMappedInstanceProperties(EntityMappingInsta */ public static List getMappedRelationships(IGCEntityGuid igcGuid, EntityMappingInstance entityMap, + ObjectCache cache, String relationshipTypeGUID, int fromRelationshipElement, SequencingOrder sequencingOrder, @@ -822,6 +837,7 @@ public static List getMappedRelationships(IGCEntityGuid igcGuid, igcomrsRepositoryConnector, omrsRelationships, relationshipMappers, + cache, relationshipTypeGUID, igcEntity, fromRelationshipElement, diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GlossaryCategoryMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GlossaryCategoryMapper.java index 0aa20441..7ce46cfc 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GlossaryCategoryMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GlossaryCategoryMapper.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Identity; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchCondition; @@ -52,10 +53,11 @@ protected GlossaryCategoryMapper() { /** * {@inheritDoc} */ - public boolean isOmrsType(IGCRestClient igcRestClient, Reference igcObject) { + @Override + public boolean isOmrsType(IGCRestClient igcRestClient, ObjectCache cache, Reference igcObject) { String assetType = IGCRestConstants.getAssetTypeForSearch(igcObject.getType()); if (assetType.equals("category")) { - Identity catIdentity = igcObject.getIdentity(igcRestClient); + Identity catIdentity = igcObject.getIdentity(igcRestClient, cache); Identity parentIdentity = catIdentity.getParentIdentity(); if (parentIdentity != null) { Identity ultimate = catIdentity.getUltimateParentIdentity(); diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GlossaryMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GlossaryMapper.java index 84471e7f..feecd094 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GlossaryMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GlossaryMapper.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Identity; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchCondition; @@ -56,13 +57,14 @@ protected GlossaryMapper() { * Utility method to check if the provided IGC object should be treated as a Glossary (true) or not (false). * * @param igcRestClient connectivity to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @param igcObject the IGC object to check * @return boolean */ - public static boolean isGlossary(IGCRestClient igcRestClient, Reference igcObject) { + public static boolean isGlossary(IGCRestClient igcRestClient, ObjectCache cache, Reference igcObject) { String assetType = IGCRestConstants.getAssetTypeForSearch(igcObject.getType()); if (assetType.equals("category")) { - Identity catIdentity = igcObject.getIdentity(igcRestClient); + Identity catIdentity = igcObject.getIdentity(igcRestClient, cache); Identity parentIdentity = catIdentity.getParentIdentity(); return parentIdentity == null && !catIdentity.getName().equals("Classifications"); } @@ -72,8 +74,9 @@ public static boolean isGlossary(IGCRestClient igcRestClient, Reference igcObjec /** * {@inheritDoc} */ - public boolean isOmrsType(IGCRestClient igcRestClient, Reference igcObject) { - return isGlossary(igcRestClient, igcObject); + @Override + public boolean isOmrsType(IGCRestClient igcRestClient, ObjectCache cache, Reference igcObject) { + return isGlossary(igcRestClient, cache, igcObject); } /** diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GlossaryTermMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GlossaryTermMapper.java index 7bb031ad..549eab27 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GlossaryTermMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GlossaryTermMapper.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Identity; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchCondition; @@ -64,10 +65,10 @@ protected GlossaryTermMapper() { * {@inheritDoc} */ @Override - public boolean isOmrsType(IGCRestClient igcRestClient, Reference igcObject) { + public boolean isOmrsType(IGCRestClient igcRestClient, ObjectCache cache, Reference igcObject) { String assetType = IGCRestConstants.getAssetTypeForSearch(igcObject.getType()); if (assetType.equals("term")) { - Identity termIdentity = igcObject.getIdentity(igcRestClient); + Identity termIdentity = igcObject.getIdentity(igcRestClient, cache); Identity ultimateParentIdentity = termIdentity.getUltimateParentIdentity(); return ultimateParentIdentity != null && !ultimateParentIdentity.getName().equals("Classifications"); } diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GovernanceDefinitionMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GovernanceDefinitionMapper.java index 590dd0b9..248e94fc 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GovernanceDefinitionMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/GovernanceDefinitionMapper.java @@ -4,6 +4,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchCondition; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchConditionSet; @@ -60,10 +61,11 @@ protected GovernanceDefinitionMapper(String igcAssetTypeName, * {@inheritDoc} */ @Override - protected InstanceProperties complexPropertyMappings(EntityMappingInstance entityMap, + protected InstanceProperties complexPropertyMappings(ObjectCache cache, + EntityMappingInstance entityMap, InstanceProperties instanceProperties) { - instanceProperties = super.complexPropertyMappings(entityMap, instanceProperties); + instanceProperties = super.complexPropertyMappings(cache, entityMap, instanceProperties); final String methodName = "complexPropertyMappings"; diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/NoteEntryMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/NoteEntryMapper.java index d46c80fd..755602af 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/NoteEntryMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/NoteEntryMapper.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchConditionSet; import org.odpi.egeria.connectors.ibm.igc.repositoryconnector.IGCOMRSRepositoryConnector; import org.odpi.egeria.connectors.ibm.igc.repositoryconnector.mapping.EntityMappingInstance; @@ -54,15 +55,17 @@ protected NoteEntryMapper() { /** * Defines the mapping of qualifiedName to ensure uniqueness for a given note. * + * @param cache a cache of information that may already have been retrieved about the provided object * @param entityMap the instantiation of a mapping to carry out * @param instanceProperties the instance properties to which to add the complex-mapped properties * @return InstanceProperties */ @Override - protected InstanceProperties complexPropertyMappings(EntityMappingInstance entityMap, + protected InstanceProperties complexPropertyMappings(ObjectCache cache, + EntityMappingInstance entityMap, InstanceProperties instanceProperties) { - instanceProperties = super.complexPropertyMappings(entityMap, instanceProperties); + instanceProperties = super.complexPropertyMappings(cache, entityMap, instanceProperties); // Above call will already setup additionalProperties for us, we just need to override qualifiedName // And qualifiedName itself actually cannot be completely unique without the RID of the note, so we will diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/ReferenceableMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/ReferenceableMapper.java index b7ec4837..ddcdfd22 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/ReferenceableMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/ReferenceableMapper.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Identity; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchCondition; @@ -127,12 +128,14 @@ private void init(String igcRidPrefix, boolean includeDefaultRelationships) { * Configures the 'qualifiedName' and 'additionalProperties' properties of all OMRS entities that extend * from Referenceable. * + * @param cache a cache of information that may already have been retrieved about the provided object * @param entityMap instantiation of a mapping to carry out * @param instanceProperties the instance properties to which to add the complex-mapped properties * @return InstanceProperties */ @Override - protected InstanceProperties complexPropertyMappings(EntityMappingInstance entityMap, + protected InstanceProperties complexPropertyMappings(ObjectCache cache, + EntityMappingInstance entityMap, InstanceProperties instanceProperties) { final String methodName = "complexPropertyMappings"; @@ -145,7 +148,7 @@ protected InstanceProperties complexPropertyMappings(EntityMappingInstance entit String repositoryName = igcomrsRepositoryConnector.getRepositoryName(); // Map IGC's identity characteristics to create a unique 'qualifiedName' - String qualifiedName = igcEntity.getIdentity(igcomrsRepositoryConnector.getIGCRestClient()).toString(); + String qualifiedName = igcEntity.getIdentity(igcomrsRepositoryConnector.getIGCRestClient(), cache).toString(); if (mapping.igcRidNeedsPrefix()) { qualifiedName = IGCRepositoryHelper.getQualifiedNameForGeneratedEntity(mapping.getIgcRidPrefix(), qualifiedName); diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/SchemaAttributeMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/SchemaAttributeMapper.java index 0b17a5db..57d44d04 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/SchemaAttributeMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/SchemaAttributeMapper.java @@ -4,6 +4,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchCondition; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchConditionSet; @@ -75,10 +76,11 @@ protected SchemaAttributeMapper(String igcAssetTypeName, * {@inheritDoc} */ @Override - protected InstanceProperties complexPropertyMappings(EntityMappingInstance entityMap, + protected InstanceProperties complexPropertyMappings(ObjectCache cache, + EntityMappingInstance entityMap, InstanceProperties instanceProperties) { - instanceProperties = super.complexPropertyMappings(entityMap, instanceProperties); + instanceProperties = super.complexPropertyMappings(cache, entityMap, instanceProperties); final String methodName = "complexPropertyMappings"; diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/SchemaElementMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/SchemaElementMapper.java index 2a4bcefa..97ff6f7d 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/SchemaElementMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/SchemaElementMapper.java @@ -4,6 +4,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Identity; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchCondition; @@ -67,10 +68,11 @@ protected SchemaElementMapper(String igcAssetTypeName, * {@inheritDoc} */ @Override - protected InstanceProperties complexPropertyMappings(EntityMappingInstance entityMap, + protected InstanceProperties complexPropertyMappings(ObjectCache cache, + EntityMappingInstance entityMap, InstanceProperties instanceProperties) { - instanceProperties = super.complexPropertyMappings(entityMap, instanceProperties); + instanceProperties = super.complexPropertyMappings(cache, entityMap, instanceProperties); final String methodName = "complexPropertyMappings"; @@ -94,6 +96,7 @@ protected InstanceProperties complexPropertyMappings(EntityMappingInstance entit instanceProperties = addAnchorGUIDProperty(repositoryHelper, repositoryName, igcRepositoryHelper, + cache, igcEntity, igcRestClient, instanceProperties); @@ -266,6 +269,7 @@ protected IGCSearchConditionSet getParentAssetSearchCriteria(OMRSRepositoryHelpe * @param repositoryHelper the OMRS repository helper * @param repositoryName the repository name * @param igcRepositoryHelper the IGC repository helper + * @param cache a cache of information that may already have been retrieved about the provided object * @param igcEntity the IGC object from which to determine the anchorGUID * @param igcRestClient connectivity to the IGC environment * @param instanceProperties the instance properties into which to populate the anchorGUID @@ -274,13 +278,14 @@ protected IGCSearchConditionSet getParentAssetSearchCriteria(OMRSRepositoryHelpe protected InstanceProperties addAnchorGUIDProperty(OMRSRepositoryHelper repositoryHelper, String repositoryName, IGCRepositoryHelper igcRepositoryHelper, + ObjectCache cache, Reference igcEntity, IGCRestClient igcRestClient, InstanceProperties instanceProperties) { final String methodName = "addAnchorGUIDProperty"; - Identity identity = igcEntity.getIdentity(igcRestClient); + Identity identity = igcEntity.getIdentity(igcRestClient, cache); Identity asset = getParentAssetIdentity(identity); if (asset != null) { // We should be safe with no prefix here as the assets DeployedDatabaseSchema and DataFile have no prefix diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/SchemaTypeMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/SchemaTypeMapper.java index 94c28958..d95e466f 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/SchemaTypeMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/entities/SchemaTypeMapper.java @@ -4,6 +4,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Identity; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearchCondition; @@ -59,10 +60,11 @@ protected SchemaTypeMapper(String igcAssetTypeName, * {@inheritDoc} */ @Override - protected InstanceProperties complexPropertyMappings(EntityMappingInstance entityMap, + protected InstanceProperties complexPropertyMappings(ObjectCache cache, + EntityMappingInstance entityMap, InstanceProperties instanceProperties) { - instanceProperties = super.complexPropertyMappings(entityMap, instanceProperties); + instanceProperties = super.complexPropertyMappings(cache, entityMap, instanceProperties); final String methodName = "complexPropertyMappings"; @@ -74,7 +76,7 @@ protected InstanceProperties complexPropertyMappings(EntityMappingInstance entit String repositoryName = igcomrsRepositoryConnector.getRepositoryName(); // setup the OMRS 'namespace' property - Identity identity = igcEntity.getIdentity(igcRestClient); + Identity identity = igcEntity.getIdentity(igcRestClient, cache); Identity parent = identity.getParentIdentity(); if (parent != null) { instanceProperties = repositoryHelper.addStringPropertyToInstance( diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/AttachedNoteLogEntryMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/AttachedNoteLogEntryMapper.java index 9a896265..5b84915c 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/AttachedNoteLogEntryMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/AttachedNoteLogEntryMapper.java @@ -4,6 +4,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.Note; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; @@ -96,6 +97,7 @@ private List getNotesFromAsset(Reference asset, IGCRestClient igcRestClien * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param relationships the relationships to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the IGC asset that may have notes * @param toIgcObject the note (or null if all should be retrieved) * @param fromRelationshipElement the starting element number of the relationships to return. @@ -109,6 +111,7 @@ private List getNotesFromAsset(Reference asset, IGCRestClient igcRestClien @Override public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, + ObjectCache cache, Reference fromIgcObject, Reference toIgcObject, int fromRelationshipElement, @@ -130,12 +133,12 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit if (toIgcObject != null && one.matchesAssetType(toIgcObject.getType())) { // Just add this single relationship - addRelationshipSafe(igcomrsRepositoryConnector, relationshipDef, toIgcObject, fromIgcObject, userId, relationships); + addRelationshipSafe(igcomrsRepositoryConnector, relationshipDef, cache, toIgcObject, fromIgcObject, userId, relationships); } else if (toIgcObject == null) { // Otherwise retrieve all of the relationships and add all of them Reference asset = getAssetFromNote((Note) fromIgcObject, igcRestClient); if (asset != null) { - addRelationshipSafe(igcomrsRepositoryConnector, relationshipDef, asset, fromIgcObject, userId, relationships); + addRelationshipSafe(igcomrsRepositoryConnector, relationshipDef, cache, asset, fromIgcObject, userId, relationships); } else { log.warn("Unable to find the owning asset for note: {}", fromIgcObject); } @@ -147,12 +150,12 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit if (toIgcObject instanceof Note) { // Just add this single relationship - addRelationshipSafe(igcomrsRepositoryConnector, relationshipDef, fromIgcObject, toIgcObject, userId, relationships); + addRelationshipSafe(igcomrsRepositoryConnector, relationshipDef, cache, fromIgcObject, toIgcObject, userId, relationships); } else { // Otherwise retrieve all the relationships and add them all List notes = getNotesFromAsset(fromIgcObject, igcRestClient); for (Note note : notes) { - addRelationshipSafe(igcomrsRepositoryConnector, relationshipDef, fromIgcObject, note, userId, relationships); + addRelationshipSafe(igcomrsRepositoryConnector, relationshipDef, cache, fromIgcObject, note, userId, relationships); } } @@ -164,6 +167,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit private void addRelationshipSafe(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, RelationshipDef relationshipDef, + ObjectCache cache, Reference asset, Reference note, String userId, @@ -173,6 +177,7 @@ private void addRelationshipSafe(IGCOMRSRepositoryConnector igcomrsRepositoryCon igcomrsRepositoryConnector, AttachedNoteLogEntryMapper.getInstance(null), relationshipDef, + cache, asset, note, "notes", diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/CategoryAnchorMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/CategoryAnchorMapper.java index fe495ca4..3404b73e 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/CategoryAnchorMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/CategoryAnchorMapper.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.Category; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Identity; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; @@ -63,14 +64,15 @@ protected CategoryAnchorMapper() { * * @param category the category to traverse upwards from to the root-level ancestor * @param igcRestClient REST connectivity to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @return Reference - the host asset */ @Override - public List getProxyOneAssetFromAsset(Reference category, IGCRestClient igcRestClient) { + public List getProxyOneAssetFromAsset(Reference category, IGCRestClient igcRestClient, ObjectCache cache) { String assetType = category.getType(); ArrayList asList = new ArrayList<>(); if (assetType.equals("category")) { - Identity catIdentity = category.getIdentity(igcRestClient); + Identity catIdentity = category.getIdentity(igcRestClient, cache); if (catIdentity != null) { Identity rootIdentity = catIdentity.getUltimateParentIdentity(); Reference root = new Reference(rootIdentity.getName(), rootIdentity.getAssetType(), rootIdentity.getRid()); @@ -97,6 +99,7 @@ public List getProxyOneAssetFromAsset(Reference category, IGCRestClie * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param relationships the relationships to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the category from which to traverse upwards / downwards * @param toIgcObject the category from which to traverse downwards / upwards (or null if not known) * @param fromRelationshipElement the starting element number of the relationships to return. @@ -110,6 +113,7 @@ public List getProxyOneAssetFromAsset(Reference category, IGCRestClie @Override public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, + ObjectCache cache, Reference fromIgcObject, Reference toIgcObject, int fromRelationshipElement, @@ -127,7 +131,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit igcomrsRepositoryConnector.getRepositoryName(), "CategoryAnchor"); - if (GlossaryMapper.isGlossary(igcRestClient, fromIgcObject)) { + if (GlossaryMapper.isGlossary(igcRestClient, cache, fromIgcObject)) { IGCSearchConditionSet conditionSet = new IGCSearchConditionSet(); if (toIgcObject == null) { @@ -168,6 +172,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit igcomrsRepositoryConnector, CategoryAnchorMapper.getInstance(null), relationshipDef, + cache, fromIgcObject, child, "subcategories", @@ -183,7 +188,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit } } else { // We are at a child category, so we need to get the ultimate root-level category - Identity catIdentity = fromIgcObject.getIdentity(igcRestClient); + Identity catIdentity = fromIgcObject.getIdentity(igcRestClient, cache); Identity rootIdentity = catIdentity.getUltimateParentIdentity(); Reference root = igcRestClient.getAssetWithSubsetOfProperties( rootIdentity.getRid(), @@ -196,6 +201,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit igcomrsRepositoryConnector, CategoryAnchorMapper.getInstance(null), relationshipDef, + cache, root, fromIgcObject, "parent_category", @@ -221,18 +227,20 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit * Avoid creating an anchor relationship between the glossary and itself (as a category). * * @param igcomrsRepositoryConnector connection to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @param oneObject the IGC object to consider for inclusion on one end of the relationship * @param otherObject the IGC object to consider for inclusion on the other end of the relationship * @return boolean */ @Override public boolean includeRelationshipForIgcObjects(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, + ObjectCache cache, Reference oneObject, Reference otherObject) { log.debug("Considering inclusion of objects: {} ({}) and {} ({})", oneObject.getName(), oneObject.getType(), otherObject.getName(), otherObject.getType()); IGCRestClient igcRestClient = igcomrsRepositoryConnector.getIGCRestClient(); - return (GlossaryMapper.isGlossary(igcRestClient, oneObject) && otherObject.getType().equals("category") && !GlossaryMapper.isGlossary(igcRestClient, otherObject)) - || (!GlossaryMapper.isGlossary(igcRestClient, oneObject) && oneObject.getType().equals("category") && GlossaryMapper.isGlossary(igcRestClient, otherObject)); + return (GlossaryMapper.isGlossary(igcRestClient, cache, oneObject) && otherObject.getType().equals("category") && !GlossaryMapper.isGlossary(igcRestClient, cache, otherObject)) + || (!GlossaryMapper.isGlossary(igcRestClient, cache, oneObject) && oneObject.getType().equals("category") && GlossaryMapper.isGlossary(igcRestClient, cache, otherObject)); } } diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/CategoryHierarchyLinkMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/CategoryHierarchyLinkMapper.java index 609876b0..bbbcf880 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/CategoryHierarchyLinkMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/CategoryHierarchyLinkMapper.java @@ -4,6 +4,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.repositoryconnector.IGCOMRSRepositoryConnector; import org.odpi.egeria.connectors.ibm.igc.repositoryconnector.mapping.classifications.ClassificationMapping; @@ -43,15 +44,17 @@ protected CategoryHierarchyLinkMapper() { * a relationship for it. * * @param igcomrsRepositoryConnector connection to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @param oneObject the IGC object to consider for inclusion on one end of the relationship * @param otherObject the IGC object to consider for inclusion on the other end of the relationship * @return boolean */ @Override public boolean includeRelationshipForIgcObjects(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, + ObjectCache cache, Reference oneObject, Reference otherObject) { - return isCategoryRelationship(igcomrsRepositoryConnector, oneObject, otherObject); + return isCategoryRelationship(igcomrsRepositoryConnector, cache, oneObject, otherObject); } /** @@ -59,18 +62,20 @@ public boolean includeRelationshipForIgcObjects(IGCOMRSRepositoryConnector igcom * not category-related it is likely because one end is either a Classification or a Glossary. * * @param igcomrsRepositoryConnector connection to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @param oneObject the IGC object to consider for inclusion on one end of the relationship * @param otherObject the IGC object to consider for inclusion on the other end of the relationship * @return boolean */ public static boolean isCategoryRelationship(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, + ObjectCache cache, Reference oneObject, Reference otherObject) { log.debug("Considering inclusion of objects: {} ({}) and {} ({})", oneObject.getName(), oneObject.getType(), otherObject.getName(), otherObject.getType()); IGCRestClient igcRestClient = igcomrsRepositoryConnector.getIGCRestClient(); - boolean isGlossary = GlossaryMapper.isGlossary(igcRestClient, oneObject) || GlossaryMapper.isGlossary(igcRestClient, otherObject); + boolean isGlossary = GlossaryMapper.isGlossary(igcRestClient, cache, oneObject) || GlossaryMapper.isGlossary(igcRestClient, cache, otherObject); if (isGlossary && log.isDebugEnabled()) { log.debug(" ... skipping, Glossary-level category."); } - boolean isClassification = ClassificationMapping.isClassification(igcRestClient, oneObject) || ClassificationMapping.isClassification(igcRestClient, otherObject); + boolean isClassification = ClassificationMapping.isClassification(igcRestClient, cache, oneObject) || ClassificationMapping.isClassification(igcRestClient, cache, otherObject); if (isClassification && log.isDebugEnabled()) { log.debug(" ... skipping, classification object."); } return !isGlossary && !isClassification; } diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/ConnectionEndpointMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/ConnectionEndpointMapper.java index 8a263b9c..5635878c 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/ConnectionEndpointMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/ConnectionEndpointMapper.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.Connector; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.DataConnection; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; @@ -62,10 +63,11 @@ protected ConnectionEndpointMapper() { * * @param connectorAsset the connector asset to translate into a host asset * @param igcRestClient REST connectivity to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @return Reference - the host asset */ @Override - public List getProxyOneAssetFromAsset(Reference connectorAsset, IGCRestClient igcRestClient) { + public List getProxyOneAssetFromAsset(Reference connectorAsset, IGCRestClient igcRestClient, ObjectCache cache) { String otherAssetType = connectorAsset.getType(); ArrayList asList = new ArrayList<>(); if (otherAssetType.equals("connector")) { @@ -86,10 +88,11 @@ public List getProxyOneAssetFromAsset(Reference connectorAsset, IGCRe * * @param connectorAsset the connector asset to translate into a data_connection asset * @param igcRestClient REST connectivity to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @return Reference - the data_connection asset */ @Override - public List getProxyTwoAssetFromAsset(Reference connectorAsset, IGCRestClient igcRestClient) { + public List getProxyTwoAssetFromAsset(Reference connectorAsset, IGCRestClient igcRestClient, ObjectCache cache) { if (connectorAsset != null && connectorAsset.getType().equals("connector")) { Connector withDataConnections = igcRestClient.getAssetWithSubsetOfProperties( connectorAsset.getId(), @@ -115,6 +118,7 @@ public List getProxyTwoAssetFromAsset(Reference connectorAsset, IGCRe * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param relationships the list of relationships to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the host asset for which to create the relationship * @param toIgcObject the other entity endpoint for the relationship (or null if unknown) * @param fromRelationshipElement the starting element number of the relationships to return. @@ -128,6 +132,7 @@ public List getProxyTwoAssetFromAsset(Reference connectorAsset, IGCRe @Override public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, + ObjectCache cache, Reference fromIgcObject, Reference toIgcObject, int fromRelationshipElement, @@ -141,6 +146,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit addMappedOMRSRelationships_host( igcomrsRepositoryConnector, relationships, + cache, fromIgcObject, fromRelationshipElement, sequencingOrder, @@ -151,6 +157,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit addMappedOMRSRelationships_connection( igcomrsRepositoryConnector, relationships, + cache, fromIgcObject, fromRelationshipElement, sequencingOrder, @@ -158,11 +165,12 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit userId ); } else if (assetType.equals("connector")) { - List connections = getProxyTwoAssetFromAsset(fromIgcObject, igcomrsRepositoryConnector.getIGCRestClient()); + List connections = getProxyTwoAssetFromAsset(fromIgcObject, igcomrsRepositoryConnector.getIGCRestClient(), cache); for (Reference connection : connections) { addMappedOMRSRelationships_connection( igcomrsRepositoryConnector, relationships, + cache, connection, fromRelationshipElement, sequencingOrder, @@ -183,6 +191,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param relationships the list of relationships to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the host asset for which to create the relationship * @param fromRelationshipElement the starting element number of the relationships to return. * This is used when retrieving elements @@ -194,6 +203,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit */ private void addMappedOMRSRelationships_host(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, + ObjectCache cache, Reference fromIgcObject, int fromRelationshipElement, SequencingOrder sequencingOrder, @@ -234,6 +244,7 @@ private void addMappedOMRSRelationships_host(IGCOMRSRepositoryConnector igcomrsR (RelationshipDef) igcomrsRepositoryConnector.getRepositoryHelper().getTypeDefByName( igcomrsRepositoryConnector.getRepositoryName(), "ConnectionEndpoint"), + cache, fromIgcObject, dataConnection, "data_connections", @@ -259,6 +270,7 @@ private void addMappedOMRSRelationships_host(IGCOMRSRepositoryConnector igcomrsR * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param relationships the list of relationships to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the data_connection object for which to create the relationship * @param fromRelationshipElement the starting element number of the relationships to return. * This is used when retrieving elements @@ -270,6 +282,7 @@ private void addMappedOMRSRelationships_host(IGCOMRSRepositoryConnector igcomrsR */ private void addMappedOMRSRelationships_connection(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, + ObjectCache cache, Reference fromIgcObject, int fromRelationshipElement, SequencingOrder sequencingOrder, @@ -315,6 +328,7 @@ private void addMappedOMRSRelationships_connection(IGCOMRSRepositoryConnector ig (RelationshipDef) igcomrsRepositoryConnector.getRepositoryHelper().getTypeDefByName( igcomrsRepositoryConnector.getRepositoryName(), "ConnectionEndpoint"), + cache, host, fromIgcObject, "data_connections", diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/DataClassAssignmentMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/DataClassAssignmentMapper.java index 128ccda0..9f8f088f 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/DataClassAssignmentMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/DataClassAssignmentMapper.java @@ -6,6 +6,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.*; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.Classification; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; @@ -80,10 +81,11 @@ protected DataClassAssignmentMapper() { * * @param relationshipAsset the classification asset to translate into a main_object asset * @param igcRestClient REST connectivity to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @return Reference - the classificationenabledgroup asset */ @Override - public List getProxyOneAssetFromAsset(Reference relationshipAsset, IGCRestClient igcRestClient) { + public List getProxyOneAssetFromAsset(Reference relationshipAsset, IGCRestClient igcRestClient, ObjectCache cache) { String otherAssetType = relationshipAsset.getType(); ArrayList asList = new ArrayList<>(); if (otherAssetType.equals("classification")) { @@ -108,10 +110,11 @@ public List getProxyOneAssetFromAsset(Reference relationshipAsset, IG * * @param relationshipAsset the classification asset to translate into a data_class asset * @param igcRestClient REST connectivity to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @return Reference - the data_class asset */ @Override - public List getProxyTwoAssetFromAsset(Reference relationshipAsset, IGCRestClient igcRestClient) { + public List getProxyTwoAssetFromAsset(Reference relationshipAsset, IGCRestClient igcRestClient, ObjectCache cache) { String otherAssetType = relationshipAsset.getType(); ArrayList asList = new ArrayList<>(); if (otherAssetType.equals("classification")) { @@ -138,6 +141,7 @@ public List getProxyTwoAssetFromAsset(Reference relationshipAsset, IG * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param relationships the list of relationships to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the IGC entity from which the relationship exists * @param toIgcObject the other entity endpoint for the relationship (or null if unknown) * @param fromRelationshipElement the starting element number of the relationships to return. @@ -154,6 +158,7 @@ public List getProxyTwoAssetFromAsset(Reference relationshipAsset, IG @Override public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, + ObjectCache cache, Reference fromIgcObject, Reference toIgcObject, int fromRelationshipElement, @@ -165,6 +170,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit mapDetectedClassifications_fromDataClass( igcomrsRepositoryConnector, relationships, + cache, (DataClass) fromIgcObject, toIgcObject instanceof Classificationenabledgroup ? (Classificationenabledgroup) toIgcObject : null, sequencingOrder, @@ -173,6 +179,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit mapSelectedClassifications_fromDataClass( igcomrsRepositoryConnector, relationships, + cache, (DataClass) fromIgcObject, userId ); @@ -180,6 +187,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit mapDetectedClassifications_toDataClass( igcomrsRepositoryConnector, relationships, + cache, (Classificationenabledgroup) fromIgcObject, toIgcObject instanceof DataClass ? (DataClass) toIgcObject : null, sequencingOrder, @@ -188,6 +196,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit mapSelectedClassifications_toDataClass( igcomrsRepositoryConnector, relationships, + cache, (Classificationenabledgroup) fromIgcObject, userId ); @@ -524,6 +533,7 @@ private void includeNoResults(IGCSearchConditionSet dataClassConditions, * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param relationships the list of relationships to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param dataClass the data_class object * @param toIgcObject the classificationenabledgroup that is classified (if known, null otherwise) * @param sequencingOrder Enum defining how the results should be ordered. @@ -531,6 +541,7 @@ private void includeNoResults(IGCSearchConditionSet dataClassConditions, */ private void mapDetectedClassifications_fromDataClass(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, + ObjectCache cache, DataClass dataClass, Classificationenabledgroup toIgcObject, SequencingOrder sequencingOrder, @@ -578,6 +589,7 @@ private void mapDetectedClassifications_fromDataClass(IGCOMRSRepositoryConnector (RelationshipDef) igcomrsRepositoryConnector.getRepositoryHelper().getTypeDefByName( igcomrsRepositoryConnector.getRepositoryName(), R_DATA_CLASS_ASSIGNMENT), + cache, classifiedObj, dataClass, "detected_classifications", @@ -610,11 +622,13 @@ private void mapDetectedClassifications_fromDataClass(IGCOMRSRepositoryConnector * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param relationships the list of relationships to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param dataClass the data_class object * @param userId the user requesting the mapped relationships */ private void mapSelectedClassifications_fromDataClass(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, + ObjectCache cache, DataClass dataClass, String userId) { @@ -643,6 +657,7 @@ private void mapSelectedClassifications_fromDataClass(IGCOMRSRepositoryConnector (RelationshipDef) igcomrsRepositoryConnector.getRepositoryHelper().getTypeDefByName( igcomrsRepositoryConnector.getRepositoryName(), R_DATA_CLASS_ASSIGNMENT), + cache, assetWithSelected, dataClass, "selected_classification", @@ -667,6 +682,7 @@ private void mapSelectedClassifications_fromDataClass(IGCOMRSRepositoryConnector * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param relationships the list of relationships to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the main_object object * @param dataClass the data_class object (if known, or null otherwise) * @param sequencingOrder Enum defining how the results should be ordered. @@ -674,6 +690,7 @@ private void mapSelectedClassifications_fromDataClass(IGCOMRSRepositoryConnector */ private void mapDetectedClassifications_toDataClass(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, + ObjectCache cache, Classificationenabledgroup fromIgcObject, DataClass dataClass, SequencingOrder sequencingOrder, @@ -725,6 +742,7 @@ private void mapDetectedClassifications_toDataClass(IGCOMRSRepositoryConnector i (RelationshipDef) igcomrsRepositoryConnector.getRepositoryHelper().getTypeDefByName( igcomrsRepositoryConnector.getRepositoryName(), R_DATA_CLASS_ASSIGNMENT), + cache, fromIgcObject, dataClassObj, "detected_classifications", @@ -757,11 +775,13 @@ private void mapDetectedClassifications_toDataClass(IGCOMRSRepositoryConnector i * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param relationships the list of relationships to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the classificationenabledgroup object * @param userId the user requesting the mapped relationships */ private void mapSelectedClassifications_toDataClass(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, + ObjectCache cache, Classificationenabledgroup fromIgcObject, String userId) { @@ -785,6 +805,7 @@ private void mapSelectedClassifications_toDataClass(IGCOMRSRepositoryConnector i (RelationshipDef) igcomrsRepositoryConnector.getRepositoryHelper().getTypeDefByName( igcomrsRepositoryConnector.getRepositoryName(), R_DATA_CLASS_ASSIGNMENT), + cache, fromIgcObject, selectedClassification, "selected_classification", diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/RelationshipMapping.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/RelationshipMapping.java index b81e6772..eaf431ed 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/RelationshipMapping.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/RelationshipMapping.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.auditlog.IGCOMRSErrorCode; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.search.IGCSearch; @@ -219,9 +220,10 @@ public String getRelationshipLevelIgcAsset() { * * @param relationshipAsset the asset to use to lookup the actual first endpoint in IGC * @param igcRestClient REST API connectivity + * @param cache a cache of information that may already have been retrieved about the provided object * @return Reference - the asset to be used for endpoint one of the relationship */ - public List getProxyOneAssetFromAsset(Reference relationshipAsset, IGCRestClient igcRestClient) { + public List getProxyOneAssetFromAsset(Reference relationshipAsset, IGCRestClient igcRestClient, ObjectCache cache) { List referenceAsList = new ArrayList<>(); referenceAsList.add(relationshipAsset); return referenceAsList; @@ -234,9 +236,10 @@ public List getProxyOneAssetFromAsset(Reference relationshipAsset, IG * * @param relationshipAsset the asset to use to lookup the actual second endpoint in IGC * @param igcRestClient REST API connectivity + * @param cache a cache of information that may already have been retrieved about the provided object * @return Reference - the asset to be used for endpoint two of the relationship */ - public List getProxyTwoAssetFromAsset(Reference relationshipAsset, IGCRestClient igcRestClient) { + public List getProxyTwoAssetFromAsset(Reference relationshipAsset, IGCRestClient igcRestClient, ObjectCache cache) { List referenceAsList = new ArrayList<>(); referenceAsList.add(relationshipAsset); return referenceAsList; @@ -315,6 +318,7 @@ void addSubType(RelationshipMapping subRelationshipMapping) { * * @param igcomrsRepositoryConnector connection to the IGC environment * @param relationships list of relationships to which to append + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the entity starting point for the relationship * @param toIgcObject the other entity endpoint for the relationship (or null if unknown) * @param fromRelationshipElement the starting element number of the relationships to return. @@ -327,6 +331,7 @@ void addSubType(RelationshipMapping subRelationshipMapping) { */ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, + ObjectCache cache, Reference fromIgcObject, Reference toIgcObject, int fromRelationshipElement, @@ -341,11 +346,13 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit * that need to be applied. * * @param igcomrsRepositoryConnector connection to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @param oneObject the IGC object to consider for inclusion on one end of the relationship * @param otherObject the IGC object to consider for inclusion on the other end of the relationship * @return boolean */ public boolean includeRelationshipForIgcObjects(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, + ObjectCache cache, Reference oneObject, Reference otherObject) { return true; @@ -1058,12 +1065,14 @@ public static IGCRelationshipGuid getRelationshipGUID(IGCRepositoryHelper igcRep * Retrieves an EntityProxy object for the provided IGC object. * * @param igcomrsRepositoryConnector OMRS connector to the IBM IGC repository + * @param cache a cache of information that may already have been retrieved about the provided object * @param igcObj the IGC object for which to retrieve an EntityProxy * @param userId the user through which to retrieve the EntityProxy (unused) * @param ridPrefix any prefix required on the object's ID to make it unique * @return EntityProxy */ private static EntityProxy getEntityProxyForObject(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, + ObjectCache cache, Reference igcObj, String userId, String ridPrefix) { @@ -1088,6 +1097,7 @@ private static EntityProxy getEntityProxyForObject(IGCOMRSRepositoryConnector ig } IGCRepositoryHelper igcRepositoryHelper = igcomrsMetadataCollection.getIgcRepositoryHelper(); EntityMappingInstance entityMap = igcRepositoryHelper.getMappingInstanceForParameters( + cache, igcObj.getType(), igcObj.getId(), ridPrefix, @@ -1096,7 +1106,7 @@ private static EntityProxy getEntityProxyForObject(IGCOMRSRepositoryConnector ig if (entityMap != null) { // Construct 'qualifiedName' from the Identity of the object - String identity = igcObj.getIdentity(igcRestClient).toString(); + String identity = igcObj.getIdentity(igcRestClient, cache).toString(); if (ridPrefix != null) { identity = IGCRepositoryHelper.getQualifiedNameForGeneratedEntity(ridPrefix, identity); } @@ -1128,7 +1138,7 @@ private static EntityProxy getEntityProxyForObject(IGCOMRSRepositoryConnector ig entityProxy.setGUID(igcEntityGuid.toString()); if (igcRestClient.hasModificationDetails(igcObj.getType())) { - Reference withModDetails = igcRestClient.getModificationDetails(igcObj); + Reference withModDetails = igcRestClient.getModificationDetails(igcObj, cache); InstanceMapping.setupInstanceModDetails(entityProxy, withModDetails.getCreatedBy(), withModDetails.getCreatedOn(), @@ -1158,6 +1168,7 @@ private static EntityProxy getEntityProxyForObject(IGCOMRSRepositoryConnector ig * @param igcomrsRepositoryConnector connectivity to an IGC environment * @param relationships the list of relationships to append to * @param mappings the mappings to use for retrieving the relationships + * @param cache a cache of information that may already have been retrieved about the provided object * @param relationshipTypeGUID String GUID of the the type of relationship required (null for all). * @param fromIgcObject the IGC object that is the source of the relationships * @param fromRelationshipElement the starting element number of the relationships to return. @@ -1171,6 +1182,7 @@ private static EntityProxy getEntityProxyForObject(IGCOMRSRepositoryConnector ig public static void getMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, List mappings, + ObjectCache cache, String relationshipTypeGUID, Reference fromIgcObject, int fromRelationshipElement, @@ -1181,6 +1193,7 @@ public static void getMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepo igcomrsRepositoryConnector, relationships, mappings, + cache, relationshipTypeGUID, fromIgcObject, null, @@ -1197,6 +1210,7 @@ public static void getMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepo * @param igcomrsRepositoryConnector connectivity to an IGC environment * @param relationships the list of relationships to append to * @param mappings the mappings to use for retrieving the relationships + * @param cache a cache of information that may already have been retrieved about the provided object * @param relationshipTypeGUID String GUID of the the type of relationship required (null for all). * @param fromIgcObject the IGC object that is the source of the relationships * @param toIgcObject the IGC object that is the target of the relationship (or null if not known). @@ -1205,6 +1219,7 @@ public static void getMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepo public static void getMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, List mappings, + ObjectCache cache, String relationshipTypeGUID, Reference fromIgcObject, Reference toIgcObject, @@ -1212,6 +1227,7 @@ public static void getMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepo getMappedRelationships(igcomrsRepositoryConnector, relationships, mappings, + cache, relationshipTypeGUID, fromIgcObject, toIgcObject, @@ -1227,6 +1243,7 @@ public static void getMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepo * @param igcomrsRepositoryConnector connectivity to an IGC environment * @param relationships the list of relationships to append to * @param mappings the mappings to use for retrieving the relationships + * @param cache a cache of information that may already have been retrieved about the provided object * @param relationshipTypeGUID String GUID of the the type of relationship required (null for all). * @param fromIgcObject the IGC object that is the source of the relationships * @param toIgcObject the IGC object that is the target of the relationship (or null if not known). @@ -1241,6 +1258,7 @@ public static void getMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepo public static void getMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, List mappings, + ObjectCache cache, String relationshipTypeGUID, Reference fromIgcObject, Reference toIgcObject, @@ -1267,8 +1285,8 @@ public static void getMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepo ProxyMapping pmTwo = mapping.getProxyTwoMapping(); if (mapping.isSelfReferencing()) { - if (mapping.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, fromIgcObject, fromIgcObject)) { - addSelfReferencingRelationship(igcomrsRepositoryConnector, mapping, relationships, fromIgcObject, userId); + if (mapping.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, cache, fromIgcObject, fromIgcObject)) { + addSelfReferencingRelationship(igcomrsRepositoryConnector, mapping, relationships, cache, fromIgcObject, userId); } } else if (!optimalStart.equals(RelationshipMapping.OptimalStart.CUSTOM)) { if (fromIgcObject.isFullyRetrieved() @@ -1277,6 +1295,7 @@ public static void getMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepo addDirectRelationship(igcomrsRepositoryConnector, mapping, relationships, + cache, fromIgcObject, toIgcObject, fromRelationshipElement, @@ -1289,6 +1308,7 @@ public static void getMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepo addInvertedRelationship(igcomrsRepositoryConnector, mapping, relationships, + cache, fromIgcObject, toIgcObject, fromRelationshipElement, @@ -1304,6 +1324,7 @@ public static void getMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepo mapping.addMappedOMRSRelationships( igcomrsRepositoryConnector, relationships, + cache, fromIgcObject, toIgcObject, fromRelationshipElement, @@ -1323,18 +1344,21 @@ public static void getMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepo * * @param mapping the mapping for the self-referencing relationship * @param relationships the list of relationships to append to + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the IGC object that is the source (and target) of the self-referencing relationship * @param userId the user retrieving the mapped relationship */ private static void addSelfReferencingRelationship(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, RelationshipMapping mapping, List relationships, + ObjectCache cache, Reference fromIgcObject, String userId) { try { Relationship relationship = getMappedRelationship( igcomrsRepositoryConnector, mapping, + cache, fromIgcObject, fromIgcObject, RelationshipMapping.SELF_REFERENCE_SENTINEL, @@ -1353,6 +1377,7 @@ private static void addSelfReferencingRelationship(IGCOMRSRepositoryConnector ig * @param igcomrsRepositoryConnector connectivity to the IGC repository * @param mapping the mapping for the direct relationship * @param relationships the list of relationships to append to + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the IGC object that is the source of the direct relationship * @param toIgcObject the IGC object that is the target of the direct relationship (if known, otherwise null) * @param fromRelationshipElement the starting element number of the relationships to return. @@ -1367,6 +1392,7 @@ private static void addSelfReferencingRelationship(IGCOMRSRepositoryConnector ig private static void addDirectRelationship(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, RelationshipMapping mapping, List relationships, + ObjectCache cache, Reference fromIgcObject, Reference toIgcObject, int fromRelationshipElement, @@ -1381,6 +1407,7 @@ private static void addDirectRelationship(IGCOMRSRepositoryConnector igcomrsRepo igcomrsRepositoryConnector, mapping, relationships, + cache, fromIgcObject, toIgcObject, userId @@ -1397,11 +1424,12 @@ private static void addDirectRelationship(IGCOMRSRepositoryConnector igcomrsRepo if (directRelationships instanceof Reference) { Reference singleRelationship = (Reference) directRelationships; - if (mapping.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, fromIgcObject, singleRelationship)) { + if (mapping.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, cache, fromIgcObject, singleRelationship)) { addSingleMappedRelationship( igcomrsRepositoryConnector, mapping, relationships, + cache, fromIgcObject, singleRelationship, igcRelationshipName, @@ -1442,6 +1470,7 @@ private static void addDirectRelationship(IGCOMRSRepositoryConnector igcomrsRepo igcomrsRepositoryConnector, mapping, relationships, + cache, fromIgcObject, allRelationships, igcRelationshipName, @@ -1465,6 +1494,7 @@ private static void addDirectRelationship(IGCOMRSRepositoryConnector igcomrsRepo * @param igcomrsRepositoryConnector connectivity to the IGC repository * @param mapping the mapping for the inverted relationship * @param relationships the list of relationships to append to + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the IGC object that is the source of the inverted relationship (or really the target) * @param toIgcObject the IGC object that is the target of the inverted relationship (if known, otherwise null) * @param fromRelationshipElement the starting element number of the relationships to return. @@ -1478,6 +1508,7 @@ private static void addDirectRelationship(IGCOMRSRepositoryConnector igcomrsRepo private static void addInvertedRelationship(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, RelationshipMapping mapping, List relationships, + ObjectCache cache, Reference fromIgcObject, Reference toIgcObject, int fromRelationshipElement, @@ -1494,6 +1525,7 @@ private static void addInvertedRelationship(IGCOMRSRepositoryConnector igcomrsRe igcomrsRepositoryConnector, mapping, relationships, + cache, fromIgcObject, toIgcObject, userId @@ -1512,6 +1544,7 @@ private static void addInvertedRelationship(IGCOMRSRepositoryConnector igcomrsRe igcomrsRepositoryConnector, mapping, relationships, + cache, fromIgcObject, igcSearchConditionSet, assetType, @@ -1545,6 +1578,7 @@ private static void addInvertedRelationship(IGCOMRSRepositoryConnector igcomrsRe igcomrsRepositoryConnector, mapping, relationships, + cache, fromIgcObject, igcSearchConditionSet, sourceAssetType, @@ -1570,6 +1604,7 @@ private static void addInvertedRelationship(IGCOMRSRepositoryConnector igcomrsRe * @param igcomrsRepositoryConnector connectivity to the IGC repository * @param mapping the mapping for the inverted relationship * @param relationships the list of relationships to append to + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the object that is the source of the IGC relationship * @param igcSearchConditionSet the search criteria to use for the search * @param assetType the type of IGC asset for which to search @@ -1585,6 +1620,7 @@ private static void addInvertedRelationship(IGCOMRSRepositoryConnector igcomrsRe private static void addSearchResultsToRelationships(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, RelationshipMapping mapping, List relationships, + ObjectCache cache, Reference fromIgcObject, IGCSearchConditionSet igcSearchConditionSet, String assetType, @@ -1609,6 +1645,7 @@ private static void addSearchResultsToRelationships(IGCOMRSRepositoryConnector i igcomrsRepositoryConnector, mapping, relationships, + cache, fromIgcObject, foundRelationships, igcPropertyName, @@ -1639,6 +1676,7 @@ private static void addSearchResultsToRelationships(IGCOMRSRepositoryConnector i private static void addListOfMappedRelationships(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, RelationshipMapping mapping, List relationships, + ObjectCache cache, Reference fromIgcObject, ItemList igcRelationships, String igcPropertyName, @@ -1660,11 +1698,12 @@ private static void addListOfMappedRelationships(IGCOMRSRepositoryConnector igco // come from this set of relationships for (Reference relation : igcRelationships.getItems()) { if (localPage.size() < totalPotentialResults - && mapping.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, fromIgcObject, relation)) { + && mapping.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, cache, fromIgcObject, relation)) { addSingleMappedRelationship( igcomrsRepositoryConnector, mapping, localPage, + cache, fromIgcObject, relation, igcPropertyName, @@ -1682,6 +1721,7 @@ private static void addListOfMappedRelationships(IGCOMRSRepositoryConnector igco addListOfMappedRelationships(igcomrsRepositoryConnector, mapping, relationships, + cache, fromIgcObject, nextPage, igcPropertyName, @@ -1699,6 +1739,7 @@ private static void addListOfMappedRelationships(IGCOMRSRepositoryConnector igco * @param igcomrsRepositoryConnector connectivity to the IGC repository * @param mapping the mapping to use in translating each relationship * @param relationships the list of relationships to append to + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the asset that is the source of the IGC relationship * @param igcRelationship the IGC relationship * @param igcPropertyName the name of the IGC relationship property @@ -1707,6 +1748,7 @@ private static void addListOfMappedRelationships(IGCOMRSRepositoryConnector igco private static void addSingleMappedRelationship(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, RelationshipMapping mapping, List relationships, + ObjectCache cache, Reference fromIgcObject, Reference igcRelationship, String igcPropertyName, @@ -1721,6 +1763,7 @@ private static void addSingleMappedRelationship(IGCOMRSRepositoryConnector igcom Relationship omrsRelationship = getMappedRelationship( igcomrsRepositoryConnector, mapping, + cache, fromIgcObject, igcRelationship, igcPropertyName, @@ -1742,6 +1785,7 @@ private static void addSingleMappedRelationship(IGCOMRSRepositoryConnector igcom * @param igcomrsRepositoryConnector connectivity to the IGC repository * @param mapping the mapping to use in translating each relationship * @param relationships the list of relationships to append to + * @param cache a cache of information that may already have been retrieved about the provided object * @param proxyOne the asset that acts as proxy one in the relationship * @param proxyTwo the asset that acts as proxy two in the relationship * @param userId the user retrieving the mapped relationship @@ -1749,6 +1793,7 @@ private static void addSingleMappedRelationship(IGCOMRSRepositoryConnector igcom private static void addSingleMappedRelationshipWithKnownOrder(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, RelationshipMapping mapping, List relationships, + ObjectCache cache, Reference proxyOne, Reference proxyTwo, String userId) { @@ -1766,6 +1811,7 @@ private static void addSingleMappedRelationshipWithKnownOrder(IGCOMRSRepositoryC igcomrsRepositoryConnector, mapping, omrsRelationshipDef, + cache, proxyOne, proxyTwo, null, @@ -1788,6 +1834,7 @@ private static void addSingleMappedRelationshipWithKnownOrder(IGCOMRSRepositoryC * * @param igcomrsRepositoryConnector connectivity to the IGC repository * @param mapping the mapping details to use + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the asset that is the source of the IGC relationship * @param relation the related IGC object * @param igcPropertyName the name of the IGC relationship property @@ -1798,6 +1845,7 @@ private static void addSingleMappedRelationshipWithKnownOrder(IGCOMRSRepositoryC */ private static Relationship getMappedRelationship(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, RelationshipMapping mapping, + ObjectCache cache, Reference fromIgcObject, Reference relation, String igcPropertyName, @@ -1812,6 +1860,7 @@ private static Relationship getMappedRelationship(IGCOMRSRepositoryConnector igc igcomrsRepositoryConnector, mapping, omrsRelationshipDef, + cache, fromIgcObject, relation, igcPropertyName, @@ -1826,6 +1875,7 @@ private static Relationship getMappedRelationship(IGCOMRSRepositoryConnector igc * @param igcomrsRepositoryConnector connectivity to the IGC repository * @param relationshipMapping the definition of how to map the relationship * @param omrsRelationshipDef the OMRS relationship definition + * @param cache a cache of information that may already have been retrieved about the provided object * @param proxyOne the IGC asset to use for endpoint 1 of the relationship * @param proxyTwo the IGC asset to use for endpoint 2 of the relationship * @param igcPropertyName the name of the IGC relationship property @@ -1837,6 +1887,7 @@ private static Relationship getMappedRelationship(IGCOMRSRepositoryConnector igc protected static Relationship getMappedRelationship(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, RelationshipMapping relationshipMapping, RelationshipDef omrsRelationshipDef, + ObjectCache cache, Reference proxyOne, Reference proxyTwo, String igcPropertyName, @@ -1845,6 +1896,7 @@ protected static Relationship getMappedRelationship(IGCOMRSRepositoryConnector i igcomrsRepositoryConnector, relationshipMapping, omrsRelationshipDef, + cache, proxyOne, proxyTwo, igcPropertyName, @@ -1859,6 +1911,7 @@ protected static Relationship getMappedRelationship(IGCOMRSRepositoryConnector i * @param igcomrsRepositoryConnector connectivity to the IGC repository * @param relationshipMapping the definition of how to map the relationship * @param omrsRelationshipDef the OMRS relationship definition + * @param cache a cache of information that may already have been retrieved about the provided object * @param proxyOne the IGC asset to consider for endpoint 1 of the relationship * @param proxyTwo the IGC asset to consider for endpoint 2 of the relationship * @param igcPropertyName the name of the IGC relationship property @@ -1871,6 +1924,7 @@ protected static Relationship getMappedRelationship(IGCOMRSRepositoryConnector i public static Relationship getMappedRelationship(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, RelationshipMapping relationshipMapping, RelationshipDef omrsRelationshipDef, + ObjectCache cache, Reference proxyOne, Reference proxyTwo, String igcPropertyName, @@ -1880,6 +1934,7 @@ public static Relationship getMappedRelationship(IGCOMRSRepositoryConnector igco igcomrsRepositoryConnector, relationshipMapping, omrsRelationshipDef, + cache, proxyOne, proxyTwo, igcPropertyName, @@ -1895,6 +1950,7 @@ public static Relationship getMappedRelationship(IGCOMRSRepositoryConnector igco * @param igcomrsRepositoryConnector connectivity to the IGC repository * @param relationshipMapping the definition of how to map the relationship * @param omrsRelationshipDef the OMRS relationship definition + * @param cache a cache of information that may already have been retrieved about the provided object * @param proxyOne the IGC asset to consider for endpoint 1 of the relationship * @param proxyTwo the IGC asset to consider for endpoint 2 of the relationship * @param igcPropertyName the name of the IGC relationship property @@ -1908,6 +1964,7 @@ public static Relationship getMappedRelationship(IGCOMRSRepositoryConnector igco public static Relationship getMappedRelationship(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, RelationshipMapping relationshipMapping, RelationshipDef omrsRelationshipDef, + ObjectCache cache, Reference proxyOne, Reference proxyTwo, String igcPropertyName, @@ -1965,12 +2022,14 @@ public static Relationship getMappedRelationship(IGCOMRSRepositoryConnector igco || (ridForEP1.equals(proxyOne.getId()) && ridForEP2.equals(proxyTwo.getId()))) { ep1 = RelationshipMapping.getEntityProxyForObject( igcomrsRepositoryConnector, + cache, proxyOne, userId, relationshipMapping.getProxyOneMapping().getIgcRidPrefix() ); ep2 = RelationshipMapping.getEntityProxyForObject( igcomrsRepositoryConnector, + cache, proxyTwo, userId, relationshipMapping.getProxyTwoMapping().getIgcRidPrefix() @@ -1978,12 +2037,14 @@ public static Relationship getMappedRelationship(IGCOMRSRepositoryConnector igco } else if (ridForEP2.equals(proxyOne.getId()) && ridForEP1.equals(proxyTwo.getId())) { ep1 = RelationshipMapping.getEntityProxyForObject( igcomrsRepositoryConnector, + cache, proxyTwo, userId, relationshipMapping.getProxyOneMapping().getIgcRidPrefix() ); ep2 = RelationshipMapping.getEntityProxyForObject( igcomrsRepositoryConnector, + cache, proxyOne, userId, relationshipMapping.getProxyTwoMapping().getIgcRidPrefix() diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/SemanticAssignmentMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/SemanticAssignmentMapper.java index 57a16aa6..332816b8 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/SemanticAssignmentMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/SemanticAssignmentMapper.java @@ -4,6 +4,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.repositoryconnector.IGCOMRSRepositoryConnector; import org.odpi.egeria.connectors.ibm.igc.repositoryconnector.IGCRepositoryHelper; @@ -64,18 +65,20 @@ protected SemanticAssignmentMapper() { * scenarios, include a relationship for it. * * @param igcomrsRepositoryConnector connection to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @param oneObject the IGC object to consider for inclusion on one end of the relationship * @param otherObject the IGC object to consider for inclusion on the other end of the relationship * @return boolean */ @Override public boolean includeRelationshipForIgcObjects(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, + ObjectCache cache, Reference oneObject, Reference otherObject) { log.debug("Considering inclusion of objects: {} ({}) and {} ({})", oneObject.getName(), oneObject.getType(), otherObject.getName(), otherObject.getType()); IGCRestClient igcRestClient = igcomrsRepositoryConnector.getIGCRestClient(); - boolean isClassification = ClassificationMapping.isClassification(igcRestClient, oneObject) - || ClassificationMapping.isClassification(igcRestClient, otherObject); + boolean isClassification = ClassificationMapping.isClassification(igcRestClient, cache, oneObject) + || ClassificationMapping.isClassification(igcRestClient, cache, otherObject); if (isClassification) { log.debug(" ... skipping, reserved Classification object."); } diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/TermAnchorMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/TermAnchorMapper.java index 8c112337..fcd75d85 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/TermAnchorMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/TermAnchorMapper.java @@ -5,6 +5,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestConstants; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.Term; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Identity; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; @@ -63,14 +64,15 @@ protected TermAnchorMapper() { * * @param term the term to traverse upwards from to the root-level ancestor * @param igcRestClient REST connectivity to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @return Reference - the host asset */ @Override - public List getProxyOneAssetFromAsset(Reference term, IGCRestClient igcRestClient) { + public List getProxyOneAssetFromAsset(Reference term, IGCRestClient igcRestClient, ObjectCache cache) { String assetType = term.getType(); ArrayList asList = new ArrayList<>(); if (assetType.equals("term")) { - Identity termIdentity = term.getIdentity(igcRestClient); + Identity termIdentity = term.getIdentity(igcRestClient, cache); if (termIdentity != null) { Identity rootIdentity = termIdentity.getUltimateParentIdentity(); Reference root = new Reference(rootIdentity.getName(), rootIdentity.getAssetType(), rootIdentity.getRid()); @@ -96,6 +98,7 @@ public List getProxyOneAssetFromAsset(Reference term, IGCRestClient i * * @param igcomrsRepositoryConnector connectivity to the IGC environment * @param relationships the relationships to which to add + * @param cache a cache of information that may already have been retrieved about the provided object * @param fromIgcObject the term from which to traverse upwards / category from which to traverse downwards * @param toIgcObject the category from which to traverse downwards / term from which to traverse upwards * (or null if not known) @@ -110,6 +113,7 @@ public List getProxyOneAssetFromAsset(Reference term, IGCRestClient i @Override public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, List relationships, + ObjectCache cache, Reference fromIgcObject, Reference toIgcObject, int fromRelationshipElement, @@ -124,7 +128,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit igcomrsRepositoryConnector.getRepositoryName(), "TermAnchor"); - if (GlossaryMapper.isGlossary(igcRestClient, fromIgcObject)) { + if (GlossaryMapper.isGlossary(igcRestClient, cache, fromIgcObject)) { IGCSearchConditionSet conditionSet = new IGCSearchConditionSet(); if (toIgcObject == null) { @@ -175,6 +179,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit igcomrsRepositoryConnector, TermAnchorMapper.getInstance(null), relationshipDef, + cache, fromIgcObject, term, "terms", @@ -193,7 +198,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit } else if (assetType.equals("term")) { // We are at a child term, so we need to get the ultimate root-level category - Identity catIdentity = fromIgcObject.getIdentity(igcRestClient); + Identity catIdentity = fromIgcObject.getIdentity(igcRestClient, cache); Identity rootIdentity = catIdentity.getUltimateParentIdentity(); Reference root = igcRestClient.getAssetWithSubsetOfProperties( rootIdentity.getRid(), @@ -206,6 +211,7 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit igcomrsRepositoryConnector, TermAnchorMapper.getInstance(null), relationshipDef, + cache, root, fromIgcObject, "parent_category", @@ -231,18 +237,20 @@ public void addMappedOMRSRelationships(IGCOMRSRepositoryConnector igcomrsReposit * Avoid creating an anchor relationship between the glossary and itself (as a category). * * @param igcomrsRepositoryConnector connection to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @param oneObject the IGC object to consider for inclusion on one end of the relationship * @param otherObject the IGC object to consider for inclusion on the other end of the relationship * @return boolean */ @Override public boolean includeRelationshipForIgcObjects(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, + ObjectCache cache, Reference oneObject, Reference otherObject) { log.debug("Considering inclusion of objects: {} ({}) and {} ({})", oneObject.getName(), oneObject.getType(), otherObject.getName(), otherObject.getType()); IGCRestClient igcRestClient = igcomrsRepositoryConnector.getIGCRestClient(); - return (GlossaryMapper.isGlossary(igcRestClient, oneObject) && otherObject.getType().equals("term")) - || (oneObject.getType().equals("term") && GlossaryMapper.isGlossary(igcRestClient, otherObject)); + return (GlossaryMapper.isGlossary(igcRestClient, cache, oneObject) && otherObject.getType().equals("term")) + || (oneObject.getType().equals("term") && GlossaryMapper.isGlossary(igcRestClient, cache, otherObject)); } } diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/TermCategorizationMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/TermCategorizationMapper.java index f5f97692..87f5d0c4 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/TermCategorizationMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mapping/relationships/TermCategorizationMapper.java @@ -4,6 +4,7 @@ import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCVersionEnum; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; import org.odpi.egeria.connectors.ibm.igc.repositoryconnector.IGCOMRSRepositoryConnector; import org.odpi.egeria.connectors.ibm.igc.repositoryconnector.mapping.attributes.TermRelationshipStatusMapper; @@ -46,15 +47,17 @@ protected TermCategorizationMapper() { * a relationship for it. * * @param igcomrsRepositoryConnector connection to the IGC environment + * @param cache a cache of information that may already have been retrieved about the provided object * @param oneObject the IGC object to consider for inclusion on one end of the relationship * @param otherObject the IGC object to consider for inclusion on the other end of the relationship * @return boolean */ @Override public boolean includeRelationshipForIgcObjects(IGCOMRSRepositoryConnector igcomrsRepositoryConnector, + ObjectCache cache, Reference oneObject, Reference otherObject) { - return CategoryHierarchyLinkMapper.isCategoryRelationship(igcomrsRepositoryConnector, oneObject, otherObject); + return CategoryHierarchyLinkMapper.isCategoryRelationship(igcomrsRepositoryConnector, cache, oneObject, otherObject); } } diff --git a/igc-adapter/src/test/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/ConnectorTest.java b/igc-adapter/src/test/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/ConnectorTest.java index 2970c1dc..78e97434 100644 --- a/igc-adapter/src/test/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/ConnectorTest.java +++ b/igc-adapter/src/test/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/ConnectorTest.java @@ -3,6 +3,7 @@ package org.odpi.egeria.connectors.ibm.igc.repositoryconnector; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.Note; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.Term; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.ItemList; @@ -763,6 +764,8 @@ public void testGlossaryRelationships() { String expectedProxyOneQN = "gen!GL@(category)=Coco Pharmaceuticals"; + ObjectCache cache = new ObjectCache(); + List relationshipExpectations = new ArrayList<>(); relationshipExpectations.add( new RelationshipExpectation(0, 22, @@ -812,20 +815,20 @@ public void testGlossaryRelationships() { glossary.setContext(Collections.emptyList()); try { CategoryAnchorMapper mapper = CategoryAnchorMapper.getInstance(igcomrsRepositoryConnector.getIGCVersion()); - List proxyOnes = mapper.getProxyOneAssetFromAsset(category, igcomrsRepositoryConnector.getIGCRestClient()); + List proxyOnes = mapper.getProxyOneAssetFromAsset(category, igcomrsRepositoryConnector.getIGCRestClient(), cache); assertEquals(proxyOnes.size(), 1); assertEquals(proxyOnes.get(0).getName(), "TestGlossary"); - assertTrue(mapper.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, category, proxyOnes.get(0))); + assertTrue(mapper.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, cache, category, proxyOnes.get(0))); - proxyOnes = mapper.getProxyOneAssetFromAsset(glossary, igcomrsRepositoryConnector.getIGCRestClient()); + proxyOnes = mapper.getProxyOneAssetFromAsset(glossary, igcomrsRepositoryConnector.getIGCRestClient(), cache); assertEquals(proxyOnes.size(), 1); assertEquals(proxyOnes.get(0).getName(), "TestGlossary"); - assertTrue(mapper.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, proxyOnes.get(0), category)); + assertTrue(mapper.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, cache, proxyOnes.get(0), category)); - proxyOnes = mapper.getProxyOneAssetFromAsset(term, igcomrsRepositoryConnector.getIGCRestClient()); + proxyOnes = mapper.getProxyOneAssetFromAsset(term, igcomrsRepositoryConnector.getIGCRestClient(), cache); assertEquals(proxyOnes.size(), 1); assertEquals(proxyOnes.get(0).getName(), "TestTerm"); - assertFalse(mapper.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, proxyOnes.get(0), glossary)); + assertFalse(mapper.includeRelationshipForIgcObjects(igcomrsRepositoryConnector, cache, proxyOnes.get(0), glossary)); } catch (Exception e) { log.error("Hit unexpected exception.", e); assertNull(e); @@ -1284,6 +1287,8 @@ public void testGetGlossaryTermNoteLogRelationships() { String expectedProxyForNoteLog = "gen!NL@(category)=Default Glossary::(term)=TestTerm"; String expectedProxyForAsset = "(category)=Default Glossary::(term)=TestTerm"; + ObjectCache cache = new ObjectCache(); + List relationshipExpectations = new ArrayList<>(); relationshipExpectations.add( new RelationshipExpectation(0, 1, @@ -1314,6 +1319,7 @@ public void testGetGlossaryTermNoteLogRelationships() { AttachedNoteLogEntryMapper mapper = AttachedNoteLogEntryMapper.getInstance(null); mapper.addMappedOMRSRelationships(igcomrsRepositoryConnector, relationships, + cache, term, null, 0, @@ -1325,6 +1331,7 @@ public void testGetGlossaryTermNoteLogRelationships() { relationships = new ArrayList<>(); mapper.addMappedOMRSRelationships(igcomrsRepositoryConnector, relationships, + cache, term, note, 0, @@ -1336,6 +1343,7 @@ public void testGetGlossaryTermNoteLogRelationships() { relationships = new ArrayList<>(); mapper.addMappedOMRSRelationships(igcomrsRepositoryConnector, relationships, + cache, note, null, 0, @@ -1347,6 +1355,7 @@ public void testGetGlossaryTermNoteLogRelationships() { relationships = new ArrayList<>(); mapper.addMappedOMRSRelationships(igcomrsRepositoryConnector, relationships, + cache, note, term, 0, @@ -1617,6 +1626,8 @@ public void testEndpointRelationships() { MockConstants.HOST_QN, null) ); + ObjectCache cache = new ObjectCache(); + testRelationshipsForEntity( "host", "Endpoint", @@ -1653,18 +1664,18 @@ public void testEndpointRelationships() { Reference connector = new Reference("DB2Connector", "connector", "b1c497ce.54ec142d.001mtr38f.q8hjqk4.spumq8.k1bt587cologck6u9tf8q"); Reference dataConnection = new Reference("IADB", "data_connection", "b1c497ce.8e4c0a48.001mtr3so.6k54588.marlmn.hvquoercv3ji5gdi2rslf"); ConnectionEndpointMapper mapper = ConnectionEndpointMapper.getInstance(igcomrsRepositoryConnector.getIGCVersion()); - List proxyOnes = mapper.getProxyOneAssetFromAsset(connector, igcomrsRepositoryConnector.getIGCRestClient()); + List proxyOnes = mapper.getProxyOneAssetFromAsset(connector, igcomrsRepositoryConnector.getIGCRestClient(), cache); assertEquals(proxyOnes.size(), 1); assertEquals(proxyOnes.get(0).getName(), "INFOSVR"); - proxyOnes = mapper.getProxyOneAssetFromAsset(dataConnection, igcomrsRepositoryConnector.getIGCRestClient()); + proxyOnes = mapper.getProxyOneAssetFromAsset(dataConnection, igcomrsRepositoryConnector.getIGCRestClient(), cache); assertEquals(proxyOnes.size(), 1); assertEquals(proxyOnes.get(0).getName(), "IADB"); - List proxyTwos = mapper.getProxyTwoAssetFromAsset(connector, igcomrsRepositoryConnector.getIGCRestClient()); + List proxyTwos = mapper.getProxyTwoAssetFromAsset(connector, igcomrsRepositoryConnector.getIGCRestClient(), cache); assertEquals(proxyTwos.size(), 6); - proxyTwos = mapper.getProxyTwoAssetFromAsset(dataConnection, igcomrsRepositoryConnector.getIGCRestClient()); + proxyTwos = mapper.getProxyTwoAssetFromAsset(dataConnection, igcomrsRepositoryConnector.getIGCRestClient(), cache); assertEquals(proxyTwos.size(), 1); assertEquals(proxyTwos.get(0).getName(), "IADB"); diff --git a/igc-clientlibrary/src/main/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/IGCRestClient.java b/igc-clientlibrary/src/main/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/IGCRestClient.java index 397168c0..1b41f81f 100644 --- a/igc-clientlibrary/src/main/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/IGCRestClient.java +++ b/igc-clientlibrary/src/main/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/IGCRestClient.java @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.errors.IGCConnectivityException; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.errors.IGCIOException; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.errors.IGCParsingException; @@ -1439,12 +1440,13 @@ public Object getPropertyByName(Reference object, String property) { * Ensures that the modification details of the asset are populated (takes no action if already populated or * the asset does not support them). * - * @param object the IGC object for which to populate modification details * @param the type of IGC object (minimally a Reference) + * @param object the IGC object for which to populate modification details + * @param cache a cache of information that may already have been retrieved about the provided object * @return T - the IGC object with its _context and modification details populated */ - public T getModificationDetails(T object) { - return getAssetContext(object, true); + public T getModificationDetails(T object, ObjectCache cache) { + return getAssetContext(object, true, cache); } /** @@ -1453,37 +1455,44 @@ public T getModificationDetails(T object) { * Will force retrieval of modification details even if _context is populated if 'bPopulateModDetails' is true * and no modification details appear to be populated. (Takes no action otherwise, just returns object as-is.) * + * @param the type of IGC object (minimally a Reference) * @param object the IGC object for which to populate the context (and modification details) * @param bPopulateModDetails true to force modification detail retrieval, false otherwise - * @param the type of IGC object (minimally a Reference) + * @param cache a cache of information that may already have been retrieved about the provided object * @return T - the IGC object with its _context and modification details populated */ @SuppressWarnings("unchecked") - private T getAssetContext(T object, boolean bPopulateModDetails) { + private T getAssetContext(T object, boolean bPopulateModDetails, ObjectCache cache) { T populated = object; if (object != null) { - boolean bHasModificationDetails = hasModificationDetails(object.getType()); + String rid = object.getId(); + Reference fromCache = cache.get(rid); + if (fromCache == null) { + boolean bHasModificationDetails = hasModificationDetails(object.getType()); - // Only bother retrieving the context if the identity isn't already present - if ( (!object.isIdentityPopulated() && (object.getContext() == null || object.getContext().isEmpty())) - || (bHasModificationDetails && !object.areModificationDetailsPopulated() && bPopulateModDetails)) { + // Only bother retrieving the context if the identity isn't already present + if ((!object.isIdentityPopulated() && (object.getContext() == null || object.getContext().isEmpty())) + || (bHasModificationDetails && !object.areModificationDetailsPopulated() && bPopulateModDetails)) { - log.debug("Context and / or modification details are empty, populating..."); + log.debug("Context and / or modification details are empty, and not found in cache; populating..."); - String rid = object.getId(); - String assetType = object.getType(); - if (object.isVirtualAsset() || IGCRestConstants.getTypesThatCannotBeSearched().contains(assetType)) { - populated = (T) getAssetById(rid); - } else { - List properties = new ArrayList<>(); - if (bHasModificationDetails) { - properties.addAll(IGCRestConstants.getModificationProperties()); + String assetType = object.getType(); + if (object.isVirtualAsset() || IGCRestConstants.getTypesThatCannotBeSearched().contains(assetType)) { + populated = (T) getAssetById(rid); + } else { + List properties = new ArrayList<>(); + if (bHasModificationDetails) { + properties.addAll(IGCRestConstants.getModificationProperties()); + } + populated = getAssetWithSubsetOfProperties(rid, assetType, properties, 2); } - populated = getAssetWithSubsetOfProperties(rid, assetType, properties, 2); - } + cache.add(populated); + } + } else { + populated = (T) fromCache; } } diff --git a/igc-clientlibrary/src/main/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/cache/ObjectCache.java b/igc-clientlibrary/src/main/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/cache/ObjectCache.java new file mode 100644 index 00000000..899d5098 --- /dev/null +++ b/igc-clientlibrary/src/main/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/cache/ObjectCache.java @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache; + +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.common.Reference; + +import java.util.HashMap; +import java.util.Map; + +/** + * Provides a general mechanism to cache IGC objects temporarily, to avoid the need to repeatedly retrieve them and + * incur the penalties of calling the REST API multiple times to retrieve the same information. + */ +public class ObjectCache { + + private Map cache = new HashMap<>(); + + /** + * Add the provided entry into the cache. + * @param entry to add + */ + public void add(Reference entry) { + cache.put(entry.getId(), entry); + } + + /** + * Retrieve an entry by its Repository ID (RID) from the cache. + * @param id RID of the entry to retrieve + * @return the IGC object, or null if not in the cache + */ + public Reference get(String id) { + return cache.getOrDefault(id, null); + } + +} diff --git a/igc-clientlibrary/src/main/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/model/common/Reference.java b/igc-clientlibrary/src/main/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/model/common/Reference.java index c903d7fe..9b227edb 100644 --- a/igc-clientlibrary/src/main/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/model/common/Reference.java +++ b/igc-clientlibrary/src/main/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/model/common/Reference.java @@ -12,6 +12,7 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; import com.fasterxml.jackson.annotation.JsonProperty; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.IGCRestClient; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.*; import java.util.Date; @@ -543,15 +544,16 @@ public boolean isVirtualAsset() { * Retrieves the semantic identity of the asset. * * @param igcrest a REST API connection to use in confirming the identity of the asset + * @param cache a cache of information that may already have been retrieved about the provided object * @return Identity */ @JsonIgnore - public Identity getIdentity(IGCRestClient igcrest) { + public Identity getIdentity(IGCRestClient igcrest, ObjectCache cache) { if (!isIdentityPopulated()) { // If the _context is null, it is not populated, while if it is empty it has been populated but there // simply is no context for this object if (getContext() == null) { - Reference assetWithCtx = igcrest.getModificationDetails(this); + Reference assetWithCtx = igcrest.getModificationDetails(this, cache); setContext(assetWithCtx.getContext()); setCreatedOn(assetWithCtx.getCreatedOn()); setCreatedBy(assetWithCtx.getCreatedBy()); diff --git a/igc-clientlibrary/src/test/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/ClientTest.java b/igc-clientlibrary/src/test/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/ClientTest.java index 31dde723..ea8caf96 100644 --- a/igc-clientlibrary/src/test/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/ClientTest.java +++ b/igc-clientlibrary/src/test/java/org/odpi/egeria/connectors/ibm/igc/clientlibrary/ClientTest.java @@ -2,6 +2,7 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.egeria.connectors.ibm.igc.clientlibrary; +import org.odpi.egeria.connectors.ibm.igc.clientlibrary.cache.ObjectCache; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.errors.IGCConnectivityException; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.errors.IGCParsingException; import org.odpi.egeria.connectors.ibm.igc.clientlibrary.model.base.*; @@ -167,7 +168,7 @@ public void testFullAssetRetrievalAndSerDe() { assertNotNull(category.getModifiedBy()); assertNotNull(category.getModifiedOn()); - Identity identity = category.getIdentity(igcRestClient); + Identity identity = category.getIdentity(igcRestClient, new ObjectCache()); assertNotNull(identity); String fullAsJSON = igcRestClient.getValueAsJSON(category); @@ -189,7 +190,7 @@ public void testFullAssetRetrievalAndSerDe() { // Note that in this case they will not be equal because there is no context on this root-level category, // so a search will always be run and the results with only mod details (and context) returned - Category withModDetails = igcRestClient.getModificationDetails(category); + Category withModDetails = igcRestClient.getModificationDetails(category, new ObjectCache()); assertEquals(withModDetails.getCreatedBy(), "Administrator IIS"); assertNotNull(withModDetails.toString()); From 126c10543d043b8d5e814c1552ef3782a8381e02 Mon Sep 17 00:00:00 2001 From: Christopher Grote Date: Wed, 5 Aug 2020 10:32:52 +0100 Subject: [PATCH 3/3] Replaces hybrid event mapper config with direct config via admin services / config document to resolve #365 Signed-off-by: Christopher Grote --- README.md | 44 ++++++--------- .../IGCOMRSRepositoryEventMapper.java | 12 +++- .../IGCOMRSMetadataCollection.java | 56 +++++++++---------- .../IGCOMRSRepositoryConnector.java | 24 +------- .../IGCOMRSRepositoryConnectorProvider.java | 2 - .../mocks/MockConnection.java | 1 - 6 files changed, 56 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index a9fd97e3..13c16eaf 100644 --- a/README.md +++ b/README.md @@ -76,30 +76,16 @@ The quick version: ``` 1. In another shell / command-line window, run the following commands to configure Egeria and startup its services -- making sure to replace the hostnames and port numbers with those relevant to your own environment (`localhost:9092` - for your own Kafka bus, `infosvr:59092` with the Information Server-embedded Kafka host and port, `infosvr` with - the hostname of your Information Server domain (services) tier, `9446` with the port number of your Information - Server domain (services) tier, `isadmin` with the username for your Information Server environment, and `isadmin` - with the password for your Information Server environment): + for your own Kafka bus, `infosvr` with the hostname of your Information Server domain (services) tier, `9446` with + the port number of your Information Server domain (services) tier, `isadmin` with the username for your Information + Server environment, and `isadmin` with the password for your Information Server environment): ```bash $ curl -k -X POST -H "Content-Type: application/json" --data '{"producer":{"bootstrap.servers":"localhost:9092"},"consumer":{"bootstrap.servers":"localhost:9092"}}' "https://localhost:9443/open-metadata/admin-services/users/admin/servers/myserver/event-bus?connectorProvider=org.odpi.openmetadata.adapters.eventbus.topic.kafka.KafkaOpenMetadataTopicProvider&topicURLRoot=OMRSTopic" $ curl -k -X POST "https://localhost:9443/open-metadata/admin-services/users/admin/servers/myserver/cohorts/mycohort" $ curl -k -X POST -H "Content-Type: application/json" --data '{"class":"Connection","connectorType":{"class":"ConnectorType","connectorProviderClassName":"org.odpi.egeria.connectors.ibm.igc.repositoryconnector.IGCOMRSRepositoryConnectorProvider"},"endpoint":{"class":"Endpoint","address":"infosvr:9446","protocol":"https"},"userId":"isadmin","clearPassword":"isadmin","configurationProperties":{"defaultZones":["default"]}}' "https://localhost:9443/open-metadata/admin-services/users/admin/servers/myserver/local-repository/mode/repository-proxy/connection" - $ curl -k -X POST "https://localhost:9443/open-metadata/admin-services/users/admin/servers/myserver/local-repository/event-mapper-details?connectorProvider=org.odpi.egeria.connectors.ibm.igc.eventmapper.IGCOMRSRepositoryEventMapperProvider&eventSource=infosvr:59092" $ curl -k -X POST "https://localhost:9443/open-metadata/admin-services/users/admin/servers/myserver/instance" ``` -### Enable IGC's events - -To start using the connector, you will need an IGC environment, running either version 11.5 or 11.7 of the software. -(The connector will automatically detect which version as part of its initialization.) You will need to first enable event -notification in your IGC environment: - -1. Navigate to "Administration": !["Administration"](docs/ibm-igc-setup1.png) -1. Navigate to "Event Notification" within the "Setup" heading: !["Event Notification"](docs/ibm-igc-setup2.png) -1. Toggle "Enable" and then "Save and Close": !["Enable" and "Save and Close"](docs/ibm-igc-setup3.png) - -There should not be any need to restart the environment after enabling the event notification. - ### Obtain the connector You can either download the latest released or snapshot version of the connector directly from ODPi, or build the @@ -206,8 +192,7 @@ For example payloads and endpoints, see the [Postman samples](samples). "userId": "{{igc_user}}", "clearPassword": "{{igc_password}}", "configurationProperties": { - "defaultZones": [ "default" ], - "enableEventMapper": false + "defaultZones": [ "default" ] } } ``` @@ -223,17 +208,24 @@ For example payloads and endpoints, see the [Postman samples](samples). You can optionally also provide a list of zone names that will be used as default zones for all Assets retrieved from IGC through the proxy (in the example above this is a single zone called `default`). - - The `enableEventMapper` configuration property can be used to enable the _experimental_ event mapper, which consumes - events that are generated by IGC. By default (when this configuration property is not specified) this is disabled, + + Note that you also need to provide the `connectorProvider` parameter, set to the name of the IGC + connectorProvider class (value as given above). + +1. (Optional and _experimental_) Configure the event mapper for IGC, by POSTing something like the following: + + The _experimental_ event mapper consumes events that are generated by IGC. By default this is disabled, and it should be treated as experimental even when enabled. When enabled, the IGC user credentials provided for the connector must have administrative authority to be able to automatically create the objects used by this experimental capability. - Note that you also need to provide the `connectorProvider` parameter, set to the name of the IGC - connectorProvider class (value as given above). + Before enabling it, you will need to first enable event notification in your IGC environment: + + 1. Navigate to "Administration": !["Administration"](docs/ibm-igc-setup1.png) + 1. Navigate to "Event Notification" within the "Setup" heading: !["Event Notification"](docs/ibm-igc-setup2.png) + 1. Toggle "Enable" and then "Save and Close": !["Enable" and "Save and Close"](docs/ibm-igc-setup3.png) -1. Configure the event mapper for IGC, by POSTing something like the following: + There should not be any need to restart the environment after enabling the event notification. ``` POST https://localhost:9443/open-metadata/admin-services/users/admin/servers/myserver/local-repository/event-mapper-details?connectorProvider=org.odpi.egeria.connectors.ibm.igc.eventmapper.IGCOMRSRepositoryEventMapperProvider&eventSource=my.igc.services.host.com:59092 @@ -245,7 +237,7 @@ For example payloads and endpoints, see the [Postman samples](samples). running on your Unified Governance / Enterprise Search tier, on port `9092`. In both cases the port will need to be network-accessible by the host where you are running Egeria itself for any events to be picked up by Egeria.) -1. The connector and event mapper should now be configured, and you should now be able +1. The connector (and optionally the event mapper) should now be configured, and you should now be able to start the instance by POSTing something like the following: ``` diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/eventmapper/IGCOMRSRepositoryEventMapper.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/eventmapper/IGCOMRSRepositoryEventMapper.java index e9d7dbff..952f9d5b 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/eventmapper/IGCOMRSRepositoryEventMapper.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/eventmapper/IGCOMRSRepositoryEventMapper.java @@ -134,7 +134,17 @@ public void start() throws ConnectorCheckedException { this.metadataCollectionId = igcomrsRepositoryConnector.getMetadataCollectionId(); this.originatorServerName = igcomrsRepositoryConnector.getServerName(); this.originatorServerType = igcomrsRepositoryConnector.getServerType(); - if (igcomrsRepositoryConnector.isEventMapperEnabled()) { + + boolean success = false; + try { + success = igcomrsRepositoryConnector.upsertOMRSBundleZip(); + this.igcRestClient.registerPOJO(OMRSStub.class); + } catch (RepositoryErrorException e) { + raiseConnectorCheckedException(IGCOMRSErrorCode.OMRS_BUNDLE_FAILURE, methodName, e, "upload"); + } + if (!success) { + raiseConnectorCheckedException(IGCOMRSErrorCode.OMRS_BUNDLE_FAILURE, methodName, null, "upload"); + } else { this.igcKafkaConsumer = new IGCKafkaConsumerThread(); igcKafkaConsumer.start(); } diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSMetadataCollection.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSMetadataCollection.java index 573bce67..09a03955 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSMetadataCollection.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSMetadataCollection.java @@ -418,8 +418,9 @@ public void addTypeDef(String userId, TypeDef newTypeDef) throws } } - checkEventMapperIsConfigured(methodName); - eventMapper.sendNewTypeDefEvent(newTypeDef); + if (eventMapper != null) { + eventMapper.sendNewTypeDefEvent(newTypeDef); + } } @@ -486,8 +487,9 @@ public void addAttributeTypeDef(String userId, AttributeTypeDef newAttributeType } - checkEventMapperIsConfigured(methodName); - eventMapper.sendNewAttributeTypeDefEvent(newAttributeTypeDef); + if (eventMapper != null) { + eventMapper.sendNewAttributeTypeDefEvent(newAttributeTypeDef); + } } @@ -662,8 +664,9 @@ public TypeDef updateTypeDef(String userId, TypeDefPatch typeDefPatch) throws } else { log.info("Updating TypeDef '{}' based on patch.", omrsTypeDefName); typeDefStore.addTypeDef(revised); - checkEventMapperIsConfigured(methodName); - eventMapper.sendUpdatedTypeDefEvent(typeDefPatch); + if (eventMapper != null) { + eventMapper.sendUpdatedTypeDefEvent(typeDefPatch); + } } } else { @@ -2115,13 +2118,14 @@ public void refreshEntityReferenceCopy(String userId, /* * Send refresh message */ - checkEventMapperIsConfigured(methodName); - eventMapper.sendRefreshEntityRequest( - typeDefGUID, - typeDefName, - entityGUID, - homeMetadataCollectionId - ); + if (eventMapper != null) { + eventMapper.sendRefreshEntityRequest( + typeDefGUID, + typeDefName, + entityGUID, + homeMetadataCollectionId + ); + } } @@ -2167,13 +2171,14 @@ public void refreshRelationshipReferenceCopy(String userId, /* * Process refresh request */ - checkEventMapperIsConfigured(methodName); - eventMapper.sendRefreshRelationshipRequest( - typeDefGUID, - typeDefName, - relationshipGUID, - homeMetadataCollectionId - ); + if (eventMapper != null) { + eventMapper.sendRefreshRelationshipRequest( + typeDefGUID, + typeDefName, + relationshipGUID, + homeMetadataCollectionId + ); + } } @@ -2207,17 +2212,6 @@ public TypeDef getAnyTypeDefByGUID(String guid) { return typeDefStore.getAnyTypeDefByGUID(guid); } - /** - * Ensure that the event mapper is configured and throw exception if it is not. - * - * @param methodName the method attempting to use the event mapper - */ - private void checkEventMapperIsConfigured(String methodName) throws RepositoryErrorException { - if (eventMapper == null) { - raiseRepositoryErrorException(IGCOMRSErrorCode.EVENT_MAPPER_NOT_INITIALIZED, methodName, repositoryName); - } - } - /** * Retrieve the listing of implemented mappings that should be used for an entity search, including navigating * subtypes when a supertype is the entity type provided. diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSRepositoryConnector.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSRepositoryConnector.java index bd05d64d..83b0e030 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSRepositoryConnector.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSRepositoryConnector.java @@ -23,7 +23,6 @@ public class IGCOMRSRepositoryConnector extends OMRSRepositoryConnector { protected IGCRestClient igcRestClient; protected IGCVersionEnum igcVersion; - protected boolean eventMapperEnabled = false; protected List defaultZones; /** @@ -102,13 +101,6 @@ public void disconnect() { */ public IGCRestClient getIGCRestClient() { return this.igcRestClient; } - /** - * Determine whether the (experimental) event mapper is enabled (true) or not (false). - * - * @return boolean - */ - public boolean isEventMapperEnabled() { return this.eventMapperEnabled; } - /** * Retrieve the list of default zones to apply to assets. * @@ -145,10 +137,6 @@ protected void connectToIGC(String methodName) throws ConnectorCheckedException } } } - Object emEnabled = proxyProperties.get(IGCOMRSRepositoryConnectorProvider.ENABLE_EVENT_MAPPER); - if (emEnabled instanceof Boolean) { - this.eventMapperEnabled = (Boolean) emEnabled; - } } boolean successfulInit = false; @@ -164,16 +152,8 @@ protected void connectToIGC(String methodName) throws ConnectorCheckedException } // Set the version based on the IGC client's auto-determination of the IGC environment's version this.igcVersion = this.igcRestClient.getIgcVersion(); - if (isEventMapperEnabled()) { - boolean success = upsertOMRSBundleZip(); - this.igcRestClient.registerPOJO(OMRSStub.class); - successfulInit = success; - } else { - successfulInit = true; - } + successfulInit = true; } - } catch (RepositoryErrorException e) { - raiseConnectorCheckedException(IGCOMRSErrorCode.OMRS_BUNDLE_FAILURE, methodName, e, address); } catch (Exception e) { raiseConnectorCheckedException(IGCOMRSErrorCode.REST_CLIENT_FAILURE, methodName, e, ""); } @@ -200,7 +180,7 @@ protected void connectToIGC(String methodName) throws ConnectorCheckedException * @return boolean true on success, or if the bundle already exists and false otherwise * @throws RepositoryErrorException on any error upserting the bundle to IGC */ - protected boolean upsertOMRSBundleZip() throws RepositoryErrorException { + public boolean upsertOMRSBundleZip() throws RepositoryErrorException { final String methodName = "upsertOMRSBundleZip"; diff --git a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSRepositoryConnectorProvider.java b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSRepositoryConnectorProvider.java index d10a1be5..118cf90c 100644 --- a/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSRepositoryConnectorProvider.java +++ b/igc-adapter/src/main/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/IGCOMRSRepositoryConnectorProvider.java @@ -32,7 +32,6 @@ public class IGCOMRSRepositoryConnectorProvider extends OMRSRepositoryConnectorP static final String CONNECTOR_TYPE_NAME = "OMRS IGC Repository Connector"; static final String CONNECTOR_TYPE_DESC = "OMRS IGC Repository Connector that processes events from the IBM InfoSphere Information Governance Catalog repository store."; - public static final String ENABLE_EVENT_MAPPER = "enableEventMapper"; public static final String DEFAULT_ZONES = "defaultZones"; /** @@ -53,7 +52,6 @@ public IGCOMRSRepositoryConnectorProvider() { connectorType.setConnectorProviderClassName(this.getClass().getName()); List recognizedConfigurationProperties = new ArrayList<>(); - recognizedConfigurationProperties.add(ENABLE_EVENT_MAPPER); recognizedConfigurationProperties.add(DEFAULT_ZONES); connectorType.setRecognizedConfigurationProperties(recognizedConfigurationProperties); diff --git a/igc-adapter/src/test/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mocks/MockConnection.java b/igc-adapter/src/test/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mocks/MockConnection.java index 332867e6..c0086f1a 100644 --- a/igc-adapter/src/test/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mocks/MockConnection.java +++ b/igc-adapter/src/test/java/org/odpi/egeria/connectors/ibm/igc/repositoryconnector/mocks/MockConnection.java @@ -40,7 +40,6 @@ public MockConnection() { List defaultZones = new ArrayList<>(); defaultZones.add("default"); configProperties.put("defaultZones", defaultZones); - configProperties.put("enableEventMapper", true); setConfigurationProperties(configProperties); }