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 id-card request.

The ChildrenIdCardGetterInterface interfaces are created through the DataSessionInterface.createChildrenIdCardGetter method.

/** 
* Sample to illustrate the use of an ChildrenIdCardGetterInterface from a `part instance id`, to get the brothers of a part instance.
*/
import {
IdCardGetterInterface, IdCardGetterInterfaceSignal, ChildrenIdCardGetterInterface,
ChildrenIdCardGetterInterfaceSignal, PartInstanceInfoInterface, InfiniteEvent,
ChildrenPartInstanceInfoInterface, DataSessionInterface, AncestryInstanceMetadataInterface,
InstanceMetadataInterface, DocumentContentInterface, WorkingSetInterface
} from 'generated_files/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 Working set has been created previously
let lWorkingSet : WorkingSetInterface;

// 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 id-card retrieval
lIdCardGetterInterface.retrieveIdCard(lPartInstanceId, lWorkingSet);

// onIdCardReady will be called when data is available
onIdCardReady = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
if (lIdCardGetterInterface.getLastError() !== undefined) {
// 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];
// get all metadata hierarchy
const lAllInstanceMetadata : Array<AncestryInstanceMetadataInterface> = lCurrentChain.getAncestorInstanceInfos();
// number of items
const lNbAncestors : number = lAllInstanceMetadata.length;

// the instance offset is the last one
const lInstanceOffset : number = lNbAncestors - 1;
if (lInstanceOffset < 1)
{
console.log(lPartInstanceId + ' is a leaf instance, exiting');
return;
}
const lParentInstanceId : number = lAllInstanceMetadata[lInstanceOffset].getParentInstanceId();
// this is the same as lAllInstanceMetadata[lInstanceOffset-1].getInstanceId();
lChildrenIdCardGetterInterface.retrieveChildrenIdCard(lParentInstanceId, lWorkingSet);
};

// onChildrenIdCardReady will be called when data is available
onChildrenIdCardReady = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
if (lChildrenIdCardGetterInterface.getLastError() !== undefined) {
// 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];

let i : number;
// iterate over the children metadata infos
const lAllInstanceMetadata : Array<InstanceMetadataInterface> = lChildren.getChildrenInstanceInfos();
const lNbChildren : number = lAllInstanceMetadata.length;
let lCurChildMetadata : InstanceMetadataInterface;

// we should have the part instance in the list of children
for(i = 0; i < lNbChildren; i += 1)
{
lCurChildMetadata = lAllInstanceMetadata[i];
if(lCurChildMetadata.getInstanceId() === lPartInstanceId)
{
break;
}
}
if (i === lNbChildren)
{
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 the last child of the `part instance`
const lPartMetadataDocuments : Array<DocumentContentInterface> = lCurChildMetadata.getPartMetadataDocuments();
if (lPartMetadataDocuments.length === 0)
{
console.log('this part instance has no part metadata documents');
return;
}
// we get the `part` metadata of me (but should do something else even more interesting)
// and we only care with the first document, but many documents may be attached
const lPartMetadata : Object = lPartMetadataDocuments[0].getDocumentContent();
// some fancy output
console.log(JSON.stringify(lPartMetadata));
};

The list of signals the ChildrenIdCardGetterInterface may trigger is available in the ChildrenIdCardGetterInterfaceSignal enumeration.

The metadata retrieval procedure is triggered through the retrieveChildrenIdCard methods. The result is not available right away, but the event ChildrenIdCardGetterInterfaceSignal.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 ChildrenIdCardGetterInterfaceSignal.ChildrenIdCardCancelled signal is fired, and shortly after, ChildrenIdCardGetterInterfaceSignal.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 ChildrenIdCardGetterInterfaceSignal.ChildrenIdCardReady, only one ChildrenIdCardGetterInterfaceSignal.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 {
ChildrenIdCardGetterInterface, ChildrenIdCardGetterInterfaceSignal,
InfiniteEvent, ChildrenPartInstanceInfoInterface, DataSessionInterface,
InstanceMetadataInterface, DocumentContentInterface, WorkingSetInterface
} from 'generated_files/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// created previously
let lWorkingSet : WorkingSetInterface;
// 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() !== undefined) {
// 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];

// iterate over the children metadata infos
const lAllInstanceMetadata : Array<InstanceMetadataInterface> = lCurrentChildren.getChildrenInstanceInfos();

// number of items
const lNbChildren : number = lAllInstanceMetadata.length;
if (lNbChildren <= 0)
{
console.log('this part instance is a leaf');
return;
}
// take the last child
const lChildInstanceOffset : number = lNbChildren - 1;
const lLastChildInstanceInfos : InstanceMetadataInterface = lAllInstanceMetadata[lChildInstanceOffset];
// we get the `part` metadata of the last child of the `part instance`
const lPartMetadataDocuments : Array<DocumentContentInterface> = lLastChildInstanceInfos.getPartMetadataDocuments();
if (lPartMetadataDocuments.length === 0)
{
console.log('this part instance has no part metadata documents');
return;
}
// and we only care with the first document, but many documents may be attached
const lPartMetadata : Object = lPartMetadataDocuments[0].getDocumentContent();
// some fancy output
console.log(JSON.stringify(lPartMetadata));

// get the visibility info in order to get information about the `part instance`
if (lLastChildInstanceInfos.isDisplayable())
{
console.log('the last child of the part instance is displayable');
}
};

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

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 {
ChildrenIdCardGetterInterface, AsyncChildrenPartInstanceInfoResult,
ChildrenPartInstanceInfoInterface, AsyncResultReason, DataSessionInterface,
InstanceMetadataInterface, DocumentContentInterface, WorkingSetInterface
} from 'generated_files/documentation/appinfiniteapi';

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

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

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

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];

