Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. //Example handler, in this case Excel rows are stored into an Apache Ignite cache
  2. public class MappingSheetHandler extends SheetHandler {
  3.  
  4. IgniteCache<BinaryObject, BinaryObject> mappingCache;
  5.  
  6. protected Map<String, String> headerRowMapping = new HashedMap<>();
  7.  
  8. protected LocationSheetHandler() {
  9. mappingCache = ignite.cache("mappings").withKeepBinary();
  10. }
  11.  
  12. @Override
  13. protected boolean processSheet() {
  14. return "Sheet 1".equals(sheetName);
  15. }
  16.  
  17. @Override
  18. protected void startSheet() {
  19. log.info(String.format("********************** Processing Mapping Sheet - %s ***************************", sheetName));
  20. }
  21.  
  22. @Override
  23. protected void endSheet() {
  24. log.info(String.format("********************** Processed Mapping Sheet - %s ***************************", sheetName));
  25. }
  26.  
  27. @Override
  28. protected void processRow() {
  29. if (rowNumber > 1 && !rowValues.isEmpty()) {
  30. String oldID = rowValues.get("A");
  31. String newID = rowValues.get("B");
  32.  
  33. if (newID == null) {
  34. return;
  35. }
  36.  
  37. String color = "white";
  38. CTXf style = rowStyles.get("A");
  39. if (style.getApplyFill()) {
  40. XSSFCellFill fill = stylesTable.getFillAt((int) style.getFillId());
  41. if ("FFFFFF00".contentEquals(fill.getFillForegroundColor().getARGBHex())) {
  42. color = "yellow";
  43. }
  44.  
  45. }
  46.  
  47. BinaryObjectBuilder keyBuilder = ignite.binary().builder("Key");
  48. keyBuilder.setField("srtype", "SomeType");
  49. keyBuilder.setField("srid", oldID);
  50. keyBuilder.setField("color", color);
  51.  
  52. BinaryObjectBuilder valBuilder = ignite.binary().builder("Value");
  53. valBuilder.setField("trtype", "SomeType");
  54. valBuilder.setField("trid", newID);
  55.  
  56. mappingCache.put(keyBuilder.build(), valBuilder.build());
  57.  
  58. }
  59. }
  60.  
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement