001/* 002 * Copyright 2019 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.odfpilotage.report.consistency; 017 018import java.util.ArrayList; 019import java.util.LinkedHashMap; 020import java.util.List; 021import java.util.Map; 022 023import org.apache.commons.lang3.StringUtils; 024 025import org.ametys.runtime.i18n.I18nizableText; 026 027/** 028 * Object representing the result of the analysis. 029 */ 030public class ConsistencyAnalysisResult 031{ 032 /** Name of the data to put the indentation level in a line*/ 033 public static final String INDENTATION_LEVEL_DATA_NAME = "indentationLevel"; 034 035 /** Status of the result */ 036 private ConsistencyAnalysisStatus _status; 037 038 /** The text visible in the resume */ 039 private I18nizableText _statusText; 040 041 /** The introduction text */ 042 private I18nizableText _introText; 043 044 /** Columns description */ 045 private Map<String, I18nizableText> _columns; 046 047 /** The names of the columns to indent regarding the indentation level */ 048 private List<String> _indentableColumns; 049 050 /** List of lines */ 051 private List<Map<String, Object>> _lines; 052 053 /** 054 * Constructor. 055 */ 056 public ConsistencyAnalysisResult() 057 { 058 _status = ConsistencyAnalysisStatus.NEUTRAL; 059 _statusText = new I18nizableText(StringUtils.EMPTY); 060 _introText = new I18nizableText(StringUtils.EMPTY); 061 _columns = new LinkedHashMap<>(); 062 _indentableColumns = new ArrayList<>(); 063 _lines = new ArrayList<>(); 064 } 065 066 /** 067 * Get the status. 068 * @return The status 069 */ 070 public ConsistencyAnalysisStatus getStatus() 071 { 072 return _status; 073 } 074 075 /** 076 * Set the status. 077 * @param status The status to set 078 */ 079 public void setStatus(ConsistencyAnalysisStatus status) 080 { 081 _status = status; 082 } 083 084 /** 085 * Get the status text for the resume. 086 * @return The status text 087 */ 088 public I18nizableText getStatusText() 089 { 090 return _statusText; 091 } 092 093 /** 094 * Set the status text for the resume. 095 * @param statusText The status text 096 */ 097 public void setStatusText(I18nizableText statusText) 098 { 099 _statusText = statusText; 100 } 101 102 /** 103 * Get the intro text. 104 * @return The intro text 105 */ 106 public I18nizableText getIntroText() 107 { 108 return _introText; 109 } 110 111 /** 112 * Set the intro text. 113 * @param introText The intro text 114 */ 115 public void setIntroText(I18nizableText introText) 116 { 117 _introText = introText; 118 } 119 120 /** 121 * Get the columns. 122 * @return The columns 123 */ 124 public Map<String, I18nizableText> getColumns() 125 { 126 return _columns; 127 } 128 129 /** 130 * Add a column. 131 * @param name The name of the column 132 * @param label The label of the column 133 */ 134 public void addColumn(String name, I18nizableText label) 135 { 136 addColumn(name, label, false); 137 } 138 139 /** 140 * Add a column. 141 * @param name The name of the column 142 * @param label The label of the column 143 * @param isIndentable <code>true</code> if the column is indentable, <code>false</code> otherwise 144 */ 145 public void addColumn(String name, I18nizableText label, boolean isIndentable) 146 { 147 _columns.put(name, label); 148 if (isIndentable) 149 { 150 _indentableColumns.add(name); 151 } 152 } 153 154 /** 155 * Retrieves the list of the indentable columns 156 * @return the list of the indentable columns 157 */ 158 public List<String> getIndentableColumns() 159 { 160 return _indentableColumns; 161 } 162 163 /** 164 * Get the lines. 165 * @return The list of lines 166 */ 167 public List<Map<String, Object>> getLines() 168 { 169 return _lines; 170 } 171 172 /** 173 * Add a line. 174 * @param line The line 175 */ 176 public void addLine(Map<String, Object> line) 177 { 178 _lines.add(line); 179 } 180 181 /** 182 * Add all the lines. 183 * @param lines The list of lines to add 184 */ 185 public void addLines(List<Map<String, Object>> lines) 186 { 187 _lines.addAll(lines); 188 } 189}