Initial commit for AAI-UI(sparky-backend)
[aai/sparky-be.git] / src / main / java / org / openecomp / sparky / synchronizer / entity / AggregationSuggestionEntity.java
1 /**
2  * ============LICENSE_START===================================================
3  * SPARKY (AAI UI service)
4  * ============================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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=====================================================
21  *
22  * ECOMP and OpenECOMP are trademarks
23  * and service marks of AT&T Intellectual Property.
24  */
25
26 package org.openecomp.sparky.synchronizer.entity;
27
28 import com.fasterxml.jackson.databind.ObjectMapper;
29 import com.fasterxml.jackson.databind.node.ObjectNode;
30
31 import java.util.ArrayList;
32 import java.util.List;
33
34 import org.json.JSONArray;
35 import org.json.JSONObject;
36 import org.openecomp.sparky.util.NodeUtils;
37
38 public class AggregationSuggestionEntity extends IndexableEntity implements IndexDocument {
39
40   private List<String> inputs = new ArrayList<String>();
41   private final String outputString = "VNFs";
42   protected ObjectMapper mapper = new ObjectMapper();
43   
44   public AggregationSuggestionEntity() {
45     super();
46     inputs.add("VNFs");
47     inputs.add("generic-vnfs");
48   }
49   
50   @Override
51   public void deriveFields() {
52     this.id = NodeUtils.generateUniqueShaDigest(this.outputString);
53   }
54
55   @Override
56   public String getIndexDocumentJson() {
57     
58     JSONArray inputArray = new JSONArray();
59     for (String input: inputs) {
60       input = input.replace(",","" );
61       input = input.replace("[","" );
62       input = input.replace("]","" );
63       inputArray.put(input);
64     }
65     
66     JSONObject entitySuggest = new JSONObject();
67     entitySuggest.put("input", inputArray);
68     entitySuggest.put("output", this.outputString);
69     entitySuggest.put("weight", 100);
70     
71     JSONObject payloadNode = new JSONObject();
72     entitySuggest.put("payload", payloadNode);
73     
74     JSONObject rootNode = new JSONObject();
75     rootNode.put("entity_suggest", entitySuggest);
76
77     return rootNode.toString();
78   }
79
80   @Override
81   public ObjectNode getBulkImportEntity() {
82     // TODO Auto-generated method stub
83     return null;
84   }
85
86 }