2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
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
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 package org.openecomp.sparky.synchronizer.entity;
28 import java.util.HashMap;
31 import org.openecomp.sparky.config.oxm.OxmModelLoader;
32 import org.openecomp.sparky.util.NodeUtils;
34 import com.fasterxml.jackson.databind.ObjectMapper;
35 import com.fasterxml.jackson.databind.node.ObjectNode;
38 * The Class AggregationEntity.
40 public class AggregationEntity extends IndexableEntity implements IndexDocument {
41 private Map<String, String> attributes = new HashMap<String, String>();
42 protected ObjectMapper mapper = new ObjectMapper();
45 * Instantiates a new aggregation entity.
47 public AggregationEntity() {
52 * Instantiates a new aggregation entity.
54 * @param loader the loader
56 public AggregationEntity(OxmModelLoader loader) {
61 * @see org.openecomp.sparky.synchronizer.entity.IndexDocument#deriveFields()
64 public void deriveFields() {
67 * We'll try and create a unique identity key that we can use for differencing the previously
68 * imported record sets as we won't have granular control of what is created/removed and when.
69 * The best we can hope for is identification of resources by generated Id until the
70 * Identity-Service UUID is tagged against all resources, then we can use that instead.
73 NodeUtils.generateUniqueShaDigest(link);
76 public void copyAttributeKeyValuePair(Map<String, Object> map){
77 for(String key: map.keySet()){
78 if (!key.equalsIgnoreCase("relationship-list")){ // ignore relationship data which is not required in aggregation
79 this.attributes.put(key, map.get(key).toString()); // not sure if entity attribute can contain an object as value
84 public void addAttributeKeyValuePair(String key, String value){
85 this.attributes.put(key, value);
89 public String getIndexDocumentJson() {
90 ObjectNode rootNode = mapper.createObjectNode();
91 rootNode.put("link", this.getLink());
92 rootNode.put("lastmodTimestamp", this.getEntityTimeStamp());
93 for (String key: this.attributes.keySet()){
94 rootNode.put(key, this.attributes.get(key));
96 return rootNode.toString();
100 public ObjectNode getBulkImportEntity() {
101 // TODO Auto-generated method stub
106 * @see java.lang.Object#toString()
109 public String toString() {
110 return "IndexDocument [" + (entityType != null ? "entityType=" + entityType + ", " : "")
111 + (entityPrimaryKeyValue != null ? "entityPrimaryKeyValue=" + entityPrimaryKeyValue + ", "
113 + (mapper != null ? "mapper=" + mapper + ", " : "") + (id != null ? "id=" + id + ", " : "")
114 + (lastmodTimestamp != null ? "lastmodTimestamp=" + lastmodTimestamp + ", " : "") + "]";