1 19 package org.openharmonise.rm.resources.metadata.values; 20 21 import java.util.logging.*; 22 23 import org.openharmonise.commons.dsi.*; 24 import org.openharmonise.commons.dsi.dml.*; 25 import org.openharmonise.rm.*; 26 import org.openharmonise.rm.dsi.*; 27 import org.openharmonise.rm.publishing.*; 28 import org.openharmonise.rm.resources.*; 29 import org.openharmonise.rm.resources.lifecycle.*; 30 import org.w3c.dom.*; 31 32 33 41 public class Value 42 extends AbstractChildObject 43 implements DataStoreObject, Publishable, Editable { 44 45 49 public static final String TAG_VALUE = "Value"; 50 51 54 public static final String TAG_DESCRIPTION = "Description"; 55 56 59 public static final String TAG_CODE = "Code"; 60 61 64 public static final String ATTRIB_ORDER = "order"; 65 66 70 private static final String TBL_VALUE = "value"; 71 72 75 private static final String CLMN_ORDER = "order"; 76 77 80 private static final Logger m_logger = Logger.getLogger(Value.class.getName()); 81 82 static { 84 DatabaseInfo.getInstance().registerTableName( 85 Value.class.getName(), 86 TBL_VALUE); 87 } 88 89 93 public Value() { 94 super(); 95 } 96 97 102 public Value(AbstractDataStoreInterface dbintrf) { 103 super(dbintrf); 104 105 } 106 107 113 public Value(AbstractDataStoreInterface dbintrf, int nId) { 114 super(dbintrf, nId); 115 116 } 117 118 125 public Value(AbstractDataStoreInterface dbintrf, boolean bIsHist) { 126 super(dbintrf); 127 setHistorical(bIsHist); 128 } 129 130 139 public Value( 140 AbstractDataStoreInterface dbintrf, 141 int nId, 142 int nKey, 143 boolean bIsHist) { 144 super(dbintrf, nId, nKey, bIsHist); 145 146 } 147 148 155 public String getCode() throws DataAccessException { 156 return getName(); 157 } 158 159 165 public void setCode(String sCode) { 166 try { 167 this.setName(sCode); 168 } catch (InvalidNameException e) { 169 m_logger.log(Level.WARNING, e.getLocalizedMessage(), e); 170 } 171 } 172 173 180 public String getDescription() throws DataAccessException { 181 return (getSummary()); 182 } 183 184 190 public void setDescription(String sDesc) { 191 setSummary(sDesc); 192 } 193 194 197 public String toString() { 198 StringBuffer strBuff = new StringBuffer (); 199 200 strBuff 201 .append("Value Name:[" + m_sName + "] ") 202 .append("Value Description:[" + m_sSummary + "] ") 203 .append("Value ID:[" + m_nId + "] "); 204 205 return strBuff.toString(); 206 } 207 208 211 public JoinConditions getInstanceJoinConditions( 212 String sObjectTag, 213 boolean bIsOuter) 214 throws DataStoreException { 215 return null; 216 } 217 218 221 public ColumnRef getInstanceColumnRef(String sColumn, boolean bIsHist) 222 throws DataStoreException { 223 ColumnRef colref = null; 224 225 colref = super.getInstanceColumnRef(sColumn, bIsHist); 226 227 return colref; 228 } 229 230 233 public Element publish(Element topEl, HarmoniseOutput xmlDoc, State state) 234 throws PublishException { 235 236 Element docEl = null; 237 Text txt = null; 238 String sTagName = topEl.getTagName(); 239 240 if (sTagName.equals(TAG_DESCRIPTION)) { 241 try { 242 docEl = xmlDoc.createElement(sTagName); 243 txt = xmlDoc.createTextNode(getDescription()); 244 docEl.appendChild(txt); 245 } catch (DataAccessException e) { 246 throw new PublishException( 247 "Error occured getting description", e); 248 } 249 } else if (sTagName.equals(TAG_CODE)) { 250 try { 251 docEl = xmlDoc.createElement(sTagName); 252 txt = xmlDoc.createTextNode(getCode()); 253 docEl.appendChild(txt); 254 } catch (DataAccessException e) { 255 throw new PublishException( 256 "Error occured getting code", e); 257 } 258 } else { 259 docEl = super.publish(topEl, xmlDoc, state); 261 } 262 263 return docEl; 264 } 265 266 269 public void populate(Element xmlElement, State state) 270 throws PopulateException { 271 String sTagName = xmlElement.getTagName(); 272 Text txt; 273 274 if (sTagName.equalsIgnoreCase(TAG_CODE)) { 275 txt = (Text) xmlElement.getFirstChild(); 276 setCode(txt.getNodeValue()); 277 } else if (sTagName.equalsIgnoreCase(TAG_DESCRIPTION)) { 278 txt = (Text) xmlElement.getFirstChild(); 279 setDescription(txt.getNodeValue()); 280 } else { 281 super.populate(xmlElement, state); 282 } 283 } 284 285 288 public String getParentObjectClassName() { 289 return ValueGroup.class.getName(); 290 } 291 292 295 public String getDBTableName() { 296 297 return TBL_VALUE; 298 } 299 300 303 public String getTagName() { 304 return TAG_VALUE; 305 } 306 307 310 311 314 protected void addDataToSave(InsertStatement insert) 315 throws DataStoreException { 316 super.addDataToSave(insert); 317 } 318 319 322 protected void saveNonCoreData() throws EditException { 323 325 } 326 } | Popular Tags |