Examples of ExtendedMetaData


Examples of org.eclipse.emf.ecore.util.ExtendedMetaData

   * @return the new TypeHelper.
   */
  public static TypeHelper createTypeHelper()
  {
    EPackage.Registry registry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);
    ExtendedMetaData extendedMetaData = new SDOExtendedMetaDataImpl(registry); //TODO create subclass that makes demand() methods synchronous
    return new TypeHelperImpl(extendedMetaData);
  }
View Full Code Here

Examples of org.eclipse.emf.ecore.util.ExtendedMetaData

      return null;
  }
 
  public static Type createType(TypeHelper scope, String uri, String name, boolean isDataType)
  {
    ExtendedMetaData extendedMetaData = ((TypeHelperImpl)scope).getExtendedMetaData();
   
    EPackage ePackage = extendedMetaData.getPackage(uri);
    if (ePackage == null)
    {
      ePackage = EcoreFactory.eINSTANCE.createEPackage();
      ePackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl());
      ePackage.setNsURI(uri);
      String packagePrefix = URI.createURI(uri).trimFileExtension().lastSegment();
      ePackage.setName(packagePrefix);
      ePackage.setNsPrefix(packagePrefix);
      extendedMetaData.putPackage(uri, ePackage);
    }

    EClassifier eClassifier = ePackage.getEClassifier(name);
    if (eClassifier != null) // already defined?
    {
View Full Code Here

Examples of org.eclipse.emf.ecore.util.ExtendedMetaData

        DataInput taskNameDataInput = null;
        if(properties.get("taskname") != null && properties.get("taskname").length() > 0) {

            if(isCustomElement(properties.get("tasktype"), preProcessingData)) {
                // add droolsjbpm-specific attribute "taskName"
                ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
                EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                        "http://www.jboss.org/drools", "taskName", false, false);
                SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                        properties.get("taskname").replaceAll("&","").replaceAll(" ", ""));
                task.getAnyAttribute().add(extensionEntry);
            }

            // map the taskName to iospecification
            taskNameDataInput = Bpmn2Factory.eINSTANCE.createDataInput();
            taskNameDataInput.setId(task.getId() + "_TaskNameInputX");
            taskNameDataInput.setName("TaskName");
           
            if(task.getIoSpecification() == null) {
                InputOutputSpecification iospec = Bpmn2Factory.eINSTANCE.createInputOutputSpecification();
                task.setIoSpecification(iospec);
            }
            task.getIoSpecification().getDataInputs().add(taskNameDataInput);
            // taskName also needs to be in dataInputAssociation
            DataInputAssociation taskNameDataInputAssociation = Bpmn2Factory.eINSTANCE.createDataInputAssociation();
            taskNameDataInputAssociation.setTargetRef(taskNameDataInput);
       
            Assignment taskNameAssignment = Bpmn2Factory.eINSTANCE.createAssignment();
            FormalExpression fromExp = Bpmn2Factory.eINSTANCE.createFormalExpression();
            fromExp.setBody(properties.get("taskname").replaceAll("&","").replaceAll(" ", ""));
            taskNameAssignment.setFrom(fromExp);
            FormalExpression toExp = Bpmn2Factory.eINSTANCE.createFormalExpression();
            toExp.setBody(task.getId() + "_TaskNameInputX");
            taskNameAssignment.setTo(toExp);
            taskNameDataInputAssociation.getAssignment().add(taskNameAssignment);

            task.getDataInputAssociations().add(taskNameDataInputAssociation);
        }
       
        //process lanes
        if(properties.get("lanes") != null && properties.get("lanes").length() > 0) {
            ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
            EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                    "http://www.jboss.org/drools", "lanes", false, false);
            SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                    properties.get("lanes"));
            task.getAnyAttribute().add(extensionEntry);
        }
       
        //process data input set
        if(properties.get("datainputset") != null && properties.get("datainputset").trim().length() > 0) {
            String[] allDataInputs = properties.get("datainputset").split( ",\\s*" );
            if(task.getIoSpecification() == null) {
                InputOutputSpecification iospec = Bpmn2Factory.eINSTANCE.createInputOutputSpecification();
                task.setIoSpecification(iospec);
            }
            InputSet inset = Bpmn2Factory.eINSTANCE.createInputSet();
            for(String dataInput : allDataInputs) {
              if(dataInput.trim().length() > 0) {
                  DataInput nextInput = Bpmn2Factory.eINSTANCE.createDataInput();
                  String[] dataInputParts = dataInput.split( ":\\s*" );
                  if(dataInputParts.length == 2) {
                    nextInput.setId(task.getId() + "_" + dataInputParts[0] + (dataInputParts[0].endsWith("InputX") ? "" : "InputX"));
                    nextInput.setName(dataInputParts[0]);
                   
                    ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
                      EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                              "http://www.jboss.org/drools", "dtype", false, false);
                      SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                          dataInputParts[1]);
                      nextInput.getAnyAttribute().add(extensionEntry);
                  } else {
                    nextInput.setId(task.getId() + "_" + dataInput + (dataInput.endsWith("InputX") ? "" : "InputX"));
                    nextInput.setName(dataInput);

                        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
                        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                                "http://www.jboss.org/drools", "dtype", false, false);
                        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                                "Object");
                        nextInput.getAnyAttribute().add(extensionEntry);
                  }
                 
                  task.getIoSpecification().getDataInputs().add(nextInput);
                  inset.getDataInputRefs().add(nextInput);
              }
            }
            // add the taskName as well if it was defined
            if(taskNameDataInput != null) {
                inset.getDataInputRefs().add(taskNameDataInput);
            }
            task.getIoSpecification().getInputSets().add(inset);
        } else {
            if(task.getIoSpecification() != null) {
                task.getIoSpecification().getInputSets().add(Bpmn2Factory.eINSTANCE.createInputSet());
            }
        }
       
        //process data output set
        if(properties.get("dataoutputset") != null && properties.get("dataoutputset").trim().length() > 0) {
            String[] allDataOutputs = properties.get("dataoutputset").split( ",\\s*" );
            if(task.getIoSpecification() == null) {
                InputOutputSpecification iospec = Bpmn2Factory.eINSTANCE.createInputOutputSpecification();
                task.setIoSpecification(iospec);
            }
           
            OutputSet outset = Bpmn2Factory.eINSTANCE.createOutputSet();
            for(String dataOutput : allDataOutputs) {
              if(dataOutput.trim().length() > 0) {
                  DataOutput nextOut = Bpmn2Factory.eINSTANCE.createDataOutput();
                  String[] dataOutputParts = dataOutput.split( ":\\s*" );
                  if(dataOutputParts.length == 2) {
                    nextOut.setId(task.getId() + "_" + dataOutputParts[0] + (dataOutputParts[0].endsWith("OutputX") ? "" : "OutputX"));
                    nextOut.setName(dataOutputParts[0]);
                   
                    ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
                      EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                              "http://www.jboss.org/drools", "dtype", false, false);
                      SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                          dataOutputParts[1]);
                      nextOut.getAnyAttribute().add(extensionEntry);
                  } else {
                    nextOut.setId(task.getId() + "_" + dataOutput + (dataOutput.endsWith("OutputX") ? "" : "OutputX"));
                    nextOut.setName(dataOutput);

                        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
                        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                                "http://www.jboss.org/drools", "dtype", false, false);
                        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                                "Object");
                        nextOut.getAnyAttribute().add(extensionEntry);
                  }
                 
                  task.getIoSpecification().getDataOutputs().add(nextOut);
                  outset.getDataOutputRefs().add(nextOut);
              }
            }
            task.getIoSpecification().getOutputSets().add(outset);
        } else {
            if(task.getIoSpecification() != null) {
                task.getIoSpecification().getOutputSets().add(Bpmn2Factory.eINSTANCE.createOutputSet());
            }
        }
       
        //process assignments
        if(properties.get("assignments") != null && properties.get("assignments").length() > 0) {
            String[] allAssignments = properties.get("assignments").split( ",\\s*" );
            for(String assignment : allAssignments) {
                if(assignment.contains("=")) {
                    String[] assignmentParts = assignment.split( "=\\s*" );
                    DataInputAssociation dia = Bpmn2Factory.eINSTANCE.createDataInputAssociation();

                    boolean foundTaskName = false;
                    if(task.getIoSpecification() != null && task.getIoSpecification().getDataOutputs() != null) {
                      List<DataInput> dataInputs = task.getIoSpecification().getDataInputs();
                      for(DataInput di : dataInputs) {
                        if(di.getId().equals(task.getId() + "_" + assignmentParts[0] + (assignmentParts[0].endsWith("InputX") ? "" : "InputX"))) {
                          dia.setTargetRef(di);
                          if(di.getName().equals("TaskName")) {
                            foundTaskName = true;
                            break;
                          }
                        }
                      }
                    }
                    // if we are dealing with TaskName and none has been defined, add it
                    if(assignmentParts[0].equals("TaskName") && !foundTaskName) {
                        DataInput assignmentTaskNameDataInput = Bpmn2Factory.eINSTANCE.createDataInput();
                        assignmentTaskNameDataInput.setId(task.getId() + "_TaskNameInputX");
                        assignmentTaskNameDataInput.setName("TaskName");
                        if(task.getIoSpecification() == null) {
                            InputOutputSpecification iospec = Bpmn2Factory.eINSTANCE.createInputOutputSpecification();
                            task.setIoSpecification(iospec);
                        }
                        task.getIoSpecification().getDataInputs().add(assignmentTaskNameDataInput);
                        dia.setTargetRef(assignmentTaskNameDataInput);
                        InputSet inset = task.getIoSpecification().getInputSets().get(0);
                        inset.getDataInputRefs().add(assignmentTaskNameDataInput);
                    }
                   
                    Assignment a = Bpmn2Factory.eINSTANCE.createAssignment();
                    FormalExpression fromExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
                    if(assignmentParts.length > 1) {
                      String replacer = assignmentParts[1].replaceAll("##", ",");
                        replacer = replacer.replaceAll("\\|\\|", "=");
                        fromExpression.setBody(wrapInCDATABlock(replacer));
                    } else {
                        fromExpression.setBody("");
                    }
                    FormalExpression toExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
                    toExpression.setBody(dia.getTargetRef().getId());
                   
                    a.setFrom(fromExpression);
                    a.setTo(toExpression);
                   
                    dia.getAssignment().add(a);
                    task.getDataInputAssociations().add(dia);
                   
                } else if(assignment.contains("<->")) {
                    String[] assignmentParts = assignment.split( "<->\\s*" );
                    DataInputAssociation dia = Bpmn2Factory.eINSTANCE.createDataInputAssociation();
                    DataOutputAssociation doa = Bpmn2Factory.eINSTANCE.createDataOutputAssociation();
                   
                    ItemAwareElement ie = Bpmn2Factory.eINSTANCE.createItemAwareElement();
                    ie.setId(assignmentParts[0]);
                    dia.getSourceRef().add(ie);
                    doa.setTargetRef(ie);
                   
                    List<DataInput> dataInputs = task.getIoSpecification().getDataInputs();
                    for(DataInput di : dataInputs) {
                        if(di.getId().equals(task.getId() + "_" + assignmentParts[1] + (assignmentParts[1].endsWith("InputX") ? "" : "InputX"))) {
                            dia.setTargetRef(di);
                            break;
                        }
                    }
                    List<DataOutput> dataOutputs = task.getIoSpecification().getDataOutputs();
                    for(DataOutput dout : dataOutputs) {
                        if(dout.getId().equals(task.getId() + "_" + assignmentParts[1] + (assignmentParts[1].endsWith("OutputX") ? "" : "OutputX"))) {
                            doa.getSourceRef().add(dout);
                            break;
                        }
                    }
                    task.getDataInputAssociations().add(dia);
                    task.getDataOutputAssociations().add(doa);
                } else if(assignment.contains("->")) {
                    String[] assignmentParts = assignment.split( "->\\s*" );
                    // we need to check if this is an data input or data output assignment
                    boolean leftHandAssignMentIsDO = false;
                    List<DataOutput> dataOutputs = task.getIoSpecification().getDataOutputs();
                    for(DataOutput dout : dataOutputs) {
                        if(dout.getId().equals(task.getId() + "_" + assignmentParts[0] + (assignmentParts[0].endsWith("OutputX") ? "" : "OutputX"))) {
                            leftHandAssignMentIsDO = true;
                            break;
                        }
                    }
                    if(leftHandAssignMentIsDO) {
                        // doing data output
                        DataOutputAssociation doa = Bpmn2Factory.eINSTANCE.createDataOutputAssociation();
                        for(DataOutput dout : dataOutputs) {
                            if(dout.getId().equals(task.getId() + "_" + assignmentParts[0] + (assignmentParts[0].endsWith("OutputX") ? "" : "OutputX"))) {
                                doa.getSourceRef().add(dout);
                                break;
                            }
                        }
                       
                        ItemAwareElement ie = Bpmn2Factory.eINSTANCE.createItemAwareElement();
                        ie.setId(assignmentParts[1]);
                        doa.setTargetRef(ie);
                        task.getDataOutputAssociations().add(doa);
                    } else {
                        // doing data input
                        DataInputAssociation dia = Bpmn2Factory.eINSTANCE.createDataInputAssociation();
                        // association from process var to dataInput var
                        ItemAwareElement ie = Bpmn2Factory.eINSTANCE.createItemAwareElement();
                        ie.setId(assignmentParts[0]);
                        dia.getSourceRef().add(ie);

                        List<DataInput> dataInputs = task.getIoSpecification().getDataInputs();
                        for(DataInput di : dataInputs) {
                            if(di.getId().equals(task.getId() + "_" + assignmentParts[1] + (assignmentParts[1].endsWith("InputX") ? "" : "InputX"))) {
                                dia.setTargetRef(di);
                                break;
                            }
                        }
                        task.getDataInputAssociations().add(dia);
                    }
                } else {
                    // TODO throw exception here?
                }
            }
           
            // check if multiple taskname datainput associations exist and remove them
            List<DataInputAssociation> dataInputAssociations = task.getDataInputAssociations();
            boolean haveTaskNameInput = false;
            for(Iterator<DataInputAssociation> itr = dataInputAssociations.iterator(); itr.hasNext();
            { 
                DataInputAssociation da = itr.next();
                if(da.getAssignment() != null && da.getAssignment().size() > 0) {
                    Assignment a = da.getAssignment().get(0);
                    if(((FormalExpression) a.getTo()).getBody().equals(task.getId() + "_TaskNameInputX")) {
                        if(!haveTaskNameInput) {
                            haveTaskNameInput = true;
                        } else {
                            itr.remove();
                        }
                    }
                }
            } 
        }
       
        // process on-entry and on-exit actions as custom elements
        if(properties.get("onentryactions") != null && properties.get("onentryactions").length() > 0) {
            String[] allActions = properties.get("onentryactions").split( "\\|\\s*" );
            for(String action : allActions) {
                OnEntryScriptType onEntryScript = DroolsFactory.eINSTANCE.createOnEntryScriptType();
                onEntryScript.setScript(wrapInCDATABlock(action));
               
                String scriptLanguage = "";
                if(properties.get("script_language").equals("java")) {
                    scriptLanguage = "http://www.java.com/java";
                } else if(properties.get("script_language").equals("mvel")) {
                    scriptLanguage = "http://www.mvel.org/2.0";
                } else {
                    // default to java
                    scriptLanguage = "http://www.java.com/java";
                }
                onEntryScript.setScriptFormat(scriptLanguage);
               
                if(task.getExtensionValues() == null || task.getExtensionValues().size() < 1) {
                  ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                  task.getExtensionValues().add(extensionElement);
                }
                FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry(
                        (Internal) DroolsPackage.Literals.DOCUMENT_ROOT__ON_ENTRY_SCRIPT, onEntryScript);
                task.getExtensionValues().get(0).getValue().add(extensionElementEntry);
            }
        }
       
        if(properties.get("onexitactions") != null && properties.get("onexitactions").length() > 0) {
            String[] allActions = properties.get("onexitactions").split( "\\|\\s*" );
            for(String action : allActions) {
                OnExitScriptType onExitScript = DroolsFactory.eINSTANCE.createOnExitScriptType();
                onExitScript.setScript(wrapInCDATABlock(action));
               
                String scriptLanguage;
                if(properties.get("script_language").equals("java")) {
                    scriptLanguage = "http://www.java.com/java";
                } else if(properties.get("script_language").equals("mvel")) {
                    scriptLanguage = "http://www.mvel.org/2.0";
                } else {
                    // default to java
                    scriptLanguage = "http://www.java.com/java";
                }
                onExitScript.setScriptFormat(scriptLanguage);
           
                if(task.getExtensionValues() == null || task.getExtensionValues().size() < 1) {
                  ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                  task.getExtensionValues().add(extensionElement);
                }
                FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry(
                        (Internal) DroolsPackage.Literals.DOCUMENT_ROOT__ON_EXIT_SCRIPT, onExitScript);
                task.getExtensionValues().get(0).getValue().add(extensionElementEntry);
            }
        }

        // multi instance
        if(properties.get("multipleinstance") != null && properties.get("multipleinstance").length() > 0 && properties.get("multipleinstance").equals("true")) {
            // will be revisited at end
            ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
            EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                    "http://www.jboss.org/drools", "mitask", false, false);
            StringBuffer buff = new StringBuffer();
            buff.append( (properties.get("multipleinstancecollectioninput") != null && properties.get("multipleinstancecollectioninput").length() > 0) ? properties.get("multipleinstancecollectioninput") : " ");
            buff.append("@");
            buff.append((properties.get("multipleinstancecollectionoutput") != null && properties.get("multipleinstancecollectionoutput").length() > 0) ? properties.get("multipleinstancecollectionoutput") : " ");
View Full Code Here

Examples of org.eclipse.emf.ecore.util.ExtendedMetaData

            } else {
                // default to java
                scriptLanguage = "http://www.java.com/java";
            }
           
            ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
            EAttributeImpl scriptLanguageElement = (EAttributeImpl) metadata.demandFeature(
                    "http://www.jboss.org/drools", "scriptFormat", false   , false);
            SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(scriptLanguageElement,
                    scriptLanguage);
            task.getAnyAttribute().add(extensionEntry);
        }
