Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

JWT Metamodel Extension Specifications/Prototype

Required changes in JWT WE

These samples showcase the mixed static and dynamic EMF technology, thanks to a JWT metamodel with an EObject-typed "aspects" relation on ModelElement (or Action). To be loaded in JWT, it also requires some magic in WEEditor.createModel().

Extract from proposed JWT Metamodel :

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="model"
    nsURI="org.eclipse.jwt" nsPrefix="">
  <eSubpackages name="core" nsURI="org.eclipse.jwt/core" nsPrefix="core">
    <eClassifiers xsi:type="ecore:EClass" name="ModelElement">
      <eStructuralFeatures xsi:type="ecore:EReference" name="aspects" upperBound="-1"
          eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject" containment="true"/>
      ...
    </eClassifiers>
    ...
  </eSubpackages>
  ...
</ecore:EPackage>

Configuring EMF .workflow file loading in WEEditor.createModel() :

                  mainModelResource = getEmfEditingDomain().getResourceSet().createResource(resourceUri);
                  XMIResourceImpl r = (XMIResourceImpl) mainModelResource;
	          r.setEncoding("UTF-8");
	          // load options
	          r.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
	          r.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
	          r.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
	          XMLOptions xmlOptions = new XMLOptionsImpl();
	          xmlOptions.setProcessAnyXML(false); // REQUIRED for XSD ; else won't find ecore classes defined in metamodel extensions ; however doesn't work with old agilpros
	          xmlOptions.setProcessSchemaLocations(true); // not required, works also with false ?!
	          r.getDefaultLoadOptions().put(XMLResource.OPTION_XML_OPTIONS, xmlOptions);
	          // save options (or in doSave())
	          r.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
	          //r.getDefaultSaveOptions().put(XMLResource.OPTION_LINE_WIDTH, new Integer(80));
	          r.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
	          r.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); // REQUIRED else no xsi:schemaLocation after save !
	          //r.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION_IMPLEMENTATION, Boolean.TRUE); // adds java:// schemaLocation for static ecore
		mainModelResource = getEmfEditingDomain().getResourceSet().getResource(
				resourceUri, true);
		// read version from the model object in the resource
		converter.readModelVersionFromFile(getModel(), resourceUri);
 
		// if old version model, reread it now that the version is known
		if (getModel() instanceof AnyType) {
			loadOldVersionModel(resourceUri);
		}

LogAspect sample

Here we define a LogAspect extension meant to provide an Action with additional information (messageFormat and logProtocol attributes) about how it might be logged at runtime.

Metamodel extension definition WEMetaModel_log1.workflow :

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="logModel"
    nsURI="org.eclipse.jwt.log" nsPrefix="">
    <eClassifiers xsi:type="ecore:EClass" name="LogAspect">
      <eStructuralFeatures xsi:type="ecore:EAttribute" name="messageFormat" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
      <eStructuralFeatures xsi:type="ecore:EAttribute" name="logProtocol" lowerBound="1"
          eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
          defaultValueLiteral="syslog"/>
    </eClassifiers>
</ecore:EPackage>

Workflow sample (inspired by a jwt2bpmn unit test workflow) activity_log1.workflow :

<?xml version="1.0" encoding="UTF-8"?>
<core:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:core="org.eclipse.jwt/core"
xmlns:organisations="org.eclipse.jwt/organisations"
xmlns:processes="org.eclipse.jwt/processes"
xmlns:log="org.eclipse.jwt.log"
xsi:schemaLocation="org.eclipse.jwt.log WEMetaModel_log1.ecore"
name="MainPackage" fileversion="0.4.0">
  <elements xsi:type="processes:Activity" name="Diagram1">
    <nodes xsi:type="processes:Action" name="Log Action" in="//@elements.0/@edges.0" out="//@elements.0/@edges.1" performedBy="//@elements.1" referenceEdges="//@elements.0/@referenceEdges.0">
      <aspects xsi:type="log:LogAspect" messageFormat="WARNING %" logProtocol="beep"/>
      <Location x="140" y="153"/>
      <Size width="71" height="31"/>
    </nodes>
    <nodes xsi:type="processes:InitialNode" out="//@elements.0/@edges.0">
      <Location x="41" y="158"/>
    </nodes>
    <nodes xsi:type="processes:FinalNode" in="//@elements.0/@edges.1">
      <Location x="294" y="157"/>
    </nodes>
    <edges source="//@elements.0/@nodes.1" target="//@elements.0/@nodes.0"/>
    <edges source="//@elements.0/@nodes.0" target="//@elements.0/@nodes.2"/>
    <references reference="//@elements.1" referenceEdges="//@elements.0/@referenceEdges.0">
      <Location x="164" y="56"/>
    </references>
    <referenceEdges reference="//@elements.0/@references.0" action="//@elements.0/@nodes.0"/>
  </elements>
  <elements xsi:type="organisations:Role" name="role" icon=""/>
