Add collaboration feature
[sdc.git] / openecomp-be / lib / openecomp-core-lib / openecomp-zusammen-lib / openecomp-zusammen-api / src / main / java / org / openecomp / types / AsdcElement.java
1 package org.openecomp.types;
2
3 import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
4 import com.amdocs.zusammen.datatypes.Id;
5 import com.amdocs.zusammen.datatypes.item.Action;
6 import com.amdocs.zusammen.datatypes.item.Info;
7 import com.amdocs.zusammen.datatypes.item.Relation;
8 import com.amdocs.zusammen.utils.fileutils.FileUtils;
9
10 import java.io.InputStream;
11 import java.util.ArrayList;
12 import java.util.Collection;
13 import java.util.Map;
14
15 public class AsdcElement implements Element {
16
17   private String type;
18   private String name;
19   private String description;
20
21   private Map<String, Object> properties;
22   private byte[] data;
23   private Collection<Relation> relations;
24   private Collection<Element> subElements = new ArrayList<>();
25   private Action action;
26   private Id elementId;
27
28   @Override
29   public Action getAction() {
30     return this.action;
31   }
32
33   @Override
34   public Id getElementId() {
35     return this.elementId;
36   }
37
38   @Override
39   public Info getInfo() {
40     Info info = new Info();
41     info.setProperties(this.properties);
42     info.addProperty(ElementPropertyName.elementType.name(), this.type != null ? this.type : this.name);
43     info.setName(this.name);
44     info.setDescription(this.description);
45
46     return info;
47   }
48
49   @Override
50   public Collection<Relation> getRelations() {
51     return this.relations;
52   }
53
54   @Override
55   public InputStream getData() {
56     return FileUtils.toInputStream(this.data);
57   }
58
59   @Override
60   public InputStream getSearchableData() {
61     return null;
62   }
63
64   @Override
65   public InputStream getVisualization() {
66     return null;
67   }
68
69
70   @Override
71   public Collection<Element> getSubElements() {
72     return this.subElements;
73   }
74
75   public void setElementId(Id elementId) {
76     this.elementId = elementId;
77   }
78
79   public void setData(InputStream data) {
80     this.data = FileUtils.toByteArray(data);
81   }
82
83   public void setRelations(Collection<Relation> relations) {
84     this.relations = relations;
85   }
86
87   public void setSubElements(Collection<Element> subElements) {
88     this.subElements = subElements;
89   }
90
91   public void setAction(Action action) {
92     this.action = action;
93   }
94
95   public AsdcElement addSubElement(Element element) {
96     this.subElements.add(element);
97     return this;
98   }
99
100   public String getType() {
101     return type;
102   }
103
104   public void setType(String type) {
105     this.type = type;
106   }
107
108   public String getName() {
109     return name;
110   }
111
112   public void setName(String name) {
113     this.name = name;
114   }
115
116   public String getDescription() {
117     return description;
118   }
119
120   public void setDescription(String description) {
121     this.description = description;
122   }
123
124   public Map<String, Object> getProperties() {
125     return properties;
126   }
127
128   public void setProperties(Map<String, Object> properties) {
129     this.properties = properties;
130   }
131 }