public class WattDepotPersistenceImpl extends WattDepotPersistence
| Constructor and Description |
|---|
WattDepotPersistenceImpl(ServerProperties properties)
Creates a new WattDepotImpl instance with the given ServerProperties.
|
getServerProperties, initializeMeasurementTypes, initializeSensorModels, setServerPropertiespublic WattDepotPersistenceImpl(ServerProperties properties)
properties - The ServerProperties.public CollectorProcessDefinition defineCollectorProcessDefinition(String id, String name, String sensorId, Long pollingInterval, String depositoryId, Set<Property> properties, String orgId) throws UniqueIdException, MisMatchedOwnerException, IdNotFoundException, BadSlugException
WattDepotPersistencedefineCollectorProcessDefinition in class WattDepotPersistenceid - The unique id.name - The unique name.sensorId - The id of the Sensor to poll.pollingInterval - The polling interval.depositoryId - The id of the depository to use.properties - The properties associated with this
CollectorProcessDefinition.orgId - the id of the owner of the CollectorProcessDefinitionUniqueIdException - if the id is already used for another
CollectorProcessDefinintion.MisMatchedOwnerException - if the given owner doesn't match the
owners of the Sensor or Depository.IdNotFoundException - if the sensorId or orgId are not defined.BadSlugException - if the given id isn't valid.public Depository defineDepository(String id, String name, MeasurementType measurementType, String orgId) throws UniqueIdException, IdNotFoundException, BadSlugException
WattDepotPersistencedefineDepository in class WattDepotPersistenceid - The unique id.name - The name.measurementType - the Measurement Type.orgId - the id of the owner of the WattDepository.UniqueIdException - if the id is already used for another
WattDepository.IdNotFoundException - if the orgId is not defined.BadSlugException - if the id isn't valid.public MeasurementPruningDefinition defineMeasurementPruningDefinition(String id, String name, String depositoryId, String sensorId, String orgId, Integer ignore, Integer collect, Integer gap) throws UniqueIdException, BadSlugException, IdNotFoundException
WattDepotPersistencedefineMeasurementPruningDefinition in class WattDepotPersistenceid - The id of the garbage collection definition.name - The name of the garbage collection definition.depositoryId - The id of the depository.sensorId - The id of the sensor.orgId - The organization id.ignore - The number of days to ignore starting from now.collect - The number of days to garbage collect in.gap - The minimum gap between measurements in seconds.UniqueIdException - if the id derived from name is already defined.BadSlugException - if the id isn't valid.IdNotFoundException - If the depository, sensor or organization are
not defined.public MeasurementType defineMeasurementType(String id, String name, String units) throws UniqueIdException, BadSlugException
WattDepotPersistencedefineMeasurementType in class WattDepotPersistenceid - The unique id.name - the name of the MeasurementType.units - the units for the MeasurementType. Must be a
javax.measure.unit.Unit toString() value.UniqueIdException - if the id derived from name is already defined.BadSlugException - if the id isn't valid.public Organization defineOrganization(String id, String name, Set<String> users) throws UniqueIdException, BadSlugException, IdNotFoundException
defineOrganization in class WattDepotPersistenceid - The unique id.name - The unique name.users - The members of the group.UniqueIdException - If the id is already used for another
Organization.BadSlugException - if the id isn't valid.IdNotFoundException - if the user's are not defined.public Sensor defineSensor(String id, String name, String uri, String modelId, Set<Property> properties, String orgId) throws UniqueIdException, MisMatchedOwnerException, IdNotFoundException, BadSlugException
defineSensor in class WattDepotPersistenceid - The unique id.name - The name of the sensor.uri - The URI for the sensor.modelId - The id of the SensorModel.properties - the properties associated with this Sensor.orgId - the id of the owner of the Sensor.UniqueIdException - if the id is already used for another Sensor.MisMatchedOwnerException - if the given owner doesn't match the
owners of the SensorModel.IdNotFoundException - if modelId, or orgId are not actual Ids.BadSlugException - if the id isn't valid.public SensorGroup defineSensorGroup(String id, String name, Set<String> sensorIds, String orgId) throws UniqueIdException, MisMatchedOwnerException, IdNotFoundException, BadSlugException
defineSensorGroup in class WattDepotPersistenceid - The unique id.name - The unique name.sensorIds - A set of the Sensors that make up the SensorGrouporgId - the owner of the SensorGroup.UniqueIdException - if the id is already used for another
SensorGroup.MisMatchedOwnerException - if the given owner doesn't match the
owners of the Sensors.IdNotFoundException - if sensorIds, or orgId are not actual Ids.BadSlugException - id the id isn't valid.public SensorModel defineSensorModel(String id, String name, String protocol, String type, String version) throws UniqueIdException, BadSlugException
WattDepotPersistencedefineSensorModel in class WattDepotPersistenceid - The unique id.name - The unique name.protocol - The protocol used by a meter.type - The type of the meter.version - The version the meter is using.UniqueIdException - if the id is already used for another
SensorModel.BadSlugException - if the id isn't valid.public UserInfo defineUserInfo(String id, String firstName, String lastName, String email, String orgId, Set<Property> properties, String password) throws UniqueIdException, IdNotFoundException
WattDepotPersistencedefineUserInfo in class WattDepotPersistenceid - The unique userId.firstName - The user's name.lastName - The user's last name.email - The user's email address.orgId - The id of the user's organization.properties - The additional properties of the user.password - the password for the user.UniqueIdException - if the id is already used for another UserInfo.IdNotFoundException - Organization is not defined.public void deleteCollectorProcessDefinition(String id, String orgId) throws IdNotFoundException, MisMatchedOwnerException
WattDepotPersistencedeleteCollectorProcessDefinition in class WattDepotPersistenceid - The unique id of the CollectorProcessDefinition.orgId - the group id of the user making the request.IdNotFoundException - If the id is not known or defined.MisMatchedOwnerException - if the orgId doesn't match the owner of
the sensor process.public void deleteDepository(String id, String orgId) throws IdNotFoundException, MisMatchedOwnerException
WattDepotPersistencedeleteDepository in class WattDepotPersistenceid - The unique id of the WattDepository.orgId - the group id of the user making the request.IdNotFoundException - If the id is not known or defined.MisMatchedOwnerException - if the orgId doesn't match the owner of
the sensor process.public void deleteMeasurementPruningDefinition(String id, String orgId) throws IdNotFoundException
WattDepotPersistencedeleteMeasurementPruningDefinition in class WattDepotPersistenceid - The id of the MeasurementPruningDefinition to delete.orgId - The Organization's id.IdNotFoundException - if the id is not defined.public void deleteMeasurement(String depotId, String orgId, String measId) throws IdNotFoundException
deleteMeasurement in class WattDepotPersistencedepotId - the id of the Depository storing the measurement.orgId - the id of the Organization.measId - The id of the measurement to delete.IdNotFoundException - if there is a problem with the ids.public void deleteMeasurementType(String id) throws IdNotFoundException
WattDepotPersistencedeleteMeasurementType in class WattDepotPersistenceid - The unique id for the MeasurementType to delete.IdNotFoundException - if the id is not a known MeasurementType.public void deleteOrganization(String id) throws IdNotFoundException
deleteOrganization in class WattDepotPersistenceid - The unique id of the Organization.IdNotFoundException - If the id is not known or defined.public void deleteSensor(String id, String orgId) throws IdNotFoundException, MisMatchedOwnerException
WattDepotPersistencedeleteSensor in class WattDepotPersistenceid - The unique id of the Sensor.orgId - the group id of the user making the request.IdNotFoundException - If the id is not known or defined.MisMatchedOwnerException - if the orgId doesn't match the owner of
the sensor.public void deleteSensorGroup(String id, String orgId) throws IdNotFoundException, MisMatchedOwnerException
WattDepotPersistencedeleteSensorGroup in class WattDepotPersistenceid - The unique id of the SensorGroup.orgId - the group id of the user making the request.IdNotFoundException - If the id is not known or defined.MisMatchedOwnerException - if the orgId doesn't match the owner of
the sensor group.public void deleteSensorModel(String id) throws IdNotFoundException
WattDepotPersistencedeleteSensorModel in class WattDepotPersistenceid - The unique id of the SensorModel.IdNotFoundException - If the id is not known or defined.public void deleteUser(String id, String orgId) throws IdNotFoundException
deleteUser in class WattDepotPersistenceid - The unique id of the User.orgId - the id of the organization the user is a member.IdNotFoundException - If the id is not known or defined.public void deleteUserPassword(String userId, String orgId) throws IdNotFoundException
deleteUserPassword in class WattDepotPersistenceuserId - The id of the UserPassword to delete.orgId - the user's organization id.IdNotFoundException - If the id is not known or defined.public CollectorProcessDefinition getCollectorProcessDefinition(String id, String orgId, boolean check) throws IdNotFoundException
getCollectorProcessDefinition in class WattDepotPersistenceid - The unique id for the CollectorProcessDefinition.orgId - the group id of the user making the request.check - true if want to check the ids.IdNotFoundException - if either id is not defined.public List<String> getCollectorProcessDefinitionIds(String orgId, boolean check) throws IdNotFoundException
getCollectorProcessDefinitionIds in class WattDepotPersistenceorgId - the id of the owner Organization.check - true if want to check the ids.IdNotFoundException - if the orgId is not defined.public List<CollectorProcessDefinition> getCollectorProcessDefinitions(String orgId, boolean check) throws IdNotFoundException
getCollectorProcessDefinitions in class WattDepotPersistenceorgId - the group id of the user making the request.check - true if want to check the ids.IdNotFoundException - if the orgId is not defined.public List<Depository> getDepositories(String orgId, boolean check) throws IdNotFoundException
getDepositories in class WattDepotPersistenceorgId - the group id of the user making the request.check - true if want to check the ids.IdNotFoundException - if orgId is not defined.public Depository getDepository(String id, String orgId, boolean check) throws IdNotFoundException
getDepository in class WattDepotPersistenceid - The unique id for the Depository to get.orgId - the id of the owner's Organization.check - true if want to check the ids.IdNotFoundException - if either id is not defined.public List<String> getDepositoryIds(String orgId, boolean check) throws IdNotFoundException
getDepositoryIds in class WattDepotPersistenceorgId - the id of the owner UserGroup.check - true if want to check the ids.IdNotFoundException - if orgId is not defined.public InterpolatedValue getEarliestMeasuredValue(String depotId, String orgId, String sensorId, boolean check) throws NoMeasurementException, IdNotFoundException
getEarliestMeasuredValue in class WattDepotPersistencedepotId - the id of the Depository.orgId - the Organziation's id.sensorId - The id of the Sensor making the measurements.check - true if want to check the ids.NoMeasurementException - If there aren't any measurements around the
time.IdNotFoundException - if there is a problem with the ids.public MeasurementPruningDefinition getMeasurementPruningDefinition(String id, String orgId, boolean check) throws IdNotFoundException
getMeasurementPruningDefinition in class WattDepotPersistenceid - The id of the MeasurementPruningDefinition.orgId - The Organization's id.check - true if want to check the ids.IdNotFoundException - if the id is not defined.public List<String> getMeasurementPruningDefinitionIds(String orgId, boolean check) throws IdNotFoundException
getMeasurementPruningDefinitionIds in class WattDepotPersistenceorgId - The Organization's id.check - true if want to check the ids.IdNotFoundException - if there is a problem with the ids.public List<MeasurementPruningDefinition> getMeasurementPruningDefinitions(String orgId, boolean check) throws IdNotFoundException
getMeasurementPruningDefinitions in class WattDepotPersistenceorgId - The Organization's id.check - true if want to check the ids.IdNotFoundException - If there is a problem with the ids.public InterpolatedValue getLatestMeasuredValue(String depotId, String orgId, String sensorId, boolean check) throws NoMeasurementException, IdNotFoundException
getLatestMeasuredValue in class WattDepotPersistencedepotId - the id of the Depository.orgId - the Organziation's id.sensorId - The id of the Sensor making the measurements.check - true if want to check the ids.NoMeasurementException - If there aren't any measurements around the
time.IdNotFoundException - if there is a problem with the ids.public InterpolatedValue getLatestMeasuredValue(String depotId, String orgId, String sensorId, Long window, boolean check) throws NoMeasurementException, IdNotFoundException
getLatestMeasuredValue in class WattDepotPersistencedepotId - the id of the Depository.orgId - the Organziation's id.sensorId - The id of the Sensor making the measurements.window - The number of seconds to consider for latest.check - true if want to check the ids.NoMeasurementException - If there aren't any measurements around the
time.IdNotFoundException - if there is a problem with the ids.public Measurement getMeasurement(String depotId, String orgId, String measId, boolean check) throws IdNotFoundException
getMeasurement in class WattDepotPersistencedepotId - the id of the Depository storing the measurements.orgId - the Organziation's id.measId - The measurement id.check - true if want to check the ids.IdNotFoundException - if there are problems with the ids.public List<Measurement> getMeasurements(String depotId, String orgId, String sensorId, boolean check) throws IdNotFoundException
getMeasurements in class WattDepotPersistencedepotId - the id of the Depository storing the measurements.orgId - the Organziation's id.sensorId - the id of the Sensor.check - true if want to check the ids.IdNotFoundException - if there is a problem with the ids.public List<Measurement> getMeasurements(String depotId, String orgId, String sensorId, Date start, Date end, boolean check) throws IdNotFoundException
getMeasurements in class WattDepotPersistencedepotId - the id of the Depository storing the measurements.orgId - the Organziation's id.sensorId - The id of the Sensor.start - The start of the interval.end - The end of the interval.check - true if want to check the ids.IdNotFoundException - if there is a problem with the ids.public Long getMeasurementsCount(String orgId, boolean check) throws IdNotFoundException
getMeasurementsCount in class WattDepotPersistenceorgId - the Organziation's id.check - true if want to check the ids.IdNotFoundException - if there is a problem with the id.public Long getMeasurementsCount(String depotId, String orgId, String sensorId, boolean check) throws IdNotFoundException
getMeasurementsCount in class WattDepotPersistencedepotId - the id of the Depository storing the measurements.orgId - the Organziation's id.sensorId - the id of the Sensor.check - true if want to check the ids.IdNotFoundException - if there is a problem with the ids.public Long getMeasurementsCount(String depotId, String orgId, String sensorId, Date start, Date end, boolean check) throws IdNotFoundException
getMeasurementsCount in class WattDepotPersistencedepotId - the id of the Depository storing the measurements.orgId - the Organziation's id.sensorId - The id of the Sensor.start - The start of the interval.end - The end of the interval.check - true if want to check the ids.IdNotFoundException - if there is a problem with the ids.public MeasurementType getMeasurementType(String id, boolean check) throws IdNotFoundException
getMeasurementType in class WattDepotPersistenceid - The unique id for the MeasurementType.check - true if want to check the ids.IdNotFoundException - if the id is not defined.public List<MeasurementType> getMeasurementTypes()
getMeasurementTypes in class WattDepotPersistencepublic Organization getOrganization(String id, boolean check) throws IdNotFoundException
getOrganization in class WattDepotPersistenceid - the unique id for the Organization.check - true if want to check the ids.IdNotFoundException - if the id isn't a defined Organization's id.public List<String> getOrganizationIds()
getOrganizationIds in class WattDepotPersistencepublic List<Organization> getOrganizations()
getOrganizations in class WattDepotPersistencepublic MeasurementRateSummary getRateSummary(String depotId, String orgId, String sensorId, boolean check) throws IdNotFoundException, NoMeasurementException
getRateSummary in class WattDepotPersistencedepotId - The depository id.orgId - The organization id.sensorId - The Sensor id.check - true if want to check the ids.IdNotFoundException - if there is a problem with the ids.NoMeasurementException - if there aren't any measurements.public Sensor getSensor(String id, String orgId, boolean check) throws IdNotFoundException
getSensor in class WattDepotPersistenceid - The unique id for the Sensor.orgId - the group id of the user making the request.check - true if want to check the ids.IdNotFoundException - if the ids are not defined.public SensorGroup getSensorGroup(String id, String orgId, boolean check) throws IdNotFoundException
getSensorGroup in class WattDepotPersistenceid - The unique id for the SensorGroup.orgId - the group id of the user making the request.check - true if want to check the ids.IdNotFoundException - if the ids are not defined.public List<String> getSensorGroupIds(String orgId, boolean check) throws IdNotFoundException
getSensorGroupIds in class WattDepotPersistenceorgId - the id of the owner UserGroup.check - true if want to check the ids.IdNotFoundException - if orgId is not defined.public List<SensorGroup> getSensorGroups(String orgId, boolean check) throws IdNotFoundException
getSensorGroups in class WattDepotPersistenceorgId - the id of the Organization owning the SensorGroups.check - true if want to check the ids.IdNotFoundException - if the orgId is not defined.public List<String> getSensorIds(String orgId, boolean check) throws IdNotFoundException
getSensorIds in class WattDepotPersistenceorgId - the id of the owner UserGroup.check - true if want to check the ids.IdNotFoundException - if orgId is not defined.public SensorModel getSensorModel(String id, boolean check) throws IdNotFoundException
getSensorModel in class WattDepotPersistenceid - The unique id for the SensorModel.check - true if want to check the ids.IdNotFoundException - if id isn't a defined SensorModel id.public List<String> getSensorModelIds()
getSensorModelIds in class WattDepotPersistencepublic List<SensorModel> getSensorModels()
getSensorModels in class WattDepotPersistencepublic List<Sensor> getSensors(String orgId, boolean check) throws IdNotFoundException
getSensors in class WattDepotPersistenceorgId - the group id of the user making the request.check - true if want to check the ids.IdNotFoundException - if orgId is not defined.public int getSessionClose()
getSessionClose in class WattDepotPersistencepublic int getSessionOpen()
getSessionOpen in class WattDepotPersistencepublic SensorMeasurementSummary getSummary(String depotId, String orgId, String sensorId, Date start, Date end, boolean check) throws IdNotFoundException
getSummary in class WattDepotPersistencedepotId - The depository id.orgId - The organization id.sensorId - The Sensor id.start - The start of the period.end - The end of the period.check - true if want to check the ids.IdNotFoundException - if there is a problem with the ids.public UserInfo getUser(String id, String orgId, boolean check) throws IdNotFoundException
getUser in class WattDepotPersistenceid - the unique id for the UserInfo.orgId - the id of the organization the user is in.check - true if want to check the ids.IdNotFoundException - if the combination of id and orgId isn't a
defined UserInfo.public List<String> getUserIds(String orgId, boolean check) throws IdNotFoundException
getUserIds in class WattDepotPersistenceorgId - the id of the organization the user is in.check - true if want to check the ids.IdNotFoundException - if orgId is not defined.public UserPassword getUserPassword(String id, String orgId, boolean check) throws IdNotFoundException
getUserPassword in class WattDepotPersistenceid - The user's id.orgId - the id of the organization the user is in.check - true if want to check the ids.IdNotFoundException - if id and orgId aren't a defined UserPassword.public List<UserInfo> getUsers()
getUsers in class WattDepotPersistencepublic List<UserInfo> getUsers(String orgId, boolean check) throws IdNotFoundException
getUsers in class WattDepotPersistenceorgId - the id of the organization the user is in.check - true if want to check the ids.IdNotFoundException - if orgId is not defined.public Double getValue(String depotId, String orgId, String sensorId, Date timestamp, boolean check) throws NoMeasurementException, IdNotFoundException
getValue in class WattDepotPersistencedepotId - the id of the depository.orgId - the Organziation's id.sensorId - The id of the Sensor making the measurements.timestamp - The time of the value.check - true if want to check the ids.NoMeasurementException - If there aren't any measurements around the
time.IdNotFoundException - if there is a problem with the ids.public Double getValue(String depotId, String orgId, String sensorId, Date start, Date end, boolean check) throws NoMeasurementException, IdNotFoundException
getValue in class WattDepotPersistencedepotId - the id of the depository.orgId - the Organziation's id.sensorId - The id of the Sensor making the measurements.start - The start of the period.end - The end of the period.check - true if want to check the ids.NoMeasurementException - if there are no measurements around the
start or end time.IdNotFoundException - if there is a problem with the ids.public Double getValue(String depotId, String orgId, String sensorId, Date start, Date end, Long gapSeconds, boolean check) throws NoMeasurementException, MeasurementGapException, IdNotFoundException
getValue in class WattDepotPersistencedepotId - the id of the depository.orgId - the Organziation's id.sensorId - The id of the Sensor making the measurements.start - The start of the interval.end - The end of the intervalgapSeconds - The maximum number of seconds that measurements need to
be within the start and end.check - true if want to check the ids.NoMeasurementException - if there are no measurements around the
start or end time.MeasurementGapException - if the measurements around start or end are
too far apart.IdNotFoundException - if there is a problem with the ids.public Double getValue(String depotId, String orgId, String sensorId, Date timestamp, Long gapSeconds, boolean check) throws NoMeasurementException, MeasurementGapException, IdNotFoundException
getValue in class WattDepotPersistencedepotId - the id of the depository.orgId - the Organziation's id.sensorId - The id of the Sensor making the measurements.timestamp - The time of the value.gapSeconds - The maximum number of seconds that measurements need to
be within the start and end.check - true if want to check the ids.NoMeasurementException - If there aren't any measurements around the
time.MeasurementGapException - if the measurements around timestamp are
too far apart.IdNotFoundException - if there is a problem with the ids.public List<String> listSensors(String depotId, String orgId, boolean check) throws IdNotFoundException
listSensors in class WattDepotPersistencedepotId - the id of the depository.orgId - the id of the organization.check - if true checks the ids.IdNotFoundException - if there is a problem with the ids.public void putMeasurement(String depotId, String orgId, Measurement meas) throws MeasurementTypeException, IdNotFoundException
putMeasurement in class WattDepotPersistencedepotId - the id of the Depository.orgId - the Organization's id.meas - The measurement to store.MeasurementTypeException - if the type of the measurement doesn't
match the Depository measurement type.IdNotFoundException - if there is a problem with the ids.public void putMeasurementList(String depotId, String orgId, MeasurementList measurementList) throws MeasurementTypeException, IdNotFoundException
putMeasurementList in class WattDepotPersistencedepotId - the id of the Depository.orgId - the Organization's id.measurementList - The list of measurements to store.MeasurementTypeException - if the type of one of the measurements doesn't
match the Depository measurement type.IdNotFoundException - if there is a problem with the ids.public void stop()
WattDepotPersistencestop in class WattDepotPersistencepublic CollectorProcessDefinition updateCollectorProcessDefinition(CollectorProcessDefinition process) throws IdNotFoundException
WattDepotPersistenceupdateCollectorProcessDefinition in class WattDepotPersistenceprocess - The updated CollectorProcessDefinition.IdNotFoundException - if there is a problem with the ids in the
CollectorProcessDefinition.public MeasurementPruningDefinition updateMeasurementPruningDefinition(MeasurementPruningDefinition gcd) throws IdNotFoundException
WattDepotPersistenceupdateMeasurementPruningDefinition in class WattDepotPersistencegcd - The updated MeasurementPruningDefinition.IdNotFoundException - If there is a problem with the ids.public MeasurementType updateMeasurementType(MeasurementType type)
WattDepotPersistenceupdateMeasurementType in class WattDepotPersistencetype - The updated MeasurementType.public Organization updateOrganization(Organization org) throws IdNotFoundException
updateOrganization in class WattDepotPersistenceorg - The updated Organization.IdNotFoundException - if the given Organization is not defined.public Sensor updateSensor(Sensor sensor) throws IdNotFoundException
WattDepotPersistenceupdateSensor in class WattDepotPersistencesensor - The updated Sensor.IdNotFoundException - if there are problems with the ids.public SensorGroup updateSensorGroup(SensorGroup group) throws IdNotFoundException
WattDepotPersistenceupdateSensorGroup in class WattDepotPersistencegroup - The updated SensorGroup.IdNotFoundException - if there is a problem with the ids.public SensorModel updateSensorModel(SensorModel model) throws IdNotFoundException
WattDepotPersistenceupdateSensorModel in class WattDepotPersistencemodel - The updated SensorModel.IdNotFoundException - if the SensorModel isn't in persistence.public UserInfo updateUserInfo(UserInfo user) throws IdNotFoundException
updateUserInfo in class WattDepotPersistenceuser - The updated UserInfo.IdNotFoundException - if the user isn't in the persistence.public UserPassword updateUserPassword(UserPassword password) throws IdNotFoundException
updateUserPassword in class WattDepotPersistencepassword - The UserPassword to update.IdNotFoundException - if the password is not in persistence.Copyright © 2015 Collaborative Software Development Laboratory. All rights reserved.