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;
42 * @return the crossReferenceEntityValues
44 public String getCrossReferenceEntityValues() {
45 return crossReferenceEntityValues;
49 * @param crossReferenceEntityValues the crossReferenceEntityValues to set
51 public void setCrossReferenceEntityValues(String crossReferenceEntityValues) {
52 this.crossReferenceEntityValues = crossReferenceEntityValues;
56 * @return the crossEntityReferenceCollection
58 public ArrayList<String> getCrossEntityReferenceCollection() {
59 return crossEntityReferenceCollection;
63 * @param crossEntityReferenceCollection the crossEntityReferenceCollection to set
65 public void setCrossEntityReferenceCollection(ArrayList<String> crossEntityReferenceCollection) {
66 this.crossEntityReferenceCollection = crossEntityReferenceCollection;
72 public ObjectMapper getMapper() {
77 * @param mapper the mapper to set
79 public void setMapper(ObjectMapper mapper) {
83 protected ArrayList<String> crossEntityReferenceCollection = new ArrayList<String>();
84 protected ObjectMapper mapper = new ObjectMapper();
87 * Instantiates a new indexable cross entity reference.
89 public IndexableCrossEntityReference() {
94 * Instantiates a new indexable cross entity reference.
96 * @param loader the loader
98 public IndexableCrossEntityReference(OxmModelLoader loader) {
103 * Adds the cross entity reference value.
105 * @param crossEntityReferenceValue the cross entity reference value
107 public void addCrossEntityReferenceValue(String crossEntityReferenceValue) {
108 if (!crossEntityReferenceCollection.contains(crossEntityReferenceValue)) {
109 crossEntityReferenceCollection.add(crossEntityReferenceValue);
114 * @see org.onap.aai.sparky.synchronizer.entity.IndexDocument#deriveFields()
117 public void deriveFields() {
118 this.id = NodeUtils.generateUniqueShaDigest(link);
119 this.crossReferenceEntityValues = NodeUtils.concatArray(crossEntityReferenceCollection, ";");
123 public String getIndexDocumentJson() {
124 ObjectNode rootNode = mapper.createObjectNode();
125 rootNode.put("entityType", this.getEntityType());
126 rootNode.put("entityPrimaryKeyValue", this.getEntityPrimaryKeyValue());
127 rootNode.put("crossEntityReferenceValues", crossReferenceEntityValues);
128 rootNode.put("link", link);
129 rootNode.put("lastmodTimestamp", this.getEntityTimeStamp());
130 return rootNode.toString();
134 public ObjectNode getBulkImportEntity() {
135 // TODO Auto-generated method stub
140 * @see java.lang.Object#toString()
143 public String toString() {
144 return "IndexableCrossEntityReference ["
145 + (crossReferenceEntityValues != null
146 ? "crossReferenceEntityValues=" + crossReferenceEntityValues + ", " : "")
147 + (crossEntityReferenceCollection != null
148 ? "crossEntityReferenceCollection=" + crossEntityReferenceCollection + ", " : "")
149 + (mapper != null ? "mapper=" + mapper + ", " : "") + (id != null ? "id=" + id + ", " : "")
150 + (entityType != null ? "entityType=" + entityType + ", " : "")
151 + (entityPrimaryKeyValue != null ? "entityPrimaryKeyValue=" + entityPrimaryKeyValue + ", "
153 + (lastmodTimestamp != null ? "lastmodTimestamp=" + lastmodTimestamp + ", " : "")
154 + (link != null ? "link=" + link + ", " : "") + (loader != null ? "loader=" + loader : "")