diff options
Diffstat (limited to 'common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model')
25 files changed, 1281 insertions, 0 deletions
diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/AllotedResource.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/AllotedResource.java new file mode 100644 index 0000000000..c6389392f6 --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/AllotedResource.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.Model; + +@Model(widget = Widget.Type.ALLOTTED_RESOURCE, cardinality = Cardinality.UNBOUNDED, + dataDeleteFlag = true) +public class AllotedResource extends Resource { +} diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/AllotedResourceWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/AllotedResourceWidget.java new file mode 100644 index 0000000000..88cdaa6af1 --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/AllotedResourceWidget.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.Model; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.ModelWidget; + + +@Model(widget = Widget.Type.ALLOTTED_RESOURCE, cardinality + = Cardinality.UNBOUNDED, dataDeleteFlag = true) +@ModelWidget(type = ModelType.WIDGET, name = "allotted-resource") +public class AllotedResourceWidget extends ResourceWidget { +} diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/FlavorWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/FlavorWidget.java new file mode 100644 index 0000000000..a427918bff --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/FlavorWidget.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.Model; +import org.onap.sdc.generator.aai.types.ModelWidget; + +@Model(widget = Widget.Type.FLAVOR, cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = false) +@ModelWidget(type = ModelType.WIDGET, name = "flavor") +public class FlavorWidget extends ResourceWidget { + +} diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/ImageWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/ImageWidget.java new file mode 100644 index 0000000000..52a52fc71e --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/ImageWidget.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.Model; +import org.onap.sdc.generator.aai.types.ModelWidget; + +@Model(widget = Widget.Type.IMAGE, cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = false) +@ModelWidget(type = ModelType.WIDGET, name = "image") +public class ImageWidget extends ResourceWidget { + +} + diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/L3Network.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/L3Network.java new file mode 100644 index 0000000000..98713c086b --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/L3Network.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.Model; + +@Model(widget = Widget.Type.L3_NET, cardinality = Cardinality + .UNBOUNDED, dataDeleteFlag = false) +public class L3Network extends Resource{ +} diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/L3NetworkWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/L3NetworkWidget.java new file mode 100644 index 0000000000..4b59e99bc9 --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/L3NetworkWidget.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.Model; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.ModelWidget; + +@Model(widget = Widget.Type.L3_NET, + cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = true) +@ModelWidget(type = ModelType.WIDGET, name = "l3-network") +public class L3NetworkWidget extends Widget { + +} + diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/LIntfWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/LIntfWidget.java new file mode 100644 index 0000000000..de62624392 --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/LIntfWidget.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.Model; +import org.onap.sdc.generator.aai.types.ModelWidget; + +@Model(widget = Widget.Type.LINT, cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = true) +@ModelWidget(type = ModelType.WIDGET, name = "l-interface") +public class LIntfWidget extends ResourceWidget { + +} diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Model.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Model.java new file mode 100644 index 0000000000..ac8dffae02 --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Model.java @@ -0,0 +1,259 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.data.GeneratorConstants; +import org.onap.sdc.generator.error.IllegalAccessException; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +public abstract class Model { + + protected Set<Resource> resources = new HashSet<>(); + protected Set<Widget> widgets = new HashSet<>(); + private String modelId; + private String modelName; + private ModelType modelType; + private String modelVersion; + private String modelNameVersionId; + private String modelDescription; + + /** + * Gets model for. + * + * @param toscaType the tosca type + * @return the model for + */ + public static Model getModelFor(String toscaType) { + + Model modelToBeReturned = null; + while (toscaType != null && toscaType.lastIndexOf(".") != -1 && modelToBeReturned == null) { + + switch (toscaType) { + + case "org.openecomp.resource.vf.allottedResource": + modelToBeReturned = new AllotedResource(); + break; + case "org.openecomp.resource.vfc.AllottedResource": + modelToBeReturned = new ProvidingService(); + break; + case "org.openecomp.resource.vfc": + modelToBeReturned = new VServerWidget(); + break; + case "org.openecomp.resource.cp": + case "org.openecomp.cp": + modelToBeReturned = new LIntfWidget(); + break; + case "org.openecomp.resource.vl": + modelToBeReturned = new L3Network(); + break; + case "org.openecomp.resource.vf": + modelToBeReturned = new VirtualFunction(); + break; + case "org.openecomp.groups.vfmodule": + case "org.openecomp.groups.VfModule": + modelToBeReturned = new VfModule(); + break; + case "org.openecomp.resource.vfc.nodes.heat.cinder": + modelToBeReturned = new VolumeWidget(); + break; + default: + modelToBeReturned = null; + break; + } + + toscaType = toscaType.substring(0, toscaType.lastIndexOf(".")); + } + + return modelToBeReturned; + } + + public abstract boolean addResource(Resource resource); + + public abstract boolean addWidget(Widget resource); + + /** + * Gets widget version id. + * + * @return the widget version id + */ + public String getWidgetId() { + org.onap.sdc.generator.aai.types.Model model = + this.getClass().getAnnotation(org.onap.sdc.generator.aai.types.Model.class); + return Widget.getWidget(model.widget()).getId(); + } + + /** + * Gets invariant id. + * + * @return the invariant id + */ + public String getWidgetInvariantId() { + org.onap.sdc.generator.aai.types.Model model = + this.getClass().getAnnotation(org.onap.sdc.generator.aai.types.Model.class); + return Widget.getWidget(model.widget()).getWidgetId(); + } + + /** + * Gets delete flag. + * + * @return the delete flag + */ + public boolean getDeleteFlag() { + org.onap.sdc.generator.aai.types.Model model = + this.getClass().getAnnotation(org.onap.sdc.generator.aai.types.Model.class); + return model.dataDeleteFlag(); + } + + /** + * Gets cardinality. + * + * @return the cardinality + */ + public Cardinality getCardinality() { + org.onap.sdc.generator.aai.types.Model model = + this.getClass().getAnnotation(org.onap.sdc.generator.aai.types.Model.class); + return model.cardinality(); + } + + public abstract Widget.Type getWidgetType(); + + public String getModelId() { + checkSupported(); + return modelId; + } + + /** + * Gets model type. + * + * @return the model type + */ + public ModelType getModelType() { + //checkSupported(); + if (this instanceof Service) { + return ModelType.SERVICE; + } else if (this instanceof Resource) { + return ModelType.RESOURCE; + } else if (this instanceof Widget) { + return ModelType.WIDGET; + } else { + return null; + } + } + + public String getModelName() { + //checkSupported(); + return modelName; + } + + public String getModelVersion() { + //checkSupported(); + return modelVersion; + } + + public String getModelNameVersionId() { + checkSupported(); + return modelNameVersionId; + } + + public String getModelDescription() { + //checkSupported(); + return modelDescription; + } + + /** + * Populate model identification information. + * + * @param modelIdentInfo the model ident info + */ + public void populateModelIdentificationInformation(Map<String, String> modelIdentInfo) { + Iterator<String> iter = modelIdentInfo.keySet().iterator(); + String property; + while (iter.hasNext()) { + switch (property = iter.next()) { + + case "vfModuleModelInvariantUUID": + case "serviceInvariantUUID": + case "resourceInvariantUUID": + case "invariantUUID": + case "providing_service_invariant_uuid": + modelId = modelIdentInfo.get(property); + break; + case "vfModuleModelUUID": + case "resourceUUID": + case "serviceUUID": + case "UUID": + case "providing_service_uuid": + modelNameVersionId = modelIdentInfo.get(property); + break; + case "vfModuleModelVersion": + case "serviceVersion": + case "resourceversion": + case "version": + modelVersion = modelIdentInfo.get(property); + break; + case "vfModuleModelName": + case "serviceName": + case "resourceName": + case "name": + modelName = modelIdentInfo.get(property); + break; + case "serviceDescription": + case "resourceDescription": + case "vf_module_description": + case "description": + modelDescription = modelIdentInfo.get(property); + break; + case "providing_service_name": + modelName = modelIdentInfo.get(property); + modelDescription = modelIdentInfo.get(property); + break; + default: + break; + } + property = null; + } + + + + } + + public Set<Resource> getResources() { + return resources; + } + + public Set<Widget> getWidgets() { + return widgets; + } + + private void checkSupported() throws IllegalAccessException { + if (this instanceof Widget) { + throw new IllegalAccessException(GeneratorConstants + .GENERATOR_AAI_ERROR_UNSUPPORTED_WIDGET_OPERATION); + } + } + +} diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/OamNetwork.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/OamNetwork.java new file mode 100644 index 0000000000..d51bf7af96 --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/OamNetwork.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.ModelWidget; +import org.onap.sdc.generator.aai.types.Model; + +@Model(widget = Widget.Type.L3_NET, cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = true) +@ModelWidget(type = ModelType.WIDGET, name = "oam-network") +public class OamNetwork extends Widget { +} + diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/ProvidingService.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/ProvidingService.java new file mode 100644 index 0000000000..3f44fe9b54 --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/ProvidingService.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.Model; + +@Model(widget = Widget.Type.ALLOTTED_RESOURCE, cardinality = Cardinality + .UNBOUNDED, + dataDeleteFlag = false) +public class ProvidingService extends Resource { +} diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Resource.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Resource.java new file mode 100644 index 0000000000..6c7cbc7548 --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Resource.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +public class Resource extends Model { + + @Override + public int hashCode() { + return getModelNameVersionId().hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof Resource) { + return getModelNameVersionId().equals(((Resource) obj).getModelNameVersionId()); + } + return false; + } + + public boolean addResource(Resource resource) { + return resources.add(resource); + } + + public boolean addWidget(Widget widget) { + return widgets.add(widget); + } + + @Override + public Widget.Type getWidgetType() { + org.onap.sdc.generator.aai.types.Model model = + this.getClass().getAnnotation(org.onap.sdc.generator.aai.types.Model.class); + return model.widget(); + } +} diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/ResourceWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/ResourceWidget.java new file mode 100644 index 0000000000..24975a2a9f --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/ResourceWidget.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +public class ResourceWidget extends Widget { + +} + diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Service.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Service.java new file mode 100644 index 0000000000..f71ff91f3e --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Service.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; + +@org.onap.sdc.generator.aai.types.Model(widget = Widget.Type.SERVICE, + cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = true) +public class Service extends Model { + + public boolean addResource(Resource resource) { + return resources.add(resource); + } + + public boolean addWidget(Widget widget) { + return widgets.add(widget); + } + + @Override + public Widget.Type getWidgetType() { + return null; + } + +} + diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/ServiceWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/ServiceWidget.java new file mode 100644 index 0000000000..f6eb5fab53 --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/ServiceWidget.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.ModelWidget; + +@ModelWidget(type = ModelType.WIDGET, name = "service-instance") +public class ServiceWidget extends Widget { + +} + diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/TenantWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/TenantWidget.java new file mode 100644 index 0000000000..23e57be12f --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/TenantWidget.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.Model; +import org.onap.sdc.generator.aai.types.ModelWidget; + +@Model(widget = Widget.Type.TENANT, cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = false) +@ModelWidget(type = ModelType.WIDGET, name = "tenant") +public class TenantWidget extends Widget { + +} + diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/TunnelXconnectWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/TunnelXconnectWidget.java new file mode 100644 index 0000000000..1a8a9fea27 --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/TunnelXconnectWidget.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.Model; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.ModelWidget; + +@Model(widget = Widget.Type.TUNNEL_XCONNECT, + cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = true) +@ModelWidget(type = ModelType.WIDGET, name = "tunnel-xconnect") +public class TunnelXconnectWidget extends Widget { +} diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VServerWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VServerWidget.java new file mode 100644 index 0000000000..6df5bb1407 --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VServerWidget.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.Model; +import org.onap.sdc.generator.aai.types.ModelWidget; + +@Model(widget = Widget.Type.VSERVER, cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = true) +@ModelWidget(type = ModelType.WIDGET, name = "vserver") +public class VServerWidget extends Widget { + + /** + * Instantiates a new V server widget. + */ + public VServerWidget() { + addWidget(new FlavorWidget()); + addWidget(new ImageWidget()); + addWidget(new TenantWidget()); + addWidget(new VfcWidget()); + } + + public boolean addWidget(Widget widget) { + return widgets.add(widget); + } + +} diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VfModule.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VfModule.java new file mode 100644 index 0000000000..1b715630e4 --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VfModule.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.Model; + +import java.util.List; + +@Model(widget = Widget.Type.VFMODULE, cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = true) +public class VfModule extends Resource { + + Widget vserver = null; + boolean addlintf = false; + boolean addvolume = false; + + List<String> members; + + public void setMembers(List<String> members) { + this.members = members; + } + + /** + * Adds Widget. + * + * @param widget the widget + * @return the boolean + */ + public boolean addWidget(Widget widget) { + if (widget.memberOf(members)) { + if (vserver == null && widget.getId().equals(new VServerWidget().getId())) { + vserver = widget; + if (addlintf) { + vserver.addWidget(new LIntfWidget()); + } + if (addvolume) { + vserver.addWidget(new VolumeWidget()); + } + } else if (widget.getId().equals(new LIntfWidget().getId())) { + if (vserver != null) { + vserver.addWidget(widget); + return true; + } else { + addlintf = true; + } + return false; + } else if (widget.getId().equals(new VolumeWidget().getId())) { + if (vserver != null) { + vserver.addWidget(widget); + } else { + addvolume = true; + } + return true; + } + if (widget.getId().equals(new OamNetwork().getId())) { + return false; + } + return widgets.add(widget); + } + return false; + } + +} diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VfModuleWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VfModuleWidget.java new file mode 100644 index 0000000000..9753db600c --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VfModuleWidget.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Model; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.ModelWidget; + +@Model(widget = Widget.Type.VFMODULE, + cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = true) +@ModelWidget(type = ModelType.WIDGET, name = "vf-module") +public class VfModuleWidget extends Widget { + +} + diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VfWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VfWidget.java new file mode 100644 index 0000000000..20ea9973aa --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VfWidget.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.Model; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.ModelWidget; + +@Model(widget = Widget.Type.VF, + cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = true) +@ModelWidget(type = ModelType.WIDGET, name = "generic-vnf") +public class VfWidget extends ResourceWidget { + +} + diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VfcWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VfcWidget.java new file mode 100644 index 0000000000..2d08ef8b7d --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VfcWidget.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.Model; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.ModelWidget; + +@Model(widget = Widget.Type.VFC, + cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = true) +@ModelWidget(type = ModelType.WIDGET, name = "vnfc") +public class VfcWidget extends ResourceWidget { + +} + diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VirtualFunction.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VirtualFunction.java new file mode 100644 index 0000000000..3736ebacc3 --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VirtualFunction.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.Model; + +@Model(widget = Widget.Type.VF, cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = true) +public class VirtualFunction extends Resource { + +} + diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VolumeGroupWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VolumeGroupWidget.java new file mode 100644 index 0000000000..918cfa897c --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VolumeGroupWidget.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.Model; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.ModelWidget; + +@Model(widget = Widget.Type.VOLUME_GROUP, + cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = true) +@ModelWidget(type = ModelType.WIDGET, name = "volume-group") +public class VolumeGroupWidget extends Widget { + +} + diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VolumeWidget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VolumeWidget.java new file mode 100644 index 0000000000..e0cdac437a --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/VolumeWidget.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.Cardinality; +import org.onap.sdc.generator.aai.types.Model; +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.aai.types.ModelWidget; + +@Model(widget = Widget.Type.VOLUME, cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = true) +@ModelWidget(type = ModelType.WIDGET, name = "volume") +public class VolumeWidget extends ResourceWidget { + +} + diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Widget.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Widget.java new file mode 100644 index 0000000000..b289b0a83c --- /dev/null +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Widget.java @@ -0,0 +1,196 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.sdc.generator.aai.model; + +import org.onap.sdc.generator.aai.types.ModelType; +import org.onap.sdc.generator.data.ArtifactType; +import org.onap.sdc.generator.data.GeneratorConstants; +import org.onap.sdc.generator.aai.types.ModelWidget; +import org.onap.sdc.generator.data.WidgetConfigurationUtil; +import org.onap.sdc.generator.error.IllegalAccessException; + +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Properties; +import java.util.Set; + +public abstract class Widget extends Model { + + private Set<String> keys = new HashSet<>(); + + /** + * Gets widget. + * + * @param type the type + * @return the widget + */ + public static Widget getWidget(Type type) { + + switch (type) { + case SERVICE: + return new ServiceWidget(); + case VF: + return new VfWidget(); + case VFC: + return new VfcWidget(); + case VSERVER: + return new VServerWidget(); + case VOLUME: + return new VolumeWidget(); + case FLAVOR: + return new FlavorWidget(); + case TENANT: + return new TenantWidget(); + case VOLUME_GROUP: + return new VolumeGroupWidget(); + case LINT: + return new LIntfWidget(); + case L3_NET: + return new L3NetworkWidget(); + case VFMODULE: + return new VfModuleWidget(); + case IMAGE: + return new ImageWidget(); + case OAM_NETWORK: + return new OamNetwork(); + case ALLOTTED_RESOURCE: + return new AllotedResourceWidget(); + case TUNNEL_XCONNECT: + return new TunnelXconnectWidget(); + default: + return null; + } + + } + + /** + * Gets id. + * + * @return the id + */ + public String getId() { + Properties properties = WidgetConfigurationUtil.getConfig(); + String id = properties.getProperty(ArtifactType.AAI.name() + ".model-version-id." + getName()); + if (id == null) { + throw new IllegalArgumentException(String.format( + GeneratorConstants.GENERATOR_AAI_CONFIGLPROP_NOT_FOUND, + ArtifactType.AAI.name() + ".model-version-id." + getName())); + } + return id; + } + + public ModelType getType() { + ModelWidget widgetModel = this.getClass().getAnnotation(ModelWidget.class); + return widgetModel.type(); + } + + public String getName() { + ModelWidget widgetModel = this.getClass().getAnnotation(ModelWidget.class); + return widgetModel.name(); + } + + /** + * Get Widget Id from properties file. + * @return - Widget Id + */ + public String getWidgetId() { + Properties properties = WidgetConfigurationUtil.getConfig(); + String id = properties.getProperty(ArtifactType.AAI.name() + ".model-invariant-id." + + getName()); + if (id == null) { + throw new IllegalArgumentException(String.format( + GeneratorConstants.GENERATOR_AAI_CONFIGLPROP_NOT_FOUND, + ArtifactType.AAI.name() + ".model-invariant-id." + getName())); + } + return id; + } + + public int hashCode() { + return getId().hashCode(); + } + + @Override + public Type getWidgetType() { + return null; + } + + /** + * Equals. + * + * @param obj Object + * @return the boolean + */ + public boolean equals(Object obj) { + if (obj instanceof Widget) { + if (getId().equals(((Widget) obj).getId())) { + ((Widget) obj).keys.addAll(this.keys); + return true; + } + return false; + } else { + return false; + } + } + + public void addKey(String key) { + this.keys.add(key); + } + + /** + * Member of boolean. + * + * @param keys the keys + * @return the boolean + */ + public boolean memberOf(List<String> keys) { + if (keys == null) { + return false; + } + return !Collections.disjoint(this.keys, keys); + } + + /** + * All instances used boolean. + * + * @param collection the collection + * @return the boolean + */ + public boolean allInstancesUsed(Set<String> collection) { + Set<String> keyCopy = new HashSet<>(keys); + keyCopy.removeAll(collection); + return keyCopy.isEmpty(); + } + + public boolean addResource(Resource resource) { + throw new IllegalAccessException(GeneratorConstants + .GENERATOR_AAI_ERROR_UNSUPPORTED_WIDGET_OPERATION); + } + + public boolean addWidget(Widget widget) { + return true; + } + + public enum Type { + SERVICE, VF, VFC, VSERVER, VOLUME, FLAVOR, TENANT, VOLUME_GROUP, LINT, L3_NET, VFMODULE, IMAGE, + OAM_NETWORK,ALLOTTED_RESOURCE,TUNNEL_XCONNECT + } +} |