Method Details

getAll

Promise getAll( )

Get a list of all of the existing assets in this asset registry.

Example

// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get all of the vehicles in the vehicle asset registry.returnassetRegistry.getAll();}).then(function(vehicles){// Process the array of vehicle objects.vehicles.forEach(function(vehicle){console.log(vehicle.vehicleId);});}).catch(function(error){// Add optional error handling here.});

Returns

Promise - A promise. The promise is resolved with an array of Resource instances representing all of the assets stored in this asset registry. If the asset registry does not exist, or the current user does not have access to the asset registry, then the promise will be rejected with an error that describes the problem.

See also

Parameters

No parameters

Example

// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get all of the vehicles in the vehicle asset registry.returnassetRegistry.getAll();}).then(function(vehicles){// Process the array of vehicle objects.vehicles.forEach(function(vehicle){console.log(vehicle.vehicleId);});}).catch(function(error){// Add optional error handling here.});

get

Promise get( string id )

Get the specified asset in this asset registry using the unique identifier of the asset.

Example

// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get the specific vehicle from the vehicle asset registry.returnassetRegistry.get('VEHICLE_1');}).then(function(vehicle){// Process the the vehicle object.console.log(vehicle.vehicleId);}).catch(function(error){// Add optional error handling here.});

Returns

Promise - A promise. The promise is resolved with a Resource instance representing the specified asset in this asset registry. If the specified asset does not exist, or the current user does not have access to the specified asset, then the promise will be rejected with an error that describes the problem.

See also

Parameters

Name

Type

Mandatory

Description

id

string

Yes

The ID of the asset.

Example

// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get the specific vehicle from the vehicle asset registry.returnassetRegistry.get('VEHICLE_1');}).then(function(vehicle){// Process the the vehicle object.console.log(vehicle.vehicleId);}).catch(function(error){// Add optional error handling here.});

addAll

Promise addAll( assets )

Add all of the specified assets to this asset registry.

Example

// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get the factory for creating new asset instances.varfactory=getFactory();// Create the first vehicle.varvehicle1=factory.newResource('org.acme','Vehicle','VEHICLE_1');vehicle1.colour='BLUE';// Create the second vehicle.varvehicle2=factory.newResource('org.acme','Vehicle','VEHICLE_2');vehicle2.colour='GREEN';// Add the vehicles to the vehicle asset registry.returnvehicleAssetRegistry.addAll([vehicle1,vehicle2]);}).catch(function(error){// Add optional error handling here.});

Returns

Promise - A promise. The promise is resolved when all of the assets have been added to this asset registry. If the assets cannot be added to this asset registry, or if the assets already exist in the asset registry, then the promise will be rejected with an error that describes the problem.

See also

Parameters

Name

Type

Mandatory

Description

assets

Yes

The assets to add to this asset registry.

Example

// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get the factory for creating new asset instances.varfactory=getFactory();// Create the first vehicle.varvehicle1=factory.newResource('org.acme','Vehicle','VEHICLE_1');vehicle1.colour='BLUE';// Create the second vehicle.varvehicle2=factory.newResource('org.acme','Vehicle','VEHICLE_2');vehicle2.colour='GREEN';// Add the vehicles to the vehicle asset registry.returnvehicleAssetRegistry.addAll([vehicle1,vehicle2]);}).catch(function(error){// Add optional error handling here.});

add

Promise add( Resource asset )

Add the specified asset to this asset registry.

Example

// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get the factory for creating new asset instances.varfactory=getFactory();// Create the vehicle.varvehicle=factory.newResource('org.acme','Vehicle','VEHICLE_1');vehicle.colour='BLUE';// Add the vehicle to the vehicle asset registry.returnvehicleAssetRegistry.add(vehicle);}).catch(function(error){// Add optional error handling here.});

Returns

Promise - A promise. The promise is resolved when the asset has been added to this asset registry. If the asset cannot be added to this asset registry, or if the asset already exists in the asset registry, then the promise will be rejected with an error that describes the problem.

See also

Parameters

Name

Type

Mandatory

Description

asset

Resource

Yes

The assets to add to this asset registry.

Example

// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get the factory for creating new asset instances.varfactory=getFactory();// Create the vehicle.varvehicle=factory.newResource('org.acme','Vehicle','VEHICLE_1');vehicle.colour='BLUE';// Add the vehicle to the vehicle asset registry.returnvehicleAssetRegistry.add(vehicle);}).catch(function(error){// Add optional error handling here.});

updateAll

Promise updateAll( assets )

Update all of the specified assets in this asset registry.

Example

