Class SetList
- java.lang.Object
-
- de.gebit.integrity.remoting.entities.setlist.SetList
-
- All Implemented Interfaces:
Serializable
public class SetList extends Object implements 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 voidaddReference(SetListEntry aReferringEntry, SetListEntryAttributeKeys anAttributeKey, SetListEntry aReferredEntry)Adds a reference to another entry to a specified parent entry under a specified attribute key.protected StringcalculateFullyQualifiedBaseName(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).SetListEntrycreateEntry(SetListEntryTypes aType)Creates a new entry.protected SetListEntryResultStatesdetermineEntryResultState(SetListEntry anEntry)Determines the result state for a specific entry.voiddumpEntries(PrintStream aStream)Performs a full dump of all entries in the setlist into the given stream.SetListEntryfindEntryByFullyQualifiedName(String aName)Finds an entry based on a given fully qualified name.List<SetListEntry>getEntriesInExecution()SetListEntrygetEntryInExecution()intgetEntryListPosition()String[]getForkExecutingEntry(SetListEntry anEntry)Returns the name of the fork that executes the given entry.StringgetFullyQualifiedName(SetListEntry anEntry)Gets the fully qualified name for an entry.StringgetFullyQualifiedName(Integer anEntryReference)Gets the fully qualified name for an entry.IntegergetLastCreatedEntryId(SetListEntryTypes aType)Returns the ID that was last given to an entry of the specified type.IntegergetLastCreatedEntryId(SetListEntryTypes... someTypes)Returns the lowest ID given to any of the specified entry types.intgetNumberOfEntriesInResultState(SetListEntryResultStates aState)Returns the number of entries in the given result state.intgetNumberOfExecutableEntries()SetListEntrygetParent(SetListEntry anEntry)Returns the parent entry for a given entry.SetListEntryResultStatesgetResultStateForEntry(SetListEntry anEntry)Returns the result state of an entry from the map.SetListEntryResultStatesgetResultStateForExecutableEntry(int aPosition)Returns the result state of an executable entry at the specified position in the list of executable entries.SetListEntrygetRootEntry()voidintegrateUpdates(SetListEntry[] someUpdatedEntries)Integrates a list of updated entries into thisSetList.booleanisEntryInExecution(SetListEntry anEntry)Checks whether a given entry is currently being executed.voidrecreateTransientData()Recreates transient data from the list of entries.SetListEntryresolveReference(Integer aReference)Resolves a single entry reference (ID).List<SetListEntry>resolveReferences(SetListEntry anEntry, SetListEntryAttributeKeys anAttributeKey)Returns a list of entries that are referred by the given entry under the given attribute key.List<SetListEntry>resolveReferences(List<Integer> someItemIds)Resolves a list of entry IDs to the actual entries.voidrewind()Clears the entry list position.voidsetEntryInExecutionReference(Integer anEntryReference)Updates the reference to the entry that's currently in execution, recalculating the execution path.StringtoString()
-
-
-
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 theSetListto 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 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 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
-
resolveReferences
public 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 List<SetListEntry> resolveReferences(List<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(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 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 String getFullyQualifiedName(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(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 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(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 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 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(PrintStream aStream)
Performs a full dump of all entries in the setlist into the given stream.- Parameters:
aStream- the stream to write into
-
-