CVS update: sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple

From: cvs@openprivacy.org
Date: Wed Mar 14 2001 - 16:02:24 PST

  • Next message: cvs@openprivacy.org: "CVS update: sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/util"

    Date: Wednesday March 14, 19101 @ 16:02
    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

    -----------------------------------

    Update of /usr/local/cvs/public/sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple
    In directory giga:/tmp/cvs-serv3720/src/java/org/openprivacy/sierra/query/talon/implementations/simple

    Modified Files:
            SimpleQueryEngine.java SimpleQueryManager.java
    Log Message:
    moved reputation insert into a dedicated package/class

    *****************************************************************
    File: sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/SimpleQueryEngine.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/SimpleQueryEngine.java?annotate=1.9

    CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/SimpleQueryEngine.java?rev=1.9&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/SimpleQueryEngine.java.diff?r1=1.9&r2=1.8

    -----------------------------------

    Index: sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/SimpleQueryEngine.java
    diff -u sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/SimpleQueryEngine.java:1.8 sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/SimpleQueryEngine.java:1.9
    --- sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/SimpleQueryEngine.java:1.8 Wed Mar 14 01:59:37 2001
    +++ sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/SimpleQueryEngine.java Wed Mar 14 16:02:24 2001
    @@ -18,27 +18,30 @@
     package org.openprivacy.sierra.query.talon.implementations.simple;
     
     
    +
     import java.io.*;
     import java.net.*;
    -import java.util.*;
     import java.sql.*;
    +import java.util.*;
    +import org.openprivacy.sierra.query.*;
    +import org.openprivacy.sierra.query.talon.implementations.simple.util.*;
     import org.openprivacy.sierra.query.talon.interfaces.*;
     import org.openprivacy.sierra.rce.talon.interfaces.*;
    -import org.openprivacy.sierra.reputation.talon.interfaces.*;
     import org.openprivacy.sierra.reputation.talon.implementations.*;
    +import org.openprivacy.sierra.reputation.talon.interfaces.*;
     import org.openprivacy.sierra.store.talon.interfaces.*;
    -import org.openprivacy.sierra.util.SierraException;
     import org.openprivacy.sierra.util.*;
    +import org.openprivacy.sierra.util.SierraException;
     import org.openprivacy.sierra.util.sql.*;
     import talon.*;
    -import talon.references.*;
     import talon.interfaces.*;
    +import talon.references.*;
     import talon.util.net.*;
     
     /**
      * @see QueryManager
      * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: SimpleQueryEngine.java,v 1.8 2001/03/14 09:59:37 burton Exp $
    + * @version $Id: SimpleQueryEngine.java,v 1.9 2001/03/15 00:02:24 burton Exp $
      */
     public class SimpleQueryEngine extends BaseComponent implements Component, QueryEngine {
     
    @@ -61,10 +64,22 @@
         /**
          * @see QueryEngine
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: SimpleQueryEngine.java,v 1.8 2001/03/14 09:59:37 burton Exp $
    + * @version $Id: SimpleQueryEngine.java,v 1.9 2001/03/15 00:02:24 burton Exp $
          */
         public Result execute( Query query ) throws SierraException {
    - return null;
    +
    + if ( supports( query ) ) {
    +
    + //FIXME: shouldn't return null
    + return null;
    +
    + } else {
    +
    + throw new QueryNotSupportedException();
    +
    + }
    +
    +
         }
     
         
    @@ -72,7 +87,7 @@
          * Add a reputation for indexing...
          *
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: SimpleQueryEngine.java,v 1.8 2001/03/14 09:59:37 burton Exp $
    + * @version $Id: SimpleQueryEngine.java,v 1.9 2001/03/15 00:02:24 burton Exp $
          */
         public void putReputation( Reputation reputation ) throws SierraException {
     
    @@ -90,27 +105,8 @@
                     StringBuffer insert = new StringBuffer();
     
                     //insert records into the reputations table
    -
    - insertIntoReputationsTable( dcp, reputation );
    -
    - Enumeration payloads = reputation.getPayloads();
    -
    - while ( payloads.hasMoreElements() ) {
    -
    - Payload current = (Payload)payloads.nextElement();
    -
    - if ( supports( current ) ) {
     
    - //insert records into the identifiers table
    - insertIntoIdentifiersTable( dcp, current );
    -
    - //insert records into the properties table
    - insertIntoPropertiesTable( dcp, current );
    -
    - }
    -
    - }
    -
    + new InsertReputation( dcp, reputation, this ).commit();
                     
                 } catch ( Throwable t ) {
                     throw new SierraException( t );
    @@ -123,161 +119,12 @@
             
         }
     
    -
    - /**
    - *
    - *
    - * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: SimpleQueryEngine.java,v 1.8 2001/03/14 09:59:37 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() );
    -
    - select_identifier.commit();
    -
    - select_identifier.getResultSet().next();
    - int 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();
    -
    - select_reputation.getResultSet().next();
    - int reputation = select_reputation.getResultSet().getInt( "pk" );
    -
    -
    - //go over all properties and add them.
    - PropertyManagerPayload pmp = (PropertyManagerPayload)payload;
    -
    - //add all properties
    -
    - Enumeration keys = pmp.getKeys();
    -
    - while ( keys.hasMoreElements() ) {
    -
    - //only update if there are no properties already entered from this reputation.
    -
    - Select verify = new Select();
    - verify.setDatabaseConnectionPool( dcp )
    - .setTable( "properties" )
    - .addInteger( "reputation", reputation )
    - .addInteger( "identifier", identifier );
    -
    - verify.commit();
    -
    -
    - if ( verify.getResultSet().next() == false) {
    -
    - //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 );
    -
    - Insert insert = new Insert();
    - insert.setDatabaseConnectionPool( dcp )
    - .setTable( "properties" )
    - .addInteger( "reputation", reputation )
    - .addInteger( "identifier", identifier )
    - .addString( "name", name )
    - .addString( "value", value )
    - .addString( "type", "string" );
    -
    - insert.commit();
    -
    - } else {
    -
    - break;
    -
    - }
    -
    -
    - }
    -
    - }
    -
    - /**
    - *
    - *
    - * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: SimpleQueryEngine.java,v 1.8 2001/03/14 09:59:37 burton Exp $
    - */
    - private void insertIntoIdentifiersTable( DatabaseConnectionPool dcp, Payload payload )
    - throws Exception {
    -
    - Select select = new Select();
    - select.setDatabaseConnectionPool( dcp )
    - .setTable( "identifiers" )
    - .addString( "uri", payload.getIdentifier().toString() );
    -
    - select.commit();
    -
    - //only insert if there are no records in the DB.
    - //HACK: there is no easy way to find out if no results were found. :(
    - if ( select.getResultSet().next() == false ) {
    -
    - this.getLogger().message( "Adding database record for identifier: " + payload.getIdentifier().toString() );
    -
    - Insert insert = new Insert();
    - insert.setDatabaseConnectionPool( dcp )
    - .setTable( "identifiers" )
    - .addString( "uri", payload.getIdentifier().toString() );
    -
    - insert.commit();
    -
    - }
    -
    - }
    -
    -
    - /**
    - *
    - *
    - * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: SimpleQueryEngine.java,v 1.8 2001/03/14 09:59:37 burton Exp $
    - */
    - private void insertIntoReputationsTable( DatabaseConnectionPool dcp, Reputation reputation )
    - throws Exception {
    -
    - Select select = new Select();
    - select.setDatabaseConnectionPool( dcp )
    - .setTable( "reputations" )
    - .addString( "uri", reputation.getURI().toString() );
    -
    - select.commit();
    -
    - //only insert if there are no records in the DB.
    - //HACK: there is no easy way to find out if no results were found. :(
    - if ( select.getResultSet().next() == false ) {
    -
    - this.getLogger().message( "Adding database record for reputation: " + reputation.getURI().toString() );
    -
    - Insert insert = new Insert();
    - insert.setDatabaseConnectionPool( dcp )
    - .setTable( "reputations" )
    - .addString( "reference", reputation.getReference().toString() )
    - .addString( "uri", reputation.getURI().toString() );
    -
    - insert.commit();
    -
    - }
    -
    - }
         
     
         /**
          * @see QueryEngine
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: SimpleQueryEngine.java,v 1.8 2001/03/14 09:59:37 burton Exp $
    + * @version $Id: SimpleQueryEngine.java,v 1.9 2001/03/15 00:02:24 burton Exp $
          */
         public boolean supports( Reputation reputation ) {
     
    @@ -301,7 +148,7 @@
         /**
          * @see QueryEngine
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: SimpleQueryEngine.java,v 1.8 2001/03/14 09:59:37 burton Exp $
    + * @version $Id: SimpleQueryEngine.java,v 1.9 2001/03/15 00:02:24 burton Exp $
          */
         public boolean supports( Payload payload ) {
     
    @@ -313,7 +160,7 @@
         /**
          * @see QueryEngine
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: SimpleQueryEngine.java,v 1.8 2001/03/14 09:59:37 burton Exp $
    + * @version $Id: SimpleQueryEngine.java,v 1.9 2001/03/15 00:02:24 burton Exp $
          */
         public boolean supports( Query query ) {
     

    *****************************************************************
    File: sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/SimpleQueryManager.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/SimpleQueryManager.java?annotate=1.7

    CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/SimpleQueryManager.java?rev=1.7&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/SimpleQueryManager.java.diff?r1=1.7&r2=1.6

    -----------------------------------

    Index: sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/SimpleQueryManager.java
    diff -u sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/SimpleQueryManager.java:1.6 sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/SimpleQueryManager.java:1.7
    --- sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/SimpleQueryManager.java:1.6 Wed Mar 14 01:59:37 2001
    +++ sierra/src/java/org/openprivacy/sierra/query/talon/implementations/simple/SimpleQueryManager.java Wed Mar 14 16:02:24 2001
    @@ -34,7 +34,7 @@
     /**
      * @see QueryManager
      * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: SimpleQueryManager.java,v 1.6 2001/03/14 09:59:37 burton Exp $
    + * @version $Id: SimpleQueryManager.java,v 1.7 2001/03/15 00:02:24 burton Exp $
      */
     public class SimpleQueryManager extends BaseComponent implements Component, QueryManager {
     
    @@ -52,7 +52,7 @@
         /**
          * @see QueryManager
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: SimpleQueryManager.java,v 1.6 2001/03/14 09:59:37 burton Exp $
    + * @version $Id: SimpleQueryManager.java,v 1.7 2001/03/15 00:02:24 burton Exp $
          */
         public QueryEngine getQueryEngine( Query query ) throws QueryNotSupportedException {
     
    @@ -73,7 +73,7 @@
         /**
          * @see QueryManager
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: SimpleQueryManager.java,v 1.6 2001/03/14 09:59:37 burton Exp $
    + * @version $Id: SimpleQueryManager.java,v 1.7 2001/03/15 00:02:24 burton Exp $
          */
         public void putReputation( Reputation reputation ) throws SierraException {
     
    @@ -89,8 +89,18 @@
     
             }
             
    -
         }
    -
    +
    + /**
    + * @see QueryManager
    + * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    + * @version $Id: SimpleQueryManager.java,v 1.7 2001/03/15 00:02:24 burton Exp $
    + */
    + public Result execute( Query query ) throws SierraException {
    +
    + return getQueryEngine( query ).execute( query );
    +
    + }
    +
     }
     



    This archive was generated by hypermail 2b30 : Wed Mar 14 2001 - 16:02:56 PST