See: Description
| Class | Description |
|---|---|
| MediaType |
Defines a java bean for the 'Media Type' field.
|
| Tag |
Defines the tag bean.
|
Provide class to retrieve attached assets from media field.
Get the value from the 'MediaType' field:
The data model used in the following example has a table that contains a field with './Media' path, which is associated with {addon.label}'s 'MediaType' field:
Adaptation aRecord = aTable.lookUpAdaptationByPrimaryKey(recordPrimaryKey);
SchemaNode schemaNode = aRecord.getSchemaNode().getNode(Path.parse("./Media"));
int maxOccurs = schemaNode.getMaxOccurs();
List<MediaType> mediaTypes = new ArrayList<MediaType>();
Object value = aRecord.get(Path.parse("./Media"));
if (maxOccurs <= 1)
{
mediaTypes.add((MediaType) value);
}
else
{
mediaTypes.addAll((List<MediaType>) value);
}
Get the asset's UUID from the Java bean object 'MediaType':
String assetUUID = aMediaType.getAttachment();
Attaching asset
//After uploading, an object DigitalAsset is returned. You can get the digital asset primary key from this.
String assetUUID = digitalAsset.getDigitalAssetContext().getDigitalAssetKey().getDigitalAssetPrimaryKey().format();
//Create a new procedure to update new value to the MediaType field.
//Note: The Drive of new uploaded asset and the Drive of target 'MediaType' field should be the same.
int maxOccurs = aNode.getMaxOccurs();
ValueContextForUpdate contextForUpdate = pContext.getContext(aRecordName);
if (maxOccurs <= 1) {
MediaType mediaType = new MediaType();
mediaType.setAttachment(assetUUID);
contextForUpdate.setValue(mediaType, aPath);
}
else
{
List<MediaType> mediaTypes = new ArrayList<MediaType>();
MediaType mediaType = new MediaType();
mediaType.setAttachment(assetUUID);
mediaTypes.add(mediaType);
contextForUpdate.setValue(mediaTypes, aPath);
}
aProcedure.doModifyContent(aRecord, contextForUpdate);