2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 Nordix Foundation
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * SPDX-License-Identifier: Apache-2.0
17 * ============LICENSE_END=========================================================
19 package org.openecomp.sdc.be.resources.data;
21 import java.util.HashMap;
24 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
25 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
26 import org.openecomp.sdc.be.datatypes.elements.ArtifactTypeDataDefinition;
27 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
29 public class ArtifactTypeData extends GraphNode {
31 private ArtifactTypeDataDefinition artifactTypeDefinition;
33 public ArtifactTypeData() {
34 super(NodeTypeEnum.Interface);
35 artifactTypeDefinition = new ArtifactTypeDataDefinition();
38 public ArtifactTypeData(ArtifactTypeDataDefinition artifactTypeDefinition) {
39 super(NodeTypeEnum.ArtifactType);
40 this.artifactTypeDefinition = artifactTypeDefinition;
43 public ArtifactTypeData(Map<String, Object> properties) {
45 artifactTypeDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
46 artifactTypeDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
47 artifactTypeDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
48 artifactTypeDefinition.setCreationDate((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
49 artifactTypeDefinition.setLastUpdated((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
52 public ArtifactTypeDataDefinition getArtifactTypeDataDefinition() {
53 return artifactTypeDefinition;
56 public void setArtifactTypeDataDefinition(ArtifactTypeDataDefinition artifactTypeDefinition) {
57 this.artifactTypeDefinition = artifactTypeDefinition;
61 public String getUniqueId() {
62 return artifactTypeDefinition.getUniqueId();
66 public Map<String, Object> toGraphMap() {
67 Map<String, Object> map = new HashMap<>();
68 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, artifactTypeDefinition.getUniqueId());
69 addIfExists(map, GraphPropertiesDictionary.TYPE, artifactTypeDefinition.getType());
70 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, artifactTypeDefinition.getCreationDate());
71 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, artifactTypeDefinition.getLastUpdated());
72 addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, artifactTypeDefinition.getDescription());