2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.onap.aai.sparky.synchronizer.entity;
25 import java.util.ArrayList;
27 import org.onap.aai.sparky.config.oxm.OxmModelLoader;
28 import org.onap.aai.sparky.util.NodeUtils;
30 import com.fasterxml.jackson.databind.ObjectMapper;
31 import com.fasterxml.jackson.databind.node.ObjectNode;
35 * The Class IndexableCrossEntityReference.
38 public class IndexableCrossEntityReference extends IndexableEntity implements IndexDocument {
40 protected String crossReferenceEntityValues;
43 * @return the crossReferenceEntityValues
45 public String getCrossReferenceEntityValues() {
46 return crossReferenceEntityValues;
50 * @param crossReferenceEntityValues the crossReferenceEntityValues to set
52 public void setCrossReferenceEntityValues(String crossReferenceEntityValues) {
53 this.crossReferenceEntityValues = crossReferenceEntityValues;
57 * @return the crossEntityReferenceCollection
59 public ArrayList<String> getCrossEntityReferenceCollection() {
60 return crossEntityReferenceCollection;
64 * @param crossEntityReferenceCollection the crossEntityReferenceCollection to set
66 public void setCrossEntityReferenceCollection(ArrayList<String> crossEntityReferenceCollection) {
67 this.crossEntityReferenceCollection = crossEntityReferenceCollection;
73 public ObjectMapper getMapper() {
78 * @param mapper the mapper to set
80 public void setMapper(ObjectMapper mapper) {
84 protected ArrayList<String> crossEntityReferenceCollection = new ArrayList<String>();
85 protected ObjectMapper mapper = new ObjectMapper();
88 * Instantiates a new indexable cross entity reference.
90 public IndexableCrossEntityReference() {
95 * Instantiates a new indexable cross entity reference.
97 * @param loader the loader
99 public IndexableCrossEntityReference(OxmModelLoader loader) {
104 * Adds the cross entity reference value.
106 * @param crossEntityReferenceValue the cross entity reference value
108 public void addCrossEntityReferenceValue(String crossEntityReferenceValue) {
109 if (!crossEntityReferenceCollection.contains(crossEntityReferenceValue)) {
110 crossEntityReferenceCollection.add(crossEntityReferenceValue);
117 * @see org.onap.aai.sparky.synchronizer.entity.IndexDocument#deriveFields()
120 public void deriveFields() {
121 this.id = NodeUtils.generateUniqueShaDigest(link);
122 this.crossReferenceEntityValues = NodeUtils.concatArray(crossEntityReferenceCollection, ";");
126 public String getIndexDocumentJson() {
127 ObjectNode rootNode = mapper.createObjectNode();
128 rootNode.put("entityType", this.getEntityType());
129 rootNode.put("entityPrimaryKeyValue", this.getEntityPrimaryKeyValue());
130 rootNode.put("crossEntityReferenceValues", crossReferenceEntityValues);
131 rootNode.put("link", link);
132 rootNode.put("lastmodTimestamp", this.getEntityTimeStamp());
133 return rootNode.toString();
137 public ObjectNode getBulkImportEntity() {
138 // TODO Auto-generated method stub
145 * @see java.lang.Object#toString()
148 public String toString() {
149 return "IndexableCrossEntityReference ["
150 + (crossReferenceEntityValues != null
151 ? "crossReferenceEntityValues=" + crossReferenceEntityValues + ", " : "")
152 + (crossEntityReferenceCollection != null
153 ? "crossEntityReferenceCollection=" + crossEntityReferenceCollection + ", " : "")
154 + (mapper != null ? "mapper=" + mapper + ", " : "") + (id != null ? "id=" + id + ", " : "")
155 + (entityType != null ? "entityType=" + entityType + ", " : "")
156 + (entityPrimaryKeyValue != null ? "entityPrimaryKeyValue=" + entityPrimaryKeyValue + ", "
158 + (lastmodTimestamp != null ? "lastmodTimestamp=" + lastmodTimestamp + ", " : "")
159 + (link != null ? "link=" + link + ", " : "") + (loader != null ? "loader=" + loader : "")