Metadata Manager

From Gcube Wiki
Revision as of 12:06, 22 June 2009 by Lucio.lelii (Talk | contribs) (MetadataManagerService)

Jump to: navigation, search

Introduction

The Metadata Manager service manages the modelling of arbitrary metadata relationships (IDB-relationships). The only assumption it does is that the metadata objects are serialized as well-formed XML documents. The service has a two-fold role:

  • to manage Metadata Objects and Metadata Collections
  • to establish secondary role-typed links. Such relationships can be in place between any type of Information Object and in the scope of a Collection or not

Clients interacts also with the Metadata Manager library for a higher level of abstraction which simplifies clients interaction with the service.

Metadata Object

A Metadata Object (MO) is a source Information Object for an IDB-relationship. An MO can be associated to one and only one target Information Object (even if in the context of different Metadata Collections) which is described by the MO. An MO here is always intended as an XML document wrapped in a well defined envelope. As to content, the Metadata Manager Service adopts an exchange model to add a number of system-level properties needed for the appropriate management of the Metadata Objects within the context of the Metadata Manager Service.

The Metadata Manager Components

The main functionality of the Metadata Manager components is the management of Metadata Objects, Metadata Collection and their relationships. To operate over Metadata Collections, the Metadata Catalog instantiates Collection Managers (or shortly, Managers) for each collection. A Collection Manager is the access point to all the possible operations over a specific Metadata Collection. From an architectural point of view, the Metadata Manager adopts the Factory pattern and Collection Managers are implemented as a stateful WS-Resource. Physically, the service is composed by:

  • the MetadataManagerFactory, a factory service that creates new Collection Managers and offers some cross-Collection operations
  • the MetadataManagerService, a service that operates over Metadata Collections (MCs) and on Metadata Objects as Elements, i.e. members of a specific Metadata Collection


MetadataManagerFactory

The MetadataManagerFactory Service creates new Collection Managers and offers some cross-Collection operations. Moreover, it operates on Metadata Objects as Information Objects related to other Information Objects and not as Members of Metadata Collections.

  • EndPointReferenceType createManager(CollectionID, params): This operation takes a set of creation parameters and creates a new Manager in order to manage a Metadata Collection bound to such a Collection. If a Metadata Collection with the specified Metadata characteristics does not exist, the Manager creates the Metadata Collection, binds it with the Document Collection with the given secondary role relationship and publishes its profile in the IS. The Creation parameters are a set of key-value; the following keys are defined in the MMLibrary and accepted by the operation:

These ones are mandatory:

    • COLLECTIONNAME -> name of the collection
    • METADATANAME -> metadata name (e.g. “dc”)
    • METADATALANG -> metadata language (e.g. “English”), as specified in the ISO 639-2
    • METADATAURI -> metadata URI: the XML Schema that defines the MO payloads
    • ROLE -> secondary role

The optional ones are:

    • DESCRIPTION -> description
    • INDEXABLE -> if the collection is indexable or not (“True”/”False”)
    • USER -> if the collection is a user collection or not (“True”/”False”)
    • RELATEDBY_COLLID -> the id of the source content collection
    • RELATEDBY_ROLE -> the source XML Schema from which the current one has been generated
    • GENERATEDBY_COLLID -> the source Metadata Collection from which the current one has been generated (by the Metadata Broker), if any
    • GENERATEDBY_URI -> the URI of the source schema of the collection from which it has been generated
    • Among the others, two parameters can modify the way in which the Metadata Collection is managed:
      • Indexable: if the new Metadata Collection is indexable, the Manager creates also a new MetadataXMLIndexer (see Section 4.2.2.3) for such a Collection using the XMLIndexer Service;
      • User: a user Collection is shown in the Portals and an end-user can operate on it; a non-user Collection is intended for internal puporses (like to collect parts of persisted Indexes).
  • ResultSetService
  • EndPointReferenceType createManagerFromCollection (MetadataCollectionID): This operation takes a Metadata Collection ID. It returns:
    • the related CollectionManager, if it already exists
    • creates a new CollectionManager and returns its EPR, if the Metadata Collection exists
    • an error, if the Collection ID is not valid
  • MOID addMetadata(ObjectID, MO, SecondaryRole): This operation takes a new non-collectable Metadata Object and
    • completes the metadata header information (e.g. the MOID, if it is not specified)
    • stores (or updates if the MOID is already included in the MO header) the object on the Storage Management Service as Information Object
    • creates a <is-described-by, <SecondaryRole>> binding in the Storage Management Service between the Metadata Object and the Information Object identified by the given Object ID
    • returns the assigned MOID
  • void deleteMetadata(MOID): This operation deletes from the Storage Management Service the Metadata Object identified by the given ID.
  • (ObjectID, (MO, SecondaryRole)[])[] getMetadata ((ObjectID, SecondaryRole, CollectionID, Rank)[]): For each given ObjectID, this operation returns the Metadata Objets. They are:
    • bound with the specified secondary role (the primary role is, of course, is-described-by) to the Information Object identified by that ObjectID
    • members of the specified Metadata Collection. The operation relies on the String[] retrieveReferred(String targetObjectID, String role, String secondaryrole) operation of the Storage Management Service.


