Interface ChildrenIdCardGetterInterface

The ChildrenIdCardGetterInterface interface is used to retrieve information about the children of a part instance (and not a geometric instance id), such as the metadata of the children parts, link, the list of children attached document, ....

The metadata documents and general information about the children can be retrieved by knowing the part instance id of the parent to retrieve. Such documents are usually requested after an idcard request.

The ChildrenIdCardGetterInterface interfaces are created through the createChildrenIdCardGetter method.

/** 
* Sample to illustrate the use of an ChildrenIdCardGetterInterface from a `part instance id`, to get the brothers of a part instance.
*/
import {
VisibilityContextInterface, IdCardGetterInterface, IdCardGetterInterfaceSignal, ChildrenIdCardGetterInterface,
ChildrenIdCardGetterInterfaceSignal, PartInstanceInfoInterface, InfiniteEvent, ChildrenPartInstanceInfoInterface, DataSessionInterface,
} from 'generated/documentation/appinfiniteapi';
// the `part instances` are retrieved by a picking for example

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// the `part instance id` to get information from (get its brothers)
let lPartInstanceId : number;
// the current filtering context has been created previously
let lVisibilityContext : VisibilityContextInterface;

// what to do when the id card retrieval is over
let onIdCardReady : (pEvent, _pCallbackData) => void;

// what to do when the children id card retrieval is over
let onChildrenIdCardReady : (pEvent, _pCallbackData) => void;

// id card getter interface creation
const lIdCardGetterInterface : IdCardGetterInterface = lDataSession.createIdCardGetter();
// children id card getter interface creation
const lChildrenIdCardGetterInterface : ChildrenIdCardGetterInterface = lDataSession.createChildrenIdCardGetter();

// connect the IDCardReady signal to the handling of the metadata of the `part instance` and its genealogy
lIdCardGetterInterface.addEventListener(IdCardGetterInterfaceSignal.IdCardReady, onIdCardReady);

// connect the GeometricInstanceConverterReady signal to the id card retrieval
lChildrenIdCardGetterInterface.addEventListener(ChildrenIdCardGetterInterfaceSignal.ChildrenIdCardReady, onChildrenIdCardReady);

// trigger the idcard retrieval
lIdCardGetterInterface.retrieveIdCard(lPartInstanceId, lVisibilityContext);

// onIdCardReady will be called when data is available
onIdCardReady = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
if (lIdCardGetterInterface.getLastError().length !== 0) {
// do nothing in case of error
// perhaps some GUI code ?
return;
}
const lPartInstanceInfos : Array<PartInstanceInfoInterface> | undefined = lIdCardGetterInterface.getPartInstanceInfos();
if (!lPartInstanceInfos || lPartInstanceInfos.length !== 1)
{
// no data (isCancelled ?)
return;
}
// we required only one `part instance`, as such, only one result should be retrieved
// iterate over the instantiation chain, but take the first chain since one `part instance` retrieved
const lCurrentChain : PartInstanceInfoInterface = lPartInstanceInfos[0];

// number of items
const lNbAncestors : number = lCurrentChain.getAncestors().length;

// the parent offset is the one before last
const lParentOffset : number = lNbAncestors - 2;
if (lParentOffset < 0)
{
console.log(lPartInstanceId + ' is a leaf instance, exiting');
return;
}
const lParentInstanceId : number = lCurrentChain.getAncestors()[lParentOffset];
lChildrenIdCardGetterInterface.retrieveChildrenIdCard(lParentInstanceId, lVisibilityContext);
}

// onChildrenIdCardReady will be called when data is available
onChildrenIdCardReady = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
if (lChildrenIdCardGetterInterface.getLastError().length !== 0) {
// do nothing in case of error
// perhaps some GUI code ?
}
const lPartInstanceInfos : Array<ChildrenPartInstanceInfoInterface> | undefined = lChildrenIdCardGetterInterface.getPartInstanceInfos();
if (!lPartInstanceInfos || lPartInstanceInfos.length !== 1)
{
// no data (isCancelled ?)
return;
}
// we required only one `part instance`, as such, only one result should be retrieved
// iterate over the instantiation chain, but take the first chain since one `part instance` retrieved
const lChildren : ChildrenPartInstanceInfoInterface = lPartInstanceInfos[0];

