forked from apache/incubator-kie-drools
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporal Predicates for OOPathcepTest (apache#1692)
* Slightly better fix for missing class OOPathExpression * Let's not merge the two expressions * Restore substitution of last OOPath chunk * Do not overwrite last declaration in OOPath * All temporal operators * Avoid collision while finding the binding ID in a OOPathChunk expr * Fix Interval Min Value and testTemporalOperatorAfterWithOOPath * Temporal operators use TemporalOperatorSpec * Coincides Predicate * Coincides predicate * Coincides Predicate * Overlaps predicate * Metby predicate * FinishedBy * Meets * Refactor to intoduce end timestamp in the evaluate method * During Predicate * Startedby predicate * Overlapped by * Includes Predicate * StartsPredicate * Finishes Predicate * Coincides * Fix After Predicate * Fix DuringPredicate * Disable tests * Moved OperatorSpec to separated package
- Loading branch information
1 parent
db135c5
commit 95eb2b6
Showing
22 changed files
with
697 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...canonical-model/src/main/java/org/drools/model/functions/temporal/CoincidesPredicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2005 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.drools.model.functions.temporal; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.drools.model.functions.temporal.TimeUtil.unitToLong; | ||
|
||
public class CoincidesPredicate extends AbstractTemporalPredicate { | ||
|
||
private final long startDevLong; | ||
private final long endDevLong; | ||
|
||
public CoincidesPredicate(long dev, TimeUnit devUnit) { | ||
super(new Interval(Interval.MIN, Interval.MAX)); | ||
this.startDevLong = unitToLong(dev, devUnit); | ||
this.endDevLong = unitToLong(dev, devUnit); | ||
} | ||
|
||
|
||
@Override | ||
public String toString() { | ||
return "coincides" + interval; | ||
} | ||
|
||
@Override | ||
public boolean evaluate(long start1, long duration1, long end1, long start2, long duration2, long end2) { | ||
long distStart = Math.abs( start2 - start1 ); | ||
long distEnd = Math.abs( end2 - end1 ); | ||
return (distStart <= this.startDevLong && distEnd <= this.endDevLong); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...ls-canonical-model/src/main/java/org/drools/model/functions/temporal/DuringPredicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2005 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.drools.model.functions.temporal; | ||
|
||
public class DuringPredicate extends AbstractTemporalPredicate { | ||
|
||
private final long startMinDev, startMaxDev; | ||
private final long endMinDev, endMaxDev; | ||
|
||
public DuringPredicate() { | ||
super(new Interval(1, Interval.MAX)); | ||
this.startMinDev = 1; | ||
this.startMaxDev = Long.MAX_VALUE; | ||
this.endMinDev = 1; | ||
this.endMaxDev = Long.MAX_VALUE; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "during" + interval; | ||
} | ||
|
||
@Override | ||
public boolean evaluate(long start1, long duration1, long end1, long start2, long duration2, long end2) { | ||
long distStart = start1 - start2; | ||
long distEnd = end2 - end1; | ||
return (distStart >= this.startMinDev && distStart <= this.startMaxDev && distEnd >= this.endMinDev && distEnd <= this.endMaxDev); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...anonical-model/src/main/java/org/drools/model/functions/temporal/FinishedbyPredicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2005 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.drools.model.functions.temporal; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.drools.model.functions.temporal.TimeUtil.unitToLong; | ||
|
||
public class FinishedbyPredicate extends AbstractTemporalPredicate { | ||
|
||
long endDev; | ||
|
||
public FinishedbyPredicate() { | ||
super(new Interval(Interval.MIN, 0)); | ||
this.endDev = 0; | ||
} | ||
|
||
public FinishedbyPredicate(long endDev, TimeUnit endDevTimeUnit) { | ||
super(new Interval(Interval.MIN, 0)); | ||
this.endDev = unitToLong(endDev, endDevTimeUnit); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "finishedby" + interval; | ||
} | ||
|
||
@Override | ||
public boolean evaluate(long start1, long duration1, long end1, long start2, long duration2, long end2) { | ||
long distStart = start2 - start1; | ||
long distEnd = Math.abs(end2 - end1); | ||
return (distStart > 0 && distEnd <= this.endDev); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...-canonical-model/src/main/java/org/drools/model/functions/temporal/FinishesPredicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2005 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.drools.model.functions.temporal; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.drools.model.functions.temporal.TimeUtil.unitToLong; | ||
|
||
public class FinishesPredicate extends AbstractTemporalPredicate { | ||
|
||
private final long endDev; | ||
|
||
public FinishesPredicate() { | ||
super(new Interval(0, Interval.MAX)); | ||
this.endDev = 0; | ||
} | ||
|
||
public FinishesPredicate(long endDev, TimeUnit endDevLongUnit) { | ||
super(new Interval(0, Interval.MAX)); | ||
this.endDev = unitToLong(endDev, endDevLongUnit); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "finishes" + interval; | ||
} | ||
|
||
@Override | ||
public boolean evaluate(long start1, long duration1, long end1, long start2, long duration2, long end2) { | ||
|
||
long distStart = start1 - start2; | ||
long distEnd = Math.abs( end2 - end1 ); | ||
return (distStart > 0 && distEnd <= this.endDev); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...-canonical-model/src/main/java/org/drools/model/functions/temporal/IncludesPredicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2005 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.drools.model.functions.temporal; | ||
|
||
public class IncludesPredicate extends AbstractTemporalPredicate { | ||
|
||
private final long startMinDev, startMaxDev; | ||
private final long endMinDev, endMaxDev; | ||
|
||
public IncludesPredicate() { | ||
super(new Interval(Interval.MIN, 0)); | ||
this.startMinDev = 1; | ||
this.startMaxDev = Long.MAX_VALUE; | ||
this.endMinDev = 1; | ||
this.endMaxDev = Long.MAX_VALUE; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "during " + interval; | ||
} | ||
|
||
@Override | ||
public boolean evaluate(long start1, long duration1, long end1, long start2, long duration2, long end2) { | ||
long distStart = start2 - start1; | ||
long distEnd = end1 - end2; | ||
return (distStart >= this.startMinDev && distStart <= this.startMaxDev && distEnd >= this.endMinDev && distEnd <= this.endMaxDev); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.