Hi Guys,
I've got a series of rules that compile fine but no rules seem to fire. The following is the rule file
/**************************
Working times rules
***************************/
package
au.com.codeprotechnology.online.ejb3.logic.crm
import au.com.codeprotechnology.online.bi.exception.ValidationError
import au.com.codeprotechnology.online.persistence.ejb.crm.WorkingTimes
import au.com.codeprotechnology.online.ejb3.logic.constants.WorkingTimesConstants
import java.util.Calendar
rule "Invalid day of week"
when
obj : WorkingTimes(val : primaryKey -> (val.getDayId() == null || val.getDayId().intValue() < Calendar.SUNDAY ||
val.getDayId().intValue() > Calendar.SATURDAY))
then
obj.addValidationError(new ValidationError(WorkingTimesConstants.MSG_KEY_INVALID_DAY_OF_WEEK, WorkingTimesConstants.MSG_INVALID_DAY_OF_WEEK));
end
rule "Invalid start hour"
when
obj : WorkingTimes(val : startHour -> (val.intValue() < WorkingTimesConstants.MIN_HOUR || val.intValue() > WorkingTimesConstants.MAX_HOUR))
then
obj.addValidationError(new ValidationError(WorkingTimesConstants.MSG_KEY_INVALID_START_HOUR, WorkingTimesConstants.MSG_INVALID_START_HOUR));
end
rule "Invalid start min"
when
obj : WorkingTimes(val : startMin -> (val.intValue() < WorkingTimesConstants.MIN_MINUTE || val.intValue() > WorkingTimesConstants.MAX_MINUTE))
then
obj.addValidationError
(new ValidationError(WorkingTimesConstants.MSG_KEY_INVALID_START_MIN, WorkingTimesConstants.MSG_INVALID_START_MIN));
end
rule "Invalid stop hour"
when
obj : WorkingTimes(val : stopHour -> (
val.intValue() < WorkingTimesConstants.MIN_HOUR || val.intValue() > WorkingTimesConstants.MAX_HOUR))
then
obj.addValidationError(new ValidationError(WorkingTimesConstants.MSG_KEY_INVALID_STOP_HOUR,
WorkingTimesConstants.MSG_INVALID_STOP_HOUR));
end
rule "Invalid stop min"
when
obj : WorkingTimes(val : stopMin -> (val.intValue() < WorkingTimesConstants.MIN_MINUTE
|| val.intValue() > WorkingTimesConstants.MAX_MINUTE))
then
obj.addValidationError(new ValidationError(WorkingTimesConstants.MSG_KEY_INVALID_STOP_MIN, WorkingTimesConstants.MSG_INVALID_STOP_MIN));
end
And this is the object I'm trying to assert
package au.com.codeprotechnology.online.persistence.ejb.crm;
import java.io.Serializable;
import javax.persistence.Column;
import
javax.persistence.Embeddable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import au.com.codeprotechnology.online.persistence.AbstractPersistenceBean
;
@Entity
@Table(name = "WORKING_TIMES")
public class WorkingTimes extends AbstractPersistenceBean implements Serializable {
private static final long serialVersionUID = -4972337627878376131L;
private WorkingTimesPK primaryKey;
private Integer startHour;
private Integer stopMin;
private Integer stopHour;
private Integer startMin;
public WorkingTimes() {
this.primaryKey = new WorkingTimesPK();
}
@EmbeddedId
public WorkingTimesPK getPrimaryKey() {
return primaryKey;
}
public void setPrimaryKey(WorkingTimesPK primaryKey) {
this.primaryKey = primaryKey;
}
@Column(name = "START_HOUR")
public Integer getStartHour() {
return startHour;
}
public void setStartHour(Integer startHour) {
this.startHour = startHour;
}
@Column(name = "START_MIN")
public Integer getStartMin() {
return startMin;
}
public void setStartMin(Integer startMin) {
this.startMin = startMin;
}
@Column(name = "STOP_HOUR")
public Integer getStopHour() {
return stopHour;
}
public void setStopHour(Integer stopHour) {
this.stopHour = stopHour;
}
@Column(name = "STOP_MIN")
public Integer getStopMin() {
return stopMin;
}
public void setStopMin(Integer stopMin) {
this.stopMin = stopMin;
}
@Embeddable
public static class WorkingTimesPK implements Serializable {
private static final long serialVersionUID = -567654057787556805L;
private Long supplierId;
private Integer dayId;
@Column(name = "DAY_ID")
public Integer getDayId() {
return dayId;
}
public void setDayId(Integer dayId) {
this.dayId = dayId;
}
@Column(name = "PREF_ID")
public Long getSupplierId() {
return supplierId;
}
public void setSupplierId(Long supplierId) {
this.supplierId = supplierId;
}
}
/**
* Not Implemented
*/
@Transient
public Long getId() {
return null;
}
public void setId(Long id) {
}
}
I've got stacks of similar rules and entity beans and it all works fine but this one doesn't seem to want to play. Does anybody have any ideas as to what is missing?