1 23 24 package org.hammurapi.render.dom; 25 26 import java.text.SimpleDateFormat ; 27 import java.util.Collection ; 28 import java.util.Iterator ; 29 30 import org.hammurapi.Waiver; 31 import org.hammurapi.WaiverEntry; 32 import org.hammurapi.results.DetailedResults; 33 import org.w3c.dom.Document ; 34 import org.w3c.dom.Element ; 35 import org.w3c.dom.Node ; 36 37 import com.pavelvlasov.render.RenderRequest; 38 import com.pavelvlasov.render.RenderingException; 39 40 45 public class DetailedResultsRenderer extends NamedResultsRenderer { 46 47 public DetailedResultsRenderer(RenderRequest request) { 48 super(request); 49 } 50 51 public DetailedResultsRenderer(RenderRequest request, String profile) { 52 super(request, profile); 53 } 54 55 public Element render(Document document) throws RenderingException { 56 Element ret=super.render(document); 57 Iterator it=((DetailedResults) request.getRenderee()).getViolations().iterator(); 58 while (it.hasNext()) { 59 ViolationRenderer ver=new ViolationRenderer(new RenderRequest(it.next())); 60 ret.appendChild(ver.render(document)); 61 } 62 63 it=((DetailedResults) request.getRenderee()).getWaivedViolations().iterator(); 64 while (it.hasNext()) { 65 WaiverEntry waiverEntry=(WaiverEntry) it.next(); 66 Element waivedViolationElement=document.createElement("waived-violation"); 67 ret.appendChild(waivedViolationElement); 68 ViolationRenderer ver=new ViolationRenderer(new RenderRequest(waiverEntry.getViolation())); 69 waivedViolationElement.appendChild(ver.render(document)); 70 waivedViolationElement.appendChild(renderWaiver(waiverEntry.getWaiver(), document)); 71 } 72 73 return ret; 81 } 82 83 public static Node renderWaiver(Waiver waiver, Document document) { 84 Element ret=document.createElement("waiver"); 85 86 appendTextElement("inspector-name", waiver.getInspectorName(), ret); 87 Collection signatures = waiver.getSignatures(); 88 if (signatures!=null) { 89 Iterator it=signatures.iterator(); 90 while (it.hasNext()) { 91 appendTextElement("signature", (String ) it.next(), ret); 92 } 93 } 94 95 appendTextElement("reason", waiver.getReason(), ret); 96 if (waiver.getExpirationDate()!=null) { 97 SimpleDateFormat sdf=new SimpleDateFormat (Waiver.DATE_FORMAT); 98 appendTextElement("expiration-date", sdf.format(waiver.getExpirationDate()), ret); 99 } 100 101 return ret; 102 } 103 } 104 | Popular Tags |