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
12 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 * ECOMP and OpenECOMP are trademarks
21 * and service marks of AT&T Intellectual Property.
23 package org.openecomp.modelloader.entity.model;
25 import java.util.HashSet;
26 import java.util.List;
29 import org.openecomp.modelloader.config.ModelLoaderConfig;
30 import org.openecomp.modelloader.entity.Artifact;
31 import org.openecomp.modelloader.entity.ArtifactType;
32 import org.openecomp.modelloader.restclient.AaiRestClient;
34 public abstract class AbstractModelArtifact extends Artifact {
36 private String modelNamespace;
37 private String modelNamespaceVersion;
38 private Set<String> referencedModelIds = new HashSet<String>();
40 public AbstractModelArtifact(ArtifactType type) {
44 public Set<String> getDependentModelIds() {
45 return referencedModelIds;
48 public void addDependentModelId(String dependentModelId) {
49 this.referencedModelIds.add(dependentModelId);
52 public String getModelNamespace() {
53 return modelNamespace;
56 public void setModelNamespace(String modelNamespace) {
57 this.modelNamespace = modelNamespace;
59 // Get the version from the namespace (in format 'http://org.openecomp.aai.inventory/v9')
60 String[] parts = modelNamespace.split("/");
61 modelNamespaceVersion = parts[parts.length-1].trim();
64 public String getModelNamespaceVersion() {
65 return modelNamespaceVersion;
68 public abstract String getUniqueIdentifier();
70 public abstract boolean push(AaiRestClient aaiClient, ModelLoaderConfig config, String distId, List<AbstractModelArtifact> addedModels);
72 public abstract void rollbackModel(AaiRestClient aaiClient, ModelLoaderConfig config, String distId);
74 public String toString() {
75 StringBuilder sb = new StringBuilder();
76 sb.append("\nType=" + getType().toString() +"\nId=" + getUniqueIdentifier() +"\nVersion=" + getModelNamespaceVersion() + "\nDependant models: ");
77 for (String dep : referencedModelIds) {