Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KOGITO-4502] GET task id API to return task info, not only the input model #1217

Merged
merged 1 commit into from
Apr 26, 2021

Conversation

fjtirado
Copy link
Contributor

@fjtirado fjtirado commented Apr 12, 2021

Changes GET task is and GET tasks API to return same data.
The new structure contains both input and output parametes, not just input.
Merge with https://github.com/kiegroup/kogito-examples/pull/652

Relevant generated code

public class Approvals_TaskModelFactory {

    public static TaskModel from(org.kie.kogito.process.WorkItem workItem) {
        switch(workItem.getNodeId()) {
            case "2":
                return Approvals_2_TaskModel.from(workItem);
            case "1":
                return Approvals_1_TaskModel.from(workItem);
            default:
                throw new IllegalArgumentException("Invalid task name for work item " + workItem);
        }
    }
}

And


public class Approvals_1_TaskModel implements TaskModel<org.acme.travels.Approvals_1_TaskInput, org.acme.travels.Approvals_1_TaskOutput> {

    private String id;

    private String name;

    private int state;

    private String phase;

    private String phaseStatus;

    private org.acme.travels.Approvals_1_TaskInput parameters;

    private org.acme.travels.Approvals_1_TaskOutput results;

    public void setId(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public String getPhase() {
        return phase;
    }

    public void setPhase(String phase) {
        this.phase = phase;
    }

    public String getPhaseStatus() {
        return phaseStatus;
    }

    public void setPhaseStatus(String phaseStatus) {
        this.phaseStatus = phaseStatus;
    }

    public org.acme.travels.Approvals_1_TaskInput getParameters() {
        return parameters;
    }

    public void setParameters(org.acme.travels.Approvals_1_TaskInput parameters) {
        this.parameters = parameters;
    }

    public org.acme.travels.Approvals_1_TaskOutput getResults() {
        return results;
    }

    public void setParams(org.acme.travels.Approvals_1_TaskOutput results) {
        this.results = results;
    }

    public static org.acme.travels.Approvals_1_TaskModel from(org.kie.kogito.process.WorkItem workItem) {
        org.acme.travels.Approvals_1_TaskModel taskModel = new org.acme.travels.Approvals_1_TaskModel();
        taskModel.id = workItem.getId();
        taskModel.name = workItem.getName();
        taskModel.state = workItem.getState();
        taskModel.phaseStatus = workItem.getPhaseStatus();
        taskModel.phase = workItem.getPhase();
        taskModel.parameters = org.acme.travels.Approvals_1_TaskInput.fromMap(workItem.getParameters());
        taskModel.results = org.acme.travels.Approvals_1_TaskOutput.fromMap(workItem.getResults());
        return taskModel;
    }
}

And

  @GET
   @Path("/{id}/tasks")
   @Produces(MediaType.APPLICATION_JSON)
   public List<TaskModel> getTasks_approvals(@PathParam("id") String id, @QueryParam("user") final String user, @QueryParam("group") final List<String> groups) {
       return process.instances().findById(id, ProcessInstanceReadMode.READ_ONLY).map(pi -> pi.workItems(Policies.of(user, groups)).stream().map(org.acme.travels.Approvals_TaskModelFactory::from).collect(Collectors.toList())).orElseThrow(NotFoundException::new);
   }

And


