Skip to content

Commit

Permalink
#48 add request input object
Browse files Browse the repository at this point in the history
  • Loading branch information
gavin2lee committed May 13, 2021
1 parent a6d91cf commit ceb6592
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.webank.taskman.service;

import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -22,6 +25,7 @@
import com.webank.taskman.mapper.RequestInfoMapper;
import com.webank.taskman.mapper.RequestTemplateMapper;
import com.webank.taskman.mapper.TaskTemplateMapper;
import com.webank.taskman.support.platform.dto.CreateTaskRequestInputDto;
import com.webank.taskman.support.platform.dto.PlatformPluginRequestDto;
import com.webank.taskman.support.platform.dto.TaskFormMetaDto;

Expand All @@ -46,6 +50,10 @@ public class TaskmanPluginServiceManagementService {

private ObjectMapper objectMapper = new ObjectMapper();

/**
*
* @param requestDto
*/
public void createTask(PlatformPluginRequestDto requestDto) {
// TODO
log.info("About to create task with request:{}", requestDto);
Expand All @@ -56,15 +64,28 @@ public void createTask(PlatformPluginRequestDto requestDto) {
if (requestDto.getAllowedOptions() != null && !requestDto.getAllowedOptions().isEmpty()) {
String allowedOptions = convertObjectToJson(requestDto.getAllowedOptions());
taskInfo.setAllowedOptions(allowedOptions);
}else{
String allowedOptions = "[\"deny\",\"approval\"]";
taskInfo.setAllowedOptions(allowedOptions);
}

taskInfo.setUpdatedBy(AuthenticationContextHolder.getCurrentUsername());
taskInfo.setUpdatedTime(new Date());
taskInfo.setCreatedBy(AuthenticationContextHolder.getCurrentUsername());
taskInfo.setCreatedTime(new Date());

CreateTaskRequestInputDto createTaskRequestInputDto = tryPickoutPlatformRequestObject(requestDto);


taskInfoService.save(taskInfo);
}

/**
*
* @param procInstId
* @param nodeDefId
* @return
*/
public TaskFormMetaDto fetchTaskCreationMeta(String procInstId, String nodeDefId) {
log.info("try to fetch task creation meta for process intance:{} and node:{}", procInstId, nodeDefId);
RequestInfo requestInfoCriteria = new RequestInfo();
Expand Down Expand Up @@ -102,10 +123,20 @@ public TaskFormMetaDto fetchTaskCreationMeta(String procInstId, String nodeDefId
formTemplateCriteria.setDelFlag(RecordDeleteFlag.NotDeleted.ordinal());
formTemplateCriteria.setTempId(taskTemplate.getId());
// TODO



TaskFormMetaDto taskFormMetaDto = buildTaskFormMetaDto();
return taskFormMetaDto;
}

private CreateTaskRequestInputDto tryPickoutPlatformRequestObject(PlatformPluginRequestDto requestDto){
List<CreateTaskRequestInputDto> inputs = requestDto.getInputs();
if(inputs == null || inputs.isEmpty()){
return null;
}

return inputs.get(0);
}

private TaskFormMetaDto buildTaskFormMetaDto() {
// TODO
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.webank.taskman.support.platform.dto;

public class CreateTaskRequestInputDto {
private String callbackUrl;
private String taskName;
private String taskDescription;
private String roleName;
private String callbackParameter;
private String reporter;
private Integer overTime;

private String taskFormInput;

//#162
private String procInstId;


public String getCallbackUrl() {
return callbackUrl;
}

public void setCallbackUrl(String callbackUrl) {
this.callbackUrl = callbackUrl;
}

public String getTaskName() {
return taskName;
}

public void setTaskName(String taskName) {
this.taskName = taskName;
}

public String getRoleName() {
return roleName;
}

public void setRoleName(String roleName) {
this.roleName = roleName;
}

public String getCallbackParameter() {
return callbackParameter;
}

public void setCallbackParameter(String callbackParameter) {
this.callbackParameter = callbackParameter;
}

public String getTaskDescription() {
return taskDescription;
}

public void setTaskDescription(String taskDescription) {
this.taskDescription = taskDescription;
}

public String getReporter() {
return reporter;
}

public void setReporter(String reporter) {
this.reporter = reporter;
}

public Integer getOverTime() { return overTime;}

public void setOverTime(Integer overTime) { this.overTime = overTime; }

public String getProcInstId() {
return procInstId;
}

public void setProcInstId(String procInstId) {
this.procInstId = procInstId;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public class PlatformPluginRequestDto {
private String requestId;
private String dueDate;
private List<String> allowedOptions;
private List<Object> inputs;
private List<CreateTaskRequestInputDto> inputs;

public PlatformPluginRequestDto withInputs(List<Object> inputs) {
public PlatformPluginRequestDto withInputs(List<CreateTaskRequestInputDto> inputs) {
this.inputs = inputs;
return this;
}
Expand Down Expand Up @@ -43,11 +43,11 @@ public void setRequestId(String requestId) {
this.requestId = requestId;
}

public List<Object> getInputs() {
public List<CreateTaskRequestInputDto> getInputs() {
return inputs;
}

public void setInputs(List<Object> inputs) {
public void setInputs(List<CreateTaskRequestInputDto> inputs) {
this.inputs = inputs;
}

Expand Down

0 comments on commit ceb6592

Please sign in to comment.