org.hackystat.telemetry.analyzer.configuration
Class TelemetryDefinitionInfoRepository

java.lang.Object
  extended by org.hackystat.telemetry.analyzer.configuration.TelemetryDefinitionInfoRepository

 class TelemetryDefinitionInfoRepository
extends java.lang.Object

The manager for TelemetryDefinitionInfo objects.

Warning: This class is NOT thread-safe.

V8 Notes: If/when we decide to provide project-level sharing, we need to enforce the condition that only one instance of a name can exist for a given project. Right now it appears that multiple users can create telemetry definitions with the same name with project scope.

I wonder why this class is not thread safe. Perhaps synchronization occurs at a higher level.

Author:
(Cedric) Qin Zhang

Constructor Summary
TelemetryDefinitionInfoRepository()
           
 
Method Summary
(package private)  void add(TelemetryDefinitionInfo telemetryDefInfo)
          Adds a telemetry definition to this in-memory repository.
(package private)  boolean exists(java.lang.String telemetryDefinitionName)
          Goes through all users, and checks whether there is a definition by name.
(package private)  TelemetryDefinitionInfo find(org.hackystat.sensorbase.resource.users.jaxb.User owner, java.lang.String name, boolean includeShared)
          Find the telemetry definition object by name.
(package private)  java.util.Collection<TelemetryDefinitionInfo> findAll(org.hackystat.sensorbase.resource.users.jaxb.User owner, boolean includesShared)
          Gets a list of telemetry definitions that this user has access to.
(package private)  void remove(org.hackystat.sensorbase.resource.users.jaxb.User owner, java.lang.String telemetryDefinitionName)
          Deletes a telemetry object definition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TelemetryDefinitionInfoRepository

TelemetryDefinitionInfoRepository()
Method Detail

find

TelemetryDefinitionInfo find(org.hackystat.sensorbase.resource.users.jaxb.User owner,
                             java.lang.String name,
                             boolean includeShared)
Find the telemetry definition object by name. This method returns null if the telemetry definition cannot be found.

Important Note that it's possible that there are multiple definitions with the same name (all have project level sharing, but owned by different users). In this case, any one of the definitions might be returned. The only guarantee is that if there are definitions in the project share scope and global share scope with the same name, the one in project share scope will be returned.

Parameters:
owner - The owner under which to find the telemetry definition object.
name - The name of the telemetry definition.
includeShared - If true, then those telemetry definitions owned by other users, but is shared will also be returned.
Returns:
An instance of TelemetryDefInfo object if found, or null.

findAll

java.util.Collection<TelemetryDefinitionInfo> findAll(org.hackystat.sensorbase.resource.users.jaxb.User owner,
                                                      boolean includesShared)
Gets a list of telemetry definitions that this user has access to.

Parameters:
owner - The owner of the telemetry definitions returned.
includesShared - If true, then those telemetry definitions owned by other users, but is shared will also be returned.
Returns:
A collection of TelemetryDefInfo objects.

add

void add(TelemetryDefinitionInfo telemetryDefInfo)
   throws TelemetryConfigurationException
Adds a telemetry definition to this in-memory repository.

Parameters:
telemetryDefInfo - Information about the definition to be added.
Throws:
TelemetryConfigurationException - If there is duplicated definition.

exists

boolean exists(java.lang.String telemetryDefinitionName)
Goes through all users, and checks whether there is a definition by name.

Parameters:
telemetryDefinitionName - The definition name.
Returns:
True if it exists.

remove

void remove(org.hackystat.sensorbase.resource.users.jaxb.User owner,
            java.lang.String telemetryDefinitionName)
Deletes a telemetry object definition. Only the owner can make the deletion. This method does nothing if the definition does not exist.

Parameters:
owner - The owner of the definition.
telemetryDefinitionName - The name of the definition.