Jump to content

ICT:Drupal - Object - Asset many to many implementation

From Costa Sano MediaWiki

Object–Asset Linking Workflow in Drupal (Conceptual and Editorial Model)

This document explains how the many‑to‑many relationship between Objects and Assets is implemented and used in Drupal.

It focuses on the editorial workflow for historians, ensuring that linking multiple Assets to an Object is intuitive, efficient, and conceptually clear.

The goal is to provide a successor‑friendly description of:

  • the conceptual model
  • the Drupal entity structure
  • the user interface
  • the historian workflow
  • the role of the ObjectAsset junction entity


1. Conceptual Model

Objects and Assets have a many‑to‑many relationship.

  • An Object may be documented by multiple Assets.
  • An Asset may document multiple Objects.

This relationship is contextual, not intrinsic. It includes additional meaning:

  • the Asset’s role relative to the Object
  • whether the Asset is the preferred representation

This is expressed through the ObjectAsset junction entity.


2. Drupal Entity Structure

The relationship is implemented using a dedicated Drupal entity type:

object_asset (junction entity)

Fields:

  • field_object → references an Object
  • field_asset → references an Asset
  • field_role → references an AssetRole
  • field_is_preferred → boolean

This entity represents one link between one Object and one Asset.

Why a junction entity?

  • supports many‑to‑many
  • supports roles
  • supports preferred flags
  • keeps Object and Asset entities clean
  • matches the DBML schema
  • matches the conceptual model
  • is fully queryable and future‑proof


3. Editorial Workflow Overview

Historians should be able to:

  1. Open an Object
  2. Browse all Assets
  3. Filter and search
  4. Select one or more Assets
  5. Assign a role
  6. Mark preferred representation
  7. Save

The workflow must be:

  • simple
  • visual
  • non‑technical
  • consistent
  • discoverable
  • safe for successors


4. Object Edit Page Layout

When editing an Object, the page contains a dedicated section:

Section: “Linked Assets”

A View listing all Assets linked to this Object via ObjectAsset.

Columns:

  • thumbnail
  • caption
  • role
  • preferred flag
  • edit link
  • remove link

This gives historians an immediate overview of all Assets associated with the Object.


5. Adding Assets to an Object

Below the list, a button is provided:

Button: “Add Assets to this Object”

Clicking this button opens a modal window.


6. Asset Selection Modal

The modal contains a View showing all Assets in the system.

Features of the Asset selection View

  • thumbnails
  • captions
  • AssetType
  • AssetSourceType
  • Place
  • Organisation
  • year
  • filename

Exposed filters

  • search box
  • type
  • source type
  • place
  • organisation
  • year range
  • keywords

This allows historians to quickly find the relevant Assets.


7. Linking an Asset to the Object

Each row in the Asset list contains a button:

“Add to Object”

Clicking this button opens a small form (still inside the modal):

ObjectAsset creation form

  • Role (dropdown from AssetRole)
  • Preferred representation (checkbox)
  • [Save]

The Object and Asset fields are pre‑filled and hidden.

After saving:

  • the link is created
  • the modal remains open
  • the historian can add more Assets


In the “Linked Assets” section on the Object page:

  • clicking “Edit” opens the ObjectAsset edit form
  • clicking “Remove” deletes the link

This allows historians to adjust roles or change the preferred representation.


9. Why This Workflow Works for Historians

This workflow is designed around how historians think:

  • They start from the Object (“the thing we study”).
  • They browse the archive of Assets visually.
  • They filter by type, date, place, or organisation.
  • They select the Assets that belong.
  • They assign meaning (role).
  • They mark the preferred representation.

They never need to:

  • understand junction entities
  • edit Assets directly
  • manage complex forms
  • navigate away from the Object page

The system remains:

  • intuitive
  • visual
  • safe
  • consistent
  • conceptually clean


10. Summary

The Object–Asset workflow in Drupal is built on:

  • a dedicated junction entity (object_asset)
  • a historian‑friendly UI
  • Views for browsing and filtering
  • modal dialogs for selection
  • role assignment
  • preferred representation flags

This approach preserves the conceptual clarity of the data model while providing a practical, efficient editorial workflow for historians and future maintainers.