From: cvs@openprivacy.orgCVS update: sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util
Date: Wednesday March 14, 19101 @ 17:05
Author: burton
CVSWEB Options: -------------------
Main CVSWeb: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi
View this module: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util
-----------------------------------
Update of /usr/local/cvs/public/sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util
In directory giga:/tmp/cvs-serv4045/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util
Modified Files:
InsertReputation.java
Log Message:
fixed bug where additional payloads weren't geting added. payloads are now getting timestamped.
*****************************************************************
File: sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util/InsertReputation.java
CVSWEB Options: -------------------
CVSWeb: Annotate this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util/InsertReputation.java?annotate=1.3
CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util/InsertReputation.java?rev=1.3&content-type=text/x-cvsweb-markup
CVSWeb: Diff to previous version: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util/InsertReputation.java.diff?r1=1.3&r2=1.2
-----------------------------------
Index: sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util/InsertReputation.java
diff -u sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util/InsertReputation.java:1.2 sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util/InsertReputation.java:1.3
--- sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util/InsertReputation.java:1.2 Wed Mar 14 16:51:13 2001
+++ sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util/InsertReputation.java Wed Mar 14 17:05:34 2001
@@ -34,7 +34,7 @@
* database.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: InsertReputation.java,v 1.2 2001/03/15 00:51:13 burton Exp $
+ * @version $Id: InsertReputation.java,v 1.3 2001/03/15 01:05:34 burton Exp $
*/
public class InsertReputation {
@@ -46,17 +46,6 @@
* FK from the properties table to the identify table. -1 if not defined.
*/
int table_properties_fk_reputation = -1;
-
- /**
- * FK from the properties table to the identify table. -1 if not defined.
- */
- int table_properties_fk_identifier = -1;
-
- /**
- * true if we have already verified that this reputation has no properties
- * in the properties table.
- */
- boolean propertiesVerified = false;
public InsertReputation( DatabaseConnectionPool dcp,
Reputation reputation,
@@ -72,7 +61,7 @@
*
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: InsertReputation.java,v 1.2 2001/03/15 00:51:13 burton Exp $
+ * @version $Id: InsertReputation.java,v 1.3 2001/03/15 01:05:34 burton Exp $
*/
private void insertIntoReputationsTable( DatabaseConnectionPool dcp )
throws Exception {
@@ -107,7 +96,7 @@
*
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: InsertReputation.java,v 1.2 2001/03/15 00:51:13 burton Exp $
+ * @version $Id: InsertReputation.java,v 1.3 2001/03/15 01:05:34 burton Exp $
*/
private void insertIntoIdentifiersTable( DatabaseConnectionPool dcp, Payload payload )
throws Exception {
@@ -140,30 +129,27 @@
*
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: InsertReputation.java,v 1.2 2001/03/15 00:51:13 burton Exp $
+ * @version $Id: InsertReputation.java,v 1.3 2001/03/15 01:05:34 burton Exp $
*/
private void insertIntoPropertiesTable( DatabaseConnectionPool dcp, Payload payload )
throws Exception {
- //get the identifier id
+ //get the identifier id.. always compute this because it changes per payload.
- if ( table_properties_fk_identifier == -1 ) {
+ int table_properties_fk_identifier = -1;
- Select select_identifier = new Select();
- select_identifier.setDatabaseConnectionPool( dcp )
- .setTable( "identifiers" )
- .addString( "uri", payload.getIdentifier().toString() );
-
- select_identifier.commit();
+ Select select_identifier = new Select();
+ select_identifier.setDatabaseConnectionPool( dcp )
+ .setTable( "identifiers" )
+ .addString( "uri", payload.getIdentifier().toString() );
- select_identifier.getResultSet().next();
- table_properties_fk_identifier = select_identifier.getResultSet().getInt( "pk" );
+ select_identifier.commit();
- }
-
+ select_identifier.getResultSet().next();
+ table_properties_fk_identifier = select_identifier.getResultSet().getInt( "pk" );
- //get the reputation id
+ //get the reputation id (if we already haven't figured it out)
if ( table_properties_fk_reputation == -1 ) {
@@ -184,56 +170,33 @@
//go over all properties and add them.
PropertyManagerPayload pmp = (PropertyManagerPayload)payload;
- //only update if there are no properties already entered from this reputation.
- Select verify = new Select();
+ //add all properties
- if ( propertiesVerified == false ) {
+ Enumeration keys = pmp.getKeys();
- verify.setDatabaseConnectionPool( dcp )
- .setTable( "properties" )
- .addInteger( "reputation", table_properties_fk_reputation )
- .addInteger( "identifier", table_properties_fk_identifier );
-
- verify.commit();
-
- }
-
- if ( this.propertiesVerified == false && verify.getResultSet().next() == false ) {
-
- this.propertiesVerified = true;
-
- //add all properties
-
- Enumeration keys = pmp.getKeys();
-
- while ( keys.hasMoreElements() ) {
+ while ( keys.hasMoreElements() ) {
- //FIXME: I am adding all records as strings here. This is a BAD
- //idea. It is much better to add the appropriate types.
- String name = (String)keys.nextElement();
- String value = pmp.getString( name );
+ //FIXME: I am adding all records as strings here. This is a BAD
+ //idea. It is much better to add the appropriate types.
+ String name = (String)keys.nextElement();
+ String value = pmp.getProperty( name ).toString();
- Insert insert = new Insert();
- insert.setDatabaseConnectionPool( dcp )
- .setTable( "properties" )
- .addInteger( "reputation", table_properties_fk_reputation )
- .addInteger( "identifier", table_properties_fk_identifier )
- .addString( "name", name )
- .addString( "value", value )
- .addString( "type", "string" );
+ Insert insert = new Insert();
+ insert.setDatabaseConnectionPool( dcp )
+ .setTable( "properties" )
+ .addInteger( "reputation", table_properties_fk_reputation )
+ .addInteger( "identifier", table_properties_fk_identifier )
+ .addString( "name", name )
+ .addString( "value", value )
+ .addString( "type", "string" );
- insert.commit();
+ insert.commit();
- }
-
- } else {
-
- sqe.getLogger().warning( "Payload not being indexed because it is already in the database: " + payload.getTypeReference() );
-
}
+
}
@@ -242,38 +205,58 @@
* Insert this reputation.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: InsertReputation.java,v 1.2 2001/03/15 00:51:13 burton Exp $
+ * @version $Id: InsertReputation.java,v 1.3 2001/03/15 01:05:34 burton Exp $
*/
public void commit() throws Exception {
-
- insertIntoReputationsTable( dcp );
- Enumeration payloads = reputation.getPayloads();
+ //FIXME: make sure this reputation (with this signature) does not already exist!!
+
+ //only update if there are no properties already entered from this reputation.
- while ( payloads.hasMoreElements() ) {
+ Select verify = new Select();
- Payload current = (Payload)payloads.nextElement();
+ verify.setDatabaseConnectionPool( dcp )
+ .setTable( "reputations" )
+ .addString( "uri", reputation.getURI().toString() );
- if ( sqe.supports( current ) ) {
+ verify.commit();
- sqe.getLogger().message( "Indexing payload: " + current.getTypeReference() );
+ //determine if this payload should be added.
+ if ( verify.getResultSet().next() == false ) {
+
+ insertIntoReputationsTable( dcp );
+
+ Enumeration payloads = reputation.getPayloads();
+
+ while ( payloads.hasMoreElements() ) {
- //insert records into the identifiers table
- insertIntoIdentifiersTable( dcp, current );
-
- //insert records into the properties table
- insertIntoPropertiesTable( dcp, current );
+ Payload current = (Payload)payloads.nextElement();
+
+ if ( sqe.supports( current ) ) {
+
+ sqe.getLogger().message( "Indexing payload: " + current.getTypeReference() );
+
+ //insert records into the identifiers table
+ insertIntoIdentifiersTable( dcp, current );
+
+ //insert records into the properties table
+ insertIntoPropertiesTable( dcp, current );
- } else {
-
- sqe.getLogger().warning( "The given payload is not supported: " + current.getTypeReference() );
-
- }
+ } else {
- }
+ sqe.getLogger().warning( "The given payload is not supported: " + current.getTypeReference() );
+
+ }
+
+ }
- }
+ } else {
+ sqe.getLogger().warning( "The given reputation already is already indexed: " + reputation.getURI() );
+ }
+
+ }
+
}
This archive was generated by hypermail 2b30 : Wed Mar 14 2001 - 17:05:35 PST