Last active
July 15, 2020 13:38
-
-
Save lucamolteni/c8e219147d87716393bc9043a19193cc to your computer and use it in GitHub Desktop.
KogitoFactHandle.patch
This file contains hidden or 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
Index: drools/kogito-ruleunits/src/main/java/org/kie/kogito/rules/units/FieldDataStore.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- drools/kogito-ruleunits/src/main/java/org/kie/kogito/rules/units/FieldDataStore.java (revision 2394b61f5a361f54787dd1e648e9976b7fd18e06) | |
+++ drools/kogito-ruleunits/src/main/java/org/kie/kogito/rules/units/FieldDataStore.java (date 1594820134890) | |
@@ -29,6 +29,7 @@ | |
import org.kie.kogito.rules.DataProcessor; | |
import org.kie.kogito.rules.SingletonStore; | |
import org.kie.kogito.rules.units.impl.DataHandleImpl; | |
+import org.kogito.KogitoInternalFactHandle; | |
public class FieldDataStore<T> implements SingletonStore<T>, | |
InternalStoreCallback { | |
@@ -92,14 +93,14 @@ | |
@Override | |
public void update(InternalFactHandle fh, Object obj, BitMask mask, Class<?> modifiedClass, Activation activation) { | |
- DataHandle dh = fh.getDataHandle(); | |
+ DataHandle dh = ((KogitoInternalFactHandle)fh).getDataHandle(); | |
entryPointSubscribers.forEach(s -> s.update(dh, obj, mask, modifiedClass, activation)); | |
subscribers.forEach(s -> s.update(dh, (T) obj)); | |
} | |
@Override | |
public void delete(InternalFactHandle fh, RuleImpl rule, TerminalNode terminalNode, FactHandle.State fhState) { | |
- DataHandle dh = fh.getDataHandle(); | |
+ DataHandle dh = ((KogitoInternalFactHandle)fh).getDataHandle(); | |
if (dh != this.handle) { | |
throw new IllegalArgumentException("The given handle is not contained in this DataStore"); | |
} | |
@@ -111,8 +112,8 @@ | |
private void internalInsert(DataHandle dh, DataProcessor processor) { | |
FactHandle fh = processor.insert(dh, dh == null ? null : dh.getObject()); | |
if (fh != null) { | |
- ((InternalFactHandle) fh).setDataStore(this); | |
- ((InternalFactHandle) fh).setDataHandle(dh); | |
+// ((KogitoInternalFactHandle) fh).setDataStore(this); TODO | |
+ ((KogitoInternalFactHandle) fh).setDataHandle(dh); | |
} | |
} | |
} | |
Index: drools/drools-core/src/main/java/org/kogito/KogitoInternalFactHandle.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- drools/drools-core/src/main/java/org/kogito/KogitoInternalFactHandle.java (date 1594819395455) | |
+++ drools/drools-core/src/main/java/org/kogito/KogitoInternalFactHandle.java (date 1594819395455) | |
@@ -0,0 +1,30 @@ | |
+/* | |
+ * Copyright 2005 Red Hat, Inc. and/or its affiliates. | |
+ * | |
+ * 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.kogito; | |
+ | |
+import org.drools.core.common.InternalFactHandle; | |
+import org.kie.kogito.rules.DataHandle; | |
+ | |
+public interface KogitoInternalFactHandle | |
+ extends | |
+ InternalFactHandle { | |
+ | |
+ default DataHandle getDataHandle() { | |
+ return null; | |
+ } | |
+ default void setDataHandle( DataHandle dataHandle ) { } | |
+} | |
Index: drools/drools-core/src/main/java/org/kogito/KogitoDefaultFactHandle.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- drools/drools-core/src/main/java/org/kogito/KogitoDefaultFactHandle.java (date 1594820001192) | |
+++ drools/drools-core/src/main/java/org/kogito/KogitoDefaultFactHandle.java (date 1594820001192) | |
@@ -0,0 +1,53 @@ | |
+package org.kogito; | |
+ | |
+import org.drools.core.WorkingMemoryEntryPoint; | |
+import org.drools.core.common.DefaultFactHandle; | |
+import org.drools.core.factmodel.traits.TraitTypeEnum; | |
+import org.drools.core.rule.EntryPointId; | |
+import org.kie.kogito.rules.DataHandle; | |
+ | |
+public class KogitoDefaultFactHandle extends DefaultFactHandle implements KogitoInternalFactHandle { | |
+ | |
+ public KogitoDefaultFactHandle() { | |
+ } | |
+ | |
+ public KogitoDefaultFactHandle(long id, Object object) { | |
+ super(id, object); | |
+ } | |
+ | |
+ public KogitoDefaultFactHandle(long id, Object object, long recency, WorkingMemoryEntryPoint wmEntryPoint) { | |
+ super(id, object, recency, wmEntryPoint); | |
+ } | |
+ | |
+ public KogitoDefaultFactHandle(long id, Object object, long recency, WorkingMemoryEntryPoint wmEntryPoint, boolean isTraitOrTraitable) { | |
+ super(id, object, recency, wmEntryPoint, isTraitOrTraitable); | |
+ } | |
+ | |
+ public KogitoDefaultFactHandle(long id, int identityHashCode, Object object, long recency, WorkingMemoryEntryPoint wmEntryPoint, boolean isTraitOrTraitable) { | |
+ super(id, identityHashCode, object, recency, wmEntryPoint, isTraitOrTraitable); | |
+ } | |
+ | |
+ public KogitoDefaultFactHandle(long id, int identityHashCode, Object object, long recency, EntryPointId entryPointId, boolean isTraitOrTraitable) { | |
+ super(id, identityHashCode, object, recency, entryPointId, isTraitOrTraitable); | |
+ } | |
+ | |
+ public KogitoDefaultFactHandle(long id, int identityHashCode, Object object, long recency, EntryPointId entryPointId, TraitTypeEnum traitType) { | |
+ super(id, identityHashCode, object, recency, entryPointId, traitType); | |
+ } | |
+ | |
+ public KogitoDefaultFactHandle(long id, String wmEntryPointId, int identityHashCode, int objectHashCode, long recency, Object object) { | |
+ super(id, wmEntryPointId, identityHashCode, objectHashCode, recency, object); | |
+ } | |
+ | |
+ private DataHandle dataHandle; | |
+ | |
+ @Override | |
+ public DataHandle getDataHandle() { | |
+ return dataHandle; | |
+ } | |
+ | |
+ @Override | |
+ public void setDataHandle(DataHandle dataHandle) { | |
+ this.dataHandle = dataHandle; | |
+ } | |
+} | |
Index: drools/drools-core/src/main/java/org/kogito/KogitoFactHandleFactory.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- drools/drools-core/src/main/java/org/kogito/KogitoFactHandleFactory.java (date 1594820033381) | |
+++ drools/drools-core/src/main/java/org/kogito/KogitoFactHandleFactory.java (date 1594820033381) | |
@@ -0,0 +1,15 @@ | |
+package org.kogito; | |
+ | |
+import org.drools.core.WorkingMemoryEntryPoint; | |
+import org.drools.core.common.InternalFactHandle; | |
+import org.drools.core.common.InternalWorkingMemory; | |
+import org.drools.core.reteoo.ObjectTypeConf; | |
+import org.drools.core.reteoo.ReteooFactHandleFactory; | |
+ | |
+public class KogitoFactHandleFactory extends ReteooFactHandleFactory { | |
+ | |
+ @Override | |
+ public InternalFactHandle newFactHandle(long id, Object object, long recency, ObjectTypeConf conf, InternalWorkingMemory workingMemory, WorkingMemoryEntryPoint wmEntryPoint) { | |
+ return new KogitoDefaultFactHandle(id, object, recency, wmEntryPoint); | |
+ } | |
+} | |
\ No newline at end of file | |
Index: drools/drools-core/src/main/java/org/kogito/KogitoKieComponentFactory.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- drools/drools-core/src/main/java/org/kogito/KogitoKieComponentFactory.java (date 1594820284253) | |
+++ drools/drools-core/src/main/java/org/kogito/KogitoKieComponentFactory.java (date 1594820284253) | |
@@ -0,0 +1,12 @@ | |
+package org.kogito; | |
+ | |
+import org.drools.core.reteoo.KieComponentFactory; | |
+import org.drools.core.spi.FactHandleFactory; | |
+ | |
+public class KogitoKieComponentFactory extends KieComponentFactory { | |
+ | |
+ @Override | |
+ public FactHandleFactory getFactHandleFactoryService() { | |
+ return new KogitoFactHandleFactory(); | |
+ } | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment