edu.utah.further.mdr.impl.service.util
Class UmlUtil

java.lang.Object
  extended by edu.utah.further.mdr.impl.service.util.UmlUtil

@Utility
public final class UmlUtil
extends Object

UML/XMI model utilities.

-----------------------------------------------------------------------------------
(c) 2008-2011 FURTHeR Project, AVP Health Sciences IT Office, University of Utah
Contact: Dr. Scott Narus <scott.narus@hsc.utah.edu>
Biomedical Informatics, 26 South 2000 East
Room 5775 HSEB, Salt Lake City, UT 84112
Day Phone: 1-801-213-3288
-----------------------------------------------------------------------------------

Version:
Mar 23, 2009
Author:
Oren E. Livne <oren.livne@utah.edu>

Field Summary
static Comparator<UmlElement> comparatorByName
          Compare UML elements by name.
 
Method Summary
static void buildPackageTree(UmlPackage root, SortedSet<UmlPackage> packages)
          Convert a sorted list of packages to a hierarchical element tree.
static Map<String,UmlClass> getClasses(Map<String,UmlClass> classSet, ClassType classType, UmlPackage pkg)
          Return the sub-set of classes in a collection of classes by class type.
static Map<String,UmlClass> getClasses(UmlModel model, ClassType classType, UmlPackage pkg)
          Return the list of classes in a model by class type.
static boolean isInPackage(UmlClass clazz, UmlPackage pkg)
          Is class in a package.
static void printMessages(XmiParser parser)
          Print an XMI parser messages after parsing a file.
static void printModelTree(UmlPackage root)
           
static void updateAncestryMarks(UmlElement element)
          If the UML element has errors, mark the entire element ancestry (including this object) as having errors of at least the same severity level as the element's marker.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comparatorByName

public static final Comparator<UmlElement> comparatorByName
Compare UML elements by name.

Method Detail

getClasses

public static Map<String,UmlClass> getClasses(UmlModel model,
                                              ClassType classType,
                                              UmlPackage pkg)
Return the list of classes in a model by class type.

Warning: works only for flat models (all classes are under the root model node).

Parameters:
model - UML model
classType - class type. If null, returns all classes
pkg - only classes in this package or any of its sub-packages will be returned, if this parameter is non-null
Returns:
list of classes of type classType under the model

getClasses

public static Map<String,UmlClass> getClasses(Map<String,UmlClass> classSet,
                                              ClassType classType,
                                              UmlPackage pkg)
Return the sub-set of classes in a collection of classes by class type.

Parameters:
classSet - class type. If null, returns all classes
pkg - only classes in this package or any of its sub-packages will be returned, if this parameter is non-null
Returns:
list of classes of type classType under the model

printMessages

public static void printMessages(XmiParser parser)
Print an XMI parser messages after parsing a file.

Parameters:
parser - XMI parser

isInPackage

public static boolean isInPackage(UmlClass clazz,
                                  UmlPackage pkg)
Is class in a package. That is, does the class package list start with the packageNames sub-list.

Parameters:
clazz - UML class
pkg - package
Returns:
is class in the package or any of its sub-packages

buildPackageTree

public static void buildPackageTree(UmlPackage root,
                                    SortedSet<UmlPackage> packages)
Convert a sorted list of packages to a hierarchical element tree.

Parameters:
root - root element of the tree to add packages under
packages - package list

printModelTree

public static void printModelTree(UmlPackage root)
Parameters:
root -

updateAncestryMarks

public static void updateAncestryMarks(UmlElement element)
If the UML element has errors, mark the entire element ancestry (including this object) as having errors of at least the same severity level as the element's marker. (The marker severity level of a parent is the maximum over the levels of its descendants markers).

Then we get an eclipse-like explorer display where an error is easy to find because it propagates up the hierarchy -- up to the very top.

Parameters:
element - UML element


Copyright © 2011 Office of the AVP for Health Sci. IT. All Rights Reserved.