cz.cuni.amis.pogamut.sposh.elements
Class PoshPlan

Package class diagram package PoshPlan
java.lang.Object
  extended by cz.cuni.amis.pogamut.sposh.elements.PoshElement<THIS,PARENT>
      extended by cz.cuni.amis.pogamut.sposh.elements.PoshDummyElement<PoshPlan,PoshPlan>
          extended by cz.cuni.amis.pogamut.sposh.elements.PoshPlan

public final class PoshPlan
extends PoshDummyElement<PoshPlan,PoshPlan>

Root node of whole lap plan, contains DriveCollection, all Competence and ActionPattern + optional documentation.

Author:
HonzaH
See Also:
top level of the decision tree, ActionPattern, Competence, TriggeredAction

Field Summary
static DataFlavor dataFlavor
          Data flavor of posh plan(for drag-and-drop), not used anywhere, but required by interface.
static String PROP_AUTHOR
          Name of the property for author.
static String PROP_INFO
          Name of the property for info.
static String PROP_NAME
          Name of the property for name.
 
Fields inherited from class cz.cuni.amis.pogamut.sposh.elements.PoshDummyElement
IDENT_PATTERN
 
Method Summary
 void addActionPattern(ActionPattern actionPattern)
          Add new AP to the lap plan (add, emit)
 void addAdopt(Adopt adopt)
           
 void addCompetence(Competence competence)
          Add competence node to the lap tree (add, emit)
 ActionPattern getActionPattern(int id)
          Get action pattern with id, equivalent of getActionPatterns().List.get(int).
 int getActionPatternId(ActionPattern actionPattern)
          Get id of AP.
 List<ActionPattern> getActionPatterns()
          Get list of all APs in the plan.
 List<TriggeredAction> getActions()
          Get all actions in this plan.
 Set<String> getActionsNames()
          Get all action names in the plan, i.e.
 Adopt getAD(String name)
          Returns adopt from the plan with specified name.
 Adopt getAdopt(int id)
          Get adopt with id, equivalent of getAdopts().List.get(int).
 int getAdoptId(Adopt adopt)
          Get id of adopt.
 List<Adopt> getAdopts()
          Get list of all ADs in the plan.
 List<TriggeredAction> getAllReferences()
           
 ActionPattern getAP(String name)
          Return action pattern from the plan with specified name.
 String getAuthor()
          Get author of the plan, optional.
 Competence getC(String name)
          Return competence from this plan with specified name.
 List<PoshElement> getChildDataNodes()
          Get list of children of this node.
 Competence getCompetence(int id)
          Get competence with id, equivalent of getCompetences().List.get(int).
 int getCompetenceId(Competence competence)
          Get id of competence.
 List<Competence> getCompetences()
          Get list of all competences.
 DataFlavor getDataFlavor()
          Get data flavour of posh plan element,used during DnD from palette to PoshScene.
 DriveCollection getDriveCollection()
          Get drive collection of this plan.
 String getInfo()
          Get info about this plan.
 String getName()
          Get name of the plan.
 Set<String> getSensesNames()
          Get all sense names in the plan, i.e.
 LapType getType()
          Get type of the element.
 boolean isAD(String name)
          Does this plan contain AD with specified name?
 boolean isAP(String name)
          Does this plan contain AP with specified name?
 boolean isC(String name)
          Does the plan contains Competence with specified name?
 boolean isCycled()
          Is some element (AP/C) of the lap plan cycled? Doesn't even have to be attached to the drive.
 boolean isUniqueNodeName(String testedName)
          Check if passed string is different than names of all referencable nodes (competences, and action patterns and adopts).
 boolean moveChild(int newIndex, PoshElement child)
          Move child to the @newIndex.
 void removeActionPattern(ActionPattern ap)
          Remove action pattern from the plan and notify listeners of plan about removal of a child.
 void removeCompetence(Competence removeCompetence)
          Remove competence from the plan and notify listeners about removal of child.
 void setAuthor(String author)
          Set new author of the plan.
 void setInfo(String info)
          Set informations about the plan.
 void setName(String name)
          Name of the plan, from docnode, optional.
 void synchronize(PoshPlan other)
          Synchronize the lap tree to other the lap tree.
 String toString()
          Return serializaton of lap tree.
 
Methods inherited from class cz.cuni.amis.pogamut.sposh.elements.PoshDummyElement
getElementId, getUnusedName, isUsedName, moveChildInList
 
Methods inherited from class cz.cuni.amis.pogamut.sposh.elements.PoshElement
addElementListener, emitChildDeleted, emitChildMove, emitChildNode, firePropertyChange, getChildId, getChildren, getElementListeners, getId, getParent, getRootNode, isChildOfParent, removeElementListener, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dataFlavor

public static final DataFlavor dataFlavor
Data flavor of posh plan(for drag-and-drop), not used anywhere, but required by interface.


PROP_NAME

public static final String PROP_NAME
Name of the property for name.

See Also:
Constant Field Values

PROP_AUTHOR

public static final String PROP_AUTHOR
Name of the property for author.

See Also:
Constant Field Values

PROP_INFO

public static final String PROP_INFO
Name of the property for info.

See Also:
Constant Field Values
Method Detail

getActionsNames

public Set<String> getActionsNames()
Get all action names in the plan, i.e. actions is DC, AP and C. Careful, if name of action is same as name of AP/C, it is expanded and thus is not a name of action, but only reference to the AP/C.

Returns:
Names of all actions in the plan.

getActions

public List<TriggeredAction> getActions()
Get all actions in this plan. It includes all actions in drives, competence elements, action patterns and adopts. NOTE: This adds all actions

Returns:
Set of all actions in the plan.

getAllReferences

public List<TriggeredAction> getAllReferences()

getSensesNames

public Set<String> getSensesNames()
Get all sense names in the plan, i.e. senses in DC goal, DE trigger, CE trigger.

Returns:
Names of all senses in all elements of the plan.

isC

public boolean isC(String name)
Does the plan contains Competence with specified name?

Parameters:
name - name we are checking
Returns:
true if C with name exists in the plane, false otherwise.

getC

public Competence getC(String name)
Return competence from this plan with specified name.

Parameters:
name - name of searched C
Returns:
competence or null if such C doesn't exists

getCompetence

public Competence getCompetence(int id)
Get competence with id, equivalent of getCompetences().List.get(int).


isAP

public boolean isAP(String name)
Does this plan contain AP with specified name?

Parameters:
name - name of AP we are checking
Returns:
true if AP with name exists in the plane, false otherwise.

getAP

public ActionPattern getAP(String name)
Return action pattern from the plan with specified name.

Parameters:
name - name of searched AP
Returns:
action pattern or null if such AP doesn't exists

getActionPattern

public ActionPattern getActionPattern(int id)
Get action pattern with id, equivalent of getActionPatterns().List.get(int).


isAD

public boolean isAD(String name)
Does this plan contain AD with specified name?

Parameters:
name - name of AD we are checking
Returns:
true if AD with name exists in the plane, false otherwise.

getAD

public Adopt getAD(String name)
Returns adopt from the plan with specified name.

Parameters:
name - name of searched AD
Returns:
adopt or null if such AD doesn't exists

getAdopt

public Adopt getAdopt(int id)
Get adopt with id, equivalent of getAdopts().List.get(int).


isUniqueNodeName

public boolean isUniqueNodeName(String testedName)
Check if passed string is different than names of all referencable nodes (competences, and action patterns and adopts). If it is, it can be used as name of new competence or action pattern.

Parameters:
testedName - name of tested string.
Returns:
true if it is unique, false otherwise.

addCompetence

public void addCompetence(Competence competence)
                   throws DuplicateNameException,
                          CycleException
Add competence node to the lap tree (add, emit)

Parameters:
competenceNode -
Throws:
DuplicateNameException
CycleException

addAdopt

public void addAdopt(Adopt adopt)
              throws DuplicateNameException,
                     CycleException
Throws:
DuplicateNameException
CycleException

getName

public String getName()
Get name of the plan. Name is the first string in documentation node.

Returns:
Name of the plan or empty string if name is not set.

setName

public void setName(String name)
Name of the plan, from docnode, optional.

Parameters:
name - the name to set.

getAuthor

public String getAuthor()
Get author of the plan, optional. Author is the second string in the documentation node of the tree.

Returns:
author of the plan or empty string if author is not set.

setAuthor

public void setAuthor(String author)
Set new author of the plan.

Parameters:
author - new author or empty string for erasing.

getInfo

public String getInfo()
Get info about this plan. Description of the plan is the third string of the documentation node.

Returns:
informationa about this plan or empty string if info is not set.

setInfo

public void setInfo(String info)
Set informations about the plan.

Parameters:
info - New info about plan or or empty string.

getCompetences

public List<Competence> getCompetences()
Get list of all competences.

Returns:
Unmodifiable list of all competences.

addActionPattern

public void addActionPattern(ActionPattern actionPattern)
                      throws DuplicateNameException,
                             CycleException
Add new AP to the lap plan (add, emit)

Parameters:
actionPatternNode -
Throws:
DuplicateNameException
CycleException

getAdopts

public List<Adopt> getAdopts()
Get list of all ADs in the plan.

Returns:
Unmodifiable list of all ADs in the plan.

getActionPatterns

public List<ActionPattern> getActionPatterns()
Get list of all APs in the plan.

Returns:
Unmodifiable list of all APs in the plan.

getDriveCollection

public DriveCollection getDriveCollection()
Get drive collection of this plan.


isCycled

public boolean isCycled()
Is some element (AP/C) of the lap plan cycled? Doesn't even have to be attached to the drive.

Returns:
true if plan has a cycle, false otherwise

toString

public String toString()
Return serializaton of lap tree.

Overrides:
toString in class Object

getChildDataNodes

public List<PoshElement> getChildDataNodes()
Description copied from class: PoshElement
Get list of children of this node. Most likely auto generated every time this method is called.

Specified by:
getChildDataNodes in class PoshElement<PoshPlan,PoshPlan>
Returns:
List of all children of this node.

moveChild

public boolean moveChild(int newIndex,
                         PoshElement child)
Description copied from class: PoshElement
Move child to the @newIndex. After child was moved (if it was moved), notify listeners.

Specified by:
moveChild in class PoshElement<PoshPlan,PoshPlan>
Returns:
if node succesfully moved

getDataFlavor

public DataFlavor getDataFlavor()
Description copied from class: PoshElement
Get data flavour of posh plan element,used during DnD from palette to PoshScene.

Specified by:
getDataFlavor in class PoshElement<PoshPlan,PoshPlan>
Returns:
dataFlavour of posh plan element, never null.

getType

public LapType getType()
Description copied from class: PoshElement
Get type of the element.

Specified by:
getType in class PoshElement<PoshPlan,PoshPlan>
Returns:
Type of element.

removeCompetence

public void removeCompetence(Competence removeCompetence)
Remove competence from the plan and notify listeners about removal of child.

Parameters:
removeCompetence - Competence to be removed

removeActionPattern

public void removeActionPattern(ActionPattern ap)
Remove action pattern from the plan and notify listeners of plan about removal of a child.

Parameters:
ap - Action pattern to be removed.

synchronize

public void synchronize(PoshPlan other)
Synchronize the lap tree to other the lap tree. After all is said and done, we should have two trees that would serialize into a same plan, but don't share any data.

Parameters:
other - The tree we are supposed to synchronize to.

getAdoptId

public int getAdoptId(Adopt adopt)
Get id of adopt. The is is an index into all adopts.

Parameters:
adopt - Adopt for which we want index
Returns:
found index
Throws:
IllegalArgumentException - If adopt is not in the adopts of the plan.

getActionPatternId

public int getActionPatternId(ActionPattern actionPattern)
Get id of AP. The is is an index into all APs in the plan.

Parameters:
actionPattern - AP for which we want index
Returns:
found index
Throws:
IllegalArgumentException - If AP is not in APs of the plan.

getCompetenceId

public int getCompetenceId(Competence competence)
Get id of competence. The is is an index into all Cs in the plan.

Parameters:
competence - C for which we want index
Returns:
found index
Throws:
IllegalArgumentException - If competence is not in the competences of the plan.


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.