diff --git a/appointment-import/src/main/java/smash/appointment/parse/PrcSubjectsParser.java b/appointment-import/src/main/java/smash/appointment/parse/PrcSubjectsParser.java index b24a61be5c22d4b6af45cc8a0347a598a9fe2108..a06e088395e0e174ea3625507faf7affb26e1b3a 100644 --- a/appointment-import/src/main/java/smash/appointment/parse/PrcSubjectsParser.java +++ b/appointment-import/src/main/java/smash/appointment/parse/PrcSubjectsParser.java @@ -4,8 +4,11 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.List; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.Color; import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.xssf.usermodel.XSSFColor; public class PrcSubjectsParser extends SubjectParser { @@ -151,9 +154,21 @@ public class PrcSubjectsParser extends SubjectParser { @Override protected boolean parseDead(Row row) { - if (row.getCell(0).getCellStyle().getFillBackgroundColorColor() != null) { + Color color = row.getCell(0).getCellStyle().getFillForegroundColorColor(); + if (color == null) { + return false; + } + if (color instanceof XSSFColor) { return true; } + if (color instanceof HSSFColor) { + HSSFColor hssfColor = (HSSFColor) color; + if (hssfColor.getHexString().equalsIgnoreCase("0:0:0")) { + return false; + } else { + return true; + } + } return false; } @@ -161,7 +176,7 @@ public class PrcSubjectsParser extends SubjectParser { protected boolean parseResigned(Row row) { try { int colorId = row.getSheet().getWorkbook().getFontAt(row.getCell(0).getCellStyle().getFontIndex()).getColor(); - //special case for black + // special case for black if (colorId == 32767) { return false; } @@ -186,7 +201,7 @@ public class PrcSubjectsParser extends SubjectParser { return false; } } catch (Exception e) { - logger.error("Problem with parsing color for subject: " + parseName(row)+" "+parseSurname(row), e); + logger.error("Problem with parsing color for subject: " + parseName(row) + " " + parseSurname(row), e); return false; } } diff --git a/appointment-import/src/test/java/smash/appointment/parse/PrcSubjectsParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/PrcSubjectsParserTest.java index b5281b382d80ca1ab4355f6bbc8cf22b031e7669..2c3a28ce8abe1d0de8960fc4082523b80c8338c0 100644 --- a/appointment-import/src/test/java/smash/appointment/parse/PrcSubjectsParserTest.java +++ b/appointment-import/src/test/java/smash/appointment/parse/PrcSubjectsParserTest.java @@ -75,6 +75,11 @@ public class PrcSubjectsParserTest extends TestBase { assertFalse(subject.isDead()); assertTrue(subject.isResigned()); - } + subject = entries.get(5); + assertFalse(subject.isDead()); + + subject = entries.get(6); + assertFalse(subject.isDead()); + } } diff --git a/appointment-import/testFiles/prcSubjectsExample.xlsx b/appointment-import/testFiles/prcSubjectsExample.xlsx index b728be7a0083e5574a6fc513934de0535fb19065..986303d98419537e3952a2d557457cb85f468693 100644 Binary files a/appointment-import/testFiles/prcSubjectsExample.xlsx and b/appointment-import/testFiles/prcSubjectsExample.xlsx differ