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.ArrayList;
30 import org.openecomp.sparky.config.oxm.OxmModelLoader;
31 import org.openecomp.sparky.util.NodeUtils;
33 import com.fasterxml.jackson.databind.ObjectMapper;
34 import com.fasterxml.jackson.databind.node.ObjectNode;
38 * The Class IndexableCrossEntityReference.
41 public class IndexableCrossEntityReference extends IndexableEntity implements IndexDocument {
43 protected String crossReferenceEntityValues;
44 protected ArrayList<String> crossEntityReferenceCollection = new ArrayList<String>();
45 protected ObjectMapper mapper = new ObjectMapper();
48 * Instantiates a new indexable cross entity reference.
50 public IndexableCrossEntityReference() {
55 * Instantiates a new indexable cross entity reference.
57 * @param loader the loader
59 public IndexableCrossEntityReference(OxmModelLoader loader) {
64 * Adds the cross entity reference value.
66 * @param crossEntityReferenceValue the cross entity reference value
68 public void addCrossEntityReferenceValue(String crossEntityReferenceValue) {
69 if (!crossEntityReferenceCollection.contains(crossEntityReferenceValue)) {
70 crossEntityReferenceCollection.add(crossEntityReferenceValue);
75 * @see org.openecomp.sparky.synchronizer.entity.IndexDocument#deriveFields()
78 public void deriveFields() {
79 this.id = NodeUtils.generateUniqueShaDigest(link);
80 this.crossReferenceEntityValues = NodeUtils.concatArray(crossEntityReferenceCollection, ";");
84 public String getIndexDocumentJson() {
85 ObjectNode rootNode = mapper.createObjectNode();
86 rootNode.put("entityType", this.getEntityType());
87 rootNode.put("entityPrimaryKeyValue", this.getEntityPrimaryKeyValue());
88 rootNode.put("crossEntityReferenceValues", crossReferenceEntityValues);
89 rootNode.put("link", link);
90 rootNode.put("lastmodTimestamp", this.getEntityTimeStamp());
91 return rootNode.toString();
95 public ObjectNode getBulkImportEntity() {
96 // TODO Auto-generated method stub
101 * @see java.lang.Object#toString()
104 public String toString() {
105 return "IndexableCrossEntityReference ["
106 + (crossReferenceEntityValues != null
107 ? "crossReferenceEntityValues=" + crossReferenceEntityValues + ", " : "")
108 + (crossEntityReferenceCollection != null
109 ? "crossEntityReferenceCollection=" + crossEntityReferenceCollection + ", " : "")
110 + (mapper != null ? "mapper=" + mapper + ", " : "") + (id != null ? "id=" + id + ", " : "")
111 + (entityType != null ? "entityType=" + entityType + ", " : "")
112 + (entityPrimaryKeyValue != null ? "entityPrimaryKeyValue=" + entityPrimaryKeyValue + ", "
114 + (lastmodTimestamp != null ? "lastmodTimestamp=" + lastmodTimestamp + ", " : "")
115 + (link != null ? "link=" + link + ", " : "") + (loader != null ? "loader=" + loader : "")