TNS Internal:NDR/ObjectModel

From NSDLWiki

Jump to: navigation, search

Contents

[hide]

NDR Object Model Implementation

Introduction

There are Content Models

Content Models for each object type
  • AgentModel
  • AggregatorModel
  • MetadataModel
  • MetadataProviderModel
  • ResourceModel
Content Models for concepts
  • CollectionModel
  • AuthorizationModel
  • OAIModel

with methods that validate an object's compliance with the overall NDR Object Model

  • assureExactlyOneHandle(NDRObject)
  • assureProperType(NDRObject)
  • etc.

and each Content Model has a Components subclass that is composed of multiple

  • Property
  • Relationship
  • Datastream

There are Types of objects which extend ConcreteObject (which extends NDRObject which extends NDRObjectInfo) and the Component subclass of the related Content Model

  • Agent
  • Aggregator
  • Metadata
  • MetadataProvider
  • Resource

each of which is implemented by an implementation class

  • GenericAgentImpl
  • GenericAggregatorImpl
  • GenericMetadataImpl
  • GenericMetadataProviderImpl
  • GenericResourceImpl


When ndr.getObject() is called, an instance of an object inheriting from NDRObject is returned. This is frequently cast to NDRObjectInfo when it is passed around between methods. The actual class of the returned object is one of GenericAgentImpl, GenericAggregatorImpl, etc. If the type() method is called on these objects, it returns one of

See the subsections for each concept to get more information.


Component subclass of Content Models

Property and Relationship Components

Code Location: org.nsdl.repository.model

