Skip to content
Snippets Groups Projects
Commit ba945e40 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

parsing of dead subjects is handled properly for old xls files

parent 03ab7b50
No related branches found
No related tags found
1 merge request!2Appointments dev
......@@ -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;
}
}
......
......@@ -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());
}
}
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment