org.shiwa.fgi.agwl2iwir.misc
Class Utils

java.lang.Object
  extended by org.shiwa.fgi.agwl2iwir.misc.Utils

public class Utils
extends java.lang.Object


Constructor Summary
Utils()
           
 
Method Summary
static void addPredecessorProperty(java.util.List<org.shiwa.fgi.iwir.AbstractTask> predTasks, java.util.List<org.shiwa.fgi.iwir.AbstractTask> succTasks)
          Adds properties to tasks for adding control links later on.
Adds a property with key 'predecessors' to all tasks of "succTasks" that have a property with key 'last'.
static void checkSignature(org.askalon.agwl.cgwd.activity.GenericActivity topLevelActivity, org.shiwa.fgi.iwir.AbstractTask topLevelTask, int globalIPCount)
          Checks whether the original agwl activity has as many input and output ports as the translated iwir task.
static boolean existsPath(java.util.List<org.shiwa.fgi.iwir.AbstractLink> links, java.lang.String fromTaskName, java.lang.String toTaskName)
          Checks whether there exists a path from the first to the second task.
Either a direct link exists or the function gets again called to find also paths with intermediate tasks.
static java.util.Set<java.lang.String> getNames(java.util.List<org.shiwa.fgi.iwir.Property> properties, java.lang.String name)
          Returns all names needed for the translation that are stored as properties.
Those are all properties with keys "agwl-name", "switch-name" or "workflow-name".
static java.lang.String getOriginalIwirName(org.askalon.agwl.cgwd.CGWDProperties properties, java.lang.String name)
          Searches for a property that stores the original iwir name of the activity.
If it was translated from a iwir task/port then the original name of the activity/port is stored as property with key "agwl-name".
static org.askalon.agwl.cgwd.activity.GenericActivity getTopLevelActivity(org.askalon.agwl.cgwd.activity.CGWDWorkflow cgwdWorkflow)
          Returns the top level activity of the workflow.
It generates a new sequence, moves the body of the workflow, global ports, properties and constraints from the workflow to itself.
static java.lang.String getUniquePortNameInTask(java.lang.String name, org.shiwa.fgi.iwir.AbstractTask task)
          Returns a unique name for a given port in a task.
Is needed for ports that have to be generated.
static org.shiwa.fgi.iwir.Constraint hasConstraint(java.util.List<org.shiwa.fgi.iwir.Constraint> constraint, java.lang.String name, java.lang.String value)
          Checks whether the list of constraints has a constraint with the given name and given value.
Goes through all constraints and compares the name and if value is not null also the given value.
static org.shiwa.fgi.iwir.Property hasProperty(java.util.List<org.shiwa.fgi.iwir.Property> properties, java.lang.String name, java.lang.String value)
          Checks whether the list of properties has a property with the given name and given value.
Goes through all properties and compares the name and, if value is not null, also the given value.
static org.shiwa.fgi.iwir.AbstractDataPort searchPortInPortList(java.util.List<org.shiwa.fgi.iwir.AbstractDataPort> ports, java.lang.String searchedPortName, java.util.Set<java.lang.String> taskNames)
          Searches in the given list of ports for a certain port name.
Because the searched port name is given in the form <taskName>/<portName> also all names of the task have to be given.
static org.shiwa.fgi.iwir.AbstractTask searchTaskInTaskList(java.util.List<org.shiwa.fgi.iwir.AbstractTask> tasks, java.lang.String searchedTaskName)
          Searches in the given list of tasks for a certain taskname.
Compares all names of the tasks with the searched name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

getOriginalIwirName

public static java.lang.String getOriginalIwirName(org.askalon.agwl.cgwd.CGWDProperties properties,
                                                   java.lang.String name)
Searches for a property that stores the original iwir name of the activity.
If it was translated from a iwir task/port then the original name of the activity/port is stored as property with key "agwl-name".

Returns:
original name of the activity

getNames

public static java.util.Set<java.lang.String> getNames(java.util.List<org.shiwa.fgi.iwir.Property> properties,
                                                       java.lang.String name)
Returns all names needed for the translation that are stored as properties.
Those are all properties with keys "agwl-name", "switch-name" or "workflow-name".

Parameters:
properties - keys have to be search in this properties
name - name of the task or port
Returns:
set of strings found in the properties, including 'name'

getUniquePortNameInTask

public static java.lang.String getUniquePortNameInTask(java.lang.String name,
                                                       org.shiwa.fgi.iwir.AbstractTask task)
Returns a unique name for a given port in a task.
Is needed for ports that have to be generated.

Parameters:
name - current name of the port
task - task of the port
Returns:
unique name for a port within the task

hasProperty

public static org.shiwa.fgi.iwir.Property hasProperty(java.util.List<org.shiwa.fgi.iwir.Property> properties,
                                                      java.lang.String name,
                                                      java.lang.String value)
Checks whether the list of properties has a property with the given name and given value.
Goes through all properties and compares the name and, if value is not null, also the given value.

Parameters:
properties - properties that have to be searched through
name - name of the searched property
value - value of the searched property or null if it can be any value
Returns:
the found property or null if it does not exist

hasConstraint

public static org.shiwa.fgi.iwir.Constraint hasConstraint(java.util.List<org.shiwa.fgi.iwir.Constraint> constraint,
                                                          java.lang.String name,
                                                          java.lang.String value)
Checks whether the list of constraints has a constraint with the given name and given value.
Goes through all constraints and compares the name and if value is not null also the given value.

Parameters:
constraint - constraints that have to be searched through
name - name of the searched property
value - value of the searched constraint or null if it can be any value
Returns:
the found constraint or null if it does not exist

searchTaskInTaskList

public static org.shiwa.fgi.iwir.AbstractTask searchTaskInTaskList(java.util.List<org.shiwa.fgi.iwir.AbstractTask> tasks,
                                                                   java.lang.String searchedTaskName)
Searches in the given list of tasks for a certain taskname.
Compares all names of the tasks with the searched name.

Parameters:
tasks - list of tasks to search for the name
searchedTaskName - name of the searched task
Returns:
task that with the searched name or null

searchPortInPortList

public static org.shiwa.fgi.iwir.AbstractDataPort searchPortInPortList(java.util.List<org.shiwa.fgi.iwir.AbstractDataPort> ports,
                                                                       java.lang.String searchedPortName,
                                                                       java.util.Set<java.lang.String> taskNames)
Searches in the given list of ports for a certain port name.
Because the searched port name is given in the form <taskName>/<portName> also all names of the task have to be given. So it compares all combinations of <taskName>/<portName> with the searched port name.

Parameters:
ports - list of ports to be searched through
searchedPortName - name of the port that has to be searched for
taskNames - set of names of the task where the ports belongs to
Returns:
the abstract data port that corresponds to the given name or null

existsPath

public static boolean existsPath(java.util.List<org.shiwa.fgi.iwir.AbstractLink> links,
                                 java.lang.String fromTaskName,
                                 java.lang.String toTaskName)
Checks whether there exists a path from the first to the second task.
Either a direct link exists or the function gets again called to find also paths with intermediate tasks.

Parameters:
links - list of links where to search for the path
fromTaskName - the task where the path starts
toTaskName - the task where the path ends
Returns:
true if there exists a path, false otherwise

getTopLevelActivity

public static org.askalon.agwl.cgwd.activity.GenericActivity getTopLevelActivity(org.askalon.agwl.cgwd.activity.CGWDWorkflow cgwdWorkflow)
Returns the top level activity of the workflow.
It generates a new sequence, moves the body of the workflow, global ports, properties and constraints from the workflow to itself.

Parameters:
cgwdWorkflow - workflow from which to generate top level activity
Returns:
the top level activity

checkSignature

public static void checkSignature(org.askalon.agwl.cgwd.activity.GenericActivity topLevelActivity,
                                  org.shiwa.fgi.iwir.AbstractTask topLevelTask,
                                  int globalIPCount)
Checks whether the original agwl activity has as many input and output ports as the translated iwir task.

Parameters:
topLevelActivity - original agwl activity
topLevelTask - translated iwir task
Throws:
TranslationException - if the number of ports differs

addPredecessorProperty

public static void addPredecessorProperty(java.util.List<org.shiwa.fgi.iwir.AbstractTask> predTasks,
                                          java.util.List<org.shiwa.fgi.iwir.AbstractTask> succTasks)
Adds properties to tasks for adding control links later on.
Adds a property with key 'predecessors' to all tasks of "succTasks" that have a property with key 'last'. The list of predecessors contains the names of all tasks of "predTasks" that have the property 'first'.

Parameters:
predTasks - list of possible predecessors
succTasks - list of possible successors