2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
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=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.acessor;
24 import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
25 import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
26 import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
27 import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.EsDataObjectReaderWriter2;
28 import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.rpctypehelper.QueryByFilter;
29 import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.rpctypehelper.QueryResult;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput;
32 import org.opendaylight.yangtools.yang.binding.DataObject;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 public class DataObjectAcessor<T extends DataObject> extends EsDataObjectReaderWriter2<T> {
38 private static final Logger LOG = LoggerFactory.getLogger(DataObjectAcessor.class);
40 DataObjectAcessor(HtDatabaseClient dbClient, Entity entity, Class<T> clazz, boolean doFullsizeRequest)
41 throws ClassNotFoundException {
42 super(dbClient, entity, clazz);
43 this.setFullsizeRequest(doFullsizeRequest);
44 LOG.info("Create {}", this.getClass().getName());
47 public QueryResult<T> getData(EntityInput input) {
49 QueryByFilter queryByFilter = new QueryByFilter(input);
50 QueryBuilder queryBuilder = queryByFilter.getQueryBuilderByFilter();
51 // Exception handling during user input for invalid filter input.
52 // This wrong filter by user is allowed an results into empty data.
53 boolean ignoreException = queryBuilder.contains("range");
55 LOG.debug("Request: {} filter {} ignoreException{}:", this.getDataTypeName(), queryByFilter, ignoreException);
57 SearchResult<T> result = doReadAll(queryBuilder, ignoreException);
58 return new QueryResult<>(queryByFilter, result);