2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.sdc.asdctool.main;
23 import org.openecomp.sdc.asdctool.impl.UpdatePropertyOnVertex;
24 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
25 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
26 import org.openecomp.sdc.common.log.wrappers.Logger;
28 import java.util.ArrayList;
29 import java.util.HashMap;
30 import java.util.List;
33 public class UpdateIsVnfMenu {
35 private static Logger log = Logger.getLogger(UpdateIsVnfMenu.class.getName());
37 private static void usageAndExit() {
38 updateIsVnfTrueUsage();
42 private static void updateIsVnfTrueUsage() {
44 "Usage: updateIsVnfTrue <titan.properties> <systemServiceName1,systemServiceName2,...,systemServiceNameN>");
47 public static void main(String[] args) {
49 if (args == null || args.length < 1) {
53 UpdatePropertyOnVertex updatePropertyOnVertex = new UpdatePropertyOnVertex();
54 String operation = args[0];
56 switch (operation.toLowerCase()) {
58 case "updateisvnftrue":
59 boolean isValid = verifyParamsLength(args, 3);
60 if (false == isValid) {
61 updateIsVnfTrueUsage();
65 Map<String, Object> keyValueToSet = new HashMap<>();
66 keyValueToSet.put(GraphPropertiesDictionary.IS_VNF.getProperty(), true);
68 List<Map<String, Object>> orCriteria = buildCriteriaFromSystemServiceNames(args[2]);
69 Integer updatePropertyOnServiceAtLeastCertified = updatePropertyOnVertex
70 .updatePropertyOnServiceAtLeastCertified(args[1], keyValueToSet, orCriteria);
72 if (updatePropertyOnServiceAtLeastCertified == null) {
74 } else if (updatePropertyOnServiceAtLeastCertified.intValue() >= 0) {
75 log.debug("Number of updated services is {}",updatePropertyOnServiceAtLeastCertified.intValue());
86 private static List<Map<String, Object>> buildCriteriaFromSystemServiceNames(String systemList) {
88 List<Map<String, Object>> systemNames = new ArrayList<>();
90 String[] split = systemList.split(",");
92 for (String systemName : split) {
93 systemName = systemName.trim();
95 Map<String, Object> map = new HashMap();
96 map.put(GraphPropertiesDictionary.SYSTEM_NAME.getProperty(), systemName);
97 map.put(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.Service.getName());
106 private static boolean verifyParamsLength(String[] args, int i) {
114 if (args.length >= i) {