| 1 7 package org.mmbase.applications.packaging.installhandlers; 8 9 import java.util.ArrayList ; 10 import java.util.Iterator ; 11 12 20 public class installStep { 21 22 private String userfeedback; 23 24 private ArrayList installsteps; 25 26 private int timestamp; 27 28 private int type = 0; 29 30 private int errorcount = 0; 31 32 private int warningcount = 0; 33 34 private int parent = -1; 35 36 39 public final static int TYPE_ERROR = 1; 40 41 44 public final static int TYPE_WARNING = 2; 45 46 47 50 public installStep() { 51 timestamp = (int) (System.currentTimeMillis() / 1000); 52 } 53 54 55 60 public void setUserFeedBack(String line) { 61 userfeedback = line; 62 } 63 64 65 70 public void setType(int type) { 71 this.type = type; 72 if (type == TYPE_WARNING) { 73 warningcount++; 74 } 75 if (type == TYPE_ERROR) { 76 errorcount++; 77 } 78 } 79 80 81 86 public String getUserFeedBack() { 87 return userfeedback; 88 } 89 90 91 96 public int getTimeStamp() { 97 return timestamp; 98 } 99 100 101 106 public int getErrorCount() { 107 if (installsteps != null) { 109 int total = errorcount; 110 Iterator e = installsteps.iterator(); 111 while (e.hasNext()) { 112 installStep step = (installStep) e.next(); 113 total += step.getErrorCount(); 114 } 115 return total; 116 } else { 117 return errorcount; 118 } 119 } 120 121 122 127 public int getWarningCount() { 128 if (installsteps != null) { 129 int total = warningcount; 130 Iterator e = installsteps.iterator(); 131 while (e.hasNext()) { 132 installStep step = (installStep) e.next(); 133 total += step.getWarningCount(); 134 } 135 return total; 136 } else { 137 return warningcount; 138 } 139 } 140 141 142 147 public Iterator getInstallSteps() { 148 if (installsteps != null) { 149 return installsteps.iterator(); 150 } else { 151 return null; 152 } 153 } 154 155 156 162 public Iterator getInstallSteps(int logid) { 163 if (logid == getId()) { 165 return getInstallSteps(); 166 } 167 168 Iterator e = getInstallSteps(); 170 if (e != null) { 171 while (e.hasNext()) { 172 installStep step = (installStep) e.next(); 173 Object o = step.getInstallSteps(logid); 174 if (o != null) { 175 return (Iterator ) o; 176 } 177 } 178 } 179 return null; 180 } 181 182 183 188 public installStep getNextInstallStep() { 189 installStep step = new installStep(); 191 step.setParent(getId()); 192 if (installsteps == null) { 193 installsteps = new ArrayList (); 194 installsteps.add(step); 195 return step; 196 } else { 197 installsteps.add(step); 198 return step; 199 } 200 } 201 202 203 208 public int getId() { 209 return this.hashCode(); 210 } 211 212 213 218 public void setParent(int parent) { 219 this.parent = parent; 220 } 221 222 223 228 public boolean hasChilds() { 229 if (installsteps != null) { 230 return true; 231 } 232 return false; 233 } 234 235 236 241 public int getParent() { 242 return parent; 243 } 244 } 245 246 | Popular Tags |