2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ===================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
21 package org.onap.aai.modelloader.entity.model;
23 import java.util.HashSet;
24 import java.util.List;
27 import org.onap.aai.modelloader.config.ModelLoaderConfig;
28 import org.onap.aai.modelloader.entity.Artifact;
29 import org.onap.aai.modelloader.entity.ArtifactType;
30 import org.onap.aai.modelloader.restclient.AaiRestClient;
32 public abstract class AbstractModelArtifact extends Artifact implements IModelArtifact {
34 private String modelNamespace;
35 private String modelNamespaceVersion;
36 private Set<String> referencedModelIds = new HashSet<>();
38 public AbstractModelArtifact(ArtifactType type) {
42 public Set<String> getDependentModelIds() {
43 return referencedModelIds;
47 public void addDependentModelId(String dependentModelId) {
48 this.referencedModelIds.add(dependentModelId);
51 public String getModelNamespace() {
52 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,
71 List<Artifact> completedArtifacts);
73 public abstract void rollbackModel(AaiRestClient aaiClient, ModelLoaderConfig config, String distId);
76 public String toString() {
77 StringBuilder sb = new StringBuilder();
78 sb.append("\nType=" + getType().toString() + "\nId=" + getUniqueIdentifier() + "\nVersion="
79 + getModelNamespaceVersion() + "\nDependant models: ");
80 for (String dep : referencedModelIds) {