How to delete contained/referenced concept array and update length when deleting a child

How to delete contained/referenced concept array and update length when deleting a child

book

Article ID: KB0071171

calendar_today

Updated On:

Products Versions
TIBCO BusinessEvents Enterprise Edition -

Description

To delete a child concept and update the array length of the parent concept you need to use below catalog function(s):

For Contained concepts arrays.

This works as a hierarchy where each concept is contained by the concept above it, then when deleting, the instance is deleted along with any other contained instances at lower levels of the containment hierarchy.
Instance.PropertyArray.removeContainedConcept(<PropertyArrayConceptReference>,<childToDelete>);

For Referenced concept arrays.

The concepts are not contained in others, here just a relationship between concepts is defined. So, it is required to delete the child explicitly, as you'll see in the function, you will delete the reference and the referenced concept instance.
PropertyArray.removeConceptReference(<PropertyArrayConceptReference>,<childToRemoveFromArray>);
Instance.deleteInstance(<childToDelete>);

e.g.,
// contained concept array (delete first child in array)
if (cp.cpChild@length>0) {
	Concepts.cpChild c2=cp.cpChild[0];
	Instance.PropertyArray.removeContainedConcept(cp.cpChild,c1);
}

// referenced concept array (remove the first child from array and delete it if necessary)
if (cp.cpChild@length>0) {
	Concepts.cpChildRef c11=cp.cpChildRef[0];
	Instance.PropertyArray.removeConceptReference(cp.cpChildRef,c11);
	Instance.deleteInstance(c11);
}
When trying to delete a contained/referenced concept array child, it is possible you'll see the returned length of the contained concept array is incorrect, this is the expected behavior if you're using just Instance.deleteInstance(child), use the mentioned functions for the correct behavior.
 

Issue/Introduction

This article shows how to delete correctly a child from contained/referenced concept array.

Environment

All

Resolution

Please see above