1 19 package org.openharmonise.rm.resources.content; 20 21 import java.util.*; 22 import java.util.logging.*; 23 24 import org.openharmonise.commons.dsi.*; 25 import org.openharmonise.commons.dsi.dml.JoinConditions; 26 import org.openharmonise.rm.DataAccessException; 27 import org.openharmonise.rm.dsi.*; 28 import org.openharmonise.rm.metadata.Profile; 29 import org.openharmonise.rm.publishing.Publishable; 30 import org.openharmonise.rm.resources.*; 31 import org.openharmonise.rm.resources.lifecycle.Editable; 32 33 34 35 36 37 45 public class Section extends AbstractParentObject implements DataStoreObject, 46 Publishable, 47 Editable, Cloneable , Comparable { 48 49 53 private static final String TBL_SECTION = "section"; 54 55 59 public static final String TAG_SECTION = "Section"; 60 61 65 private static List CHILD_CLASS_NAMES = null; 66 67 70 private static final Logger m_logger = Logger.getLogger(Section.class.getName()); 71 72 static { 74 DatabaseInfo.getInstance().registerTableName(Section.class.getName(),TBL_SECTION); 75 76 try { 77 CHILD_CLASS_NAMES = new Vector(); 78 CHILD_CLASS_NAMES.add(Document.class.getName()); 79 CHILD_CLASS_NAMES.add(Asset.class.getName()); 80 CHILD_CLASS_NAMES.add(Section.class.getName()); 81 82 } catch (Exception e) { 83 throw new RuntimeException (e.getMessage()); 84 } 85 } 86 87 88 91 public Section() { 92 super(); 93 94 } 95 96 101 public Section(AbstractDataStoreInterface dbintrf) { 102 super(dbintrf); 103 104 } 105 106 112 public Section(AbstractDataStoreInterface dbintrf, int nId) { 113 super(dbintrf, nId); 114 115 } 116 117 125 public Section(AbstractDataStoreInterface dbintrf, int nId, int nKey, boolean bIsHist) { 126 super(dbintrf, nId, nKey, bIsHist); 127 } 128 129 136 public Section(AbstractDataStoreInterface dbintrf, boolean bIsHist) { 137 super(dbintrf); 138 setHistorical(bIsHist); 139 } 140 141 142 145 public String toString() { 146 StringBuffer strBuff = new StringBuffer (); 147 148 try { 149 strBuff.append("Section Title:[" + m_sName + "] ") 150 .append("Section Summary:[" + m_sSummary + "] ") 151 .append("Section ID:[" + m_nId + "] ") 152 .append("Section status:[" + getStatus().getIntValue() + "] "); 153 154 Profile prof = getProfile(); 155 156 if(prof != null) { 157 strBuff.append("Profile:" + prof.toString()); 158 } 159 160 } catch (DataAccessException e) { 161 m_logger.log(Level.WARNING, e.getLocalizedMessage(), e); 162 } 163 164 return strBuff.toString(); 165 } 166 167 170 public String getParentObjectClassName() { 171 return getClass().getName(); 172 } 173 174 177 public String getDBTableName() { 178 return TBL_SECTION; 179 } 180 181 184 public JoinConditions getInstanceJoinConditions(String sObjectTag, boolean bIsOuter) throws DataStoreException { 185 JoinConditions joinConditions = new JoinConditions(); 186 DatabaseInfo dbInfo = DatabaseInfo.getInstance(); 187 String sChildTableName = null; 188 String sClassName = null; 189 190 if (sObjectTag.equals("Document") == true) { 191 sChildTableName = dbInfo.getTableName(Document.class.getName()); 192 sClassName = Document.class.getName(); 193 } else if (sObjectTag.equals("Asset") == true) { 194 sChildTableName = dbInfo.getTableName(Asset.class.getName()); 195 sClassName = Asset.class.getName(); 196 } else if (sObjectTag.equals("Section") == true) { 197 sChildTableName = dbInfo.getTableName(Section.class.getName()); 198 sClassName = Section.class.getName(); 199 } else { 200 throw new DataStoreException("Invalid child object."); 201 } 202 203 ColumnRef childKeyCol = getGroupChildJoinColumnRef(sChildTableName, CLMN_CHILD_KEY); 205 ColumnRef parentKeyCol = getGroupChildJoinColumnRef(sChildTableName, CLMN_PARENT_KEY); 206 207 joinConditions.addCondition(getInstanceColumnRef(AbstractObject.ATTRIB_KEY, false), parentKeyCol); 208 209 if (sObjectTag.equals("Document") == true) { 210 joinConditions.addCondition(Document.getColumnRef(sClassName, AbstractObject.ATTRIB_KEY, false), childKeyCol); 211 } else if (sObjectTag.equals("Asset") == true) { 212 joinConditions.addCondition(Asset.getColumnRef(sClassName, AbstractObject.ATTRIB_KEY, false), childKeyCol); 213 } else if (sObjectTag.equals("Section") == true) { 214 joinConditions.addCondition(getColumnRef(sClassName, AbstractObject.ATTRIB_KEY, false), childKeyCol); 215 } 216 217 return joinConditions; 218 } 219 220 223 public String getTagName() { 224 225 return TAG_SECTION; 226 } 227 228 229 232 public List getChildClassNames() { 233 return CHILD_CLASS_NAMES; 234 } 235 236 237 238 } | Popular Tags |