2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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=========================================================
20 package org.openecomp.sdc.asdctool.impl.internal.tool;
22 import java.io.IOException;
24 import org.openecomp.sdc.asdctool.utils.ConsoleWriter;
25 import org.openecomp.sdc.asdctool.utils.ReportWriter;
26 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
28 public abstract class CommonInternalTool {
30 protected ReportWriter reportWriter;
31 private String reportType;
33 CommonInternalTool(String reportType) {
34 this.reportType = reportType;
37 protected ReportWriter getReportWriter() throws IOException {
38 if (reportWriter == null) {
39 reportWriter = new ReportWriter(reportType);
44 public void closeAll() {
46 getReportWriter().close();
47 } catch (IOException e) {
48 ConsoleWriter.dataLine("\nFailed to close report file.");
52 protected void printComponentInfo(Map<GraphPropertyEnum, Object> metadataProperties) {
53 ConsoleWriter.dataLine("component from type", metadataProperties.get(GraphPropertyEnum.COMPONENT_TYPE));
54 ConsoleWriter.dataLine("component name", metadataProperties.get(GraphPropertyEnum.NAME));
55 ConsoleWriter.dataLine("component version", metadataProperties.get(GraphPropertyEnum.VERSION));
56 ConsoleWriter.dataLine("component state", metadataProperties.get(GraphPropertyEnum.STATE));
57 ConsoleWriter.dataLine("component is highest", metadataProperties.get(GraphPropertyEnum.IS_HIGHEST_VERSION));
58 ConsoleWriter.dataLine("component is archived", metadataProperties.get(GraphPropertyEnum.IS_ARCHIVED));