edu.nrao.sss.model.project
Class ProgramBlock

java.lang.Object
  extended by edu.nrao.sss.model.project.ProgramBlock
All Implemented Interfaces:
ProgBlock, UserAccountable, Identifiable, Cloneable

public class ProgramBlock
extends Object
implements Identifiable, UserAccountable, Cloneable, ProgBlock

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 SchedulingBlocks.

Version Info:

$Revision: 2277 $
$Date: 2009-04-29 11:19:38 -0600 (Wed, 29 Apr 2009) $
$Author: dharland $

Since:
2006-02-24
Author:
David M. Harland

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
<T extends ProgramBlock>
T
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
<T extends ProgramBlock>
T
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

DEFAULT_NAME

public static final String DEFAULT_NAME
See Also:
Constant Field Values
Constructor Detail

ProgramBlock

public ProgramBlock()
Creates a new instance.

Method Detail

reset

public void reset()
Resets this project to its initial state. A reset project has the same state as a new project.


getId

public Long getId()
Specified by:
getId in interface Identifiable

clearId

public void clearId()
Resets this pb's id to UNIDENTIFIED and calls all of it's SchedulingBlock's clearId() methods.


setName

public void setName(String newName)
Sets the name of this program block.

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.

Specified by:
setName in interface ProgBlock
Parameters:
newName - the new name of this program block.

getName

public String getName()
Returns the name of this program block.

Specified by:
getName in interface ProgBlock
Returns:
the name of this program block.

getLongName

@Deprecated
public String getLongName()
Deprecated. 


setLongName

@Deprecated
public void setLongName(String newName)
Deprecated. 


getShortName

@Deprecated
public String getShortName()
Deprecated. 


setShortName

@Deprecated
public void setShortName(String newName)
Deprecated. 


setAcceptableConfigurations

public void setAcceptableConfigurations(List<TelescopeConfiguration> newList)
For use by Hibernate and JAXB.

Specified by:
setAcceptableConfigurations in interface ProgBlock

getAcceptableConfigurations

public List<TelescopeConfiguration> getAcceptableConfigurations()
Returns a list of the telescope configurations that are acceptable to this program block. The list is ordered by priority. In other words, the configuration found in the 0th position is the preferred configuration, the one found in the 1st position is the runner-up, and so on.

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.

Specified by:
getAcceptableConfigurations in interface ProgBlock
Returns:
a list of acceptable telescope configurations.

setProject

public void setProject(Project newProject)
Sets the project to which this program block belongs.

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.

Parameters:
newProject - the project to which this program block belongs.

getProject

public Project getProject()
Returns the project to which this program block belongs, if any.

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.

Returns:
the project to which this program block belongs, if any.
See Also:
hasProject()

hasProject

public boolean hasProject()
Returns true if this program block has a non-null project.

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:

  1. This program block has just been created and its project has not yet been set.
  2. A client removed this program block from its project and did not place it in a new project.
  3. A client explicitly set this program block's project to null.

Returns:
true if this program block has a non-null project. Therefore a return value of true means that you can call getProject() and know that it will return a non-null object.

isProjectPartiallyScheduled

public boolean isProjectPartiallyScheduled()
Description copied from interface: ProgBlock
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.

Specified by:
isProjectPartiallyScheduled in interface ProgBlock
Returns:
true if the project is partially scheduled; false otherwise.

createSchedulingBlock

public SchedulingBlock createSchedulingBlock()
Creates and returns a new scheduling block that is suitable for use with this program block. The returned scheduling block has not been added to this program block.

Returns:
a new scheduling block that can later be added to this program block.

addSchedulingBlock

public void addSchedulingBlock(SchedulingBlock schedBlock)
Adds the given scheduling block to this program block.

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.

Parameters:
schedBlock - the scheduling block to be added to this program block.

addSchedulingBlock

public void addSchedulingBlock(int idx,
                               SchedulingBlock schedBlock)
Adds the given scheduling block to this program block at index 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.

Parameters:
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.

removeSchedulingBlock

public void removeSchedulingBlock(SchedulingBlock schedBlock)
                           throws ValidationException
