return data.trim().replaceAll("[^0-9]", "");
}
+ public static String getRequirement(JsonArray requirements, String key) {
+ for (int i = 0; i < requirements.size(); i++) {
+ JsonElement requirement = requirements.get(i);
+ Map.Entry<String, JsonElement> next = requirement.getAsJsonObject().entrySet().iterator().next();
+ String s = next.getKey();
+ if (key.equals(s)) {
+ return next.getValue().getAsString();
+ }
+ }
+ return null;
+ }
+
/**
* @param cbamVnfd the CBAM VNFD
* @return the converted ONAP VNFD
"topology_template:\n" +
" inputs:\n" +
" etsi_config:\n" +
- " type: string\n"+
- " description: The ETSI configuration\n"+
+ " type: string\n" +
+ " description: The ETSI configuration\n" +
" node_templates:\n";
}
private String buildEcp(String name, JsonElement ecp, Set<Map.Entry<String, JsonElement>> nodes) {
if (ecp.getAsJsonObject().has(REQUIREMENTS)) {
- String icpName = getIcpName(ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray());
+ String icpName = getRequirement(ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "internal_connection_point");
if (icpName != null) {
return buildEcpInternal(name, icpName, nodes);
} else {
private String buildEcpInternal(String ecpName, String icpName, Set<Map.Entry<String, JsonElement>> nodes) {
JsonObject icpNode = get(icpName, nodes).getAsJsonObject();
if (icpNode.has(REQUIREMENTS)) {
- String vdu = getVduOfIcp(icpNode.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray());
+ String vdu = getRequirement(icpNode.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "virtual_binding");
//internal connection point is bound to VDU
if (vdu != null) {
return buildVduCpd(ecpName, vdu, child(icpNode, PROPERTIES));
return "";
}
- private String getVduOfIcp(JsonArray icpRequirements) {
- String vdu = null;
- for (int i = 0; i < icpRequirements.size(); i++) {
- JsonElement requirement = icpRequirements.get(i);
- Map.Entry<String, JsonElement> next = requirement.getAsJsonObject().entrySet().iterator().next();
- String s = next.getKey();
- if ("virtual_binding".equals(s)) {
- vdu = next.getValue().getAsString();
- }
- }
- return vdu;
- }
-
- private String getIcpName(JsonArray requirements) {
- String icpName = null;
- for (int i = 0; i < requirements.size(); i++) {
- JsonElement requirement = requirements.get(i);
- Map.Entry<String, JsonElement> next = requirement.getAsJsonObject().entrySet().iterator().next();
- String s = next.getKey();
- if ("internal_connection_point".equals(s)) {
- icpName = next.getValue().getAsString();
- }
- }
- return icpName;
- }
-
private String buildIcp(String name, JsonObject icp) {
if (icp.has(REQUIREMENTS)) {
JsonArray requirements = icp.get(REQUIREMENTS).getAsJsonArray();
- String vdu = null;
- String vl = null;
- for (int i = 0; i < requirements.size(); i++) {
- JsonElement requirement = requirements.get(i);
- Map.Entry<String, JsonElement> next = requirement.getAsJsonObject().entrySet().iterator().next();
- String s = next.getKey();
- if ("virtual_binding".equals(s)) {
- vdu = next.getValue().getAsString();
- } else if ("virtual_link".equals(s)) {
- vl = next.getValue().getAsString();
- }
- }
+ String vdu = getRequirement(requirements, "virtual_binding");
+ String vl = getRequirement(requirements, "virtual_link");
if (vdu == null) {
logger.warn("The {} internal connection point does not have a VDU", name);
} else if (vl == null) {