Hi,

I need to be able to add a relationship to the AtlasRelationshipStore 
where the relationship has been defined in another metadata repository 
(and discovered using OMRS). The relationship therefore has an existing 
(external) unique GUID. For an entity I can use import to add the entity 
whilst maintain the existing GUID. For relationships, the relationship 
store seems to always generate a new GUID, which overwrites the existing 
GUID.

i.e. currently, relationship store does the following:

private AtlasEdge createRelationshipEdge(...) {
    ...
    AtlasEdge     ret               = graphHelper
.getOrCreateEdge(fromVertex, toVertex, relationshipLabel);
    ...
    // map additional properties to relationship edge
    if (ret != null) {
        final String guid = UUID.randomUUID().toString();
        ...
        AtlasGraphUtilsV1.setProperty(ret, Constants.
RELATIONSHIP_GUID_PROPERTY_KEY, guid);
              ...
 

I could add a condition in the relationship store - to test whether there 
is an existing (assigned, non-negative) GUID and if so to use that rather 
than generating a new GUID.

i.e. could I change relationship store to do the following:

private AtlasEdge createRelationshipEdge(...) {
    ...
    AtlasEdge     ret               = graphHelper
.getOrCreateEdge(fromVertex, toVertex, relationshipLabel);
    ...
    // map additional properties to relationship edge
    if (ret != null) {
        String relationshipGuid = relationship.getGuid();
        final String guid = AtlasTypeUtil.isAssignedGuid(relationshipGuid) 
? relationshipGuid : UUID.randomUUID().toString();
              ...
 

However, I wanted to check first whether there is an import capability for 
relationships (or a plan to add it) as that may be a better way to achieve 
it.

If the above looks a sensible approach I will raise a JIRA and create a 
patch.

Best regards,
  Graham

Graham Wallis
IBM Analytics Emerging Technology Center
Internet: [email protected] 
IBM Laboratories, Hursley Park, Hursley, Hampshire SO21 2JN
Tel: +44-1962-815356    Tie: 7-245356

Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

Reply via email to