Removes the given scheduling block from this program block.

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.

Parameters:
schedBlock - the scheduling block to be removed.
Throws:
ValidationException - if schedBlock is a prerequisite of one or more of this program block's scheduling blocks.

removeAllSchedulingBlocks

public void removeAllSchedulingBlocks()
Removes all scheduling blocks from this program block. Each scheduling block is notified that it no longer has a containing program block.


hasPrerequisites

public boolean hasPrerequisites()
Returns true if this block has one or more prequisite blocks.

Returns:
true if this block has one or more prequisite blocks.

getSchedulingBlocks

public List<SchedulingBlock> getSchedulingBlocks()
Returns the scheduling blocks that belong to this program block.

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.

Returns:
the scheduling blocks that belong to this program block.

getSchedulingBlocksSortedByPrereqs

public 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.

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.

Returns:
scheduling blocks sorted by prerequisite relationships.

getScheduleEntries

public Collection<ScheduleEntry> getScheduleEntries(EventStatus execStatus,
                                                    Collection<ScheduleEntry> destination)
Returns the schedule entries of this block that have an execution status of execStatus. Only the status of the entries is considered. This method does not look, for example, at the isTest() property.

Parameters:
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.
Returns:
the collection holding the schedule entries. This will be either destination or a new collection, if destination is null.
See Also:
getReadyToScheduleEntries(Collection)

getReadyToScheduleEntries

public Collection<ScheduleEntry> getReadyToScheduleEntries(Collection<ScheduleEntry> destination)
Returns the schedule entries of this block that are ready for scheduling. If this is a test program block, or if this block has no NOT_YET_SCHEDULED entries, the returned collection will be empty.

Parameters:
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.
Returns:
a collection of ready-to-be-scheduled entries, or an empty collection. The returned collection will be either destination or a new collection, if destination is null.
See Also:
getScheduleEntries(EventStatus, Collection)

addPrerequisite

public boolean addPrerequisite(ProgramBlock newPrereq)
Adds 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.

Parameters:
newPrereq - a new direct prerequisite for this program block.
Returns:
true if newPrereq was added to this program block's set of direct prerequisites.
The conditions that lead to a return value of false are:
  1. newPrereq is null
  2. newPrereq is already an direct prerequisite of this program block
  3. This program block is currently a prequisite, direct or otherwise, of newPrereq.

removePrerequisite

public boolean removePrerequisite(ProgramBlock oldPrereq)
Removes 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.)

Parameters:
oldPrereq - the prerequisite to be removed from this scheduling block's set of direct prerequisites.
Returns:
true if oldPrereq was successfully removed. Note that a return value of false might mean that oldPrereq was not an direct prerequisite of this program block.

removeAllPrerequisites

public void removeAllPrerequisites()
Clears this program block's set of prerequisites.


isPrerequisiteOf

public boolean isPrerequisiteOf(ProgramBlock progBlock)
Returns true if this program block is either a direct or indirect prerequisite of progBlock. (For an explanation of direct versus indirect prerequisites, see the note in the addPrerequisite(ProgramBlock) method.)

Parameters:
progBlock - the program block to test.
Returns:
true if this program block is a prerequisite of progBlock.
See Also:
isDirectPrerequisiteOf(ProgramBlock)

isDirectPrerequisiteOf

public boolean isDirectPrerequisiteOf(ProgramBlock progBlock)
Returns true if this program block is an direct prerequisite of progBlock. (For an explanation of direct versus indirect prequisites, see the note in the addPrerequisite(ProgramBlock) method.)

Parameters:
progBlock - the program block to test.
Returns:
true if this program block is an direct prerequisite of progBlock.
See Also:
isPrerequisiteOf(ProgramBlock)

getDirectPrerequisites

public Set<ProgramBlock> getDirectPrerequisites()
Returns this program block's set of direct prerequisites.

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 UnsupportedOperationExceptions.

Returns:
this program block's set of direct prerequisites.

getAllPrerequisites

