nikhilpurohit
8 years agoNew Contributor
Mapper not showing target schema for my custom snap
Hi,
In this i am creating snap which takes input as document and output as document it works fine right now. But when i am putting my snap as input for mapper it shows data on Input Schema perfectly.
but when i am using mapper output as input of my snap Test 2 it shows no data on target schema.
Test2 snap code snippet below
@General(title = "Test 2", purpose = "Consumes the incoming documents",
author = "Your Company Name", docLink = "http://yourdocslinkhere.com")
@Inputs(min = 1, max = 1, accepts = {ViewType.DOCUMENT})
@Outputs(min = 1, max = 1, offers = {ViewType.BINARY})
@Errors(min = 1, max = 1, offers = {ViewType.DOCUMENT})
@Version(snap = 1)
@Category(snap = SnapCategory.FORMAT)
public class Test2 implements Snap {
private String filePath;
@Inject
private DocumentUtility documentUtility;
String filetype;
String type;
String fileBrowser;
Map<String, Object> composite;
private AtomicInteger count = new AtomicInteger(0);
@Inject
private InputViews inputViews;
@Inject
private OutputViews outputViews;
@Inject
protected ErrorViews errorViews;
@Override
public void defineProperties(PropertyBuilder propertyBuilder) {
}
@Override
public void configure(PropertyValues propertyValues) throws ConfigurationException {
}
@Override
public void execute() throws ExecutionException {
InputView inputView = inputViews.get();
Iterator<Document> documentIterator = inputViews.getDocumentsFrom(inputView);
while (documentIterator.hasNext()) {
Document next = documentIterator.next();
Map<String, Object> asMap = documentUtility.getAsMap(next, errorViews);
try {
List<String> EntriesList = Formatter(asMap);
outputViews.write(new BinaryOutput() {
@Override
public void write(WritableByteChannel writeChannel) throws IOException {
OutputStream outputStream = Channels.newOutputStream(writeChannel);
try {
IOUtils.writeLines(EntriesList, null, outputStream, UTF_8);
} finally {
IOUtils.closeQuietly(outputStream);
}
}
@Override
public Document getHeader() {
// TODO Auto-generated method stub
return next;
}
});
} catch (JAXBException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
count.getAndIncrement();
}
}
@Override
public void cleanup() throws ExecutionException {
log.debug("Consumed {} documents", count.get());
}
}
Mapper Configuration screenshot: ( Target schema is blank )
Now please help me what i need to change in my code or provide me code snippet to expose my data on target schema.
Thanks