1 19 package org.openharmonise.rm.resources.publishing; 20 21 import org.openharmonise.commons.dsi.AbstractDataStoreInterface; 22 import org.openharmonise.commons.xml.XMLDocument; 23 import org.openharmonise.rm.*; 24 import org.openharmonise.rm.publishing.*; 25 import org.openharmonise.rm.resources.lifecycle.Editable; 26 import org.openharmonise.rm.resources.xml.XMLResource; 27 import org.w3c.dom.Element ; 28 29 30 39 public class Template extends XMLResource implements Editable { 40 41 public static final String ATTRIB_TEMPLATEID = "templateId"; 43 public static final String TAG_TEMPLATE = "Template" ; 44 45 private static final String TBL_TEMPLATEGROUP = "template"; 47 48 49 52 public Template() { 53 super(); 54 } 55 56 61 public Template(AbstractDataStoreInterface con) { 62 super(con); 63 } 64 65 71 public Template(AbstractDataStoreInterface con, int nId) { 72 super(con,nId); 73 } 74 75 82 public Template(AbstractDataStoreInterface con, int nId, int nKey, boolean bIsHistorical) 83 { 84 super(con,nId, nKey, bIsHistorical); 85 } 86 87 97 public Element publishObjectToElement(Publishable pubObj, 98 HarmoniseOutput output, State state) 99 throws PublishException { 100 Element rootEl; 101 try { 102 rootEl = getTemplateRootElement(); 103 } catch (DataAccessException e) { 104 throw new PublishException("Error occurred getting template element",e); 105 } 106 107 Element el = pubObj.publish(rootEl,(HarmoniseOutput) output,(State) state); 108 109 return el; 110 } 111 112 118 public Element getTemplateRootElement() throws DataAccessException { 119 if (isPopulated() == false) { 120 try { 121 populateFromDatabase(); 122 } catch (PopulateException e) { 123 throw new DataAccessException("Error occured populating object",e); 124 } 125 } 126 127 XMLDocument xml = getXIncludeResolvedDocument(); 128 129 130 Element root = xml.getDocumentElement(); 131 root.setAttribute(ATTRIB_TEMPLATEID, "" + m_nId); 132 133 return (xml.getDocumentElement()); 134 } 135 136 139 public String getDBTableName() { 140 return TBL_TEMPLATEGROUP; 141 } 142 143 146 public String getParentObjectClassName() { 147 148 return TemplateGroup.class.getName(); 149 } 150 151 } | Popular Tags |