gov.nasa.pds.registry.service
Class MetadataStoreJPA

java.lang.Object
  extended by gov.nasa.pds.registry.service.MetadataStoreJPA
All Implemented Interfaces:
MetadataStore

@Repository(value="metadataStore")
public class MetadataStoreJPA
extends Object
implements MetadataStore

This is a database implementation using Java's persistence library. Any database that supports JPA can be used in conjunction with this implementation of a MetadataStore. To use a different type of database one would need to update the persistence unit provided via configuration and injected with Spring.

Author:
pramirez

Constructor Summary
MetadataStoreJPA()
           
 
Method Summary
 void deleteRegistryObject(String guid, Class<? extends RegistryObject> objectClass)
          Removes a registry object from the back end store.
 PagedResponse<Association> getAssociations(RegistryQuery<AssociationFilter> query, Integer start, Integer rows)
          Retrieves associations from the back end store that match the query and are within the requested results list range
 PagedResponse<AuditableEvent> getAuditableEvents(RegistryQuery<EventFilter> query, Integer start, Integer rows)
          Retrieves auditable events from the back end store that match the query and are within the requested results list range
 List<AuditableEvent> getAuditableEvents(String affectedObject)
          Retrieves the list of events that the given affected object was referenced in
 List<ClassificationNode> getClassificationNodes(String scheme)
          Retrieves the list of classification nodes which fall under a given classification scheme
 javax.persistence.EntityManager getEntityManager()
           
 PagedResponse<ExtrinsicObject> getExtrinsics(RegistryQuery<ExtrinsicFilter> query, Integer start, Integer rows)
          Retrieves products from back end store that match the query and are within the requested result list range
 long getNumRegistryObjects(Class<? extends RegistryObject> objectClass)
          Gets the count of registry objects managed in the backed of a given type.
 RegistryObject getRegistryObject(String guid, Class<? extends RegistryObject> objectClass)
          Returns the registry object with a given guid and of the given type
 RegistryObject getRegistryObject(String lid, String versionName, Class<? extends RegistryObject> objectClass)
          Retrieves a registry object that is identified by its logical identifier and user supplied version.
 List<RegistryObject> getRegistryObjects(Integer start, Integer rows, Class<? extends RegistryObject> objectClass)
          This method allows paging through registry objects of a given type.
 PagedResponse getRegistryObjects(RegistryQuery<ObjectFilter> query, Integer start, Integer rows, Class<? extends RegistryObject> objectClass)
          Generic query for a given class of registry objects.
 List<RegistryObject> getRegistryObjectVersions(String lid, Class<? extends RegistryObject> objectClass)
          Returns all versions of a registry object that share a logical identifier
 boolean hasClassificationNode(String scheme, String code)
          Checks to see if a code exists within a classification scheme
 boolean hasRegistryObject(String guid, Class<? extends RegistryObject> objectClass)
          Test to see if a registry object exists with a guid and type requested.
 boolean hasRegistryObject(String lid, String versionName, Class<? extends RegistryObject> objectClass)
          Test to see if a registry object exists with a logical identifier, version, and type requested.
 boolean hasRegistryObjectVersions(String lid, Class<? extends RegistryObject> objectClass)
          Test to see if there are any versions of the registry object with the logical id and type requested
 void saveRegistryObject(RegistryObject registryObject)
          Stores a registry object into the back end.
 void setEntityManager(javax.persistence.EntityManager entityManager)
           
 void updateRegistryObject(RegistryObject registryObject)
          Updates a registry object that shares the guid of the given object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetadataStoreJPA

public MetadataStoreJPA()
Method Detail

setEntityManager

public void setEntityManager(javax.persistence.EntityManager entityManager)

getEntityManager

public javax.persistence.EntityManager getEntityManager()

getExtrinsics

@Transactional(readOnly=true)
public PagedResponse<ExtrinsicObject> getExtrinsics(RegistryQuery<ExtrinsicFilter> query,
                                                                  Integer start,
                                                                  Integer rows)
Description copied from interface: MetadataStore
Retrieves products from back end store that match the query and are within the requested result list range

Specified by:
getExtrinsics in interface MetadataStore
Parameters:
query - to filter against extrinsics
start - index within the results to start at. This index is one based
rows - number of results to get
Returns:
list of extrinsics

getAuditableEvents

@Transactional(readOnly=true)
public List<AuditableEvent> getAuditableEvents(String affectedObject)
Description copied from interface: MetadataStore
Retrieves the list of events that the given affected object was referenced in

Specified by:
getAuditableEvents in interface MetadataStore
Parameters:
affectedObject - guid of a registry object
Returns:
list of events

getClassificationNodes

@Transactional(readOnly=true)
public List<ClassificationNode> getClassificationNodes(String scheme)
Description copied from interface: MetadataStore
Retrieves the list of classification nodes which fall under a given classification scheme

Specified by:
getClassificationNodes in interface MetadataStore
Parameters:
scheme - guid of the scheme
Returns:
list of classification nodes

getAssociations

@Transactional(readOnly=true)
public PagedResponse<Association> getAssociations(RegistryQuery<AssociationFilter> query,
                                                                Integer start,
                                                                Integer rows)
Description copied from interface: MetadataStore
Retrieves associations from the back end store that match the query and are within the requested results list range

Specified by:
getAssociations in interface MetadataStore
Parameters:
query - to filter against associations.
start - index within the results to start at. This index is one based
rows - number of results to get. If equal to -1 return all.
Returns:
list of associations

getRegistryObject

@Transactional(readOnly=true)
public RegistryObject getRegistryObject(String guid,
                                                      Class<? extends RegistryObject> objectClass)
Description copied from interface: MetadataStore
Returns the registry object with a given guid and of the given type

Specified by:
getRegistryObject in interface MetadataStore
Parameters:
guid - of requested registry object
objectClass - type of object. For instance, a ExtrinsicObject, ClassificationNode, Service, etc. Anything that extends from a RegistryObject
Returns:

saveRegistryObject

@Transactional(readOnly=false,
               propagation=REQUIRED)
public void saveRegistryObject(RegistryObject registryObject)
Description copied from interface: MetadataStore
Stores a registry object into the back end.

Specified by:
saveRegistryObject in interface MetadataStore
Parameters:
registryObject - to store

deleteRegistryObject

@Transactional(readOnly=false,
               propagation=REQUIRED)
public void deleteRegistryObject(String guid,
                                               Class<? extends RegistryObject> objectClass)
Description copied from interface: MetadataStore
Removes a registry object from the back end store.

Specified by:
deleteRegistryObject in interface MetadataStore
Parameters:
guid - of object to remove
objectClass - type of object to remove

getNumRegistryObjects

@Transactional(readOnly=true)
public long getNumRegistryObjects(Class<? extends RegistryObject> objectClass)
Description copied from interface: MetadataStore
Gets the count of registry objects managed in the backed of a given type.

Specified by:
getNumRegistryObjects in interface MetadataStore
Parameters:
objectClass - type of object to look up
Returns:
count of objects

getRegistryObject

public RegistryObject getRegistryObject(String lid,
                                        String versionName,
                                        Class<? extends RegistryObject> objectClass)
Description copied from interface: MetadataStore
Retrieves a registry object that is identified by its logical identifier and user supplied version.

Specified by:
getRegistryObject in interface MetadataStore
Parameters:
lid - logical identifier of registry object.
versionName - version of registry object.
objectClass - type of registry object.
Returns:
The identfied registry object of the requested type.

getRegistryObjectVersions

@Transactional(readOnly=true)
public List<RegistryObject> getRegistryObjectVersions(String lid,
                                                                    Class<? extends RegistryObject> objectClass)
Description copied from interface: MetadataStore
Returns all versions of a registry object that share a logical identifier