// The existing vehicles that have come from elsewhere.varvehicle1;varvehicle2;// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get the factory for creating new asset instances.varfactory=getFactory();// Modify the properties of the first vehicle.vehicle1.colour='PURPLE';// Modify the properties of the second vehicle.vehicle2.colour='ORANGE';// Update the vehicles in the vehicle asset registry.returnvehicleAssetRegistry.updateAll([vehicle1,vehicle2]);}).catch(function(error){// Add optional error handling here.});

Returns

Promise - A promise. The promise is resolved when all of the assets have been updated in this asset registry. If the assets cannot be updated in this asset registry, or if the assets do not exist in the asset registry, then the promise will be rejected with an error that describes the problem.

See also

Parameters

Name

Type

Mandatory

Description

assets

Yes

The assets to update in this asset registry.

Example

// The existing vehicles that have come from elsewhere.varvehicle1;varvehicle2;// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get the factory for creating new asset instances.varfactory=getFactory();// Modify the properties of the first vehicle.vehicle1.colour='PURPLE';// Modify the properties of the second vehicle.vehicle2.colour='ORANGE';// Update the vehicles in the vehicle asset registry.returnvehicleAssetRegistry.updateAll([vehicle1,vehicle2]);}).catch(function(error){// Add optional error handling here.});

update

Promise update( Resource asset )

Update the specified asset in this asset registry.

Example

// The existing vehicle that has come from elsewhere.varvehicle;// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get the factory for creating new asset instances.varfactory=getFactory();// Modify the properties of the vehicle.vehicle.colour='PURPLE';// Update the vehicle in the vehicle asset registry.returnvehicleAssetRegistry.update(vehicle);}).catch(function(error){// Add optional error handling here.});

Returns

Promise - A promise. The promise is resolved when the asset have been updated in this asset registry. If the asset cannot be updated in this asset registry, or if the asset does not exist in the asset registry, then the promise will be rejected with an error that describes the problem.

See also

Parameters

Name

Type

Mandatory

Description

asset

Resource

Yes

The asset to update in this asset registry.

Example

// The existing vehicle that has come from elsewhere.varvehicle;// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get the factory for creating new asset instances.varfactory=getFactory();// Modify the properties of the vehicle.vehicle.colour='PURPLE';// Update the vehicle in the vehicle asset registry.returnvehicleAssetRegistry.update(vehicle);}).catch(function(error){// Add optional error handling here.});

removeAll

Promise removeAll( ; assets )

Remove all of the specified assets from this asset registry.

Example

// The existing vehicles that have come from elsewhere.varvehicle1;// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get the factory for creating new asset instances.varfactory=getFactory();// Remove the vehicles from the vehicle asset registry. Note that// one vehicle is specified as a vehicle instance, and the other// vehicle is specified by the ID of the vehicle.returnvehicleAssetRegistry.removeAll([vehicle1,'VEHICLE_2']);}).catch(function(error){// Add optional error handling here.});

Returns

Promise - A promise. The promise is resolved when all of the assets have been removed from this asset registry. If the assets cannot be removed from this asset registry, or if the assets do not exist in the asset registry, then the promise will be rejected with an error that describes the problem.

See also

Parameters

Name

Type

Mandatory

Description

assets

;

Yes

The assets, or the IDs of the assets, to remove from this asset registry.

Example

// The existing vehicles that have come from elsewhere.varvehicle1;// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get the factory for creating new asset instances.varfactory=getFactory();// Remove the vehicles from the vehicle asset registry. Note that// one vehicle is specified as a vehicle instance, and the other// vehicle is specified by the ID of the vehicle.returnvehicleAssetRegistry.removeAll([vehicle1,'VEHICLE_2']);}).catch(function(error){// Add optional error handling here.});

remove

Promise remove( string; Resource asset )

Remove the specified asset from this asset registry.

Example

// The existing vehicle that has come from elsewhere.varvehicle;// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get the factory for creating new asset instances.varfactory=getFactory();// Remove the vehicle from the vehicle asset registry.returnvehicleAssetRegistry.remove(vehicle);}).catch(function(error){// Add optional error handling here.});

Returns

Promise - A promise. The promise is resolved when the asset has been removed from this asset registry. If the asset cannot be removed from this asset registry, or if the asset does not exist in the asset registry, then the promise will be rejected with an error that describes the problem.

See also

Parameters

Name

Type

Mandatory

Description

asset

string; Resource

Yes

The asset, or ID of the asset, to remove from this asset registry.

Example

// The existing vehicle that has come from elsewhere.varvehicle;// Get the vehicle asset registry.returngetAssetRegistry('org.acme.Vehicle').then(function(vehicleAssetRegistry){// Get the factory for creating new asset instances.varfactory=getFactory();// Remove the vehicle from the vehicle asset registry.returnvehicleAssetRegistry.remove(vehicle);}).catch(function(error){// Add optional error handling here.});