2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 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 package org.onap.aai.sparky.sync.entity;
23 import java.util.ArrayList;
25 import org.onap.aai.sparky.util.NodeUtils;
27 import com.fasterxml.jackson.annotation.JsonIgnore;
28 import com.fasterxml.jackson.core.JsonProcessingException;
32 * The Class IndexableCrossEntityReference.
35 public class IndexableCrossEntityReference extends IndexableEntity implements IndexDocument {
37 protected String crossReferenceEntityValues;
38 protected ArrayList<String> crossEntityReferenceCollection = new ArrayList<String>();
41 * Instantiates a new indexable cross entity reference.
43 public IndexableCrossEntityReference() {
48 * Adds the cross entity reference value.
50 * @param crossEntityReferenceValue the cross entity reference value
52 public void addCrossEntityReferenceValue(String crossEntityReferenceValue) {
53 if (!crossEntityReferenceCollection.contains(crossEntityReferenceValue)) {
54 crossEntityReferenceCollection.add(crossEntityReferenceValue);
58 public String getCrossReferenceEntityValues() {
59 return crossReferenceEntityValues;
62 public void setCrossReferenceEntityValues(String crossReferenceEntityValues) {
63 this.crossReferenceEntityValues = crossReferenceEntityValues;
69 * @see org.openecomp.sparky.synchronizer.entity.IndexDocument#deriveFields()
72 public void deriveFields() {
73 this.id = NodeUtils.generateUniqueShaDigest(link);
74 this.crossReferenceEntityValues = NodeUtils.concatArray(crossEntityReferenceCollection, ";");
77 @JsonIgnore // Since this is a "get" we need to JSON ignore otherwise it will be called when converting to JSON
79 public String getAsJson() throws JsonProcessingException {
81 return NodeUtils.convertObjectToJson(this, false);
86 public String toString() {
87 return "IndexableCrossEntityReference ["
88 + (crossReferenceEntityValues != null
89 ? "crossReferenceEntityValues=" + crossReferenceEntityValues + ", " : "")
90 + (crossEntityReferenceCollection != null
91 ? "crossEntityReferenceCollection=" + crossEntityReferenceCollection + ", " : "");