Added oparent to sdc main
[sdc.git] / openecomp-be / lib / openecomp-core-lib / openecomp-zusammen-lib / openecomp-zusammen-api / src / main / java / org / openecomp / types / AsdcElement.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20 package org.openecomp.types;
21
22 import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
23 import com.amdocs.zusammen.datatypes.Id;
24 import com.amdocs.zusammen.datatypes.item.Action;
25 import com.amdocs.zusammen.datatypes.item.Info;
26 import com.amdocs.zusammen.datatypes.item.Relation;
27 import com.amdocs.zusammen.utils.fileutils.FileUtils;
28
29 import java.io.InputStream;
30 import java.util.ArrayList;
31 import java.util.Collection;
32 import java.util.Map;
33
34 public class AsdcElement implements Element {
35
36   private String type;
37   private String name;
38   private String description;
39
40   private Map<String, Object> properties;
41   private byte[] data;
42   private Collection<Relation> relations;
43   private Collection<Element> subElements = new ArrayList<>();
44   private Action action;
45   private Id elementId;
46
47   @Override
48   public Action getAction() {
49     return this.action;
50   }
51
52   @Override
53   public Id getElementId() {
54     return this.elementId;
55   }
56
57   @Override
58   public Info getInfo() {
59     Info info = new Info();
60     info.setProperties(this.properties);
61     info.addProperty(ElementPropertyName.elementType.name(), this.type != null ? this.type : this.name);
62     info.setName(this.name);
63     info.setDescription(this.description);
64
65     return info;
66   }
67
68   @Override
69   public Collection<Relation> getRelations() {
70     return this.relations;
71   }
72
73   @Override
74   public InputStream getData() {
75     return FileUtils.toInputStream(this.data);
76   }
77
78   @Override
79   public InputStream getSearchableData() {
80     return null;
81   }
82
83   @Override
84   public InputStream getVisualization() {
85     return null;
86   }
87
88
89   @Override
90   public Collection<Element> getSubElements() {
91     return this.subElements;
92   }
93
94   public void setElementId(Id elementId) {
95     this.elementId = elementId;
96   }
97
98   public void setData(InputStream data) {
99     this.data = FileUtils.toByteArray(data);
100   }
101
102   public void setRelations(Collection<Relation> relations) {
103     this.relations = relations;
104   }
105
106   public void setSubElements(Collection<Element> subElements) {
107     this.subElements = subElements;
108   }
109
110   public void setAction(Action action) {
111     this.action = action;
112   }
113
114   public AsdcElement addSubElement(Element element) {
115     this.subElements.add(element);
116     return this;
117   }
118
119   public String getType() {
120     return type;
121   }
122
123   public void setType(String type) {
124     this.type = type;
125   }
126
127   public String getName() {
128     return name;
129   }
130
131   public void setName(String name) {
132     this.name = name;
133   }
134
135   public String getDescription() {
136     return description;
137   }
138
139   public void setDescription(String description) {
140     this.description = description;
141   }
142
143   public Map<String, Object> getProperties() {
144     return properties;
145   }
146
147   public void setProperties(Map<String, Object> properties) {
148     this.properties = properties;
149   }
150 }