use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class ConfiguredXpathQueryTest method testResolveXpath_function.
@Test
public void testResolveXpath_function() throws Exception {
ConfiguredXpathQuery query = init(create(), "count(/message)");
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML);
Document doc = XmlHelper.createDocument(XML);
MetadataElement result = query.resolveXpath(doc, new XPath(), query.createXpathQuery(msg));
assertEquals("1", result.getValue());
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class ConfiguredXpathQueryTest method testResolveNodesAsString.
@Test
public void testResolveNodesAsString() throws Exception {
ConfiguredXpathQuery query = new ConfiguredXpathQuery("result", "//source-id");
query.setAsXmlString(true);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML);
MetadataElement result = query.resolveXpath(XmlHelper.createDocument(msg.getContent()), new XPath(), query.createXpathQuery(msg));
assertEquals("<source-id>partnera</source-id>", result.getValue().strip());
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class FirstRowMetadataTranslator method translateResult.
@Override
public long translateResult(JdbcResult source, AdaptrisMessage target) throws SQLException, ServiceException {
List<MetadataElement> added = new ArrayList<MetadataElement>();
long resultSetCount = 0;
Iterator<JdbcResultRow> iter;
for (JdbcResultSet resultSet : source.getResultSets()) {
if (resultSet.getRows() != null && (iter = resultSet.getRows().iterator()) != null && iter.hasNext()) {
JdbcResultRow storedProcedureResultRow = iter.next();
if (storedProcedureResultRow != null) {
for (int i = 0; i < storedProcedureResultRow.getFieldCount(); i++) {
String column = storedProcedureResultRow.getFieldName(i);
String resultSetPrefix = source.countResultSets() > 1 ? Long.toString(resultSetCount) + getResultSetCounterPrefix() : "";
MetadataElement md = new MetadataElement(resultSetPrefix + getMetadataKeyPrefix() + getSeparator() + getColumnNameStyle().format(column), toString(storedProcedureResultRow, i));
if (log.isTraceEnabled()) {
added.add(md);
}
target.addMetadata(md);
}
if (log.isTraceEnabled()) {
log.debug("Added metadata : " + added);
}
} else {
log.debug("No Rows to process");
}
resultSetCount++;
}
}
return resultSetCount;
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class DynamicServiceExecutorTest method testDoService_MimeServiceExtractor_ByContentId.
@Test
public void testDoService_MimeServiceExtractor_ByContentId() throws Exception {
AddMetadataService metadataService = new AddMetadataService();
metadataService.addMetadataElement(new MetadataElement(getName(), getName()));
DynamicServiceExecutor dynamicService = createService();
dynamicService.setServiceExtractor(new MimeServiceExtractor(new SelectByContentId("Service")));
AdaptrisMessage msg = createMimeMessage(new ServiceList(new Service[] { metadataService }), ENCODING_8BIT);
execute(dynamicService, msg);
assertEquals(getName(), msg.getMetadataValue(getName()));
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class DynamicServiceExecutorTest method testDoService_MimeServiceExtractor_ByPosition.
@Test
public void testDoService_MimeServiceExtractor_ByPosition() throws Exception {
AddMetadataService metadataService = new AddMetadataService();
metadataService.addMetadataElement(new MetadataElement(getName(), getName()));
DynamicServiceExecutor dynamicService = createService();
dynamicService.setServiceExtractor(new MimeServiceExtractor(new SelectByPosition(0)));
AdaptrisMessage msg = createMimeMessage(new ServiceList(new Service[] { metadataService }), ENCODING_7BIT);
execute(dynamicService, msg);
assertEquals(getName(), msg.getMetadataValue(getName()));
}
Aggregations