Reading a MagicDraw Profile

Here is a sample code that shows how to read a MagicDraw Profile, and import it in a MagicDraw Model:
Map<String, Object> options = new HashMap<String, Object>();
try {
	// Create an MDWorkbench Model
	com.sodius.mdw.core.model.Model model = mdw.getMetamodelManager().getMetamodel(UMLPackage.eINSTANCE).createModel();
	// Create a Package in the Model
	com.sodius.mdw.metamodel.uml21.Package dataModel = newModel.create(UMLPackage.Literals.MODEL);
	dataModel.setName("Data");
	// Resource used to homogenise the model (unique id...)
	com.sodius.mdw.metamodel.uml21.io.md.utils.MagicDraw2UMLResourceManager  md2umlResourceManager = new MagicDraw2UMLResourceManager();
	md2umlResourceManager.create((com.sodius.mdw.metamodel.uml21.Model) dataModel);
	// Import Profile in Model (create Package Import)
	options.put(MagicDrawOptions.OPTION_MAGIC_DRAW_VERSION, MagicDrawVersion.LATEST.getVersionName());
	new MagicDrawProfileResourceReader(model, options).read(path_to_profile);
	...
	// Delete temporary Model
	md2umlResourceManager.delete();
} catch (CoreException e) {
	...
}
Where path_to_profile represents the path to the profile to load.
If the profile to load is a predefined MagicDraw profile, path_to_profile should look like pathmap://MAGIC_DRAW/ER_profile.mdzip.uml.
If the profile to load is a mdzip file, path_to_profile should look like file:///" + new File("c:\\myProfile.mdzip").getPath().

Reading the SysML Profile

Here is a sample code that shows how to read the SysML Profile - to create a SysML MagicDraw Model
Map<String, Object> options = new HashMap<String, Object>();
try {
	// Create an MDWorkbench Model
	com.sodius.mdw.core.model.Model model = mdw.getMetamodelManager().getMetamodel(UMLPackage.eINSTANCE).createModel();
	// Create a Package in the Model
	com.sodius.mdw.metamodel.uml21.Package dataModel = newModel.create(UMLPackage.Literals.MODEL);
	dataModel.setName("Data");
	// Resource used to homogenise the model (unique id...)
	com.sodius.mdw.metamodel.uml21.io.md.utils.MagicDraw2UMLResourceManager  md2umlResourceManager = new MagicDraw2UMLResourceManager();
	md2umlResourceManager.create((com.sodius.mdw.metamodel.uml21.Model) dataModel);
	// Import Profile in Model (create Package Import)
	options.put(MagicDrawOptions.OPTION_MAGIC_DRAW_VERSION, MagicDrawVersion.LATEST.getVersionName());
	new MagicDrawProfileResourceReader(model, options).readSysML();
	...
	// Delete temporary Model
	md2umlResourceManager.delete();
} catch (CoreException e) {
	...
}

Reading the UPDM Profile

Here is a sample code that shows how to read the UPDM Profile - to create a UPDM2 MagicDraw Model
Map<String, Object> options = new HashMap<String, Object>();
try {
	// Create an MDWorkbench Model
	com.sodius.mdw.core.model.Model model = mdw.getMetamodelManager().getMetamodel(UMLPackage.eINSTANCE).createModel();
	// Create a Package in the Model
	com.sodius.mdw.metamodel.uml21.Package dataModel = newModel.create(UMLPackage.Literals.MODEL);
	dataModel.setName("Data");
	// Resource used to homogenise the model (unique id...)
	com.sodius.mdw.metamodel.uml21.io.md.utils.MagicDraw2UMLResourceManager  md2umlResourceManager = new MagicDraw2UMLResourceManager();
	md2umlResourceManager.create((com.sodius.mdw.metamodel.uml21.Model) dataModel);
	// Import Profile in Model (create Package Import)
	options.put(MagicDrawOptions.OPTION_MAGIC_DRAW_VERSION, MagicDrawVersion.LATEST.getVersionName());
	new MagicDrawProfileResourceReader(model, options).readUPDM();
	...
	// Delete temporary Model
	md2umlResourceManager.delete();
} catch (CoreException e) {
	...
}

Reading the BPMN Profile

Here is a sample code that shows how to read the BPMN Profile - to create a BPMN2 MagicDraw Model
Map<String, Object> options = new HashMap<String, Object>();
try {
	// Create an MDWorkbench Model
	com.sodius.mdw.core.model.Model model = mdw.getMetamodelManager().getMetamodel(UMLPackage.eINSTANCE).createModel();
	// Create a Package in the Model
	com.sodius.mdw.metamodel.uml21.Package dataModel = newModel.create(UMLPackage.Literals.MODEL);
	dataModel.setName("Data");
	// Resource used to homogenise the model (unique id...)
	com.sodius.mdw.metamodel.uml21.io.md.utils.MagicDraw2UMLResourceManager  md2umlResourceManager = new MagicDraw2UMLResourceManager();
	md2umlResourceManager.create((com.sodius.mdw.metamodel.uml21.Model) dataModel);
	// Import Profile in Model (create Package Import)
	options.put(MagicDrawOptions.OPTION_MAGIC_DRAW_VERSION, MagicDrawVersion.LATEST.getVersionName());
	new MagicDrawProfileResourceReader(model, options).readBPMN();
	...
	// Delete temporary Model
	md2umlResourceManager.delete();
} catch (CoreException e) {
	...
}

Reading the Ecore Profile

Here is a sample code that shows how to read the Ecore Profile:
Map<String, Object> options = new HashMap<String, Object>();
try {
	// Create MDWorkbench Model
	com.sodius.mdw.core.model.Model model = mdw.getMetamodelManager().getMetamodel(UMLPackage.eINSTANCE).createModel();
	// Create a Package in the Model
	com.sodius.mdw.metamodel.uml21.Package dataModel = newModel.create(UMLPackage.Literals.MODEL);
	dataModel.setName("Data");
	// Resource used to homogenise the model (unique id...)
	com.sodius.mdw.metamodel.uml21.io.md.utils.MagicDraw2UMLResourceManager  md2umlResourceManager = new MagicDraw2UMLResourceManager();
	md2umlResourceManager.create((com.sodius.mdw.metamodel.uml21.Model) dataModel);
	// Import Profile in Model (create Package Import)
	options.put(MagicDrawOptions.OPTION_MAGIC_DRAW_VERSION, MagicDrawVersion.LATEST.getVersionName());
	new MagicDrawProfileResourceReader(model, options).readEcore();
	...
	// Delete temporary Model
	md2umlResourceManager.delete();
} catch (CoreException e) {
	...
}

Related concepts
Profile and Stereotype

Related reference
MDAccess for UML API Reference
MDAccess for MagicDraw API Reference
MagicDraw Profile Resource Reader