Author: [log in to unmask] Date: Thu Oct 30 14:41:23 2014 New Revision: 1358 Log: Add a method that allows retrieval of a conditions set by class type. This method was originally in AbstractSvtConditionsConverter. Modified: java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/DatabaseConditionsManager.java Modified: java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/DatabaseConditionsManager.java ============================================================================= --- java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/DatabaseConditionsManager.java (original) +++ java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/DatabaseConditionsManager.java Thu Oct 30 14:41:23 2014 @@ -575,6 +575,26 @@ public <CollectionType extends ConditionsObjectCollection> ConditionsSeries<CollectionType> getConditionsSeries(String conditionsKey) { return conditionsSeriesConverter.createSeries(conditionsKey); } + + /** + * Get a given collection of the given type from the conditions database. + * + * @param type Class type + * @return A collection of objects of the given type from the conditions database + */ + public <CollectionType extends ConditionsObjectCollection> CollectionType getCollection(Class<CollectionType> type){ + + // Get the table name from the database configuration + TableMetaData metaData = this.findTableMetaData(type); + if(metaData == null) + throw new RuntimeException("Table name data for condition of type " + type.getSimpleName() + " was not found."); + String tableName = metaData.getTableName(); + + // FIXME: This should be changed to catch a conditions record not found exception instead of + // a runtime exception. + CollectionType conditionsCollection = this.getCachedConditions(type, tableName).getCachedData(); + return conditionsCollection; + } /** * Simple utility method to cast the generic <code>ConditionsManager</code> to this class.