implemented conference hotlists and SIG list management from the Top page;

cleaned up remaining SQL statements using text columns instead of column
indexes with the ResultSet; fleshed out specifics in the TODO for
SIG administration
This commit is contained in:
Eric J. Bowersox
2001-02-19 02:56:16 +00:00
parent 7b7e6be996
commit e23de5dae6
32 changed files with 1400 additions and 111 deletions
@@ -149,4 +149,8 @@ public interface ConferenceContext
public abstract SIGContext getEnclosingSIG();
public abstract void removeFromHotlist() throws DataException;
public abstract void setHotlistSequence(int seq) throws DataException;
} // end interface ConferenceContext
@@ -151,4 +151,6 @@ public interface SIGContext extends SearchMode
public abstract List getMemberList() throws DataException;
public abstract boolean canManageConferences();
} // end interface SIGContext
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Community System.
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@@ -520,7 +520,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
{ // get a database connection
conn = datapool.getConnection();
Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT COUNT(*) AS total FROM refcategory WHERE name ");
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM refcategory WHERE name ");
switch (mode)
{ // compose SQL in different ways depending on the search term
@@ -556,7 +556,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
if (!(rs.next()))
throw new InternalStateError("getSearchCategoryCount search failure (MUST have 1 row!)");
return rs.getInt("total");
return rs.getInt(1);
} // end try
catch (SQLException e)
@@ -1288,7 +1288,7 @@ class ConferenceCoreData implements ConferenceData
rs = stmt.executeQuery(sql.toString());
if (!(rs.next()))
throw new InternalStateError("bogus query in createConference - must return at least 1 row!");
new_sequence = (short)(rs.getShort(1) + 100);
new_sequence = (short)(rs.getShort(1) + 10);
// insert the record into the conferences table!
sql.setLength(0);
@@ -572,9 +572,23 @@ class ConferenceSIGContextImpl implements ConferenceSIGContext
public void setHideList(SIGBackend sig, boolean flag) throws DataException
{
if (logger.isDebugEnabled())
logger.debug("setHideList(conf #" + confid + ", " + flag + ")");
if (deleted)
{ // aiyaiyai - we're deleted
logger.error("conference deleted, can't change a thing");
throw new DataException("This conference has been deleted.");
} // end if
if (flag==hide_list)
{ // this is a no-op
logger.warn("setHideList for this conference is a no-op");
return;
} // end if
Connection conn = null; // database connection
AuditRecord ar = null; // audit record
@@ -585,8 +599,10 @@ class ConferenceSIGContextImpl implements ConferenceSIGContext
// create the SQL statement
Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE sigtoconf SET hide_list = ");
sql.append(hide_list ? '1' : '0').append(" WHERE sigid = ").append(this.sig.realSIGID());
sql.append(flag ? '1' : '0').append(" WHERE sigid = ").append(this.sig.realSIGID());
sql.append(" AND confid = ").append(confid).append(';');
if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString());
// execute the update
stmt.executeUpdate(sql.toString());
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Community System.
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@@ -1359,6 +1359,70 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
} // end getEnclosingSIG
public void removeFromHotlist() throws DataException
{
Connection conn = null;
try
{ // retrieve a connection from the datapool
conn = datapool.getConnection();
Statement stmt = conn.createStatement();
// create the DELETE statement and just execute it blind (if this conference is not in the hotlist,
// the DELETE is a no-op).
StringBuffer sql = new StringBuffer("DELETE FROM confhotlist WHERE uid = ");
sql.append(sig.realUID()).append(" AND sigid = ").append(sig.realSIGID()).append(" AND confid = ");
sql.append(confid).append(';');
stmt.executeUpdate(sql.toString());
} // end try
catch (SQLException e)
{ // this becomes a DataException
logger.error("DB error removing from hotlist: " + e.getMessage(),e);
throw new DataException("error removing from hotlist: " + e.getMessage(),e);
} // end catch
finally
{ // make sure we release the connection before we go
if (conn!=null)
datapool.releaseConnection(conn);
} // end finally
} // end removeFromHotlist
public void setHotlistSequence(int seq) throws DataException
{
Connection conn = null;
try
{ // retrieve a connection from the datapool
conn = datapool.getConnection();
Statement stmt = conn.createStatement();
// create the UPDATE statement and just execute it blind (if this conference is not in the hotlist,
// the UPDATE is a no-op).
StringBuffer sql = new StringBuffer("UPDATE confhotlist SET sequence = ");
sql.append(seq).append(" WHERE uid = ").append(sig.realUID()).append(" AND sigid = ");
sql.append(sig.realSIGID()).append(" AND confid = ").append(confid).append(';');
stmt.executeUpdate(sql.toString());
} // end try
catch (SQLException e)
{ // this becomes a DataException
logger.error("DB error setting hotlist sequence: " + e.getMessage(),e);
throw new DataException("error setting hotlist sequence: " + e.getMessage(),e);
} // end catch
finally
{ // make sure we release the connection before we go
if (conn!=null)
datapool.releaseConnection(conn);
} // end finally
} // end setHotlistSequence
/*--------------------------------------------------------------------------------
* Implementations from interface UserBackend
*--------------------------------------------------------------------------------
@@ -651,9 +651,9 @@ class ContactInfoImpl implements ContactInfo, Stashable
// now read back the contact ID we just added
int new_contactid;
ResultSet rs = stmt.executeQuery("SELECT LAST_INSERT_ID() AS blort;");
ResultSet rs = stmt.executeQuery("SELECT LAST_INSERT_ID();");
if (rs.next())
new_contactid = rs.getInt("blort");
new_contactid = rs.getInt(1);
else
throw new DataException("unable to read back new contact ID");
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Community System.
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@@ -1280,7 +1280,7 @@ class SIGCoreData implements SIGData, SIGDataBackend
{ // get a database connection and create the appropriate SELECT statement
conn = datapool.getConnection();
Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT COUNT(*) AS total FROM sigmember WHERE sigid = ");
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM sigmember WHERE sigid = ");
sql.append(sigid);
if (!include_hidden)
sql.append(" AND hidden = 0");
@@ -1291,7 +1291,7 @@ class SIGCoreData implements SIGData, SIGDataBackend
if (!(rs.next()))
throw new InternalStateError("getMemberCount query failure - must have ONE row!");
return rs.getInt("total");
return rs.getInt(1);
} // end try
catch (SQLException e)
@@ -1709,9 +1709,9 @@ class SIGCoreData implements SIGData, SIGDataBackend
stmt.executeUpdate(sql.toString()); // here we go!
// Get the SIGID of the new SIG!
rs = stmt.executeQuery("SELECT LAST_INSERT_ID() AS blort;");
rs = stmt.executeQuery("SELECT LAST_INSERT_ID();");
if (rs.next())
new_sigid = rs.getInt("blort");
new_sigid = rs.getInt(1);
else
{ // we should have gotten a SIGID back!
logger.error("readback of new SIGID failed!");
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Community System.
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@@ -1124,6 +1124,20 @@ class SIGUserContextImpl implements SIGContext, SIGBackend
} // end getMemberList
public boolean canManageConferences()
{
SIGData sd = getSIGDataNE();
if (sd==null)
return false;
if (!(sd.checkMembership(level,is_member)))
return false;
if (sd.isFeaturePresent("CONF"))
return sd.canCreateSIGSubObjects(level);
else
return false;
} // end canManageConferences
/*--------------------------------------------------------------------------------
* Implementations from interface UserBackend
*--------------------------------------------------------------------------------
@@ -1241,20 +1255,18 @@ class SIGUserContextImpl implements SIGContext, SIGBackend
{ // get a database connection
conn = datapool.getConnection();
Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT sm.sigid AS sigid, sm.granted_lvl AS level, "
+ "sm.locked AS locked, s.signame AS name, s.alias AS alias "
StringBuffer sql = new StringBuffer("SELECT sm.sigid, sm.granted_lvl, sm.locked, s.signame, s.alias "
+ "FROM sigmember sm, sigs s WHERE sm.sigid = s.sigid "
+ "AND sm.uid = ");
sql.append(user.realUID()).append(" ORDER BY s.signame;");
ResultSet rs = stmt.executeQuery(sql.toString());
while (rs.next())
{ // create the user contexts and add them to the return vector
int the_sigid = rs.getInt("sigid");
int the_sigid = rs.getInt(1);
if (logger.isDebugEnabled())
logger.debug("...found SIG #" + String.valueOf(the_sigid));
SIGContext tmp = new SIGUserContextImpl(engine,user,datapool,the_sigid,rs.getInt("level"),
rs.getBoolean("locked"),rs.getString("name"),
rs.getString("alias"));
SIGContext tmp = new SIGUserContextImpl(engine,user,datapool,the_sigid,rs.getInt(2),rs.getBoolean(3),
rs.getString(4),rs.getString(5));
rc.add(tmp);
} // end while
@@ -1457,7 +1469,7 @@ class SIGUserContextImpl implements SIGContext, SIGBackend
{ // get a database connection
conn = datapool.getConnection();
Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT COUNT(*) AS total FROM sigs WHERE ");
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM sigs WHERE ");
switch (field)
{
@@ -1506,7 +1518,7 @@ class SIGUserContextImpl implements SIGContext, SIGBackend
if (!(rs.next()))
throw new InternalStateError("getSearchSIGCount search failure (MUST have 1 row!)");
return rs.getInt("total");
return rs.getInt(1);
} // end try
catch (SQLException e)
@@ -1590,7 +1602,7 @@ class SIGUserContextImpl implements SIGContext, SIGBackend
{ // get a database connection
conn = datapool.getConnection();
Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT COUNT(*) AS total FROM sigs WHERE catid = ");
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM sigs WHERE catid = ");
sql.append(catid);
if (Capability.hideHiddenDirectorySIGs(user.realBaseLevel()))
sql.append(" AND hide_dir = 0");
@@ -1605,7 +1617,7 @@ class SIGUserContextImpl implements SIGContext, SIGBackend
if (!(rs.next()))
throw new InternalStateError("getNumSIGsInCategory search failure (MUST have 1 row!)");
return rs.getInt("total");
return rs.getInt(1);
} // end try
catch (SQLException e)