2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.core.tools.commands;
23 import static org.openecomp.core.tools.commands.CommandName.RESET_OLD_VERSION;
25 import com.datastax.driver.core.ResultSet;
26 import java.util.ArrayList;
27 import org.apache.commons.cli.CommandLine;
28 import org.apache.commons.cli.Option;
29 import org.openecomp.core.tools.store.HealingHandler;
30 import org.openecomp.core.tools.store.VersionCassandraLoader;
31 import org.openecomp.core.tools.store.zusammen.datatypes.HealingEntity;
35 * Created by ayalaben on 10/15/2017
37 public class SetHealingFlag extends Command {
39 private static final String VERSION_OPTION = "v";
42 options.addOption(Option.builder(VERSION_OPTION).hasArg().argName("version").desc("release version").build());
46 public boolean execute(String[] args) {
47 CommandLine cmd = parseArgs(args);
48 String oldVersion = cmd.hasOption(VERSION_OPTION) ? cmd.getOptionValue(VERSION_OPTION) : null;
50 VersionCassandraLoader versionCassandraLoader = new VersionCassandraLoader();
51 ResultSet listItemVersion = versionCassandraLoader.listItemVersion();
53 ArrayList<HealingEntity> healingEntities = new ArrayList<>();
55 listItemVersion.iterator().forEachRemaining(entry -> healingEntities.add(new HealingEntity(entry.getString(0),
56 entry.getString(1), entry.getString(2), true, oldVersion)));
58 HealingHandler healingHandler = new HealingHandler();
59 healingHandler.populateHealingTable(healingEntities);
65 public CommandName getCommandName() {
66 return RESET_OLD_VERSION;