com.ibm.jps.util
Class RSMModel

java.lang.Object
  extended by com.ibm.jps.util.RSMModel

public class RSMModel
extends java.lang.Object

Contains utilities for manipulating UML model elements.


Constructor Summary
RSMModel()
           
 
Method Summary
static org.eclipse.uml2.uml.Profile applyProfile(org.eclipse.uml2.uml.Package inToPkg, java.lang.String inExtension, java.lang.String inProfileName)
          applyProfile will apply the specified profile to the specified package (typically a model) if it is not already applied.
static boolean areNamespacesDependent(org.eclipse.uml2.uml.Namespace inFrom, org.eclipse.uml2.uml.Namespace inTo)
          arePackagesDependent determines whether or not the client Namespace ('from') depends on the supplier Namespace ('to').
static boolean areOperationsEqual(org.eclipse.uml2.uml.Operation op1, org.eclipse.uml2.uml.Operation op2)
          Checks if two operations are equal.
static boolean classContainsOperation(org.eclipse.uml2.uml.Class cls, org.eclipse.uml2.uml.Operation op)
          Checks if a class contains the specified operation
static boolean classifierDependsOn(org.eclipse.uml2.uml.Classifier inElt, org.eclipse.uml2.uml.Namespace inNS)
          dependsOn determines if the input element (inElt) depends on the target namespace (inNS), i.e. if inElt has a relationship with any element belonging to the target namespace.
static boolean containedIn(java.lang.String source, java.lang.String target)
          containedIn determines if the 'source' package is contained in the 'target' package.
static void copyOperation(org.eclipse.uml2.uml.Operation inOp, org.eclipse.uml2.uml.Interface inInt)
          Copies the specified operation to the target interface
static org.eclipse.uml2.uml.Package createPackageHierarchy(org.eclipse.uml2.uml.Package inRootPkg, java.lang.String inFromQualifiedName)
          createPackageHierarchy takes as an input a qualified name like 'model::package1::package2::namedelement' and will generate under the specified root package (inRootPkg) the following package hierarchy:
(root package)
.....package1
..........package2 The 'model' prefix in the qualified name is ignored, as well as the 'namedelement' suffix.
static org.eclipse.uml2.uml.Abstraction createTrace(org.eclipse.uml2.uml.NamedElement inFrom, org.eclipse.uml2.uml.NamedElement inTo)
          Creates a <> dependency from a client to a supplier.
static boolean dependencyExists(org.eclipse.uml2.uml.Namespace inFrom, org.eclipse.uml2.uml.Namespace inTo)
          dependencyExists returns true if there is a dependency relationship whether explicit or implicit.
static java.util.List<org.eclipse.uml2.uml.Actor> findAssociatedActors(org.eclipse.emf.ecore.EObject inObj, org.eclipse.uml2.uml.UseCase inUC)
          Returns of list of actors associated with the specified use case.
static java.util.List<RSMRelation> findClients(org.eclipse.emf.ecore.EObject inObj, org.eclipse.uml2.uml.Classifier inCl)
          Returns the clients of the specified classifier.
static org.eclipse.uml2.uml.Element findElement(org.eclipse.uml2.uml.Package inPkg, org.eclipse.emf.ecore.EClass inElementKind, java.lang.String inElementName)
          Finds a named element of a given type in the specified package.
static java.util.List<org.eclipse.emf.ecore.EObject> findElements(org.eclipse.emf.ecore.EObject inObj, org.eclipse.emf.ecore.EClass inElementKind)
          Finds recursively all elements of the specified kind within the specified object.
static java.util.List<org.eclipse.uml2.uml.Element> findElements(org.eclipse.uml2.uml.Package inPkg, org.eclipse.emf.ecore.EClass inElementKind, java.lang.String inElementName)
          Finds elements of a given type with a given name in the specified package.
static java.util.List<org.eclipse.uml2.uml.Element> findLinkedElement(org.eclipse.uml2.uml.Package inPkg, org.eclipse.emf.ecore.EClass inElementKind, org.eclipse.emf.ecore.EClass inRelationKind, java.lang.String inElementName, boolean recursiveSearch)
          Finds objects of a given type linked through relationships of the specified kind to the specified named element.
static org.eclipse.uml2.uml.Profile findProfile(java.lang.String inExtension, java.lang.String inProfileName)
           
static java.util.List<RSMRelation> findSuppliers(org.eclipse.emf.ecore.EObject inObj, org.eclipse.uml2.uml.Classifier inCl)
           
static org.eclipse.uml2.uml.Abstraction findTrace(org.eclipse.uml2.uml.NamedElement inFrom, org.eclipse.uml2.uml.NamedElement inTo)
           
static java.lang.String getBasicInfo(org.eclipse.emf.ecore.EObject elt)
           
static java.util.List<RSMRelation> getDependencies(org.eclipse.uml2.uml.NamedElement inNE)
           
static java.lang.String getDocumentation(org.eclipse.uml2.uml.Element from)
           
static org.eclipse.uml2.uml.NamedElement getElementByQualifiedName(org.eclipse.uml2.uml.Package inPkg, java.lang.String elementQualifiedName)
           
static org.eclipse.uml2.uml.Model getModel(org.eclipse.uml2.uml.Element elt)
           
static org.eclipse.core.resources.IResource getModelResource(org.eclipse.uml2.uml.NamedElement elt)
           
static java.lang.String getNameWithoutModel(java.lang.String name)
           
static java.util.List<RSMRelation> getRelations(org.eclipse.uml2.uml.Classifier inCl)
           
static java.lang.String getStereotypes(org.eclipse.uml2.uml.Element elt)
           
static boolean haveSameSignature(org.eclipse.uml2.uml.Operation op1, org.eclipse.uml2.uml.Operation op2)
          Checks if two operations have the same signature.
static boolean haveSameSignature(org.eclipse.uml2.uml.Parameter p1, org.eclipse.uml2.uml.Parameter p2)
          Checks if two parameters have the same signature.
static boolean interfaceContainsOperation(org.eclipse.uml2.uml.Interface inInt, org.eclipse.uml2.uml.Operation inOp)
          Checks if a interface contains the specified operation
static void setDocumentation(org.eclipse.uml2.uml.NamedElement to, java.lang.String text)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RSMModel

public RSMModel()
Method Detail

applyProfile

public static org.eclipse.uml2.uml.Profile applyProfile(org.eclipse.uml2.uml.Package inToPkg,
                                                        java.lang.String inExtension,
                                                        java.lang.String inProfileName)
applyProfile will apply the specified profile to the specified package (typically a model) if it is not already applied. The applied profile - or null if not found - is returned to the caller.

Parameters:
inToPkg - The package to apply the profile to
inExtension - The name of the extension containing the profile (e.g. the RUP Analysis profile is found in 'com.ibm.xtools.modeler.ui.templates')
inProfileName - The profile name (e.g. the RUP Analysis profile is called 'Analysis Profile')
Returns:
The applied profile or null (if the profile is not found)

areNamespacesDependent

public static boolean areNamespacesDependent(org.eclipse.uml2.uml.Namespace inFrom,
                                             org.eclipse.uml2.uml.Namespace inTo)
arePackagesDependent determines whether or not the client Namespace ('from') depends on the supplier Namespace ('to'). If the client and supplier are the same object, or if the supplier is contained in the client, 'false' is returned.

Parameters:
inFrom - The client Namespace
inTo - The supplier Namespace
Returns:
True if the client Namespace depends on the supplier Namespace

areOperationsEqual

public static boolean areOperationsEqual(org.eclipse.uml2.uml.Operation op1,
                                         org.eclipse.uml2.uml.Operation op2)
Checks if two operations are equal. Two operations are defined to be equal if they have the same name and the same signature.

Parameters:
op1 - The first operation
op2 - The second operation
Returns:
True if the operations have the same name and signature

classContainsOperation

public static boolean classContainsOperation(org.eclipse.uml2.uml.Class cls,
                                             org.eclipse.uml2.uml.Operation op)
Checks if a class contains the specified operation

Parameters:
cls - The class to be searched for the presence of the specified operation.
op - The operation
Returns:
True if the class contains the operation.

classifierDependsOn

public static boolean classifierDependsOn(org.eclipse.uml2.uml.Classifier inElt,
                                          org.eclipse.uml2.uml.Namespace inNS)
dependsOn determines if the input element (inElt) depends on the target namespace (inNS), i.e. if inElt has a relationship with any element belonging to the target namespace.

Parameters:
inElt - The input element
inNS - The target namespace
Returns:
True if the input element depends on the target namespace

containedIn

public static boolean containedIn(java.lang.String source,
                                  java.lang.String target)
containedIn determines if the 'source' package is contained in the 'target' package.

Parameters:
String - source
String - target
Returns:
boolean