View Full Code Here

Examples of org.eclipse.emf.ecore.util.ExtendedMetaData

            gateway.setName(escapeXmlString(properties.get("name")));
        } else {
            gateway.setName("");
        }
        if(properties.get("defaultgate") != null && (gateway instanceof InclusiveGateway || gateway instanceof ExclusiveGateway) ) {
          ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
            EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                        "http://www.jboss.org/drools", "dg", false, false);
            SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                properties.get("defaultgate"));
            gateway.getAnyAttribute().add(extensionEntry);
        }
View Full Code Here

Examples of org.eclipse.emf.ecore.util.ExtendedMetaData

                _elementColors.get(sequenceFlow.getId()).add("bordercolor:" + properties.get("bordercolor"));
            }
        }

        if(properties.get("fontsize") != null && properties.get("fontsize").length() > 0) {
          ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
          EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
              "http://www.jboss.org/drools", "fontsize", false, false);
          SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
              properties.get("fontsize"));
          sequenceFlow.getAnyAttribute().add(extensionEntry);

        }

        if(properties.get("fontcolor") != null && properties.get("fontcolor").length() > 0) {
            if(!(_elementColors.containsKey(sequenceFlow.getId()))) {
                List<String> colorsList = new ArrayList<String>();
                colorsList.add("fontcolor:" + properties.get("fontcolor"));
                _elementColors.put(sequenceFlow.getId(), colorsList);
            } else {
                _elementColors.get(sequenceFlow.getId()).add("fontcolor:" + properties.get("fontcolor"));
            }
        }

        if(properties.get("isselectable") != null && properties.get("isselectable").length() > 0) {
          ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
          EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                         "http://www.jboss.org/drools", "selectable", false, false);
          SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
              properties.get("isselectable"));
          sequenceFlow.getAnyAttribute().add(extensionEntry);
        }

        if (properties.get("auditing") != null && !"".equals(properties.get("auditing"))) {
            Auditing audit = Bpmn2Factory.eINSTANCE.createAuditing();
            audit.getDocumentation().add(createDocumentation(properties.get("auditing")));
            sequenceFlow.setAuditing(audit);
        }

        if (properties.get("conditionexpression") != null && !"".equals(properties.get("conditionexpression"))) {
            FormalExpression expr = Bpmn2Factory.eINSTANCE.createFormalExpression();
            String scriptStr = properties.get("conditionexpression").replaceAll("\\\\n", "\n");
            expr.setBody(wrapInCDATABlock(scriptStr));
            // check if language was specified
            if (properties.get("conditionexpressionlanguage") != null && !"".equals(properties.get("conditionexpressionlanguage"))) {
                String languageStr;
                if(properties.get("conditionexpressionlanguage").equals("drools")) {
                    languageStr = "http://www.jboss.org/drools/rule";
                } else if(properties.get("conditionexpressionlanguage").equals("mvel")) {
                    languageStr = "http://www.mvel.org/2.0";
                } else if(properties.get("conditionexpressionlanguage").equals("java")) {
                    languageStr = "http://www.java.com/java";
                } else {
                    // default to mvel
                    languageStr = "http://www.mvel.org/2.0";
                }
                expr.setLanguage(languageStr);
            }
            sequenceFlow.setConditionExpression(expr);
        }
       
        if (properties.get("priority") != null && !"".equals(properties.get("priority"))) {
            ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
            EAttributeImpl priorityElement = (EAttributeImpl) metadata.demandFeature(
                    "http://www.jboss.org/drools", "priority", false   , false);
            SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(priorityElement,
                    properties.get("priority"));
            sequenceFlow.getAnyAttribute().add(extensionEntry);
        }
