Class SetList
- java.lang.Object
-
- de.gebit.integrity.remoting.entities.setlist.SetList
-
- All Implemented Interfaces:
java.io.Serializable
public class SetList extends java.lang.Object implements java.io.Serializable
The Setlist is a data structure to contain a test execution plan as well as test results. Its name refers to the setlists used by bands to write down the songs played during a concert (okay, it's a stupid reason to name it like that, but hey, I didn't have any better idea ;-) ).
Setlists are stored in a flat way, with the entries actually resembling a tree structure by referencing each other via their IDs. This allows for easy incremental update of single entries regardless of the size of the subtrees below them, as long as the IDs of each entry stay the same.- Author:
- Rene Schneider - initial API and implementation
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SetList()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addReference(SetListEntry aReferringEntry, SetListEntryAttributeKeys anAttributeKey, SetListEntry aReferredEntry)
Adds a reference to another entry to a specified parent entry under a specified attribute key.protected java.lang.String
calculateFullyQualifiedBaseName(SetListEntry anEntry)
Determines the fully qualified base name for an entry (this entry is possibly extended with a counter to resolve duplicates, hence it is a base name).SetListEntry
createEntry(SetListEntryTypes aType)
Creates a new entry.protected SetListEntryResultStates
determineEntryResultState(SetListEntry anEntry)
Determines the result state for a specific entry.void
dumpEntries(java.io.PrintStream aStream)
Performs a full dump of all entries in the setlist into the given stream.SetListEntry
findEntryByFullyQualifiedName(java.lang.String aName)
Finds an entry based on a given fully qualified name.java.util.List<SetListEntry>
getEntriesInExecution()
SetListEntry
getEntryInExecution()
int
getEntryListPosition()
java.lang.String[]
getForkExecutingEntry(SetListEntry anEntry)
Returns the name of the fork that executes the given entry.java.lang.String
getFullyQualifiedName(SetListEntry anEntry)
Gets the fully qualified name for an entry.java.lang.String
getFullyQualifiedName(java.lang.Integer anEntryReference)
Gets the fully qualified name for an entry.java.lang.Integer
getLastCreatedEntryId(SetListEntryTypes aType)
Returns the ID that was last given to an entry of the specified type.java.lang.Integer
getLastCreatedEntryId(SetListEntryTypes... someTypes)
Returns the lowest ID given to any of the specified entry types.int
getNumberOfEntriesInResultState(SetListEntryResultStates aState)
Returns the number of entries in the given result state.int
getNumberOfExecutableEntries()
SetListEntry
getParent(SetListEntry anEntry)
Returns the parent entry for a given entry.SetListEntryResultStates
getResultStateForEntry(SetListEntry anEntry)
Returns the result state of an entry from the map.SetListEntryResultStates
getResultStateForExecutableEntry(int aPosition)
Returns the result state of an executable entry at the specified position in the list of executable entries.SetListEntry
getRootEntry()
void
integrateUpdates(SetListEntry[] someUpdatedEntries)
Integrates a list of updated entries into thisSetList
.boolean
isEntryInExecution(SetListEntry anEntry)
Checks whether a given entry is currently being executed.void
recreateTransientData()
Recreates transient data from the list of entries.SetListEntry
resolveReference(java.lang.Integer aReference)
Resolves a single entry reference (ID).java.util.List<SetListEntry>
resolveReferences(SetListEntry anEntry, SetListEntryAttributeKeys anAttributeKey)
Returns a list of entries that are referred by the given entry under the given attribute key.java.util.List<SetListEntry>
resolveReferences(java.util.List<java.lang.Integer> someItemIds)
Resolves a list of entry IDs to the actual entries.void
rewind()
Clears the entry list position.void
setEntryInExecutionReference(java.lang.Integer anEntryReference)
Updates the reference to the entry that's currently in execution, recalculating the execution path.java.lang.String
toString()
-
-
-
Method Detail
-
recreateTransientData
public void recreateTransientData()
Recreates transient data from the list of entries. Used after deserialization of the whole structure in order to prepare it for being actually used. Transient entries are redundant and not transmitted for size reasons.
-
determineEntryResultState
protected SetListEntryResultStates determineEntryResultState(SetListEntry anEntry)
Determines the result state for a specific entry.- Parameters:
anEntry
- the entry- Returns:
- the result state or null in case the entry doesn't have a result
-
getNumberOfExecutableEntries
public int getNumberOfExecutableEntries()
-
getNumberOfEntriesInResultState
public int getNumberOfEntriesInResultState(SetListEntryResultStates aState)
Returns the number of entries in the given result state.- Parameters:
aState
- the state to query- Returns:
- the number
-
getResultStateForEntry
public SetListEntryResultStates getResultStateForEntry(SetListEntry anEntry)
Returns the result state of an entry from the map.- Parameters:
anEntry
- the entry- Returns:
- the result state, or null if the entry doesn't have one
-
getResultStateForExecutableEntry
public SetListEntryResultStates getResultStateForExecutableEntry(int aPosition)
Returns the result state of an executable entry at the specified position in the list of executable entries.- Parameters:
aPosition
- the position- Returns:
- the result state, or null if the position doesn't have one
-
createEntry
public SetListEntry createEntry(SetListEntryTypes aType)
Creates a new entry. Uses up an entry ID in the process.
Note that this doesn't necessarily create a new entry, it may also reuse an already existing one! It's part of the concept of theSetList
to actually create entries on the first (dry) run through the tests, and reuse old entries during the second (actual) test run, updating their result status etc. in the process.- Parameters:
aType
- the type of entry- Returns:
- the new entry
-
getLastCreatedEntryId
public java.lang.Integer getLastCreatedEntryId(SetListEntryTypes aType)
Returns the ID that was last given to an entry of the specified type.- Parameters:
aType
- the type- Returns:
- the ID if available, or null if none has been given to an entry of that type
-
getLastCreatedEntryId
public java.lang.Integer getLastCreatedEntryId(SetListEntryTypes... someTypes)
Returns the lowest ID given to any of the specified entry types.- Parameters:
someTypes
- the types- Returns:
- the ID if available, or null if none has been given to any entry of the types
-
addReference
public void addReference(SetListEntry aReferringEntry, SetListEntryAttributeKeys anAttributeKey, SetListEntry aReferredEntry)
Adds a reference to another entry to a specified parent entry under a specified attribute key.- Parameters:
aReferringEntry
- the parent entryanAttributeKey
- the attribute key under which the reference shall be createdaReferredEntry
- the entry to refer
-
rewind
public void rewind()
Clears the entry list position.
-
integrateUpdates
public void integrateUpdates(SetListEntry[] someUpdatedEntries)
Integrates a list of updated entries into thisSetList
.- Parameters:
someUpdatedEntries
- the updated entries
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
resolveReferences
public java.util.List<SetListEntry> resolveReferences(SetListEntry anEntry, SetListEntryAttributeKeys anAttributeKey)
Returns a list of entries that are referred by the given entry under the given attribute key.- Parameters:
anEntry
- the entryanAttributeKey
- the attribute key- Returns:
- the list of resolved entries
-
resolveReferences
public java.util.List<SetListEntry> resolveReferences(java.util.List<java.lang.Integer> someItemIds)
Resolves a list of entry IDs to the actual entries.- Parameters:
someItemIds
- the IDs to resolve- Returns:
- the list of entries
-
resolveReference
public SetListEntry resolveReference(java.lang.Integer aReference)
Resolves a single entry reference (ID).- Parameters:
aReference
- the ID of the entry- Returns:
- the entry, or null if there is none with that ID
-
getRootEntry
public SetListEntry getRootEntry()
-
getParent
public SetListEntry getParent(SetListEntry anEntry)
Returns the parent entry for a given entry.- Parameters:
anEntry
- the child entry- Returns:
- the parent, or null if none was found
-
getFullyQualifiedName
public java.lang.String getFullyQualifiedName(SetListEntry anEntry)
Gets the fully qualified name for an entry. For more info regarding this name, seefullyQualifiedNameMap
.- Parameters:
anEntry
- the entry to look for- Returns:
- the fully qualified name
-
getFullyQualifiedName
public java.lang.String getFullyQualifiedName(java.lang.Integer anEntryReference)
Gets the fully qualified name for an entry. For more info regarding this name, seefullyQualifiedNameMap
.- Parameters:
anEntryReference
- the entry to look for- Returns:
- the fully qualified name
-
findEntryByFullyQualifiedName
public SetListEntry findEntryByFullyQualifiedName(java.lang.String aName)
Finds an entry based on a given fully qualified name. For more info regarding this name, seefullyQualifiedNameMap
.- Parameters:
aName
- the name to search for- Returns:
- the entry or null if none was found
-
calculateFullyQualifiedBaseName
protected java.lang.String calculateFullyQualifiedBaseName(SetListEntry anEntry)
Determines the fully qualified base name for an entry (this entry is possibly extended with a counter to resolve duplicates, hence it is a base name). For more info regarding this name, seefullyQualifiedNameMap
.- Parameters:
anEntry
- the entry to calculate the name for- Returns:
- the name
-
setEntryInExecutionReference
public void setEntryInExecutionReference(java.lang.Integer anEntryReference)
Updates the reference to the entry that's currently in execution, recalculating the execution path.- Parameters:
anEntryReference
- the new entry in execution
-
getEntryInExecution
public SetListEntry getEntryInExecution()
-
getEntryListPosition
public int getEntryListPosition()
-
getEntriesInExecution
public java.util.List<SetListEntry> getEntriesInExecution()
-
isEntryInExecution
public boolean isEntryInExecution(SetListEntry anEntry)
Checks whether a given entry is currently being executed.- Parameters:
anEntry
- the entry- Returns:
- true if the entry is being executed, false otherwise
-
getForkExecutingEntry
public java.lang.String[] getForkExecutingEntry(SetListEntry anEntry)
Returns the name of the fork that executes the given entry.- Parameters:
anEntry
- the entry- Returns:
- the forks' name (index 0) and description (index 1, if available, otherwise null) or null if the entry is executed by the master
-
dumpEntries
public void dumpEntries(java.io.PrintStream aStream)
Performs a full dump of all entries in the setlist into the given stream.- Parameters:
aStream
- the stream to write into
-
-