Coverage Report - com.buckosoft.PicMan.dom.PicsInSetDom
 
Classes in this File Line Coverage Branch Coverage Complexity
PicsInSetDom
0%
0/23
0%
0/2
1.5
 
 1  
 /******************************************************************************
 2  
  * PicsInSetDom.java - XML Sets for PicMan's Editors
 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.Iterator;
 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.Pic;
 19  
 import com.buckosoft.PicMan.domain.Set;
 20  
 
 21  
 /** XML for Pics in a Set
 22  
  * @author Dick Balaska
 23  
  * @since 2008/06/01
 24  
  */
 25  0
 public class PicsInSetDom {
 26  
         /** Fetch the {@link com.buckosoft.PicMan.domain.Pic}s in a set.
 27  
          * For now, all that we need is the pid and the name of the Pic
 28  
          * @param pmf The reference to the PicManFacade
 29  
          * @param sid The Set ID to query
 30  
          * @param size The size that we want to query.
 31  
          * @return A DOM of a List of stripped down Pic.
 32  
          */
 33  
         static public Document createDocument(PicManFacade pmf, int sid, int size) {
 34  0
                 Document document = DocumentHelper.createDocument();
 35  0
                 Element root = document.addElement("PicsInSet");
 36  0
                 Set set = pmf.getDB().getSet(sid);
 37  0
                 List<Pic> list = pmf.getDB().getPics(set, size);
 38  0
                 Iterator<Pic> iter = list.iterator();
 39  0
                 while (iter.hasNext()) {
 40  0
                         Pic pic = iter.next();
 41  0
                         Element ele = DocumentHelper.createElement("Pic");
 42  0
                         ele.addElement("pid").addText(((Integer)pic.getPid()).toString());
 43  0
                         ele.addElement("name").addText(pic.getName());
 44  0
                         root.add(ele);
 45  0
                 }
 46  0
                 return document;
 47  
         }
 48  
 
 49  
         /** Fetch the number of {@link com.buckosoft.PicMan.domain.Pic}s in a set.
 50  
          * @param pmf The reference to the PicManFacade
 51  
          * @param setName The name of the Set to query
 52  
          * @param size The size that we want to query.
 53  
          * @return A DOM with the element "count" which is the number of pics in the set/size specified.
 54  
          */
 55  
         static public Document createDocument(PicManFacade pmf, String setName, int size) {
 56  0
                 Document document = DocumentHelper.createDocument();
 57  0
                 Element root = document.addElement("PicsInSetCount");
 58  0
                 Set set = pmf.getDB().getSet(setName);
 59  0
                 List<Pic> list = pmf.getDB().getPics(set, size);
 60  0
                 root.addElement("name").addText(set.getName());
 61  0
                 root.addElement("sid").addText("" + set.getSid());
 62  0
                 root.addElement("size").addText("" + size);
 63  0
                 root.addElement("count").addText("" + list.size());
 64  0
                 return document;
 65  
         }
 66  
 }