public int countAllResources() { // read all count String sql = singleStorageSql.getNumRowsSql(m_resourceTableName); List results = m_sql.dbRead(sql, null, new SqlReader() { public Object readSqlResultRecord(ResultSet result) { try { int count = result.getInt(1); return Integer.valueOf(count); } catch (SQLException ignore) { return null; } } }); if (results.isEmpty()) return 0; return ((Integer) results.get(0)).intValue(); }
public boolean checkResource(String id) { // just see if the record exists String sql = singleStorageSql.getResourceIdSql(m_resourceTableIdField, m_resourceTableName); Object fields[] = new Object[1]; fields[0] = caseId(id); List ids = m_sql.dbRead(sql, fields, null); return (!ids.isEmpty()); }
public List getAllResources(int first, int last) { String sql = singleStorageSql.getXmlSql(m_resourceTableIdField, m_resourceTableName, first, last); Object[] fields = singleStorageSql.getXmlFields(first, last); List xml = m_sql.dbRead(sql, fields, null); List rv = new Vector(); // process all result xml into user objects if (!xml.isEmpty()) { for (int i = 0; i < xml.size(); i++) { Entity entry = readResource((String) xml.get(i)); if (entry != null) rv.add(entry); } } return rv; }
public void removeResource(Edit edit) String statement = singleStorageSql.getDeleteSql(m_resourceTableIdField, m_resourceTableName); statement = singleStorageSql.getDeleteLocksSql();
public List getAllResourcesWhere(String field, String value) { // read all users from the db String sql = singleStorageSql.getXmlSql(field, m_resourceTableName); Object[] fields = new Object[1]; fields[0] = value; // %%% + "order by " + m_resourceTableOrderField + " asc"; return loadResources(sql, fields); }
String statement = singleStorageSql.getDeleteLocksSql();
public List getAllResourcesWhereLike(String field, String value) { String sql = singleStorageSql.getXmlLikeSql(field, m_resourceTableName); Object[] fields = new Object[1]; fields[0] = value; // %%% + "order by " + m_resourceTableOrderField + " asc"; return loadResources(sql, fields); }
/** * Get a limited number of Resources a given field matches a given value, returned in ascending order * by another field. The limit on the number of rows is specified by values for the first item to be * retrieved (indexed from 0) and the maxCount. * @param selectBy The name of a field to be used in selecting resources. * @param selectByValue The value to select. * @param orderBy The name of a field to be used in ordering the resources. * @param tableName The table on which the query is to operate * @param first A non-negative integer indicating the first record to return * @param maxCount A positive integer indicating the maximum number of rows to return * @return The list of all Resources that meet the criteria. */ public List getAllResourcesWhere(String selectBy, String selectByValue, String orderBy, int first, int maxCount) { // read all users from the db String sql = singleStorageSql.getXmlWhereLimitSql(selectBy, orderBy, m_resourceTableName, first, maxCount); Object[] fields = new Object[1]; fields[0] = selectByValue; // %%% + "order by " + m_resourceTableOrderField + " asc"; return loadResources(sql, fields); }
String sql = singleStorageSql.getXmlAndFieldSql(m_resourceTableIdField, m_resourceTableName);
String statement = singleStorageSql.getInsertLocks();
public void removeResource(Edit edit) String statement = singleStorageSql.getDeleteSql(m_resourceTableIdField, m_resourceTableName); statement = singleStorageSql.getDeleteLocksSql();
public List getAllResourcesWhere(String field, String value) { // read all users from the db String sql = singleStorageSql.getXmlSql(field, m_resourceTableName); Object[] fields = new Object[1]; fields[0] = value; // %%% + "order by " + m_resourceTableOrderField + " asc"; return loadResources(sql, fields); }
String statement = singleStorageSql.getDeleteLocksSql();
public List getAllResourcesWhereLike(String field, String value) { String sql = singleStorageSql.getXmlLikeSql(field, m_resourceTableName); Object[] fields = new Object[1]; fields[0] = value; // %%% + "order by " + m_resourceTableOrderField + " asc"; return loadResources(sql, fields); }
/** * Get a limited number of Resources a given field matches a given value, returned in ascending order * by another field. The limit on the number of rows is specified by values for the first item to be * retrieved (indexed from 0) and the maxCount. * @param selectBy The name of a field to be used in selecting resources. * @param selectByValue The value to select. * @param orderBy The name of a field to be used in ordering the resources. * @param tableName The table on which the query is to operate * @param first A non-negative integer indicating the first record to return * @param maxCount A positive integer indicating the maximum number of rows to return * @return The list of all Resources that meet the criteria. */ public List getAllResourcesWhere(String selectBy, String selectByValue, String orderBy, int first, int maxCount) { // read all users from the db String sql = singleStorageSql.getXmlWhereLimitSql(selectBy, orderBy, m_resourceTableName, first, maxCount); Object[] fields = new Object[1]; fields[0] = selectByValue; // %%% + "order by " + m_resourceTableOrderField + " asc"; return loadResources(sql, fields); }
String sql = singleStorageSql.getXmlAndFieldSql(m_resourceTableIdField, m_resourceTableName);
String statement = singleStorageSql.getInsertLocks();
public List getAllResources(int first, int last) { String sql = singleStorageSql.getXmlSql(m_resourceTableIdField, m_resourceTableName, first, last); Object[] fields = singleStorageSql.getXmlFields(first, last); List xml = m_sql.dbRead(sql, fields, null); List rv = new Vector(); // process all result xml into user objects if (!xml.isEmpty()) { for (int i = 0; i < xml.size(); i++) { Entity entry = readResource((String) xml.get(i)); if (entry != null) rv.add(entry); } } return rv; }
public List getAllResources() { List all = new Vector(); // read all users from the db String sql = singleStorageSql.getXmlSql(m_resourceTableName); // %%% + "order by " + m_resourceTableOrderField + " asc"; List xml = m_sql.dbRead(sql); // process all result xml into user objects if (!xml.isEmpty()) { for (int i = 0; i < xml.size(); i++) { Entity entry = readResource((String) xml.get(i)); if (entry != null) all.add(entry); } } return all; }
statement = singleStorageSql.getDeleteLocksSql();