-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[incubator-kie-issues-1439] UserTask Decouple codegen and interface f…
…rom engine (#3655)
- Loading branch information
1 parent
8f828b3
commit 34389fe
Showing
348 changed files
with
9,053 additions
and
12,988 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
84 changes: 0 additions & 84 deletions
84
...on/api/src/main/java/org/kie/kogito/prediction/api/PredictionAwareHumanTaskLifeCycle.java
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
.../src/main/java/org/kie/kogito/prediction/api/PredictionAwareHumanTaskWorkItemHandler.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,65 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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.kie.kogito.prediction.api; | ||
|
||
import java.util.Optional; | ||
|
||
import org.kie.kogito.internal.process.workitem.KogitoWorkItem; | ||
import org.kie.kogito.internal.process.workitem.KogitoWorkItemHandler; | ||
import org.kie.kogito.internal.process.workitem.KogitoWorkItemManager; | ||
import org.kie.kogito.internal.process.workitem.WorkItemTransition; | ||
import org.kie.kogito.process.workitems.impl.DefaultKogitoWorkItemHandler; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class PredictionAwareHumanTaskWorkItemHandler extends DefaultKogitoWorkItemHandler { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(PredictionAwareHumanTaskWorkItemHandler.class); | ||
|
||
private PredictionService predictionService; | ||
|
||
public PredictionAwareHumanTaskWorkItemHandler(PredictionService predictionService) { | ||
this.predictionService = predictionService; | ||
} | ||
|
||
public Optional<WorkItemTransition> activateWorkItemHandler(KogitoWorkItemManager manager, KogitoWorkItemHandler handler, KogitoWorkItem workItem, WorkItemTransition transition) { | ||
PredictionOutcome outcome = predictionService.predict(workItem, workItem.getParameters()); | ||
logger.debug("Prediction service returned confidence level {} for work item {}", outcome.getConfidenceLevel(), workItem.getStringId()); | ||
|
||
if (outcome.isCertain()) { | ||
workItem.setOutputs(outcome.getData()); | ||
logger.debug("Prediction service is certain (confidence level {}) on the outputs, completing work item {}", outcome.getConfidenceLevel(), workItem.getStringId()); | ||
|
||
return Optional.of(this.newTransition("skip", workItem.getPhaseStatus(), outcome.getData())); | ||
} else if (outcome.isPresent()) { | ||
logger.debug("Prediction service is NOT certain (confidence level {}) on the outputs, setting recommended outputs on work item {}", | ||
outcome.getConfidenceLevel(), | ||
workItem.getStringId()); | ||
workItem.setOutputs(outcome.getData()); | ||
} | ||
return Optional.empty(); | ||
} | ||
|
||
public Optional<WorkItemTransition> completeWorkItemHandler(KogitoWorkItemManager manager, KogitoWorkItemHandler handler, KogitoWorkItem workItem, WorkItemTransition transition) { | ||
// upon actual transition train the data if it's completion phase | ||
predictionService.train(workItem, workItem.getParameters(), transition.data()); | ||
return Optional.empty(); | ||
} | ||
|
||
} |
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
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
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.