00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 package org.openmobileis.synchro.journal;
00027
00036 import freemarker.template.*;
00037
00038 public abstract class DefaultLogRenderer implements JournalLogRenderer {
00039
00040 protected String syncName;
00041
00042 public DefaultLogRenderer() {}
00043
00044 public DefaultLogRenderer(String syncName) {
00045 this.syncName = syncName;
00046 }
00047
00048 public void render(SimpleList templatelist, JournalEntry[] entryList) {
00049 SimpleHash hash = new SimpleHash();
00050 SimpleList loglist = new SimpleList();
00051 for (int i=0; i<entryList.length; i++) {
00052
00053 if (entryList[i].getServiceEntryID() == 0) {
00054 hash.put("serviceName", this.getSyncLabel());
00055 hash.put("synchroMessage", new SimpleScalar(entryList[i].getEntryData()));
00056 hash.put("synchroDate", entryList[i].getFormatedDate());
00057 } else {
00058 SimpleHash hashlog = new SimpleHash();
00059 hashlog.put("detailMessage", entryList[i].getEntryData());
00060 if (entryList[i].getStatus() != -1) {
00061 hashlog.put("status", String.valueOf(entryList[i].getStatus()));
00062 }
00063 loglist.add(hashlog);
00064 }
00065 }
00066 hash.put("detailLogList", loglist);
00067 hash.put("hasEntries", new SimpleScalar(entryList.length > 1));
00068 templatelist.add(hash);
00069 }
00070
00071 public String getSyncName() {
00072 return syncName;
00073 }
00074
00078 public abstract String getSyncLabel();
00079
00080
00081 }