Enumeration ChildrenIdCardGetterInterfaceSignal

The ChildrenIdCardGetterInterfaceSignal lists all the signals that may be sent by the ChildrenIdCardGetterInterface.

These signals are emitted by the ChildrenIdCardGetterInterface when some data is available.

/** 
* 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);

Please refer to ChildrenIdCardGetterInterface for more information about children id-card requests.
Events

Enumeration Members

ChildrenIdCardCancelled: "cancelled"

Signal sent by the ChildrenIdCardGetterInterface when the ChildrenIdCardGetterInterface is requested to be cancelled.

Such an event is fired if the ChildrenIdCardGetterInterface was running and ChildrenIdCardGetterInterface.cancel is called. The ChildrenIdCardReady signal will be triggered shortly after.

No attachment for events of this type.

ChildrenIdCardReady: "ready"

Signal sent by the ChildrenIdCardGetterInterface when the ChildrenIdCardGetterInterface is ready, i.e. ChildrenIdCardGetterInterface.getPartInstanceInfos can be called.

Warning, the ChildrenIdCardReady signal is sent when ChildrenIdCardGetterInterface.cancel is called and the ChildrenIdCardGetterInterface is updating. In such a case, no data will be available in the ChildrenIdCardGetterInterface.

The attachment is a string telling the request id of the call to ChildrenIdCardGetterInterface.retrieveChildrenIdCard (ChildrenIdCardGetterInterface.getLastRequestId).