org.lsst.ccs.config
Class Factories

java.lang.Object
  extended by org.lsst.ccs.config.Factories

public class Factories
extends Object

A set of static methods to be used on Configuration service client's side : they are hiding some implementation details to the "outside" world. To be used in conjunction with ConfigurationFacade (but these codes may be called locally without referring to a server)

Author:
bamade

Constructor Summary
Factories()
           
 
Method Summary
static ConfigProfile copyProfile(ConfigProfile toBeCopied, String newName, String newTag, String newUserName, int newLevel, boolean toEngineering)
          to be used to create a copy of configuration with different name , tag, etc.
static ConfigProfile createConfigProfile(SubsystemDescription subsystemDesc, String name, String tag, String userName, int level)
          Creates a new ConfigProfile with ParameterConfiguration where values are just copied from the Description default value.
static ParameterConfiguration createParameterConfiguration(ParameterDescription description)
          factory method to create a ParameterConfiguration object
static ParameterConfiguration createParameterConfiguration(ParameterDescription description, String value)
          factory method to create a ParameterConfiguration object
static ParameterDescription createParameterDescription(ParameterBase parameterBase, String description, String simpleName, String constraints, int level)
          factory method to create a new ParameterDescription.
static ParameterDescription createParameterDescription(ParameterDescription other)
          factory method to create a new ParameterDescription from another one.
static ConfigProfile createRawConfigProfile(SubsystemDescription subsystemDesc, String name, String tag, String userName, int level)
          Creates a new ConfigProfile that has no ParameterConfiguration (and so is not ready to be persisted).
static SubsystemDescription createRawSubsystemDescription(String subsystemName, String tag, String user, String version, InputStream inputStream, String charSetName)
          creates a "raw" subsystem description by reading a groovy text from file.
static SubsystemDescription createRawSubsystemDescription(String subsystemName, String tag, String user, String version, Serializable configurationData, DataFlavour dataFlavour)
          Creates a new SubsystemDescription without any ParameterDescription creation.
static SubsystemDescription createSubsystemDescription(String subsystemName, String tag, String user, String version, Serializable configurationData, DataFlavour dataFlavour, ParameterFilter filter)
          creates a new SubsystemDescription populated with "empty" ParameterDescriptions.
static SubsystemDescription createSubsystemDescriptionCopy(SubsystemDescription desc)
          creates a new SubsystemDescription from another.
static ConfigProfile repair(ConfigProfile oldProfile, SubsystemDescription newDescription, ConfigurationMismatchListener mismatchListener)
          tries to create a new ConfigProfile from an old one.
static void tryCopyParameters(SubsystemDescription newDescription, SubsystemDescription model, DescriptionMismatchListener mismatchListener)
          tries to copy ParameterDescription from a model to a new subsystem description.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Factories

public Factories()
Method Detail

createRawSubsystemDescription

public static SubsystemDescription createRawSubsystemDescription(String subsystemName,
                                                                 String tag,
                                                                 String user,
                                                                 String version,
                                                                 Serializable configurationData,
                                                                 DataFlavour dataFlavour)
Creates a new SubsystemDescription without any ParameterDescription creation. The object is not registered in the database since it is to be populated by ParameterDescription objects.

To populate the descriptions get the base descriptions from the Subsystemdescription by calling a version of getBaseParameters or getParameterDescriptions and generate the descriptions from these bases.

Parameters:
subsystemName -
tag -
user -
version -
configurationData -
dataFlavour -
Returns:

createRawSubsystemDescription

public static SubsystemDescription createRawSubsystemDescription(String subsystemName,
                                                                 String tag,
                                                                 String user,
                                                                 String version,
                                                                 InputStream inputStream,
                                                                 String charSetName)
creates a "raw" subsystem description by reading a groovy text from file.

Parameters:
subsystemName -
tag -
user -
version -
inputStream -
charSetName -
Returns:

createSubsystemDescription

public static SubsystemDescription createSubsystemDescription(String subsystemName,
                                                              String tag,
                                                              String user,
                                                              String version,
                                                              Serializable configurationData,
                                                              DataFlavour dataFlavour,
                                                              ParameterFilter filter)
