[jboss-svn-commits] JBL Code SVN: r32900 - labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/persistence.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun May 16 13:23:49 EDT 2010
Author: ge0ffrey
Date: 2010-05-16 13:23:49 -0400 (Sun, 16 May 2010)
New Revision: 32900
Modified:
labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/persistence/NurseRosteringSolutionImporter.java
Log:
more fail-fast on nonsense
Modified: labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/persistence/NurseRosteringSolutionImporter.java
===================================================================
--- labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/persistence/NurseRosteringSolutionImporter.java 2010-05-16 12:47:39 UTC (rev 32899)
+++ labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/persistence/NurseRosteringSolutionImporter.java 2010-05-16 17:23:49 UTC (rev 32900)
@@ -186,6 +186,10 @@
skill.setId(id);
skill.setCode(element.getText());
skillList.add(skill);
+ if (skillMap.containsKey(skill.getCode())) {
+ throw new IllegalArgumentException("There are 2 skills with the same code ("
+ + skill.getCode() + ").");
+ }
skillMap.put(skill.getCode(), skill);
id++;
}
@@ -232,6 +236,10 @@
}
shiftTypeList.add(shiftType);
+ if (shiftTypeMap.containsKey(shiftType.getCode())) {
+ throw new IllegalArgumentException("There are 2 shiftTypes with the same code ("
+ + shiftType.getCode() + ").");
+ }
shiftTypeMap.put(shiftType.getCode(), shiftType);
id++;
index++;
@@ -332,6 +340,10 @@
}
patternList.add(pattern);
+ if (patternMap.containsKey(pattern.getCode())) {
+ throw new IllegalArgumentException("There are 2 patterns with the same code ("
+ + pattern.getCode() + ").");
+ }
patternMap.put(pattern.getCode(), pattern);
id++;
}
@@ -415,6 +427,10 @@
}
contractList.add(contract);
+ if (contractMap.containsKey(contract.getCode())) {
+ throw new IllegalArgumentException("There are 2 contracts with the same code ("
+ + contract.getCode() + ").");
+ }
contractMap.put(contract.getCode(), contract);
id++;
}
@@ -503,7 +519,8 @@
int minimumValue = Integer.parseInt(minElement.getText());
if (minimumValue < 1) {
throw new IllegalArgumentException("The minimumValue (" + minimumValue
- + ") of contract (" + contract.getCode() + ") should be at least 1.");
+ + ") of contract (" + contract.getCode() + ") and contractLineType ("
+ + contractLineType + ") should be at least 1.");
}
contractLine.setMinimumValue(minimumValue);
contractLine.setMinimumWeight(minimumWeight);
@@ -513,7 +530,8 @@
int maximumValue = Integer.parseInt(maxElement.getText());
if (maximumValue < 1) {
throw new IllegalArgumentException("The maximumValue (" + maximumValue
- + ") of contract (" + contract.getCode() + ") should be at least 1.");
+ + ") of contract (" + contract.getCode() + ") and contractLineType ("
+ + contractLineType + ") should be at least 1.");
}
contractLine.setMaximumValue(maximumValue);
contractLine.setMaximumWeight(maximumWeight);
@@ -567,6 +585,10 @@
}
employeeList.add(employee);
+ if (employeeMap.containsKey(employee.getCode())) {
+ throw new IllegalArgumentException("There are 2 employees with the same code ("
+ + employee.getCode() + ").");
+ }
employeeMap.put(employee.getCode(), employee);
id++;
}
More information about the jboss-svn-commits
mailing list