com.synthesisstudios.holmz.service
Interface Session

All Known Subinterfaces:
SuperSession

public interface Session


Method Summary
 void changePassword(java.lang.String oldPassword, java.lang.String newPassword)
          Changes the current users password.
 void clear()
          When data is laoded from the DB, it is cached to prevent loading the same object repeately.
 void close()
          Closes the session.
 User confirmUserAccount(java.lang.String confirmationCode)
          Confirms a user account.
 double convert(double num, Unit fromUnit, Unit toUnit)
          Converts a number from one unit to another unit of the same dimension.
 WorksheetAnswersUpdater createAnswers(Worksheet domain, java.lang.String objectKey)
          Creates a new WorksheetAnswersUpater for building a new WorksheetAnswers.
 Dimension createDimension(java.lang.String key, java.lang.String displayName, java.lang.String description, java.lang.String referenceUnitKey, java.lang.String referenceUnitSymbol, java.lang.String referenceUnitDisplayName, java.lang.String referenceUnitDescription, Units baseUnits)
          Creates a new Dimension and reference unit.
 Domain createDomain(java.lang.String key, java.lang.String displayName, java.lang.String description)
          Creates a new domain.
 EnumType createEnumType(java.lang.String key, java.lang.String displayName, java.lang.String description)
          Creates a new EnumType.
 EnumValue createEnumValue(EnumType enumType, java.lang.String key, java.lang.String displayName, java.lang.String description)
          Creates a new EnumValue for the specified EnumType.
 DomainObjectUpdater createObject(Domain domain, java.lang.String objectKey)
          Creates a new DomainObjectUpater for building a new DomainObject.
 PropertyUpdater createProperty(Domain domain, java.lang.String key)
          Gets a PropertyUpdater to create a new property.
 PropertyUpdater createProperty(Worksheet worksheet, java.lang.String key)
          Gets a PropertyUpdater to create a new property.
 Quantity createQuantity(double magnitude, Units units)
          Creates a Quantity object.
 Question createQuestion(Worksheet worksheet, java.lang.String key, java.lang.String text)
          Creates a new Question on the specified worksheet.
 RoleUpdater createRole(java.lang.String roleName)
          create a new role
 UnitUpdater createUnit(Dimension dim, java.lang.String key)
          Gets a UnitUpdater to create a new unit.
 UserUpdater createUser(java.lang.String username)
          create a new user
 Worksheet createWorksheet(java.lang.String key, java.lang.String displayName, java.lang.String description)
          Creates a new worksheet.
 void deleteAnswers(WorksheetAnswers object)
          Deletes the specified object.
 void deleteObject(DomainObject object)
          Deletes the specified object.
 boolean deleteRole(Role role)
          delete a role
 WorksheetAnswersUpdater editAnswers(WorksheetAnswers object)
          Creates a new WorksheetAnswersUpater for editing an existing WorksheetAnswers.
 DimensionUpdater editDimension(Dimension dimension)
          Gets a DimensionUpdater to edit a dimension.
 DomainUpdater editDomain(Domain domain)
          Gets a DomainUpdater to edit a domain.
 EnumTypeUpdater editEnumType(EnumType enumType)
          Creates an EnumTypeUpdater to edit the given EnumType
 EnumValueUpdater editEnumValue(EnumValue enumValue)
          Creates an EnumValueUpdater to edit the given EnumValue
 DomainObjectUpdater editObject(DomainObject object)
          Creates a new DomainObjectUpater for editing an existing DomainObject.
 PropertyUpdater editProperty(Property property)
          Gets a PropertyUpdater to edit a property.
 QuestionUpdater editQuestion(Question question)
          Gets a QuestionUpdater to edit a question.
 RoleUpdater editRole(Role role)
          get the role updater for a given role
 UnitUpdater editUnit(Unit unit)
          Gets a UnitUpdater to edit the given unit.
 UserUpdater editUser(User user)
          get the user updater for a user
 WorksheetUpdater editWorksheet(Worksheet worksheet)
          Gets a WorksheetUpdater to edit a worksheet.
 java.lang.Object evaluate(Formula formula)
          Evaluates the given formula in the root environment.
 java.lang.Object evaluate(Formula formula, Environment environment)
          Evaluates the given formula in the given environment.
 java.lang.String generateUserConfirmationCode(User user)
          Generates a user confirmation code that can be emailed to a user to confirm their account.
 PropertyType getBooleanPropertyType()
           
 User getCurrentUser()
          Gets the user with which this session is associated.
 Dimension getDimension(java.lang.String key)
          Gets a Dimension via its unique key.
 java.util.List<Dimension> getDimensions()
          Gets all defined quantities.
 Domain getDomain(java.lang.String key)
          Gets a domain using its unique key.
 java.util.List<Domain> getDomains()
          Gets a list of all the domains in the database.
 Units getEmptyUnits()
          Gets a Units object that contains no units.
 PropertyType getEnumPropertyType(EnumType enumType)
           
 EnumType getEnumType(java.lang.String key)
          Looks up the EnumType with the specified key.
 java.util.List<EnumType> getEnumTypes()
          Gets a list of all the EnumTypes in the database.
 PropertyType getMultivaluePropertyType(PropertyType baseType, int minSize, int maxSize)
           
 PropertyType getNumberPropertyType()
           
 PropertyType getObjectPropertyType(DomainObject root)
           
 Role getRole(java.lang.String roleName)
          Gets a role by name.
 java.util.List<Role> getRoles()
          Gets a list of all the roles in the system.
 Environment getRootEnvironment()
          Gets the root environment for evaluating formulas.
 PropertyType getStringPropertyType()
           
 PropertyType getTimestampPropertyType()
           
 Unit getUnit(java.lang.String key)
          Gets a Unit via its unique key -- this will first look up the unit by its key, and then will look it up by its symbol second.
 java.util.List<Unit> getUnits(Dimension dimension)
          Gets the units for the given dimension.
 User getUser(java.lang.String username)
          get a user
 java.util.List<User> getUsers()
          get all the users
 Worksheet getWorksheet(java.lang.String key)
          Gets a worksheet using its unique key.
 java.util.List<Worksheet> getWorksheets()
          Gets a list of all the worksheets in the database.
 Formula parseFormula(java.lang.String expression)
          Parses the given expression into a formula.
 PropertyType parsePropertyType(java.lang.String typeDescriptor)
          Parses a typeDescriptor into a PropertyType.
 Units parseUnits(java.lang.String units)
          Parses a units expression, such as "meter^2" or "miles/gallon"
 

