Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.kie.kogito.examples.OrderItemsResource Maven / Gradle / Ivy
/*
* Copyright 2021 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.kie.kogito.examples;
import java.net.URI;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import org.jbpm.util.JsonSchemaUtil;
import org.kie.kogito.process.Process;
import org.kie.kogito.process.ProcessInstance;
import org.kie.kogito.process.WorkItem;
import org.kie.kogito.process.ProcessService;
import org.kie.kogito.process.workitem.Attachment;
import org.kie.kogito.process.workitem.AttachmentInfo;
import org.kie.kogito.process.workitem.Comment;
import org.kie.kogito.process.workitem.Policies;
import org.kie.kogito.process.workitem.TaskModel;
import org.kie.kogito.auth.IdentityProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;
import org.springframework.http.ResponseEntity;
import org.springframework.http.HttpStatus;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
@RestController
@RequestMapping("/orderItems")
@org.springframework.stereotype.Component()
public class OrderItemsResource {
@org.springframework.beans.factory.annotation.Autowired()
@org.springframework.beans.factory.annotation.Qualifier("demo.orderItems")
Process process;
@Autowired
ProcessService processService;
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public List getResources_orderItems() {
return processService.getProcessInstanceOutput(process);
}
@GetMapping(value = "/schema", produces = MediaType.APPLICATION_JSON_VALUE)
public Map getResourceSchema_orderItems() {
return JsonSchemaUtil.load(this.getClass().getClassLoader(), process.id());
}
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public OrderItemsModelOutput getResource_orderItems(@PathVariable("id") String id) {
return processService.findById(process, id).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public OrderItemsModelOutput deleteResource_orderItems(@PathVariable("id") final String id) {
return processService.delete(process, id).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@PutMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public OrderItemsModelOutput updateModel_orderItems(@PathVariable("id") String id, @RequestBody(required = false) OrderItemsModel resource) {
return processService.update(process, id, resource).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@GetMapping(value = "/{id}/tasks", produces = MediaType.APPLICATION_JSON_VALUE)
public List getTasks_orderItems(@PathVariable("id") String id, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups) {
return processService.getTasks(process, id, user, groups).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND)).stream().map(org.kie.kogito.examples.OrderItems_TaskModelFactory::from).collect(Collectors.toList());
}
@PostMapping(value = "/{id}/Verify_order/{taskId}/phases/{phase}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public OrderItemsModelOutput completeTask_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @PathVariable("phase") final String phase, @RequestParam("user") final String user, @RequestParam("group") final List groups, @RequestBody(required = false) final org.kie.kogito.examples.OrderItems_4_TaskOutput model) {
return processService.completeTask(process, id, taskId, phase, user, groups, model).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@PutMapping(value = "/{id}/Verify_order/{taskId}", consumes = MediaType.APPLICATION_JSON_VALUE)
public org.kie.kogito.examples.OrderItems_4_TaskOutput saveTask_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups, @RequestBody(required = false) final org.kie.kogito.examples.OrderItems_4_TaskOutput model) {
return processService.saveTask(process, id, taskId, user, groups, model, org.kie.kogito.examples.OrderItems_4_TaskOutput::fromMap).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@PostMapping(value = "/{id}/Verify_order/{taskId}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public OrderItemsModelOutput taskTransition_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @RequestParam(value = "phase", required = false, defaultValue = "complete") final String phase, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups, @RequestBody(required = false) final org.kie.kogito.examples.OrderItems_4_TaskOutput model) {
return processService.taskTransition(process, id, taskId, phase, user, groups, model).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@GetMapping(value = "/{id}/Verify_order/{taskId}", produces = MediaType.APPLICATION_JSON_VALUE)
public org.kie.kogito.examples.OrderItems_4_TaskModel getTask_Verify_order_0(@PathVariable("id") String id, @PathVariable("taskId") String taskId, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups) {
return processService.getTask(process, id, taskId, user, groups, org.kie.kogito.examples.OrderItems_4_TaskModel::from).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@DeleteMapping(value = "/{id}/Verify_order/{taskId}", produces = MediaType.APPLICATION_JSON_VALUE)
public OrderItemsModelOutput abortTask_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @RequestParam(value = "phase", required = false, defaultValue = "abort") final String phase, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups) {
return processService.abortTask(process, id, taskId, phase, user, groups).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@GetMapping(value = "Verify_order/schema", produces = MediaType.APPLICATION_JSON_VALUE)
public Map getSchema_Verify_order_0() {
return JsonSchemaUtil.load(this.getClass().getClassLoader(), process.id(), "Verify_order");
}
@GetMapping(value = "/{id}/Verify_order/{taskId}/schema", produces = MediaType.APPLICATION_JSON_VALUE)
public Map getSchemaAndPhases_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups) {
return processService.getSchemaAndPhases(process, id, taskId, "Verify_order", user, groups);
}
@PostMapping(value = "/{id}/Verify_order/{taskId}/comments", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity addComment_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups, @RequestBody String commentInfo, UriComponentsBuilder uriComponentsBuilder) {
return processService.addComment(process, id, taskId, user, groups, commentInfo).map(comment -> ResponseEntity.created(uriComponentsBuilder.path("/orderItems/{id}/Verify_order/{taskId}/comments/{commentId}").buildAndExpand(id, taskId, comment.getId().toString()).toUri()).body(comment)).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@PutMapping(value = "/{id}/Verify_order/{taskId}/comments/{commentId}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.TEXT_PLAIN_VALUE)
public Comment updateComment_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @PathVariable("commentId") final String commentId, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups, @RequestBody String comment) {
return processService.updateComment(process, id, taskId, commentId, user, groups, comment).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@DeleteMapping(value = "/{id}/Verify_order/{taskId}/comments/{commentId}")
public ResponseEntity deleteComment_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @PathVariable("commentId") final String commentId, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups) {
return processService.deleteComment(process, id, taskId, commentId, user, groups).map(removed -> (removed ? ResponseEntity.ok().build() : ResponseEntity.notFound().build())).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@PostMapping(value = "/{id}/Verify_order/{taskId}/attachments", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity addAttachment_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups, @RequestBody AttachmentInfo attachmentInfo, UriComponentsBuilder uriComponentsBuilder) {
return processService.addAttachment(process, id, taskId, user, groups, attachmentInfo).map(attachment -> ResponseEntity.created(uriComponentsBuilder.path("/orderItems/{id}/Verify_order/{taskId}/attachments/{attachmentId}").buildAndExpand(id, taskId, attachment.getId()).toUri()).body(attachment)).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@PutMapping(value = "/{id}/Verify_order/{taskId}/attachments/{attachmentId}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public Attachment updateAttachment_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @PathVariable("attachmentId") final String attachmentId, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups, @RequestBody AttachmentInfo attachment) {
return processService.updateAttachment(process, id, taskId, attachmentId, user, groups, attachment).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@DeleteMapping(value = "/{id}/Verify_order/{taskId}/attachments/{attachmentId}")
public ResponseEntity deleteAttachment_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @PathVariable("attachmentId") final String attachmentId, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups) {
return processService.deleteAttachment(process, id, taskId, attachmentId, user, groups).map(removed -> (removed ? ResponseEntity.ok() : ResponseEntity.notFound()).build()).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@GetMapping(value = "/{id}/Verify_order/{taskId}/attachments/{attachmentId}", produces = MediaType.APPLICATION_JSON_VALUE)
public Attachment getAttachment_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @PathVariable("attachmentId") final String attachmentId, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups) {
return processService.getAttachment(process, id, taskId, attachmentId, user, groups).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Attachment " + attachmentId + " not found"));
}
@GetMapping(value = "/{id}/Verify_order/{taskId}/attachments", produces = MediaType.APPLICATION_JSON_VALUE)
public Collection getAttachments_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @RequestParam(value = "user") final String user, @RequestParam(value = "group") final List groups) {
return processService.getAttachments(process, id, taskId, user, groups).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
@GetMapping(value = "/{id}/Verify_order/{taskId}/comments/{commentId}", produces = MediaType.APPLICATION_JSON_VALUE)
public Comment getComment_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @PathVariable("commentId") final String commentId, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups) {
return processService.getComment(process, id, taskId, commentId, user, groups).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Comment " + commentId + " not found"));
}
@GetMapping(value = "/{id}/Verify_order/{taskId}/comments", produces = MediaType.APPLICATION_JSON_VALUE)
public Collection getComments_Verify_order_0(@PathVariable("id") final String id, @PathVariable("taskId") final String taskId, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "group", required = false) final List groups) {
return processService.getComments(process, id, taskId, user, groups).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
}