summaryrefslogtreecommitdiffstats
path: root/common/src/main
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-01-28 13:53:02 +0000
committerGerrit Code Review <gerrit@onap.org>2019-01-28 13:53:02 +0000
commit1f57cd06a3bf1deeb277430dba310088368c82fa (patch)
tree63015921567bdea04574c4b528227020bf600bce /common/src/main
parentcfd23fabab7a07981a0f0d23797b922cdaf6e2cb (diff)
parent1e05b82f5633a6430761e053701264dd4ec4468b (diff)
Merge "add custom object support to a ai client"
Diffstat (limited to 'common/src/main')
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java8
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java49
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIObjectType.java166
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/Relationships.java6
4 files changed, 132 insertions, 97 deletions
diff --git a/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java b/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java
index 242fd41b19..9d2c3a8b1b 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java
@@ -22,10 +22,10 @@ package org.onap.so.client.aai;
public class AAINamespaceConstants {
- protected static final String CLOUD_INFRASTRUCTURE = "/cloud-infrastructure";
- protected static final String NETWORK = "/network";
- protected static final String BUSINESS = "/business";
- protected static final String SERVICE_DESIGN_AND_CREATION = "/service-design-and-creation";
+ public static final String CLOUD_INFRASTRUCTURE = "/cloud-infrastructure";
+ public static final String NETWORK = "/network";
+ public static final String BUSINESS = "/business";
+ public static final String SERVICE_DESIGN_AND_CREATION = "/service-design-and-creation";
}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java
index b3bfcc1648..12e0ebe691 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java
@@ -20,38 +20,43 @@
package org.onap.so.client.aai;
-import org.onap.aai.domain.yang.NetworkTechnologies;
+import java.io.Serializable;
+
import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals;
import org.onap.so.constants.Defaults;
import com.google.common.base.CaseFormat;
-public enum AAIObjectPlurals implements GraphInventoryObjectPlurals {
+public class AAIObjectPlurals implements GraphInventoryObjectPlurals, Serializable {
- CUSTOMER(AAINamespaceConstants.BUSINESS, "/customers"),
- GENERIC_VNF(AAINamespaceConstants.NETWORK, "/generic-vnfs"),
- PORT_GROUP(AAIObjectType.VCE.uriTemplate(), "/port-groups"),
- PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers"),
- P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces"),
- L3_NETWORK(AAINamespaceConstants.NETWORK, "/l3-networks"),
- NETWORK_POLICY(AAINamespaceConstants.NETWORK, "/network-policies"),
- VPN_BINDING(AAINamespaceConstants.NETWORK, "/vpn-bindings"),
- SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions"),
- SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances"),
- OWNING_ENTITY(AAINamespaceConstants.BUSINESS, "/owning-entities"),
- VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups"),
- AVAILIBILITY_ZONE(AAIObjectType.CLOUD_REGION.uriTemplate(), "/availability-zones"),
- VF_MODULE(AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules"),
- CONFIGURATION(AAINamespaceConstants.NETWORK, "/configurations"),
- DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants"),
- NETWORK_TECHNOLOGY(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/network-technologies"),
- LOGICAL_LINK(AAINamespaceConstants.NETWORK, "/logical-links");
+ private static final long serialVersionUID = 5312713297525740746L;
+
+ public static final AAIObjectPlurals CUSTOMER = new AAIObjectPlurals(AAINamespaceConstants.BUSINESS, "/customers", "customer");
+ public static final AAIObjectPlurals GENERIC_VNF = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/generic-vnfs", "generic-vnf");
+ public static final AAIObjectPlurals PORT_GROUP = new AAIObjectPlurals(AAIObjectType.VCE.uriTemplate(), "/port-groups", "port-group");
+ public static final AAIObjectPlurals PSERVER = new AAIObjectPlurals(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers", "pserver");
+ public static final AAIObjectPlurals P_INTERFACE = new AAIObjectPlurals(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces", "p-interface");
+ public static final AAIObjectPlurals L3_NETWORK = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/l3-networks", "l3-network");
+ public static final AAIObjectPlurals NETWORK_POLICY = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/network-policies", "network-policy");
+ public static final AAIObjectPlurals VPN_BINDING = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/vpn-bindings", "vpn-binding");
+ public static final AAIObjectPlurals SERVICE_SUBSCRIPTION = new AAIObjectPlurals(AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions", "service-subscription");
+ public static final AAIObjectPlurals SERVICE_INSTANCE = new AAIObjectPlurals(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances", "service-instance");
+ public static final AAIObjectPlurals OWNING_ENTITY = new AAIObjectPlurals(AAINamespaceConstants.BUSINESS, "/owning-entities", "owning-entity");
+ public static final AAIObjectPlurals VOLUME_GROUP = new AAIObjectPlurals(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups", "volume-group");
+ public static final AAIObjectPlurals AVAILIBILITY_ZONE = new AAIObjectPlurals(AAIObjectType.CLOUD_REGION.uriTemplate(), "/availability-zones", "availability-zone");
+ public static final AAIObjectPlurals VF_MODULE = new AAIObjectPlurals(AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules", "vf-module");
+ public static final AAIObjectPlurals CONFIGURATION = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/configurations", "configuration");
+ public static final AAIObjectPlurals DEFAULT_TENANT = new AAIObjectPlurals(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants", "default-tenant");
+ public static final AAIObjectPlurals NETWORK_TECHNOLOGY = new AAIObjectPlurals(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/network-technologies", "network-technology");
+ public static final AAIObjectPlurals LOGICAL_LINK = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/logical-links", "logical-link");
private final String uriTemplate;
private final String partialUri;
- private AAIObjectPlurals(String parentUri, String partialUri) {
+ private final String name;
+ protected AAIObjectPlurals(String parentUri, String partialUri, String name) {
this.uriTemplate = parentUri + partialUri;
this.partialUri = partialUri;
+ this.name = name;
}
@Override
@@ -75,6 +80,6 @@ public enum AAIObjectPlurals implements GraphInventoryObjectPlurals {
}
@Override
public String typeName(CaseFormat format) {
- return CaseFormat.UPPER_UNDERSCORE.to(format, this.name());
+ return CaseFormat.LOWER_HYPHEN.to(format, this.name);
}
}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java
index 0237f91833..a6a9acfadd 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java
@@ -20,18 +20,25 @@
package org.onap.so.client.aai;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.net.URL;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Priority;
import org.onap.aai.annotations.Metadata;
-import org.onap.aai.domain.yang.AllottedResource;
import org.onap.aai.domain.yang.AggregateRoute;
+import org.onap.aai.domain.yang.AllottedResource;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.Collection;
import org.onap.aai.domain.yang.Complex;
import org.onap.aai.domain.yang.Configuration;
import org.onap.aai.domain.yang.Connector;
import org.onap.aai.domain.yang.Customer;
+import org.onap.aai.domain.yang.Device;
import org.onap.aai.domain.yang.ExtAaiNetwork;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.InstanceGroup;
@@ -45,6 +52,7 @@ import org.onap.aai.domain.yang.OwningEntity;
import org.onap.aai.domain.yang.PInterface;
import org.onap.aai.domain.yang.PhysicalLink;
import org.onap.aai.domain.yang.Platform;
+import org.onap.aai.domain.yang.Pnf;
import org.onap.aai.domain.yang.PortGroup;
import org.onap.aai.domain.yang.Project;
import org.onap.aai.domain.yang.Pserver;
@@ -52,7 +60,6 @@ import org.onap.aai.domain.yang.RouteTableReference;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.ServiceSubscription;
import org.onap.aai.domain.yang.SpPartner;
-import org.onap.aai.domain.yang.Device;
import org.onap.aai.domain.yang.Subnet;
import org.onap.aai.domain.yang.Tenant;
import org.onap.aai.domain.yang.TunnelXconnect;
@@ -65,77 +72,115 @@ import org.onap.aai.domain.yang.VpnBinding;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.client.graphinventory.GraphInventoryObjectType;
import org.onap.so.constants.Defaults;
+import org.reflections.Reflections;
+import org.reflections.scanners.SubTypesScanner;
+import org.reflections.util.ClasspathHelper;
+import org.reflections.util.ConfigurationBuilder;
import com.google.common.base.CaseFormat;
-public enum AAIObjectType implements GraphInventoryObjectType {
+public class AAIObjectType implements GraphInventoryObjectType, Serializable {
- DEFAULT_CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/{cloud-region-id}"),
- CUSTOMER(AAINamespaceConstants.BUSINESS, Customer.class),
- GENERIC_QUERY("/search", "/generic-query"),
- BULK_PROCESS("/bulkprocess", ""),
- SINGLE_TRANSACTION("/bulk/single-transaction", ""),
- GENERIC_VNF(AAINamespaceConstants.NETWORK, GenericVnf.class),
- VF_MODULE(AAIObjectType.GENERIC_VNF.uriTemplate(), VfModule.class),
- L3_NETWORK(AAINamespaceConstants.NETWORK, L3Network.class),
- NETWORK_POLICY(AAINamespaceConstants.NETWORK, NetworkPolicy.class),
- NODES_QUERY("/search", "/nodes-query"),
- CUSTOM_QUERY("/query", ""),
- ROUTE_TABLE_REFERENCE(AAINamespaceConstants.NETWORK, RouteTableReference.class),
- DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants/tenant/{tenant-id}"),
- VCE(AAINamespaceConstants.NETWORK, Vce.class),
- PORT_GROUP(AAIObjectType.VCE.uriTemplate(), PortGroup.class),
- VPN_BINDING(AAINamespaceConstants.NETWORK, VpnBinding.class),
- CONFIGURATION(AAINamespaceConstants.NETWORK, Configuration.class),
- PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Pserver.class),
- SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), ServiceSubscription.class),
- SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), ServiceInstance.class),
- PROJECT(AAINamespaceConstants.BUSINESS, Project.class),
- LINE_OF_BUSINESS(AAINamespaceConstants.BUSINESS, LineOfBusiness.class),
- PLATFORM(AAINamespaceConstants.BUSINESS, Platform.class),
- OWNING_ENTITY(AAINamespaceConstants.BUSINESS, OwningEntity.class),
- ALLOTTED_RESOURCE(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), AllottedResource.class),
- PNF(AAINamespaceConstants.NETWORK, "/pnfs/pnf/{pnf-name}"),
- OPERATIONAL_ENVIRONMENT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, OperationalEnvironment.class),
- CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, CloudRegion.class),
- TENANT(AAIObjectType.CLOUD_REGION.uriTemplate(), Tenant.class),
- VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), VolumeGroup.class),
- VSERVER(AAIObjectType.TENANT.uriTemplate(), Vserver.class),
- MODEL_VER(AAINamespaceConstants.SERVICE_DESIGN_AND_CREATION + "/models/model/{model-invariant-id}", ModelVer.class),
- TUNNEL_XCONNECT(AAIObjectType.ALLOTTED_RESOURCE.uriTemplate(), TunnelXconnect.class),
- P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), PInterface.class),
- PHYSICAL_LINK(AAINamespaceConstants.NETWORK, PhysicalLink.class),
- INSTANCE_GROUP(AAINamespaceConstants.NETWORK, InstanceGroup.class),
- COLLECTION(AAINamespaceConstants.NETWORK, Collection.class),
- VNFC(AAINamespaceConstants.NETWORK, Vnfc.class),
- VLAN_TAG(AAINamespaceConstants.NETWORK, VlanTag.class),
- COMPLEX(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Complex.class),
- CONNECTOR(AAINamespaceConstants.BUSINESS, Connector.class),
- NETWORK_TECHNOLOGY(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, NetworkTechnology.class),
- SUBNET(AAIObjectType.L3_NETWORK.uriTemplate(), Subnet.class),
- SP_PARTNER(AAINamespaceConstants.BUSINESS, SpPartner.class),
- DEVICE(AAINamespaceConstants.NETWORK, Device.class),
- EXT_AAI_NETWORK(AAINamespaceConstants.NETWORK, ExtAaiNetwork.class),
- AGGREGATE_ROUTE(AAINamespaceConstants.NETWORK, AggregateRoute.class),
- UNKNOWN("", "");
+ private static final long serialVersionUID = -2877184776691514600L;
+ private static Map<String, AAIObjectType> map = new HashMap<>();
+
+ public static final AAIObjectType DEFAULT_CLOUD_REGION = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/{cloud-region-id}", "default-cloud-region");
+ public static final AAIObjectType CUSTOMER = new AAIObjectType(AAINamespaceConstants.BUSINESS, Customer.class);
+ public static final AAIObjectType GENERIC_QUERY = new AAIObjectType("/search", "/generic-query", "generic-query");
+ public static final AAIObjectType BULK_PROCESS = new AAIObjectType("/bulkprocess", "", "bulkprocess");
+ public static final AAIObjectType SINGLE_TRANSACTION = new AAIObjectType("/bulk/single-transaction", "", "single-transaction");
+ public static final AAIObjectType GENERIC_VNF = new AAIObjectType(AAINamespaceConstants.NETWORK, GenericVnf.class);
+ public static final AAIObjectType VF_MODULE = new AAIObjectType(AAIObjectType.GENERIC_VNF.uriTemplate(), VfModule.class);
+ public static final AAIObjectType L3_NETWORK = new AAIObjectType(AAINamespaceConstants.NETWORK, L3Network.class);
+ public static final AAIObjectType NETWORK_POLICY = new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkPolicy.class);
+ public static final AAIObjectType NODES_QUERY = new AAIObjectType("/search", "/nodes-query", "nodes-query");
+ public static final AAIObjectType CUSTOM_QUERY = new AAIObjectType("/query", "", "query");
+ public static final AAIObjectType ROUTE_TABLE_REFERENCE = new AAIObjectType(AAINamespaceConstants.NETWORK, RouteTableReference.class);
+ public static final AAIObjectType DEFAULT_TENANT = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants/tenant/{tenant-id}", "default-tenant");
+ public static final AAIObjectType VCE = new AAIObjectType(AAINamespaceConstants.NETWORK, Vce.class);
+ public static final AAIObjectType PORT_GROUP = new AAIObjectType(AAIObjectType.VCE.uriTemplate(), PortGroup.class);
+ public static final AAIObjectType VPN_BINDING = new AAIObjectType(AAINamespaceConstants.NETWORK, VpnBinding.class);
+ public static final AAIObjectType CONFIGURATION = new AAIObjectType(AAINamespaceConstants.NETWORK, Configuration.class);
+ public static final AAIObjectType PSERVER = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Pserver.class);
+ public static final AAIObjectType SERVICE_SUBSCRIPTION = new AAIObjectType(AAIObjectType.CUSTOMER.uriTemplate(), ServiceSubscription.class);
+ public static final AAIObjectType SERVICE_INSTANCE = new AAIObjectType(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), ServiceInstance.class);
+ public static final AAIObjectType PROJECT = new AAIObjectType(AAINamespaceConstants.BUSINESS, Project.class);
+ public static final AAIObjectType LINE_OF_BUSINESS = new AAIObjectType(AAINamespaceConstants.BUSINESS, LineOfBusiness.class);
+ public static final AAIObjectType PLATFORM = new AAIObjectType(AAINamespaceConstants.BUSINESS, Platform.class);
+ public static final AAIObjectType OWNING_ENTITY = new AAIObjectType(AAINamespaceConstants.BUSINESS, OwningEntity.class);
+ public static final AAIObjectType ALLOTTED_RESOURCE = new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), AllottedResource.class);
+ public static final AAIObjectType PNF = new AAIObjectType(AAINamespaceConstants.NETWORK, Pnf.class);
+ public static final AAIObjectType OPERATIONAL_ENVIRONMENT = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, OperationalEnvironment.class);
+ public static final AAIObjectType CLOUD_REGION = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, CloudRegion.class);
+ public static final AAIObjectType TENANT = new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), Tenant.class);
+ public static final AAIObjectType VOLUME_GROUP = new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), VolumeGroup.class);
+ public static final AAIObjectType VSERVER = new AAIObjectType(AAIObjectType.TENANT.uriTemplate(), Vserver.class);
+ public static final AAIObjectType MODEL_VER = new AAIObjectType(AAINamespaceConstants.SERVICE_DESIGN_AND_CREATION + "/models/model/{model-invariant-id}", ModelVer.class);
+ public static final AAIObjectType TUNNEL_XCONNECT = new AAIObjectType(AAIObjectType.ALLOTTED_RESOURCE.uriTemplate(), TunnelXconnect.class);
+ public static final AAIObjectType P_INTERFACE = new AAIObjectType(AAIObjectType.PSERVER.uriTemplate(), PInterface.class);
+ public static final AAIObjectType PHYSICAL_LINK = new AAIObjectType(AAINamespaceConstants.NETWORK, PhysicalLink.class);
+ public static final AAIObjectType INSTANCE_GROUP = new AAIObjectType(AAINamespaceConstants.NETWORK, InstanceGroup.class);
+ public static final AAIObjectType COLLECTION = new AAIObjectType(AAINamespaceConstants.NETWORK, Collection.class);
+ public static final AAIObjectType VNFC = new AAIObjectType(AAINamespaceConstants.NETWORK, Vnfc.class);
+ public static final AAIObjectType VLAN_TAG = new AAIObjectType(AAINamespaceConstants.NETWORK, VlanTag.class);
+ public static final AAIObjectType COMPLEX = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Complex.class);
+ public static final AAIObjectType CONNECTOR = new AAIObjectType(AAINamespaceConstants.BUSINESS, Connector.class);
+ public static final AAIObjectType NETWORK_TECHNOLOGY = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, NetworkTechnology.class);
+ public static final AAIObjectType SUBNET = new AAIObjectType(AAIObjectType.L3_NETWORK.uriTemplate(), Subnet.class);
+ public static final AAIObjectType SP_PARTNER = new AAIObjectType(AAINamespaceConstants.BUSINESS, SpPartner.class);
+ public static final AAIObjectType DEVICE = new AAIObjectType(AAINamespaceConstants.NETWORK, Device.class);
+ public static final AAIObjectType EXT_AAI_NETWORK = new AAIObjectType(AAINamespaceConstants.NETWORK, ExtAaiNetwork.class);
+ public static final AAIObjectType AGGREGATE_ROUTE = new AAIObjectType(AAINamespaceConstants.NETWORK, AggregateRoute.class);
+ public static final AAIObjectType UNKNOWN = new AAIObjectType("", "", "unknown");
private final String uriTemplate;
private final String parentUri;
private final String partialUri;
private final Class<?> aaiObjectClass;
- private static Map<String, AAIObjectType> map = new HashMap<>();
- private AAIObjectType(String parentUri, String partialUri) {
+ private final String name;
+
+ static {
+ /* Locate any AAIObjectTypes on the classpath and add them to our map */
+ java.util.Collection<URL> packages = ClasspathHelper.forPackage("");
+ Reflections r = new Reflections(new ConfigurationBuilder().setUrls(packages).setScanners(new SubTypesScanner()));
+
+ Set<Class<? extends AAIObjectType>> resources =
+ r.getSubTypesOf(AAIObjectType.class);
+ try {
+ for (Class<? extends AAIObjectType> customTypeClass : resources) {
+ AAIObjectType customType;
+ customType = customTypeClass.newInstance();
+ }
+ } catch (InstantiationException | IllegalAccessException e) {
+ }
+ }
+ protected AAIObjectType() {
+ this.parentUri = null;
+ this.partialUri = null;
+ this.uriTemplate = null;
+ this.aaiObjectClass = null;
+ this.name = null;
+ }
+ protected AAIObjectType(String parentUri, String partialUri, String name) {
this.parentUri = parentUri;
this.partialUri = partialUri;
this.uriTemplate = parentUri + partialUri;
this.aaiObjectClass = null;
+ this.name = name;
+ if (!AAIObjectType.map.containsKey(name)) {
+ AAIObjectType.map.put(name, this);
+ }
}
- private AAIObjectType(String parentUri, Class<?> aaiObjectClass) {
+ protected AAIObjectType(String parentUri, Class<?> aaiObjectClass) {
this.parentUri = parentUri;
this.partialUri = removeParentUri(aaiObjectClass, parentUri);
this.uriTemplate = parentUri + partialUri;
this.aaiObjectClass = aaiObjectClass;
+ this.name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, aaiObjectClass.getSimpleName());
+ if (!AAIObjectType.map.containsKey(name)) {
+ AAIObjectType.map.put(name, this);
+ }
}
@Override
@@ -144,12 +189,6 @@ public enum AAIObjectType implements GraphInventoryObjectType {
}
public static AAIObjectType fromTypeName(String name) {
- if (map.isEmpty()) {
- for (AAIObjectType type : AAIObjectType.values()) {
- map.put(type.typeName(), type);
- }
- }
-
if (map.containsKey(name)) {
return map.get(name);
} else {
@@ -162,12 +201,7 @@ public enum AAIObjectType implements GraphInventoryObjectType {
}
@Override
public String typeName(CaseFormat format) {
- String enumName = this.name();
- if (this.equals(AAIObjectType.DEFAULT_CLOUD_REGION) || this.equals(AAIObjectType.DEFAULT_TENANT)) {
- enumName = enumName.replace("DEFAULT_", "");
- }
-
- return CaseFormat.UPPER_UNDERSCORE.to(format, enumName);
+ return CaseFormat.LOWER_HYPHEN.to(format, this.name.replace("default-", ""));
}
@Override
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java b/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java
index bab145b3fd..e907bc97d7 100644
--- a/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java
+++ b/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java
@@ -91,11 +91,7 @@ public class Relationships {
final String relatedTo = (String)relationship.get("related-to");
if (p.test(relatedTo)) {
AAIObjectType type;
- try {
- type = AAIObjectType.valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, relatedTo));
- } catch (IllegalArgumentException e) {
- type = AAIObjectType.UNKNOWN;
- }
+ type = AAIObjectType.fromTypeName(relatedTo);
final String relatedLink = (String)relationship.get("related-link");
result.add(AAIUriFactory.createResourceFromExistingURI(type, UriBuilder.fromPath(relatedLink).build()));