    @GET
    @Path("/{id}/firstLineApproval/{taskId}")
    @Produces(MediaType.APPLICATION_JSON)
    public org.acme.travels.Approvals_1_TaskModel getTask_firstLineApproval_0(@PathParam("id") String id, @PathParam("taskId") String taskId, @QueryParam("user") final String user, @QueryParam("group") final List<String> groups) {
        return process.instances().findById(id, ProcessInstanceReadMode.READ_ONLY).map(pi -> org.acme.travels.Approvals_1_TaskModel.from(pi.workItem(taskId, Policies.of(user, groups)))).orElseThrow(NotFoundException::new);
    }

@kie-ci
Copy link
Contributor

kie-ci commented Apr 12, 2021

The Linux check has failed. Please check the logs.

@fjtirado fjtirado force-pushed the KOGITO-4502 branch 2 times, most recently from 1340607 to 5d5a26b Compare April 13, 2021 10:03
@fjtirado
Copy link
Contributor Author

fjtirado commented Apr 13, 2021

And here is the generated payload

[
    {
        "id": "92160e2d-1c4b-4453-bf85-88cb4c412c5f",
        "name": "firstLineApproval",
        "state": 0,
        "phase": "active",
        "phaseStatus": "Ready",
        "parameters": {
            "traveller": {
                "firstName": "John",
                "lastName": "Doe",
                "email": "[email protected]",
                "nationality": "American",
                "address": {
                    "street": "main street",
                    "city": "Boston",
                    "zipCode": "10005",
                    "country": "US"
                }
            }
        },
        "results": {
            "approved": null
        }
    }
]

@fjtirado fjtirado marked this pull request as ready for review April 13, 2021 10:43
@mbiarnes
Copy link
Contributor

Jenkins retest this

@kie-ci
Copy link
Contributor

kie-ci commented Apr 13, 2021

The Linux check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Apr 13, 2021

The Linux check has failed. Please check the logs.

@fjtirado fjtirado force-pushed the KOGITO-4502 branch 2 times, most recently from 6557875 to e8444a4 Compare April 13, 2021 17:26
@kie-ci
Copy link
Contributor

kie-ci commented Apr 13, 2021

The Linux check has failed. Please check the logs.

@fjtirado fjtirado force-pushed the KOGITO-4502 branch 2 times, most recently from bfacf14 to 6250b6f Compare April 14, 2021 09:58
@kie-ci
Copy link
Contributor

kie-ci commented Apr 14, 2021

The Linux check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Apr 14, 2021

The Linux check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Apr 15, 2021

The Linux check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Apr 15, 2021

The Linux check has failed. Please check the logs.

@fjtirado
Copy link
Contributor Author

jenkins retest this

@kie-ci
Copy link
Contributor

kie-ci commented Apr 16, 2021

The Linux check has failed. Please check the logs.

@fjtirado
Copy link
Contributor Author

jenkins retest this

@kie-ci
Copy link
Contributor

kie-ci commented Apr 21, 2021

The Linux check has failed. Please check the logs.

@cristianonicolai
Copy link
Contributor

jenkins please retest this

@kie-ci
Copy link
Contributor

kie-ci commented Apr 22, 2021

The Linux check has failed. Please check the logs.

@fjtirado
Copy link
Contributor Author

jenkins retest this

@kie-ci
Copy link
Contributor

kie-ci commented Apr 22, 2021

The Linux check has failed. Please check the logs.

@fjtirado
Copy link
Contributor Author

jenkins retest this

1 similar comment
@fjtirado
Copy link
Contributor Author

jenkins retest this

@kie-ci
Copy link
Contributor

kie-ci commented Apr 22, 2021

The Linux check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Apr 23, 2021

The Linux check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Apr 23, 2021

The Linux check has failed. Please check the logs.

@cristianonicolai
Copy link
Contributor

jenkins please retest this

@kie-ci
Copy link
Contributor

kie-ci commented Apr 23, 2021

The Linux check has failed. Please check the logs.

@cristianonicolai
Copy link
Contributor

jenkins please retest this

@kie-ci
Copy link
Contributor

kie-ci commented Apr 23, 2021

The Linux check has failed. Please check the logs.

@cristianonicolai
Copy link
Contributor

jenkins please retest this

@kie-ci
Copy link
Contributor

kie-ci commented Apr 24, 2021

The Linux check has failed. Please check the logs.

@cristianonicolai
Copy link
Contributor

jenkins please retest this

@kie-ci
Copy link
Contributor

kie-ci commented Apr 25, 2021

The Linux check has failed. Please check the logs.

@fjtirado
Copy link
Contributor Author

jenkins retest this

@sonarqubecloud
Copy link

@kie-ci
Copy link
Contributor

kie-ci commented Apr 26, 2021

The Linux check is successful.

@fjtirado
Copy link
Contributor Author

fjtirado commented Apr 26, 2021

@kiegroup/gatekeepers please merge this (finally green, the sonar cloud is caused by JBPMMessages, which I try to ignore unsuccesfully)

@MarianMacik MarianMacik merged commit 36b092c into apache:master Apr 26, 2021
ricardozanini added a commit to ricardozanini/kogito-runtimes that referenced this pull request May 20, 2024
tiagobento pushed a commit that referenced this pull request May 22, 2024
* Fix kie-issues #1217 - Replace quay.io with docker.io

Signed-off-by: Ricardo Zanini <[email protected]>

* Replace outdated image with bananas 🍌

Signed-off-by: Ricardo Zanini <[email protected]>

---------

Signed-off-by: Ricardo Zanini <[email protected]>
rgdoliveira added a commit to rgdoliveira/kogito-runtimes that referenced this pull request Jun 10, 2024
)

* Fix kie-issues apache#1217 - Replace quay.io with docker.io

Signed-off-by: Ricardo Zanini <[email protected]>

* Replace outdated image with bananas 🍌

Signed-off-by: Ricardo Zanini <[email protected]>

---------

Signed-off-by: Ricardo Zanini <[email protected]>
# Conflicts:
#	.ci/jenkins/Jenkinsfile.setup-branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants