Package es.bsc.dataclay.metadataservice
Class MetaDataServiceDB
- java.lang.Object
-
- es.bsc.dataclay.metadataservice.MetaDataServiceDB
-
public final class MetaDataServiceDB extends Object
MetaData data base.
-
-
Constructor Summary
Constructors Constructor Description MetaDataServiceDB(SQLiteDataSource dataSource)
MetaDataServiceDB constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close DB.void
createTables()
Create tables of MDS.void
deleteByID(ObjectID objectID)
Delete object metadata identified by ID provided (ignored if object does not exist)void
deleteExternalObject(ObjectID objectID)
Delete a federated object from an external dataClay instance.boolean
deleteFederatedObject(ObjectID objectID, DataClayInstanceID dataClayID)
Delete federated objectvoid
dropTables()
Delete the tables of MDS.boolean
existsByDataSetID(DataSetID datasetID)
Check if there is any ObjectMetaData with DataSetID providedboolean
existsByID(ObjectID objectID)
Check if there is an object object metadata identified by ID providedboolean
existsExternalObject(ObjectID objectID, boolean unregisteredFlag)
Checks whether the given object is externally federatedboolean
existsFederatedObject(ObjectID objectID)
Checks if the object is already federated.boolean
existsFederatedObjectWithDC(ObjectID objectID, DataClayInstanceID dataClayID)
Checks if the object is already federated with given external dataClay instance.Set<ObjectID>
getAllObjectIDs()
Get all objects registered in systemObjectMetaData
getByAlias(String alias)
Get anb object by class - alias (null if it does not exist)ArrayList<ObjectMetaData>
getByClass(MetaClassID classID)
Get a set of objects metadata by its Class IDObjectMetaData
getByID(ObjectID objectID)
Get object metadata by IDSet<DataClayInstanceID>
getDataClaysOurObjectIsFederatedWith(ObjectID objectID)
Retrieves external target dataClays ids which the given object is federated withDataClayInstanceID
getExternalDataClayOfObject(ObjectID objectID)
Retrieves external source dataClay id owning the given object.Set<ObjectID>
getObjectsFederatedWithDataClay(DataClayInstanceID extDataClayInstanceID)
Method that retrieves all the objects federated/belonging to dataClay with ID provided.Set<ObjectID>
getUnregisteredExternalObjects()
Get unregistered external objects.void
insertExternalObject(ObjectID objectID, DataClayInstanceID srcDataClayID, boolean unregisteredFlag)
Registers an object that has been federated from an external dataClay instance.boolean
insertFederatedObject(ObjectID objectID, DataClayInstanceID dataClayID)
Registers an object to be federated with an external dataClay instancevoid
store(ObjectMetaData objectMD)
Store ObjectMetaData into databasevoid
updateAliasByID(ObjectID objectID, String newAlias)
Update object metadata by IDvoid
updateDataSetIDByID(ObjectID objectID, DataSetID newdatasetid)
Update object metadata by IDvoid
updateForReplicaByID(ObjectID objectID, Set<ExecutionEnvironmentID> newLocs, boolean newReadOnly)
Update object metadata by IDvoid
updateLocationIDsByID(ObjectID objectID, Set<ExecutionEnvironmentID> newLocs)
Update object metadata by IDvoid
updateReadOnlyByID(ObjectID objectID, boolean newisreadonly)
Update object metadata by IDvoid
updateUnregisteredFlagExternalObject(ObjectID objectID, boolean unregisteredFlag)
Update external object flag unregisteredvoid
vacuum()
Vacuum database.
-
-
-
Constructor Detail
-
MetaDataServiceDB
public MetaDataServiceDB(SQLiteDataSource dataSource)
MetaDataServiceDB constructor.- Parameters:
dataSource
- data source
-
-
Method Detail
-
createTables
public void createTables()
Create tables of MDS.
-
dropTables
public void dropTables()
Delete the tables of MDS. Just the other way around of createTables --much simpler.
-
store
public void store(ObjectMetaData objectMD)
Store ObjectMetaData into database- Parameters:
objectMD
- ObjectMetaData
-
getByID
public ObjectMetaData getByID(ObjectID objectID)
Get object metadata by ID- Parameters:
objectID
- ID of the object- Returns:
- The ObjectMetaData or null if it does not exist
-
getAllObjectIDs
public Set<ObjectID> getAllObjectIDs()
Get all objects registered in system- Returns:
- The id of all objects registered
-
existsByID
public boolean existsByID(ObjectID objectID)
Check if there is an object object metadata identified by ID provided- Parameters:
objectID
- ID of the object- Returns:
- TRUE if exists. FALSE otherwise
-
existsByDataSetID
public boolean existsByDataSetID(DataSetID datasetID)
Check if there is any ObjectMetaData with DataSetID provided- Parameters:
datasetID
- DataSetID- Returns:
- TRUE if there is any ObjectMetaData with DataSetID provided. FALSE otherwise.
-
deleteByID
public void deleteByID(ObjectID objectID) throws DbHandlerException
Delete object metadata identified by ID provided (ignored if object does not exist)- Parameters:
objectID
- ID of the object- Throws:
DbHandlerException
-
updateAliasByID
public void updateAliasByID(ObjectID objectID, String newAlias) throws DbObjectNotExistException
Update object metadata by ID- Parameters:
objectID
- ID of the object to updatenewAlias
- new alias of the object- Throws:
DbObjectNotExistException
- if object does not exist
-
updateDataSetIDByID
public void updateDataSetIDByID(ObjectID objectID, DataSetID newdatasetid) throws DbObjectNotExistException
Update object metadata by ID- Parameters:
objectID
- ID of object to updatenewdatasetid
- New dataset id- Throws:
DbObjectNotExistException
- if object does not exist
-
updateLocationIDsByID
public void updateLocationIDsByID(ObjectID objectID, Set<ExecutionEnvironmentID> newLocs) throws DbObjectNotExistException
Update object metadata by ID- Parameters:
objectID
- ID of object to updatenewLocs
- New location ids- Throws:
DbObjectNotExistException
- if object does not exist
-
updateReadOnlyByID
public void updateReadOnlyByID(ObjectID objectID, boolean newisreadonly) throws DbObjectNotExistException
Update object metadata by ID- Parameters:
objectID
- ID of object to updatenewisreadonly
- new is read only value- Throws:
DbObjectNotExistException
- if object does not exist
-
updateForReplicaByID
public void updateForReplicaByID(ObjectID objectID, Set<ExecutionEnvironmentID> newLocs, boolean newReadOnly) throws DbObjectNotExistException
Update object metadata by ID- Parameters:
objectID
- ID of object to updatenewLocs
- New storage location ids- Throws:
DbObjectNotExistException
- if object does not exist
-
getByClass
public ArrayList<ObjectMetaData> getByClass(MetaClassID classID)
Get a set of objects metadata by its Class ID- Parameters:
classID
- Class ID of the objects- Returns:
- The ObjectMetaDatas with class id provided
-
getByAlias
public ObjectMetaData getByAlias(String alias)
Get anb object by class - alias (null if it does not exist)- Parameters:
alias
- alias of the object- Returns:
- object instancing specified class and aliased with given alias. null if there is none.
-
insertFederatedObject
public boolean insertFederatedObject(ObjectID objectID, DataClayInstanceID dataClayID)
Registers an object to be federated with an external dataClay instance- Parameters:
objectID
- id of the object to be federateddataClayID
- id of the external dataClay instance- Returns:
- true if the object has been successfully registered, false if it was already registered previously
-
deleteFederatedObject
public boolean deleteFederatedObject(ObjectID objectID, DataClayInstanceID dataClayID)
Delete federated object- Parameters:
objectID
- id of the object to be deleteddataClayID
- id of the external dataClay instance- Returns:
- true if the object has been successfully deleted, false otherwise
-
existsFederatedObjectWithDC
public boolean existsFederatedObjectWithDC(ObjectID objectID, DataClayInstanceID dataClayID)
Checks if the object is already federated with given external dataClay instance.- Parameters:
objectID
- id of the object to be checkeddataClayID
- id of the external dataClay id- Returns:
- true if the object is already registered as federated object with given external dataClay instance. false otherwise.
-
existsFederatedObject
public boolean existsFederatedObject(ObjectID objectID)
Checks if the object is already federated.- Parameters:
objectID
- id of the object to be checked- Returns:
- true if the object is already registered as federated object with given external dataClay instance. false otherwise.
-
getDataClaysOurObjectIsFederatedWith
public Set<DataClayInstanceID> getDataClaysOurObjectIsFederatedWith(ObjectID objectID)
Retrieves external target dataClays ids which the given object is federated with- Parameters:
objectID
- id of the object to be checked- Returns:
- ids of external dataClays which the object is federated with
-
getObjectsFederatedWithDataClay
public Set<ObjectID> getObjectsFederatedWithDataClay(DataClayInstanceID extDataClayInstanceID)
Method that retrieves all the objects federated/belonging to dataClay with ID provided.- Parameters:
extDataClayInstanceID
- id of dataclay- Returns:
- all the objects federated/belonging to dataClay with ID provided.
-
insertExternalObject
public void insertExternalObject(ObjectID objectID, DataClayInstanceID srcDataClayID, boolean unregisteredFlag)
Registers an object that has been federated from an external dataClay instance.- Parameters:
objectID
- ID of the external objectsrcDataClayID
- id of the source dataClay instance federating this objectunregisteredFlag
- Indicates object is unregistered
-
deleteExternalObject
public void deleteExternalObject(ObjectID objectID)
Delete a federated object from an external dataClay instance.- Parameters:
objectID
- ID of the external object
-
existsExternalObject
public boolean existsExternalObject(ObjectID objectID, boolean unregisteredFlag)
Checks whether the given object is externally federated- Parameters:
objectID
- id of the object to be checkedunregisteredFlag
- Indicates if object is unregistered or not- Returns:
- true if it is an external object federated. false otherwise.
-
getUnregisteredExternalObjects
public Set<ObjectID> getUnregisteredExternalObjects()
Get unregistered external objects.- Returns:
- id of external objects unregistered
-
updateUnregisteredFlagExternalObject
public void updateUnregisteredFlagExternalObject(ObjectID objectID, boolean unregisteredFlag) throws DbObjectNotExistException
Update external object flag unregistered- Parameters:
objectID
- ID of the object to updateunregisteredFlag
- Value of flag unregistered- Throws:
DbObjectNotExistException
- if object does not exist
-
getExternalDataClayOfObject
public DataClayInstanceID getExternalDataClayOfObject(ObjectID objectID)
Retrieves external source dataClay id owning the given object.- Parameters:
objectID
- id of the object to be checked- Returns:
- id of the external source dataClay
-
vacuum
public void vacuum()
Vacuum database.
-
close
public void close()
Close DB.
-
-