X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=sdnr%2Fwt%2Fdata-provider%2Fsetup%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fccsdk%2Ffeatures%2Fsdnr%2Fwt%2Fdataprovider%2Fsetup%2Fdata%2FDatabaseInfo.java;fp=sdnr%2Fwt%2Fdata-provider%2Fsetup%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fccsdk%2Ffeatures%2Fsdnr%2Fwt%2Fdataprovider%2Fsetup%2Fdata%2FDatabaseInfo.java;h=a6e81343ad46dbac2aa6b61fdb89b9931daa1e6b;hb=ee75b19ee79f49b28a3137b6dcfdf02d6120f3de;hp=0000000000000000000000000000000000000000;hpb=8f762f215f49fd4b1d498adc2cc4f98093f0ddf3;p=ccsdk%2Ffeatures.git diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java new file mode 100644 index 000000000..a6e81343a --- /dev/null +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java @@ -0,0 +1,63 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data; + +/** + * @author Michael Dürre + * + */ +public class DatabaseInfo { + public final String doctype; + public final String alias; + private final String mapping; + private final String settingsFormat; + private final String index; + public String getIndex(String version) { + return this.index + version; + } + + public DatabaseInfo(String alias, String doctype, String mapping) { + this(alias,alias,doctype,mapping); + } + + public DatabaseInfo(String index,String alias, String doctype, String mapping) { + this(index,alias,doctype, mapping, + "{\"index\":{\"number_of_shards\":%d,\"number_of_replicas\":%d},\"analysis\":{\"analyzer\":{\"content\":" + + "{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}"); + } + + public DatabaseInfo(String index,String alias,String doctype, String mapping, String settingsformat) { + this.index = index; + this.alias = alias; + this.doctype = doctype; + this.mapping = mapping; + this.settingsFormat = settingsformat; + } + + + public String getMapping() { + return this.mapping==null?null:String.format("{\"%s\":{\"properties\":%s}}",this.doctype, this.mapping); + } + public String getSettings(int shards, int replicas) { + return String.format(this.settingsFormat, shards, replicas); + } +} \ No newline at end of file