Skip to content
Browse files

Database query for resource basic information

  • Loading branch information...
1 parent 0136e63 commit a8d41f6986d8feb0dcda65d11e42431c68f5290a @carlasouza carlasouza committed Jul 15, 2011
View
5 ...service/java/source/src/org/globus/workspace/persistence/PersistenceAdapterConstants.java
@@ -27,6 +27,10 @@
public static final String SQL_SELECT_RESOURCES =
"SELECT id FROM resources";
+ //TODO add select to resource state
+ public static final String SQL_SELECT_RESOURCE_BASIC_INFORMATION =
+ "SELECT id, name, state FROM resources";
+
public static final String SQL_SELECT_ALL_ASSOCIATIONS =
"SELECT * FROM associations";
@@ -242,6 +246,7 @@
public static final String[] PREPARED_STATEMENTS = {
SQL_SELECT_RESOURCES,
+ SQL_SELECT_RESOURCE_BASIC_INFORMATION,
SQL_SELECT_ALL_ASSOCIATIONS,
SQL_SET_STATE,
SQL_SET_OPS_ENABLED,
View
58 service/service/java/source/src/org/globus/workspace/persistence/PersistenceAdapterImpl.java
@@ -870,6 +870,64 @@ private void removeGroupOrEnsemble(String id)
}
}
+ public List<ResourceEntry> findWorkspacesBasicInformation() throws WorkspaceDatabaseException, SQLException {
+
+ if (this.dbTrace) {
+ logger.trace("findActiveWorkspacesIDs()");
+ }
+
+ Connection c = null;
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+ try {
+ c = getConnection();
+ pstmt = c.prepareStatement(SQL_SELECT_RESOURCE_BASIC_INFORMATION);
+ rs = pstmt.executeQuery();
+
+
+ if (rs == null || !rs.next())
+ return null;
+
+ final ArrayList<ResourceEntry> results = new ArrayList<ResourceEntry>();
+ do {
+
+ Integer id = new Integer(rs.getInt(1));
+ String name = rs.getString(2);
+ Integer state = new Integer(rs.getInt(3));
+
+ ResourceEntry res = new ResourceEntry(id);
+ res.setName(id);
+ res.setState(state);
+
+ results.add(res);
+ if (this.dbTrace) {
+ logger.trace("found id: " + id);
+ }
+ } while (rs.next());
+
+
+ return results;
+
+ } catch (SQLException e) {
+ logger.error("",e);
+ throw new WorkspaceDatabaseException(e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ if (c != null) {
+ returnConnection(c);
+ }
+ } catch (SQLException sql) {
+ logger.error("SQLException in finally cleanup", sql);
+ }
+ }
+ }
+
public boolean isActiveWorkspaceID(int id)
throws WorkspaceDatabaseException {

0 comments on commit a8d41f6

Please sign in to comment.
Something went wrong with that request. Please try again.