aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/main/java
diff options
context:
space:
mode:
authorhetengjiao <hetengjiao@chinamobile.com>2020-11-13 15:18:59 +0800
committerhetengjiao <hetengjiao@chinamobile.com>2020-11-17 11:53:27 +0800
commit75a86282d2ec71f53ca4e078762f0fae25dac8cd (patch)
tree3ba6c3ee7292b4ba10864cd1134a77be581c9832 /common/src/main/java
parentd9c2a8645009b7080302f01b7e13e1480060eebd (diff)
fixed cs profile trans to ss profile
Issue-ID: SO-2963 Signed-off-by: hetengjiao <hetengjiao@chinamobile.com> Change-Id: Ia5a40ac9126641479047a0a76c7d2fefc1d6f07d
Diffstat (limited to 'common/src/main/java')
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java85
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java116
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java74
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java9
4 files changed, 175 insertions, 109 deletions
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java
index 3bd155d512..d68a374cf0 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java
@@ -21,100 +21,37 @@
package org.onap.so.beans.nsmf;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
+@Data
public class CnSliceProfile {
+ @JsonProperty(value = "sNSSAIList", required = true)
private List<String> snssaiList;
private String sliceProfileId;
+ @JsonProperty(value = "pLMNIdList", required = true)
private List<String> plmnIdList;
+ @JsonProperty(value = "perfReq", required = true)
private PerfReq perfReq;
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
+ @JsonProperty(value = "maxNumberofUEs")
private int maxNumberofUEs;
+ @JsonProperty(value = "coverageAreaTAList")
private List<String> coverageAreaTAList;
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
+ @JsonProperty(value = "latency")
private int latency;
+ @JsonProperty(value = "uEMobilityLevel")
private UeMobilityLevel ueMobilityLevel;
+ @JsonProperty(value = "resourceSharingLevel")
private ResourceSharingLevel resourceSharingLevel;
-
- public String getSliceProfileId() {
- return sliceProfileId;
- }
-
- public void setSliceProfileId(String sliceProfileId) {
- this.sliceProfileId = sliceProfileId;
- }
-
- public List<String> getPlmnIdList() {
- return plmnIdList;
- }
-
- public void setPlmnIdList(List<String> plmnIdList) {
- this.plmnIdList = plmnIdList;
- }
-
- public PerfReq getPerfReq() {
- return perfReq;
- }
-
- public void setPerfReq(PerfReq perfReq) {
- this.perfReq = perfReq;
- }
-
- public int getMaxNumberofUEs() {
- return maxNumberofUEs;
- }
-
- public void setMaxNumberofUEs(int maxNumberofUEs) {
- this.maxNumberofUEs = maxNumberofUEs;
- }
-
- public List<String> getCoverageAreaTAList() {
- return coverageAreaTAList;
- }
-
- public void setCoverageAreaTAList(List<String> coverageAreaTAList) {
- this.coverageAreaTAList = coverageAreaTAList;
- }
-
- public int getLatency() {
- return latency;
- }
-
- public void setLatency(int latency) {
- this.latency = latency;
- }
-
- public UeMobilityLevel getUeMobilityLevel() {
- return ueMobilityLevel;
- }
-
- public void setUeMobilityLevel(UeMobilityLevel ueMobilityLevel) {
- this.ueMobilityLevel = ueMobilityLevel;
- }
-
- public ResourceSharingLevel getResourceSharingLevel() {
- return resourceSharingLevel;
- }
-
- public void setResourceSharingLevel(ResourceSharingLevel resourceSharingLevel) {
- this.resourceSharingLevel = resourceSharingLevel;
- }
-
- public List<String> getSnssaiList() {
- return snssaiList;
- }
-
- public void setSnssaiList(List<String> snssaiList) {
- this.snssaiList = snssaiList;
- }
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java
new file mode 100644
index 0000000000..c64af1d958
--- /dev/null
+++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.beans.nsmf;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.ToString;
+import org.springframework.beans.BeanUtils;
+import java.io.Serializable;
+import java.util.Arrays;
+
+@Data
+@ToString
+public class SliceProfileAdapter implements Serializable {
+
+ private static final long serialVersionUID = -6412175980642584804L;
+
+ @JsonProperty(value = "sliceProfileId")
+ private String sliceProfileId;
+
+ @JsonProperty(value = "sNSSAI")
+ private String sNSSAIList = "";
+
+ @JsonProperty(value = "pLMNIdList")
+ private String pLMNIdList = "";
+
+ @JsonProperty(value = "maxNumberofUEs")
+ private long maxNumberofUEs;
+
+ @JsonProperty(value = "coverageAreaTAList")
+ private String coverageAreaTAList = "";
+
+ @JsonProperty(value = "latency")
+ private int latency;
+
+ @JsonProperty(value = "uEMobilityLevel")
+ private String uEMobilityLevel;
+
+ @JsonProperty(value = "resourceSharingLevel")
+ private String resourceSharingLevel;
+
+ @JsonProperty(value = "maxBandwidth")
+ private String bandwidth;
+
+ @JsonProperty(value = "sST")
+ private String sST;
+
+ @JsonProperty(value = "activityFactor")
+ private String activityFactor;
+
+ @JsonProperty(value = "survivalTime")
+ private String survivalTime;
+
+ public AnSliceProfile trans2AnProfile() {
+ AnSliceProfile anSliceProfile = new AnSliceProfile();
+ BeanUtils.copyProperties(this, anSliceProfile);
+ anSliceProfile.setSNSSAIList(Arrays.asList(this.sNSSAIList.split("\\|")));
+ anSliceProfile.setPLMNIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
+
+ String[] areas = this.coverageAreaTAList.split("\\|");
+ Integer[] areasRes = new Integer[areas.length];
+ for (int i = 0; i < areas.length; i++) {
+ areasRes[i] = str2Code(areas[i]);
+ }
+ anSliceProfile.setCoverageAreaTAList(Arrays.asList(areasRes));
+ anSliceProfile.setUEMobilityLevel(UeMobilityLevel.fromString(this.uEMobilityLevel));
+ anSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel));
+ AnPerfReq anPerfReq = new AnPerfReq();
+ // todo
+ anSliceProfile.setPerfReq(anPerfReq);
+ return anSliceProfile;
+ }
+
+ private Integer str2Code(String area) {
+ return area.hashCode() >> 16;
+ }
+
+ public CnSliceProfile trans2CnProfile() {
+ CnSliceProfile cnSliceProfile = new CnSliceProfile();
+ BeanUtils.copyProperties(this, cnSliceProfile);
+ cnSliceProfile.setSnssaiList(Arrays.asList(this.sNSSAIList.split("\\|")));
+ cnSliceProfile.setCoverageAreaTAList(Arrays.asList(this.coverageAreaTAList.split("\\|")));
+ cnSliceProfile.setPlmnIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
+ cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel));
+ PerfReq perfReq = new PerfReq();
+ // todo
+ cnSliceProfile.setPerfReq(perfReq);
+ return cnSliceProfile;
+ }
+
+ public TnSliceProfile trans2TnProfile() {
+ TnSliceProfile tnSliceProfile = new TnSliceProfile();
+ BeanUtils.copyProperties(this, tnSliceProfile);
+ tnSliceProfile.setSNSSAIList(Arrays.asList(this.sNSSAIList.split("\\|")));
+ tnSliceProfile.setPLMNIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
+ return tnSliceProfile;
+ }
+}
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 e97aa704eb..bfd4627b47 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,6 +19,7 @@
*/
package org.onap.so.beans.nsmf;
+import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.JsonObject;
import lombok.*;
@@ -56,15 +57,15 @@ public class SliceTaskParamsAdapter implements Serializable {
private TemplateInfo NSTInfo = new TemplateInfo();
- private SliceTaskInfo<TnSliceProfile> tnBHSliceTaskInfo = new SliceTaskInfo<>();
+ private SliceTaskInfo<SliceProfileAdapter> tnBHSliceTaskInfo = new SliceTaskInfo<>();
- private SliceTaskInfo<TnSliceProfile> tnMHSliceTaskInfo = new SliceTaskInfo<>();
+ private SliceTaskInfo<SliceProfileAdapter> tnMHSliceTaskInfo = new SliceTaskInfo<>();
- private SliceTaskInfo<TnSliceProfile> tnFHSliceTaskInfo = new SliceTaskInfo<>();
+ private SliceTaskInfo<SliceProfileAdapter> tnFHSliceTaskInfo = new SliceTaskInfo<>();
- private SliceTaskInfo<CnSliceProfile> cnSliceTaskInfo = new SliceTaskInfo<>();
+ private SliceTaskInfo<SliceProfileAdapter> cnSliceTaskInfo = new SliceTaskInfo<>();
- private SliceTaskInfo<AnSliceProfile> anSliceTaskInfo = new SliceTaskInfo<>();
+ private SliceTaskInfo<SliceProfileAdapter> anSliceTaskInfo = new SliceTaskInfo<>();
@SuppressWarnings("unchecked")
public void convertFromJson(String jsonString) throws IOException {
@@ -80,24 +81,24 @@ public class SliceTaskParamsAdapter implements Serializable {
this.setServiceProfile(replaceHeader(paramMap, "ServiceProfile."));
- TnSliceProfile tnBHSliceProfile = mapper.readValue(
- mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.BH.")), TnSliceProfile.class);
+ SliceProfileAdapter tnBHSliceProfile = mapper.readValue(
+ mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.BH.")), SliceProfileAdapter.class);
this.tnBHSliceTaskInfo.setSliceProfile(tnBHSliceProfile);
- TnSliceProfile tnMHSliceProfile = mapper.readValue(
- mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.MH.")), TnSliceProfile.class);
+ SliceProfileAdapter tnMHSliceProfile = mapper.readValue(
+ mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.MH.")), SliceProfileAdapter.class);
this.tnMHSliceTaskInfo.setSliceProfile(tnMHSliceProfile);
- TnSliceProfile tnFHSliceProfile = mapper.readValue(
- mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.FH.")), TnSliceProfile.class);
+ SliceProfileAdapter tnFHSliceProfile = mapper.readValue(
+ mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.FH.")), SliceProfileAdapter.class);
this.tnFHSliceTaskInfo.setSliceProfile(tnFHSliceProfile);
- CnSliceProfile cnSliceProfile = mapper.readValue(
- mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.CN.")), CnSliceProfile.class);
+ SliceProfileAdapter cnSliceProfile = mapper.readValue(
+ mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.CN.")), SliceProfileAdapter.class);
this.cnSliceTaskInfo.setSliceProfile(cnSliceProfile);
- AnSliceProfile anSliceProfile = mapper.readValue(
- mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.AN.")), AnSliceProfile.class);
+ SliceProfileAdapter anSliceProfile = mapper.readValue(
+ mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.AN.")), SliceProfileAdapter.class);
this.anSliceTaskInfo.setSliceProfile(anSliceProfile);
this.tnBHSliceTaskInfo.setSuggestNssiId(paramMap.get("TN.BH.SuggestNSSIId"));
@@ -148,33 +149,31 @@ public class SliceTaskParamsAdapter implements Serializable {
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());
+ String value = entry.getValue() == null ? "" : entry.getValue().toString();
+ jsonObject.addProperty("SliceProfile.AN." + entry.getKey(), value);
}
-
Map<String, Object> sliceProfileCn = bean2Map(cnSliceTaskInfo.getSliceProfile());
for (Map.Entry<String, Object> entry : sliceProfileCn.entrySet()) {
- jsonObject.addProperty("SliceProfile.CN." + entry.getKey(), entry.getValue().toString());
+ String value = entry.getValue() == null ? "" : entry.getValue().toString();
+ jsonObject.addProperty("SliceProfile.CN." + entry.getKey(), value);
}
-
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());
+ String value = entry.getValue() == null ? "" : entry.getValue().toString();
+ jsonObject.addProperty("SliceProfile.TN.BH." + entry.getKey(), value);
}
-
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());
+ String value = entry.getValue() == null ? "" : entry.getValue().toString();
+ jsonObject.addProperty("SliceProfile.TN.MH." + entry.getKey(), value);
}
-
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());
+ String value = entry.getValue() == null ? "" : entry.getValue().toString();
+ jsonObject.addProperty("SliceProfile.TN.FH." + entry.getKey(), value);
}
-
jsonObject.addProperty("TN.BH.SuggestNSSIId", tnBHSliceTaskInfo.getSuggestNssiId());
jsonObject.addProperty("TN.BH.SuggestNSSIName", tnBHSliceTaskInfo.getSuggestNssiName());
jsonObject.addProperty("TN.BH.progress", tnBHSliceTaskInfo.getProgress());
@@ -182,7 +181,6 @@ public class SliceTaskParamsAdapter implements Serializable {
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());
@@ -190,7 +188,6 @@ public class SliceTaskParamsAdapter implements Serializable {
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());
@@ -198,7 +195,6 @@ public class SliceTaskParamsAdapter implements Serializable {
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());
@@ -206,7 +202,6 @@ public class SliceTaskParamsAdapter implements Serializable {
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());
@@ -219,7 +214,7 @@ public class SliceTaskParamsAdapter implements Serializable {
/**
* change T t to {@link Map}
- *
+ *
* @param t input
* @param <T> Object
* @return {@link Map}
@@ -234,9 +229,18 @@ public class SliceTaskParamsAdapter implements Serializable {
Field[] fields = t.getClass().getDeclaredFields();
for (Field field : fields) {
String name = field.getName();
- Method method = t.getClass().getMethod("get" + name);
+ String key = name;
+ if (name == null || "".equals(name) || "serialVersionUID".equalsIgnoreCase(name)) {
+ continue;
+ }
+ JsonProperty annotation = field.getAnnotation(JsonProperty.class);
+ if (annotation != null && !annotation.value().equals(JsonProperty.USE_DEFAULT_NAME)) {
+ key = annotation.value();
+ }
+
+ Method method = t.getClass().getMethod("get" + name.substring(0, 1).toUpperCase() + name.substring(1));
Object value = method.invoke(t);
- resMap.put(name, value);
+ resMap.put(key, value);
}
} catch (Exception e) {
@@ -247,7 +251,7 @@ public class SliceTaskParamsAdapter implements Serializable {
/**
* replace of slice profile
- *
+ *
* @param paramMap params map
* @param header starts of key
* @return Map
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java
index ccd6001957..1effb4e972 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java
@@ -21,7 +21,9 @@
package org.onap.so.beans.nsmf;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
+import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
@@ -29,8 +31,15 @@ public class TnSliceProfile {
private String sliceProfileId;
+ @JsonProperty(value = "maxBandwidth")
private String bandwidth;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private int latency;
+
+ @JsonProperty(value = "sNSSAIList", required = true)
+ private List<String> sNSSAIList;
+
+ @JsonProperty(value = "pLMNIdList", required = true)
+ private List<String> pLMNIdList;
}