[jboss-svn-commits] JBL Code SVN: r32854 - 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
Thu May 13 06:51:47 EDT 2010


Author: ge0ffrey
Date: 2010-05-13 06:51:47 -0400 (Thu, 13 May 2010)
New Revision: 32854

Modified:
   labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/persistence/NurseRosteringEvaluatorHelper.java
Log:
nurse rostering: line contains filter

Modified: labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/persistence/NurseRosteringEvaluatorHelper.java
===================================================================
--- labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/persistence/NurseRosteringEvaluatorHelper.java	2010-05-13 10:49:56 UTC (rev 32853)
+++ labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/persistence/NurseRosteringEvaluatorHelper.java	2010-05-13 10:51:47 UTC (rev 32854)
@@ -18,7 +18,7 @@
 
     private static final String INPUT_FILE_PREFIX = "long01";
     private static final String OUTPUT_FILE_SUFFIX = "_tmp";
-    private static final String DEFAULT_LINE_CONTAINS_FILTER = null;
+    private static final String DEFAULT_LINE_CONTAINS_FILTER = "Requested shift off";
 
     public static void main(String[] args) {
         String lineContainsFilter;
@@ -78,26 +78,26 @@
         }
 
         private void processLine(String line) {
-            int excessIndex = line.indexOf("excess = ");
-            if (excessIndex >= 0) {
-                String key = line.substring(0, excessIndex);
-                int value = Integer.parseInt(line.substring(excessIndex).replaceAll("excess = (\\d+) .*", "$1"));
-                int[] excess = excessMap.get(key);
-                if (excess == null) {
-                    excess = new int[]{0, value};
-                    excessMap.put(key, excess);
-                } else {
-                    excess[0]++;
-                    excess[1] += value;
+            if (lineContainsFilter == null || line.contains(lineContainsFilter)) {
+                int excessIndex = line.indexOf("excess = ");
+                if (excessIndex >= 0) {
+                    String key = line.substring(0, excessIndex);
+                    int value = Integer.parseInt(line.substring(excessIndex).replaceAll("excess = (\\d+) .*", "$1"));
+                    int[] excess = excessMap.get(key);
+                    if (excess == null) {
+                        excess = new int[]{0, value};
+                        excessMap.put(key, excess);
+                    } else {
+                        excess[0]++;
+                        excess[1] += value;
+                    }
                 }
-            }
-            int employeeIndex = line.indexOf("Employee: ");
-            if (employeeIndex >= 0) {
-                lastEmployeeCode = line.substring(employeeIndex).replaceAll("Employee: (.+)", "$1");
-            } else if (line.contains("Penalty:")) {
-                lastEmployeeCode = null;
-            }
-            if (lineContainsFilter == null || line.contains(lineContainsFilter)) {
+                int employeeIndex = line.indexOf("Employee: ");
+                if (employeeIndex >= 0) {
+                    lastEmployeeCode = line.substring(employeeIndex).replaceAll("Employee: (.+)", "$1");
+                } else if (line.contains("Penalty:")) {
+                    lastEmployeeCode = null;
+                }
                 if (lastEmployeeCode != null) {
                     System.out.print("E(" + lastEmployeeCode + ")  ");
                 }
@@ -107,6 +107,9 @@
 
         public void writeResults() {
             System.out.println("EvaluatorHelper results for " + name);
+            if (lineContainsFilter != null) {
+                System.out.println("with lineContainsFilter (" + lineContainsFilter + ")");
+            }
             for (Map.Entry<String, int[]> entry : excessMap.entrySet()) {
                 int[] excess = entry.getValue();
                 System.out.println(entry.getKey() + " count = " + excess[0] + " total = " + excess[1]);



More information about the jboss-svn-commits mailing list