From: cvs@openprivacy.orgCVS update: sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util
Date: Wednesday March 14, 19101 @ 16:51
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-serv3967/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util
Modified Files:
InsertReputation.java
Log Message:
properties table was not accepting multiple properties for the same reputation because of unique index
*****************************************************************
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.2
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.2&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.2&r2=1.1
-----------------------------------
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.1 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.1 Wed Mar 14 16:02:24 2001
+++ sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util/InsertReputation.java Wed Mar 14 16:51:13 2001
@@ -34,13 +34,29 @@
* database.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: InsertReputation.java,v 1.1 2001/03/15 00:02:24 burton Exp $
+ * @version $Id: InsertReputation.java,v 1.2 2001/03/15 00:51:13 burton Exp $
*/
public class InsertReputation {
private DatabaseConnectionPool dcp = null;
private Reputation reputation = null;
private SimpleQueryEngine sqe = null;
+
+ /**
+ * 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,
@@ -56,7 +72,7 @@
*
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: InsertReputation.java,v 1.1 2001/03/15 00:02:24 burton Exp $
+ * @version $Id: InsertReputation.java,v 1.2 2001/03/15 00:51:13 burton Exp $
*/
private void insertIntoReputationsTable( DatabaseConnectionPool dcp )
throws Exception {
@@ -91,7 +107,7 @@
*
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: InsertReputation.java,v 1.1 2001/03/15 00:02:24 burton Exp $
+ * @version $Id: InsertReputation.java,v 1.2 2001/03/15 00:51:13 burton Exp $
*/
private void insertIntoIdentifiersTable( DatabaseConnectionPool dcp, Payload payload )
throws Exception {
@@ -124,56 +140,77 @@
*
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: InsertReputation.java,v 1.1 2001/03/15 00:02:24 burton Exp $
+ * @version $Id: InsertReputation.java,v 1.2 2001/03/15 00:51:13 burton Exp $
*/
private void insertIntoPropertiesTable( DatabaseConnectionPool dcp, Payload payload )
throws Exception {
//get the identifier id
- Select select_identifier = new Select();
- select_identifier.setDatabaseConnectionPool( dcp )
- .setTable( "identifiers" )
- .addString( "uri", payload.getIdentifier().toString() );
+
+ if ( 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_identifier.commit();
- select_identifier.getResultSet().next();
- int identifier = select_identifier.getResultSet().getInt( "pk" );
+ select_identifier.getResultSet().next();
+ table_properties_fk_identifier = select_identifier.getResultSet().getInt( "pk" );
+
+ }
+
+
//get the reputation id
- Select select_reputation = new Select();
- select_reputation.setDatabaseConnectionPool( dcp )
- .setTable( "reputations" )
- .addString( "uri", payload.getIdentifier().toString() );
- select_reputation.commit();
+ if ( table_properties_fk_reputation == -1 ) {
+
+ Select select_reputation = new Select();
+ select_reputation.setDatabaseConnectionPool( dcp )
+ .setTable( "reputations" )
+ .addString( "uri", payload.getIdentifier().toString() );
- select_reputation.getResultSet().next();
- int reputation = select_reputation.getResultSet().getInt( "pk" );
+ select_reputation.commit();
+
+ select_reputation.getResultSet().next();
+ table_properties_fk_reputation = select_reputation.getResultSet().getInt( "pk" );
+
+ }
+
//go over all properties and add them.
PropertyManagerPayload pmp = (PropertyManagerPayload)payload;
-
- //add all properties
- Enumeration keys = pmp.getKeys();
+ //only update if there are no properties already entered from this reputation.
- while ( keys.hasMoreElements() ) {
+ Select verify = new Select();
- //only update if there are no properties already entered from this reputation.
+ if ( propertiesVerified == false ) {
- Select verify = new Select();
verify.setDatabaseConnectionPool( dcp )
.setTable( "properties" )
- .addInteger( "reputation", reputation )
- .addInteger( "identifier", identifier );
+ .addInteger( "reputation", table_properties_fk_reputation )
+ .addInteger( "identifier", table_properties_fk_identifier );
verify.commit();
+ }
- if ( verify.getResultSet().next() == false) {
-
+ if ( this.propertiesVerified == false && verify.getResultSet().next() == false ) {
+
+ this.propertiesVerified = true;
+
+ //add all properties
+
+ Enumeration keys = pmp.getKeys();
+
+
+ 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();
@@ -182,30 +219,30 @@
Insert insert = new Insert();
insert.setDatabaseConnectionPool( dcp )
.setTable( "properties" )
- .addInteger( "reputation", reputation )
- .addInteger( "identifier", identifier )
+ .addInteger( "reputation", table_properties_fk_reputation )
+ .addInteger( "identifier", table_properties_fk_identifier )
.addString( "name", name )
.addString( "value", value )
.addString( "type", "string" );
insert.commit();
- } else {
-
- break;
-
}
+
+ } else {
- }
+ sqe.getLogger().warning( "Payload not being indexed because it is already in the database: " + payload.getTypeReference() );
+
+ }
+
+ }
- }
-
/**
* Insert this reputation.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: InsertReputation.java,v 1.1 2001/03/15 00:02:24 burton Exp $
+ * @version $Id: InsertReputation.java,v 1.2 2001/03/15 00:51:13 burton Exp $
*/
public void commit() throws Exception {
@@ -219,13 +256,19 @@
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() );
+
+ }
}
This archive was generated by hypermail 2b30 : Wed Mar 14 2001 - 16:51:15 PST