Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Example handler, in this case Excel rows are stored into an Apache Ignite cache
- public class MappingSheetHandler extends SheetHandler {
- IgniteCache<BinaryObject, BinaryObject> mappingCache;
- protected Map<String, String> headerRowMapping = new HashedMap<>();
- protected LocationSheetHandler() {
- mappingCache = ignite.cache("mappings").withKeepBinary();
- }
- @Override
- protected boolean processSheet() {
- return "Sheet 1".equals(sheetName);
- }
- @Override
- protected void startSheet() {
- log.info(String.format("********************** Processing Mapping Sheet - %s ***************************", sheetName));
- }
- @Override
- protected void endSheet() {
- log.info(String.format("********************** Processed Mapping Sheet - %s ***************************", sheetName));
- }
- @Override
- protected void processRow() {
- if (rowNumber > 1 && !rowValues.isEmpty()) {
- String oldID = rowValues.get("A");
- String newID = rowValues.get("B");
- if (newID == null) {
- return;
- }
- String color = "white";
- CTXf style = rowStyles.get("A");
- if (style.getApplyFill()) {
- XSSFCellFill fill = stylesTable.getFillAt((int) style.getFillId());
- if ("FFFFFF00".contentEquals(fill.getFillForegroundColor().getARGBHex())) {
- color = "yellow";
- }
- }
- BinaryObjectBuilder keyBuilder = ignite.binary().builder("Key");
- keyBuilder.setField("srtype", "SomeType");
- keyBuilder.setField("srid", oldID);
- keyBuilder.setField("color", color);
- BinaryObjectBuilder valBuilder = ignite.binary().builder("Value");
- valBuilder.setField("trtype", "SomeType");
- valBuilder.setField("trid", newID);
- mappingCache.put(keyBuilder.build(), valBuilder.build());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement