Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp

Rodney Bowden

Greenhorn
+ Follow
since May 03, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rodney Bowden

Hi, I am trying to write a rule to load balance, in the first instance, a singular contract. Below is the rule.


Error
Exception in thread "AWT-EventQueue-0" Exception executing consequence for rule "fairAssignmentCountPerEmployee" in org.optaplanner.examples.nurserostering.solver: java.lang.NullPointerException
at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.core.common.DefaultAgenda.handleException(DefaultAgenda.java:1242)
at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:439)
at org.drools.core.phreak.RuleExecutor.fireActivation(RuleExecutor.java:380)
at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:136)
at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:89)
at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:34)
at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43)
at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1062)
at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:1009)
at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1001)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1330)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1321)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1305)
at org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.calculateScore(DroolsScoreDirector.java:171)
at org.optaplanner.examples.common.business.SolutionBusiness.getScore(SolutionBusiness.java:218)
at org.optaplanner.examples.common.swingui.SolverAndPersistenceFrame.resetScreen(SolverAndPersistenceFrame.java:805)
at org.optaplanner.examples.common.swingui.SolverAndPersistenceFrame.setSolutionLoaded(SolverAndPersistenceFrame.java:775)
at org.optaplanner.examples.common.swingui.SolverAndPersistenceFrame.access$1(SolverAndPersistenceFrame.java:765)
at org.optaplanner.examples.common.swingui.SolverAndPersistenceFrame$DataImportAction.actionPerformed(SolverAndPersistenceFrame.java:421)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6539)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6304)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.NullPointerException
at org.drools.core.reteoo.FromNodeLeftTuple.getAccumulatedObjects(FromNodeLeftTuple.java:111)
at org.drools.core.common.AgendaItem.getObjectsDeep(AgendaItem.java:79)
at org.drools.core.reteoo.RuleTerminalNodeLeftTuple.getObjectsDeep(RuleTerminalNodeLeftTuple.java:359)
at org.optaplanner.core.api.score.holder.AbstractScoreHolder.extractJustificationList(AbstractScoreHolder.java:133)
at org.optaplanner.core.api.score.holder.AbstractScoreHolder.registerConstraintMatch(AbstractScoreHolder.java:104)
at org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScoreHolder.addSoftConstraintMatch(HardSoftScoreHolder.java:177)
at org.optaplanner.examples.nurserostering.solver.Rule_fairAssignmentCountPerEmployee343111290.defaultConsequence(Rule_fairAssignmentCountPerEmployee343111290.java:21)
at org.optaplanner.examples.nurserostering.solver.Rule_fairAssignmentCountPerEmployee343111290DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
at org.optaplanner.examples.nurserostering.solver.Rule_fairAssignmentCountPerEmployee343111290DefaultConsequenceInvoker.evaluate(Unknown Source)
at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:432)
... 53 more

Can see contract in debub
13:15:52.451 [EventQueue-0] INFO  HHH000397: Using ASTQueryTranslatorFactory
Hibernate: select shiftonreq0_.id as id1_20_, shiftonreq0_.employee_id as employee3_20_, shiftonreq0_.shift_id as shift_id4_20_, shiftonreq0_.weight as weight2_20_ from ShiftOnRequest shiftonreq0_
FT
1 month ago
Does anyone have an example code to enable the update of the username and password fields within the hibernate.cfg file via JAVAFX?
1 month ago
I fixed my problem as per the below

package org.optaplanner.examples.nurserostering.persistence;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.poi.hssf.util.CellReference;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.optaplanner.examples.common.persistence.AbstractXlsxSolutionExporter;

import org.optaplanner.examples.nurserostering.domain.Employee;
import org.optaplanner.examples.nurserostering.domain.NurseRoster;
import org.optaplanner.examples.nurserostering.domain.NurseRosterParametrization;
import org.optaplanner.examples.nurserostering.domain.ShiftAssignment;
import org.optaplanner.examples.nurserostering.domain.ShiftDate;



1 month ago
I would like to position my output based on the column value (the date). See attachment Screen Shot. Below is my current code.  I would like to place the shift code value cell.setCellValue(obj.getShiftType().getCode()); for the employee in the correct date column and row. Any suggestions welcome.



}

1 month ago
Hi There, I am trying to export to excel in a particular format. Below is my current code:  





I can get the following formats.. Viewed better in attachment: What I really want is the date to be a header and the shift code to align to the date and employee. Any suggestions?

