An aspect represents specific functionality of an asset. It provides a rich, domain specific interface to this functionality.

Introduction

The basic characteristics of an aspect are:

  • built “on top” of the asset model
  • allows to split the top level Asset API with too many methods
  • can use multiple traits

The censhare Framework provides already many builds in Aspects as part of the Logical Model:
Aspects

Posibility to define and add custom Aspects.

Example

Different functionality is required to operate with different asset parts:

  • Pages
  • Data/files attached
  • Related assets

A page aspect provides methods to manipulate asset pages:

Page aspect

A storage aspect adds methods required for the storage items:

Storage aspect

A relations aspect provides an interface for relations:

Relations aspect

Java API

  • Accessing an aspect by its class: as(Aspect.class) 

    Pages aspect = asset.as(Pages.class);
  • Convenience methods for the most standard aspects are available with: asAspect() 

    Pages aspect = asset.asPages();
Example
@CommandHandler(command = "com.censhare.api.dam.assetmanagement.moveToNextWorkflowStep")
public static final class MoveToNextWorkflowStepHandler {
    @Execute
    public Result execute(CommandContext context, Input input) throws Exception {
        ...
        // Load the asset
        Asset asset = atomicRef.get();
        // Get the Workflow's aspect
        WorkflowAspect workflowAspect = asset.asWorkflow();
        // Execute the business logic (delegating to aspect)
        boolean isFinal = workflowAspect.moveToNextWorkflowStep();
        ...
    }
}