// number of children
// const lNbChildren : number = lChildren.getChildren().length;
// we should have the part instance in the list of children
const lIndexOfMe : number = lChildren.getChildren().indexOf(lPartInstanceId);
if (lIndexOfMe < 0)
{
console.log('something really weird has happen, I am not in the list of children of my parent, am I the root ?');
return;
}

// we get the `part` metadata of me (but should do something else even more interesting)
const lPartMetadata : Object = lChildren.getChildrenIdCard().partmd[lIndexOfMe];
// some fancy output
console.log(JSON.stringify(lPartMetadata));
}

The list of signals the ChildrenIdCardGetterInterface may trigger is available in the [ChildrenIdCardGetterInterfaceSignal](../enums/ChildrenIdCardGetterInterfaceSignal.html) enumeration.

The metadata retrieval procedure is triggered through the retrieveChildrenIdCard methods. The result is not available right away, but the event ChildrenIdCardReady is triggered when the result of the ChildrenIdCardGetterInterface is available. The result is available through the [getPartInstanceInfos]] function.

Warning : there may be cases when the getPartInstanceInfos is not available such as when the ChildrenIdCardGetterInterface is updating, i.e. when isRunning returns true, or when the ChildrenIdCardGetterInterface has been cancelled, i.e. when isCancelled returns true.

An ChildrenIdCardGetterInterface may be interrupted (cancelled) when the ChildrenIdCardGetterInterface is updating and cancel is called. In such cases, the ChildrenIdCardCancelled signal is fired, and shortly after, ChildrenIdCardReady signal is fired, but getPartInstanceInfos will return undefined. Just call retrieveChildrenIdCard with another (or the same) part instance ids to trigger a new retrieval.

If you call multiple times retrieveChildrenIdCard before receiving the ChildrenIdCardReady, only one ChildrenIdCardReady will be sent with the content of the last call to retrieveChildrenIdCard.

The developer may process the results of an id card retrieval with the following code :

/** 
* Sample to illustrate the use of an ChildrenIdCardGetterInterface with the parsing of
* PartInstanceInfoInterface to display some information about a part instance.
*/
import {
VisibilityContextInterface, ChildrenIdCardGetterInterface, ChildrenIdCardGetterInterfaceSignal,
InfiniteEvent, ChildrenPartInstanceInfoInterface, PartInstanceInfoStatusFlag, DataSessionInterface
} from 'generated/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// created previously
let lVisibilityContext : VisibilityContextInterface;
// the `part instance id` to get
let lPartInstanceId : number;
// what to do when we have retrieved id card information ?
let onChildrenIdCardReady : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void;

// create an ChildrenIdCardGetter
const lChildrenIdCardGetterInterface : ChildrenIdCardGetterInterface = lDataSession.createChildrenIdCardGetter();
// what to do when result is ready ?
lChildrenIdCardGetterInterface.addEventListener(ChildrenIdCardGetterInterfaceSignal.ChildrenIdCardReady, onChildrenIdCardReady);

// onChildrenIdCardReady will be called when data is available
onChildrenIdCardReady = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
if (lChildrenIdCardGetterInterface.getLastError().length !== 0) {
// do nothing in case of error
// perhaps some GUI code ?
}
const lPartInstanceInfos : Array<ChildrenPartInstanceInfoInterface> | undefined = lChildrenIdCardGetterInterface.getPartInstanceInfos();
if (!lPartInstanceInfos || lPartInstanceInfos.length !== 1)
{
// no data (isCancelled ?)
return;
}
// we required only one `part instance`, as such, only one result should be retrieved
// iterate over the instantiation chain, but take the first chain since one `part instance` retrieved
const lCurrentChildren : ChildrenPartInstanceInfoInterface = lPartInstanceInfos[0];

// number of items
const lNbChildren : number = lCurrentChildren.getChildren().length;
if (lNbChildren <= 0)
{
console.log('this part instance is a leaf');
return;
}
// take the last child
const lChildInstanceOffset : number = lNbChildren - 1;
// we get the `part` metadata of the last child of the `part instance`
const lPartMetadata : Object = lCurrentChildren.getChildrenIdCard().partmd[lChildInstanceOffset];
// some fancy output
console.log(JSON.stringify(lPartMetadata));

// get the flags in order to get information about the `part instance`
const lFlags : number = lCurrentChildren.getChildrenStatusFlags()[lChildInstanceOffset];
if ((lFlags & PartInstanceInfoStatusFlag.PI_Displayable) !== 0)
{
console.log('the last child of the part instance is displayable')
}
}

