diff options
Diffstat (limited to 'common')
14 files changed, 252 insertions, 251 deletions
diff --git a/common/pom.xml b/common/pom.xml index ff13da4ee6..74e51805ad 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -71,7 +71,6 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-client</artifactId> - <version>${cxf.version}</version> <scope>test</scope> </dependency> <dependency> diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java index 27c5cf8e26..dc8e69121e 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java @@ -22,14 +22,16 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; +import java.io.Serializable; import java.util.Map; @JsonInclude(JsonInclude.Include.NON_NULL) @Data -public class AllocateAnNssi { +public class AllocateAnNssi implements Serializable { @Deprecated public final static String URL = "/api/rest/provMns/v1/an/NSS" + "/SliceProfiles"; + private static final long serialVersionUID = 4925129853421138442L; private String nsstId; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java b/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java index 418f8a5065..e2c2e999ec 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java @@ -21,9 +21,12 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class AnPerfReq { +public class AnPerfReq implements Serializable { + + private static final long serialVersionUID = -7415880702887244040L; private PerfReqEmbb perfReqEmbb; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java index 83675da5f0..eef0396205 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java @@ -23,11 +23,16 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; +import lombok.ToString; +import java.io.Serializable; import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) @Data -public class AnSliceProfile { +@ToString +public class AnSliceProfile implements Serializable { + + private static final long serialVersionUID = -3057342171549542794L; @JsonProperty(value = "sliceProfileId", required = true) private String sliceProfileId; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java index 399d51e894..10aaf26413 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java @@ -21,12 +21,14 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) -public class DeAllocateNssi { +public class DeAllocateNssi implements Serializable { @Deprecated public final static String URL = "/api/rest/provMns/v1/NSS" + "/SliceProfiles/%s"; + private static final long serialVersionUID = 8198187346132154044L; private String nsiId; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/JobStatusResponse.java b/common/src/main/java/org/onap/so/beans/nsmf/JobStatusResponse.java index 9259d51591..a0a9531c89 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/JobStatusResponse.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/JobStatusResponse.java @@ -21,9 +21,12 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class JobStatusResponse { +public class JobStatusResponse implements Serializable { + + private static final long serialVersionUID = -2039407266985403172L; private ResponseDescriptor responseDescriptor; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java index d1679c6dfa..3219846ec7 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java @@ -21,9 +21,12 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class NsiInfo { +public class NsiInfo implements Serializable { + + private static final long serialVersionUID = -8432406430744875618L; private String nsiName; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java index 66368be6b8..92acdaa90d 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java @@ -21,9 +21,12 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class NssiResponse { +public class NssiResponse implements Serializable { + + private static final long serialVersionUID = 2723440188640857903L; private String nssiId; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java index bce0d56f9a..f6e945e368 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java @@ -21,9 +21,12 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class PerfReqEmbb { +public class PerfReqEmbb implements Serializable { + + private static final long serialVersionUID = 8886635511695277599L; @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int expDataRateDL; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java index 0b05d39bab..9e4b4edce3 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java @@ -21,9 +21,12 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class PerfReqUrllc { +public class PerfReqUrllc implements Serializable { + + private static final long serialVersionUID = 3133479142915485943L; @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int e2eLatency; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java b/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java index 146032c6fd..2456d540ce 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java @@ -22,11 +22,14 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; +import java.io.Serializable; import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) @Data -public class ResponseDescriptor { +public class ResponseDescriptor implements Serializable { + + private static final long serialVersionUID = 6330527958947215910L; @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int progress; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java index 19e8b46314..f9848fca31 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java @@ -19,10 +19,11 @@ */ package org.onap.so.beans.nsmf; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; import java.io.Serializable; -import java.util.List; +@JsonInclude(JsonInclude.Include.NON_NULL) @Data public class ServiceInfo implements Serializable { diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParams.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParams.java index f0857fc458..4aa567112f 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParams.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParams.java @@ -22,11 +22,19 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.JsonObject; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; import java.io.IOException; import java.io.Serializable; import java.util.HashMap; import java.util.Map; +@Data +@AllArgsConstructor +@NoArgsConstructor +@ToString public class SliceTaskParams implements Serializable { private static final long serialVersionUID = -4389946152970978423L; @@ -45,17 +53,17 @@ public class SliceTaskParams implements Serializable { private String cnScriptName; - private Map<String, Object> serviceProfile; + private Map<String, Object> serviceProfile = new HashMap<>(); private String suggestNsiId; private String suggestNsiName; - private Map<String, Object> sliceProfileTn; + private Map<String, Object> sliceProfileTn = new HashMap<>(); - private Map<String, Object> sliceProfileCn; + private Map<String, Object> sliceProfileCn = new HashMap<>(); - private Map<String, Object> sliceProfileAn; + private Map<String, Object> sliceProfileAn = new HashMap<>(); private String tnSuggestNssiId; @@ -87,237 +95,6 @@ public class SliceTaskParams implements Serializable { private String anStatusDescription; - public SliceTaskParams() { - this.serviceProfile = new HashMap<>(); - this.sliceProfileAn = new HashMap<>(); - this.sliceProfileCn = new HashMap<>(); - this.sliceProfileTn = new HashMap<>(); - } - - public String getNstId() { - return nstId; - } - - public void setNstId(String nstId) { - this.nstId = nstId; - } - - public String getNstName() { - return nstName; - } - - public void setNstName(String nstName) { - this.nstName = nstName; - } - - public String getTnScriptName() { - return tnScriptName; - } - - public void setTnScriptName(String tnScriptName) { - this.tnScriptName = tnScriptName; - } - - public String getAnScriptName() { - return anScriptName; - } - - public void setAnScriptName(String anScriptName) { - this.anScriptName = anScriptName; - } - - public String getCnScriptName() { - return cnScriptName; - } - - public void setCnScriptName(String cnScriptName) { - this.cnScriptName = cnScriptName; - } - - public String getServiceId() { - return serviceId; - } - - public void setServiceId(String serviceId) { - this.serviceId = serviceId; - } - - public String getServiceName() { - return serviceName; - } - - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - - public Map<String, Object> getServiceProfile() { - return serviceProfile; - } - - public void setServiceProfile(Map<String, Object> serviceProfile) { - this.serviceProfile = serviceProfile; - } - - public String getSuggestNsiId() { - return suggestNsiId; - } - - public void setSuggestNsiId(String suggestNsiId) { - this.suggestNsiId = suggestNsiId; - } - - public String getSuggestNsiName() { - return suggestNsiName; - } - - public void setSuggestNsiName(String suggestNsiName) { - this.suggestNsiName = suggestNsiName; - } - - public Map<String, Object> getSliceProfileTn() { - return sliceProfileTn; - } - - public void setSliceProfileTn(Map<String, Object> sliceProfileTn) { - this.sliceProfileTn = sliceProfileTn; - } - - public Map<String, Object> getSliceProfileCn() { - return sliceProfileCn; - } - - public void setSliceProfileCn(Map<String, Object> sliceProfileCn) { - this.sliceProfileCn = sliceProfileCn; - } - - public Map<String, Object> getSliceProfileAn() { - return sliceProfileAn; - } - - public void setSliceProfileAn(Map<String, Object> sliceProfileAn) { - this.sliceProfileAn = sliceProfileAn; - } - - public String getTnSuggestNssiId() { - return tnSuggestNssiId; - } - - public void setTnSuggestNssiId(String tnSuggestNssiId) { - this.tnSuggestNssiId = tnSuggestNssiId; - } - - public String getTnSuggestNssiName() { - return tnSuggestNssiName; - } - - public void setTnSuggestNssiName(String tnSuggestNssiName) { - this.tnSuggestNssiName = tnSuggestNssiName; - } - - public String getTnProgress() { - return tnProgress; - } - - public void setTnProgress(String tnProgress) { - this.tnProgress = tnProgress; - } - - public String getTnStatus() { - return tnStatus; - } - - public void setTnStatus(String tnStatus) { - this.tnStatus = tnStatus; - } - - public String getTnStatusDescription() { - return tnStatusDescription; - } - - public void setTnStatusDescription(String tnStatusDescription) { - this.tnStatusDescription = tnStatusDescription; - } - - public String getCnSuggestNssiId() { - return cnSuggestNssiId; - } - - public void setCnSuggestNssiId(String cnSuggestNssiId) { - this.cnSuggestNssiId = cnSuggestNssiId; - } - - public String getCnSuggestNssiName() { - return cnSuggestNssiName; - } - - public void setCnSuggestNssiName(String cnSuggestNssiName) { - this.cnSuggestNssiName = cnSuggestNssiName; - } - - public String getCnProgress() { - return cnProgress; - } - - public void setCnProgress(String cnProgress) { - this.cnProgress = cnProgress; - } - - public String getCnStatus() { - return cnStatus; - } - - public void setCnStatus(String cnStatus) { - this.cnStatus = cnStatus; - } - - public String getCnStatusDescription() { - return cnStatusDescription; - } - - public void setCnStatusDescription(String cnStatusDescription) { - this.cnStatusDescription = cnStatusDescription; - } - - public String getAnSuggestNssiId() { - return anSuggestNssiId; - } - - public void setAnSuggestNssiId(String anSuggestNssiId) { - this.anSuggestNssiId = anSuggestNssiId; - } - - public String getAnSuggestNssiName() { - return anSuggestNssiName; - } - - public void setAnSuggestNssiName(String anSuggestNssiName) { - this.anSuggestNssiName = anSuggestNssiName; - } - - public String getAnProgress() { - return anProgress; - } - - public void setAnProgress(String anProgress) { - this.anProgress = anProgress; - } - - public String getAnStatus() { - return anStatus; - } - - public void setAnStatus(String anStatus) { - this.anStatus = anStatus; - } - - public String getAnStatusDescription() { - return anStatusDescription; - } - - public void setAnStatusDescription(String anStatusDescription) { - this.anStatusDescription = anStatusDescription; - } - public String convertToJson() { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("ServiceId", serviceId); diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java index 6ad752f047..8ea0eb6587 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java @@ -19,8 +19,15 @@ */ package org.onap.so.beans.nsmf; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.JsonObject; import lombok.*; import org.onap.so.beans.nsmf.oof.TemplateInfo; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.io.Serializable; import java.util.Map; @@ -29,7 +36,8 @@ import java.util.Map; @AllArgsConstructor @ToString @Builder -public class SliceTaskParamsAdapter { +public class SliceTaskParamsAdapter implements Serializable { + private static final long serialVersionUID = -7785578865170503301L; private String serviceId; @@ -58,9 +66,195 @@ public class SliceTaskParamsAdapter { private SliceTaskInfo<AnSliceProfile> anSliceTaskInfo; + @SuppressWarnings("unchecked") + public void convertFromJson(String jsonString) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + Map<String, String> paramMap = (Map<String, String>) mapper.readValue(jsonString, Map.class); + + this.setServiceName(paramMap.get("ServiceName")); + this.setServiceId(paramMap.get("ServiceId")); + this.setNstId(paramMap.get("NSTId")); + this.setNstName(paramMap.get("NSTName")); + this.setSuggestNsiId(paramMap.get("suggestNSIId")); + this.setSuggestNsiName(paramMap.get("suggestNSIName")); + + this.setServiceProfile(replaceHeader(paramMap, "ServiceProfile.")); + + TnSliceProfile tnBHSliceProfile = mapper.readValue( + mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.BH.")), TnSliceProfile.class); + this.tnBHSliceTaskInfo.setSliceProfile(tnBHSliceProfile); + + TnSliceProfile tnMHSliceProfile = mapper.readValue( + mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.MH.")), TnSliceProfile.class); + this.tnMHSliceTaskInfo.setSliceProfile(tnMHSliceProfile); + + TnSliceProfile tnFHSliceProfile = mapper.readValue( + mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.FH.")), TnSliceProfile.class); + this.tnFHSliceTaskInfo.setSliceProfile(tnFHSliceProfile); + + CnSliceProfile cnSliceProfile = mapper.readValue( + mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.CN.")), CnSliceProfile.class); + this.cnSliceTaskInfo.setSliceProfile(cnSliceProfile); + + AnSliceProfile anSliceProfile = mapper.readValue( + mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.AN.")), AnSliceProfile.class); + this.anSliceTaskInfo.setSliceProfile(anSliceProfile); + + this.tnBHSliceTaskInfo.setSuggestNssiId(paramMap.get("TN.BH.SuggestNSSIId")); + this.tnBHSliceTaskInfo.setSuggestNssiName(paramMap.get("TN.BH.SuggestNSSIName")); + this.tnBHSliceTaskInfo.setProgress(paramMap.get("TN.BH.progress")); + this.tnBHSliceTaskInfo.setStatus(paramMap.get("TN.BH.status")); + this.tnBHSliceTaskInfo.setStatusDescription(paramMap.get("TN.BH.statusDescription")); + this.tnBHSliceTaskInfo.setScriptName(paramMap.get("TN.BH.ScriptName")); + + this.tnMHSliceTaskInfo.setSuggestNssiId(paramMap.get("TN.MH.SuggestNSSIId")); + this.tnMHSliceTaskInfo.setSuggestNssiName(paramMap.get("TN.MH.SuggestNSSIName")); + this.tnMHSliceTaskInfo.setProgress(paramMap.get("TN.MH.progress")); + this.tnMHSliceTaskInfo.setStatus(paramMap.get("TN.MH.status")); + this.tnMHSliceTaskInfo.setStatusDescription(paramMap.get("TN.MH.statusDescription")); + this.tnMHSliceTaskInfo.setScriptName(paramMap.get("TN.MH.ScriptName")); + + this.tnFHSliceTaskInfo.setSuggestNssiId(paramMap.get("TN.FH.SuggestNSSIId")); + this.tnFHSliceTaskInfo.setSuggestNssiName(paramMap.get("TN.FH.SuggestNSSIName")); + this.tnFHSliceTaskInfo.setProgress(paramMap.get("TN.FH.progress")); + this.tnFHSliceTaskInfo.setStatus(paramMap.get("TN.FH.status")); + this.tnFHSliceTaskInfo.setStatusDescription(paramMap.get("TN.FH.statusDescription")); + this.tnFHSliceTaskInfo.setScriptName(paramMap.get("TN.FH.ScriptName")); + + this.cnSliceTaskInfo.setSuggestNssiId(paramMap.get("CN.SuggestNSSIId")); + this.cnSliceTaskInfo.setSuggestNssiName(paramMap.get("CN.SuggestNSSIName")); + this.cnSliceTaskInfo.setProgress(paramMap.get("CN.progress")); + this.cnSliceTaskInfo.setStatus(paramMap.get("CN.status")); + this.cnSliceTaskInfo.setStatusDescription(paramMap.get("CN.statusDescription")); + this.cnSliceTaskInfo.setScriptName(paramMap.get("CN.ScriptName")); + + this.anSliceTaskInfo.setSuggestNssiId(paramMap.get("AN.SuggestNSSIId")); + this.anSliceTaskInfo.setSuggestNssiName(paramMap.get("AN.SuggestNSSIName")); + this.anSliceTaskInfo.setProgress(paramMap.get("AN.progress")); + this.anSliceTaskInfo.setStatus(paramMap.get("AN.status")); + this.anSliceTaskInfo.setStatusDescription(paramMap.get("AN.statusDescription")); + this.anSliceTaskInfo.setScriptName(paramMap.get("AN.ScriptName")); + } + public String convertToJson() { - SliceTaskParams sliceTaskParams = new SliceTaskParams(); - sliceTaskParams.setServiceId(serviceId); - return sliceTaskParams.convertToJson(); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("ServiceId", serviceId); + jsonObject.addProperty("ServiceName", serviceName); + jsonObject.addProperty("NSTId", nstId); + jsonObject.addProperty("NSTName", nstName); + jsonObject.addProperty("suggestNSIId", suggestNsiId); + jsonObject.addProperty("suggestNSIName", suggestNsiName); + + for (Map.Entry<String, Object> entry : serviceProfile.entrySet()) { + jsonObject.addProperty("ServiceProfile." + entry.getKey(), entry.getValue().toString()); + } + + Map<String, Object> sliceProfileAn = bean2Map(anSliceTaskInfo.getSliceProfile()); + + for (Map.Entry<String, Object> entry : sliceProfileAn.entrySet()) { + jsonObject.addProperty("SliceProfile.AN." + entry.getKey(), entry.getValue().toString()); + } + + Map<String, Object> sliceProfileCn = bean2Map(cnSliceTaskInfo.getSliceProfile()); + for (Map.Entry<String, Object> entry : sliceProfileCn.entrySet()) { + jsonObject.addProperty("SliceProfile.CN." + entry.getKey(), entry.getValue().toString()); + } + + Map<String, Object> sliceProfileTnBH = bean2Map(tnBHSliceTaskInfo.getSliceProfile()); + for (Map.Entry<String, Object> entry : sliceProfileTnBH.entrySet()) { + jsonObject.addProperty("SliceProfile.TN.BH." + entry.getKey(), entry.getValue().toString()); + } + + Map<String, Object> sliceProfileTnMH = bean2Map(tnMHSliceTaskInfo.getSliceProfile()); + for (Map.Entry<String, Object> entry : sliceProfileTnMH.entrySet()) { + jsonObject.addProperty("SliceProfile.TN.MH." + entry.getKey(), entry.getValue().toString()); + } + + Map<String, Object> sliceProfileTnFH = bean2Map(tnFHSliceTaskInfo.getSliceProfile()); + for (Map.Entry<String, Object> entry : sliceProfileTnFH.entrySet()) { + jsonObject.addProperty("SliceProfile.TN.FH." + entry.getKey(), entry.getValue().toString()); + } + + jsonObject.addProperty("TN.BH.SuggestNSSIId", tnBHSliceTaskInfo.getSuggestNssiId()); + jsonObject.addProperty("TN.BH.SuggestNSSIName", tnBHSliceTaskInfo.getSuggestNssiName()); + jsonObject.addProperty("TN.BH.progress", tnBHSliceTaskInfo.getProgress()); + jsonObject.addProperty("TN.BH.status", tnBHSliceTaskInfo.getStatus()); + jsonObject.addProperty("TN.BH.statusDescription", tnBHSliceTaskInfo.getStatusDescription()); + jsonObject.addProperty("TN.BH.ScriptName", tnBHSliceTaskInfo.getScriptName()); + + + jsonObject.addProperty("TN.MH.SuggestNSSIId", tnMHSliceTaskInfo.getSuggestNssiId()); + jsonObject.addProperty("TN.MH.SuggestNSSIName", tnMHSliceTaskInfo.getSuggestNssiName()); + jsonObject.addProperty("TN.MH.progress", tnMHSliceTaskInfo.getProgress()); + jsonObject.addProperty("TN.MH.status", tnMHSliceTaskInfo.getStatus()); + jsonObject.addProperty("TN.MH.statusDescription", tnMHSliceTaskInfo.getStatusDescription()); + jsonObject.addProperty("TN.MH.ScriptName", tnMHSliceTaskInfo.getScriptName()); + + + jsonObject.addProperty("TN.FH.SuggestNSSIId", tnFHSliceTaskInfo.getSuggestNssiId()); + jsonObject.addProperty("TN.FH.SuggestNSSIName", tnFHSliceTaskInfo.getSuggestNssiName()); + jsonObject.addProperty("TN.FH.progress", tnFHSliceTaskInfo.getProgress()); + jsonObject.addProperty("TN.FH.status", tnFHSliceTaskInfo.getStatus()); + jsonObject.addProperty("TN.FH.statusDescription", tnFHSliceTaskInfo.getStatusDescription()); + jsonObject.addProperty("TN.FH.ScriptName", tnFHSliceTaskInfo.getScriptName()); + + + jsonObject.addProperty("CN.SuggestNSSIId", cnSliceTaskInfo.getSuggestNssiId()); + jsonObject.addProperty("CN.SuggestNSSIName", cnSliceTaskInfo.getSuggestNssiName()); + jsonObject.addProperty("CN.progress", cnSliceTaskInfo.getProgress()); + jsonObject.addProperty("CN.status", cnSliceTaskInfo.getStatus()); + jsonObject.addProperty("CN.statusDescription", cnSliceTaskInfo.getStatusDescription()); + jsonObject.addProperty("CN.ScriptName", cnSliceTaskInfo.getScriptName()); + + + jsonObject.addProperty("AN.SuggestNSSIId", anSliceTaskInfo.getSuggestNssiId()); + jsonObject.addProperty("AN.SuggestNSSIName", anSliceTaskInfo.getSuggestNssiName()); + jsonObject.addProperty("AN.progress", anSliceTaskInfo.getProgress()); + jsonObject.addProperty("AN.status", anSliceTaskInfo.getStatus()); + jsonObject.addProperty("AN.statusDescription", anSliceTaskInfo.getStatusDescription()); + jsonObject.addProperty("AN.ScriptName", anSliceTaskInfo.getScriptName()); + + return jsonObject.toString(); + } + + /** + * change T t to {@link Map} + * + * @param t input + * @param <T> Object + * @return {@link Map} + */ + private <T> Map<String, Object> bean2Map(T t) { + Map<String, Object> resMap = new HashMap<>(); + try { + Field[] fields = t.getClass().getDeclaredFields(); + for (Field field : fields) { + String name = field.getName(); + Method method = t.getClass().getMethod("get" + name); + Object value = method.invoke(t); + resMap.put(name, value); + } + + } catch (Exception e) { + e.printStackTrace(); + } + return resMap; + } + + /** + * replace of slice profile + * + * @param paramMap params map + * @param header starts of key + * @return Map + */ + private Map<String, Object> replaceHeader(Map<String, String> paramMap, String header) { + Map<String, Object> sliceProfileMap = new HashMap<>(); + for (Map.Entry<String, String> entry : paramMap.entrySet()) { + if (entry.getKey().startsWith(header)) { + sliceProfileMap.put(entry.getKey().replaceFirst("^" + header, ""), entry.getValue()); + } + } + return sliceProfileMap; } } |