copyOperation

public static void copyOperation(org.eclipse.uml2.uml.Operation inOp,
                                 org.eclipse.uml2.uml.Interface inInt)
Copies the specified operation to the target interface

Parameters:
inOp - The operation to duplicate
inInt - The target interface

createPackageHierarchy

public static org.eclipse.uml2.uml.Package createPackageHierarchy(org.eclipse.uml2.uml.Package inRootPkg,
                                                                  java.lang.String inFromQualifiedName)
createPackageHierarchy takes as an input a qualified name like 'model::package1::package2::namedelement' and will generate under the specified root package (inRootPkg) the following package hierarchy:
(root package)
.....package1
..........package2

The 'model' prefix in the qualified name is ignored, as well as the 'namedelement' suffix. createPackageHierarchy will return the last package in the hierarchy (package2 in the example, or the root package if the input qualified name is something like 'model::namedelement'.

createPackageHierarchy is typically used to duplicate a package hierarchy from an input model to a target model.

Parameters:
inRootPkg - The root package under which the package hierarchy should be created
inFromQualifiedName - Q full qualified name such as 'model::package1::package2::namedelement'
Returns:
The last package in the hierarchy (package2 in the example) or the root package

createTrace

public static org.eclipse.uml2.uml.Abstraction createTrace(org.eclipse.uml2.uml.NamedElement inFrom,
                                                           org.eclipse.uml2.uml.NamedElement inTo)
Creates a <> dependency from a client to a supplier.

Parameters:
inFrom - The client element
inTo - The supplier element
Returns:
The created relationship

dependencyExists

public static boolean dependencyExists(org.eclipse.uml2.uml.Namespace inFrom,
                                       org.eclipse.uml2.uml.Namespace inTo)
dependencyExists returns true if there is a dependency relationship whether explicit or implicit.

Parameters:
inFrom - The client namespace
inTo - The supplier namespace
Returns:
True if the client has a dependency relationship (explicit or implicit) to the supplier

findAssociatedActors

public static java.util.List<org.eclipse.uml2.uml.Actor> findAssociatedActors(org.eclipse.emf.ecore.EObject inObj,
                                                                              org.eclipse.uml2.uml.UseCase inUC)
Returns of list of actors associated with the specified use case.

Parameters:
inObj - The Ecore object containing the possible associations (typically the whole model)
inUC - The referenced use case
Returns:
The list of actors associated with the use case

findClients

public static java.util.List<RSMRelation> findClients(org.eclipse.emf.ecore.EObject inObj,
                                                      org.eclipse.uml2.uml.Classifier inCl)
Returns the clients of the specified classifier.

Parameters:
inObj - The Ecore object to search
inCl - The input classifier
Returns:
The list of RSMRelation objects that are the clients of the input classifier

findElement

public static org.eclipse.uml2.uml.Element findElement(org.eclipse.uml2.uml.Package inPkg,
                                                       org.eclipse.emf.ecore.EClass inElementKind,
                                                       java.lang.String inElementName)
Finds a named element of a given type in the specified package. Only searches the specified package and not the nested packages

Parameters:
inPkg - The package to search into
inElementKind - The kind of element
inElementName - The name of the element
Returns:
The found element or null

findElements

public static java.util.List<org.eclipse.emf.ecore.EObject> findElements(org.eclipse.emf.ecore.EObject inObj,
                                                                         org.eclipse.emf.ecore.EClass inElementKind)
Finds recursively all elements of the specified kind within the specified object.

Parameters:
inObj - The object to search into
inElementKind - The kind of element
Returns:
The list of found objects (of type EObject)

findElements

public static java.util.List<org.eclipse.uml2.uml.Element> findElements(org.eclipse.uml2.uml.Package inPkg,
                                                                        org.eclipse.emf.ecore.EClass inElementKind,
                                                                        java.lang.String inElementName)
Finds elements of a given type with a given name in the specified package. Searches the specified package and all nested packages.

Parameters:
inPkg - The package to search into
inElementKind - The kind of element
inElementName - The name of the element
Returns:
The list of found elements (of type Element)

findLinkedElement

public static java.util.List<org.eclipse.uml2.uml.Element> findLinkedElement(org.eclipse.uml2.uml.Package inPkg,
                                                                             org.eclipse.emf.ecore.EClass inElementKind,
                                                                             org.eclipse.emf.ecore.EClass inRelationKind,
                                                                             java.lang.String inElementName,
                                                                             boolean recursiveSearch)
Finds objects of a given type linked through relationships of the specified kind to the specified named element.

Parameters:
inPkg -
inElementKind -
inRelationKind -
inElementName -
recursiveSearch -
Returns:
The list of found elements (of type Element)

findProfile

public static org.eclipse.uml2.uml.Profile findProfile(java.lang.String inExtension,
                                                       java.lang.String inProfileName)
Parameters:
inExtension -
inProfileName -
Returns:
The found profile

findSuppliers

public static java.util.List<RSMRelation> findSuppliers(org.eclipse.emf.ecore.EObject inObj,
                                                        org.eclipse.uml2.uml.Classifier inCl)
Parameters:
inObj -
inCl -
Returns:
The list RSMRelation objects

findTrace

public static org.eclipse.uml2.uml.Abstraction findTrace(org.eclipse.uml2.uml.NamedElement inFrom,
                                                         org.eclipse.uml2.uml.NamedElement inTo)
Parameters:
inFrom -
inTo -
Returns:
The found <> abstraction

getBasicInfo

public static java.lang.String getBasicInfo(org.eclipse.emf.ecore.EObject elt)
Parameters:
elt -
Returns:
The string containing the object's basic information

getDependencies

public static java.util.List<RSMRelation> getDependencies(org.eclipse.uml2.uml.NamedElement inNE)
Parameters:
inNE -
Returns:
The list of found dependencies (as RSMRelation objects)

getDocumentation

public static java.lang.String getDocumentation(org.eclipse.uml2.uml.Element from)
Parameters:
from -
Returns:
The element's documentation

getElementByQualifiedName

public static org.eclipse.uml2.uml.NamedElement getElementByQualifiedName(org.eclipse.uml2.uml.Package inPkg,
                                                                          java.lang.String elementQualifiedName)
Parameters:
inPkg -
elementQualifiedName -
Returns:
The found element or null

getModel

public static org.eclipse.uml2.uml.Model getModel(org.eclipse.uml2.uml.Element elt)
Parameters:
elt -
Returns:
The model of the element

getModelResource

public static org.eclipse.core.resources.IResource getModelResource(org.eclipse.uml2.uml.NamedElement elt)
Parameters:
elt -
Returns:
The resource of the element or null

getNameWithoutModel

public static java.lang.String getNameWithoutModel(java.lang.String name)
Parameters:
name -
Returns:
The name of the element without the model

getRelations

public static java.util.List<RSMRelation> getRelations(org.eclipse.uml2.uml.Classifier inCl)
Parameters:
inCl -
Returns:
List of RSMRelation objects

getStereotypes

public static java.lang.String getStereotypes(org.eclipse.uml2.uml.Element elt)
Parameters:
elt -
Returns:
The applied stereotypes as a string

haveSameSignature

public static boolean haveSameSignature(org.eclipse.uml2.uml.Operation op1,
                                        org.eclipse.uml2.uml.Operation op2)
Checks if two operations have the same signature. Two operations are defined to have the same signature if the parameter lists of the operations have the same number of parameters, the parameters appear in the lists in the same order, and each parameter in one operation has the same signature as the corresponding parameter of the second operation. Note that the return parameter does not contribute to the signature of an operation.

Parameters:
op1 - First operation
op2 - Second operation
Returns:
True if the operations have the same signature

haveSameSignature

public static boolean haveSameSignature(org.eclipse.uml2.uml.Parameter p1,
                                        org.eclipse.uml2.uml.Parameter p2)
Checks if two parameters have the same signature. Two parameters are defined to have the same signature if they are of the same type and they have the same direction. The names of the parameters are ignored because in the context of an operation the names do not determine the signature of an operation. Also, if the types of the parameters are unspecified (that is if getType() for each parameter is null, the parameters are defined to have the same signature only if their directions are the same.

Parameters:
p1 - First parameter
p2 - Second parameter
Returns:
True if the parameters have the same types and direction

interfaceContainsOperation

public static boolean interfaceContainsOperation(org.eclipse.uml2.uml.Interface inInt,
                                                 org.eclipse.uml2.uml.Operation inOp)
Checks if a interface contains the specified operation

Parameters:
cls - The interface to be searched for the presence of the specified operation.
inOp - The operation
Returns:
True if the interface contains the operation.

setDocumentation

public static void setDocumentation(org.eclipse.uml2.uml.NamedElement to,
                                    java.lang.String text)
Parameters:
to -
text -