2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (c) 2017 AT&T Intellectual Property
6 * ===================================================================
7 * Modifications Copyright (c) 2019 IBM
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.
21 * ============LICENSE_END=============================================
22 * ====================================================================
24 package org.onap.music.datastore.jsonobjects;
26 import org.onap.music.datastore.PreparedQueryObject;
27 import org.onap.music.eelf.logging.EELFLoggerDelegate;
29 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
31 import io.swagger.annotations.ApiModel;
32 import io.swagger.annotations.ApiModelProperty;
34 @JsonIgnoreProperties(ignoreUnknown = true)
35 @ApiModel(value = "JsonIndex", description = "Index Object")
36 public class JsonIndex {
38 private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JsonIndex.class);
40 private String indexName;
41 private String keyspaceName;
42 private String tableName;
43 private String fieldName;
45 public JsonIndex(String indexName,String keyspaceName,String tableName,String fieldName) {
46 this.indexName = indexName;
47 this.keyspaceName= keyspaceName;
48 this.tableName = tableName;
49 this.fieldName = fieldName;
52 @ApiModelProperty(value = "Index Name")
53 public String getIndexName() {
57 public JsonIndex setIndexName(String indexName) {
58 this.indexName = indexName;
62 @ApiModelProperty(value = "Keyspace name")
63 public String getKeyspaceName() {
67 public JsonIndex setKeyspaceName(String keyspaceName) {
68 this.keyspaceName = keyspaceName;
72 public JsonIndex setTableName(String tableName) {
73 this.tableName = tableName;
77 @ApiModelProperty(value = "Table name")
78 public String getTableName() {
82 public JsonIndex setFieldName(String fieldName) {
83 this.fieldName = fieldName;
87 @ApiModelProperty(value = "Field name")
88 public String getFieldName() {
92 public PreparedQueryObject genCreateIndexQuery() {
94 if (logger.isDebugEnabled()) {
95 logger.debug("Came inside genCreateIndexQuery method");
98 logger.info("genCreateIndexQuery indexName ::" + indexName);
99 logger.info("genCreateIndexQuery keyspaceName ::" + keyspaceName);
100 logger.info("genCreateIndexQuery tableName ::" + tableName);
101 logger.info("genCreateIndexQuery fieldName ::" + fieldName);
103 long start = System.currentTimeMillis();
105 PreparedQueryObject query = new PreparedQueryObject();
106 query.appendQueryString("Create index if not exists " + this.getIndexName() + " on " + this.getKeyspaceName() + "."
107 + this.getTableName() + " (" + this.getFieldName() + ");");
109 long end = System.currentTimeMillis();
111 logger.info(EELFLoggerDelegate.applicationLogger,
112 "Time taken for setting up query in create index:" + (end - start));
114 logger.info(EELFLoggerDelegate.applicationLogger,
115 " create index query :" + query.getQuery());