2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
22 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 package org.onap.aai.modelloader.entity.model;
26 import java.util.HashSet;
27 import java.util.List;
30 import org.onap.aai.modelloader.config.ModelLoaderConfig;
31 import org.onap.aai.modelloader.entity.Artifact;
32 import org.onap.aai.modelloader.entity.ArtifactType;
33 import org.onap.aai.modelloader.restclient.AaiRestClient;
35 public abstract class AbstractModelArtifact extends Artifact {
37 private String modelNamespace;
38 private String modelNamespaceVersion;
39 private Set<String> referencedModelIds = new HashSet<String>();
41 public AbstractModelArtifact(ArtifactType type) {
45 public Set<String> getDependentModelIds() {
46 return referencedModelIds;
49 public void addDependentModelId(String dependentModelId) {
50 this.referencedModelIds.add(dependentModelId);
53 public String getModelNamespace() {
54 return modelNamespace;
57 public void setModelNamespace(String modelNamespace) {
58 this.modelNamespace = modelNamespace;
60 // Get the version from the namespace (in format 'http://org.openecomp.aai.inventory/v9')
61 String[] parts = modelNamespace.split("/");
62 modelNamespaceVersion = parts[parts.length-1].trim();
65 public String getModelNamespaceVersion() {
66 return modelNamespaceVersion;
69 public abstract String getUniqueIdentifier();
71 public abstract boolean push(AaiRestClient aaiClient, ModelLoaderConfig config, String distId, List<AbstractModelArtifact> addedModels);
73 public abstract void rollbackModel(AaiRestClient aaiClient, ModelLoaderConfig config, String distId);
75 public String toString() {
76 StringBuilder sb = new StringBuilder();
77 sb.append("\nType=" + getType().toString() +"\nId=" + getUniqueIdentifier() +"\nVersion=" + getModelNamespaceVersion() + "\nDependant models: ");
78 for (String dep : referencedModelIds) {