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;
25 import org.openecomp.sdc.asdctool.utils.ConsoleWriter;
26 import org.openecomp.sdc.asdctool.utils.ReportWriter;
27 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
29 public abstract class CommonInternalTool {
30 protected ReportWriter reportWriter;
31 private String reportType;
33 CommonInternalTool(String reportType){
34 this.reportType = reportType;
36 protected ReportWriter getReportWriter() throws IOException{
37 if ( reportWriter == null ){
38 reportWriter = new ReportWriter(reportType);
42 public void closeAll() {
44 getReportWriter().close();
45 } catch (IOException e) {
46 ConsoleWriter.dataLine("\nFailed to close report file.");
49 protected void printComponentInfo(Map<GraphPropertyEnum, Object> metadataProperties) {
50 ConsoleWriter.dataLine("component from type", metadataProperties.get(GraphPropertyEnum.COMPONENT_TYPE));
51 ConsoleWriter.dataLine("component name", metadataProperties.get(GraphPropertyEnum.NAME));
52 ConsoleWriter.dataLine("component version", metadataProperties.get(GraphPropertyEnum.VERSION));
53 ConsoleWriter.dataLine("component state", metadataProperties.get(GraphPropertyEnum.STATE));
54 ConsoleWriter.dataLine("component is highest", metadataProperties.get(GraphPropertyEnum.IS_HIGHEST_VERSION));
55 ConsoleWriter.dataLine("component is archived", metadataProperties.get(GraphPropertyEnum.IS_ARCHIVED));