package org.wso2.carbon.cep.core.internal.config;
import org.apache.axiom.om.OMElement;
import org.wso2.carbon.cep.core.Output;
import org.wso2.carbon.cep.core.internal.util.CEPConstants;
import javax.xml.namespace.QName;
/**
* This class will help to build Output Object from a given OMELement
*/
public class OutputHelper {
public static Output fromOM(OMElement outputElement) {
Output output = new Output();
String topic = outputElement.getAttributeValue(new QName(CEPConstants.CEP_CONF_ATTR_TOPIC));
output.setTopic(topic);
String brokerProxy = outputElement.getAttributeValue(new QName(CEPConstants.CEP_CONF_ELE_BROKER_NAME));
output.setBrokerName(brokerProxy);
OMElement elementMappingElement = outputElement.getFirstChildWithName(new QName(CEPConstants.CEP_CONF_NAMESPACE,
CEPConstants.CEP_CONF_ELE_EMAPPING));
if (elementMappingElement != null) {
output.setElementMapping(ElementMappingHelper.fromOM(elementMappingElement));
}
OMElement xmlMappingElement = outputElement.getFirstChildWithName(new QName(CEPConstants.CEP_CONF_NAMESPACE,
CEPConstants.CEP_CONF_ELE_XML_MAPPING));
if (xmlMappingElement != null) {
output.setXmlMapping(XMLMappingHelper.fromOM(xmlMappingElement));
}
return output;
}
}