View Javadoc
1   /******************************************************************************
2    * MosaicManDom.java - XML Sets for PicMan's SetMan
3    * 
4    * PicMan - The BuckoSoft Picture Manager in Java
5    * Copyright(c) 2007 - Dick Balaska
6    * 
7    */
8   package com.buckosoft.PicMan.dom;
9   
10  import java.util.Date;
11  
12  import org.dom4j.Document;
13  import org.dom4j.DocumentHelper;
14  import org.dom4j.Element;
15  
16  import com.buckosoft.PicMan.business.PicManFacade;
17  import com.buckosoft.PicMan.business.mosaic.MosaicEngine;
18  import com.buckosoft.PicMan.domain.User;
19  
20  /** XML for MosaicDisplay
21   * @author Dick Balaska
22   * @since 2007/12/28
23   * @see <a href="http://cvs.buckosoft.com/Projects/java/PicMan/PicMan/src/com/buckosoft/PicMan/dom/MosaicManDom.java">MosaicManDom.java</a>
24   */
25  public class MosaicManDom {
26  
27  	/** Return the Mosaic runtime status as a Document
28  	 * @param pmf The PicMan Facade
29  	 * @param user Who is connected to the browser? (Not used)
30  	 * @return A DOM Document
31  	 */
32  	
33  	static public Document createDocument(PicManFacade pmf, User user) {
34  		Document document = DocumentHelper.createDocument();
35  		Element root = document.addElement("MosaicMan");
36  		getDateElement(root);
37  		MosaicEngine me = pmf.getMosaicMan().getMosaicEngine();
38  		if (me != null)  {
39  			root.addElement("masterPic").addText(me.getMasterPicName());
40  			root.addElement("lastMosaicUpdate").addText(me.getLastMosaicUpdate().toString());
41  			root.addElement("status").addText(me.getStatus());
42  			root.addElement("info").addText(me.getInfo());
43  			root.addElement("name").addText(me.getName());
44  			root.addElement("fileName").addText(me.getOutputFileName());
45  			root.addElement("duration").addText(me.getDurationAsString());
46  		}
47  		return document;
48  	}
49  
50  	private static void getDateElement(Element ele) {
51  		Date now = new Date();
52  		ele.addElement("date").addText(now.toString());
53  	}
54  	
55  }