Primary Classes:

  • Component - interface that defines enum of Types: Property, Datastream, Relationship and forces all component classes to have...
    • getType() - component classes below each return one of the above defined types (Property, Relationship, or Datastream) as appropriate
    • subject() - returns what the component type considers its subject (ex. for Property and Relationship - subject is an NDR object; Datastream doesn't implement Component)
    • subclass Pattern
      • getMatchingType()
      • matches()
    • subclass Name which extends xml QName (qualified name)


Component Types:

  • Property - NDRObjectInfo subject, Name predicate(QName), String value
  • Relationship - NDRObjectInfo subject, Name predicate(QName), NDRObjectInfo object

NOTE: Datastreams do not implement Component. See Datastream Components below.


Datastream Components

Code Location: org.nsdl.repository.impl.fedora

Primary Classes:

  • org.nsdl.repository.model.Datastream - interface that defines basic accessor methods (ex. g/setMimeType(),g/setLabel(), etc.)
  • FedoraDatastream - interface that extends Datastream and adds Fedora specific accessor methods (ex. getState(), controlGroup(), etc.)


Classes that implement FedoraDatastream:

  • DeferredAPIDatastream
  • ManagedDatastream
  • RedirectDatastream
  • XMLDatastream


Content Models

Code Location: org.nsdl.repository.model.content

Primary Classes:

  • ContentModel - interface that forces all models to have...
    • checkCompliance()
    • init()
  • CommonModel - implements ContentModel
    • defines properties, relationships, and datastreams that are common to all the content models in CommonModels.Components.
    • has common compliance methods (ex. assureExactlyOneHandle(), etc.)


Specific Content Models (all implement ContentModel):

Content Models for each object type

  • AgentModel
  • AggregatorModel
  • MetadataModel
  • MetadataProviderModel
  • ResourceModel

Content Models for concepts

  • CollectionModel
  • AuthorizationModel
  • OAIModel


These classes have several parts...

  • implement ContentModel
  • includes a subclass called Components which extends CommonModel.Components and defines the predicate (of type Name which implements QName) for properties, relationships, and datastreams. The Type classes described later extend this Components subclass.
    • creates an instance of repository.model.Property.Name for each property
      (ex. new Property.Name(NS="http://ns.nsdl.org/api/relationships#","objectType",PREFIX="nsdl");)
    • creates an instance of repository.model.Relationship.Name for each relationship
      (ex. new Relationship.Name(NS="http://ns.nsdl.org/api/relationships#","memberOf",PREFIX="nsdl");)
    • creates an instance of repository.model.Datastream.Name for each datastream
      (ex. new Datastream.Name("DC");)
  • includes a subclass called Identifiers which extends Definitions (used for AgentModel and ResourceModel only). Used by compliance methods.
  • caches identifiers, properties, and relationships (exclusive and all) by using ModelUtil class to get the list of properties and relationships from the structure of the Components subclass of the Content Model class and the list of identifiers from the structure of the Identifiers subclass of the Content Model. The cached lists are used by compliance methods.
  • checkCompliance() method which is called by NSDLContentModel
  • compliance methods related to controlling the inter-object models of NDR. These methods are called by the checkCompliance() method


Other Classes:

  • CollectionsModel - the only thing that put this here instead of up with the Specific Content Models is that NSDLContentModel does not have it on the list of models for which it calls checkCompliance
  • Definitions - lots of things extend this, but it doesn't define anything
  • NSDLContentModel - called by repository.tools.ContentModelValidator and runs through all models defined above and calls checkCompliance() method starting with CommonModel.checkCompliance()


Classes related to Components

  • Scope - enum to determine whether a Component is part of another model or exclusive to a particular model. Values of enum: Shared | Exclusive | All. Used in conjunction with ModelUtil.
  • Shared - interface to define a java annotation (@Shared) to be placed before Component (Property or Relationship) definitions to mark them as shared. ModelUtil uses isAnnotationPresent() in the getRels() method to determine whether a Property or Relationship is shared or exclusive.
  • ModelUtil - utility class to help with getting properties and relationships individually or as a list (exclusive | all)
    • checkNSProperties/Relationships() - determines if a property/relationship with a specific namespace that is part of an object is on the list of properties for that namespace that was defined by the Components of the model for the object's type. Throws an exception if not. Called by checkProtectedNS() compliance method in Content Model classes.
    • checkExclusiveProperties/Relationships() -
    • getRels() returns either a list of Properties or a list of Relationships, for the specified scope (Shared | Exclusive | All) based on the structure of the passed in class (either Components or Identifiers) isAnnotationPresent() is used to determine match with passed in scope. If the property or relationship definition is marked with the @Share annotation, then it is considered Shared; otherwise, it is Exclusive.


Example: AgentModel

Components
From CommonModel
Property.Name NSDL_STATE http://ns.nsdl.org/api/relationships#,state,nsdl
Property.Name HAS_HANDLE http://ns.nsdl.org/api/relationships#,hasHandle,nsdl
Property.Name OBJECT_TYPE http://ns.nsdl.org/api/relationships#,objectType,nsdl
Relationship.Name MEMBER_OF http://ns.nsdl.org/api/relationships#,memberOf,nsdl
Datastream.Name DC DC
From AgentModel
Property.Name IDENTIFIER_HOST http://ns.nsdl.org/api/relationships#,hasResourceHOST,nsdl
Property.Name IDENTIFIER_USER http://ns.nsdl.org/api/relationships#,hasResourceUSER,nsdl
Property.Name IDENTIFIER_OTHER http://ns.nsdl.org/api/relationships#,hasResourceOTHER,nsdl
Identifiers
From CommonModel
none
From AgentModel
Property.Name HOST Components.IDENTIFIER_HOST
Property.Name USER Components.IDENTIFIER_USER
Cache
From CommonModel
N/A
From AgentModel
properties NSDL_STATE, HAS_HANDLE, OBJECT_TYPE, IDENTIFIER_HOST, IDENTIFIER_USER, IDENTIFIER_OTHER
relationships MEMBER_OF
exclusiveProperties NSDL_STATE, HAS_HANDLE, OBJECT_TYPE, IDENTIFIER_HOST, IDENTIFIER_USER
exclusiveRelationships MEMBER_OF
Compliance Methods
From CommonModel
  • assureExactlyOneHandle(NDRObject)
  • assureProperType(NDRObject)
From AgentModel
  • checkExclusiveComponents(NDRObject)
  • checkProtectedNS(NDRObject)
  • assureExactlyOneAgentIdentifier(NDRObject)
  • assureUniqueIdentifier(NDRObject)


Types

Code Location: org.nsdl.repository.model.types


Primary Classes:

  • Type
    • creates stubbed objects of Type (requiring extension of a specific interface class) where the name of the object is the name of the interface class and the class of the object is the Generic*Impl class (ex. Type<Agent> Agent = new GenericAgentImpl();)
  • TypeFactory


The following classes define interfaces that determine what methods are needed for the various types of NDR objects. Each extends ConcreteObject and repository.model.content.*Model.Componenets, where * is the type (ex. AgentModel.Components). NOTE: AgentModel.Componenets extends CommonModel.Components

  • Agent - interface that extends ConcreateObject (which extends NDRObject) and AgentModel.Components
  • Aggregator
  • Metadata
  • MetadataProvider
  • Resource


The following classes implement the above interfaces and extend ConcreteObjectBase (which extends MutableObjectWrapper and implements ConcreteObject)

  • GenericAgentImpl - extends ConcreateObjectBase and implements Agent
  • GenericAggregatorImpl
  • GenericMetadataImpl
  • GenericMetadataProviderImpl
  • GenericResourceImpl


Other classes:

  • ConcreteObject - interface that extends NDRObject; adds method isUnder(Aggregator) to determine if an object is in the hierarchy of an Aggregator (Not Supported at the time this document was written)
  • ConcreteObjectBase - interface that extends MutableObjectWrapper and implements ConcreteObject
  • Grouping - interface defining methods getAgent(), getMembers(), countMembers(), getBranding()
  • GroupingBase - abstract class extending ConcreteObjectBase and implementing Grouping class. Used by GenericAggregatorImpl and GenericMetadataProviderImpl classes.


NDR Objects

Primary Classes:

  • NDRObjectInfo - interface that defines methods type() and handle()
  • NDRObject - interface that extends NDRObjectInfo


NDRObject:

  • defines enum State - complex enum with methods for manipulating state; basic values: Active | Interactive | Delete (see Java enum type
  • requires methods for...
    • get/setState
    • getCreateDate/ModifiedDate
    • get/add/removeProperty/Relationship/Datastream
    • getProperties/Relationships/Datastreams
    • getRelationship
    • getRelationships
    • commit


NDRObjectTemplate extends MutableObjectBase

Personal tools