stella.xml
Class TypeHelper

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.xml.TypeHelper
All Implemented Interfaces:
Cloneable, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying
Direct Known Subclasses:
JTypeHelper

public class TypeHelper
extends PropertyBundles
implements Initializable

A type helper knows how to match a special object type on a given telescope to default setups. It knows how to construct the following items using ElementHelpers:


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  Map constraints
          The constraints as a map of element helpers to their variables.
private  List daughters
          The list of daughter targets.
private static String DEFABSTRACT
          The default abstract.
private static String DEFACCESS
          The default access.
private static String DEFPROPOSAL
          The default abstract.
private static String DEFREQUIRES
          The default roof-open condition.
private static String DEFURLRESOURCES
          The default path.
private  Map exceptions
          The exceptions, if any, a mapping of element helpers to 'for'.
private  Map fitsheaders
          The mapping of fits-headers, as element headers, to fits IDs.
private  Map gains
          The gains, a map of element helpers to their classes.
static String KEY_ABSTRACT
          The abstract section.
static String KEY_ACCESS
          The access to this target.
static String KEY_CONSTRAINTS
          A list of constraints properties, as ElementHelpers.
static String KEY_DAUGHTERS
          The list of daughters.
static String KEY_EXCEPTIONS
          A list of setup properties, as ElementHelpers.
static String KEY_FITSHEADERS
          A list of fitsheader properties, as ElementHelpers.
static String KEY_GAINS
          A list of gain properties, as ElementHelpers.
static String KEY_HELPERCLASS
          The key mapping to the type helper class name.
static String KEY_OBJECTS
          A list of object IDs.
static String KEY_PROPOSAL
          The proposal section, an attribute to abstract.
static String KEY_RATEHOW
          A list of constraints properties, as ElementHelpers.
static String KEY_RATEWHEN
          The requirement in the select section.
static String KEY_REQUIRES
          The requirement in the select section.
static String KEY_SEQUENCE
          The observing sequence this type requires.
static String KEY_SETUPS
          A list of setup properties, as ElementHelpers.
static String KEY_SUCCESSOR
          The successor target.
static String KEY_TIMESLOTS
          A list of timeslot properties, as ElementHelpers.
static String KEY_TYPE
          The type of object this helper is bound to.
private  Map objects
          The mapping of object, as object helpers to object IDs.
private  Map rate
          The rating constraints as a map of element helpers to variables.
private  Map setups
          The mapping of instrument setups, as element helpers, to setup ID.
private  Map timeslots
          The time-slots, a map of element helpers to their classes.
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
TypeHelper(Map prop)
          Constructs a new type helper.
 
Method Summary
 boolean addAbstractFragment(Map xml)
          Adds the abstract section as a part of a TargetFactory mapping.
 boolean addConstraint(String file)
          Add a constraint by a named resource.
 boolean addDaughterFragment(Map xml)
          Adds the daughters to the target fragments of the TargetFactory mapping.
 boolean addExceptionFragment(Map xml)
          Adds the exception maps as a part of a TargetFactory mapping.
 boolean addFitsHeaderFragment(Map xml)
          Adds the fits headers sections to the target fragments.
 boolean addObjectFragment(Map xml)
          Adds the object helpers as object-fagements to the TargetFactory mapping.
 boolean addRateFragment(Map xml)
          Adds the rate criterium as a part of a TargetFactory mapping.
 boolean addRating(String file)
          Add a rating by a named resource.
 boolean addSelectFragment(Map xml)
          Adds the select criterium as a part of a TargetFactory mapping.
 boolean addSetupFragment(Map xml)
          Adds the setup sections as a part of a TargetFactory mapping.
 boolean addSuccessorFragment(Map xml)
          Adds the successor to the target fragment of the TargetFactory mapping.
private static List createConstraintElements(Collection constraints)
          Converts ElementHelpers into constraint elements.
