Search in sources :

Example 76 with MetadataElement

use of com.adaptris.core.MetadataElement in project interlok by adaptris.

the class MetadataAppenderService method doService.

@Override
public void doService(AdaptrisMessage msg) {
    StringBuffer result = new StringBuffer();
    for (String key : appendKeys) {
        if (msg.getMetadataValue(key) != null) {
            result.append(msg.getMetadataValue(key));
        }
    }
    MetadataElement e = new MetadataElement(resultKey, result.toString());
    logMetadata("Added {}", e);
    msg.addMetadata(e);
}
Also used : MetadataElement(com.adaptris.core.MetadataElement)

Example 77 with MetadataElement

use of com.adaptris.core.MetadataElement in project interlok by adaptris.

the class CompareTimestamps method compare.

@Override
public MetadataElement compare(MetadataElement firstItem, MetadataElement secondItem) throws ServiceException {
    MetadataElement result = new MetadataElement();
    result.setKey(getResultKey());
    try {
        result.setValue(String.valueOf(compareFormattedDates(firstItem.getValue(), secondItem.getValue())));
    } catch (ParseException e) {
        throw ExceptionHelper.wrapServiceException(e);
    }
    return result;
}
Also used : MetadataElement(com.adaptris.core.MetadataElement) ParseException(java.text.ParseException)

Example 78 with MetadataElement

use of com.adaptris.core.MetadataElement in project interlok by adaptris.

the class ConfiguredXpathQuery method resolveXpath.

@Override
public MetadataElement resolveXpath(Document doc, XPath xpath, String expr) throws Exception {
    String result;
    if (asXmlString()) {
        Node node = XpathQueryHelper.resolveSingleNode(doc, xpath, expr, allowEmptyResults());
        result = XmlHelper.nodeToString(node);
    } else {
        result = XpathQueryHelper.resolveSingleTextItem(doc, xpath, expr, allowEmptyResults());
    }
    return new MetadataElement(getMetadataKey(), result);
}
Also used : Node(org.w3c.dom.Node) MetadataElement(com.adaptris.core.MetadataElement)

Example 79 with MetadataElement

use of com.adaptris.core.MetadataElement in project interlok by adaptris.

the class MultiItemConfiguredXpathQuery method resolveXpath.

@Override
public MetadataElement resolveXpath(Document doc, XPath xpath, String expr) throws CoreException {
    String items = "";
    if (asXmlString()) {
        NodeList nodes = XpathQueryHelper.resolveNodeList(doc, xpath, expr, allowEmptyResults());
        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);
            items += XmlHelper.nodeToString(node) + "\n";
        }
    } else {
        items = XpathQueryHelper.resolveMultipleTextItems(doc, xpath, expr, allowEmptyResults(), getSeparator());
    }
    return new MetadataElement(getMetadataKey(), items);
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) MetadataElement(com.adaptris.core.MetadataElement) InputFieldHint(com.adaptris.annotation.InputFieldHint)

Example 80 with MetadataElement

use of com.adaptris.core.MetadataElement in project interlok by adaptris.

the class MultiItemMetadataXpathQuery method resolveXpath.

@Override
public MetadataElement resolveXpath(Document doc, XPath xpath, String expr) throws CoreException {
    String items = "";
    if (asXmlString()) {
        NodeList nodes = XpathQueryHelper.resolveNodeList(doc, xpath, expr, allowEmptyResults());
        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);
            items += XmlHelper.nodeToString(node) + "\n";
        }
    } else {
        items = XpathQueryHelper.resolveMultipleTextItems(doc, xpath, expr, allowEmptyResults(), getSeparator());
    }
    return new MetadataElement(getMetadataKey(), items);
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) MetadataElement(com.adaptris.core.MetadataElement) InputFieldHint(com.adaptris.annotation.InputFieldHint)

Aggregations

MetadataElement (com.adaptris.core.MetadataElement)151 Test (org.junit.Test)101 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)94 XPath (com.adaptris.util.text.xml.XPath)23 Document (org.w3c.dom.Document)19 MetadataCollection (com.adaptris.core.MetadataCollection)18 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)18 ServiceException (com.adaptris.core.ServiceException)17 ServiceList (com.adaptris.core.ServiceList)14 Cache (com.adaptris.core.cache.Cache)14 MetadataCacheValueTranslator (com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator)12 ArrayList (java.util.ArrayList)11 CoreException (com.adaptris.core.CoreException)10 Service (com.adaptris.core.Service)10 HashSet (java.util.HashSet)9 ExpiringMapCache (com.adaptris.core.cache.ExpiringMapCache)8 StandaloneProducer (com.adaptris.core.StandaloneProducer)7 StaticCacheValueTranslator (com.adaptris.core.services.cache.translators.StaticCacheValueTranslator)7 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)6 Session (javax.jms.Session)6