Annotation Management

From Gcube Wiki
Revision as of 09:43, 16 October 2008 by Fabio.simeoni (Talk | contribs) (Sample Usage)

Jump to: navigation, search

The Annotation Back-End (ABE) service manages the entire life-cycle of annotation relationships between information objects, from their creation and collation to their retrieval, update, and deletion, independently from application-specific models of annotation content.

Clients may interact with the ABE service through a standard library of stubs generated automatically from the public service interfaces. They may also do so at a higher level of abstraction through the Annotation Back-end Library, an extension of the stub library which simplifies clients interaction with the service.

Annotation Relationships

Annotation relationships are specialisations of metadata relationships that give target objects the broad semantic of subjective and contextual assertions about source objects. More formally, annotation relationships are binary relationships with primary role is-described-by and secondary role is-annotated-by (IAB).

As specializations of metadata relationships, annotation relationships inherit all their properties:

  • they are exclusive on their targets but repeatable on their sources: an annotation describes one and only one object even though the number of annotations for any given object may be unbounded;
  • they preserve membership: an annotation belongs to a collection if and only if the annotated object does.

Annotation relationships induce a related specialization of the notion of collection: a collection is an annotation collection if it is a metadata collection of type IAB. More formally, A is an annotation collection for C if:

  • A is an IAB-collection in the scope of C;
  • all the members of A are annotations of members of C, and
  • A is an annotation of C.

The definition of annotation relationships and annotation collections – as well as the relationships between these definitions and more generic notions in the gCube Information Model can be graphically illustrated as follows:

ABErelationships.png

Annotation Model

The ABE service and library adopt a model of annotation content that is suitable for the exchange of potentially very heterogeneous annotations. In particular, the ABE exchange model complements arbitrary, application-specific notions of annotations with a small number of system-level and application-independent properties.

The model is defined in terms of XML serialisations of annotations and is in itself an extension of the exchange model adopted by Metadata Management services. In particular, it follows the same design pattern of grouping system-level properties into a header element and application-defined properties into a body element. The model is formally defined by the following schema:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema 
	xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
	xmlns:tns="http://gcube-system.org/namespaces/annotationmanagement/abe/model" 
	targetNamespace="http://gcube-system.org/namespaces/annotationmanagement/abe/model" 
	elementFormDefault="qualified" attributeFormDefault="unqualified">
	
	<xsd:import namespace="http://gcube-system.org/namespaces/metadatamanagement/mm/model"/>
	
	<xsd:element name="annotation" type="tns:annotationType"/>

	<xsd:complexType name="annotationType">
		<xsd:sequence>
			<xsd:element name="header" type="tns:headerType" />
			<xsd:element name="body" type="tns:bodyType" />
		</xsd:sequence>
	</xsd:complexType>
	
	<xsd:complexType name="headerType">
		<xsd:sequence>
			<xsd:element name="previous" type="xsd:string" minOccurs="0"/>
		</xsd:sequence>
	</xsd:complexType>
	
	<xsd:complexType name="bodyType">
		<xsd:sequence>
			<xsd:any namespace="##other" processContents="lax"/>
		</xsd:sequence>
	</xsd:complexType>
	
</xsd:schema>

Architecture

Within the gCube architecture, the ABE service is placed at the top of a stack of Information Organisation services, from Storage Management services to Content Management services and Metadata Management services. Its main role within the stack is one of mediation between the users of Information Presentation services and Metadata Management services one step below. In this role, the value it offers to its clients is one of specialisation and transparent aggregation of functionality available more generically for the management of metadata objects.

ABEarchitecture.jpg

Design

The design of the service is distributed across three port-types: the Manager, the Broker, and the </code>Factory</code>.

ABEdesign1.png

Managers

The Manager port-type manages annotations of objects which belong to a target collection. It is the preferred point of contact for clients that:

  • wish to work with such annotations regardless of the annotation collections to which individual annotations belong;
  • wish to work with annotations which belong to specific annotation collections.

