Class DataContractManager

  • All Implemented Interfaces:
    CommonManager

    public final class DataContractManager
    extends AbstractManager
    This class is responsible to manage datacontracts: add, remove and modify.
    • 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 account
        datacontractID - 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.