MetadataManagerService

The MetadataManagerService allows user to manipulate a MetadataCollection, the operation provided are:

  • String getMetadataCollectionID(): Gets the Metadata Collection identifier
  • void deleteCollection(): Deletes the Metadata Collection and destroys the related Collection Manager.
    • The elements are also removed from the storage service, if they do not belong to other Metadata Collections
    • If the MetadataCollection is indexable, it is also destroyed from the XMLIndexer service
  • ListOfUpdateElementsResults updateElements(UpdateElements): Updates the given MOs either in the Storage Management and in the XMLIndexer (if the Collection is Indexable)
    • UpdateElements is a list of XML String representation of the MetadataObjects(MOs) to update
    • ListOfUpdateElementsResults is an array of the same cardinality of the input string. Each item is a boolean value reporting true if the MO in the same position in the input array was successfully updates, false otherwise.
  • AddElementsResponse addElements(addElements): Adds the given elements to the MetadataCollection
    • addElements is a list, where each item of the list is a valid ID of an IO available in the Storage and a list of new MOs to bind to such IO
    • AddElementsResponse is a list, which is a map with the ID of the IO and the list of MOs bound to it in the operation
  • String getElements(String): Adds the given elements to the MetadataCollection using the ResultSetService
    • the input string is the reference to an RSLocator with the MOs to store
    • the output string is the reference to an RSLocator with a list of the stored MOs' IDs
  • GetElementsFromMOIDResponse getElementsFromMOID(MOIDList): Gets the MOs identified by the given MOIDs
    • MOIDList is a list of MO IDs
    • GetElementsFromMOIDResponse contains the MetadataObjects related to the given IDs
  • MOIDList deleteElements(MOIDList): Deletes from storage service the Metadata Object identified by the given ID
    • If the MetadataCollection is indexable it deletes the Metadata Object from the related MetadataXMLIndexer using the XMLindexer service
    • MOIDList is a list with the IDs of MetadataObjects(MOs), in input the IDs to delete, in output it returns the ID of the elements not deleted
  • GetAllElementsResponse getAllElements(void)':Returns all the MOs of the current Metadata Collection
    • GetAllElementsResponse
  • addElementsRS
  • Strign getAllElementsRS(): Returns all the MOs of the current Metadata Collection using the ResultSetService
    • the output String is a reference to an RSLocator with the retrieved elements
  • getElementsRS:

The MMLibrary

The library offers a number of facilities for interacting with the creation and manipulation of Metadata Object.

First of all,the library operates at client-side by moving some of the logic on that side avoiding unnecessary interactions between clients and the Metadata Manager service.

The library offers a a set of method to easily wrap an XML documents in the model exchanged format as required by Metadata Manager service. In addition, the library offers support for wrap the Object with the appropriate metadata envelope, to create a valid Metadata Object that can be stored on the Metadata Manager Service.

In addition, the library permits to extract the basic MO information from a string representing a Metadata Object.

The new feature of the Metadata Manager: "generated-by" relationship between metadata objects The Metadata Manager handle this new relationship between MO To be able to use this feature it is needed to create a Metadata Collection specifying the following CollectionParameter:

    • the GENERATEDBY_COLLID: the ID of the Metadata Collection from which it has been generated

Then,the Metadata envelope need to have a new field <generatedByMOID> to specify the Metadata Object from which it has been generated The Metadata Manager will take care of this new field and will store the information in the Storage as secondary role, to be able to retrieve it later.

Dependencies

These are the dependencies of the Service :


  • MMLibrary
  • XMLIndexer
  • ResultSetService
  • ResultSetLibrary
  • ResultSetClientLibrary
  • ContentManagement
  • ContentManagementService
  • ContentManagementLibrary

Usage Examples

This example shows how to create a MetadataManager:


...

                String factoryURI ="http://node2.d.d4science.research-infrastructures.eu:8080/wsrf/services/gcube/metadatamanagement/metadatamanager/MetadataManagerFactory";
										
		String id = args[0]; // collection name
		
		MetadataManagerFactoryServiceAddressingLocator factoryLocator = new MetadataManagerFactoryServiceAddressingLocator();
		//MetadataManagerServiceAddressingLocator  instanceLocator = new MetadataManagerServiceAddressingLocator();
		MetadataManagerFactoryPortType mFactory;

		try {			
			EndpointReferenceType factoryEPR = new EndpointReferenceType();
			factoryEPR.setAddress(new Address(factoryURI));
			
			
			System.out.println("Creating the new Factory portType");

			mFactory= factoryLocator.getMetadataManagerFactoryPortTypePort(factoryEPR);

			System.out.println("Created instance.\n");
			
			CreateManagerRequest request = new CreateManagerRequest();
			request.setCollectionID(id);			
			CollectionParameter [] ss = new CollectionParameter[6];
			CreateCollectionParameters ccp = new CreateCollectionParameters();			
			
			for ( int i =0; i<ss.length; i++ )
				ss[i] = new CollectionParameter();
			
			ss[0].setName(CreationParameters.COLLECTIONNAME.toString());
			ss[0].setValue(id);	
			
			
			// metadatalang, metadataname, metadataformat are all used for MetadataFormat 
			// they are mandatory
			ss[1].setName(CreationParameters.METADATALANG.toString());
			ss[1].setValue("en");
			
			ss[2].setName(CreationParameters.METADATANAME.toString());
			ss[2].setValue("dc");
			
			ss[3].setName(CreationParameters.METADATAURI.toString());
			ss[3].setValue("http://mail.google.com/mail");
			
			ss[4].setName(CreationParameters.ROLE.toString());
			ss[4].setValue(SecondaryRoleDescription.ROLE_GENERATION);
			
	String factoryURI = //"http://dlib31.isti.cnr.it:8080/wsrf/services/gcube/metadatamanagement/metadatamanager/MetadataManagerFactory";
				"http://node2.d.d4science.research-infrastructures.eu:8080/wsrf/services/gcube/metadatamanagement/metadatamanager/MetadataManagerFactory";
										
		String id = "CMProve";     
		if (args.length ==1) 
        	id = args[0];
		
		MetadataManagerFactoryServiceAddressingLocator factoryLocator = new MetadataManagerFactoryServiceAddressingLocator();
		//MetadataManagerServiceAddressingLocator  instanceLocator = new MetadataManagerServiceAddressingLocator();
		MetadataManagerFactoryPortType mFactory;

		try {			
			EndpointReferenceType factoryEPR = new EndpointReferenceType();
			factoryEPR.setAddress(new Address(factoryURI));
			
			
			System.out.println("Creating the new Factory portType");

			mFactory= factoryLocator.getMetadataManagerFactoryPortTypePort(factoryEPR);

			System.out.println("Created instance.\n");
			
			CreateManagerRequest request = new CreateManagerRequest();
			request.setCollectionID(id);			
			CollectionParameter [] ss = new CollectionParameter[8];
			CreateCollectionParameters ccp = new CreateCollectionParameters();			
			
			for ( int i =0; i<ss.length; i++ )
				ss[i] = new CollectionParameter();
			
			ss[0].setName(CreationParameters.COLLECTIONNAME.toString());
			ss[0].setValue(id);
			System.out.println("COLLECTIONNAME:"+id);			
			/*ss[1].setName(CreationParameters.DESCRIPTION.toString());
			ss[1].setValue("Description Metadata Collection");			
			String editable = "True";
			ss[2].setName(CreationParameters.EDITABLE.toString());
			ss[2].setValue(editable);*/
			
			/*System.out.println(CreationParameters.DESCRIPTION.toString()+": Description Metadata Collection");
			System.out.println(CreationParameters.EDITABLE.toString()+ ": "+editable);
			
			// Indexable mandatory
			String indexable = "True";
			
			ss[3].setName(CreationParameters.INDEXABLE.toString());
			ss[3].setValue(indexable);
			
			System.out.println(CreationParameters.INDEXABLE.toString() +": "+indexable);		
			
			String user = "True";
			ss[4].setName(CreationParameters.USER.toString());
			ss[4].setValue(user);
			System.out.println(CreationParameters.USER.toString()+": " +user);*/
			
			// metadatalang, metadataname, metadataformat are all used for MetadataFormat 
			// they are mandatory
			ss[1].setName(CreationParameters.METADATALANG.toString());
			ss[1].setValue("en");
			
			ss[2].setName(CreationParameters.METADATANAME.toString());
			ss[2].setValue("dc");
			
			ss[3].setName(CreationParameters.METADATAURI.toString());
			ss[3].setValue("http://mail.google.com/mail");
			
			ss[4].setName(CreationParameters.ROLE.toString());
			ss[4].setValue(SecondaryRoleDescription.ROLE_GENERATION);
			
			ss[5].setName(CreationParameters.INDEXABLE.toString());
			ss[5].setValue("true");
			//String relatedbyCollID = "3971d1a0-4771-11dd-8639-ae5f2f1f5aef";
		
			
			String generatedbyCollID = "1222d1a0-4771-11dd-8639-ae5f2f1f5ae";
			ss[6].setName(CreationParameters.GENERATEDBY_COLLID.toString());
			ss[6].setValue(generatedbyCollID);
			System.out.println(CreationParameters.GENERATEDBY_COLLID.toString() + ": GeneratedID");			
			ss[7].setName(CreationParameters.GENERATEDBY_URI.toString());
			ss[7].setValue("http://mail.google.com/mail");
						
			ccp.setParams(ss);
			request.setCollectionParameters(ccp);
			CreateManagerResponse response  = new CreateManagerResponse();
			try{
				 mFactory = GCUBERemotePortTypeContext.getProxy(mFactory,GCUBEScope.getScope("/gcube/devsec"));	 	               
				response = mFactory.createManager(request);
			}catch(Exception e ){
				e.printStackTrace();
				return;
			}
			
			System.out.println("Created MC:"+response.getEndpointReference().toString());
		} catch (Exception e) {
			e.getMessage();
			e.printStackTrace();	
		}
	}		
....