// trigger the retrieval
lChildrenIdCardGetterInterface.retrieveChildrenIdCard(lPartInstanceId, lVisibilityContext);

or asynchronously :
/** 
* Sample to illustrate the asynchronous use of an ChildrenIdCardGetterInterface with the parsing of
* PartInstanceInfoInterface to display some information about a part instance.
*/
import {
VisibilityContextInterface, ChildrenIdCardGetterInterface, AsyncChildrenPartInstanceInfoResult,
ChildrenPartInstanceInfoInterface, PartInstanceInfoStatusFlag, AsyncResultReason, DataSessionInterface
} from 'generated/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// created previously
let lVisibilityContext : VisibilityContextInterface;
// the `part instance id` to get
let lPartInstanceId : number;

// create an ChildrenIdCardGetter
const lChildrenIdCardGetterInterface : ChildrenIdCardGetterInterface = lDataSession.createChildrenIdCardGetter();

const retrieveIdCard = async () : Promise<any> =>
{
// trigger the retrieval
const lResult : AsyncChildrenPartInstanceInfoResult = await lChildrenIdCardGetterInterface.asyncRetrieveChildrenIdCard(lPartInstanceId, lVisibilityContext);

if (lResult.reason !== AsyncResultReason.ARR_Success || lResult.value === undefined)
{
// do nothing in case of error
// perhaps some GUI code ?
return;
}
const lPartInstanceInfos : Array<ChildrenPartInstanceInfoInterface> = lResult.value;
// we required only one `part instance`, as such, only one result should be retrieved
// iterate over the instantiation chain, but take the first chain since one `part instance` retrieved
const lCurrentChildren : ChildrenPartInstanceInfoInterface = lPartInstanceInfos[0];

// number of items
const lNbChildren : number = lCurrentChildren.getChildren().length;
if (lNbChildren <= 0)
{
console.log('this part instance is a leaf');
return;
}
// take the last child
const lChildInstanceOffset : number = lNbChildren - 1;
// we get the `part` metadata of the last child of the `part instance`
const lPartMetadata : Object = lCurrentChildren.getChildrenIdCard().partmd[lChildInstanceOffset];
// some fancy output
console.log(JSON.stringify(lPartMetadata));

// get the flags in order to get information about the `part instance`
const lFlags : number = lCurrentChildren.getChildrenStatusFlags()[lChildInstanceOffset];
if ((lFlags & PartInstanceInfoStatusFlag.PI_Displayable) !== 0)
{
console.log('the last child of the part instance is displayable')
}
}

retrieveIdCard();

Please make sure the destination browser supports promises before using async calls.
Data Retrievers

See

Hierarchy