Specified by:
getRegistryObjectVersions in interface MetadataStore
Parameters:
lid - logical identifier of objects to look up
objectClass - type of registry object
Returns:
list of matching registry objects

getRegistryObjects

@Transactional(readOnly=true)
public List<RegistryObject> getRegistryObjects(Integer start,
                                                             Integer rows,
                                                             Class<? extends RegistryObject> objectClass)
Description copied from interface: MetadataStore
This method allows paging through registry objects of a given type.

Specified by:
getRegistryObjects in interface MetadataStore
Parameters:
start - index within the results to start at. This index is one based
rows - number of results to get
objectClass - type of object to get
Returns:
list of registry objects that share the type requested

getRegistryObjects

public PagedResponse getRegistryObjects(RegistryQuery<ObjectFilter> query,
                                        Integer start,
                                        Integer rows,
                                        Class<? extends RegistryObject> objectClass)
Description copied from interface: MetadataStore
Generic query for a given class of registry objects. This query only contains attributes that are applicable across all registry objects.

Specified by:
getRegistryObjects in interface MetadataStore
Parameters:
query - based on a set of filters
start - index within the results to start at. This index is one based
rows - number of results to get
objectClass - the type of registry object to look for
Returns:
list of RegistryObject with the given class

hasRegistryObject

@Transactional(readOnly=true)
public boolean hasRegistryObject(String lid,
                                               String versionName,
                                               Class<? extends RegistryObject> objectClass)
Description copied from interface: MetadataStore
Test to see if a registry object exists with a logical identifier, version, and type requested.

Specified by:
hasRegistryObject in interface MetadataStore
Parameters:
lid - logical id of object
versionName - registry generated version
objectClass - type of registry object
Returns:
flag indicating existence of registry object

hasRegistryObjectVersions

@Transactional(readOnly=true)
public boolean hasRegistryObjectVersions(String lid,
                                                       Class<? extends RegistryObject> objectClass)
Description copied from interface: MetadataStore
Test to see if there are any versions of the registry object with the logical id and type requested

Specified by:
hasRegistryObjectVersions in interface MetadataStore
Parameters:
lid - logical id of object
objectClass - type of registry object
Returns:
flag indicating existence of registry object

hasRegistryObject

@Transactional(readOnly=true)
public boolean hasRegistryObject(String guid,
                                               Class<? extends RegistryObject> objectClass)
Description copied from interface: MetadataStore
Test to see if a registry object exists with a guid and type requested.

Specified by:
hasRegistryObject in interface MetadataStore
Parameters:
guid - globally unique identifier of object
objectClass - type of registry object
Returns:
flag indicating existence of registry object

updateRegistryObject

@Transactional(readOnly=false,
               propagation=REQUIRED)
public void updateRegistryObject(RegistryObject registryObject)
Description copied from interface: MetadataStore
Updates a registry object that shares the guid of the given object

Specified by:
updateRegistryObject in interface MetadataStore
Parameters:
registryObject - to update too

hasClassificationNode

@Transactional(readOnly=true)
public boolean hasClassificationNode(String scheme,
                                                   String code)
Description copied from interface: MetadataStore
Checks to see if a code exists within a classification scheme

Specified by:
hasClassificationNode in interface MetadataStore
Parameters:
scheme - guid of the scheme
code - to check for in scheme
Returns:
flag to indicate existence

getAuditableEvents

public PagedResponse<AuditableEvent> getAuditableEvents(RegistryQuery<EventFilter> query,
                                                        Integer start,
                                                        Integer rows)
Description copied from interface: MetadataStore
Retrieves auditable events from the back end store that match the query and are within the requested results list range

Specified by:
getAuditableEvents in interface MetadataStore
Parameters:
query - to filter against events.
start - index within the results to start at. This index is one based
rows - number of results to get. If equal to -1 return all.
Returns:
list of events


Copyright © 2010-2011 Planetary Data System. All Rights Reserved.