Socket Client UI 기본 골격 작성
This commit is contained in:
+27
-6
@@ -3,12 +3,17 @@ package com.eactive.testmaster.client.controller;
|
||||
import com.eactive.testmaster.client.dto.ApiCollectionDTO;
|
||||
import com.eactive.testmaster.client.dto.ApiRequestDTO;
|
||||
import com.eactive.testmaster.client.entity.ApiCollection;
|
||||
import com.eactive.testmaster.client.entity.ApiLayout;
|
||||
import com.eactive.testmaster.client.entity.ApiRequestInfo;
|
||||
import com.eactive.testmaster.client.mapper.ApiLayoutMapper;
|
||||
import com.eactive.testmaster.client.mapper.ApiRequestMapper;
|
||||
import com.eactive.testmaster.client.service.ApiLayoutMgmtService;
|
||||
import com.eactive.testmaster.client.service.ApiRequestMgmtService;
|
||||
import com.eactive.testmaster.common.util.SecurityUtil;
|
||||
import com.eactive.testmaster.user.entity.StaffUser;
|
||||
import com.eactive.testmaster.user.service.UserService;
|
||||
import javax.transaction.Transactional;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -20,13 +25,19 @@ public class ApiRequestMgmtController {
|
||||
private static final String SUCCESS = "success";
|
||||
private final ApiRequestMgmtService apiRequestMgmtService;
|
||||
|
||||
private final ApiLayoutMgmtService apiLayoutMgmtService;
|
||||
|
||||
private final ApiRequestMapper apiRequestMapper;
|
||||
|
||||
private final ApiLayoutMapper apiLayoutMapper;
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
public ApiRequestMgmtController(ApiRequestMgmtService apiRequestMgmtService, ApiRequestMapper apiRequestMapper, UserService userService) {
|
||||
public ApiRequestMgmtController(ApiRequestMgmtService apiRequestMgmtService, ApiLayoutMgmtService apiLayoutMgmtService, ApiRequestMapper apiRequestMapper, ApiLayoutMapper apiLayoutMapper, UserService userService) {
|
||||
this.apiRequestMgmtService = apiRequestMgmtService;
|
||||
this.apiLayoutMgmtService = apiLayoutMgmtService;
|
||||
this.apiRequestMapper = apiRequestMapper;
|
||||
this.apiLayoutMapper = apiLayoutMapper;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@@ -39,7 +50,7 @@ public class ApiRequestMgmtController {
|
||||
|
||||
@PostMapping("/mgmt/collections/create.do")
|
||||
public ResponseEntity<String> createApiCollection(
|
||||
@RequestBody ApiCollectionDTO dto) {
|
||||
@RequestBody ApiCollectionDTO dto) {
|
||||
|
||||
ApiCollection collection = apiRequestMapper.map(dto);
|
||||
StaffUser user = userService.findByEsntlId(SecurityUtil.getCurrentUserEsntlId());
|
||||
@@ -64,18 +75,28 @@ public class ApiRequestMgmtController {
|
||||
}
|
||||
|
||||
@PostMapping("/mgmt/collections/{id}/apis/save.do")
|
||||
public ResponseEntity<String> addApiToCollection(@PathVariable(name = "id") String id,
|
||||
@RequestBody ApiRequestDTO dto) {
|
||||
@Transactional
|
||||
public ResponseEntity<String> addApiToCollection(@PathVariable(name = "id") String id, @RequestBody ApiRequestDTO dto) {
|
||||
ApiRequestInfo apiRequestInfo = apiRequestMapper.map(dto);
|
||||
StaffUser user = userService.findByEsntlId(SecurityUtil.getCurrentUserEsntlId());
|
||||
apiRequestInfo.setOwner(user);
|
||||
String apiId = apiRequestMgmtService.saveApiToCollection(id, apiRequestInfo);
|
||||
|
||||
if (dto.getLayout() != null) {
|
||||
dto.getLayout().setApiRequestId(apiId);
|
||||
apiLayoutMgmtService.saveLayout(apiLayoutMapper.map(dto.getLayout()));
|
||||
}
|
||||
return ResponseEntity.ok(apiId);
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/mgmt/collections/{id}/apis/delete.do")
|
||||
public ResponseEntity<String> removeApiFromCollection(@PathVariable(name = "id") String id,
|
||||
@RequestBody ApiRequestDTO dto) {
|
||||
@Transactional
|
||||
public ResponseEntity<String> removeApiFromCollection(@PathVariable(name = "id") String id, @RequestBody ApiRequestDTO dto) {
|
||||
ApiLayout layout = apiLayoutMgmtService.findLayoutByApiRequest(dto.getId());
|
||||
if (layout != null) {
|
||||
apiLayoutMgmtService.deleteLayout(layout.getId());
|
||||
}
|
||||
apiRequestMgmtService.removeApiFromCollection(id, dto.getId());
|
||||
return ResponseEntity.ok(SUCCESS);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
package com.eactive.testmaster.client.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ApiLayoutDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@JsonProperty("id")
|
||||
private String id;
|
||||
|
||||
@JsonProperty("APIREQUESTID")
|
||||
private String apiRequestId;
|
||||
|
||||
@JsonProperty("LOUTNAME")
|
||||
private String loutName;
|
||||
|
||||
@JsonProperty("LOUTPTRNNAME")
|
||||
private String loutPtrnName;
|
||||
|
||||
@JsonProperty("LOUTDESC")
|
||||
private String loutDesc;
|
||||
|
||||
@JsonProperty("EAIBZWKDSTCD")
|
||||
private String eaiBzwkDstCd;
|
||||
|
||||
@JsonProperty("UAPPLNAME")
|
||||
private String uApplName;
|
||||
|
||||
@JsonProperty("SYSINTFACNAME")
|
||||
private String sysIntFacName;
|
||||
|
||||
@JsonProperty("AUTHOR")
|
||||
private String author;
|
||||
|
||||
@JsonProperty("EAISEVRDSTCD")
|
||||
private String eaiSevRdStCd;
|
||||
|
||||
@JsonProperty("MODFMGTSTUSDSTCD")
|
||||
private String modfMgtStusDstCd;
|
||||
|
||||
@JsonProperty("USEYN")
|
||||
private String useYn;
|
||||
|
||||
@JsonProperty("VERINFO")
|
||||
private String verInfo;
|
||||
|
||||
@JsonProperty("layoutItems")
|
||||
List<ApiLayoutItemDTO> layoutItems = new ArrayList<>();
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getApiRequestId() {
|
||||
return apiRequestId;
|
||||
}
|
||||
|
||||
public void setApiRequestId(String apiRequestId) {
|
||||
this.apiRequestId = apiRequestId;
|
||||
}
|
||||
|
||||
public String getLoutName() {
|
||||
return loutName;
|
||||
}
|
||||
|
||||
public void setLoutName(String loutName) {
|
||||
this.loutName = loutName;
|
||||
}
|
||||
|
||||
public String getLoutPtrnName() {
|
||||
return loutPtrnName;
|
||||
}
|
||||
|
||||
public void setLoutPtrnName(String loutPtrnName) {
|
||||
this.loutPtrnName = loutPtrnName;
|
||||
}
|
||||
|
||||
public String getLoutDesc() {
|
||||
return loutDesc;
|
||||
}
|
||||
|
||||
public void setLoutDesc(String loutDesc) {
|
||||
this.loutDesc = loutDesc;
|
||||
}
|
||||
|
||||
public String getEaiBzwkDstCd() {
|
||||
return eaiBzwkDstCd;
|
||||
}
|
||||
|
||||
public void setEaiBzwkDstCd(String eaiBzwkDstCd) {
|
||||
this.eaiBzwkDstCd = eaiBzwkDstCd;
|
||||
}
|
||||
|
||||
public String getuApplName() {
|
||||
return uApplName;
|
||||
}
|
||||
|
||||
public void setuApplName(String uApplName) {
|
||||
this.uApplName = uApplName;
|
||||
}
|
||||
|
||||
public String getSysIntFacName() {
|
||||
return sysIntFacName;
|
||||
}
|
||||
|
||||
public void setSysIntFacName(String sysIntFacName) {
|
||||
this.sysIntFacName = sysIntFacName;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getEaiSevRdStCd() {
|
||||
return eaiSevRdStCd;
|
||||
}
|
||||
|
||||
public void setEaiSevRdStCd(String eaiSevRdStCd) {
|
||||
this.eaiSevRdStCd = eaiSevRdStCd;
|
||||
}
|
||||
|
||||
public String getModfMgtStusDstCd() {
|
||||
return modfMgtStusDstCd;
|
||||
}
|
||||
|
||||
public void setModfMgtStusDstCd(String modfMgtStusDstCd) {
|
||||
this.modfMgtStusDstCd = modfMgtStusDstCd;
|
||||
}
|
||||
|
||||
public String getUseYn() {
|
||||
return useYn;
|
||||
}
|
||||
|
||||
public void setUseYn(String useYn) {
|
||||
this.useYn = useYn;
|
||||
}
|
||||
|
||||
public String getVerInfo() {
|
||||
return verInfo;
|
||||
}
|
||||
|
||||
public void setVerInfo(String verInfo) {
|
||||
this.verInfo = verInfo;
|
||||
}
|
||||
|
||||
public List<ApiLayoutItemDTO> getLayoutItems() {
|
||||
return layoutItems;
|
||||
}
|
||||
|
||||
public void setLayoutItems(List<ApiLayoutItemDTO> layoutItems) {
|
||||
this.layoutItems = layoutItems;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
package com.eactive.testmaster.client.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.io.Serializable;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ApiLayoutItemDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@JsonProperty("itemId")
|
||||
private Long itemId;
|
||||
|
||||
@JsonProperty("id")
|
||||
private Long id;
|
||||
|
||||
@JsonProperty("parent")
|
||||
private Long parent;
|
||||
|
||||
@JsonProperty("level")
|
||||
private Integer level;
|
||||
|
||||
@JsonProperty("loutName")
|
||||
private String loutName;
|
||||
|
||||
@JsonProperty("loutItemSerno")
|
||||
private Integer loutItemSerno;
|
||||
|
||||
@JsonProperty("loutItemName")
|
||||
private String loutItemName;
|
||||
|
||||
@JsonProperty("loutItemDesc")
|
||||
private String loutItemDesc;
|
||||
|
||||
@JsonProperty("loutItemDepth")
|
||||
private Integer loutItemDepth;
|
||||
|
||||
@JsonProperty("loutItemType")
|
||||
private String loutItemType;
|
||||
|
||||
@JsonProperty("loutItemOccCnt")
|
||||
private String loutItemOccCnt;
|
||||
|
||||
@JsonProperty("loutItemOccRef")
|
||||
private String loutItemOccRef;
|
||||
|
||||
@JsonProperty("loutItemDataType")
|
||||
private String loutItemDataType;
|
||||
|
||||
@JsonProperty("loutItemLength")
|
||||
private Integer loutItemLength;
|
||||
|
||||
@JsonProperty("loutItemDecimal")
|
||||
private Integer loutItemDecimal;
|
||||
|
||||
@JsonProperty("loutItemDefault")
|
||||
private String loutItemDefault;
|
||||
|
||||
@JsonProperty("loutItemMaskYn")
|
||||
private String loutItemMaskYn;
|
||||
|
||||
@JsonProperty("loutItemMaskOffset")
|
||||
private Integer loutItemMaskOffset;
|
||||
|
||||
@JsonProperty("loutItemMaskLength")
|
||||
private Integer loutItemMaskLength;
|
||||
|
||||
@JsonProperty("parentLoutItemIndex")
|
||||
private Integer parentLoutItemIndex;
|
||||
|
||||
@JsonProperty("expanded")
|
||||
private Boolean expanded;
|
||||
|
||||
@JsonProperty("isLeaf")
|
||||
private Boolean isLeaf;
|
||||
|
||||
@JsonProperty("LOUTITEMPATH")
|
||||
private String loutItemPath;
|
||||
|
||||
@JsonProperty(value = "value", defaultValue = "")
|
||||
private String value;
|
||||
|
||||
public Long getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public void setItemId(Long itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(Long parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Integer getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(Integer level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getLoutName() {
|
||||
return loutName;
|
||||
}
|
||||
|
||||
public void setLoutName(String loutName) {
|
||||
this.loutName = loutName;
|
||||
}
|
||||
|
||||
public Integer getLoutItemSerno() {
|
||||
return loutItemSerno;
|
||||
}
|
||||
|
||||
public void setLoutItemSerno(Integer loutItemSerno) {
|
||||
this.loutItemSerno = loutItemSerno;
|
||||
}
|
||||
|
||||
public String getLoutItemName() {
|
||||
return loutItemName;
|
||||
}
|
||||
|
||||
public void setLoutItemName(String loutItemName) {
|
||||
this.loutItemName = loutItemName;
|
||||
}
|
||||
|
||||
public String getLoutItemDesc() {
|
||||
return loutItemDesc;
|
||||
}
|
||||
|
||||
public void setLoutItemDesc(String loutItemDesc) {
|
||||
this.loutItemDesc = loutItemDesc;
|
||||
}
|
||||
|
||||
public Integer getLoutItemDepth() {
|
||||
return loutItemDepth;
|
||||
}
|
||||
|
||||
public void setLoutItemDepth(Integer loutItemDepth) {
|
||||
this.loutItemDepth = loutItemDepth;
|
||||
}
|
||||
|
||||
public String getLoutItemType() {
|
||||
return loutItemType;
|
||||
}
|
||||
|
||||
public void setLoutItemType(String loutItemType) {
|
||||
this.loutItemType = loutItemType;
|
||||
}
|
||||
|
||||
public String getLoutItemOccCnt() {
|
||||
return loutItemOccCnt;
|
||||
}
|
||||
|
||||
public void setLoutItemOccCnt(String loutItemOccCnt) {
|
||||
this.loutItemOccCnt = loutItemOccCnt;
|
||||
}
|
||||
|
||||
public String getLoutItemOccRef() {
|
||||
return loutItemOccRef;
|
||||
}
|
||||
|
||||
public void setLoutItemOccRef(String loutItemOccRef) {
|
||||
this.loutItemOccRef = loutItemOccRef;
|
||||
}
|
||||
|
||||
public String getLoutItemDataType() {
|
||||
return loutItemDataType;
|
||||
}
|
||||
|
||||
public void setLoutItemDataType(String loutItemDataType) {
|
||||
this.loutItemDataType = loutItemDataType;
|
||||
}
|
||||
|
||||
public Integer getLoutItemLength() {
|
||||
return loutItemLength;
|
||||
}
|
||||
|
||||
public void setLoutItemLength(Integer loutItemLength) {
|
||||
this.loutItemLength = loutItemLength;
|
||||
}
|
||||
|
||||
public Integer getLoutItemDecimal() {
|
||||
return loutItemDecimal;
|
||||
}
|
||||
|
||||
public void setLoutItemDecimal(Integer loutItemDecimal) {
|
||||
this.loutItemDecimal = loutItemDecimal;
|
||||
}
|
||||
|
||||
public String getLoutItemDefault() {
|
||||
return loutItemDefault;
|
||||
}
|
||||
|
||||
public void setLoutItemDefault(String loutItemDefault) {
|
||||
this.loutItemDefault = loutItemDefault;
|
||||
}
|
||||
|
||||
public String getLoutItemMaskYn() {
|
||||
return loutItemMaskYn;
|
||||
}
|
||||
|
||||
public void setLoutItemMaskYn(String loutItemMaskYn) {
|
||||
this.loutItemMaskYn = loutItemMaskYn;
|
||||
}
|
||||
|
||||
public Integer getLoutItemMaskOffset() {
|
||||
return loutItemMaskOffset;
|
||||
}
|
||||
|
||||
public void setLoutItemMaskOffset(Integer loutItemMaskOffset) {
|
||||
this.loutItemMaskOffset = loutItemMaskOffset;
|
||||
}
|
||||
|
||||
public Integer getLoutItemMaskLength() {
|
||||
return loutItemMaskLength;
|
||||
}
|
||||
|
||||
public void setLoutItemMaskLength(Integer loutItemMaskLength) {
|
||||
this.loutItemMaskLength = loutItemMaskLength;
|
||||
}
|
||||
|
||||
public Integer getParentLoutItemIndex() {
|
||||
return parentLoutItemIndex;
|
||||
}
|
||||
|
||||
public void setParentLoutItemIndex(Integer parentLoutItemIndex) {
|
||||
this.parentLoutItemIndex = parentLoutItemIndex;
|
||||
}
|
||||
|
||||
public Boolean getExpanded() {
|
||||
return expanded;
|
||||
}
|
||||
|
||||
public void setExpanded(Boolean expanded) {
|
||||
this.expanded = expanded;
|
||||
}
|
||||
|
||||
public Boolean getLeaf() {
|
||||
return isLeaf;
|
||||
}
|
||||
|
||||
public void setLeaf(Boolean leaf) {
|
||||
isLeaf = leaf;
|
||||
}
|
||||
|
||||
public String getLoutItemPath() {
|
||||
return loutItemPath;
|
||||
}
|
||||
|
||||
public void setLoutItemPath(String loutItemPath) {
|
||||
this.loutItemPath = loutItemPath;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class ApiRequestDTO implements Serializable {
|
||||
|
||||
private String postRequestScript;
|
||||
|
||||
private long sentBytes; //estimated size of the request
|
||||
private ApiLayoutDTO layout;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
@@ -131,11 +131,11 @@ public class ApiRequestDTO implements Serializable {
|
||||
this.postRequestScript = postRequestScript;
|
||||
}
|
||||
|
||||
// public long getSentBytes() {
|
||||
// return sentBytes;
|
||||
// }
|
||||
//
|
||||
// public void setSentBytes(long sentBytes) {
|
||||
// this.sentBytes = sentBytes;
|
||||
// }
|
||||
public ApiLayoutDTO getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
public void setLayout(ApiLayoutDTO layout) {
|
||||
this.layout = layout;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
package com.eactive.testmaster.client.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "API_LAYOUT")
|
||||
public class ApiLayout {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "API_REQUEST_INFO_ID")
|
||||
private ApiRequestInfo apiRequestInfo;
|
||||
|
||||
private String loutName;
|
||||
|
||||
private String loutPtrnName;
|
||||
|
||||
private String loutDesc;
|
||||
|
||||
private String eaiBzwkDstCd;
|
||||
|
||||
private String uApplName;
|
||||
|
||||
private String sysIntFacName;
|
||||
|
||||
private String author;
|
||||
|
||||
private String eaiSevRdStCd;
|
||||
|
||||
private String modfMgtStusDstCd;
|
||||
|
||||
private String useYn;
|
||||
|
||||
private String verInfo;
|
||||
|
||||
@OneToMany(mappedBy = "apiLayout", cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
|
||||
private List<ApiLayoutItem> layoutItems = new ArrayList<>();
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public ApiRequestInfo getApiRequestInfo() {
|
||||
return apiRequestInfo;
|
||||
}
|
||||
|
||||
public void setApiRequestInfo(ApiRequestInfo apiRequestInfo) {
|
||||
this.apiRequestInfo = apiRequestInfo;
|
||||
}
|
||||
|
||||
public String getLoutName() {
|
||||
return loutName;
|
||||
}
|
||||
|
||||
public void setLoutName(String loutName) {
|
||||
this.loutName = loutName;
|
||||
}
|
||||
|
||||
public String getLoutPtrnName() {
|
||||
return loutPtrnName;
|
||||
}
|
||||
|
||||
public void setLoutPtrnName(String loutPtrnName) {
|
||||
this.loutPtrnName = loutPtrnName;
|
||||
}
|
||||
|
||||
public String getLoutDesc() {
|
||||
return loutDesc;
|
||||
}
|
||||
|
||||
public void setLoutDesc(String loutDesc) {
|
||||
this.loutDesc = loutDesc;
|
||||
}
|
||||
|
||||
public String getEaiBzwkDstCd() {
|
||||
return eaiBzwkDstCd;
|
||||
}
|
||||
|
||||
public void setEaiBzwkDstCd(String eaiBzwkDstCd) {
|
||||
this.eaiBzwkDstCd = eaiBzwkDstCd;
|
||||
}
|
||||
|
||||
public String getUApplName() {
|
||||
return uApplName;
|
||||
}
|
||||
|
||||
public void setUApplName(String uApplName) {
|
||||
this.uApplName = uApplName;
|
||||
}
|
||||
|
||||
public String getSysIntFacName() {
|
||||
return sysIntFacName;
|
||||
}
|
||||
|
||||
public void setSysIntFacName(String sysIntFacName) {
|
||||
this.sysIntFacName = sysIntFacName;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getEaiSevRdStCd() {
|
||||
return eaiSevRdStCd;
|
||||
}
|
||||
|
||||
public void setEaiSevRdStCd(String eaiSevRdStCd) {
|
||||
this.eaiSevRdStCd = eaiSevRdStCd;
|
||||
}
|
||||
|
||||
public String getModfMgtStusDstCd() {
|
||||
return modfMgtStusDstCd;
|
||||
}
|
||||
|
||||
public void setModfMgtStusDstCd(String modfMgtStusDstCd) {
|
||||
this.modfMgtStusDstCd = modfMgtStusDstCd;
|
||||
}
|
||||
|
||||
public String getUseYn() {
|
||||
return useYn;
|
||||
}
|
||||
|
||||
public void setUseYn(String useYn) {
|
||||
this.useYn = useYn;
|
||||
}
|
||||
|
||||
public String getVerInfo() {
|
||||
return verInfo;
|
||||
}
|
||||
|
||||
public void setVerInfo(String verInfo) {
|
||||
this.verInfo = verInfo;
|
||||
}
|
||||
|
||||
public List<ApiLayoutItem> getLayoutItems() {
|
||||
return layoutItems;
|
||||
}
|
||||
|
||||
public void setLayoutItems(List<ApiLayoutItem> layoutItems) {
|
||||
this.layoutItems = layoutItems;
|
||||
}
|
||||
|
||||
public void addApiLayoutItem(ApiLayoutItem item) {
|
||||
item.setApiLayout(this);
|
||||
this.layoutItems.add(item);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
package com.eactive.testmaster.client.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "API_LAYOUT_ITEM")
|
||||
public class ApiLayoutItem {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "API_LAYOUT_ID", nullable = false)
|
||||
private ApiLayout apiLayout; // This is the back-reference to the parent
|
||||
|
||||
@Id
|
||||
@Column(name = "API_LAYOUT_ITEM_ID")
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long itemId;
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long parent;
|
||||
|
||||
private Integer level;
|
||||
|
||||
private String loutName;
|
||||
|
||||
private Integer loutItemSerno;
|
||||
|
||||
private String loutItemName;
|
||||
|
||||
private String loutItemDesc;
|
||||
|
||||
private Integer loutItemDepth;
|
||||
|
||||
private String loutItemType;
|
||||
|
||||
private String loutItemOccCnt;
|
||||
|
||||
private String loutItemOccRef;
|
||||
|
||||
private String loutItemDataType;
|
||||
|
||||
private Integer loutItemLength;
|
||||
|
||||
private Integer loutItemDecimal;
|
||||
|
||||
private String loutItemDefault;
|
||||
|
||||
private String loutItemMaskYn;
|
||||
|
||||
private Integer loutItemMaskOffset;
|
||||
|
||||
private Integer loutItemMaskLength;
|
||||
|
||||
private Integer parentLoutItemIndex;
|
||||
|
||||
private Boolean expanded;
|
||||
|
||||
private Boolean isLeaf;
|
||||
|
||||
private String loutItemPath;
|
||||
|
||||
private String value;
|
||||
|
||||
public Long getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public void setItemId(Long itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public ApiLayout getApiLayout() {
|
||||
return apiLayout;
|
||||
}
|
||||
|
||||
public void setApiLayout(ApiLayout apiLayout) {
|
||||
this.apiLayout = apiLayout;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(Long parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Integer getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(Integer level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getLoutName() {
|
||||
return loutName;
|
||||
}
|
||||
|
||||
public void setLoutName(String loutName) {
|
||||
this.loutName = loutName;
|
||||
}
|
||||
|
||||
public Integer getLoutItemSerno() {
|
||||
return loutItemSerno;
|
||||
}
|
||||
|
||||
public void setLoutItemSerno(Integer loutItemSerno) {
|
||||
this.loutItemSerno = loutItemSerno;
|
||||
}
|
||||
|
||||
public String getLoutItemName() {
|
||||
return loutItemName;
|
||||
}
|
||||
|
||||
public void setLoutItemName(String loutItemName) {
|
||||
this.loutItemName = loutItemName;
|
||||
}
|
||||
|
||||
public String getLoutItemDesc() {
|
||||
return loutItemDesc;
|
||||
}
|
||||
|
||||
public void setLoutItemDesc(String loutItemDesc) {
|
||||
this.loutItemDesc = loutItemDesc;
|
||||
}
|
||||
|
||||
public Integer getLoutItemDepth() {
|
||||
return loutItemDepth;
|
||||
}
|
||||
|
||||
public void setLoutItemDepth(Integer loutItemDepth) {
|
||||
this.loutItemDepth = loutItemDepth;
|
||||
}
|
||||
|
||||
public String getLoutItemType() {
|
||||
return loutItemType;
|
||||
}
|
||||
|
||||
public void setLoutItemType(String loutItemType) {
|
||||
this.loutItemType = loutItemType;
|
||||
}
|
||||
|
||||
public String getLoutItemOccCnt() {
|
||||
return loutItemOccCnt;
|
||||
}
|
||||
|
||||
public void setLoutItemOccCnt(String loutItemOccCnt) {
|
||||
this.loutItemOccCnt = loutItemOccCnt;
|
||||
}
|
||||
|
||||
public String getLoutItemOccRef() {
|
||||
return loutItemOccRef;
|
||||
}
|
||||
|
||||
public void setLoutItemOccRef(String loutItemOccRef) {
|
||||
this.loutItemOccRef = loutItemOccRef;
|
||||
}
|
||||
|
||||
public String getLoutItemDataType() {
|
||||
return loutItemDataType;
|
||||
}
|
||||
|
||||
public void setLoutItemDataType(String loutItemDataType) {
|
||||
this.loutItemDataType = loutItemDataType;
|
||||
}
|
||||
|
||||
public Integer getLoutItemLength() {
|
||||
return loutItemLength;
|
||||
}
|
||||
|
||||
public void setLoutItemLength(Integer loutItemLength) {
|
||||
this.loutItemLength = loutItemLength;
|
||||
}
|
||||
|
||||
public Integer getLoutItemDecimal() {
|
||||
return loutItemDecimal;
|
||||
}
|
||||
|
||||
public void setLoutItemDecimal(Integer loutItemDecimal) {
|
||||
this.loutItemDecimal = loutItemDecimal;
|
||||
}
|
||||
|
||||
public String getLoutItemDefault() {
|
||||
return loutItemDefault;
|
||||
}
|
||||
|
||||
public void setLoutItemDefault(String loutItemDefault) {
|
||||
this.loutItemDefault = loutItemDefault;
|
||||
}
|
||||
|
||||
public String getLoutItemMaskYn() {
|
||||
return loutItemMaskYn;
|
||||
}
|
||||
|
||||
public void setLoutItemMaskYn(String loutItemMaskYn) {
|
||||
this.loutItemMaskYn = loutItemMaskYn;
|
||||
}
|
||||
|
||||
public Integer getLoutItemMaskOffset() {
|
||||
return loutItemMaskOffset;
|
||||
}
|
||||
|
||||
public void setLoutItemMaskOffset(Integer loutItemMaskOffset) {
|
||||
this.loutItemMaskOffset = loutItemMaskOffset;
|
||||
}
|
||||
|
||||
public Integer getLoutItemMaskLength() {
|
||||
return loutItemMaskLength;
|
||||
}
|
||||
|
||||
public void setLoutItemMaskLength(Integer loutItemMaskLength) {
|
||||
this.loutItemMaskLength = loutItemMaskLength;
|
||||
}
|
||||
|
||||
public Integer getParentLoutItemIndex() {
|
||||
return parentLoutItemIndex;
|
||||
}
|
||||
|
||||
public void setParentLoutItemIndex(Integer parentLoutItemIndex) {
|
||||
this.parentLoutItemIndex = parentLoutItemIndex;
|
||||
}
|
||||
|
||||
public Boolean getExpanded() {
|
||||
return expanded;
|
||||
}
|
||||
|
||||
public void setExpanded(Boolean expanded) {
|
||||
this.expanded = expanded;
|
||||
}
|
||||
|
||||
public Boolean getLeaf() {
|
||||
return isLeaf;
|
||||
}
|
||||
|
||||
public void setLeaf(Boolean leaf) {
|
||||
isLeaf = leaf;
|
||||
}
|
||||
|
||||
public String getLoutItemPath() {
|
||||
return loutItemPath;
|
||||
}
|
||||
|
||||
public void setLoutItemPath(String loutItemPath) {
|
||||
this.loutItemPath = loutItemPath;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.eactive.testmaster.client.mapper;
|
||||
|
||||
import com.eactive.testmaster.client.dto.ApiLayoutItemDTO;
|
||||
import com.eactive.testmaster.client.entity.ApiLayoutItem;
|
||||
import com.eactive.testmaster.client.repository.ApiLayoutItemRepository;
|
||||
import com.eactive.testmaster.common.mapper.CommonMapper;
|
||||
import java.util.List;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Mapper(componentModel = "spring",
|
||||
uses = {CommonMapper.class},
|
||||
unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
@Component
|
||||
public abstract class ApiLayoutItemMapper {
|
||||
|
||||
@Autowired
|
||||
private ApiLayoutItemRepository apiLayoutItemRepository;
|
||||
|
||||
public abstract ApiLayoutItem map(ApiLayoutItemDTO dto);
|
||||
|
||||
public abstract ApiLayoutItemDTO map(ApiLayoutItem entity);
|
||||
|
||||
public ApiLayoutItem map(Long id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return apiLayoutItemRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("No ApiLayoutItem found for ID: " + id));
|
||||
}
|
||||
|
||||
// Method to map lists of ApiLayoutItemDTOs to lists of ApiLayoutItem entities
|
||||
public abstract List<ApiLayoutItem> mapItems(List<ApiLayoutItemDTO> dtos);
|
||||
|
||||
// Method to map lists of ApiLayoutItem entities to lists of ApiLayoutItemDTOs
|
||||
public abstract List<ApiLayoutItemDTO> mapItemDTOs(List<ApiLayoutItem> entities);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.eactive.testmaster.client.mapper;
|
||||
|
||||
import com.eactive.testmaster.client.dto.ApiLayoutDTO;
|
||||
import com.eactive.testmaster.client.entity.ApiLayout;
|
||||
import com.eactive.testmaster.client.entity.ApiRequestInfo;
|
||||
import com.eactive.testmaster.client.repository.ApiLayoutRepository;
|
||||
import com.eactive.testmaster.client.repository.ApiRequestRepository;
|
||||
import com.eactive.testmaster.common.mapper.CommonMapper;
|
||||
import java.util.List;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Mapper(componentModel = "spring",
|
||||
uses = {CommonMapper.class, ApiLayoutItemMapper.class},
|
||||
unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
@Component
|
||||
public abstract class ApiLayoutMapper {
|
||||
|
||||
@Autowired
|
||||
private ApiLayoutRepository apiLayoutRepository;
|
||||
|
||||
@Autowired
|
||||
private ApiRequestRepository apiRequestRepository;
|
||||
|
||||
|
||||
@Mapping(target = "apiRequestInfo", source = "apiRequestId")
|
||||
public abstract ApiLayout map(ApiLayoutDTO dto);
|
||||
|
||||
@Mapping(target = "apiRequestId", source = "apiRequestInfo")
|
||||
public abstract ApiLayoutDTO map(ApiLayout entity);
|
||||
|
||||
public ApiRequestInfo mapApiRequestInfo(String id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return apiRequestRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("No ApiRequest found for ID: " + id));
|
||||
}
|
||||
|
||||
public String mapApiRequestId(ApiRequestInfo entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
return entity.getId();
|
||||
}
|
||||
|
||||
|
||||
public ApiLayout map(String id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return apiLayoutRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("No ApiLayout found for ID: " + id));
|
||||
}
|
||||
|
||||
// public abstract List<ApiLayout> mapLayouts(List<ApiLayoutDTO> dtos);
|
||||
|
||||
public abstract List<ApiLayoutDTO> mapLayoutDTOs(List<ApiLayout> entities);
|
||||
}
|
||||
@@ -3,40 +3,73 @@ package com.eactive.testmaster.client.mapper;
|
||||
import com.eactive.testmaster.client.dto.ApiCollectionDTO;
|
||||
import com.eactive.testmaster.client.dto.ApiRequestDTO;
|
||||
import com.eactive.testmaster.client.entity.ApiCollection;
|
||||
import com.eactive.testmaster.client.entity.ApiLayout;
|
||||
import com.eactive.testmaster.client.entity.ApiLayoutItem;
|
||||
import com.eactive.testmaster.client.entity.ApiRequestInfo;
|
||||
import com.eactive.testmaster.client.repository.ApiLayoutRepository;
|
||||
import com.eactive.testmaster.client.repository.ApiRequestRepository;
|
||||
import com.eactive.testmaster.common.mapper.CommonMapper;
|
||||
import com.eactive.testmaster.server.mapper.ServerMapper;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mapper(componentModel = "spring",
|
||||
uses = {CommonMapper.class, ServerMapper.class},
|
||||
unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
uses = {CommonMapper.class, ServerMapper.class},
|
||||
unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
@Component
|
||||
public abstract class ApiRequestMapper {
|
||||
|
||||
@Autowired
|
||||
private ApiRequestRepository apiRequestRepository;
|
||||
|
||||
@Autowired
|
||||
private ApiLayoutRepository apiLayoutRepository;
|
||||
|
||||
@Autowired
|
||||
private ApiLayoutMapper apiLayoutMapper;
|
||||
|
||||
public abstract ApiCollection map(ApiCollectionDTO dto);
|
||||
|
||||
public abstract ApiRequestInfo map(ApiRequestDTO dto);
|
||||
|
||||
@Mapping(target = "layout", ignore = true)
|
||||
public abstract ApiRequestDTO map(ApiRequestInfo entity);
|
||||
|
||||
public String mapId(ApiRequestInfo entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
return entity.getId();
|
||||
}
|
||||
|
||||
public ApiRequestInfo map(String id) {
|
||||
if(id == null) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return apiRequestRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("No ApiRequest found for ID: " + id));
|
||||
}
|
||||
|
||||
@AfterMapping
|
||||
public void handleTypeSpecificMapping(ApiRequestInfo entity, @MappingTarget ApiRequestDTO dto) {
|
||||
if ("TCP".equals(entity.getType())) {
|
||||
ApiLayout layout = apiLayoutRepository.findFirstByApiRequestInfo(entity);
|
||||
if (layout!=null) {
|
||||
layout.getLayoutItems().sort(Comparator.comparingInt(ApiLayoutItem::getLoutItemSerno));
|
||||
dto.setLayout(apiLayoutMapper.map(layout));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public abstract List<ApiRequestInfo> mapApis(List<ApiRequestDTO> apis);
|
||||
|
||||
public abstract List<ApiCollectionDTO> mapCollections(List<ApiCollection> apis);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.eactive.testmaster.client.repository;
|
||||
|
||||
import com.eactive.testmaster.client.entity.ApiLayoutItem;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
public interface ApiLayoutItemRepository extends JpaRepository<ApiLayoutItem, Long>, JpaSpecificationExecutor<ApiLayoutItem> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.eactive.testmaster.client.repository;
|
||||
|
||||
import com.eactive.testmaster.client.entity.ApiLayout;
|
||||
import com.eactive.testmaster.client.entity.ApiRequestInfo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
public interface ApiLayoutRepository extends JpaRepository<ApiLayout, String>, JpaSpecificationExecutor<ApiLayout> {
|
||||
|
||||
ApiLayout findFirstByApiRequestInfo(ApiRequestInfo apiRequestInfo);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.eactive.testmaster.client.service;
|
||||
|
||||
|
||||
import com.eactive.testmaster.client.entity.ApiLayout;
|
||||
import com.eactive.testmaster.client.entity.ApiRequestInfo;
|
||||
import com.eactive.testmaster.client.repository.ApiLayoutRepository;
|
||||
import com.eactive.testmaster.client.repository.ApiRequestRepository;
|
||||
import com.eactive.testmaster.common.exception.NotFoundException;
|
||||
import java.util.UUID;
|
||||
import javax.transaction.Transactional;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class ApiLayoutMgmtService {
|
||||
|
||||
private final ApiLayoutRepository apiLayoutRepository;
|
||||
|
||||
private final ApiRequestRepository apiRequestRepository;
|
||||
|
||||
public ApiLayoutMgmtService(ApiRequestRepository apiRequestRepository, ApiLayoutRepository apiLayoutRepository) {
|
||||
this.apiRequestRepository = apiRequestRepository;
|
||||
this.apiLayoutRepository = apiLayoutRepository;
|
||||
}
|
||||
|
||||
public ApiLayout findLayoutByApiRequest(String apiRequestId) {
|
||||
ApiRequestInfo apiRequestInfo = apiRequestRepository.findById(apiRequestId)
|
||||
.orElseThrow(() -> new NotFoundException(String.format("ApiRequestInfo with ID %s not found", apiRequestId)));
|
||||
|
||||
return apiLayoutRepository.findFirstByApiRequestInfo(apiRequestInfo);
|
||||
}
|
||||
|
||||
public ApiLayout saveLayout(ApiLayout layout) {
|
||||
if (layout.getId() == null) {
|
||||
return createLayout(layout);
|
||||
} else {
|
||||
return updateLayout(layout.getId(), layout);
|
||||
}
|
||||
}
|
||||
|
||||
public ApiLayout createLayout(ApiLayout layout) {
|
||||
layout.setId(UUID.randomUUID().toString());
|
||||
if (layout.getLayoutItems() != null && !layout.getLayoutItems().isEmpty()) {
|
||||
layout.getLayoutItems().forEach(layoutItem -> {
|
||||
layoutItem.setApiLayout(layout);
|
||||
});
|
||||
}
|
||||
return apiLayoutRepository.save(layout);
|
||||
}
|
||||
|
||||
public ApiLayout updateLayout(String layoutId, ApiLayout updatedLayout) {
|
||||
ApiLayout layout = apiLayoutRepository.findById(layoutId)
|
||||
.orElseThrow(() -> new NotFoundException(String.format("Layout with ID %s not found", layoutId)));
|
||||
|
||||
// Update fields based on the values provided in updatedLayout
|
||||
layout.setLoutName(updatedLayout.getLoutName());
|
||||
layout.setLoutDesc(updatedLayout.getLoutDesc());
|
||||
layout.setLoutPtrnName(updatedLayout.getLoutPtrnName());
|
||||
layout.setLoutDesc(updatedLayout.getLoutDesc());
|
||||
layout.setEaiBzwkDstCd(updatedLayout.getEaiBzwkDstCd());
|
||||
layout.setUApplName(updatedLayout.getUApplName());
|
||||
layout.setSysIntFacName(updatedLayout.getSysIntFacName());
|
||||
layout.setAuthor(updatedLayout.getAuthor());
|
||||
layout.setEaiSevRdStCd(updatedLayout.getEaiSevRdStCd());
|
||||
layout.setModfMgtStusDstCd(updatedLayout.getModfMgtStusDstCd());
|
||||
layout.setUseYn(updatedLayout.getUseYn());
|
||||
layout.setVerInfo(updatedLayout.getVerInfo());
|
||||
|
||||
if (updatedLayout.getLayoutItems() != null && !updatedLayout.getLayoutItems().isEmpty()) {
|
||||
layout.getLayoutItems().clear();
|
||||
updatedLayout.getLayoutItems().forEach(layoutItem -> {
|
||||
layoutItem.setApiLayout(layout); // Set back reference to layout
|
||||
layout.getLayoutItems().add(layoutItem);
|
||||
});
|
||||
}
|
||||
|
||||
return apiLayoutRepository.save(layout);
|
||||
}
|
||||
|
||||
// Method to delete a layout
|
||||
public void deleteLayout(String id) {
|
||||
ApiLayout layout = apiLayoutRepository.findById(id)
|
||||
.orElseThrow(() -> new NotFoundException(String.format("Layout with ID %s not found", id)));
|
||||
apiLayoutRepository.delete(layout);
|
||||
}
|
||||
}
|
||||
@@ -85,22 +85,6 @@ public class NettyTcpApiClient implements ApiClient {
|
||||
ChannelFuture f = b.connect(host, port).sync();
|
||||
f.channel().closeFuture().sync();
|
||||
|
||||
// Wait for the response
|
||||
return answer.take(); // This will block until a message is available
|
||||
}
|
||||
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// NettyTcpApiClient client = new NettyTcpApiClient();
|
||||
// try {
|
||||
// String response = client.sendMessage("localhost", 30913, "00340000BASICTST010134567890ABCDEF");
|
||||
// System.out.println("Server replied: " + response);
|
||||
// } catch (InterruptedException e) {
|
||||
// Thread.currentThread().interrupt();
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// client.shutdown();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.eactive.testmaster.client.service.internal;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import java.util.List;
|
||||
|
||||
public class FixedLengthFrameDecoder extends ByteToMessageDecoder {
|
||||
private final int frameLength;
|
||||
|
||||
public FixedLengthFrameDecoder(int frameLength) {
|
||||
if (frameLength <= 0) {
|
||||
throw new IllegalArgumentException("frameLength must be a positive integer: " + frameLength);
|
||||
}
|
||||
this.frameLength = frameLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
|
||||
while (in.readableBytes() >= frameLength) {
|
||||
ByteBuf buf = in.readBytes(frameLength);
|
||||
out.add(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,18 @@ public class ServerDTO {
|
||||
|
||||
private boolean enabled = true;
|
||||
|
||||
private boolean messageKeyInclude = false;
|
||||
|
||||
private Integer messageKeyOffset;
|
||||
|
||||
private Integer messageKeyLength;
|
||||
|
||||
private boolean lengthFieldInclude = false;
|
||||
|
||||
private Integer lengthFieldOffset;
|
||||
|
||||
private Integer lengthFieldLength;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -77,4 +89,52 @@ public class ServerDTO {
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public boolean isMessageKeyInclude() {
|
||||
return messageKeyInclude;
|
||||
}
|
||||
|
||||
public void setMessageKeyInclude(boolean messageKeyInclude) {
|
||||
this.messageKeyInclude = messageKeyInclude;
|
||||
}
|
||||
|
||||
public Integer getMessageKeyOffset() {
|
||||
return messageKeyOffset;
|
||||
}
|
||||
|
||||
public void setMessageKeyOffset(Integer messageKeyOffset) {
|
||||
this.messageKeyOffset = messageKeyOffset;
|
||||
}
|
||||
|
||||
public Integer getMessageKeyLength() {
|
||||
return messageKeyLength;
|
||||
}
|
||||
|
||||
public void setMessageKeyLength(Integer messageKeyLength) {
|
||||
this.messageKeyLength = messageKeyLength;
|
||||
}
|
||||
|
||||
public boolean isLengthFieldInclude() {
|
||||
return lengthFieldInclude;
|
||||
}
|
||||
|
||||
public void setLengthFieldInclude(boolean lengthFieldInclude) {
|
||||
this.lengthFieldInclude = lengthFieldInclude;
|
||||
}
|
||||
|
||||
public Integer getLengthFieldOffset() {
|
||||
return lengthFieldOffset;
|
||||
}
|
||||
|
||||
public void setLengthFieldOffset(Integer lengthFieldOffset) {
|
||||
this.lengthFieldOffset = lengthFieldOffset;
|
||||
}
|
||||
|
||||
public Integer getLengthFieldLength() {
|
||||
return lengthFieldLength;
|
||||
}
|
||||
|
||||
public void setLengthFieldLength(Integer lengthFieldLength) {
|
||||
this.lengthFieldLength = lengthFieldLength;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,24 @@ public class Server {
|
||||
@Column(name = "IS_ENABLED", columnDefinition = "boolean default true")
|
||||
private boolean enabled;
|
||||
|
||||
@Column(name = "MESSAGE_KEY_INCLUDE", columnDefinition = "boolean default false")
|
||||
private boolean messageKeyInclude;
|
||||
|
||||
@Column(name = "MESSAGE_KEY_OFFSET", columnDefinition = "integer")
|
||||
private Integer messageKeyOffset;
|
||||
|
||||
@Column(name = "MESSAGE_KEY_LENGTH", columnDefinition = "integer")
|
||||
private Integer messageKeyLength;
|
||||
|
||||
@Column(name = "LENGTH_FIELD_INCLUDE", columnDefinition = "boolean default false")
|
||||
private boolean lengthFieldInclude;
|
||||
|
||||
@Column(name = "LENGTH_FIELD_OFFSET", columnDefinition = "integer")
|
||||
private Integer lengthFieldOffset;
|
||||
|
||||
@Column(name = "LENGTH_FIELD_LENGTH", columnDefinition = "integer")
|
||||
private Integer lengthFieldLength;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -71,7 +89,6 @@ public class Server {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
@@ -80,6 +97,54 @@ public class Server {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public boolean isMessageKeyInclude() {
|
||||
return messageKeyInclude;
|
||||
}
|
||||
|
||||
public void setMessageKeyInclude(boolean messageKeyInclude) {
|
||||
this.messageKeyInclude = messageKeyInclude;
|
||||
}
|
||||
|
||||
public boolean isLengthFieldInclude() {
|
||||
return lengthFieldInclude;
|
||||
}
|
||||
|
||||
public void setLengthFieldInclude(boolean lengthFieldInclude) {
|
||||
this.lengthFieldInclude = lengthFieldInclude;
|
||||
}
|
||||
|
||||
public Integer getMessageKeyOffset() {
|
||||
return messageKeyOffset;
|
||||
}
|
||||
|
||||
public void setMessageKeyOffset(Integer messageKeyOffset) {
|
||||
this.messageKeyOffset = messageKeyOffset;
|
||||
}
|
||||
|
||||
public Integer getMessageKeyLength() {
|
||||
return messageKeyLength;
|
||||
}
|
||||
|
||||
public void setMessageKeyLength(Integer messageKeyLength) {
|
||||
this.messageKeyLength = messageKeyLength;
|
||||
}
|
||||
|
||||
public Integer getLengthFieldOffset() {
|
||||
return lengthFieldOffset;
|
||||
}
|
||||
|
||||
public void setLengthFieldOffset(Integer lengthFieldOffset) {
|
||||
this.lengthFieldOffset = lengthFieldOffset;
|
||||
}
|
||||
|
||||
public Integer getLengthFieldLength() {
|
||||
return lengthFieldLength;
|
||||
}
|
||||
|
||||
public void setLengthFieldLength(Integer lengthFieldLength) {
|
||||
this.lengthFieldLength = lengthFieldLength;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public String getFullHostAddress() {
|
||||
return scheme + "://" + hostname + (port == null ? "" : ":" + port) + basePath;
|
||||
|
||||
@@ -47,6 +47,12 @@ public class ServerMapper {
|
||||
dto.setScheme(server.getScheme());
|
||||
dto.setBasePath(server.getBasePath());
|
||||
dto.setEnabled(server.isEnabled());
|
||||
dto.setLengthFieldInclude(server.isLengthFieldInclude());
|
||||
dto.setMessageKeyInclude(server.isMessageKeyInclude());
|
||||
dto.setLengthFieldLength(server.getLengthFieldLength());
|
||||
dto.setLengthFieldOffset(server.getLengthFieldOffset());
|
||||
dto.setMessageKeyLength(server.getMessageKeyLength());
|
||||
dto.setMessageKeyOffset(server.getMessageKeyOffset());
|
||||
|
||||
return dto;
|
||||
}
|
||||
@@ -66,6 +72,12 @@ public class ServerMapper {
|
||||
server.setScheme(dto.getScheme());
|
||||
server.setBasePath(dto.getBasePath());
|
||||
server.setEnabled(dto.isEnabled());
|
||||
server.setLengthFieldInclude(dto.isLengthFieldInclude());
|
||||
server.setMessageKeyInclude(dto.isMessageKeyInclude());
|
||||
server.setLengthFieldLength(dto.getLengthFieldLength());
|
||||
server.setLengthFieldOffset(dto.getLengthFieldOffset());
|
||||
server.setMessageKeyLength(dto.getMessageKeyLength());
|
||||
server.setMessageKeyOffset(dto.getMessageKeyOffset());
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,12 @@ public class ServerMgmtService {
|
||||
server.setBasePath(updated.getBasePath());
|
||||
server.setPort(updated.getPort());
|
||||
server.setEnabled(updated.isEnabled());
|
||||
server.setLengthFieldInclude(updated.isLengthFieldInclude());
|
||||
server.setMessageKeyInclude(updated.isMessageKeyInclude());
|
||||
server.setMessageKeyLength(updated.getMessageKeyLength());
|
||||
server.setMessageKeyOffset(updated.getMessageKeyOffset());
|
||||
server.setLengthFieldLength(updated.getLengthFieldLength());
|
||||
server.setLengthFieldOffset(updated.getLengthFieldOffset());
|
||||
|
||||
serverRepository.save(server);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user