Changeset 4008


Ignore:
Timestamp:
Nov 27, 2007, 2:02:55 PM (15 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #846: Add query parameters to QueryOptions?

Location:
trunk/src
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/info/net/sf/basedb/info/QueryOptions.java

    r3974 r4008  
    7070 
    7171  private boolean includeNotRemoved = true;
     72 
     73  private QueryParameter[] parameters;
    7274 
    7375  /**
     
    270272    this.prefix = prefix;
    271273  }
     274 
     275  /**
     276    Get the parameters used in this query.
     277    @return An array of query parameters, may be null or empty if no
     278      parameters are used
     279  */
     280  public QueryParameter[] getParameters()
     281  {
     282    return parameters;
     283  }
     284 
     285  /**
     286    Set the parmeters to use in this query.
     287    @param parameters An array of query parameters, may be null or empty
     288      if not parameters are used
     289  */
     290  public void setParameters(QueryParameter[] parameters)
     291  {
     292    this.parameters = parameters;
     293  }
     294 
    272295}
  • trunk/src/test/TestWebservices.java

    r3991 r4008  
    4343import net.sf.basedb.info.ProjectInfo;
    4444import net.sf.basedb.info.QueryOptions;
     45import net.sf.basedb.info.QueryParameter;
    4546import net.sf.basedb.info.RawBioAssayInfo;
    4647import net.sf.basedb.info.ReporterListInfo;
     
    525526      //Tests ProjectClient.getProjects(QueryOptions qOpt)
    526527      QueryOptions qOpt = new QueryOptions();
     528      qOpt.setRestrictionWithPrefix("$valueType = :vt", "$");
     529      qOpt.setParameters(new QueryParameter[]{ new QueryParameter("vt", Type.STRING.getValue()) });
    527530      AnnotationTypeInfo[] infos = atClient.getAnnotationTypes(null, qOpt);
    528531     
  • trunk/src/webservices/server/net/sf/basedb/ws/server/ServicesUtil.java

    r3975 r4008  
    3232import net.sf.basedb.core.Include;
    3333import net.sf.basedb.core.ItemQuery;
     34import net.sf.basedb.core.Type;
    3435import net.sf.basedb.core.query.Hql;
    3536import net.sf.basedb.info.AnnotationInfo;
    3637import net.sf.basedb.info.QueryOptions;
     38import net.sf.basedb.info.QueryParameter;
    3739import net.sf.basedb.info.ToTransferable;
    3840import net.sf.basedb.info.Transferable;
     
    7476    {
    7577      query.restrict(Hql.restriction(qOpt.getRestriction(), qOpt.getRestrictionPrefix()));
     78    }
     79    QueryParameter[] parameters = qOpt.getParameters();
     80    if (parameters != null && parameters.length > 0)
     81    {
     82      for (QueryParameter qp : parameters)
     83      {
     84        Type valueType = Type.valueOf(qp.getType());
     85        Object value = valueType.parseString(qp.getValue());
     86        query.setParameter(qp.getName(), value, valueType);
     87      }
    7688    }
    7789    return query;
Note: See TracChangeset for help on using the changeset viewer.