| 1 |
|
package be.dvw.administration.mvc.taglibs; |
| 2 |
|
|
| 3 |
|
import org.apache.commons.logging.Log; |
| 4 |
|
import org.apache.commons.logging.LogFactory; |
| 5 |
|
import org.dom4j.io.OutputFormat; |
| 6 |
|
import org.dom4j.io.XMLWriter; |
| 7 |
|
import org.dom4j.DocumentException; |
| 8 |
|
|
| 9 |
|
import javax.servlet.jsp.JspException; |
| 10 |
|
import javax.servlet.jsp.JspWriter; |
| 11 |
|
import javax.servlet.jsp.tagext.BodyTagSupport; |
| 12 |
|
import javax.xml.transform.TransformerException; |
| 13 |
|
|
| 14 |
|
import be.dvw.administration.mvc.navigation.LeftMenu; |
| 15 |
|
import be.dvw.administration.mvc.navigation.LeftMenuXSLTImpl; |
| 16 |
|
import be.dvw.administration.services.scores.ScoreService; |
| 17 |
|
import be.dvw.administration.services.scores.ScoreServiceCastorImpl; |
| 18 |
|
import be.dvw.administration.services.instruments.InstrumentService; |
| 19 |
|
import be.dvw.administration.services.instruments.InstrumentServiceCastorImpl; |
| 20 |
|
import be.dvw.administration.Constants; |
| 21 |
|
|
| 22 |
|
import java.io.UnsupportedEncodingException; |
| 23 |
|
import java.io.IOException; |
| 24 |
|
import java.io.Writer; |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
0 |
public class SummaryTag extends BodyTagSupport { |
| 34 |
|
|
| 35 |
0 |
private static Log LOG = LogFactory.getLog(SummaryTag.class); |
| 36 |
|
private String page; |
| 37 |
|
private JspWriter out; |
| 38 |
|
|
| 39 |
|
public int doStartTag() throws JspException { |
| 40 |
|
|
| 41 |
0 |
LOG.debug("Executing the SummaryTag for page " + page); |
| 42 |
|
|
| 43 |
|
try { |
| 44 |
0 |
out = pageContext.getOut(); |
| 45 |
|
|
| 46 |
0 |
if ( Constants.SCORE_PAGE.equals(page) ) |
| 47 |
0 |
out.println(getScoresSummary()); |
| 48 |
0 |
if ( Constants.INSTRUMENT_PAGE.equals(page)) |
| 49 |
0 |
out.println(getInstrumentSummary()); |
| 50 |
0 |
if ( Constants.PERSON_PAGE.equals(page) ) |
| 51 |
0 |
out.println(getPersonSummary()); |
| 52 |
|
|
| 53 |
0 |
} catch (IOException e) { |
| 54 |
0 |
LOG.error("Exception", e); |
| 55 |
0 |
} |
| 56 |
|
|
| 57 |
0 |
return SKIP_BODY; |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
private String getScoresSummary() |
| 67 |
|
{ |
| 68 |
0 |
ScoreService scoreService = new ScoreServiceCastorImpl(); |
| 69 |
0 |
StringBuffer strb = new StringBuffer(); |
| 70 |
0 |
strb.append("Bibliotheek bevat "); |
| 71 |
0 |
strb.append(scoreService.getTotalNumber()); |
| 72 |
0 |
strb.append(" titels met een huidige waarde van "); |
| 73 |
0 |
strb.append(scoreService.getCurrentValue()); |
| 74 |
0 |
strb.append(" €"); |
| 75 |
|
|
| 76 |
0 |
LOG.debug("Generated summary for scores"); |
| 77 |
0 |
return strb.toString(); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
private String getInstrumentSummary() |
| 86 |
|
{ |
| 87 |
0 |
InstrumentService instrumentService = new InstrumentServiceCastorImpl(); |
| 88 |
0 |
StringBuffer strb = new StringBuffer(); |
| 89 |
0 |
strb.append("Instrumentarium bevat "); |
| 90 |
0 |
strb.append(instrumentService.getTotalNumber()); |
| 91 |
0 |
strb.append(" instrumenten met een huidige waarde van "); |
| 92 |
0 |
strb.append(instrumentService.getCurrentValue()); |
| 93 |
0 |
strb.append(" €"); |
| 94 |
0 |
LOG.debug("Generated summary for instruments"); |
| 95 |
0 |
return strb.toString(); |
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
private String getPersonSummary() |
| 99 |
|
{ |
| 100 |
0 |
return "Er zijn 214 personen waarvan 103 leden en 35 muzikanten opgeslaan"; |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
public int doEndTag() throws JspException { |
| 116 |
0 |
return EVAL_PAGE; |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
public String getPage() { |
| 120 |
0 |
return page; |
| 121 |
|
} |
| 122 |
|
|
| 123 |
|
public void setPage(String page) { |
| 124 |
0 |
this.page = page; |
| 125 |
0 |
} |
| 126 |
|
} |