public static OutputMapping fromOM(OMElement mappingElement)
      throws EventFormatterValidationException, EventFormatterConfigurationException {

    MapOutputMapping mapOutputMapping = new MapOutputMapping();

    String customMappingEnabled =
        mappingElement.getAttributeValue(new QName(EventFormatterConstants.EF_ATTR_CUSTOM_MAPPING));
    if (customMappingEnabled == null
        || (customMappingEnabled.equals(EventFormatterConstants.TM_VALUE_ENABLE))) {
      mapOutputMapping.setCustomMappingEnabled(true);
      if (!validateMapEventMapping(mappingElement)) {
        throw new EventFormatterConfigurationException(
            "Map Mapping is not valid, check the output mapping");
      }

      if (mappingElement != null) {
        Iterator propertyIterator =
            mappingElement.getChildrenWithName(
                new QName(
                    EventFormatterConstants.EF_CONF_NS, EventFormatterConstants.EF_ELE_PROPERTY));
        while (propertyIterator.hasNext()) {
          OMElement propertyOMElement = (OMElement) propertyIterator.next();
          EventOutputProperty eventOutputProperty = getOutputPropertyFromOM(propertyOMElement);
          mapOutputMapping.addOutputPropertyConfiguration(eventOutputProperty);
        }
      }
    } else {
      mapOutputMapping.setCustomMappingEnabled(false);
    }

    return mapOutputMapping;
  }
  public static OMElement outputMappingToOM(OutputMapping outputMapping, OMFactory factory) {

    MapOutputMapping mapOutputMapping = (MapOutputMapping) outputMapping;

    List<EventOutputProperty> outputPropertyConfiguration =
        mapOutputMapping.getOutputPropertyConfiguration();

    OMElement mappingOMElement =
        factory.createOMElement(new QName(EventFormatterConstants.EF_ELE_MAPPING_PROPERTY));
    mappingOMElement.declareDefaultNamespace(EventFormatterConstants.EF_CONF_NS);

    mappingOMElement.addAttribute(
        EventFormatterConstants.EF_ATTR_TYPE, EventFormatterConstants.EF_MAP_MAPPING_TYPE, null);

    if (mapOutputMapping.isCustomMappingEnabled()) {
      mappingOMElement.addAttribute(
          EventFormatterConstants.EF_ATTR_CUSTOM_MAPPING,
          EventFormatterConstants.TM_VALUE_ENABLE,
          null);

      if (outputPropertyConfiguration.size() > 0) {
        for (EventOutputProperty eventOutputProperty : outputPropertyConfiguration) {
          mappingOMElement.addChild(getPropertyOmElement(factory, eventOutputProperty));
        }
      }
    } else {
      mappingOMElement.addAttribute(
          EventFormatterConstants.EF_ATTR_CUSTOM_MAPPING,
          EventFormatterConstants.TM_VALUE_DISABLE,
          null);
    }
    return mappingOMElement;
  }