Package cz.metacentrum.perun.core.impl
Class ConsentsManagerImpl
java.lang.Object
cz.metacentrum.perun.core.impl.ConsentsManagerImpl
- All Implemented Interfaces:
ConsentsManagerImplApi
Consents database logic.
- Author:
- Radoslav Čerhák invalid input: '<'r.cerhak@gmail.com>
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final RowMapper
<ConsentHub> protected static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFacility
(PerunSession sess, ConsentHub consentHub, Facility facility) Adds facility to consent hub.void
changeConsentStatus
(PerunSession sess, Consent consent) Set consent statusvoid
checkConsentExists
(PerunSession sess, Consent consent) Check if consent exists in underlying data source.void
checkConsentHubExists
(PerunSession sess, ConsentHub consentHub) Throws exception if consent hub does not exist.boolean
consentExists
(PerunSession sess, Consent consent) Check if consent exists in underlying data source.boolean
consentHubExists
(PerunSession sess, ConsentHub consentHub) Returns true, if consent hub exists, false otherwise.createConsent
(PerunSession perunSession, Consent consent) Save consent to database.createConsentHub
(PerunSession sess, ConsentHub consentHub) Creates new consent hub.void
deleteConsent
(PerunSession perunSession, Consent consent) Delete consent from the database.void
deleteConsentHub
(PerunSession perunSession, ConsentHub consentHub) Deletes the consent hub.Get list of all Consent HubsgetAllConsents
(PerunSession sess) Gel all consentsgetConsentById
(PerunSession sess, int id) Get consent object with specified idgetConsentForUserAndConsentHub
(PerunSession sess, int userId, int consentHubId, ConsentStatus status) Get consent for chosen user in specified consent hub with specified statusgetConsentHubByFacility
(PerunSession sess, int facilityId) Finds existing Consent Hub by facility.getConsentHubById
(PerunSession sess, int id) Finds existing Consent Hub by id.getConsentHubByName
(PerunSession sess, String name) Finds existing Consent Hub by name.getConsentHubsByService
(PerunSession session, int serviceId) Finds all existing Consent Hubs by service (service is assigned to them)getConsentsForConsentHub
(PerunSession sess, int id) Get all consents for chosen ConsentHubgetConsentsForConsentHub
(PerunSession sess, int id, ConsentStatus status) Get all consents for chosen ConsentHub with the specified statusgetConsentsForUser
(PerunSession sess, int id) Get all consents for chosen UsergetConsentsForUser
(PerunSession sess, int id, ConsentStatus status) Get all consents for chosen User with the specified statusgetConsentsForUserAndConsentHub
(PerunSession sess, int userId, int consentHubId) Get list of consents for user and consent hubgetFacilitiesForConsentHub
(ConsentHub consentHub) Get list of all facilities associated to the given Consent Hubvoid
removeFacility
(PerunSession sess, ConsentHub consentHub, Facility facility) Removes facility from consent hub.void
updateConsentHub
(PerunSession sess, ConsentHub consentHub) Updates the consent hub.
-
Field Details
-
CONSENT_HUB_MAPPING_SELECT_QUERY
- See Also:
-
CONSENT_HUB_MAPPER
-
-
Constructor Details
-
ConsentsManagerImpl
-
-
Method Details
-
addFacility
public void addFacility(PerunSession sess, ConsentHub consentHub, Facility facility) throws FacilityAlreadyAssigned Description copied from interface:ConsentsManagerImplApi
Adds facility to consent hub.- Specified by:
addFacility
in interfaceConsentsManagerImplApi
- Parameters:
sess
- sessionconsentHub
- consent hubfacility
- facility to be added- Throws:
FacilityAlreadyAssigned
- if facility is already assigned to consent hub
-
changeConsentStatus
Description copied from interface:ConsentsManagerImplApi
Set consent status- Specified by:
changeConsentStatus
in interfaceConsentsManagerImplApi
- Parameters:
sess
- perun sessionconsent
- consent
-
checkConsentExists
Description copied from interface:ConsentsManagerImplApi
Check if consent exists in underlying data source.- Specified by:
checkConsentExists
in interfaceConsentsManagerImplApi
- Parameters:
sess
- PerunSessionconsent
- Consent to check- Throws:
ConsentNotExistsException
- if consent doesn't exist
-
checkConsentHubExists
public void checkConsentHubExists(PerunSession sess, ConsentHub consentHub) throws ConsentHubNotExistsException Description copied from interface:ConsentsManagerImplApi
Throws exception if consent hub does not exist.- Specified by:
checkConsentHubExists
in interfaceConsentsManagerImplApi
- Parameters:
sess
- sessionconsentHub
- consent hub- Throws:
ConsentHubNotExistsException
- if consent hub does not exist
-
consentExists
Description copied from interface:ConsentsManagerImplApi
Check if consent exists in underlying data source.- Specified by:
consentExists
in interfaceConsentsManagerImplApi
- Parameters:
sess
- perun sessionconsent
- Consent to check- Returns:
- true if consent exists in data source, false otherwise
-
consentHubExists
Description copied from interface:ConsentsManagerImplApi
Returns true, if consent hub exists, false otherwise.- Specified by:
consentHubExists
in interfaceConsentsManagerImplApi
- Parameters:
sess
- sessionconsentHub
- consent hub- Returns:
- whether consent hub exists
-
createConsent
public Consent createConsent(PerunSession perunSession, Consent consent) throws ConsentExistsException Description copied from interface:ConsentsManagerImplApi
Save consent to database.- Specified by:
createConsent
in interfaceConsentsManagerImplApi
- Parameters:
perunSession
- PerunSessionconsent
- Consent- Returns:
- created consent
- Throws:
ConsentExistsException
- if consent already exists
-
createConsentHub
Description copied from interface:ConsentsManagerImplApi
Creates new consent hub.- Specified by:
createConsentHub
in interfaceConsentsManagerImplApi
- Parameters:
sess
- sessionconsentHub
- consent hub- Returns:
- new consent hub
-
deleteConsent
public void deleteConsent(PerunSession perunSession, Consent consent) throws ConsentNotExistsException Description copied from interface:ConsentsManagerImplApi
Delete consent from the database.- Specified by:
deleteConsent
in interfaceConsentsManagerImplApi
- Parameters:
perunSession
- PerunSessionconsent
- Consent- Throws:
ConsentNotExistsException
- if consent doesn't exist
-
deleteConsentHub
public void deleteConsentHub(PerunSession perunSession, ConsentHub consentHub) throws ConsentHubAlreadyRemovedException Description copied from interface:ConsentsManagerImplApi
Deletes the consent hub.- Specified by:
deleteConsentHub
in interfaceConsentsManagerImplApi
- Parameters:
perunSession
- sessionconsentHub
- consent hub- Throws:
ConsentHubAlreadyRemovedException
-
getAllConsentHubs
Description copied from interface:ConsentsManagerImplApi
Get list of all Consent Hubs- Specified by:
getAllConsentHubs
in interfaceConsentsManagerImplApi
- Parameters:
sess
- perun session- Returns:
- list of Consent Hubs
-
getAllConsents
Description copied from interface:ConsentsManagerImplApi
Gel all consents- Specified by:
getAllConsents
in interfaceConsentsManagerImplApi
- Parameters:
sess
- PerunSession- Returns:
- all existing consents in the database
-
getConsentById
Description copied from interface:ConsentsManagerImplApi
Get consent object with specified id- Specified by:
getConsentById
in interfaceConsentsManagerImplApi
- Parameters:
sess
- perun sessionid
- id of desired consent object- Returns:
- consent object with specified id
- Throws:
ConsentNotExistsException
- thrown if consent with the id doesn't exist
-
getConsentForUserAndConsentHub
public Consent getConsentForUserAndConsentHub(PerunSession sess, int userId, int consentHubId, ConsentStatus status) throws ConsentNotExistsException Description copied from interface:ConsentsManagerImplApi
Get consent for chosen user in specified consent hub with specified status- Specified by:
getConsentForUserAndConsentHub
in interfaceConsentsManagerImplApi
- Parameters:
sess
- PerunSessionuserId
- id of the userconsentHubId
- id of the consent hubstatus
- chosen status- Returns:
- consent for chosen user in specified consent hub with specified status
- Throws:
ConsentNotExistsException
- if consent doesn't exist
-
getConsentHubByFacility
public ConsentHub getConsentHubByFacility(PerunSession sess, int facilityId) throws ConsentHubNotExistsException Description copied from interface:ConsentsManagerImplApi
Finds existing Consent Hub by facility.- Specified by:
getConsentHubByFacility
in interfaceConsentsManagerImplApi
- Parameters:
sess
- perun sessionfacilityId
- facility for which consent hub is searched- Returns:
- found Consent Hub
- Throws:
ConsentHubNotExistsException
- if Consent Hub with the specified name doesn't exist
-
getConsentHubById
Description copied from interface:ConsentsManagerImplApi
Finds existing Consent Hub by id.- Specified by:
getConsentHubById
in interfaceConsentsManagerImplApi
- Parameters:
sess
- perun sessionid
- id of the Consent Hub you are looking for- Returns:
- found Consent Hub
- Throws:
ConsentHubNotExistsException
- if Consent Hub with the specified id doesn't exist
-
getConsentHubByName
public ConsentHub getConsentHubByName(PerunSession sess, String name) throws ConsentHubNotExistsException Description copied from interface:ConsentsManagerImplApi
Finds existing Consent Hub by name.- Specified by:
getConsentHubByName
in interfaceConsentsManagerImplApi
- Parameters:
sess
- perun sessionname
- name of the Consent Hub you are looking for- Returns:
- found Consent Hub
- Throws:
ConsentHubNotExistsException
- if Consent Hub with the specified name doesn't exist
-
getConsentHubsByService
Description copied from interface:ConsentsManagerImplApi
Finds all existing Consent Hubs by service (service is assigned to them)- Specified by:
getConsentHubsByService
in interfaceConsentsManagerImplApi
- Parameters:
session
- perun sessionserviceId
- service for which consent hubs are searched- Returns:
- list of consent hubs that have given service assigned to them
-
getConsentsForConsentHub
Description copied from interface:ConsentsManagerImplApi
Get all consents for chosen ConsentHub with the specified status- Specified by:
getConsentsForConsentHub
in interfaceConsentsManagerImplApi
- Parameters:
sess
- PerunSessionid
- id of the ConsentHubstatus
- status of the consent- Returns:
- consents for chosen ConsentHub with the specified status
-
getConsentsForConsentHub
Description copied from interface:ConsentsManagerImplApi
Get all consents for chosen ConsentHub- Specified by:
getConsentsForConsentHub
in interfaceConsentsManagerImplApi
- Parameters:
sess
- PerunSessionid
- id of the ConsentHub- Returns:
- consents for chosen ConsentHub
-
getConsentsForUser
Description copied from interface:ConsentsManagerImplApi
Get all consents for chosen User with the specified status- Specified by:
getConsentsForUser
in interfaceConsentsManagerImplApi
- Parameters:
sess
- PerunSessionid
- id of the Userstatus
- status of the consent- Returns:
- consents for chosen User with the specified status
-
getConsentsForUser
Description copied from interface:ConsentsManagerImplApi
Get all consents for chosen User- Specified by:
getConsentsForUser
in interfaceConsentsManagerImplApi
- Parameters:
sess
- PerunSessionid
- id of the user- Returns:
- consents for chosen User
-
getConsentsForUserAndConsentHub
public List<Consent> getConsentsForUserAndConsentHub(PerunSession sess, int userId, int consentHubId) Description copied from interface:ConsentsManagerImplApi
Get list of consents for user and consent hub- Specified by:
getConsentsForUserAndConsentHub
in interfaceConsentsManagerImplApi
- Parameters:
sess
- PerunSessionuserId
- id of the userconsentHubId
- id of the consent hub- Returns:
- list of consents for the user and consent hub
-
getFacilitiesForConsentHub
Description copied from interface:ConsentsManagerImplApi
Get list of all facilities associated to the given Consent Hub- Specified by:
getFacilitiesForConsentHub
in interfaceConsentsManagerImplApi
- Parameters:
consentHub
- Consent Hub- Returns:
- list of facilities
-
removeFacility
public void removeFacility(PerunSession sess, ConsentHub consentHub, Facility facility) throws RelationNotExistsException Description copied from interface:ConsentsManagerImplApi
Removes facility from consent hub.- Specified by:
removeFacility
in interfaceConsentsManagerImplApi
- Parameters:
sess
- sessionconsentHub
- consent hubfacility
- facility to be removed- Throws:
RelationNotExistsException
- if facility is not assigned to consent hub
-
updateConsentHub
public void updateConsentHub(PerunSession sess, ConsentHub consentHub) throws ConsentHubExistsException Description copied from interface:ConsentsManagerImplApi
Updates the consent hub. Ignores related facilities.- Specified by:
updateConsentHub
in interfaceConsentsManagerImplApi
- Parameters:
sess
- sessionconsentHub
- consent hub- Throws:
ConsentHubExistsException
- if consent hub with the same name exists
-