ERVU-226: add start/end dates in ConfigExecuteBtn.ts
This commit is contained in:
parent
fa78bf4855
commit
dc67e681dd
4 changed files with 83 additions and 19 deletions
48
backend/src/main/java/dto/ConfigExecuteRequest.java
Normal file
48
backend/src/main/java/dto/ConfigExecuteRequest.java
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
package dto;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Alexandr Shalaginov
|
||||||
|
*/
|
||||||
|
public class ConfigExecuteRequest {
|
||||||
|
public List<String> ids;
|
||||||
|
|
||||||
|
public LocalDate startDate;
|
||||||
|
|
||||||
|
public LocalDate endDate;
|
||||||
|
|
||||||
|
public List<String> getIds() {
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIds(List<String> ids) {
|
||||||
|
this.ids = ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getStartDate() {
|
||||||
|
return startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartDate(LocalDate startDate) {
|
||||||
|
this.startDate = startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getEndDate() {
|
||||||
|
return endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndDate(LocalDate endDate) {
|
||||||
|
this.endDate = endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ConfigExecuteRequest{" +
|
||||||
|
"ids=" + ids +
|
||||||
|
", startDate=" + startDate +
|
||||||
|
", endDate=" + endDate +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package rpc;
|
package rpc;
|
||||||
|
|
||||||
import java.util.List;
|
import dto.ConfigExecuteRequest;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import service.ConfigExecutorService;
|
import service.ConfigExecutorService;
|
||||||
|
|
||||||
|
|
@ -22,7 +21,7 @@ public class ConfigExecutorRpcService extends Behavior {
|
||||||
}
|
}
|
||||||
|
|
||||||
@RpcCall
|
@RpcCall
|
||||||
public String callConfigExecutor(String methodPath, List<String> ids) {
|
public String callConfigExecutor(String methodPath, ConfigExecuteRequest configExecuteRequest) {
|
||||||
return configExecutorService.call(methodPath, ids);
|
return configExecutorService.call(methodPath, configExecuteRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import dto.ConfigExecuteRequest;
|
||||||
import dto.ExportDataRequest;
|
import dto.ExportDataRequest;
|
||||||
import model.FileModel;
|
import model.FileModel;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
@ -63,19 +63,19 @@ public class ConfigExecutorService {
|
||||||
return fileModel;
|
return fileModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String call(String methodPath, List<String> ids) {
|
public String call(String methodPath, ConfigExecuteRequest configExecuteRequest) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
HttpEntity<List<String>> entity = new HttpEntity<>(ids, headers);
|
HttpEntity<ConfigExecuteRequest> entity = new HttpEntity<>(configExecuteRequest, headers);
|
||||||
LOGGER.info("Starts call config executor service with method: {}, for ids: {}", methodPath,
|
LOGGER.info("Starts call config executor service with method: {}, for request: {}", methodPath,
|
||||||
ids
|
configExecuteRequest
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
ResponseEntity<String> response = restTemplate.exchange(url.concat(methodPath),
|
ResponseEntity<String> response = restTemplate.exchange(url.concat(methodPath),
|
||||||
HttpMethod.POST, entity, String.class
|
HttpMethod.POST, entity, String.class
|
||||||
);
|
);
|
||||||
LOGGER.info("Method: {}, executed with status: {}, for ids:{}", methodPath,
|
LOGGER.info("Method: {}, executed with status: {}, for request:{}", methodPath,
|
||||||
response.getStatusCode().value(), ids
|
response.getStatusCode().value(), configExecuteRequest
|
||||||
);
|
);
|
||||||
return response.getBody();
|
return response.getBody();
|
||||||
}
|
}
|
||||||
|
|
@ -94,15 +94,15 @@ public class ConfigExecutorService {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
String.format("Failed call config executor service method: %s for ids: %s with error",
|
String.format("Failed call config executor service method: %s for request: %s with error",
|
||||||
methodPath, ids
|
methodPath, configExecuteRequest
|
||||||
), e);
|
), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
String.format("Failed call config executor service method: %s for ids: %s with error",
|
String.format("Failed call config executor service method: %s for request: %s with error",
|
||||||
methodPath, ids
|
methodPath, configExecuteRequest
|
||||||
), e);
|
), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,14 @@
|
||||||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef} from "@angular/core";
|
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef} from "@angular/core";
|
||||||
import {AbstractButton, MessagesService, NotNull, ObjectRef, TextArea} from "@webbpm/base-package";
|
import {
|
||||||
|
AbstractButton,
|
||||||
|
DateTimePicker,
|
||||||
|
MessagesService,
|
||||||
|
NotNull,
|
||||||
|
ObjectRef,
|
||||||
|
TextArea
|
||||||
|
} from "@webbpm/base-package";
|
||||||
import {ConfigExecutorRpcService} from "../generated/rpc/ConfigExecutorRpcService";
|
import {ConfigExecutorRpcService} from "../generated/rpc/ConfigExecutorRpcService";
|
||||||
|
import {ConfigExecuteRequest} from "../generated/dto/ConfigExecuteRequest";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: a.petrov
|
* @author: a.petrov
|
||||||
|
|
@ -16,6 +24,10 @@ export class ConfigExecuteBtn extends AbstractButton {
|
||||||
@ObjectRef()
|
@ObjectRef()
|
||||||
@NotNull()
|
@NotNull()
|
||||||
public ervuIdField: TextArea;
|
public ervuIdField: TextArea;
|
||||||
|
@ObjectRef()
|
||||||
|
public startDate: DateTimePicker;
|
||||||
|
@ObjectRef()
|
||||||
|
public endDate: DateTimePicker;
|
||||||
@NotNull()
|
@NotNull()
|
||||||
public methodPath: string;
|
public methodPath: string;
|
||||||
private script: ConfigExecutorRpcService;
|
private script: ConfigExecutorRpcService;
|
||||||
|
|
@ -32,13 +44,18 @@ export class ConfigExecuteBtn extends AbstractButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
doClickActions(): Promise<any> {
|
doClickActions(): Promise<any> {
|
||||||
const value = this.ervuIdField.getValue();
|
const value: string = this.ervuIdField.getValue();
|
||||||
if (value && this.methodPath.trim().length !== 0) {
|
if (value && this.methodPath.trim().length !== 0) {
|
||||||
const ids = value.replace(/[{}]/g, '')
|
const ids: string[] = value.replace(/[{}]/g, '')
|
||||||
.split(',')
|
.split(',')
|
||||||
.map(id => id.trim().replace(/"/g, ''));
|
.map(id => id.trim().replace(/"/g, ''));
|
||||||
|
|
||||||
return this.script.callConfigExecutor(this.methodPath, ids, true)
|
let configExecuteRequest: ConfigExecuteRequest = new ConfigExecuteRequest();
|
||||||
|
configExecuteRequest.ids = ids;
|
||||||
|
configExecuteRequest.startDate = this.startDate ? this.startDate.getDateValue() : null;
|
||||||
|
configExecuteRequest.endDate = this.endDate ? this.endDate.getDateValue() : null;
|
||||||
|
|
||||||
|
return this.script.callConfigExecutor(this.methodPath, configExecuteRequest, true)
|
||||||
.then(successMsg => this.messagesService.success(successMsg))
|
.then(successMsg => this.messagesService.success(successMsg))
|
||||||
.catch(error => Promise.reject(error));
|
.catch(error => Promise.reject(error));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue