How to refresh relationships on import (how to replace an old set of existing relationships with a new import set) using DELETEALL?

How to refresh relationships on import (how to replace an old set of existing relationships with a new import set) using DELETEALL?

book

Article ID: KB0094262

calendar_today

Updated On:

Products Versions
TIBCO Collaborative Information Manager -
Not Applicable -

Description

Resolution:
Description:
============
DELETEALL produces unexpected result when importing record relationships.

Environment:
============
TIBCO Collaborative Information Manager (CIM) 8.1.0


Symptoms:
=========
Following an import operation, new and existing relationships are not, or no longer, present in the Repositories into which the records are bing imported.

Cause:
======
On first inspection, it appears that all that has to be done to read in a new set of relationships to replace an existing one is to include in the data source a CONTAINS column in between the data for the Parent Record and that for the Child Record as follows:

PARENTID    PARENTIDEXT     CONTAINS                       CHILDID     CHILDIDEXT
P001            P001EXT             0:0::1234:DELETEALL     C001         C001EXT
P002            P002EXT             0:0::1234:DELETEALL     C002         C002EXT

Map the resultant DataSource attributes to the relevant repository fields for PARENT and CHILD, save and import.

Unfortunately, this does not (always) work.  Specifically, the behaviour of DELETEALL is a little different than most people expect: DELETEALL will ONLY delete a link if the CHILD is not mentioned elsewhere in the Datasource, otherwise it will leave the link in place.

Resolution:
===========
The correct use of DELETEALL is to first remove all existing links from PARENT to CHILD for the records to be changed using one import map covering just the PARENT and then to put the new links in using another containing the new PARENT - CHILD links.

To understand this, suppose you have a relation REL between two repositories, PARENT and CHILD:

PARENT -----REL---->  CHILD

Now, suppose the following actual relationships already exist:

PARENT RECORD         RELATION             CHILD RECORD
P001                             ---------->              C001
P002                             ---------->              C002
P003                             ---------->              C003
P004                             ---------->              C004
P005                             ---------->              C005
                                                                  C006
and you go to import the following relationships, using DELETEALL:

P003                             ---------->              C002
P005                             ---------->              C006

In this case, the following relationships WILL BE deleted as the children are orphaned by the DELETEALL:

P003                             ---------->              C003
P005                             ---------->              C005

This gives the expected result:

PARENT RECORD         RELATION             CHILD RECORD
P001                             ---------->              C001
P002                             --------\
                                                 ->              C002
P003                             --------/
P004                             ---------->              C004
P005                             ---------->              C006

Suppose, however, you now import the following relationships using DELETEALL:

P002                             ---------->              C002
P003                             ---------->              C004

In this case, the following relationship WILL NOT BE deleted:

P003                             ---------->              C002

as C002 is not orphaned, even though it is from the perspective of P003, so the link remains:

PARENT RECORD         RELATION             CHILD RECORD
P001                             ---------->              C001
P002                             --------\
                                                  ->             C002
P003                             =====<
                                                  ->             C004
P004                             -------/
P005                             ---------->              C006

So, P003 ends up being related to C002 and C004.

To avoid this situation first "import" just the PARENT records to be changed using DELETEALL:

P002 with DELETEALL
P003 with DELETEALL

This gives you:

P001                             ---------->              C001
P002                                                          C002
P003
P004                             ---------->              C004
P005                             ---------->              C006

Then, in a separate import without DELETEALL, import the NEW PARENT - CHILD relations:

P002                             ---------->              C002
P003                             ---------->              C004

This gives you:

PARENT RECORD         RELATION             CHILD RECORD
P001                             ---------->              C001
P002                             ---------->              C002
P003                             -------\
                                                  ->             C004
P004                             -------/
P005                             ---------->              C006

This is how to correctly use DELETEALL. Note that DELETEALL will only delete the immediate children of a parent, not its grand children or great grand children (or any relations beyond that). To do this requires writing rules to first recurse down the hierarchy, applying DELETEALL only upon exit (back upward) from each level in the hierarchy.

Issue/Introduction

How to refresh relationships on import (how to replace an old set of existing relationships with a new import set) using DELETEALL?