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.
25 package org.onap.aai.sparky.sync.entity;
27 import java.util.ArrayList;
29 import org.onap.aai.sparky.util.NodeUtils;
31 import com.fasterxml.jackson.annotation.JsonIgnore;
32 import com.fasterxml.jackson.core.JsonProcessingException;
36 * The Class IndexableCrossEntityReference.
39 public class IndexableCrossEntityReference extends IndexableEntity implements IndexDocument {
41 protected String crossReferenceEntityValues;
42 protected ArrayList<String> crossEntityReferenceCollection = new ArrayList<String>();
45 * Instantiates a new indexable cross entity reference.
47 public IndexableCrossEntityReference() {
52 * Adds the cross entity reference value.
54 * @param crossEntityReferenceValue the cross entity reference value
56 public void addCrossEntityReferenceValue(String crossEntityReferenceValue) {
57 if (!crossEntityReferenceCollection.contains(crossEntityReferenceValue)) {
58 crossEntityReferenceCollection.add(crossEntityReferenceValue);
62 public String getCrossReferenceEntityValues() {
63 return crossReferenceEntityValues;
66 public void setCrossReferenceEntityValues(String crossReferenceEntityValues) {
67 this.crossReferenceEntityValues = crossReferenceEntityValues;
73 * @see org.openecomp.sparky.synchronizer.entity.IndexDocument#deriveFields()
76 public void deriveFields() {
77 this.id = NodeUtils.generateUniqueShaDigest(link);
78 this.crossReferenceEntityValues = NodeUtils.concatArray(crossEntityReferenceCollection, ";");
81 @JsonIgnore // Since this is a "get" we need to JSON ignore otherwise it will be called when converting to JSON
83 public String getAsJson() throws JsonProcessingException {
85 return NodeUtils.convertObjectToJson(this, false);
90 public String toString() {
91 return "IndexableCrossEntityReference ["
92 + (crossReferenceEntityValues != null
93 ? "crossReferenceEntityValues=" + crossReferenceEntityValues + ", " : "")
94 + (crossEntityReferenceCollection != null
95 ? "crossEntityReferenceCollection=" + crossEntityReferenceCollection + ", " : "");