protected NamespacedProperty createNamespacedProperty(
     String xpath, Map<String, String> namespaces) {
   NamespacedProperty nsp = EsbFactory.eINSTANCE.createNamespacedProperty();
   nsp.setPropertyValue(xpath.toString());
   if (namespaces != null) {
     nsp.setNamespaces(namespaces);
   }
   return nsp;
 }
 protected NamespacedProperty createNamespacedProperty(SynapseXPath xpath) {
   NamespacedProperty nsp = EsbFactory.eINSTANCE.createNamespacedProperty();
   nsp.setPropertyValue(xpath.toString());
   if (xpath.getNamespaces() != null) {
     @SuppressWarnings("unchecked")
     Map<String, String> map = xpath.getNamespaces();
     nsp.setNamespaces(map);
   }
   return nsp;
 }
  public ResolvingEndpoint getEndpointFromXpath(NamespacedProperty nameSpacedProperty)
      throws Exception {

    SynapseXPath synapseXPath = new SynapseXPath(nameSpacedProperty.getPropertyValue());
    for (int i = 0; i < nameSpacedProperty.getNamespaces().keySet().size(); ++i) {
      String prefix = (String) nameSpacedProperty.getNamespaces().keySet().toArray()[i];
      String namespaceUri = nameSpacedProperty.getNamespaces().get(prefix);
      synapseXPath.addNamespace(prefix, namespaceUri);
    }
    ResolvingEndpoint resolvingEndpoint = new ResolvingEndpoint();
    resolvingEndpoint.setKeyExpression(synapseXPath);
    return resolvingEndpoint;
  }
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated NOT
   */
  protected IterateMediatorImpl() {
    super();

    // Attach path.
    NamespacedProperty attachPath = EsbFactoryImpl.eINSTANCE.createNamespacedProperty();
    attachPath.setPrettyName("Attach Path");
    attachPath.setPropertyName("attachPath");
    attachPath.setPropertyValue("/default/expression");
    setAttachPath(attachPath);

    // Iterate expression.
    NamespacedProperty iterateExpression = EsbFactoryImpl.eINSTANCE.createNamespacedProperty();
    iterateExpression.setPrettyName("Iterate Expression");
    iterateExpression.setPropertyName("expression");
    iterateExpression.setPropertyValue(DEFAULT_EXPRESSION_PROPERTY_VALUE);
    setIterateExpression(iterateExpression);

    RegistryKeyProperty targetSequenceKey = EsbFactoryImpl.eINSTANCE.createRegistryKeyProperty();
    targetSequenceKey.setPrettyName("Sequence Reference");
    targetSequenceKey.setKeyName("key");
    targetSequenceKey.setKeyValue(DEFAULT_REGISTRY_KEY);
    setSequenceKey(targetSequenceKey);

    setTarget(EsbFactoryImpl.eINSTANCE.createIterateTarget());
  }
 protected NamespacedProperty createNamespacedProperty(SynapsePath path) {
   NamespacedProperty nsp = EsbFactory.eINSTANCE.createNamespacedProperty();
   nsp.setPropertyValue(path.toString());
   if (path.getPathType() == SynapsePath.X_PATH) {
     // nsp.setPropertyValue(path.getExpression());
     if (path.getNamespaces() != null) {
       @SuppressWarnings("unchecked")
       Map<String, String> map = path.getNamespaces();
       nsp.setNamespaces(map);
     }
   } else if (path.getPathType() == SynapsePath.JSON_PATH) {
     // nsp.setPropertyValue(path.getExpression());
   }
   return nsp;
 }
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated NOT
   */
  @SuppressWarnings("unchecked")
  protected SendMediatorImpl() {
    super();
    // Static Receiving Sequence
    staticReceivingSequence = EsbFactoryImpl.eINSTANCE.createRegistryKeyProperty();
    DeveloperStudioProviderUtils.addFilter(
        (Map<String, List<String>>) staticReceivingSequence.getFilters(),
        CSProviderConstants.FILTER_MEDIA_TYPE,
        ESBMediaTypeConstants.MEDIA_TYPE_SEQUENCE);
    staticReceivingSequence.setPrettyName("Static");
    staticReceivingSequence.setKeyName("receive");
    staticReceivingSequence.setKeyValue(DEFAULT_SEQUENCE_REFERENCE_REGISTRY_KEY);
    setStaticReceivingSequence(staticReceivingSequence);

    // Dynamic Receiving Sequence
    dynamicReceivingSequence = EsbFactoryImpl.eINSTANCE.createNamespacedProperty();
    dynamicReceivingSequence.setPropertyName("receive");
    dynamicReceivingSequence.setPropertyValue(DEFAULT_XPATH_PROPERTY_VALUE);
    dynamicReceivingSequence.setPrettyName("Dynamic");
    setDynamicReceivingSequence(dynamicReceivingSequence);
  }
  protected void okPressed() {

    for (TableItem item : publishEventAttributeTable.getItems()) {
      PublishEventMediatorAttribute attribute = (PublishEventMediatorAttribute) item.getData();
      NamespacedProperty expression =
          ((PublishEventMediatorAttributeImpl) item.getData()).getAttributeExpression();

      // If the attribute is a new one, add it to the model.
      if (null == attribute.eContainer()) {
        // Update the publishEvent attribute with the latest data from
        // table row.
        attribute.setAttributeName(item.getText(0));

        if (item.getText(2).equals(AttributeValueType.STRING.getLiteral())) {
          attribute.setAttributeValueType(AttributeValueType.STRING);
          attribute.setAttributeValue(item.getText(1));
        }

        if (item.getText(2).equals(AttributeValueType.EXPRESSION.getLiteral())) {
          attribute.setAttributeValueType(AttributeValueType.EXPRESSION);
          NamespacedProperty namespaceProperty =
              EsbFactoryImpl.eINSTANCE.createNamespacedProperty();
          namespaceProperty.setPropertyValue(item.getText(1));
          namespaceProperty.setNamespaces(expression.getNamespaces());
          attribute.setAttributeExpression(namespaceProperty);
        }

        // Record the add operation.
        AddCommand addCmd = null;
        if (attributeCategory.equals(PUBLISH_EVENT_META_CATEGORY)) {
          addCmd =
              new AddCommand(
                  editingDomain,
                  publishEventMediator,
                  EsbPackage.Literals.PUBLISH_EVENT_MEDIATOR__META_ATTRIBUTES,
                  attribute);
        }
        if (attributeCategory.equals(PUBLISH_EVENT_CORRELATION_CATEGORY)) {
          addCmd =
              new AddCommand(
                  editingDomain,
                  publishEventMediator,
                  EsbPackage.Literals.PUBLISH_EVENT_MEDIATOR__CORRELATION_ATTRIBUTES,
                  attribute);
        }
        if (attributeCategory.equals(PUBLISH_EVENT_PAYLOAD_CATEGORY)) {
          addCmd =
              new AddCommand(
                  editingDomain,
                  publishEventMediator,
                  EsbPackage.Literals.PUBLISH_EVENT_MEDIATOR__PAYLOAD_ATTRIBUTES,
                  attribute);
        }
        if (attributeCategory.equals(PUBLISH_EVENT_ARBITRARY_CATEGORY)) {
          addCmd =
              new AddCommand(
                  editingDomain,
                  publishEventMediator,
                  EsbPackage.Literals.PUBLISH_EVENT_MEDIATOR__ARBITRARY_ATTRIBUTES,
                  attribute);
        }
        getResultCommand().append(addCmd);
      }
    }

    // Apply changes.
    if (getResultCommand().canExecute()) {
      editingDomain.getCommandStack().execute(getResultCommand());
    }

    super.okPressed();
  }
  private org.apache.synapse.mediators.builtin.ValidateMediator createValidateMediator(
      EsbNode subject, TransformationInfo information) throws TransformerException, JaxenException {

    /*
     * Check subject.
     */
    Assert.isTrue(subject instanceof ValidateMediator, "Invalid subject.");
    ValidateMediator visualValidateMediator = (ValidateMediator) subject;
    /*
     * Configure Validate mediator.
     */

    org.apache.synapse.mediators.builtin.ValidateMediator validateMediator =
        new org.apache.synapse.mediators.builtin.ValidateMediator();
    setCommonProperties(validateMediator, visualValidateMediator);

    NamespacedProperty sourceXPath = visualValidateMediator.getSourceXpath();
    if (sourceXPath.getPropertyValue() != null && !sourceXPath.getPropertyValue().equals("")) {
      SynapseXPath synapseXPath = new SynapseXPath(sourceXPath.getPropertyValue());
      for (Entry<String, String> entry : sourceXPath.getNamespaces().entrySet()) {
        synapseXPath.addNamespace(entry.getKey(), entry.getValue());
      }
      validateMediator.setSource(synapseXPath);
    }

    List<Value> valueList = new ArrayList<Value>();
    for (ValidateSchema schema : visualValidateMediator.getSchemas()) {

      if (schema.getValidateSchemaKeyType().getLiteral().equals(KeyType.STATIC.getLiteral())) {

        if (schema.getValidateStaticSchemaKey() != null
            && schema.getValidateStaticSchemaKey().getKeyValue() != null) {
          Value val = new Value(schema.getValidateStaticSchemaKey().getKeyValue());
          valueList.add(val);
        }

      } else {

        NamespacedProperty dynamicSchemaKey = schema.getValidateDynamicSchemaKey();
        if (dynamicSchemaKey != null && dynamicSchemaKey.getPropertyValue() != null) {
          SynapseXPath xpath = new SynapseXPath(dynamicSchemaKey.getPropertyValue());
          for (Entry<String, String> entry : dynamicSchemaKey.getNamespaces().entrySet()) {
            xpath.addNamespace(entry.getKey(), entry.getValue());
          }
          Value val = new Value(xpath);
          valueList.add(val);
        }
      }
    }
    validateMediator.setSchemaKeys(valueList);

    // ListMediator onFailMediatorList = new AnonymousListMediator();
    SequenceMediator onFailMediatorList = new SequenceMediator();
    TransformationInfo newOnFailInfo = new TransformationInfo();
    newOnFailInfo.setTraversalDirection(information.getTraversalDirection());
    newOnFailInfo.setSynapseConfiguration(information.getSynapseConfiguration());
    newOnFailInfo.setOriginInSequence(information.getOriginInSequence());
    newOnFailInfo.setOriginOutSequence(information.getOriginOutSequence());
    newOnFailInfo.setCurrentProxy(information.getCurrentProxy());
    newOnFailInfo.setParentSequence(onFailMediatorList);
    doTransform(newOnFailInfo, visualValidateMediator.getOnFailOutputConnector());
    validateMediator.addAll(onFailMediatorList.getList());

    for (ValidateFeature feature : visualValidateMediator.getFeatures()) {
      try {
        validateMediator.addFeature(feature.getFeatureName(), feature.isFeatureEnabled());
      } catch (Exception e) {
        log.error(e);
      }
    }

    if (!visualValidateMediator.getResources().isEmpty()) {

      ResourceMap rMap = new ResourceMap();

      for (ValidateResource resource : visualValidateMediator.getResources()) {

        if (resource.getLocation() != null && resource.getKey() != null) {

          rMap.addResource(resource.getLocation(), resource.getKey().getKeyValue());
        }
      }

      validateMediator.setResourceMap(rMap);
    }

    return validateMediator;
  }