| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
package com.buckosoft.PicMan.dom; |
| 9 | |
|
| 10 | |
import java.util.Collections; |
| 11 | |
import java.util.List; |
| 12 | |
|
| 13 | |
import org.dom4j.Document; |
| 14 | |
import org.dom4j.DocumentHelper; |
| 15 | |
import org.dom4j.Element; |
| 16 | |
|
| 17 | |
import com.buckosoft.PicMan.business.PicManFacade; |
| 18 | |
import com.buckosoft.PicMan.domain.Mosaic; |
| 19 | |
import com.buckosoft.PicMan.domain.Pic; |
| 20 | |
import com.buckosoft.PicMan.domain.Poster; |
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | 0 | public class PosterSetupDom { |
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
static public Document createDocument(PicManFacade pmf) { |
| 33 | 0 | Document document = DocumentHelper.createDocument(); |
| 34 | 0 | Element root = document.addElement("PosterList"); |
| 35 | 0 | List<Poster> list = pmf.getDB().getPosters(); |
| 36 | 0 | Collections.sort(list); |
| 37 | 0 | for (Poster p : list) |
| 38 | 0 | addPoster(pmf, p, root); |
| 39 | 0 | return document; |
| 40 | |
} |
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
static public Document createDocument(PicManFacade pmf, int pid) { |
| 48 | 0 | Document document = DocumentHelper.createDocument(); |
| 49 | 0 | Element root = document.addElement("Poster"); |
| 50 | 0 | Poster p = pmf.getDB().getPoster(pid); |
| 51 | 0 | addPoster(pmf, p, root); |
| 52 | 0 | return document; |
| 53 | |
} |
| 54 | |
|
| 55 | |
static private void addPoster(PicManFacade pmf, Poster p, Element root) { |
| 56 | 0 | Element ele = DocumentHelper.createElement("Poster"); |
| 57 | 0 | ele.addElement("pid").addText("" + p.getPid()); |
| 58 | 0 | ele.addElement("name").addText(p.getName()); |
| 59 | 0 | ele.addElement("outPath").addText(p.getOutputPath()); |
| 60 | 0 | ele.addElement("masterMid").addText("" + p.getMasterMid()); |
| 61 | 0 | Mosaic m = pmf.getDB().getMosaic(p.getMasterMid()); |
| 62 | 0 | if (m != null) { |
| 63 | 0 | Pic pic = pmf.getDB().getPic(m.getMasterPic()); |
| 64 | 0 | if (pic != null) { |
| 65 | 0 | ele.addElement("picWidth").addText("" + pic.getWidth()); |
| 66 | 0 | ele.addElement("picHeight").addText("" + pic.getHeight()); |
| 67 | |
} |
| 68 | |
} |
| 69 | 0 | Element config = ele.addElement("Config"); |
| 70 | 0 | for (String k : p.getConfig().keySet()) |
| 71 | 0 | config.addElement(k).addText(p.getConfig().get(k)); |
| 72 | 0 | root.add(ele); |
| 73 | |
|
| 74 | 0 | } |
| 75 | |
} |