@Override
protected Chunk doProcessChunk(final Chunk data,
final Map<String, Serializable> context,
final IProcessListener processListener,
final ProcessingStats stats)
throws Exception {
final Batch batch = browserFacade.relation(TypeView.TYPE_VIEW_NAME).batch();
for (final CatalogElement ce : data.getItems()) {
try {
if (ce.isDeleted()) {
batch.delete(Condition.eq(TypeView.FIELD_EXTID, ce.getId().getId()));
} else if (ce.getElement() == null && ce.getNonElement() != null) {
String extId = null;
extId = ce.getNonElement().getExtId();
final Serializable[] tuple = TypeView.asTuple(ce.getNonElement());
batch.addOrUpdate(Condition.eq(TypeView.FIELD_EXTID, extId), tuple);
} else if (ce.isDeleted()) {
batch.delete(Condition.eq(TypeView.FIELD_EXTID, ce.getExtId()));
}
} catch (final Exception e) {
log.error("Exception processing element " + ce.getExtId());
if (processListener != null) {
processListener.notifyEvent("typeViewGenerator.process", new String[]{ce.getExtId()}, EventResultCode.ERROR, StackTraceUtil.getStackTrace(e));
}
throw e;
}
}
batch.run();
return data;
}