Methods

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal. It is possible to add an object that will be included in the callback to avoid creating too many closures.

    Returns

    The id of the inserted callback (actually an UUID).

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.
    • pObject: undefined | Object
      in
      The optional object the callback will be called with when the given event fires.

    Returns string

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal.

    Returns

    The id of the inserted callback (actually an UUID).

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.

    Returns string

  • Asynchronously gets the information about the children of the specified part instance ids.

    Returns a promise.

    If pFilteringContext is modified during the execution, then the call is cancelled (see cancel).

    Please note that in case of multiple promises running at the same time on the same ChildrenIdCardGetterInterface, the first promises will be signalled as cancelled, the last as ok, but all calls to getPartInstanceInfos after awaiting will return the same value.

    Returns

    A promise. The promise is resolved with the reason (success, cancelled, disposed, bad input). In case of success, the promise is resolved with an Array.

    Parameters

    • pPartInstanceIds: number[] | Uint32Array
      in
      The list of part instance ids to fetch metadata from.
    • pFilteringContext: VisibilityContextInterface
      in
      The current filtering context for configured metadata.

    Returns Promise<AsyncChildrenPartInstanceInfoResult>

  • Asynchronously gets the information about the children of the specified part instance id.

    Returns a promise.

    Please note that in case of multiple promises running at the same time on the same ChildrenIdCardGetterInterface, the first promises will be signalled as cancelled, the last as ok, but all calls to getPartInstanceInfos after awaiting will return the same value.

    If pFilteringContext is modified during the execution, then the call is cancelled (see cancel).

    Returns

    A promise. The promise is resolved with the reason (success, cancelled, disposed, bad input). In case of success, the promise is resolved with an Array.

    Parameters

    • pPartInstanceId: number
      in
      The part instance id to fetch metadata from.
    • pFilteringContext: VisibilityContextInterface
      in
      The current filtering context for configured metadata.

    Returns Promise<AsyncChildrenPartInstanceInfoResult>

  • Cancels the computation of the metadata retrieving process (if any).

    A ChildrenIdCardCancelled signal is emitted if the ChildrenIdCardGetterInterface is retrieving data.

    Returns

    true if the DocumentIdConverterInterface was running, else false.

    See

    IdCardCancelled

    Returns boolean

  • Gets the last error returned by the update of the ChildrenIdCardGetterInterface.

    Returns

    The last error message (if any, or an empty string if no error occurred).

    Returns string

  • Gets the result of the metadata request.

    The metadata content is returned if the ChildrenIdCardGetterInterface has finished computing. Use addEventListener on the event ChildrenIdCardReady to know when the ChildrenIdCardGetterInterface is ready.

    DO NOT modify this data in place, this results in undefined behavior.

    Returns

    const
    the metadata of the requested part instance ids and their genealogy (the size of the array is the number of part instance ids requested (see [retrieveChildrenIdCard](ChildrenIdCardGetterInterface.html#retrieveChildrenIdCard))), or undefined if the ChildrenIdCardGetterInterface is computing or if the ChildrenIdCardGetterInterface is in error or cancelled.

    See

    Returns undefined | ChildrenPartInstanceInfoInterface[]

  • Tells if the EventDispatcher has such a callback registered for the given event type.

    Returns

    true if such a listener is installed for the given type of event.

    Parameters

    • pType: string
      in
      The type of the event to test.
    • pListener: tListenerCallback
      in
      The listener function that gets tested.

    Returns boolean

  • Tells if the ChildrenIdCardGetterInterface has been cancelled.

    This is generally the case after calling cancel when the ChildrenIdCardGetterInterface is retrieving data.

    Returns

    true if the ChildrenIdCardGetterInterface is cancelled.

    Returns boolean

  • Tells if the ChildrenIdCardGetterInterface is updating.

    This is the case after calling retrieveChildrenIdCard.

    Returns

    true if the ChildrenIdCardGetterInterface is updating.

    Returns boolean

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    • pObject: undefined | Object

      The listener object that was used when addEventListener was called.

    Returns boolean

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    Returns boolean

  • Removes a listener by its id.

    If no such listener is found, then the function returns false and does nothing. You must use the return value of addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pId: string
      in
      The id returned by the call to [addEventListener](ChildrenIdCardGetterInterface.html#addEventListener) that you want to remove.

    Returns boolean

  • Gets the information about the children of the specified part instance ids.

    The ChildrenIdCardReady signal is fired when the part instance ids metadata result is ready.

    Returns true if the metadata procedure retrieval is started. If not, just call getLastError to get the reason why the procedure failed. For instance, pPartInstanceIds is considered as invalid input if it is empty or at least one element is out of range [1 : 2^31-1].

    If pFilteringContext is modified during the execution, then the call is cancelled (see cancel).

    Returns

    true if the retrieval procedure has begun.

    See

    ChildrenIdCardGetterInterfaceSignal

    Parameters

    • pPartInstanceIds: number[] | Uint32Array
      in
      The list of part instance ids to fetch metadata from.
    • pFilteringContext: VisibilityContextInterface
      in
      The current filtering context for configured metadata.

    Returns boolean

  • Gets the information about the children of the specified part instance id.

    The event ChildrenIdCardReady is fired when the part instance id metadata result is ready.

    Returns true if the metadata procedure retrieval is started. If not, just call getLastError to get the reason why the procedure failed. For instance, pPartInstanceIds is considered as invalid input if it is empty or at least one element is out of range [1 - 2^31-1].

    If pFilteringContext is modified during the execution, then the call is cancelled (see cancel).

    Returns

    true if the retrieval procedure has begun.

    See

    ChildrenIdCardGetterInterfaceSignal

    Parameters

    • pPartInstanceId: number
      in
      The part instance id to fetch metadata from.
    • pFilteringContext: VisibilityContextInterface
      in
      The current filtering context for configured metadata.

    Returns boolean