</core:Model>


InvokeWebServiceAspect sample

Adding this aspect to an action (or its application) specifies a runtime invocation of the given web service.

Note that there will be two different ways to invoke a service : either explicitly calling a web service using this aspect, or calling a generic service and also specifying its binding (web service, rmi, xml / rest...) by using another aspect InvokeServiceAspect and runtime infrastructure provided by the friend SCOrWare project.

Metamodel extension definition WEMetaModel_ws.workflow :

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="wsModel"
    nsURI="org.eclipse.jwt.ws" nsPrefix=""
    xmlns:core="org.eclipse.jwt/core"
    xsi:schemaLocation="org.eclipse.jwt/core java://org.eclipse.jwt.we.model.core.CorePackage">
  <eClassifiers xsi:type="ecore:EClass" name="InvokeWebService" instanceClassName="org.eclipse.jwt.we.model.core.impl.AspectImpl"
      eSuperTypes="java://org.eclipse.jwt.we.model.core.CorePackage#//core/ApplicationAspectTemplate">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="bindingType" lowerBound="1"
        eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="wsdl" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="url" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="operation" lowerBound="1"
        eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>
</ecore:EPackage>

Extract from workflow activity sample :

<elements xsi:type="processes:Activity" name="Diagram1">
    <nodes xsi:type="processes:Action" name="WS Action" in="//@elements.0/@edges.0" out="//@elements.0/@edges.1" performedBy="//@elements.1" referenceEdges="//@elements.0/@referenceEdges.0">
      <aspects xsi:type="ws:InvokeWebService" bindingType="ws" wsdl="" url="http://localhost:8080/EchoService" operation="echo"/>
      ...
    </nodes>
...
</elements>

Some screenshots : File:Jwt emfextension ws.png

UserMappingAspect sample

This sample showcases a more complex aspect.

UserMappingAspect's purpose is to allow to provide to an action (or its application) more specific user mappings than those defined globally at workflow level. It is useful when all applications executed by a workflow are not using the same user directory as the workflow engine ; in this case, applications that require specific credentials will use this aspect to provide them.

The UserMappingAspect contains several UserMappings, each specifying how a given runtime user (i.e. a user known within the workflow engine) is mapped to different credentials when talking to the application, which has to exploit this data on its own.

Metamodel extension definition WEMetaModel_usermapping.workflow (added 20080624) :

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="usermappingModel"
    nsURI="org.eclipse.jwt.usermapping" nsPrefix="">
  <eClassifiers xsi:type="ecore:EClass" name="UserMappingAspect" instanceClassName="org.eclipse.jwt.we.model.core.impl.AspectImpl"
      eSuperTypes="WEMetaModel.ecore#//core/ApplicationAspectTemplate">
    <eStructuralFeatures xsi:type="ecore:EReference" name="userMappings" upperBound="-1"
        eType="#//UserMapping" containment="true"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="enabled" lowerBound="1"
        eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean" defaultValueLiteral="true"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="UserMapping">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="username" lowerBound="1"
        eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="password" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="mappedUserName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>
</ecore:EPackage>

Extract from workflow activity sample (added 20080624) :

<elements xsi:type="processes:Activity" name="Diagram1">
    <nodes xsi:type="processes:Action" name="User Mapping Action" in="//@elements.0/@edges.0" out="//@elements.0/@edges.1" performedBy="//@elements.1" referenceEdges="//@elements.0/@referenceEdges.0">
      <aspects xsi:type="usermapping:UserMappingAspect" enabled="true">
        <usermapping:userMappings xsi:type="usermapping:UserMapping" username="guest" password="" mappedUserName="anonymous"/>
        <usermapping:userMappings xsi:type="usermapping:UserMapping" username="admin" password="admin"/>
      </aspects>
      ...
    </nodes>
...
</elements>

Some screenshots (added 20080624) : Jwt emfextension usermapping.png

Back to the top