Isabella       D L E E L N N L
Anthony Phan   D D L D E D L L
Michael B       D L N L L N N L
Alana Gill       N N N N N N N N
Sophie Dreves   E E D D D L E E
Reece Bamford   N D D L N E E D
Clayton Fletcher   E E E E E D L L
Gemma Nevin       D L L N E E D L
Michael C       E E N N D E L D
Lisa Coull       D L L L D L E E
Karen Ahrens   L E E E N D E D
David Hemmings     L N N N N N N N



Isabella            2019-04-09/D 2019-04-10/D 2019-04-11/L 2019-04-14/E 2019-04-15/E 2019-04-16/L 2019-04-19/N 2019-04-20/N 2019-04-21/L
Anthony Phan        2019-04-08/D 2019-04-09/D 2019-04-10/D 2019-04-11/L 2019-04-15/D 2019-04-16/E 2019-04-17/D 2019-04-18/L 2019-04-19/L
Michael B            2019-04-10/L 2019-04-11/D 2019-04-12/L 2019-04-13/N 2019-04-15/L 2019-04-16/L 2019-04-19/N 2019-04-20/N 2019-04-21/L
Alana Gill            2019-04-08/L 2019-04-09/N 2019-04-10/N 2019-04-11/N 2019-04-12/N 2019-04-16/N 2019-04-17/N 2019-04-18/N 2019-04-21/N
Sophie Dreves        2019-04-08/N 2019-04-12/E 2019-04-13/E 2019-04-14/D 2019-04-15/D 2019-04-16/D 2019-04-17/L 2019-04-20/E 2019-04-21/E
Reece Bamford        2019-04-08/L 2019-04-09/N 2019-04-12/D 2019-04-13/D 2019-04-14/L 2019-04-15/N 2019-04-17/E 2019-04-18/E 2019-04-19/D
Clayton Fletcher    2019-04-08/D 2019-04-09/E 2019-04-10/E 2019-04-11/E 2019-04-15/E 2019-04-16/E 2019-04-17/D 2019-04-18/L 2019-04-19/L
Gemma Nevin         2019-04-10/L 2019-04-11/D 2019-04-12/L 2019-04-13/L 2019-04-14/N 2019-04-17/E 2019-04-18/E 2019-04-19/D 2019-04-20/L
Michael C            2019-04-09/E 2019-04-10/E 2019-04-11/E 2019-04-13/N 2019-04-14/N 2019-04-18/D 2019-04-19/E 2019-04-20/L 2019-04-21/D
Lisa Coull            2019-04-08/N 2019-04-12/D 2019-04-13/L 2019-04-14/L 2019-04-15/L 2019-04-16/D 2019-04-17/L 2019-04-20/E 2019-04-21/E
Karen Ahrens        2019-04-08/E 2019-04-09/L 2019-04-12/E 2019-04-13/E 2019-04-14/E 2019-04-15/N 2019-04-18/D 2019-04-19/E 2019-04-20/D
David Hemmings      2019-04-08/E 2019-04-09/L 2019-04-10/N 2019-04-11/N 2019-04-12/N 2019-04-16/N 2019-04-17/N 2019-04-18/N 2019-04-21/N


1 month ago
Hi there, I am trying to pass some data from a list into a spreadsheet. Current code below: This works fine in giving me a format as follows. But what i really want is the format as per attached. Any ideas greatly appreciated as I am struggling

Name

Karen Ahrens E 2019-04-08
David Hemmings E 2019-04-08
Clayton Fletcher D 2019-04-08
Anthony Phan D 2019-04-08
Reece Bamford L 2019-04-08
Alana Gill L 2019-04-08
Sophie Dreves N 2019-04-08
Lisa Coull N 2019-04-08
Gemma Nevin E 2019-04-09
Michael C E 2019-04-09
Michael B D 2019-04-09
Isabella D 2019-04-09
Karen Ahrens L 2019-04-09
David Hemmings L 2019-04-09
Reece Bamford N 2019-04-09
Alana Gill N 2019-04-09
Gemma Nevin E 2019-04-10
Michael C E 2019-04-10
Michael B D 2019-04-10
Isabella D 2019-04-10


Name           2019-04-08     2019-04-09
Karen Ahrens            E                L
David Hemmings    E           L
Clayton Fletcher   D
Anthony Phan             D
Reece Bamford   L               N
Alana Gill L          N
Sophie Dreves  N
Lisa Coull          N
Gemma Nevin
                                                E
Michael C
                                               E
Michael B
                                               D
Isabella
                                                D



2 months ago