creates a new SubsystemDescription populated with "empty" ParameterDescriptions. The object is not in the database since the list of descriptions should be modified first.

TODO: this method will be modified to populate with parameterDescriptions that are not necessarily empty.

Parameters:
subsystemName -
tag -
user -
version -
configurationData -
dataFlavour -
filter -
Returns:

createSubsystemDescriptionCopy

public static SubsystemDescription createSubsystemDescriptionCopy(SubsystemDescription desc)
creates a new SubsystemDescription from another. The other one could be active of deprecated data: this method is meant to create another subsystemdescription were only the ParameterDescription are to be changed. not that the list of ParameterDescription may be populated (if the model have some) and then that this set is to be modified (the resulting object is not yet persisted in the database).

Parameters:
desc -
Returns:

createParameterDescription

public static ParameterDescription createParameterDescription(ParameterBase parameterBase,
                                                              String description,
                                                              String simpleName,
                                                              String constraints,
                                                              int level)
factory method to create a new ParameterDescription. To be used by tools such as GUI

Parameters:
parameterBase -
description -
simpleName -
constraints -
level -
Returns:

createParameterDescription

public static ParameterDescription createParameterDescription(ParameterDescription other)
factory method to create a new ParameterDescription from another one.

Parameters:
other -
Returns:

tryCopyParameters

public static void tryCopyParameters(SubsystemDescription newDescription,
                                     SubsystemDescription model,
                                     DescriptionMismatchListener mismatchListener)
tries to copy ParameterDescription from a model to a new subsystem description. each ParameterDescription is checked against the configData (if not compatible it is rejected and a Listener is notified).

NOT IMPLEMENTED YET

Parameters:
newDescription - a subsystem description without any ParameterDescription
model -
mismatchListener - optional code that will be warned when inconsistencies occur

createRawConfigProfile

public static ConfigProfile createRawConfigProfile(SubsystemDescription subsystemDesc,
                                                   String name,
                                                   String tag,
                                                   String userName,
                                                   int level)
Creates a new ConfigProfile that has no ParameterConfiguration (and so is not ready to be persisted).

Parameters:
subsystemDesc - should be read from the database
name -
tag -
userName -
level -
Returns:
Throws:
IllegalArgumentException - if subsystemdescription not in database

createConfigProfile

public static ConfigProfile createConfigProfile(SubsystemDescription subsystemDesc,
                                                String name,
                                                String tag,
                                                String userName,
                                                int level)
Creates a new ConfigProfile with ParameterConfiguration where values are just copied from the Description default value.

Parameters:
subsystemDesc - should be already in the database
name -
tag -
userName -
level -
Returns:
Throws:
IllegalArgumentException - if subsystemdescription not in database

copyProfile

public static ConfigProfile copyProfile(ConfigProfile toBeCopied,
                                        String newName,
                                        String newTag,
                                        String newUserName,
                                        int newLevel,
                                        boolean toEngineering)
to be used to create a copy of configuration with different name , tag, etc. This is used mostly to go back and forth in Engineering mode: for instance start an Engineering mode with modification of parameters "on the fly"

when this is used to create an "engineering mode" profile it is mandatory that the profile to be copied is an active one (not a deprecated one)

Parameters:
toBeCopied - for the moment should be an "active" ConfigProfile (not a deprecated one)
newName -
newTag -
newUserName -
newLevel -
toEngineering -
Returns:

createParameterConfiguration

public static ParameterConfiguration createParameterConfiguration(ParameterDescription description,
                                                                  String value)
factory method to create a ParameterConfiguration object

Parameters:
description -
value -
Returns:

createParameterConfiguration

public static ParameterConfiguration createParameterConfiguration(ParameterDescription description)
factory method to create a ParameterConfiguration object

Parameters:
description -
Returns:

repair

public static ConfigProfile repair(ConfigProfile oldProfile,
                                   SubsystemDescription newDescription,
                                   ConfigurationMismatchListener mismatchListener)
tries to create a new ConfigProfile from an old one. The new one is matched to an active subsystemDescription

NOT IMPLEMENTED YET

Parameters:
oldProfile -
newDescription - an active subsystemDescription already registered in the databse
mismatchListener -
Returns:


Copyright © 2013 LSST. All Rights Reserved.