Enumeration IdCardGetterInterfaceSignal

The IdCardGetterInterfaceSignal lists all the signals that may be sent by the IdCardGetterInterface.

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

/** 
* Sample to illustrate the use of an IdCardGetterInterface with the parsing of
* PartInstanceInfoInterface to display some information about a part instance.
*/
import {
WorkingSetInterface, IdCardGetterInterface, IdCardGetterInterfaceSignal,
InfiniteEvent, PartInstanceInfoInterface, DataSessionInterface, AncestryInstanceMetadataInterface, DocumentContentInterface
} from 'generated_files/documentation/appinfiniteapi';

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

// create an idCardGetter
const lIdCardGetterInterface : IdCardGetterInterface = lDataSession.createIdCardGetter();
// what to do when result is ready ?
lIdCardGetterInterface.addEventListener(IdCardGetterInterfaceSignal.IdCardReady, onIdCardReady);

// 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 ?
}
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];

// iterate over the metadata infos
const lAllInstanceMetadata : Array<AncestryInstanceMetadataInterface> = lCurrentChain.getAncestorInstanceInfos();

// number of items
const lNbAncestors : number = lAllInstanceMetadata.length;
const lOffsetToPartInstance : number = lNbAncestors - 1;
// we get the `part` metadata of the given `part instance` (and not their parents - grand parents) => lNbAncestors-1
const lCurrentInstanceInfos : AncestryInstanceMetadataInterface = lAllInstanceMetadata[lOffsetToPartInstance];
const lPartMetadataDocuments : Array<DocumentContentInterface> = lCurrentInstanceInfos.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 (lCurrentInstanceInfos.isDisplayable())
{
console.log('this part instance is displayable');
}
};

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

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

Enumeration Members

Enumeration Members

IdCardCancelled: "cancelled"

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

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

No attachment for events of this type.

IdCardReady: "ready"

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

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

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