ABEdesign2.png

Clients may create annotation collections for the target collection, and then add, update, retrieve or delete annotation from them. These operations map directly onto equivalent operations of the Metadata Management service and are offered to present a single point of contact for annotations. Clients may also retrieve annotations across multiple annotation collections, though of course no write operation is offered at this level of abstraction.

All operations process and produce bulk data to avoid the latency of finer-grained interactions. Similarly, all operations are conceptually overloaded to work either by-value – inputs and outputs are entirely included in message payloads – or else by-reference – input and outputs are throttled in ‘pages’ using the resultset abstraction. Finally, all operations are tolerant to fine-grained failures, through they record them and then report them as return values.

The Manager is stateful, in that it maintains (in memory and on the local file system) summary information about the annotation collections of target collections. The information is grouped under local ‘proxies’ of the target collections, and the proxies are bound to the port-type interface on a per-request basis, in line with the implied resource pattern of WSRF. In particular, the pairing of the Manager interface and collection proxies identifies WS-Resources informally referred to as Managers.

ABEdesign3.png

Managers are created in response to client requests to the Factory [[#The Factory|port-type]. At the time and within the scope of their creation, a selection of the state of Managers is published in the Information System. In WSRF terminology, these are the Resource Properties that identify the target collection and their annotation collections and by which Managers can be discovered by clients.

Following publication, Managers are kept up-to-date with respect to the creation and deletion of annotation collections which do not occur through interaction with the Managers themselves. This form of maintenance is achieved by polling the Information System at regular intervals. During their lifetime, Managers satisfy client requests by interacting with WS-Resources and Running Instances of the Metadata Manager service. The interactions are based on best-effort and caching strategies.

Brokers

The Broker port-type manages annotations of objects which belong to either one of a number of target collections. Clients may retrieve annotations for these objects regardless of the collections to which the objects or their annotations belong. For example, the Broker is the recommended point of contact for clients that wish to browse the annotations of the results of a distributed search. Clients may also narrow their interaction to single target collections by obtaining a reference to dedicated Managers.

ABEdesign4.png

Like for Managers, the operations of the ,Broker operate in bulk, either by-value or by-reference, and report fine-grained failures within return values. Similarly, the Broker is stateful and its state is an aggregation of the state of the Manager. In particular the local ‘collection proxies’ of Managers are grouped in collection sets, and then collections sets are bound to the Broker into WS-Resources informally called Brokers.

ABEdesign5.png

Like Managers, Brokers are created by the Factory [[#The Factory|port-type] persisted and publish the identifiers of the target collections in the bound set as a Resource Property. During their lifetime, Brokers also interact with WS-Resources and Running Instances of the Metadata Manager service. The interactions, however, occur indirectly, in that they are delegated to Managers dedicated to the collections in the collection set.

The Factory

The Factory is the point of contact to the ABE for clients that wish to create Managers and Brokers for one or more target collections, starting from their public identifiers. In this role, it is stateless.

ABEdesign6.png

The ABE Library

The library offers a number of facilities for interacting with the port-types and WS-Resources of the ABE service.

First of all, it encapsulates stub-based interaction behind a local object-oriented interface. The interface is distributed across a set of classes which model remote port-types (AnnotationManager, AnnotationBroker) and related state abstractions (Collection, AnnotationCollection), or else manage configuration aspects of the interaction with the ABE, such as scope and security(AnnotationContext).

Throughout, the library makes use of language features which are not found in the stubs automatically generated from the remote interfaces, including high-level models of inputs and outputs, method overloading, and parametric type-checking. Behind these abstractions, the library engages in optimised and best-effort interactions with factory and WS-Resources of the ABE service. In particular, it hides from clients the discovery or creation of WS-Resources, but not the existence of remote interactions and the possibility of their failure.

In addition, the library offers convenient object bindings for the XML representations of annotations that are required by the remote interface in input or produced by it in output. Clients that wish to do so can model annotations as objects with the advantages of expressiveness and early type checking which normally characterise data binding solutions. Bindings occurs within an extensible framework defined by a root class (BaseAnnotation) that can be extended by classes which model particular types of annotations. In particular, the root class defines the protocol that subclasses implement to serialise their ‘body’ to and from the exchange model. The framework is built atop analogous frameworks offered by Metadata and ResultSet libraries, so that annotations are transparently suitable for use as generic metadata objects and as records of a resultset.

When it comes to actually manipulate annotations, the library provides annotation buffering so as to mediate between the fine-grained nature of operations in interactive sessions and the coarse-grained nature of interaction with the remote port-types. This may enable responsive user interfaces by concentrating bulk network interactions at distinguished 'commit' points which are entirely under client control. Specifically, clients that retrieve annotations from managers or brokers transparently fill buffers specific to individual annotation collections. They can then modify the buffered annotations locally for maximum responsiveness and commit the changes remotely before filling the buffer with the next retrieval operation.

Finally, the library offers built-in support for linking annotations of the same object into 'threads' similar to those typically formed by postings in mailing lists and discussion forums, or those associated with chains of versions.

Sample Usage

Interaction with the ABE service is illustrated with the examples below. The examples are based on the ABE library, partly because it is the recommended way to interact with the service and partly because the use of plain stubs can be inferred from the public interfaces of the service

The examples are modelled as static methods of a hypothetical test class, so as to explicitate their inputs. We assume that the following variables are defined in the closure of the test methods:


//some logger
GCUBELog logger = ...

//some scope
GCUBEScope scope = ....;

First, we configure the library's behaviour through its AnnotationContext. In this sense, the AnnotationContext acts as a GCUBEScopeManager for the remote interactions with the ABE service which the library undertakes on behalf of its clients. As the examples are assumed to execute within the same thread, the simplest of scope configurations will suffice:


//configures the library to call the ABE service with a specific scope in this thread
AnnotationContext.setScope(scope) 

Note, however, that the AnnotationContext:

  • exposes the full GCUBEScopeManager for multi-threaded executions;
  • it can be configured to use any ScopeManager implementation which pre-exists in the client environment (e.g. a GCUBEServiceContext in clients that are services in their own right:

//configures the library to use an existing scope manager 
//AnnotationContext.setScopeManager(someExistingManager);

The first test method, uses the AnnotationContext to create and return an AnnotationManager for some annotated collection, i.e. a collection whose elements may be associated with annotations in one or more annnotation collections:

/**
* Creates an annotation manager for an annotated collection.
* @param collectionID the collection identifier.
*/

public static AnnotationManager getAnnotationManager(String collectionID) throws Exception {

  //Creates an annotation manager
  // note: this triggers a remote interaction and may return a GCUBEException 
  // we don't specifically deal with here
  return AnnotationContext.createManager(collectionID);

}

The following methods are utilities used in the test methods below to display summaries of the properties of the annotation collections associated with the annotated collection:


/**
 * Displays the properties of the annotation collections an annotation manager.
 * @param manager the manager.
*/
public static void listCollections(AnnotationManager manager) {
   //displays the properties of its annotation collections
   if (manager.getAnnotationCollections().size()==0) logger.debug("No annotation collections for target collection"+manager.getCollectionID());
   for (AnnotationCollection<?> coll : manager.getAnnotationCollections().values()) showCollection(coll);
}

/**
* Displays the properties of an annotation collection.
* @param collection the collection.
*/
public static void showCollection(AnnotationCollection<? extends Annotation<?>> collection) {
  logger.info("***********************");
  logger.info("ID:"+collection.getID());
  for (Map.Entry<CollectionDescription.CreationParameters,String> prop : collection.getCreationParameters().entrySet())
	logger.info(prop.getKey().name()+":"+prop.getValue());
	logger.info("***********************");
}


Alert icon2.gif THIS SECTION OF GCUBE DOCUMENTATION IS CURRENTLY UNDER UPDATE.