Cameo Simulation Toolkit is a MagicDraw plugin which provides a unique set of tools supporting the standard-ized construction, verification, and execution of computational complete models based on a foundational sub-set of the UML. No Magic is the first in the industry to provide customers with an easy-to-use, standard-based executable UML. Log in / Sign up.
|
package mainPackage;
import com.nomagic.uml2.ext.jmi.helpers.StereotypesHelper;
import com.nomagic.uml2.ext.magicdraw.auxiliaryconstructs.mdmodels.Model;
import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element;
import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement;
import com.nomagic.uml2.ext.magicdraw.mdprofiles.Stereotype;
import java.util.Collection;
import com.nomagic.magicdraw.core.Application;
import com.nomagic.magicdraw.core.Project;
import com.nomagic.magicdraw.properties.Property;
public class ModelExplorer {
public ModelExplorer(){
Project project = Application.getInstance().getProject();
Collection<Stereotype> allStereo = StereotypesHelper.getAllStereotypes(Application.getInstance().getProject());
System.out.println(allStereo.toArray().toString());
//StereotypesHelper.getExtendedElements(MagicDrawProfile.ELEMENTSLIBRARY_STEREOTYPE);
@SuppressWarnings('deprecation')
Model model = project.getModel();
Collection<Element> modelElements = model.getOwnedElement();
Object[] modelElementsArray = modelElements.toArray();
for(int i = 0; i < modelElementsArray.length; i++){
try {
String elementsName = ((NamedElement) modelElementsArray[i]).getName();
//System.out.println(elementsName);
if(elementsName.equals('InstancePackage')){
Collection<Element> packageElements = ((Element) modelElementsArray[i]).getOwnedElement();
Object[] packageElementsArray = packageElements.toArray();
for(int j = 0; j < packageElementsArray.length; j++){
try {
String propertiesName = ((NamedElement) packageElementsArray[j]).getName();
//System.out.println(propertiesName);
if(propertiesName.equals('Aqua')){
Collection<Element> deepElements = ((Element) packageElementsArray[j]).getOwnedElement();
Object[] deepElementsArray = deepElements.toArray();
for(int k = 0; k < deepElementsArray.length; k++){
try {
//String deepName = ((Slot) deepElementsArray[k]).getName();
//System.out.println(deepName);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//System.out.println(elements.toString());
}
}