JUDE API User Guide

January 31, 2007
Change Vision, Inc.



[What's JUDE API]

JUDE API is a Java Interface Group for developing applications software using JUDE model data.
This document will explain how to develop applications using the JUDE API.

[Permission to Use]

[JUDE API System Requirements]

The system environments that enable JUDE to run are required to run applications software using JUDE API.

[Features]

JUDE API enables you to obtain JUDE model elements and use them on applications software.
The reference of model elements used in Class Diagrams and UseCase Diagrams, Activity Diagrams, Sequence Diagrams, FlowChart, Mindmap are currently supported. .

[How to get Model Information]

We will show you how to get model information simply with examples using Class Diagrams, Object Diagrams and sample programs in this paragraph.
Please refer to JUDE API JavaDoc for details for each interface and methods.

How to get Attribute information of class

You can get the array of Attributes by calling Class(IClass) Method getAttributes().
In case the class is associated with other classes, the information of the association end will be also included in Attribute information objects.
For example, if Class0 has attribute0 and is associated with Class1 (association end role name class1), the attribute information of Class0 will be shown like this figure.

How to get Operation information of class

You can get the array of Operations by calling Class(IClass) Method getOperations()

How to get Dependency information of class

You can get the array of all Dependencies of the selected class by calling Class(IClass) Method getClientDependencies(). By calling getSupplier(), you can get the supplier class of the selected class.
For example, in case that Class0 depends on Class1, the information will be shown like this figure.

How to get Realization information of class

You can get the array of Realizations between the selected class and the realized interfaces by calling Class(IClass) Method getClientRealizations(). By calling getSupplier(), you can get the realized interfaces.
For example, in case that Class1 realizes Class0, the information will be shown like this figure.

How to get Generalization information of class

You can get the array of Generalizations between the selected class and its superclass by calling Class(IClass) Method getGeneralizations(). By calling getSuperType(), you can get its superclass information.
For example, in case that Class1 inherits Class0, the information will be like this figure.

How to get a Model of project accessor

All model information in JUDE Project file is stored under the model of project accessor (Project model) in a tree structure.
First, get the ProjectAccessor object and open JUDE project file, then get Project Model (IModel Class object).

ClassDefinitionBuilder.java

        // Open project file and get project model
        ProjectAccessor prjAccessor = ProjectAccessorFactory.getProjectAccessor();
        prjAccessor.open(inputFile);
        IModel iModel = prjAccessor.getProject();


How to get packages under Package recursively

It is defined that Package we call here would include Subsystems and Models that inherit IPackage.
You can get all model elements directly under the package (IPackage) in an array by calling getOwnedElements() and get only packages abstracted from it. By doing so, you can get all packages recursively.

ClassDefinitionBuilder.java

    /**
     * Get packages under Package recursively.
     * 
     * @param iPackage
     *            Selected Package
     * @param iPackages
     *            The list of all stored packages
     * @return The list of all stored packages
     */
    private List getPackages(IPackage iPackage, List iPackages) {
        INamedElement[] iNamedElements = iPackage.getOwnedElements();
        for (int i = 0; i < iNamedElements.length; i++) {
            INamedElement iNamedElement = iNamedElements[i];
            if (iNamedElement instanceof IPackage) {
                iPackages.add(iNamedElement);
                getPackages((IPackage)iNamedElement, iPackages);
            }
        }
        return iPackages;
    }

How to get classes under Package

You can get all model elements directly under the package in an array by calling getOwnedElements() and get only classes abstracted from it.

ClassDefinitionBuilder.java

    /**
     * Get classes under the selected Package.
     * 
     * @param iPackage
     *            Selected package
     * @return the list of all stored classes
     */
    private List getIClasses(IPackage iPackage) {
        List iClasses = new ArrayList();
        INamedElement[] iNamedElements = iPackage.getOwnedElements();
        for (int i = 0; i < iNamedElements.length; i++) {
            INamedElement iNamedElement = iNamedElements[i];
            if (iNamedElement instanceof IClass) {
                iClasses.add(iNamedElement);
            }
        }
        return iClasses;
    }

How to get Full Path Name of class

You can get the name of class by calling getName() in case they are subclasses of INamedElement (i.g. IClass).
In addition, by calling getOwner() that obtains the owned model elements, you can get the Full Path name from the project model.

ClassDefinitionBuilder.java

    /**
     * Get the class name with Full Path
     * 
     * @param iClass
     *            Class
     * @return Class name (Full Path)
     */
    private String getFullName(IClass iClass) {
        StringBuffer sb = new StringBuffer();
        IElement owner = iClass.getOwner();
        while (owner != null && owner instanceof INamedElement && owner.getOwner() != null) {
            sb.insert(0, ((INamedElement) owner).getName() + "::");
            owner = owner.getOwner();
        }
        sb.append(iClass.getName());
        return sb.toString();
    }

[How to get Model Information of an activity diagram]

We will show you how to get model information with examples using class diagram and object diagram
please refer to this pageto get details for each interface and methods.

How to get partition

You can get the array of partitions(IPartition) by calling getPartitions() Method of IActivity.
By calling getSuperPartition() and getSuperPartition(), you can get hierarchy information of partitions.
For example, in case of Partition0 and Partition1, the information will be like diagram.

How to get control flow

You can get the array of control flow(IFlow) by calling getFlows() Method of IActivity.
By calling getIncomings() and getOutgoings(), you can get information of control flow of actions.
For example, in case of two control flows, the information will be like diagram.

How to get actions and start point

You can get the array of ActivityNode(IActivityNode) by calling getActivityNode() Method of IActivity.
By calling getActivityNode() of Partition(IPartition), you can get actions' information in a partition.
For example, the information for actions0 and start point will be like diagram.

[How to get Model Information of a sequence diagram]

We will show you how to get model information with examples using class diagram and object diagram
please refer to this pageto get details for each interface and methods.

How to get lifeline

You can get the array of Lifeline(ILifeline) by calling getLifelines() Method of Interaction(IInteraction).
For example, the information of LifeLine0 will be like diagram.

How to get compound fragment

You can get the array of CombinedFragment(ICombinedFragment) and Message(IMessage) by calling getFragments() Method of Interaction(IInteraction).
For example, the information of alt compound fragment will be like diagram.

How to get operand

You can get the array of InteractionOperand(IInteractionOperand) by calling getInteractionOperands() Method of CombinedFragment(ICombinedFragment).
For example, the information of two compound fragments in alt compound fragment will be like diagram.

How to get message

You can get the array of CombinedFragment(ICombinedFragment) and Message(IMessage) by calling getFragments() Method of Interaction(IInteraction).
For example, the information of Message0 will be like diagram.

[How to get diagrams]

NamedElement(INamedElement) is the parent of diagram(IDiagram) and package(IPackage), partion(IPartition) etc.
All diagrams can be got by getDiagrams() of an namedElement.

Example: How to get an activity diagram

public List getActivityDiagram(IPackage iPackage) {
    List activityDiagrams = new ArrayList();
    
    IDiagram[] dgms = iPackage.getDiagrams();
    for (int i = 0; i < dgms.length; i++) {
        IDiagram dgm = dgms[i];
        if (dgm instanceof IActivityDiagram 
                && !((IActivityDiagram )dgm).isFlowChart()) {
               activityDiagrams.add(dgm);
        }
    }
    return activityDiagrams;
}

Example: How to get an sequence diagram

public List getFlowCharts(IPackage iPackage) {
    List flowCharts = new ArrayList();
    
    IDiagram[] dgms = iPackage.getDiagrams();
    for (int i = 0; i < dgms.length; i++) {
        IDiagram dgm = dgms[i];
        if (dgm instanceof IActivityDiagram 
                && ((IActivityDiagram )dgm).isFlowChart()) {
            flowCharts.add(dgm);
        }
    }
    return flowCharts ;
}

How to get alias

Alias is hold by taggedValue in a JUDE model.TaggedValues can be got by ITaggedValue
If key of alias1 is "jude.multi_language.alias1" and key of alias2 is "jude.multi_language.alias2",
you can get them by codes below.

Example: How to get alias1

private static final String KEY_ALIAS1 = "jude.multi_language.alias1";

private String geAlias1(INamedElement element) {
    ITaggedValue[] tvs = element.getTaggedValues();
    for (int i = 0; i < tvs.length; i++) {
        ITaggedValue tv = tvs[i];
        if (KEY_ALIAS1.equals(tv.getKey())) {
            return tv.getValue();
        }
    }
    return null;
}

How to get Hyperlink

Hyperlink is hold as taggedvalue in JUDE model.TaggedValue can be got by ITaggedValue.
Hyerlink is hold as taggedValue with key named "jude.hyperlink"

Example for getting hyperlink

private static final String KEY_HYPERLINK = "jude.hyperlink";

private List getHyperlinkStrings(INamedElement element) {
    List hyperlinkStrings = new ArrayList();

    ITaggedValue[] tvs = element.getTaggedValues();
    for (int i = 0; i < tvs.length; i++) {
        ITaggedValue tv = tvs[i];
        if (KEY_HYPERLINK.equals(tv.getKey())) {
            hyperlinkStrings.add(tv.getValue());
        }
    }
    return hyperlinkStrings;
}

Just like the example below, there are kind of hyperlink, name, path, commend in a got string.
As kinds of a hyperlink,file is "file",URL is "url,model is "model".For a modelAname is id which can be got by getId() of IElementImp

Excample: How to get hyperlinkd

type=file,name=jude.log,path=C:/Documents and Settings,comment= Target is a file
type=url,name=http://www.change-vision.com,path=http://,comment= Target is a web page
type=model,name=9a1411-1112fec29a5-0804d01aa6c5fb9fe2aab956b4ca593a,path=,comment= Target is a Jude model

How to get basic elements in a flowChart

Flow chart is a kind of activity diagram in JUDE. Basic elements in a flowchart are action with stereotypes.

How to get loop start element

private static final String LOOP_START_ELEMENT = "loop_start";

public List getLoopStartElements(IActivityDiagram iActivityDiagram) {
   List loopStartElements = new ArrayList();

   IActivity iActivity = iActivityDiagram.getActivity();
   IActivityNode[] activityNodes = iActivity.getActivityNodes();
   for (int i = 0; i < activityNodes.length; i++) {
        IActivityNode node = activityNodes[i];
        String[] stereotypes = node.getStereotypes();
        for (int j = 0; j < stereotypes.length; j++) {
           if (LOOP_START_ELEMENT.equals(stereotypes[j])) {
               loopStartElements.add(node);
               break;
           }
        }
    }
    return loopStartElements;
}

Stereotype list of basic elements

process‚P <--- As standard process, there is no stereotypeB
process2(flow_process)
Predefined Process (predefined_process)
Hand Work (hand_work)
Preparation (preparation)
Server(server)
Machine(machine)
Data(data)
Stored Data(stored_data)
Internal Storage(internal_storage)
Sequential Storage(sequential_storage)
Disk(disk)
Database(database)
Document(document)
Hand Inputting(hand_inputting)
Display(display)
Judgement(judgement)
Loop Start(loop_start)
Loop End(loop_end)
Internal Connector(internal_connector)
External Connector(external_connector)

[Save as Project, Export/Import XMI]

Export XMI

Export JUDE Project file to XMI file (.xml).
Export XMI function is not available in JUDE/Community.

Example of Export XMI

import com.change_vision.jude.api.inf.project.ProjectAccessor;
import com.change_vision.jude.api.inf.project.ProjectAccessorFactory;

public class Test {
  public static void main(String[] args) {
	try {
		ProjectAccessor prjAccessor = ProjectAccessorFactory.getProjectAccessor();

		prjAccessor.open("C:\\API\\pro305.jude");      		
		prjAccessor.exportXMI("C:\\API\\pro305_xmi.xml");
		prjAccessor.close();

	} catch (Exception e) {
		e.printStackTrace();
	}
  }
}

Import XMI

Import XMI project file(.xml) to a JUDE project file.
XMI Import function is not available in JUDE/Community. Ensure to let the ClassPath go through the jar that locates in the JUDE/Professional Install folder\lib to execute XMI Import. Ensure to let the ClassPath go through the jar that locates in the JUDE/Professional Install folder\lib to execute XMI Import.

Save as Project

Save as a new project(.jude).

Example of XMI Import and Save as Project

import com.change_vision.jude.api.inf.project.ProjectAccessor;
import com.change_vision.jude.api.inf.project.ProjectAccessorFactory;

public class Test {
  public static void main(String[] args) {
	try {
		ProjectAccessor prjAccessor = ProjectAccessorFactory.getProjectAccessor();

		prjAccessor.importXMI("C:\\API\\pro305_xmi.xml");  
		prjAccessor.saveAs("C:\\API\\pro305_2.jude"); 
		prjAccessor.close();
  		
	} catch (Exception e) {
		e.printStackTrace();
	}
  }
}

Using Import/Export XMI in JUDE API

JUDE API for Import/Export XMI is available with the following steps.

Export JUDE project file to XMI - Edit - Import XMI - Save as JUDE project file.

import com.change_vision.jude.api.inf.project.ProjectAccessor;
import com.change_vision.jude.api.inf.project.ProjectAccessorFactory;

public class Test {
  public static void main(String[] args) {
	try {
		ProjectAccessor prjAccessor = ProjectAccessorFactory.getProjectAccessor();

		prjAccessor.open("C:\\API\\pro305.jude");      		
		prjAccessor.exportXMI("C:\\API\\pro305_xmi.xml");
		prjAccessor.close();

		// Edit

		prjAccessor.importXMI("C:\\API\\pro305_xmi.xml");  
		prjAccessor.saveAs("C:\\API\\pro305_2.jude"); 
		prjAccessor.close();
  		
	} catch (Exception e) {
		e.printStackTrace();
	}
  }
}

[Expanded information about Model elements]

What is the difference between UML metamodel and JUDE API?

A part of the class structure of JUDE API is different from the one of UML metamodel.
JUDE API has a simplified structure. Some of abstract model elements in the UML metamodel inheritance structure are eliminated because they would never be instantiated as model elements.
Refer to JUDE API JavaDoc for more details.

Class elements contain Icon Notations

Those elements that can be shown as normal class notations such as Actor, Interface, Boundary, Entity, Control are classes that have stereotypes.
For example, Actor is a class that has a stereotype of "Actor", and Interface is a class that has a stereotype of "Interface".

About TaggedValue(ITaggedValue)

JUDE uses TaggedValus for derived information of Attributes and Role names, and expressions about UseCase descriptions.

[Sample Applications]

ClassDefinitionExporter

Class information in JUDE Project File would be exported into CSV format.
There are 5 information of the class get exported; Class Full Path name, Attribute, Operation, Definition, SuperClass, and Supplier of the realization.


How to compile

Compilation can be done with your system command prompt or Java IDE (Integrated Development Environments) tool. The class path needs to be set to both of JUDE install folder and jude-api.jar that is inside the same folder.

Sample : Compiles using [compile.bat] that is a batch file for Windows command prompt

C:\Program Files\JUDE-XXXXXXXXXX\api\sample\csvexporter>compile


How to Run

Running can be done by specifying the JUDE project file name as the first parameter and the csv format file name where is the target to export as the second parameter by using your system command prompt or Java IDE (Integrated Development Environments) tool. The Class Path needs to be set to both of jude-api.jar and jude-community.jar(jude-pro.jar) that are in the install folder.
Also, memory option for Java environment needs to be set up in case the size of your JUDE Project is large.

Sample : Running using [run.bat] that is a batch file for Windows command prompt.

C:\Program Files\JUDE-XXXXXXXXXX\api\sample\csvexporter>run ..\APISample.jude APISample.csv