public Set<ProgramBlock> getAllPrerequisites()
Returns a set containing all direct and indirect prerequisites of this program block. (For an explanation of direct versus indirect prequisites, see the note in the addPrerequisite(ProgramBlock) method.)

Returns:
a set containing all prerequisites of this program block.

isTest

public boolean isTest()
Returns true if this block is part of a test project.

Returns:
true if this block is part of a test project.

getExecutionStatus

public EventSetStatus getExecutionStatus()
Returns this program block's execution status.

Returns:
this program block's execution status.

setCreatedBy

public void setCreatedBy(Long userId)
Description copied from interface: UserAccountable
Sets the ID of the user who created this object.

If userId is null, this object will be updated not with null but with UserAccountable.NULL_USER_ID instead.

Specified by:
setCreatedBy in interface UserAccountable
Parameters:
userId - the ID of the user who most recently updated this object.

setCreatedOn

public void setCreatedOn(Date d)
Description copied from interface: UserAccountable
Sets the date on which this object was created.

If d is null it will be ignored and this method will do nothing.

Specified by:
setCreatedOn in interface UserAccountable
Parameters:
d - the date on which this object was created.

setLastUpdatedBy

public void setLastUpdatedBy(Long userId)
Description copied from interface: UserAccountable
Sets the ID of the user who most recently updated this object.

If userId is null, this object will be updated not with null but with UserAccountable.NULL_USER_ID instead.

Specified by:
setLastUpdatedBy in interface UserAccountable
Parameters:
userId - the ID of the user who most recently updated this object.

setLastUpdatedOn

public void setLastUpdatedOn(Date d)
Description copied from interface: UserAccountable
Sets the date on which this object was most recently updated.

If d is null it will be ignored and this method will do nothing.

Specified by:
setLastUpdatedOn in interface UserAccountable
Parameters:
d - the date on which this object was most recently updated.

getCreatedBy

public Long getCreatedBy()
Description copied from interface: UserAccountable
Returns the ID of the user who created this object.

If this object does not know the identity of the user who created it, the returned ID will be UserAccountable.NULL_USER_ID.

Specified by:
getCreatedBy in interface UserAccountable
Returns:
the ID of the user who created this object.

getCreatedOn

public Date getCreatedOn()
Description copied from interface: UserAccountable
Returns the date on which this object was created.

Specified by:
getCreatedOn in interface UserAccountable
Returns:
the date on which this object was created.

getLastUpdatedBy

public Long getLastUpdatedBy()
Description copied from interface: UserAccountable
Returns the ID of the user who most recently updated this object.

If this object does not know the identity of the user who lasted updated it, the returned ID will be UserAccountable.NULL_USER_ID.

Specified by:
getLastUpdatedBy in interface UserAccountable
Returns:
the ID of the user who most recently updated this object.

getLastUpdatedOn

public Date getLastUpdatedOn()
Description copied from interface: UserAccountable
Returns the most recent date on which this object was updated.

Specified by:
getLastUpdatedOn in interface UserAccountable
Returns:
the most recent date on which this object was updated.

setComments

public void setComments(String replacementComments)
Sets comments about this program block.

Parameters:
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 ("").
See Also:
appendComments(String)

appendComments

public void appendComments(String additionalComments)
Adds additional comments to those already associated with this program block.

Parameters:
additionalComments - new, additional, comments about this program block.
See Also:
setComments(String)

getComments

public String getComments()
Returns comments about this program block. The value returned is guaranteed to be non-null.

Returns:
free-form text about this program block.
See Also:
appendComments(String), setComments(String)

toString

public String toString()
Returns a text representation of this program block. The default form of the text is XML. However, if anything goes wrong during the conversion to XML, an alternate, and much abbreviated, form will be returned.

Overrides:
toString in class Object
Returns:
a text representation of this program block.
See Also:
toSummaryString()

toSummaryString

public String toSummaryString()
Returns a short textual description of this program block.

Returns:
a short textual description of this program block.

toXml

public String toXml()
             throws JAXBException
Returns an XML representation of this program block.

Returns:
an XML representation of this program block.
Throws:
JAXBException - if anything goes wrong during the conversion to XML.
See Also:
writeAsXmlTo(Writer)