// iterate over the children metadata infos
const lAllInstanceMetadata : Array<InstanceMetadataInterface> = lCurrentChildren.getChildrenInstanceInfos();
// number of items
const lNbChildren : number = lAllInstanceMetadata.length;
if (lNbChildren <= 0)
{
console.log('this part instance is a leaf');
return;
}
// take the last child
const lChildInstanceOffset : number = lNbChildren - 1;
const lLastChildInstanceInfos : InstanceMetadataInterface = lAllInstanceMetadata[lChildInstanceOffset];
// we get the `part` metadata of the last child of the `part instance`
const lPartMetadataDocuments : Array<DocumentContentInterface> = lLastChildInstanceInfos.getPartMetadataDocuments();

if (lPartMetadataDocuments.length === 0)
{
console.log('this part instance has no part metadata documents');
return;
}
// and we only care with the first document, but many documents may be attached
const lPartMetadata : Object = lPartMetadataDocuments[0].getDocumentContent();
// some fancy output
console.log(JSON.stringify(lPartMetadata));

// get the visibility info in order to get information about the `part instance`
if (lLastChildInstanceInfos.isDisplayable())
{
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

interface ChildrenIdCardGetterInterface {
    addEventListener(pType, pListener, pObject): string;
    addEventListener(pType, pListener): string;
    areSignalsBlocked(): boolean;
    asyncRetrieveChildrenIdCard(pPartInstanceIds, pWorkingSet): Promise<AsyncChildrenPartInstanceInfoResult>;
    asyncRetrieveRootIdCard(pWorkingSet): Promise<AsyncPartInstanceInfoResult>;
    blockSignals(pBlock): void;
    cancel(): boolean;
    dispose(): void;
    getInfiniteObjectType(): InfiniteObjectType;
    getLastError(): InfiniteError;
    getLastRequestId(): string;
    getPartInstanceInfos(): ChildrenPartInstanceInfoInterface[];
    getResultForIdCardCustomization(pMultiMetadataHierarchies, pDocPool): boolean;
    hasEventListener(pType, pListener): boolean;
    hasEventListenerById(pId): boolean;
    isCancelled(): boolean;
    isDisposed(): boolean;
    isRunning(): boolean;
    removeAllEventListeners(): boolean;
    removeEventListener(pType, pListener, pObject): boolean;
    removeEventListener(pType, pListener): boolean;
    removeEventListenerById(pId): boolean;
    retrieveChildrenIdCard(pPartInstanceIds, pWorkingSet): boolean;
    retrieveChildrenIdCard(pPartInstanceId, pWorkingSet): boolean;
    retrieveRootIdCard(pWorkingSet): boolean;
}

Hierarchy (view full)

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. Calling twice addEventListener with the same parameters results in the second call to be ignored, only unique pairs callback / object are allowed, in order to avoid calling multiple times the same thing.

    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: Object
      in
      The optional object the callback will be called with when the given event fires.

    Returns string

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

  • 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.

    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

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

  • Tells if signals sent by the object are blocked or not.

    If signals are blocked, no signal will be emitted nor buffered, such signal will be lost.

    Returns boolean

    true if signals are blocked.

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

    Returns a promise.

    If pWorkingSet 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.

    Parameters

    • pPartInstanceIds: number | number[] | Uint32Array
      in
      The list of part instance ids to fetch metadata from.
    • pWorkingSet: WorkingSetInterface
      in
      The current working set for configured metadata.

    Returns Promise<AsyncChildrenPartInstanceInfoResult>

    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.

  • Asynchronously gets the information about the specified part instance id and its genealogy.

    Returns a promise.

    Please note that in case of multiple promises running at the same time on the same IdCardGetterInterface, 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 pWorkingSet is modified during the execution, then the call is cancelled (see cancel).

    Parameters

    Returns Promise<AsyncPartInstanceInfoResult>

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

  • Blocks / Unblocks all signals sent by the object.

    If signals are blocked, no signal will be emitted nor buffered, such signal will be lost.

    Parameters

    • pBlock: boolean
      in
      If set to true, all further signals will be silently discarded.

    Returns void

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

    Returns InfiniteError

    The last error if any, or undefined if no error occurred.

  • Gets the result for the id-card customization script.

    As the customization script may change, the customization script types are not exposed to the Infinite api. You can get them from the @3djuump.com/client-script-3djuump-infinite package.

    /** 
    * Sample to illustrate the use of an IdCardGetterInterface with the usage of the customization script.
    */
    import { ChildrenIdCardGetterInterface, tScriptDocPool } from 'generated_files/documentation/appinfiniteapi';

    // created previously
    let lChildrenIdCardGetterInterface : ChildrenIdCardGetterInterface;
    // ...
    // ...
    const lMultiHierarchy : Array<any> = [];
    const lDocPool : tScriptDocPool = {};
    // now retrieve the result
    if(!lChildrenIdCardGetterInterface.getResultForIdCardCustomization(lMultiHierarchy, lDocPool))
    {
    console.log('Error while transforming data');
    throw new Error('customization failed');
    }
    // now we can use the customization script since data is ready to be used.

    The detailed usage of the customization script is beyond the scope of this documentation.

    Parameters

    • pMultiMetadataHierarchies: any[]
      out
      The multi id card hierarchy result.
    • pDocPool: tScriptDocPool
      out
      The map of docs.

    Returns boolean

    true if the conversion went right.

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

    Parameters

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

    Returns boolean

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

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

    Parameters

    • pId: string
      in
      The id of the callback to test.

    Returns boolean

    true if such a listener is installed for the given callback id.

  • Tells if the ChildrenIdCardGetterInterface has been cancelled.

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

    Returns boolean

    true if the ChildrenIdCardGetterInterface is cancelled.

  • Tells if the ChildrenIdCardGetterInterface is updating.

    This is the case after calling retrieveChildrenIdCard.

    Returns boolean

    true if the ChildrenIdCardGetterInterface is updating.

  • 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.

    Parameters

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

      The listener function that gets removed.

    • pObject: Object

      The listener object that was used when addEventListener was called.

    Returns boolean

    true if the callback was removed else false.

  • 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.

    Parameters

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

      The listener function that gets removed.

    Returns boolean

    true if the callback was removed else false.

  • 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.

    Parameters

    • pId: string
      in
      The id returned by the call to addEventListener that you want to remove.

    Returns boolean

    true if the callback was removed else false.

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

    The ChildrenIdCardGetterInterfaceSignal.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 pWorkingSet is modified during the execution, then the call is cancelled (see cancel).

    Parameters

    • pPartInstanceIds: number[] | Uint32Array
      in
      The list of part instance ids to fetch metadata from.
    • pWorkingSet: WorkingSetInterface
      in
      The current working set for configured metadata.

    Returns boolean

    true if the retrieval procedure has begun.

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

    The event ChildrenIdCardGetterInterfaceSignal.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 pWorkingSet is modified during the execution, then the call is cancelled (see cancel).

    Parameters

    • pPartInstanceId: number
      in
      The part instance id to fetch metadata from.
    • pWorkingSet: WorkingSetInterface
      in
      The current working set for configured metadata.

    Returns boolean

    true if the retrieval procedure has begun.

  • Gets the information about the specified part instance id and its genealogy.

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

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

    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].

    Parameters

    Returns boolean

    true if the retrieval procedure has begun.