Method Detail

clear

void clear()
When data is laoded from the DB, it is cached to prevent loading the same object repeately. This clear() method clears all cached data.


close

void close()
Closes the session. The session should not be used after calling this, and this method should be called when the session is no longer needed.


getCurrentUser

User getCurrentUser()
Gets the user with which this session is associated.


changePassword

void changePassword(java.lang.String oldPassword,
                    java.lang.String newPassword)
                    throws ValidationException
Changes the current users password.

Throws:
ValidationException

getRoles

java.util.List<Role> getRoles()
Gets a list of all the roles in the system.


getRole

Role getRole(java.lang.String roleName)
Gets a role by name. Returns null if the Role is not found.


createRole

RoleUpdater createRole(java.lang.String roleName)
                       throws PermissionException
create a new role

Throws:
PermissionException

editRole

RoleUpdater editRole(Role role)
                     throws PermissionException
get the role updater for a given role

Throws:
PermissionException

deleteRole

boolean deleteRole(Role role)
                   throws PermissionException
delete a role

Throws:
PermissionException

getUsers

java.util.List<User> getUsers()
get all the users


getUser

User getUser(java.lang.String username)
get a user


createUser

UserUpdater createUser(java.lang.String username)
                       throws PermissionException
create a new user

Throws:
PermissionException

editUser

UserUpdater editUser(User user)
                     throws PermissionException
get the user updater for a user

Throws:
PermissionException

generateUserConfirmationCode

java.lang.String generateUserConfirmationCode(User user)
                                              throws PermissionException
Generates a user confirmation code that can be emailed to a user to confirm their account.

Throws:
PermissionException

confirmUserAccount

User confirmUserAccount(java.lang.String confirmationCode)
                        throws PermissionException
Confirms a user account. If the confirmation code is valid, the user's account will be marked as confirmed and the User object returned.

Throws:
PermissionException

getDimensions

java.util.List<Dimension> getDimensions()
Gets all defined quantities.


getDimension

Dimension getDimension(java.lang.String key)
Gets a Dimension via its unique key. Returns null if not found.


getUnit

Unit getUnit(java.lang.String key)
Gets a Unit via its unique key -- this will first look up the unit by its key, and then will look it up by its symbol second. Returns null if not found.


getUnits

java.util.List<Unit> getUnits(Dimension dimension)
Gets the units for the given dimension.


createDimension

Dimension createDimension(java.lang.String key,
                          java.lang.String displayName,
                          java.lang.String description,
                          java.lang.String referenceUnitKey,
                          java.lang.String referenceUnitSymbol,
                          java.lang.String referenceUnitDisplayName,
                          java.lang.String referenceUnitDescription,
                          Units baseUnits)
                          throws PermissionException,
                                 ValidationException
Creates a new Dimension and reference unit.

Parameters:
key - The unique key that identifies this dimension, such as "length", "weight".
displayName - The display name for this dimension, such as "Length", "Weight".
description - A human readable description of this dimension.
referenceUnitKey - The unique key that identifies the reference unit, such as "meter".
referenceUnitSymbol - The short symbol for the unit, such as "m", or "s".
referenceUnitDisplayName - The singular name for the reference unit, such as "Meter".
referenceUnitDescription - A human readable description of the reference unit.
baseUnits - If this unit can be defined in terms of other units, those units can be specified here. For example, if defining "Enerty" and "Joule", base units could be specified as "kg*m^2/s^2"
Throws:
PermissionException - if the current user can't create dimensions
InvalidKeyException - if key or referenceUnitKey is invalid
NonUniqueKeyexception - if key or referenceUnitKey are not sufficiently unique.
InvalidDisplayNameException - if a displayName is invalid
ValidationException

editDimension

DimensionUpdater editDimension(Dimension dimension)
Gets a DimensionUpdater to edit a dimension.


createUnit

UnitUpdater createUnit(Dimension dim,
                       java.lang.String key)
                       throws PermissionException
Gets a UnitUpdater to create a new unit.

Throws:
InvalidKeyException - if key is invalid
NonUniqueKeyexception - if key is not unique.
PermissionException

editUnit

UnitUpdater editUnit(Unit unit)
                     throws PermissionException
Gets a UnitUpdater to edit the given unit.

Throws:
PermissionException

convert

double convert(double num,
               Unit fromUnit,
               Unit toUnit)
Converts a number from one unit to another unit of the same dimension.


parseUnits

Units parseUnits(java.lang.String units)
Parses a units expression, such as "meter^2" or "miles/gallon"


getEmptyUnits

Units getEmptyUnits()
Gets a Units object that contains no units.


createQuantity

Quantity createQuantity(double magnitude,
                        Units units)
Creates a Quantity object.


getEnumTypes

java.util.List<EnumType> getEnumTypes()
Gets a list of all the EnumTypes in the database.


getEnumType

EnumType getEnumType(java.lang.String key)
Looks up the EnumType with the specified key.


createEnumType

EnumType createEnumType(java.lang.String key,
                        java.lang.String displayName,
                        java.lang.String description)
                        throws PermissionException,
                               InvalidKeyException,
                               NonUniqueKeyException,
                               InvalidDisplayNameException
Creates a new EnumType.

Throws:
PermissionException
InvalidKeyException
NonUniqueKeyException
InvalidDisplayNameException

editEnumType

EnumTypeUpdater editEnumType(EnumType enumType)
                             throws PermissionException
Creates an EnumTypeUpdater to edit the given EnumType

Throws:
PermissionException

createEnumValue

EnumValue createEnumValue(EnumType enumType,
                          java.lang.String key,
                          java.lang.String displayName,
                          java.lang.String description)
                          throws PermissionException,
                                 InvalidKeyException,
                                 NonUniqueKeyException,
                                 InvalidDisplayNameException
Creates a new EnumValue for the specified EnumType.

Throws:
PermissionException
InvalidKeyException
NonUniqueKeyException
InvalidDisplayNameException

editEnumValue

EnumValueUpdater editEnumValue(EnumValue enumValue)
                               throws PermissionException
Creates an EnumValueUpdater to edit the given EnumValue

Throws:
PermissionException

getStringPropertyType

PropertyType getStringPropertyType()

getNumberPropertyType

PropertyType getNumberPropertyType()

getBooleanPropertyType

PropertyType getBooleanPropertyType()

getTimestampPropertyType

PropertyType getTimestampPropertyType()

getObjectPropertyType

PropertyType getObjectPropertyType(DomainObject root)

getEnumPropertyType

PropertyType getEnumPropertyType(EnumType enumType)

getMultivaluePropertyType

PropertyType getMultivaluePropertyType(PropertyType baseType,
                                       int minSize,
                                       int maxSize)

parsePropertyType

PropertyType parsePropertyType(java.lang.String typeDescriptor)
                               throws InvalidTypeDescriptorException
Parses a typeDescriptor into a PropertyType.

Throws:
InvalidTypeDescriptorException

getDomains

java.util.List<Domain> getDomains()
Gets a list of all the domains in the database.


getDomain

Domain getDomain(java.lang.String key)
Gets a domain using its unique key.


createDomain

Domain createDomain(java.lang.String key,
                    java.lang.String displayName,
                    java.lang.String description)
                    throws PermissionException,
                           ValidationException
Creates a new domain.

Throws:
PermissionException
ValidationException

editDomain

DomainUpdater editDomain(Domain domain)
                         throws PermissionException
Gets a DomainUpdater to edit a domain.

Throws:
PermissionException

getWorksheets

java.util.List<Worksheet> getWorksheets()
Gets a list of all the worksheets in the database.


getWorksheet

Worksheet getWorksheet(java.lang.String key)
Gets a worksheet using its unique key.


createWorksheet

Worksheet createWorksheet(java.lang.String key,
                          java.lang.String displayName,
                          java.lang.String description)
                          throws PermissionException,
                                 ValidationException
Creates a new worksheet.

Throws:
PermissionException
ValidationException

editWorksheet

WorksheetUpdater editWorksheet(Worksheet worksheet)
                               throws PermissionException
Gets a WorksheetUpdater to edit a worksheet.

Throws:
PermissionException

createProperty

PropertyUpdater createProperty(Domain domain,
                               java.lang.String key)
                               throws PermissionException,
                                      InvalidKeyException,
                                      NonUniqueKeyException
Gets a PropertyUpdater to create a new property.

Throws:
PermissionException
InvalidKeyException
NonUniqueKeyException

createProperty

PropertyUpdater createProperty(Worksheet worksheet,
                               java.lang.String key)
                               throws PermissionException,
                                      InvalidKeyException,
                                      NonUniqueKeyException
Gets a PropertyUpdater to create a new property.

Throws:
PermissionException
InvalidKeyException
NonUniqueKeyException

editProperty

PropertyUpdater editProperty(Property property)
                             throws PermissionException
Gets a PropertyUpdater to edit a property.

Throws:
PermissionException

createQuestion

Question createQuestion(Worksheet worksheet,
                        java.lang.String key,
                        java.lang.String text)
                        throws PermissionException,
                               InvalidKeyException
Creates a new Question on the specified worksheet.

Throws:
PermissionException
InvalidKeyException

editQuestion

QuestionUpdater editQuestion(Question question)
                             throws PermissionException
Gets a QuestionUpdater to edit a question.

Throws:
PermissionException

createObject

DomainObjectUpdater createObject(Domain domain,
                                 java.lang.String objectKey)
                                 throws PermissionException,
                                        ValidationException
Creates a new DomainObjectUpater for building a new DomainObject.

Throws:
NonUniqueKeyException
InvalidKeyException
PermissionException
ValidationException

editObject

DomainObjectUpdater editObject(DomainObject object)
                               throws PermissionException
Creates a new DomainObjectUpater for editing an existing DomainObject.

Throws:
PermissionException

deleteObject

void deleteObject(DomainObject object)
                  throws PermissionException,
                         ValidationException
Deletes the specified object.

Throws:
ValidationException - if the object has children that would be left orphaned.
PermissionException

createAnswers

WorksheetAnswersUpdater createAnswers(Worksheet domain,
                                      java.lang.String objectKey)
                                      throws PermissionException,
                                             ValidationException
Creates a new WorksheetAnswersUpater for building a new WorksheetAnswers.

Throws:
NonUniqueKeyException
InvalidKeyException
PermissionException
ValidationException

editAnswers

WorksheetAnswersUpdater editAnswers(WorksheetAnswers object)
                                    throws PermissionException
Creates a new WorksheetAnswersUpater for editing an existing WorksheetAnswers.

Throws:
PermissionException

deleteAnswers

void deleteAnswers(WorksheetAnswers object)
                   throws PermissionException,
                          ValidationException
Deletes the specified object.

Throws:
ValidationException - if the object has children that would be left orphaned.
PermissionException

parseFormula

Formula parseFormula(java.lang.String expression)
                     throws FormulaParseException
Parses the given expression into a formula.

Throws:
FormulaParseException

getRootEnvironment

Environment getRootEnvironment()
Gets the root environment for evaluating formulas.


evaluate

java.lang.Object evaluate(Formula formula,
                          Environment environment)
                          throws EvaluationException
Evaluates the given formula in the given environment.

Throws:
EvaluationException

evaluate

java.lang.Object evaluate(Formula formula)
                          throws EvaluationException
Evaluates the given formula in the root environment.

Throws:
EvaluationException