juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svi...@apache.org
Subject cvs commit: ws-juddi/src/java/org/apache/juddi/datastore/jdbc FindTModelByCategoryQuery.java FindServiceByCategoryQuery.java FindBusinessByCategoryQuery.java FindBindingByCategoryQuery.java JDBCDataStore.java
Date Wed, 16 Mar 2005 03:49:40 GMT
sviens      2005/03/15 19:49:40

  Modified:    src/java/org/apache/juddi/datastore/jdbc
                        FindTModelByCategoryQuery.java
                        FindServiceByCategoryQuery.java
                        FindBusinessByCategoryQuery.java
                        FindBindingByCategoryQuery.java JDBCDataStore.java
  Log:
  Fix for bug# JUDDI-33 - findTModel returns unexpected results when trying to filter results
with categoryBag (see http://issues.apache.org/jira/browse/JUDDI-33)
  Fix for bug# JUDDI-14 - possible issue with find_service using CategoryBag (see: http://issues.apache.org/jira/browse/JUDDI-14)
  
  Revision  Changes    Path
  1.9       +105 -1    ws-juddi/src/java/org/apache/juddi/datastore/jdbc/FindTModelByCategoryQuery.java
  
  Index: FindTModelByCategoryQuery.java
  ===================================================================
  RCS file: /home/cvs/ws-juddi/src/java/org/apache/juddi/datastore/jdbc/FindTModelByCategoryQuery.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FindTModelByCategoryQuery.java	29 Jun 2004 13:49:22 -0000	1.8
  +++ FindTModelByCategoryQuery.java	16 Mar 2005 03:49:40 -0000	1.9
  @@ -173,6 +173,110 @@
     }
   
     /**
  +   * Select ...
  +   *
  +   * @param connection JDBC connection
  +   * @throws java.sql.SQLException
  +   */
  +  public static Vector select(KeyedReference keyedRef,Vector keysIn,FindQualifiers qualifiers,Connection
connection)
  +    throws java.sql.SQLException
  +  {
  +    // If there is a keysIn vector but it doesn't contain
  +    // any keys then the previous query has exhausted
  +    // all possibilities of a match so skip this call.
  +    //
  +    if ((keysIn != null) && (keysIn.size() == 0))
  +      return keysIn;
  +
  +    Vector keysOut = new Vector();
  +    PreparedStatement statement = null;
  +    ResultSet resultSet = null;
  +
  +    // construct the SQL statement
  +    DynamicQuery sql = new DynamicQuery(selectSQL);
  +    appendWhere(sql,keyedRef,qualifiers);
  +    appendIn(sql,keysIn);
  +    appendOrderBy(sql,qualifiers);
  +
  +    try
  +    {
  +      log.debug(sql.toString());
  +
  +      statement = sql.buildPreparedStatement(connection);
  +      resultSet = statement.executeQuery();
  +
  +      while (resultSet.next())
  +        keysOut.addElement(resultSet.getString(1));//("TMODEL_KEY"));
  +
  +      return keysOut;
  +    }
  +    finally
  +    {
  +      try {
  +        resultSet.close();
  +      }
  +      catch (Exception e)
  +      {
  +        log.warn("An Exception was encountered while attempting to close " +
  +          "the Find TModel ResultSet: "+e.getMessage(),e);
  +      }
  +
  +      try {
  +        statement.close();
  +      }
  +      catch (Exception e)
  +      {
  +        log.warn("An Exception was encountered while attempting to close " +
  +          "the Find TModel Statement: "+e.getMessage(),e);
  +      }
  +    }
  +  }
  +
  +  /**
  +   *
  +   */
  +  private static void appendWhere(DynamicQuery sql,KeyedReference keyedRef,FindQualifiers
qualifiers)
  +  {
  +    sql.append("WHERE M.TMODEL_KEY = C.TMODEL_KEY ");
  +
  +    if (keyedRef != null)
  +    {
  +      sql.append("AND (");
  +
  +      String key = keyedRef.getTModelKey();
  +      String name = keyedRef.getKeyName();
  +      String value = keyedRef.getKeyValue();
  +        
  +      if (name == null)
  +        name = "";
  +        
  +      if (value == null)
  +        value = "";
  +        
  +      // If the tModelKey involved is that of uddi-org:general_keywords, 
  +      // the keyNames are identical (DO NOT IGNORE keyName). Otherwise 
  +      // keyNames are not significant. Omitted keyNames are treated as 
  +      // identical to empty (zero length) keyNames.
  +      //
  +      if (key.equals(TModel.GENERAL_KEYWORDS_TMODEL_KEY)) 
  +      {
  +        sql.append("(C.TMODEL_KEY_REF = ? AND C.KEY_NAME = ? AND C.KEY_VALUE = ?)");
  +        sql.addValue(key);
  +        sql.addValue(name);
  +        sql.addValue(value);
  +      }
  +      else 
  +      {
  +        sql.append("(C.TMODEL_KEY_REF = ? AND C.KEY_VALUE = ?)");
  +        sql.addValue(key);
  +        sql.addValue(value);
  +      }
  +
  +      sql.append(") ");
  +    }
  +  }
  +
  +  /**
      * Utility method used to construct SQL "IN" statements such as
      * the following SQL example:
      *
  @@ -272,7 +376,7 @@
           txn.begin(connection);
   
           select(categoryBag,keysIn,null,connection);
  -        select(categoryBag,null,null,connection);
  +        select((KeyedReference)keyedRefVector.elementAt(0),null,null,connection);
   
           // commit the transaction
           txn.commit();
  
  
  
  1.8       +120 -3    ws-juddi/src/java/org/apache/juddi/datastore/jdbc/FindServiceByCategoryQuery.java
  
  Index: FindServiceByCategoryQuery.java
  ===================================================================
  RCS file: /home/cvs/ws-juddi/src/java/org/apache/juddi/datastore/jdbc/FindServiceByCategoryQuery.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FindServiceByCategoryQuery.java	29 Jun 2004 13:49:22 -0000	1.7
  +++ FindServiceByCategoryQuery.java	16 Mar 2005 03:49:40 -0000	1.8
  @@ -112,7 +112,6 @@
         }
       }
     }
  -
     /**
      *
      */
  @@ -182,6 +181,119 @@
     }
   
     /**
  +   * Select ...
  +   *
  +   * @param businessKey
  +   * @param keyedRef
  +   * @param keysIn
  +   * @param qualifiers
  +   * @param connection JDBC connection
  +   * @throws java.sql.SQLException
  +   */
  +  public static Vector select(String businessKey,KeyedReference keyedRef,Vector keysIn,FindQualifiers
qualifiers,Connection connection)
  +    throws java.sql.SQLException
  +  {
  +    // If there is a keysIn vector but it doesn't contain
  +    // any keys then the previous query has exhausted
  +    // all possibilities of a match so skip this call.
  +    //
  +    if ((keysIn != null) && (keysIn.size() == 0))
  +      return keysIn;
  +
  +    Vector keysOut = new Vector();
  +    PreparedStatement statement = null;
  +    ResultSet resultSet = null;
  +
  +    // construct the SQL statement
  +    DynamicQuery sql = new DynamicQuery(selectSQL);
  +    appendWhere(sql,businessKey,keyedRef,qualifiers);
  +    appendIn(sql,keysIn);
  +    appendOrderBy(sql,qualifiers);
  +
  +    try
  +    {
  +      log.debug(sql.toString());
  +
  +      statement = sql.buildPreparedStatement(connection);
  +      resultSet = statement.executeQuery();
  +
  +      while (resultSet.next())
  +        keysOut.addElement(resultSet.getString(1));//("SERVICE_KEY"));
  +
  +      return keysOut;
  +    }
  +    finally
  +    {
  +      try {
  +        resultSet.close();
  +      }
  +      catch (Exception e)
  +      {
  +        log.warn("An Exception was encountered while attempting to close " +
  +          "the Find BusinessService ResultSet: "+e.getMessage(),e);
  +      }
  +
  +      try {
  +        statement.close();
  +      }
  +      catch (Exception e)
  +      {
  +        log.warn("An Exception was encountered while attempting to close " +
  +          "the Find BusinessService Statement: "+e.getMessage(),e);
  +      }
  +    }
  +  }
  +
  +  /**
  +   *
  +   */
  +  private static void appendWhere(DynamicQuery sql,String businessKey,KeyedReference keyedRef,FindQualifiers
qualifiers)
  +  {
  +    sql.append("WHERE C.SERVICE_KEY = S.SERVICE_KEY ");
  +    if (businessKey != null)
  +    {
  +      sql.append("AND S.BUSINESS_KEY = ? ");
  +      sql.addValue(businessKey);
  +    }
  +  
  +    if (keyedRef != null)
  +    {
  +      sql.append("AND (");
  +
  +      String key = keyedRef.getTModelKey();
  +      String name = keyedRef.getKeyName();
  +      String value = keyedRef.getKeyValue();
  +          
  +      if (name == null)
  +        name = "";
  +          
  +      if (value == null)
  +        value = "";
  +          
  +      // If the tModelKey involved is that of uddi-org:general_keywords, 
  +      // the keyNames are identical (DO NOT IGNORE keyName). Otherwise 
  +      // keyNames are not significant. Omitted keyNames are treated as 
  +      // identical to empty (zero length) keyNames.
  +      //
  +      if (key.equals(TModel.GENERAL_KEYWORDS_TMODEL_KEY)) 
  +      {
  +        sql.append("(C.TMODEL_KEY_REF = ? AND C.KEY_NAME = ? AND C.KEY_VALUE = ?)");
  +        sql.addValue(key);
  +        sql.addValue(name);
  +        sql.addValue(value); 
  +      }
  +      else 
  +      {
  +        sql.append("(C.TMODEL_KEY_REF = ? AND C.KEY_VALUE = ?)");
  +        sql.addValue(key);
  +        sql.addValue(value); 
  +      }
  +
  +      sql.append(") ");
  +    }
  +  }
  +
  +  /**
      * Utility method used to construct SQL "IN" statements such as
      * the following SQL example:
      *
  @@ -282,8 +394,13 @@
           // begin a new transaction
           txn.begin(connection);
   
  -        select(businessKey,categoryBag,keysIn,null,connection);
  -        select(businessKey,categoryBag,null,null,connection);
  +        keysIn = select(businessKey,categoryBag,keysIn,null,connection);
  +                
  +        for (int i=0; i< keyedRefVector.size(); i++)
  +        {
  +          KeyedReference keyedRef = (KeyedReference)keyedRefVector.elementAt(i);
  +          keysIn = select(businessKey,keyedRef,null,null,connection);
  +        }      
   
           // commit the transaction
           txn.commit();
  
  
  
  1.7       +105 -1    ws-juddi/src/java/org/apache/juddi/datastore/jdbc/FindBusinessByCategoryQuery.java
  
  Index: FindBusinessByCategoryQuery.java
  ===================================================================
  RCS file: /home/cvs/ws-juddi/src/java/org/apache/juddi/datastore/jdbc/FindBusinessByCategoryQuery.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FindBusinessByCategoryQuery.java	29 Jun 2004 13:49:22 -0000	1.6
  +++ FindBusinessByCategoryQuery.java	16 Mar 2005 03:49:40 -0000	1.7
  @@ -172,6 +172,110 @@
     }
   
     /**
  +   * Select ...
  +   *
  +   * @param connection JDBC connection
  +   * @throws java.sql.SQLException
  +   */
  +  public static Vector select(KeyedReference keyedRef,Vector keysIn,FindQualifiers qualifiers,Connection
connection)
  +    throws java.sql.SQLException
  +  {
  +    // If there is a keysIn vector but it doesn't contain
  +    // any keys then the previous query has exhausted
  +    // all possibilities of a match so skip this call.
  +    //
  +    if ((keysIn != null) && (keysIn.size() == 0))
  +      return keysIn;
  +
  +    Vector keysOut = new Vector();
  +    PreparedStatement statement = null;
  +    ResultSet resultSet = null;
  +
  +    // construct the SQL statement
  +    DynamicQuery sql = new DynamicQuery(selectSQL);
  +    appendWhere(sql,keyedRef,qualifiers);
  +    appendIn(sql,keysIn);
  +    appendOrderBy(sql,qualifiers);
  +
  +    try
  +    {
  +      log.debug(sql.toString());
  +
  +      statement = sql.buildPreparedStatement(connection);
  +      resultSet = statement.executeQuery();
  +
  +      while (resultSet.next())
  +        keysOut.addElement(resultSet.getString(1));//("BUSINESS_KEY"));
  +
  +      return keysOut;
  +    }
  +    finally
  +    {
  +      try {
  +        resultSet.close();
  +      }
  +      catch (Exception e)
  +      {
  +        log.warn("An Exception was encountered while attempting to close " +
  +          "the Find BusinessEntity ResultSet: "+e.getMessage(),e);
  +      }
  +
  +      try {
  +        statement.close();
  +      }
  +      catch (Exception e)
  +      {
  +        log.warn("An Exception was encountered while attempting to close " +
  +          "the Find BusinessEntity Statement: "+e.getMessage(),e);
  +      }
  +    }
  +  }
  +
  +  /**
  +   *
  +   */
  +  private static void appendWhere(DynamicQuery sql,KeyedReference keyedRef,FindQualifiers
qualifiers)
  +  {
  +    sql.append("WHERE B.BUSINESS_KEY = C.BUSINESS_KEY ");
  +
  +    if (keyedRef != null)
  +    {
  +      sql.append("AND (");
  +  
  +      String key = keyedRef.getTModelKey();
  +      String name = keyedRef.getKeyName();
  +      String value = keyedRef.getKeyValue();
  +            
  +      if (name == null)
  +        name = "";
  +            
  +      if (value == null)
  +        value = "";
  +            
  +      // If the tModelKey involved is that of uddi-org:general_keywords, 
  +      // the keyNames are identical (DO NOT IGNORE keyName). Otherwise 
  +      // keyNames are not significant. Omitted keyNames are treated as 
  +      // identical to empty (zero length) keyNames.
  +      //
  +      if (key.equals(TModel.GENERAL_KEYWORDS_TMODEL_KEY)) 
  +      {
  +        sql.append("(C.TMODEL_KEY_REF = ? AND C.KEY_NAME = ? AND C.KEY_VALUE = ?)");
  +        sql.addValue(key);
  +        sql.addValue(name);
  +        sql.addValue(value);
  +      }
  +      else 
  +      {
  +        sql.append("(C.TMODEL_KEY_REF = ? AND C.KEY_VALUE = ?)");
  +        sql.addValue(key);
  +        sql.addValue(value);
  +      }
  +  
  +      sql.append(") ");
  +    }
  +  }
  +
  +  /**
      * Utility method used to construct SQL "IN" statements such as
      * the following SQL example:
      *
  @@ -271,7 +375,7 @@
           txn.begin(connection);
   
           select(categoryBag,keysIn,null,connection);
  -        select(categoryBag,null,null,connection);
  +        select((KeyedReference)keyedRefVector.elementAt(0),null,null,connection);
   
           // commit the transaction
           txn.commit();
  
  
  
  1.6       +115 -1    ws-juddi/src/java/org/apache/juddi/datastore/jdbc/FindBindingByCategoryQuery.java
  
  Index: FindBindingByCategoryQuery.java
  ===================================================================
  RCS file: /home/cvs/ws-juddi/src/java/org/apache/juddi/datastore/jdbc/FindBindingByCategoryQuery.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FindBindingByCategoryQuery.java	29 Jun 2004 13:49:22 -0000	1.5
  +++ FindBindingByCategoryQuery.java	16 Mar 2005 03:49:40 -0000	1.6
  @@ -183,6 +183,120 @@
     }
   
     /**
  +   * Select ...
  +   *
  +   * @param serviceKey
  +   * @param keyedRef
  +   * @param keysIn
  +   * @param qualifiers
  +   * @param connection JDBC connection
  +   * @throws java.sql.SQLException
  +   */
  +  public static Vector select(String serviceKey,KeyedReference keyedRef,Vector keysIn,FindQualifiers
qualifiers,Connection connection)
  +    throws java.sql.SQLException
  +  {
  +    // If there is a keysIn vector but it doesn't contain
  +    // any keys then the previous query has exhausted
  +    // all possibilities of a match so skip this call.
  +    //
  +    if ((keysIn != null) && (keysIn.size() == 0))
  +      return keysIn;
  +
  +    Vector keysOut = new Vector();
  +    PreparedStatement statement = null;
  +    ResultSet resultSet = null;
  +    DynamicQuery dynStmt = new DynamicQuery();
  +    
  +    DynamicQuery sql = new DynamicQuery(selectSQL);
  +    appendWhere(sql,serviceKey,keyedRef,qualifiers);
  +    appendIn(sql,keysIn);
  +    appendOrderBy(sql,qualifiers);
  +    
  +    try
  +    {
  +      log.debug(sql.toString());
  +      
  +      statement = sql.buildPreparedStatement(connection);
  +      resultSet = statement.executeQuery();      
  +      while (resultSet.next())
  +      {
  +        keysOut.addElement(resultSet.getString(1));//("SERVICE_KEY"));
  +      }
  +
  +      return keysOut;
  +    }
  +    finally
  +    {
  +      try {
  +        resultSet.close();
  +      }
  +      catch (Exception e)
  +      {
  +        log.warn("An Exception was encountered while attempting to close " +
  +          "the Find BindingTemplate ResultSet: "+e.getMessage(),e);
  +      }
  +
  +      try {
  +        statement.close();
  +      }
  +      catch (Exception e)
  +      {
  +        log.warn("An Exception was encountered while attempting to close " +
  +          "the Find BindingTemplate Statement: "+e.getMessage(),e);
  +      }
  +    }
  +  }
  +
  +  /**
  +   *
  +   */
  +  private static void appendWhere(DynamicQuery sql,String serviceKey,KeyedReference keyedRef,FindQualifiers
qualifiers)
  +  {
  +    sql.append("WHERE C.BINDING_KEY = B.BINDING_KEY ");
  +    if (serviceKey != null)
  +    {
  +      sql.append("AND B.SERVICE_KEY = ? ");
  +      sql.addValue(serviceKey);
  +    }
  +    
  +    if (keyedRef != null)
  +    {
  +      sql.append("AND (");
  + 
  +      String key = keyedRef.getTModelKey();
  +      String name = keyedRef.getKeyName();
  +      String value = keyedRef.getKeyValue();
  +       
  +      if (name == null)
  +        name = "";
  +        
  +      if (value == null)
  +        value = "";
  +        
  +      // If the tModelKey involved is that of uddi-org:general_keywords, 
  +      // the keyNames are identical (DO NOT IGNORE keyName). Otherwise 
  +      // keyNames are not significant. Omitted keyNames are treated as 
  +      // identical to empty (zero length) keyNames.
  +      //
  +      if (key.equals(TModel.GENERAL_KEYWORDS_TMODEL_KEY)) 
  +      {
  +        sql.append("(C.TMODEL_KEY_REF = ? AND C.KEY_NAME = ? AND C.KEY_VALUE = ?)");
  +        sql.addValue(key);
  +        sql.addValue(name);
  +        sql.addValue(value);
  +      }
  +      else 
  +      {
  +        sql.append("(C.TMODEL_KEY_REF = ? AND C.KEY_VALUE = ?)");
  +        sql.addValue(key);
  +        sql.addValue(value);
  +      }
  +  
  +      sql.append(") ");
  +    }
  +  }
  +
  +  /**
      * Utility method used to construct SQL "IN" statements such as
      * the following SQL example:
      *
  @@ -289,7 +403,7 @@
           keys = select(serviceKey,categoryBag,keysIn,null,connection);
           System.out.println(keys.size());
           
  -        keys = select(serviceKey,categoryBag,null,null,connection);
  +        keys = select(serviceKey,(KeyedReference)keyedRefVector.elementAt(0),null,null,connection);
           System.out.println(keys.size());
   
           // commit the transaction
  
  
  
  1.12      +143 -21   ws-juddi/src/java/org/apache/juddi/datastore/jdbc/JDBCDataStore.java
  
  Index: JDBCDataStore.java
  ===================================================================
  RCS file: /home/cvs/ws-juddi/src/java/org/apache/juddi/datastore/jdbc/JDBCDataStore.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JDBCDataStore.java	10 Mar 2005 05:05:00 -0000	1.11
  +++ JDBCDataStore.java	16 Mar 2005 03:49:40 -0000	1.12
  @@ -1436,9 +1436,37 @@
         if ((discoveryURLs != null) && (discoveryURLs.size() > 0))
           keyVector = FindBusinessByDiscoveryURLQuery.select(discoveryURLs,keyVector,findQualifiers,connection);
   
  -      if ((categoryBag != null) && (categoryBag.size() > 0))
  -        keyVector = FindBusinessByCategoryQuery.select(categoryBag,keyVector,findQualifiers,connection);
  +//    TODO (CategoryBag Error)        
  +//      if ((categoryBag != null) && (categoryBag.size() > 0))
  +//        keyVector = FindBusinessByCategoryQuery.select(categoryBag,keyVector,findQualifiers,connection);
   
  +      if ((findQualifiers != null) && (findQualifiers.orAllKeys))  
  +      {
  +        // orAllKeys = Use logical "OR" when searching by category 
  +        // bag. See UDDI v2.04 API Specification - Appendix E.
  +        //
  +        if ((categoryBag != null) && (categoryBag.size() > 0))
  +          keyVector = FindBusinessByCategoryQuery.select(categoryBag,keyVector,findQualifiers,connection);
  +      }
  +      else 
  +      {
  +        // Default UDDI v2 behavior: Use logical "AND" when searching 
  +        // by category bag. See UDDI v2.04 API Specification - Appendix E.
  +        //
  +        if ((categoryBag != null) && (categoryBag.size() > 0))
  +        {
  +          Vector keyedRefVector = categoryBag.getKeyedReferenceVector();
  +          if (keyedRefVector != null)
  +          {
  +            for (int i=0; i<keyedRefVector.size(); i++)
  +            {
  +              KeyedReference keyedRef = (KeyedReference)keyedRefVector.elementAt(i);
  +              keyVector = FindBusinessByCategoryQuery.select(keyedRef,keyVector,findQualifiers,connection);
  +            }
  +          }
  +        }
  +      }
  +      
         if ((identifierBag != null) && (identifierBag.size() > 0))
           keyVector = FindBusinessByIdentifierQuery.select(identifierBag,keyVector,findQualifiers,connection);
   
  @@ -1467,12 +1495,43 @@
   
       try
       {
  +      if (businessKey != null)
  +        keyVector = FindServiceByBusinessKeyQuery.select(businessKey,keyVector,findQualifiers,connection);
  +            
         if ((tModelBag != null) && (tModelBag.size() > 0))
           keyVector = FindServiceByTModelKeyQuery.select(businessKey,tModelBag,keyVector,findQualifiers,connection);
   
  -      if ((categoryBag != null) && (categoryBag.size() > 0))
  -        keyVector = FindServiceByCategoryQuery.select(businessKey,categoryBag,keyVector,findQualifiers,connection);
  +//    TODO (CategoryBag Error)        
  +//      if ((categoryBag != null) && (categoryBag.size() > 0))
  +//        keyVector = FindServiceByCategoryQuery.select(businessKey,categoryBag,keyVector,findQualifiers,connection);
   
  +      if ((findQualifiers != null) && (findQualifiers.orAllKeys))  
  +      {
  +        // orAllKeys = Use logical "OR" when searching by category 
  +        // bag. See UDDI v2.04 API Specification - Appendix E.
  +        //
  +        if ((categoryBag != null) && (categoryBag.size() > 0))
  +          keyVector = FindServiceByCategoryQuery.select(businessKey,categoryBag,keyVector,findQualifiers,connection);
  +      }
  +      else 
  +      {
  +        // Default UDDI v2 behavior: Use logical "AND" when searching 
  +        // by category bag. See UDDI v2.04 API Specification - Appendix E.
  +        //
  +        if ((categoryBag != null) && (categoryBag.size() > 0))
  +        {
  +          Vector keyedRefVector = categoryBag.getKeyedReferenceVector();
  +          if (keyedRefVector != null)
  +          {
  +            for (int i=0; i<keyedRefVector.size(); i++)
  +            {
  +              KeyedReference keyedRef = (KeyedReference)keyedRefVector.elementAt(i);
  +              keyVector = FindServiceByCategoryQuery.select(businessKey,keyedRef,keyVector,findQualifiers,connection);
  +            }
  +          }
  +        }
  +      }
  +      
         // always perform this query - even when not searching by Name!!!
         keyVector = FindServiceByNameQuery.select(businessKey,nameVector,keyVector,findQualifiers,connection);
       }
  @@ -1497,8 +1556,36 @@
   
       try
       {
  -      if ((categoryBag != null) && (categoryBag.size() > 0))
  -        keyVector = FindTModelByCategoryQuery.select(categoryBag,keyVector,findQualifiers,connection);
  +// TODO (CategoryBag Error)        
  +//      if ((categoryBag != null) && (categoryBag.size() > 0))
  +//        keyVector = FindTModelByCategoryQuery.select(categoryBag,keyVector,findQualifiers,connection);
  +
  +      if ((findQualifiers != null) && (findQualifiers.orAllKeys))  
  +      {
  +        // orAllKeys = Use logical "OR" when searching by category 
  +        // bag. See UDDI v2.04 API Specification - Appendix E.
  +        //
  +        if ((categoryBag != null) && (categoryBag.size() > 0))
  +          keyVector = FindTModelByCategoryQuery.select(categoryBag,keyVector,findQualifiers,connection);
  +      }
  +      else 
  +      {
  +        // Default UDDI v2 behavior: Use logical "AND" when searching 
  +        // by category bag. See UDDI v2.04 API Specification - Appendix E.
  +        //
  +        if ((categoryBag != null) && (categoryBag.size() > 0))
  +        {
  +          Vector keyedRefVector = categoryBag.getKeyedReferenceVector();
  +          if (keyedRefVector != null)
  +          {
  +            for (int i=0; i<keyedRefVector.size(); i++)
  +            {
  +              KeyedReference keyedRef = (KeyedReference)keyedRefVector.elementAt(i);
  +              keyVector = FindTModelByCategoryQuery.select(keyedRef,keyVector,findQualifiers,connection);
  +            }
  +          }
  +        }
  +      }
   
         if ((identifierBag != null) && (identifierBag.size() > 0))
           keyVector = FindTModelByIdentifierQuery.select(identifierBag,keyVector,findQualifiers,connection);
  @@ -1527,26 +1614,61 @@
   
       try
       {
  +      if (serviceKey != null)
  +        keyVector = FindBindingByServiceKeyQuery.select(serviceKey,keyVector,findQualifiers,connection);
  +        
         if ((tModelBag != null) && (tModelBag.size() > 0))
           keyVector = FindBindingByTModelKeyQuery.select(serviceKey,tModelBag,keyVector,findQualifiers,connection);
   
  -      if ((categoryBag != null) && (categoryBag.size() > 0))
  -        keyVector = FindBindingByCategoryQuery.select(serviceKey,categoryBag,keyVector,findQualifiers,connection);
  +//    TODO (CategoryBag Error)        
  +//      if ((categoryBag != null) && (categoryBag.size() > 0))
  +//        keyVector = FindBindingByCategoryQuery.select(serviceKey,categoryBag,keyVector,findQualifiers,connection);
   
  -       /**
  -        *  Anil: Only if the serviceKey is passed
  -        */
  -
  -      if((serviceKey != null) && (tModelBag == null) && (categoryBag ==
null))
  -      {
  -         Vector bindtempVect= BindingTemplateTable.selectByServiceKey(serviceKey,connection);
  -         for(int i=0; bindtempVect != null && i < bindtempVect.size();i++)
  -         {
  -            BindingTemplate bt = (BindingTemplate)bindtempVect.elementAt(i);
  -            if(keyVector == null )  keyVector = new Vector(bindtempVect.size());
  -            keyVector.add(bt.getBindingKey());
  -         }
  +      if ((findQualifiers != null) && (findQualifiers.orAllKeys))  
  +      {
  +        // orAllKeys = Use logical "OR" when searching by category 
  +        // bag. See UDDI v2.04 API Specification - Appendix E.
  +        //
  +        if ((categoryBag != null) && (categoryBag.size() > 0))
  +          keyVector = FindBindingByCategoryQuery.select(serviceKey,categoryBag,keyVector,findQualifiers,connection);
  +      }
  +      else 
  +      {
  +        // Default UDDI v2 behavior: Use logical "AND" when searching 
  +        // by category bag. See UDDI v2.04 API Specification - Appendix E.
  +        //
  +        if ((categoryBag != null) && (categoryBag.size() > 0))
  +        {
  +          Vector keyedRefVector = categoryBag.getKeyedReferenceVector();
  +          if (keyedRefVector != null)
  +          {
  +            for (int i=0; i<keyedRefVector.size(); i++)
  +            {
  +              KeyedReference keyedRef = (KeyedReference)keyedRefVector.elementAt(i);
  +              keyVector = FindBindingByCategoryQuery.select(serviceKey,keyedRef,keyVector,findQualifiers,connection);
  +            }
  +          }
  +        }
         }
  +  
  +// Steve: This fix has been replaced with the call to 
  +//        FindBindingByServiceKeyQuery found at the start of 
  +//        this method.
  +//
  +//      /**
  +//        *  Anil: Only if the serviceKey is passed
  +//        */
  +//
  +//      if((serviceKey != null) && (tModelBag == null) && (categoryBag
== null))
  +//      {
  +//         Vector bindtempVect= BindingTemplateTable.selectByServiceKey(serviceKey,connection);
  +//         for(int i=0; bindtempVect != null && i < bindtempVect.size();i++)
  +//         {
  +//            BindingTemplate bt = (BindingTemplate)bindtempVect.elementAt(i);
  +//            if(keyVector == null )  keyVector = new Vector(bindtempVect.size());
  +//            keyVector.add(bt.getBindingKey());
  +//         }
  +//      }
       }
       catch(java.sql.SQLException sqlex)
       {
  
  
  

Mime
View raw message