Coverage Report - com.buckosoft.PicMan.dom.MosaicBatchSetupDom
 
Classes in this File Line Coverage Branch Coverage Complexity
MosaicBatchSetupDom
0%
0/29
0%
0/4
1.667
 
 1  
 /******************************************************************************
 2  
  * MosaicBatchSetupDom.java - XML for Mosaic Batch 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.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  
 /** XML for Mosaic Setups
 22  
  * @author Dick Balaska
 23  
  * @since 2008/09/19
 24  
  * @see <a href="http://cvs.buckosoft.com/Projects/java/PicMan/PicMan/src/com/buckosoft/PicMan/dom/MosaicBatchSetupDom.java">MosaicBatchSetupDom.java</a>
 25  
  */
 26  0
 public class MosaicBatchSetupDom {
 27  
         /** Fetch a dom that is a list of Mosaics in the system
 28  
          * @param pmf the PicManFacade
 29  
          * @return a Document
 30  
          */
 31  
         static public Document createDocument(PicManFacade pmf) {
 32  0
                 Document document = DocumentHelper.createDocument();
 33  0
                 Element root = document.addElement("MosaicBatchList");
 34  0
                 List<MosaicBatch>        list = pmf.getDB().getMosaicBatches();
 35  0
                 Collections.sort(list);
 36  0
                 Iterator<MosaicBatch> iter = list.iterator();
 37  0
                 while (iter.hasNext()) {
 38  0
                         MosaicBatch mb = iter.next();
 39  0
                         addMosaic(pmf, mb, root);
 40  0
                 }
 41  0
                 return document;
 42  
         }
 43  
 
 44  
         /** Fetch a dom that is a single MosaicBatch
 45  
          * @param pmf the PicManFacade
 46  
          * @param mbid the MosiacBatch id to fetch
 47  
          * @return a Document
 48  
          */
 49  
         static public Document createDocument(PicManFacade pmf, int mbid) {
 50  0
                 Document document = DocumentHelper.createDocument();
 51  0
                 Element root = document.addElement("Mosaic");
 52  0
                 MosaicBatch mb = pmf.getDB().getMosaicBatch(mbid);
 53  0
                 addMosaic(pmf, mb, root);
 54  0
                 return document;
 55  
         }
 56  
 
 57  
         static private void addMosaic(PicManFacade pmf, MosaicBatch mb, Element root) {
 58  0
                 Element ele = DocumentHelper.createElement("MosaicBatch");
 59  0
                 ele.addElement("mbid").addText("" + mb.getMbid());
 60  0
                 ele.addElement("mid").addText("" + mb.getMid());
 61  0
                 ele.addElement("name").addText(mb.getName());
 62  0
                 ele.addElement("sizes").addText(mb.getSizes());
 63  0
                 ele.addElement("engineName").addText(mb.getEngine());
 64  0
                 ele.addElement("outPic").addText(mb.getOutPic());
 65  0
                 ele.addElement("masterPic").addText(mb.getMasterPic());
 66  0
                 ele.addElement("sid").addText("" + mb.getSid());
 67  0
                 if (mb.getStartTime() != null)
 68  0
                         ele.addElement("startTime").addText("" + mb.getStartTime().getTime());
 69  0
                 root.add(ele);
 70  
 
 71  0
         }
 72  
 
 73  
 }