Package com.orchestranetworks.addon.dama.models


package com.orchestranetworks.addon.dama.models

Provide class to retrieve attached assets from media field.

Examples of getting an asset's UUID from a field using the 'MediaType' field

  1. 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);
            }
    
  2. Get the asset's UUID from the Java bean object 'MediaType':

            String assetUUID = aMediaType.getAttachment();
    
  3. 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);
    
  • Classes
    Class
    Description
    Defines a java bean for the 'Media Type' field.
    Defines the tag bean.