writeAsXmlTo

public void writeAsXmlTo(Writer writer)
                  throws JAXBException
Writes an XML representation of this program block to writer.

Parameters:
writer - the device to which XML is written.
Throws:
JAXBException - if anything goes wrong during the conversion to XML.

fromXml

public static ProgramBlock fromXml(String xmlFile)
                            throws JAXBException,
                                   XMLStreamException,
                                   FileNotFoundException
Creates a new program block from the XML data in the given file.

Parameters:
xmlFile - the name of an XML file. This method will attempt to locate the file by using Class.getResource(String).
Returns:
a new program block from the XML data in the given file.
Throws:
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".

fromXml

public static ProgramBlock fromXml(Reader reader)
                            throws JAXBException,
                                   XMLStreamException
Creates a new program block based on the XML data read from reader.

Parameters:
reader - the source of the XML data. If this value is null, null is returned.
Returns:
a new program block based on the XML data read from reader.
Throws:
XMLStreamException - if the XML is not well-formed, or for some other "unexpected processing conditions".
JAXBException - if anything else goes wrong during the transformation.

fromXml

public static <T extends ProgramBlock> T fromXml(String xmlFile,
                                                 Class<T> pbType)
                                      throws JAXBException,
                                             XMLStreamException,
                                             FileNotFoundException
Creates a new program block from the XML data in the given file.

Sample usage:

   VlaProgramBlock myPb = ProgramBlock.fromXml(VlaProgramBlock.class,
                                               myFile);

Type Parameters:
T - the particular subclass of ProgramBlock returned.
Parameters:
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).
Returns:
a new program block from the XML data in the given file.
Throws:
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".

fromXml

public static <T extends ProgramBlock> T fromXml(Reader reader,
                                                 Class<T> pbType)
                                      throws JAXBException,
                                             XMLStreamException
Creates a new program block based on the XML data read from reader.

Sample usage:

   VlaProgramBlock myPb = ProgramBlock.fromXml(VlaProgramBlock.class,
                                               myReader);

Type Parameters:
T - the particular subclass of ProgramBlock returned.
Parameters:
pbType - the Class of an object that extends Scan.
reader - the source of the XML data. If this value is null, null is returned.
Returns:
a new program block based on the XML data read from reader.
Throws:
XMLStreamException - if the XML is not well-formed, or for some other "unexpected processing conditions".
JAXBException - if anything else goes wrong during the transformation.

clone

public ProgramBlock clone()
Returns a program block that is almost a copy of this one.

The returned element is, for the most part, a deep copy of this one. However, there are a few exceptions:

  1. The ID will be set to Identifiable.UNIDENTIFIED.
  2. The project will be null.
  3. The createdOn and lastUpdatedOn attributes will be set to the current system time.

If anything goes wrong during the cloning procedure, a RuntimeException will be thrown.

Overrides:
clone in class Object

cloneWithoutPrerequisites

public ProgramBlock cloneWithoutPrerequisites()
Returns a program block that is almost a copy of this one.

The returned element is, for the most part, a deep copy of this one. However, there are a few exceptions:

  1. The ID will be set to Identifiable.UNIDENTIFIED.
  2. The XML ID will be given a new UUID.
  3. The project will be null.
  4. The createdOn and lastUpdatedOn attributes will be set to the current system time.
  5. The list of prerequisites will be empty.

If anything goes wrong during the cloning procedure, a RuntimeException will be thrown.

Returns:
a near copy of this program block, without prerequisites.

equals

public boolean equals(Object o)
Returns true if 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:

  1. id
  2. project
  3. createdOn
  4. createdBy
  5. lastUpdatedOn
  6. lastUpdatedBy

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getPrequisiteComparator

public static Comparator<ProgramBlock> getPrequisiteComparator()
Returns a comparator that places all prerequisites before the blocks that depend upon them. Blocks that have no prereqs, and are prereqs of nothing, could be placed anywhere in the sorting process.

Returns:
a comparator that places all prerequisites before the blocks that depend upon them.


Copyright © 2009. All Rights Reserved.