Source references
In the records that you return to users from your services, you can include source references that contain information about the external source from which the data came. Entity and link records both support the inclusion of source reference objects.
Setting a source reference
To add a source reference to an entity or link, call the setSourceReference()
function from within the service's acquire
callback.
For example, see the calls to complaintEntity.setSourceReference()
and victimOfLink.setSourceReference()
in the following code:
const exampleSourceRef = {
name: 'NYPD Complaint Dataset',
type: 'Open source data',
description: 'A collection of open source data about NYPD complaints',
};
addService(
{
id: 'getVictims',
name: 'NYPD Connector: Get all victims',
description: 'A service that retrieves all the victim data.',
},
({ result }) => {
const complaintId = `Complaint: 1`;
const complaintEntity = result.addEntity(Complaint, complaintId);
complaintEntity.setSourceReference(exampleSourceRef);
const victimId = `Victim: 1`;
const victimEntity = result.addEntity(Person, victimId);
victimEntity.setSourceReference(exampleSourceRef);
const victimOfLinkId = `VictimOf: 1`;
const victimOfLink = result.addLink(Victimof, victimOfLinkId, victimEntity, complaintEntity);
victimOfLink.setSourceReference(exampleSourceRef);
}
);