Class DataContractManager
- java.lang.Object
-
- es.bsc.dataclay.util.management.AbstractManager
-
- es.bsc.dataclay.logic.datacontractmgr.DataContractManager
-
- All Implemented Interfaces:
CommonManager
public final class DataContractManager extends AbstractManager
This class is responsible to manage datacontracts: add, remove and modify.
-
-
Field Summary
-
Fields inherited from class es.bsc.dataclay.util.management.AbstractManager
dataSource
-
-
Constructor Summary
Constructors Constructor Description DataContractManager(SQLiteDataSource dataSource)
Instantiates an DataContract Manager that uses the Backend configuration provided.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkDataSetHasNoDataContracts(DataSetID datasetID)
This method checks if there is no datacontract associated with the provided datasetvoid
cleanCaches()
Method that cleans the caches of the manager.Map<DataContractID,DataContract>
getDataContractIDsOfApplicant(AccountID applicantAccountID)
Get all datacontract IDs of the user provided (as applicant)Map<DataContractID,DataContract>
getDataContractIDsOfProvider(DataSetID datasetIDofProvider)
Get info of all datacontracts of the dataset provided indexed by their id.DataContract
getDataContractInfoOfApplicantWithProvider(AccountID applicantAccountID, DataSetID datasetIDofProvider)
Get datacontract info of the user provided (as applicant) with a dataset provider.DataContractManagerDB
getDbHandler()
Method used for unit testing.Map<DataContractID,DataContract>
getInfoOfSomeActiveDataContractsForAccountWithProviders(AccountID applicantAccountID, Set<DataSetID> dataSetsIDs)
Get all datacontracts IDs of the user provided (as applicant) with a set of datasets providers.DataContractID
getPublicDataContractIDOfProvider(DataSetID datasetIDofProvider)
Get info of the expected contract for a public dataset.DataContractID
newPrivateDataContract(DataContract newDataContract)
Method that creates a new private datacontract with the provided information.DataContractID
newPublicDataContract(DataContract newDataContract)
Method that creates a new public datacontract.void
registerToPublicDataContract(AccountID applicantAccountID, DataContractID datacontractID)
Method that allows an account to register to a public datacontract.
-
-
-
Constructor Detail
-
DataContractManager
public DataContractManager(SQLiteDataSource dataSource)
Instantiates an DataContract Manager that uses the Backend configuration provided.- Parameters:
managerName
- Manager/service name.
-
-
Method Detail
-
newPrivateDataContract
public DataContractID newPrivateDataContract(DataContract newDataContract) throws ParseException
Method that creates a new private datacontract with the provided information.- Parameters:
newDataContract
- Specifications of the datacontract- Returns:
- the id of the datacontract
- Throws:
ParseException
- parse exception.
-
newPublicDataContract
public DataContractID newPublicDataContract(DataContract newDataContract) throws ParseException
Method that creates a new public datacontract.- Parameters:
newDataContract
- Specifications of the datacontract- Returns:
- the id of the datacontract
- Throws:
ParseException
- parse exception.
-
registerToPublicDataContract
public void registerToPublicDataContract(AccountID applicantAccountID, DataContractID datacontractID)
Method that allows an account to register to a public datacontract.- Parameters:
applicantAccountID
- the id of the applicant accountdatacontractID
- the id of the datacontract- Throws:
Exception
- if some exception occurs:
DataContractNotExistException: if the datacontract does not exist
DataContractNotPublicException: if the datacontract is not public
DataContractNotActiveException: if the datacontract has expired
AccountAlreadyRegisteredInDataContract if the account is already registered to the datacontract
-
checkDataSetHasNoDataContracts
public boolean checkDataSetHasNoDataContracts(DataSetID datasetID)
This method checks if there is no datacontract associated with the provided dataset- Parameters:
datasetID
- the dataset to be checked- Returns:
- true if there is no datacontract related with the dataset, false otherwise
- Throws:
Exception
- if some exception occurs
-
getInfoOfSomeActiveDataContractsForAccountWithProviders
public Map<DataContractID,DataContract> getInfoOfSomeActiveDataContractsForAccountWithProviders(AccountID applicantAccountID, Set<DataSetID> dataSetsIDs)
Get all datacontracts IDs of the user provided (as applicant) with a set of datasets providers.- Parameters:
applicantAccountID
- the applicant user.dataSetsIDs
- the IDs of the datasets' providers.- Returns:
- The info of the datacontracts of the user (as applicant) with the given datasets.
- Throws:
Exception
- if some exception occurs
-
getDataContractIDsOfProvider
public Map<DataContractID,DataContract> getDataContractIDsOfProvider(DataSetID datasetIDofProvider)
Get info of all datacontracts of the dataset provided indexed by their id.- Parameters:
datasetIDofProvider
- the dataset of the datacontract- Returns:
- The info of the datacontracts of the account provided in the dataset provided
- Throws:
Exception
- if some exception occurs
-
getPublicDataContractIDOfProvider
public DataContractID getPublicDataContractIDOfProvider(DataSetID datasetIDofProvider)
Get info of the expected contract for a public dataset.- Parameters:
datasetIDofProvider
- the dataset of the datacontract- Returns:
- The info of the datacontracts of the account provided in the dataset provided
- Throws:
Exception
- if some exception occurs
-
getDataContractIDsOfApplicant
public Map<DataContractID,DataContract> getDataContractIDsOfApplicant(AccountID applicantAccountID)
Get all datacontract IDs of the user provided (as applicant)- Parameters:
applicantAccountID
- the applicant user- Returns:
- The info of the datacontracts of the user (as applicant)
- Throws:
Exception
- if some exception occurs
-
getDataContractInfoOfApplicantWithProvider
public DataContract getDataContractInfoOfApplicantWithProvider(AccountID applicantAccountID, DataSetID datasetIDofProvider)
Get datacontract info of the user provided (as applicant) with a dataset provider.- Parameters:
applicantAccountID
- the applicant user.datasetIDofProvider
- the ID of the dataset provider.- Returns:
- The info of the datacontracts of the user (as applicant) with the given dataset.
- Throws:
Exception
- if some exception occurs
-
getDbHandler
public DataContractManagerDB getDbHandler()
Method used for unit testing.- Returns:
- The db handler reference of this manager.
-
cleanCaches
public void cleanCaches()
Description copied from interface:CommonManager
Method that cleans the caches of the manager. Used on testing.- Specified by:
cleanCaches
in interfaceCommonManager
- Specified by:
cleanCaches
in classAbstractManager
-
-