View Full Code Here

Examples of org.eclipse.emf.ecore.util.ExtendedMetaData

                if(shapeColorParts[0].equals("fontcolor")) {
                    fontColor = shapeColorParts[1];
                }
            }

            ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;

            EAttributeImpl extensionAttributeBgColor = (EAttributeImpl) metadata .demandFeature(
                    "http://www.omg.org/spec/BPMN/non-normative/color", "background-color", false, false);
            SimpleFeatureMapEntry extensionEntryBgColor = new SimpleFeatureMapEntry(extensionAttributeBgColor,
                    backgroundColor);
            shape.getBpmnElement().getAnyAttribute().add(extensionEntryBgColor);

            EAttributeImpl extensionAttributeBorderColor = (EAttributeImpl) metadata .demandFeature(
                    "http://www.omg.org/spec/BPMN/non-normative/color", "border-color", false, false);
            SimpleFeatureMapEntry extensionEntryBorderColor = new SimpleFeatureMapEntry(extensionAttributeBorderColor,
                    borderColor);
            shape.getBpmnElement().getAnyAttribute().add(extensionEntryBorderColor);

            EAttributeImpl extensionAttributeColor = (EAttributeImpl) metadata .demandFeature(
                    "http://www.omg.org/spec/BPMN/non-normative/color", "color", false, false);
            SimpleFeatureMapEntry extensionEntryColor = new SimpleFeatureMapEntry(extensionAttributeColor,
                    fontColor);
            shape.getBpmnElement().getAnyAttribute().add(extensionEntryColor);
        } else {
View Full Code Here

Examples of org.eclipse.emf.ecore.util.ExtendedMetaData

                if(shapeColorParts[0].equals("fontcolor")) {
                    fontColor = shapeColorParts[1];
                }
            }

            ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
            EAttributeImpl extensionAttributeBgColor = (EAttributeImpl) metadata .demandFeature(
                    "http://www.omg.org/spec/BPMN/non-normative/color", "background-color", false, false);
            SimpleFeatureMapEntry extensionEntryBgColor = new SimpleFeatureMapEntry(extensionAttributeBgColor,
                    backgroundColor);
            edge.getBpmnElement().getAnyAttribute().add(extensionEntryBgColor);

            EAttributeImpl extensionAttributeBorderColor = (EAttributeImpl) metadata .demandFeature(
                    "http://www.omg.org/spec/BPMN/non-normative/color", "border-color", false, false);
            SimpleFeatureMapEntry extensionEntryBorderColor = new SimpleFeatureMapEntry(extensionAttributeBorderColor,
                    borderColor);
            edge.getBpmnElement().getAnyAttribute().add(extensionEntryBorderColor);

            EAttributeImpl extensionAttributeColor = (EAttributeImpl) metadata .demandFeature(
                    "http://www.omg.org/spec/BPMN/non-normative/color", "color", false, false);
            SimpleFeatureMapEntry extensionEntryColor = new SimpleFeatureMapEntry(extensionAttributeColor,
                    fontColor);
            edge.getBpmnElement().getAnyAttribute().add(extensionEntryColor);
        } else {
View Full Code Here

Examples of org.eclipse.emf.ecore.util.ExtendedMetaData

                            ((Definitions) baseElt).getRootElements().add(itemdef);
                        }
                    }

                    if(properties.get("adhocprocess") != null && properties.get("adhocprocess").equals("true")) {
                      ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
                        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                                    "http://www.jboss.org/drools", "adHoc", false, false);
                        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                            properties.get("adhocprocess"));
                        rootLevelProcess.getAnyAttribute().add(extensionEntry);
                    }

                    if(properties.get("customdescription") != null && properties.get("customdescription").length() > 0) {
                        MetaDataType metadata = DroolsFactory.eINSTANCE.createMetaDataType();
                        metadata.setName("customDescription");
                        metadata.setMetaValue(wrapInCDATABlock(properties.get("customdescription")));

                        if(rootLevelProcess.getExtensionValues() == null || rootLevelProcess.getExtensionValues().size() < 1) {
                            ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                            rootLevelProcess.getExtensionValues().add(extensionElement);
                        }
                        FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry(
                                (Internal) DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, metadata);
                        rootLevelProcess.getExtensionValues().get(0).getValue().add(extensionElementEntry);
                    }

                    rootLevelProcess.setId(properties.get("id"));
                    applyProcessProperties(rootLevelProcess, properties);
                    ((Definitions) baseElt).getRootElements().add(rootLevelProcess);
                }
          } else {
            for (BaseElement child : childElements) {
                  // tasks are only permitted under processes.
                  // a process should be created implicitly for tasks at the root
                  // level.
 
                  // process designer doesn't make a difference between tasks and
                  // global tasks.
                  // if a task has sequence edges it is considered a task,
                  // otherwise it is considered a global task.
  //                if (child instanceof Task && _outgoingFlows.get(child).isEmpty() && !_sequenceFlowTargets.contains(_objMap.get(child))) {
  //                    // no edges on a task at the top level! We replace it with a
  //                    // global task.
  //                    GlobalTask task = null;
  //                    if (child instanceof ScriptTask) {
  //                        task = Bpmn2Factory.eINSTANCE.createGlobalScriptTask();
  //                        ((GlobalScriptTask) task).setScript(((ScriptTask) child).getScript());
  //                        ((GlobalScriptTask) task).setScriptLanguage(((ScriptTask) child).getScriptFormat());
  //                        // TODO scriptLanguage missing on scriptTask
  //                    } else if (child instanceof UserTask) {
  //                        task = Bpmn2Factory.eINSTANCE.createGlobalUserTask();
  //                    } else if (child instanceof ServiceTask) {
  //                        // we don't have a global service task! Fallback on a
  //                        // normal global task
  //                        task = Bpmn2Factory.eINSTANCE.createGlobalTask();
  //                    } else if (child instanceof BusinessRuleTask) {
  //                        task = Bpmn2Factory.eINSTANCE.createGlobalBusinessRuleTask();
  //                    } else if (child instanceof ManualTask) {
  //                        task = Bpmn2Factory.eINSTANCE.createGlobalManualTask();
  //                    } else {
  //                        task = Bpmn2Factory.eINSTANCE.createGlobalTask();
  //                    }
  //
  //                    task.setName(((Task) child).getName());
  //                    task.setIoSpecification(((Task) child).getIoSpecification());
  //                    task.getDocumentation().addAll(((Task) child).getDocumentation());
  //                    ((Definitions) baseElt).getRootElements().add(task);
  //                    continue;
  //                } else {
                      if (child instanceof SequenceFlow) {
                          // for some reason sequence flows are placed as root elements.
                          // find if the target has a container, and if we can use it:
                          List<String> ids = _outgoingFlows.get(child);
                          FlowElementsContainer container = null;
                          for (String id : ids) { // yes, we iterate, but we'll take the first in the list that will work.
                              Object obj = _idMap.get(id);
                              if (obj instanceof EObject && ((EObject) obj).eContainer() instanceof FlowElementsContainer) {
                                  container = (FlowElementsContainer) ((EObject) obj).eContainer();
                                  break;
                              }
                          }
                          if (container != null) {
                              container.getFlowElements().add((SequenceFlow) child);
                              continue;
                          }
                         
                      }
                      if (child instanceof Task || child instanceof SequenceFlow
                              || child instanceof Gateway || child instanceof Event
                              || child instanceof Artifact || child instanceof DataObject || child instanceof SubProcess
                              || child instanceof Lane || child instanceof CallActivity) {
                          if (rootLevelProcess == null) {
                              rootLevelProcess = Bpmn2Factory.eINSTANCE.createProcess();
                              // set the properties and item definitions first
                              if(properties.get("vardefs") != null && properties.get("vardefs").length() > 0) {
                                  String[] vardefs = properties.get("vardefs").split( ",\\s*" );
                                  for(String vardef : vardefs) {
                                      Property prop = Bpmn2Factory.eINSTANCE.createProperty();
                                      ItemDefinition itemdef =  Bpmn2Factory.eINSTANCE.createItemDefinition();
                                      // check if we define a structure ref in the definition
                                      if(vardef.contains(":")) {
                                          String[] vardefParts = vardef.split( ":\\s*" );
                                          prop.setId(vardefParts[0]);
                                          itemdef.setId("_" + prop.getId() + "Item");
                                          itemdef.setStructureRef(vardefParts[1]);
                                      } else {
                                          prop.setId(vardef);
                                          itemdef.setId("_" + prop.getId() + "Item");
                                      }
                                      prop.setItemSubjectRef(itemdef);
                                      rootLevelProcess.getProperties().add(prop);
                                      ((Definitions) baseElt).getRootElements().add(itemdef);
                                  }
                              }
                              if(properties.get("adhocprocess") != null && properties.get("adhocprocess").equals("true")) {
                                ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
                                  EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                                              "http://www.jboss.org/drools", "adHoc", false, false);
                                  SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                                      properties.get("adhocprocess"));
                                  rootLevelProcess.getAnyAttribute().add(extensionEntry);
                              }
                                if(properties.get("customdescription") != null && properties.get("customdescription").length() > 0) {
                                    MetaDataType metadata = DroolsFactory.eINSTANCE.createMetaDataType();
                                    metadata.setName("customDescription");
                                    metadata.setMetaValue(wrapInCDATABlock(properties.get("customdescription")));

                                    if(rootLevelProcess.getExtensionValues() == null || rootLevelProcess.getExtensionValues().size() < 1) {
                                        ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                                        rootLevelProcess.getExtensionValues().add(extensionElement);
                                    }
View Full Code Here

Examples of org.eclipse.emf.ecore.util.ExtendedMetaData

     {

        // Initialize the SDO runtime
        DataObjectUtil.initRuntime();
        EPackage.Registry packageRegistry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);
        ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(packageRegistry);
        XSDHelper xsdHelper = new XSDHelperImpl(extendedMetaData, null);

        try {
           
            // Load the WSDL file
            File inputFile = new File(wsdlFileName).getAbsoluteFile();
            InputStream inputStream = new FileInputStream(inputFile);
           
            // Define SDO metadata
            xsdHelper.define(inputStream, inputFile.toURI().toString());

            if (targetDirectory == null) {
                targetDirectory = new File(wsdlFileName).getCanonicalFile().getParent();
            } else {
                targetDirectory = new File(targetDirectory).getCanonicalPath();
            }

            // Populate the typeMapping table that will be given to the Axis2 WSDL2Java
            Map<QName, SDODataBindingTypeMappingEntry> typeMapping =
                                    new HashMap<QName, SDODataBindingTypeMappingEntry>();
            if (!packageRegistry.values().isEmpty()) {
                ResourceSet resourceSet = DataObjectUtil.createResourceSet();

                // Populate list of GenPackages and a map of GenClasses keyed by EClass
                List<GenPackage> genPackages = new ArrayList<GenPackage>();
                Map<EClass, GenClass> genClasses = new HashMap<EClass, GenClass>();
                for (Iterator iter = packageRegistry.values().iterator(); iter.hasNext();) {
                    EPackage currentEPackage = (EPackage)iter.next();
                    String currentBasePackage = extractBasePackageName(currentEPackage, xsdJavaPackage);
                    String currentPrefix = CodeGenUtil.capName(currentEPackage.getName());

                    GenPackage currentGenPackage = createGenPackage(currentEPackage, currentBasePackage,
                                                                    currentPrefix, genOptions, resourceSet);
                    genPackages.add(currentGenPackage);
                    for (GenClass genClass : (List<GenClass>)currentGenPackage.getGenClasses()) {
                        genClasses.put(genClass.getEcoreClass(), genClass);
                    }

                }

                // Process all the SDO packages
                // Populate the qname -> interfaceName typeMapping table
                for (GenPackage currentGenPackage : genPackages) {
                    EPackage currentEPackage = currentGenPackage.getEcorePackage();
                   
                    // Populate the type mappings for all the complex types
                    for (GenClass genClass : (List<GenClass>)currentGenPackage.getGenClasses()) {
                        QName qname = new QName(extendedMetaData.getNamespace(currentEPackage),
                                                extendedMetaData.getName(genClass.getEcoreClass()));
                        String interfaceName = currentGenPackage.getInterfacePackageName() + '.'
                                               + genClass.getInterfaceName();
                        SDODataBindingTypeMappingEntry typeMappingEntry =
                                new SDODataBindingTypeMappingEntry(interfaceName, false, null);
                        typeMapping.put(qname, typeMappingEntry);
                    }

                    // Process all the global XSD elements
                    EClass documentRoot = extendedMetaData.getDocumentRoot(currentEPackage);
                    if (documentRoot != null) {
                        for (EStructuralFeature element : (List<EStructuralFeature>)extendedMetaData
                            .getElements(documentRoot)) {
                            EClassifier elementType = element.getEType();
                           
                            // Handle a complex type
                            if (elementType instanceof EClass) {
                                EClass eClass = (EClass)elementType;

                                GenClass genClass = genClasses.get(elementType);
                                QName qname = new QName(extendedMetaData.getNamespace(currentEPackage),
                                        extendedMetaData.getName(element));
                                String interfaceName = genClass.getGenPackage().getInterfacePackageName()
                                + '.' + genClass.getInterfaceName();
                                boolean anonymous = extendedMetaData.isAnonymous(eClass);
                               
                                // Build list of property class names
                                List<String> propertyClassNames=new ArrayList<String>();
                                for (EStructuralFeature feature : (List<EStructuralFeature>)eClass.getEStructuralFeatures()) {
                                    EClassifier propertyType = feature.getEType();
                                    if (propertyType instanceof EClass) {
                                        GenClass propertyGenClass = genClasses.get(propertyType);
                                        String propertyClassName = propertyGenClass.getGenPackage().getInterfacePackageName()
                                                               + '.' + propertyGenClass.getInterfaceName();
                                        propertyClassNames.add(propertyClassName);
                                    } else if (propertyType instanceof EClassifier) {
                                        String propertyClassName = propertyType.getInstanceClass().getName();
                                        propertyClassNames.add(propertyClassName);
                                    }
                                }

                                SDODataBindingTypeMappingEntry typeMappingEntry =
                                    new SDODataBindingTypeMappingEntry(interfaceName, anonymous, propertyClassNames);
                                typeMapping.put(qname, typeMappingEntry);
                               
                            } else {
                               
                                // Handle a simple type
                                QName qname = new QName(extendedMetaData.getNamespace(currentEPackage),
                                                        extendedMetaData.getName(element));
                                String className = elementType.getInstanceClass().getName();
                                SDODataBindingTypeMappingEntry typeMappingEntry =
                                        new SDODataBindingTypeMappingEntry(className, false, null);
                                typeMapping.put(qname, typeMappingEntry);
                            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.