|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.nrao.sss.model.project.ProgramBlock
public class ProgramBlock
A set of observations that share a common telescope configuration.
A ProgramBlock
is part of a Project
and describes in
detail how observations are to be completed.
A ProgramBlock
is also a container of SchedulingBlock
s.
Version Info:
$Revision: 2277 $ |
$Date: 2009-04-29 11:19:38 -0600 (Wed, 29 Apr 2009) $ |
$Author: dharland $ |
Field Summary | |
---|---|
static String |
DEFAULT_NAME
|
Fields inherited from interface edu.nrao.sss.util.Identifiable |
---|
UNIDENTIFIED |
Fields inherited from interface edu.nrao.sss.model.UserAccountable |
---|
NULL_USER_ID |
Constructor Summary | |
---|---|
ProgramBlock()
Creates a new instance. |
Method Summary | ||
---|---|---|
boolean |
addPrerequisite(ProgramBlock newPrereq)
Adds newPrereq to this program block's set of direct
prerequisites. |
|
void |
addSchedulingBlock(int idx,
SchedulingBlock schedBlock)
Adds the given scheduling block to this program block at index idx . |
|
void |
addSchedulingBlock(SchedulingBlock schedBlock)
Adds the given scheduling block to this program block. |
|
void |
appendComments(String additionalComments)
Adds additional comments to those already associated with this program block. |
|
void |
clearId()
Resets this pb's id to UNIDENTIFIED and calls all of it's SchedulingBlock's clearId() methods. |
|
ProgramBlock |
clone()
Returns a program block that is almost a copy of this one. |
|
ProgramBlock |
cloneWithoutPrerequisites()
Returns a program block that is almost a copy of this one. |
|
SchedulingBlock |
createSchedulingBlock()
Creates and returns a new scheduling block that is suitable for use with this program block. |
|
boolean |
equals(Object o)
Returns true if o is equal to this program block. |
|
static ProgramBlock |
fromXml(Reader reader)
Creates a new program block based on the XML data read from reader . |
|
static
|
fromXml(Reader reader,
Class<T> pbType)
Creates a new program block based on the XML data read from reader . |
|
static ProgramBlock |
fromXml(String xmlFile)
Creates a new program block from the XML data in the given file. |
|
static
|
fromXml(String xmlFile,
Class<T> pbType)
Creates a new program block from the XML data in the given file. |
|
List<TelescopeConfiguration> |
getAcceptableConfigurations()
Returns a list of the telescope configurations that are acceptable to this program block. |
|
Set<ProgramBlock> |
getAllPrerequisites()
Returns a set containing all direct and indirect prerequisites of this program block. |
|
String |
getComments()
Returns comments about this program block. |
|
Long |
getCreatedBy()
Returns the ID of the user who created this object. |
|
Date |
getCreatedOn()
Returns the date on which this object was created. |
|
Set<ProgramBlock> |
getDirectPrerequisites()
Returns this program block's set of direct prerequisites. |
|
EventSetStatus |
getExecutionStatus()
Returns this program block's execution status. |
|
Long |
getId()
|
|
Long |
getLastUpdatedBy()
Returns the ID of the user who most recently updated this object. |
|
Date |
getLastUpdatedOn()
Returns the most recent date on which this object was updated. |
|
String |
getLongName()
Deprecated. |
|
String |
getName()
Returns the name of this program block. |
|
static Comparator<ProgramBlock> |
getPrequisiteComparator()
Returns a comparator that places all prerequisites before the blocks that depend upon them. |
|
Project |
getProject()
Returns the project to which this program block belongs, if any. |
|
Collection<ScheduleEntry> |
getReadyToScheduleEntries(Collection<ScheduleEntry> destination)
Returns the schedule entries of this block that are ready for scheduling. |
|
Collection<ScheduleEntry> |
getScheduleEntries(EventStatus execStatus,
Collection<ScheduleEntry> destination)
Returns the schedule entries of this block that have an execution status of execStatus . |
|
List<SchedulingBlock> |
getSchedulingBlocks()
Returns the scheduling blocks that belong to this program block. |
|
List<SchedulingBlock> |
getSchedulingBlocksSortedByPrereqs()
Returns a list of this program block's scheduling blocks sorted such that any prerequisites of the block at index i are at in indices greater than i. |
|
String |
getShortName()
Deprecated. |
|
int |
hashCode()
|
|
boolean |
hasPrerequisites()
Returns true if this block has one or more prequisite blocks. |
|
boolean |
hasProject()
Returns true if this program block has a non-null project. |
|
boolean |
isDirectPrerequisiteOf(ProgramBlock progBlock)
Returns true if this program block is an direct prerequisite of progBlock . |
|
boolean |
isPrerequisiteOf(ProgramBlock progBlock)
Returns true if this program block is either a direct or indirect prerequisite of progBlock . |
|
boolean |
isProjectPartiallyScheduled()
Returns true if there is at least one scheduling block in the project that has been scheduled; false if there is nothing in the project that has been scheduled. |
|
boolean |
isTest()
Returns true if this block is part of a test project . |
|
void |
removeAllPrerequisites()
Clears this program block's set of prerequisites. |
|
void |
removeAllSchedulingBlocks()
Removes all scheduling blocks from this program block. |
|
boolean |
removePrerequisite(ProgramBlock oldPrereq)
Removes oldPrereq from this program block's set of
direct prerequisites. |
|
void |
removeSchedulingBlock(SchedulingBlock schedBlock)
Removes the given scheduling block from this program block. |
|
void |
reset()
Resets this project to its initial state. |
|
void |
setAcceptableConfigurations(List<TelescopeConfiguration> newList)
For use by Hibernate and JAXB. |
|
void |
setComments(String replacementComments)
Sets comments about this program block. |
|
void |
setCreatedBy(Long userId)
Sets the ID of the user who created this object. |
|
void |
setCreatedOn(Date d)
Sets the date on which this object was created. |
|
void |
setLastUpdatedBy(Long userId)
Sets the ID of the user who most recently updated this object. |
|
void |
setLastUpdatedOn(Date d)
Sets the date on which this object was most recently updated. |
|
void |
setLongName(String newName)
Deprecated. |
|
void |
setName(String newName)
Sets the name of this program block. |
|
void |
setProject(Project newProject)
Sets the project to which this program block belongs. |
|
void |
setShortName(String newName)
Deprecated. |
|
String |
toString()
Returns a text representation of this program block. |
|
String |
toSummaryString()
Returns a short textual description of this program block. |
|
String |
toXml()
Returns an XML representation of this program block. |
|
void |
writeAsXmlTo(Writer writer)
Writes an XML representation of this program block to writer . |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_NAME
Constructor Detail |
---|
public ProgramBlock()
Method Detail |
---|
public void reset()
public Long getId()
getId
in interface Identifiable
public void clearId()
public void setName(String newName)
If newName
is null or the empty string
(""), the request to change the name will be
denied and the current name will remain in place.
setName
in interface ProgBlock
newName
- the new name of this program block.public String getName()
getName
in interface ProgBlock
@Deprecated public String getLongName()
@Deprecated public void setLongName(String newName)
@Deprecated public String getShortName()
@Deprecated public void setShortName(String newName)
public void setAcceptableConfigurations(List<TelescopeConfiguration> newList)
setAcceptableConfigurations
in interface ProgBlock
public List<TelescopeConfiguration> getAcceptableConfigurations()
The returned list is guaranteed to be non-null. It will normally have one or more elements, but it is possible for it to be empty. This program block does no validation on the elements of the returned list. It could have repeated elements or elements that pertain to different kinds of telescopes. Ideally, though, the list will contain one or more configurations of the same telescope with no repeated entries.
The list returned is the one actually held by this program block.
This means that changes to the list made by a client after calling
this method will be reflected in this object. It also means
that to manipulate this list, clients must first fetch it using
this method; there is not equivalent set
method.
getAcceptableConfigurations
in interface ProgBlock
public void setProject(Project newProject)
If this program block is currently contained in a project
that is not the same as the newProject
parameter,
the current project will be told to remove this program block
from its collection of program blocks. If newProject
is not null, it will be told to add this program block
to its collection. Finally, this program block's project
will be set to newProject
, even if it is null.
Passing this method a newProject
of null has the
effect of disconnecting this program block from any project.
newProject
- the project to which this program block belongs.public Project getProject()
This program block may be one of several that belong to the same project. If this program block belongs to no project, the value returned is null.
hasProject()
public boolean hasProject()
Program blocks should normally be contained within, and therefore have a non-null, project. However, there are some situations where this method will return false:
getProject()
and know that
it will return a non-null object.public boolean isProjectPartiallyScheduled()
ProgBlock
isProjectPartiallyScheduled
in interface ProgBlock
public SchedulingBlock createSchedulingBlock()
public void addSchedulingBlock(SchedulingBlock schedBlock)
If schedBlock
is already part of this program block,
or if it is null, no action is taken.
Otherwise it is added to this program block, removed from
the program block to which it had been attached (if any),
and updated so that it knows it belongs to this program block.
schedBlock
- the scheduling block to be added to this program block.public void addSchedulingBlock(int idx, SchedulingBlock schedBlock)
idx
.
If schedBlock
is already part of this program block,
or if it is null, no action is taken.
Otherwise it is added to this program block, removed from
the program block to which it had been attached (if any),
and updated so that it knows it belongs to this program block.
idx
- the index in our list of scheduling blocks at which to add schedBlock
.schedBlock
- the scheduling block to be added to this program block.public void removeSchedulingBlock(SchedulingBlock schedBlock) throws ValidationException
If schedBlock
is null, or if it does
not belong to this program block, nothing happens.
If it is a prerequisite of one or more of the scheduling
blocks held by this program block, an exception is thrown
and it is not removed from this program block.
Otherwise, schedBlock
is removed from this
program block and has its program block attribute set to
null.
schedBlock
- the scheduling block to be removed.
ValidationException
- if schedBlock
is a prerequisite of one
or more of this program block's scheduling blocks.public void removeAllSchedulingBlocks()
public boolean hasPrerequisites()
public List<SchedulingBlock> getSchedulingBlocks()
The returned List
is a copy of the one held internally
by this program block, so changes made to it will not be reflected
herein.
public List<SchedulingBlock> getSchedulingBlocksSortedByPrereqs()
Note that the sort determines only how prerequisites and things dependent on them are place relative to one another. For example, imagine four blocks A, B, C, and D. C has A and B as prerequisites and no other block has prerequisites. The returned list will place C in a lower index than A and B. However, we know nothing about how A and B will be placed relative to each other, nor do we know ahead of time where D will be placed.
public Collection<ScheduleEntry> getScheduleEntries(EventStatus execStatus, Collection<ScheduleEntry> destination)
execStatus
. Only the status of the
entries is considered. This method does not look, for example, at the
isTest()
property.
execStatus
- the execution status of the schedule entries to be added
to destination
.destination
- the collection to which the schedule entries should be
added. If this collection is null, a new one
will be created. This collection is returned.
destination
or a new collection, if destination
is
null.getReadyToScheduleEntries(Collection)
public Collection<ScheduleEntry> getReadyToScheduleEntries(Collection<ScheduleEntry> destination)
destination
- the collection to which the ready-to-be-scheduled
entries should be added. If this collection is
null, a new one will be created. This
collection is returned.
destination
or a new collection, if destination
is
null.getScheduleEntries(EventStatus, Collection)
public boolean addPrerequisite(ProgramBlock newPrereq)
newPrereq
to this program block's set of direct
prerequisites. If this program block belongs to a project, and if
newPrereq
becomes a prerequisite of this one, then
newPrereq
is added to this project, because a program block that
is part of a project may have as prerequisites only those program blocks
that belong to the same project.
In order to prevent a circular chain of dependencies, newPrereq
will not be added to this program block's set if this block is
a prerequisite of newPrereq
.
Direct vs. Indirect Prerequisites
The prerequisite methods of this class often
refer to direct or indirect prerequisites. This section
explains the meanings of those terms. Consider this set of dependencies:
A)--+---------------+ |-->E)--+ | B)--+ | |-->G)-->H C |-->F)--+ D)----------+where the notation
X)-->Y
means that Y
is dependent on the
completion of X
or, alternatively, X
is a prerequisite of
Y
.
Program block E
has two prerequisites, A
and B
,
each of which is direct.
Program block F
has two direct prerequisites, D
and
E
, and two indirect prerequisites, A
and B
.
Program block G
is interesting because A
serves as both
a direct and an indirect (via F
and E
) prerequisite.
Methods that refer only to prerequisite without the direct or indirect adjective mean a prerequisite of any type.
newPrereq
- a new direct prerequisite for this program block.
newPrereq
was added to this program
block's set of direct prerequisites.newPrereq
is nullnewPrereq
is already an direct prerequisite
of this program blocknewPrereq
.
public boolean removePrerequisite(ProgramBlock oldPrereq)
oldPrereq
from this program block's set of
direct prerequisites.
(For an explanation of direct versus indirect
prequisites, see the note in the
addPrerequisite(ProgramBlock)
method.)
oldPrereq
- the prerequisite to be removed from this scheduling
block's set of direct prerequisites.
oldPrereq
was successfully removed.
Note that a return value of false might mean that
oldPrereq
was not an direct prerequisite of
this program block.public void removeAllPrerequisites()
public boolean isPrerequisiteOf(ProgramBlock progBlock)
progBlock
.
(For an explanation of direct versus indirect
prerequisites, see the note in the
addPrerequisite(ProgramBlock)
method.)
progBlock
- the program block to test.
progBlock
.isDirectPrerequisiteOf(ProgramBlock)
public boolean isDirectPrerequisiteOf(ProgramBlock progBlock)
progBlock
.
(For an explanation of direct versus indirect
prequisites, see the note in the
addPrerequisite(ProgramBlock)
method.)
progBlock
- the program block to test.
progBlock
.isPrerequisiteOf(ProgramBlock)
public Set<ProgramBlock> getDirectPrerequisites()
The returned Set
is an unmodifiable set
that will not permit additions of new elements or
deletions of existing elements. Attempts to modify
the set will result in UnsupportedOperationException
s.
public Set<ProgramBlock> getAllPrerequisites()
addPrerequisite(ProgramBlock)
method.)
public boolean isTest()
test project
.
public EventSetStatus getExecutionStatus()
public void setCreatedBy(Long userId)
UserAccountable
If userId
is null, this object will be updated
not with null but with UserAccountable.NULL_USER_ID
instead.
setCreatedBy
in interface UserAccountable
userId
- the ID of the user who most recently updated this object.public void setCreatedOn(Date d)
UserAccountable
If d
is null it will be ignored and this method
will do nothing.
setCreatedOn
in interface UserAccountable
d
- the date on which this object was created.public void setLastUpdatedBy(Long userId)
UserAccountable
If userId
is null, this object will be updated
not with null but with UserAccountable.NULL_USER_ID
instead.
setLastUpdatedBy
in interface UserAccountable
userId
- the ID of the user who most recently updated this object.public void setLastUpdatedOn(Date d)
UserAccountable
If d
is null it will be ignored and this method
will do nothing.
setLastUpdatedOn
in interface UserAccountable
d
- the date on which this object was most recently updated.public Long getCreatedBy()
UserAccountable
If this object does not know the identity of the user who created
it, the returned ID will be UserAccountable.NULL_USER_ID
.
getCreatedBy
in interface UserAccountable
public Date getCreatedOn()
UserAccountable
getCreatedOn
in interface UserAccountable
public Long getLastUpdatedBy()
UserAccountable
If this object does not know the identity of the user who lasted
updated it, the returned ID will be UserAccountable.NULL_USER_ID
.
getLastUpdatedBy
in interface UserAccountable
public Date getLastUpdatedOn()
UserAccountable
getLastUpdatedOn
in interface UserAccountable
public void setComments(String replacementComments)
replacementComments
- free-form text about this program block.
These comments replace all previously set comments.
A null value will be replaced by the empty string ("").appendComments(String)
public void appendComments(String additionalComments)
additionalComments
- new, additional, comments about this program block.setComments(String)
public String getComments()
appendComments(String)
,
setComments(String)
public String toString()
toString
in class Object
toSummaryString()
public String toSummaryString()
public String toXml() throws JAXBException
JAXBException
- if anything goes wrong during the conversion to XML.writeAsXmlTo(Writer)
public void writeAsXmlTo(Writer writer) throws JAXBException
writer
.
writer
- the device to which XML is written.
JAXBException
- if anything goes wrong during the conversion to XML.public static ProgramBlock fromXml(String xmlFile) throws JAXBException, XMLStreamException, FileNotFoundException
xmlFile
- the name of an XML file. This method will attempt to locate
the file by using Class.getResource(String)
.
FileNotFoundException
- if the XML file cannot be found.
JAXBException
- if the schema file used (if any) is malformed, if
the XML file cannot be read, or if the XML file is not
schema-valid.
XMLStreamException
- if there is a problem opening the XML file,
if the XML is not well-formed, or for some other
"unexpected processing conditions".public static ProgramBlock fromXml(Reader reader) throws JAXBException, XMLStreamException
reader
.
reader
- the source of the XML data.
If this value is null, null is returned.
reader
.
XMLStreamException
- if the XML is not well-formed,
or for some other "unexpected processing conditions".
JAXBException
- if anything else goes wrong during the
transformation.public static <T extends ProgramBlock> T fromXml(String xmlFile, Class<T> pbType) throws JAXBException, XMLStreamException, FileNotFoundException
Sample usage:
VlaProgramBlock myPb = ProgramBlock.fromXml(VlaProgramBlock.class, myFile);
T
- the particular subclass of ProgramBlock
returned.pbType
- the Class
of an object that extends, or is a,
ProgramBlock
.xmlFile
- the name of an XML file. This method will attempt to locate
the file by using Class.getResource(String)
.
FileNotFoundException
- if the XML file cannot be found.
JAXBException
- if the schema file used (if any) is malformed, if
the XML file cannot be read, or if the XML file is not
schema-valid.
XMLStreamException
- if there is a problem opening the XML file,
if the XML is not well-formed, or for some other
"unexpected processing conditions".public static <T extends ProgramBlock> T fromXml(Reader reader, Class<T> pbType) throws JAXBException, XMLStreamException
reader
.
Sample usage:
VlaProgramBlock myPb = ProgramBlock.fromXml(VlaProgramBlock.class, myReader);
T
- the particular subclass of ProgramBlock
returned.pbType
- the Class
of an object that extends Scan
.reader
- the source of the XML data.
If this value is null, null is returned.
reader
.
XMLStreamException
- if the XML is not well-formed,
or for some other "unexpected processing conditions".
JAXBException
- if anything else goes wrong during the
transformation.public ProgramBlock clone()
The returned element is, for the most part, a deep copy of this one. However, there are a few exceptions:
Identifiable.UNIDENTIFIED
.
If anything goes wrong during the cloning procedure,
a RuntimeException
will be thrown.
clone
in class Object
public ProgramBlock cloneWithoutPrerequisites()
The returned element is, for the most part, a deep copy of this one. However, there are a few exceptions:
Identifiable.UNIDENTIFIED
.
If anything goes wrong during the cloning procedure,
a RuntimeException
will be thrown.
public boolean equals(Object o)
o
is equal to this program block.
In order to be equal to this program block, o
must be non-null
and of the same class as this block. Equality is determined by examining
the equality of corresponding attributes, with the following exceptions,
which are ignored when assessing equality:
equals
in class Object
public int hashCode()
hashCode
in class Object
public static Comparator<ProgramBlock> getPrequisiteComparator()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |