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.
[DROOLS-2634] fix for several cep use cases in executable model
- Loading branch information
1 parent
0c825e9
commit 2fd3ac3
Showing
17 changed files
with
334 additions
and
63 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
57 changes: 57 additions & 0 deletions
57
...s-canonical-model/src/main/java/org/drools/model/constraints/FixedTemporalConstraint.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,57 @@ | |||
/* | |||
* 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.constraints; | |||
|
|||
import org.drools.model.Variable; | |||
import org.drools.model.functions.temporal.TemporalPredicate; | |||
import org.drools.model.impl.ModelComponent; | |||
import org.drools.model.view.FixedTemporalExprViewItem; | |||
|
|||
public class FixedTemporalConstraint<A> extends TemporalConstraint { | |||
|
|||
private final long value; | |||
|
|||
public FixedTemporalConstraint( String exprId, Variable<A> var1, long value, TemporalPredicate temporalPredicate ) { | |||
super(exprId, var1, temporalPredicate); | |||
this.value = value; | |||
} | |||
|
|||
public FixedTemporalConstraint( FixedTemporalExprViewItem<A> expr ) { | |||
this( expr.getExprId(), expr.getFirstVariable(), expr.getValue(), expr.getTemporalPredicate() ); | |||
} | |||
|
|||
@Override | |||
public Variable[] getVariables() { | |||
return new Variable[] { var1 }; | |||
} | |||
|
|||
public long getValue() { | |||
return value; | |||
} | |||
|
|||
@Override | |||
public boolean isEqualTo( ModelComponent o ) { | |||
if ( this == o ) return true; | |||
if ( o == null || getClass() != o.getClass() ) return false; | |||
|
|||
FixedTemporalConstraint<?> that = ( FixedTemporalConstraint<?> ) o; | |||
|
|||
if ( !ModelComponent.areEqualInModel( var1, that.var1 ) ) return false; | |||
if ( value != that.value ) return false; | |||
return temporalPredicate.equals( that.temporalPredicate ); | |||
} | |||
} |
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
53 changes: 53 additions & 0 deletions
53
...anonical-model/src/main/java/org/drools/model/constraints/VariableTemporalConstraint.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,53 @@ | |||
/* | |||
* 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.constraints; | |||
|
|||
import org.drools.model.Variable; | |||
import org.drools.model.functions.temporal.TemporalPredicate; | |||
import org.drools.model.impl.ModelComponent; | |||
import org.drools.model.view.VariableTemporalExprViewItem; | |||
|
|||
public class VariableTemporalConstraint<A> extends TemporalConstraint { | |||
|
|||
private final Variable<?> var2; | |||
|
|||
public VariableTemporalConstraint( String exprId, Variable<A> var1, Variable<?> var2, TemporalPredicate temporalPredicate ) { | |||
super(exprId, var1, temporalPredicate); | |||
this.var2 = var2; | |||
} | |||
|
|||
public VariableTemporalConstraint( VariableTemporalExprViewItem<A> expr ) { | |||
this( expr.getExprId(), expr.getFirstVariable(), expr.getSecondVariable(), expr.getTemporalPredicate() ); | |||
} | |||
|
|||
@Override | |||
public Variable[] getVariables() { | |||
return new Variable[] { var1, var2 }; | |||
} | |||
|
|||
@Override | |||
public boolean isEqualTo( ModelComponent o ) { | |||
if ( this == o ) return true; | |||
if ( o == null || getClass() != o.getClass() ) return false; | |||
|
|||
VariableTemporalConstraint<?> that = ( VariableTemporalConstraint<?> ) o; | |||
|
|||
if ( !ModelComponent.areEqualInModel( var1, that.var1 ) ) return false; | |||
if ( !ModelComponent.areEqualInModel( var2, that.var2 ) ) return false; | |||
return temporalPredicate.equals( that.temporalPredicate ); | |||
} | |||
} |
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
44 changes: 44 additions & 0 deletions
44
...drools-canonical-model/src/main/java/org/drools/model/view/FixedTemporalExprViewItem.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,44 @@ | |||
/* | |||
* 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.view; | |||
|
|||
import org.drools.model.Variable; | |||
import org.drools.model.functions.temporal.TemporalPredicate; | |||
|
|||
public class FixedTemporalExprViewItem<T> extends TemporalExprViewItem<T> { | |||
|
|||
private final long value; | |||
|
|||
public FixedTemporalExprViewItem( Variable<T> var1, long value, TemporalPredicate temporalPredicate ) { | |||
super(var1, value, temporalPredicate); | |||
this.value = value; | |||
} | |||
|
|||
public FixedTemporalExprViewItem( String exprId, Variable<T> var1, long value, TemporalPredicate temporalPredicate ) { | |||
super(exprId, var1, temporalPredicate); | |||
this.value = value; | |||
} | |||
|
|||
public long getValue() { | |||
return value; | |||
} | |||
|
|||
@Override | |||
public Variable<?>[] getVariables() { | |||
return new Variable[] { getFirstVariable() }; | |||
} | |||
} |
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.