Coverage Report - com.buckosoft.PicMan.dom.PosterSetupDom
 
Classes in this File Line Coverage Branch Coverage Complexity
PosterSetupDom
0%
0/29
0%
0/8
2.333
 
 1  
 /******************************************************************************
 2  
  * PosterSetupDom.java - XML for Poster Setups
 3  
  * 
 4  
  * PicMan - The BuckoSoft Picture Manager in Java
 5  
  * Copyright(c) 2008 - Dick Balaska
 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  
 /** XML for Poster Setups
 23  
  * @author Dick Balaska
 24  
  * @since 2008/02/14
 25  
  * @see <a href="http://cvs.buckosoft.com/Projects/java/PicMan/PicMan/src/com/buckosoft/PicMan/dom/PosterSetupDom.java">PosterSetupDom.java</a>
 26  
  */
 27  0
 public class PosterSetupDom {
 28  
         /** Fetch a dom that is a list of Mosaics in the system
 29  
          * @param pmf the PicManFacade
 30  
          * @return a Document
 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  
         /** Fetch a dom that is a single Poster
 43  
          * @param pmf the PicManFacade
 44  
          * @param pid the Poster id to fetch
 45  
          * @return a Document
 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  
 }