private  List createElementHelpers(String props)
          Converts a comma-separated list of property files into a list of ElementHelpers by reading the properties and passing them to the element helper constructor.
private  Map createHelperMap(String props)
          Converts a comma-separted list of proprty files into a mapping of {ElementHelpers to keys queried from the helpers by asking their property named according to the second argument.
private static List createMeritElements(String tag, Collection merit)
          Converts ElementHelpers into Merit elements.
protected  void error(String warn)
          Issues an error message.
private  ElementHelper fromResourceName(String file)
          Creates a single element helper from a specified named resource, normally a properties file.
 String getAbstract()
          Returns the abstract.
 String getAccess()
          Returns the access flag of the target.
 Collection getAllConstraints()
          Returns the list of constraints as a list of ElementHelpers.
 Collection getAllExceptions()
          Returns a collection of all exceptions as a collection of ElementHelpers.
 Collection getAllFitsHeaders()
          Returns the fits headers as a collections of ElementHelpers.
 Collection getAllGains()
          Returns the list of gains as a list of ElementHelpers.
 Collection getAllObjects()
          Returns the objects as a collections of ObjectHelpers.
 Collection getAllRatings()
          Returns the list of rating constraints as a collection of ElementHelpers.
 Collection getAllSetups()
          Returns the setups as a collection of ElementHelpers.
 Collection getAllTimeslots()
          Returns the list of timeslots as a list of ElementHelpers.
 ElementHelper getConstraintByID(Object whom)
          Returns the constraint which applies to the variable of the given name.
 List getDaughters()
          Returns a string-list of daughter targets or null.
 ElementHelper getExceptionByID(String whom)
          Returns the exception element helper with the given 'for' attribute.
 ElementHelper getFitsHeaderByID(String id)
          Returns the fitsheader element helper with the given ID attribute.
 ElementHelper getGainByID(Object clname)
          Returns the gain with has the specified class.
 ObjectHelper getObjectByID(String id)
          Returns the object helper with the given ID attribute.
 String getProposal()
          Returns the proposal.
 String getRateWhen()
          Returns the requirement for object selection as a string.
 ElementHelper getRatingByID(Object whom)
          Returns the rating constraint which applies to the variable of the given name.
 String getRequirement()
          Returns the requirement for object selection as a string.
 String getSequence()
          Returns the observing sequence for this type.
 ElementHelper getSetupByID(String id)
          Returns the setup element helper with the given ID attribute.
 String getSuccessor()
          Returns the successor target or null.
 ElementHelper getTimeslotByID(Object clname)
          Returns the timeslot with has the specified class.
 String getType()
          Returns the type this helper is bound to.
protected  void info(String warn)
          Issues an info message.
 void init()
          Uses the property files provided for the KEY_CONSTRAINTS, KEY_TIMESLOTS, KEY_GAINS, KEY_EXCEPTIONS, KEY_SETUPS, KEY_OBJECTS, and KEY_FITSHEADERS to construct the specified lists of element helpers.
 void setAbstract(String abstr)
          Sets the abstract.
 void setAccess(String newacc)
          Sets the access flag.
 void setDaughters(List dau)
          Sets the list of daughters.
 void setProposal(String abstr)
          Sets the abstract.
 void setRateWhen(String req)
          Sets the requirement for object selection.
 void setRequirement(String req)
          Sets the requirement for object selection.
 void setSequence(String seq)
          Sets the sequence type.
 void setSuccessor(String succ)
          Sets the successor target.
protected  void warn(String warn)
          Issues a warning message.
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 

Field Detail

KEY_HELPERCLASS

public static final String KEY_HELPERCLASS
The key mapping to the type helper class name.

See Also:
Constant Field Values

KEY_TYPE

public static final String KEY_TYPE
The type of object this helper is bound to.

See Also:
Constant Field Values

KEY_SEQUENCE

public static final String KEY_SEQUENCE
The observing sequence this type requires.

See Also:
Constant Field Values

KEY_ACCESS

public static final String KEY_ACCESS
The access to this target.

See Also:
Constant Field Values

KEY_ABSTRACT

public static final String KEY_ABSTRACT
The abstract section.

See Also:
Constant Field Values

KEY_PROPOSAL

public static final String KEY_PROPOSAL
The proposal section, an attribute to abstract.

See Also:
Constant Field Values

KEY_REQUIRES

public static final String KEY_REQUIRES
The requirement in the select section.

See Also:
Constant Field Values

KEY_CONSTRAINTS

public static final String KEY_CONSTRAINTS
A list of constraints properties, as ElementHelpers.

See Also:
Constant Field Values

KEY_RATEWHEN

public static final String KEY_RATEWHEN
The requirement in the select section.

See Also:
Constant Field Values

KEY_RATEHOW

public static final String KEY_RATEHOW
A list of constraints properties, as ElementHelpers.

See Also:
Constant Field Values

KEY_TIMESLOTS

public static final String KEY_TIMESLOTS
A list of timeslot properties, as ElementHelpers.

See Also:
Constant Field Values

KEY_GAINS

public static final String KEY_GAINS
A list of gain properties, as ElementHelpers.

See Also:
Constant Field Values

KEY_EXCEPTIONS

public static final String KEY_EXCEPTIONS
A list of setup properties, as ElementHelpers.

See Also:
Constant Field Values

KEY_SETUPS

public static final String KEY_SETUPS
A list of setup properties, as ElementHelpers.

See Also:
Constant Field Values

KEY_OBJECTS

public static final String KEY_OBJECTS
A list of object IDs. Each object must be set per name.

See Also:
Constant Field Values

KEY_FITSHEADERS

public static final String KEY_FITSHEADERS
A list of fitsheader properties, as ElementHelpers.

See Also:
Constant Field Values

KEY_DAUGHTERS

public static final String KEY_DAUGHTERS
The list of daughters.

See Also:
Constant Field Values

KEY_SUCCESSOR

public static final String KEY_SUCCESSOR
The successor target.

See Also:
Constant Field Values

DEFURLRESOURCES

private static final String DEFURLRESOURCES
The default path.

See Also:
Constant Field Values

DEFACCESS

private static final String DEFACCESS
The default access.

See Also:
Constant Field Values

DEFABSTRACT

private static final String DEFABSTRACT
The default abstract.

See Also:
Constant Field Values

DEFPROPOSAL

private static final String DEFPROPOSAL
The default abstract.

See Also:
Constant Field Values

DEFREQUIRES

private static final String DEFREQUIRES
The default roof-open condition.

See Also:
Constant Field Values

constraints

private Map constraints
The constraints as a map of element helpers to their variables.


timeslots

private Map timeslots
The time-slots, a map of element helpers to their classes.


gains

private Map gains
The gains, a map of element helpers to their classes.


rate

private Map rate
The rating constraints as a map of element helpers to variables.


exceptions

private Map exceptions
The exceptions, if any, a mapping of element helpers to 'for'.


setups

private Map setups
The mapping of instrument setups, as element helpers, to setup ID.


fitsheaders

private Map fitsheaders
The mapping of fits-headers, as element headers, to fits IDs.


objects

private Map objects
The mapping of object, as object helpers to object IDs.


daughters

private List daughters
The list of daughter targets.

Constructor Detail

TypeHelper

public TypeHelper(Map prop)
Constructs a new type helper. The properties supplied should be specific for the object type and the telescope. Only the very basic KEY_ABSTRACT and the KEY_REQUIRES are defaulted.

Method Detail

init

public void init()
Uses the property files provided for the KEY_CONSTRAINTS, KEY_TIMESLOTS, KEY_GAINS, KEY_EXCEPTIONS, KEY_SETUPS, KEY_OBJECTS, and KEY_FITSHEADERS to construct the specified lists of element helpers.

Specified by:
init in interface Initializable
Overrides:
init in class PropertyResources

addAbstractFragment

public boolean addAbstractFragment(Map xml)
Adds the abstract section as a part of a TargetFactory mapping. The text of the abstract is submitted to the TargetFactory#createAbstract} method, if the abstract text is defined.

Returns:
True, if abstract was added.

addSelectFragment

public boolean addSelectFragment(Map xml)
Adds the select criterium as a part of a TargetFactory mapping. This requires that the KEY_REQUIRES is set, that all constraints are valid, and that all timeslots and gains are defined and valid. The constrains are converted from ElementHelpers to a list of ParsedTarget.Constraints by passing all variables, which are present as doubles, to the ParsedTarget.Constraint constructor. The merits are converted into lists of merits using the TargetFactory.createMerit(java.lang.String, java.lang.String, java.lang.String, java.util.Map) method.

Returns:
True, if select was added.

addRateFragment

public boolean addRateFragment(Map xml)
Adds the rate criterium as a part of a TargetFactory mapping. This allows that the KEY_RATEWHEN is set and that all constraints specified are valid. The constrains are converted from ElementHelpers to a list of ParsedTarget.Constraints by passing all variables, which are present as doubles, to the ParsedTarget.Constraint constructor.

Returns:
True, if rate was added.

addExceptionFragment

public boolean addExceptionFragment(Map xml)
Adds the exception maps as a part of a TargetFactory mapping. All exception elements are non-obligatory, thus no validity checking is done.


addSetupFragment

public boolean addSetupFragment(Map xml)
Adds the setup sections as a part of a TargetFactory mapping. First, the setups are tested for validity, then they are added to the target factory.


addFitsHeaderFragment

public boolean addFitsHeaderFragment(Map xml)
Adds the fits headers sections to the target fragments. According to the TargetFactory.createFitsHeader(java.lang.String, java.util.List, java.util.Map) method, the list added to the document fragment must already be a list of FITSheader elements. These are constructed with the TargetFactory.createInternFitsHeader(java.lang.String, java.lang.String, java.lang.String) method.
Fits entries are ElementHelpers, but here the keys in the UserAdjustable.getVariables()-returned map are already the fits keys, the values linked to them are the variable names. If comments should be added, they are merged into the user-adjustable map with keys ending as ElementHelper.KEY_APPENDIX.


addObjectFragment

public boolean addObjectFragment(Map xml)
Adds the object helpers as object-fagements to the TargetFactory mapping. If any object is not valid, no object is added.


addDaughterFragment

public boolean addDaughterFragment(Map xml)
Adds the daughters to the target fragments of the TargetFactory mapping.


addSuccessorFragment

public boolean addSuccessorFragment(Map xml)
Adds the successor to the target fragment of the TargetFactory mapping.


getType

public String getType()
Returns the type this helper is bound to. This property is always set, if object survived initialization.


getAccess

public String getAccess()
Returns the access flag of the target.


setAccess

public void setAccess(String newacc)
Sets the access flag.


getSequence

public String getSequence()
Returns the observing sequence for this type.


setSequence

public void setSequence(String seq)
Sets the sequence type. Normally users do not need to change this.


getAbstract

public String getAbstract()
Returns the abstract.


setAbstract

public void setAbstract(String abstr)
Sets the abstract.


getProposal

public String getProposal()
Returns the proposal.


setProposal

public void setProposal(String abstr)
Sets the abstract.


getRequirement

public String getRequirement()
Returns the requirement for object selection as a string.


setRequirement

public void setRequirement(String req)
Sets the requirement for object selection.


getRateWhen

public String getRateWhen()
Returns the requirement for object selection as a string.


setRateWhen

public void setRateWhen(String req)
Sets the requirement for object selection.


getDaughters

public List getDaughters()
Returns a string-list of daughter targets or null.


setDaughters

public void setDaughters(List dau)
Sets the list of daughters.


getSuccessor

public String getSuccessor()
Returns the successor target or null.


setSuccessor

public void setSuccessor(String succ)
Sets the successor target.


getAllConstraints

public Collection getAllConstraints()
Returns the list of constraints as a list of ElementHelpers. Can be null.


getConstraintByID

public ElementHelper getConstraintByID(Object whom)
Returns the constraint which applies to the variable of the given name.


addConstraint

public boolean addConstraint(String file)
Add a constraint by a named resource.


getAllRatings

public Collection getAllRatings()
Returns the list of rating constraints as a collection of ElementHelpers. Can be null.


getRatingByID

public ElementHelper getRatingByID(Object whom)
Returns the rating constraint which applies to the variable of the given name.


addRating

public boolean addRating(String file)
Add a rating by a named resource.


getAllTimeslots

public Collection getAllTimeslots()
Returns the list of timeslots as a list of ElementHelpers. Can be null.


getTimeslotByID

public ElementHelper getTimeslotByID(Object clname)
Returns the timeslot with has the specified class.


getAllGains

public Collection getAllGains()
Returns the list of gains as a list of ElementHelpers. Can be null.


getGainByID

public ElementHelper getGainByID(Object clname)
Returns the gain with has the specified class.


getAllExceptions

public Collection getAllExceptions()
Returns a collection of all exceptions as a collection of ElementHelpers. Can be null.


getExceptionByID

public ElementHelper getExceptionByID(String whom)
Returns the exception element helper with the given 'for' attribute.


getAllSetups

public Collection getAllSetups()
Returns the setups as a collection of ElementHelpers. Always defined if object survived initialization.


getSetupByID

public ElementHelper getSetupByID(String id)
Returns the setup element helper with the given ID attribute.


getAllFitsHeaders

public Collection getAllFitsHeaders()
Returns the fits headers as a collections of ElementHelpers. Can be null.


getFitsHeaderByID

public ElementHelper getFitsHeaderByID(String id)
Returns the fitsheader element helper with the given ID attribute.


getAllObjects

public Collection getAllObjects()
Returns the objects as a collections of ObjectHelpers. Can be null.


getObjectByID

public ObjectHelper getObjectByID(String id)
Returns the object helper with the given ID attribute.


error

protected void error(String warn)
Issues an error message. This class pipes directly to Syslog.error.


warn

protected void warn(String warn)
Issues a warning message. This class pipes directly to Syslog.warning.


info

protected void info(String warn)
Issues an info message. This class pipes directly to Syslog.info.


fromResourceName

private ElementHelper fromResourceName(String file)
Creates a single element helper from a specified named resource, normally a properties file.


createElementHelpers

private List createElementHelpers(String props)
Converts a comma-separated list of property files into a list of ElementHelpers by reading the properties and passing them to the element helper constructor.


createHelperMap

private Map createHelperMap(String props)
Converts a comma-separted list of proprty files into a mapping of {ElementHelpers to keys queried from the helpers by asking their property named according to the second argument. A warning is issued if two identical mappings exist, in which case only the later on is kept. Note that this method can only work correctly if the value of the ID-field is already set after initialization, i.e. it must be specified in the ElementHelper.KEY_INIT section.


createConstraintElements

private static List createConstraintElements(Collection constraints)
Converts ElementHelpers into constraint elements. This is done by constructing ParsedTarget#Constraints on fully-qulified element helpers. The validity of those has been checked, thus no further tests are commenced.


createMeritElements

private static List createMeritElements(String tag,
                                        Collection merit)
Converts ElementHelpers into Merit elements. This is done by invoking the TargetFactory.createMerit(java.lang.String, java.lang.String, java.lang.String, java.util.Map) method on fully-qulified element helpers. The validity of those has been check, thus no further test are commenced.