1
2
3
4
5
6
7
8 package com.buckosoft.PicMan.dom;
9
10 import java.util.Collections;
11 import java.util.Iterator;
12 import java.util.List;
13
14 import org.dom4j.Document;
15 import org.dom4j.DocumentHelper;
16 import org.dom4j.Element;
17
18 import com.buckosoft.PicMan.business.PicManFacade;
19 import com.buckosoft.PicMan.domain.MosaicBatch;
20
21
22
23
24
25
26 public class MosaicBatchSetupDom {
27
28
29
30
31 static public Document createDocument(PicManFacade pmf) {
32 Document document = DocumentHelper.createDocument();
33 Element root = document.addElement("MosaicBatchList");
34 List<MosaicBatch> list = pmf.getDB().getMosaicBatches();
35 Collections.sort(list);
36 Iterator<MosaicBatch> iter = list.iterator();
37 while (iter.hasNext()) {
38 MosaicBatch mb = iter.next();
39 addMosaic(pmf, mb, root);
40 }
41 return document;
42 }
43
44
45
46
47
48
49 static public Document createDocument(PicManFacade pmf, int mbid) {
50 Document document = DocumentHelper.createDocument();
51 Element root = document.addElement("Mosaic");
52 MosaicBatch mb = pmf.getDB().getMosaicBatch(mbid);
53 addMosaic(pmf, mb, root);
54 return document;
55 }
56
57 static private void addMosaic(PicManFacade pmf, MosaicBatch mb, Element root) {
58 Element ele = DocumentHelper.createElement("MosaicBatch");
59 ele.addElement("mbid").addText("" + mb.getMbid());
60 ele.addElement("mid").addText("" + mb.getMid());
61 ele.addElement("name").addText(mb.getName());
62 ele.addElement("sizes").addText(mb.getSizes());
63 ele.addElement("engineName").addText(mb.getEngine());
64 ele.addElement("outPic").addText(mb.getOutPic());
65 ele.addElement("masterPic").addText(mb.getMasterPic());
66 ele.addElement("sid").addText("" + mb.getSid());
67 if (mb.getStartTime() != null)
68 ele.addElement("startTime").addText("" + mb.getStartTime().getTime());
69 root.add(ele);
70
71 }
72
73 }