1 19 package org.openharmonise.rm.resources.metadata.properties; 20 21 import java.util.*; 22 23 import org.openharmonise.commons.dsi.*; 24 import org.openharmonise.commons.dsi.dml.JoinConditions; 25 import org.openharmonise.rm.DataAccessException; 26 import org.openharmonise.rm.dsi.*; 27 import org.openharmonise.rm.publishing.Publishable; 28 import org.openharmonise.rm.resources.*; 29 import org.openharmonise.rm.resources.lifecycle.Editable; 30 31 32 41 public class PropertyGroup 42 extends AbstractParentObject 43 implements Editable, DataStoreObject, Publishable, Cloneable { 44 45 48 protected static String TYPE_PROPERTYGROUP = PropertyGroup.class.getName(); 49 52 private static List CHILD_CLASS_NAMES = null; 53 54 58 public static final String TAG_PROPERTYGROUP = "PropertyGroup"; 59 60 64 private static final String TBL_PROPERTYGROUP = "prop_group"; 65 66 static { 68 CHILD_CLASS_NAMES = new Vector(); 69 CHILD_CLASS_NAMES.add(Property.class.getName()); 70 CHILD_CLASS_NAMES.add(PropertyGroup.class.getName()); 71 72 DatabaseInfo.getInstance().registerTableName( 73 PropertyGroup.class.getName(), 74 TBL_PROPERTYGROUP); 75 76 } 77 78 82 public PropertyGroup() { 83 super(); 84 } 85 86 92 public PropertyGroup(AbstractDataStoreInterface dbinterf) { 93 super(dbinterf); 94 95 } 96 97 105 public PropertyGroup(AbstractDataStoreInterface dbinterf, boolean bHist) { 106 super(dbinterf); 107 setHistorical(bHist); 108 } 109 110 116 public PropertyGroup(AbstractDataStoreInterface dbinterf, int nId) { 117 super(dbinterf, nId); 118 119 } 120 121 130 public PropertyGroup( 131 AbstractDataStoreInterface dbinterf, 132 int nId, 133 int nKey, 134 boolean bHist) { 135 super(dbinterf, nId, nKey, bHist); 136 137 } 138 139 147 public static List getTopLevelGroups(AbstractDataStoreInterface dbinterf) 148 throws DataAccessException { 149 return AbstractParentObject.getTopLevelGroups( 150 dbinterf, 151 new PropertyGroup()); 152 } 153 154 157 public List getChildClassNames() { 158 return CHILD_CLASS_NAMES; 159 } 160 161 164 public String getParentObjectClassName() { 165 return getClass().getName(); 166 } 167 168 171 public String getDBTableName() { 172 return TBL_PROPERTYGROUP; 173 } 174 175 178 public JoinConditions getInstanceJoinConditions( 179 String sObjectTag, 180 boolean bIsOuter) 181 throws DataStoreException { 182 JoinConditions joinConditions = new JoinConditions(); 183 DatabaseInfo dbInfo = DatabaseInfo.getInstance(); 184 String sChildTableName = null; 185 String sClassName = null; 186 187 if (sObjectTag.equals("Property") == true) { 188 sChildTableName = dbInfo.getTableName(Property.class.getName()); 189 sClassName = Property.class.getName(); 190 } else if (sObjectTag.equals("PropertyGroup") == true) { 191 sChildTableName = 192 dbInfo.getTableName(PropertyGroup.class.getName()); 193 sClassName = PropertyGroup.class.getName(); 194 } else { 195 throw new DataStoreException("Invalid child object"); 196 } 197 198 ColumnRef childKeyCol = 200 getGroupChildJoinColumnRef(sChildTableName, CLMN_CHILD_KEY); 201 ColumnRef parentKeyCol = 202 getGroupChildJoinColumnRef(sChildTableName, CLMN_PARENT_KEY); 203 204 joinConditions.addCondition( 205 getInstanceColumnRef(AbstractObject.ATTRIB_KEY, false), 206 parentKeyCol); 207 208 if (sObjectTag.equals("Property") == true) { 209 joinConditions.addCondition( 210 Property.getColumnRef( 211 sClassName, 212 AbstractObject.ATTRIB_KEY, 213 false), 214 childKeyCol); 215 } else if (sObjectTag.equals("PropertyGroup") == true) { 216 joinConditions.addCondition( 217 PropertyGroup.getColumnRef( 218 sClassName, 219 AbstractObject.ATTRIB_KEY, 220 false), 221 childKeyCol); 222 } 223 224 return joinConditions; 225 } 226 227 230 public String getTagName() { 231 232 return TAG_PROPERTYGROUP; 233 } 234 235 } | Popular Tags |