Changeset 3974


Ignore:
Timestamp:
Nov 16, 2007, 9:28:40 AM (14 years ago)
Author:
Nicklas Nordborg
Message:

References #827: Add more web services methods

Added Transferable and ToTransferable? to make it easier to write generic code for populating classes that are going to be transfered with web services.

Location:
trunk/src
Files:
2 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/AnnotatedItem.java

    r3956 r3974  
    9595    @since 2.5
    9696   */
    97   AnnotatedItemInfo toInfo(AnnotatedItemInfo info)
     97  AnnotatedItemInfo toTransferable(AnnotatedItemInfo info)
    9898  {
    99     super.toInfo(info);
     99    super.toTransferable(info);
    100100    info.setAnnotated(this.isAnnotated());
    101101    return info;
  • trunk/src/core/net/sf/basedb/core/AnnotationType.java

    r3973 r3974  
    3333import net.sf.basedb.core.query.Hql;
    3434import net.sf.basedb.info.AnnotationTypeInfo;
     35import net.sf.basedb.info.ToTransferable;
    3536
    3637import java.util.Set;
     
    5758public class AnnotationType
    5859  extends CommonItem<AnnotationTypeData>
     60  implements ToTransferable<AnnotationTypeInfo>
    5961{
    6062  /**
     
    266268  }
    267269 
    268   public AnnotationTypeInfo toInfo(AnnotationTypeInfo info)
    269   {
    270     super.toInfo(info);
     270  public AnnotationTypeInfo toTransferable(AnnotationTypeInfo info)
     271  {
     272    super.toTransferable(info);
    271273    info.setDefaultValue(getDefaultValue());
    272274    info.setExternalId(getExternalId());
  • trunk/src/core/net/sf/basedb/core/ArrayDesign.java

    r3956 r3974  
    3232import net.sf.basedb.core.query.Restrictions;
    3333import net.sf.basedb.info.ArrayDesignInfo;
     34import net.sf.basedb.info.ToTransferable;
    3435
    3536import java.util.Collection;
     
    6162public class ArrayDesign
    6263  extends AnnotatedItem<ArrayDesignData>
    63   implements FileStoreEnabled
     64  implements FileStoreEnabled, ToTransferable<ArrayDesignInfo>
    6465{
    6566 
     
    757758    @since 2.5
    758759   */
    759   public ArrayDesignInfo toInfo(ArrayDesignInfo info)
    760   {
    761     super.toInfo(info);
     760  public ArrayDesignInfo toTransferable(ArrayDesignInfo info)
     761  {
     762    super.toTransferable(info);
    762763    info.setNumDbFeatures(this.getNumDbFeatures());
    763764    info.setNumFileFeatures(this.getNumFileFeatures());
    764    
    765765    return info;
    766766  }
  • trunk/src/core/net/sf/basedb/core/BasicItem.java

    r3956 r3974  
    176176    @since 2.5
    177177   */
    178   BasicItemInfo toInfo(BasicItemInfo info)
     178  BasicItemInfo toTransferable(BasicItemInfo info)
    179179  {
    180180    info.setId(this.getId());
     181    info.setVersion(getVersion());
    181182    return info;
    182183  }
  • trunk/src/core/net/sf/basedb/core/BioAssaySet.java

    r3972 r3974  
    4343import net.sf.basedb.core.query.JoinType;
    4444import net.sf.basedb.info.BioAssaySetInfo;
     45import net.sf.basedb.info.ToTransferable;
    4546
    4647import java.util.Collections;
     
    7071public class BioAssaySet
    7172  extends ChildItem<BioAssaySetData>
    72   implements Nameable, Removable, Annotatable
     73  implements Nameable, Removable, Annotatable, ToTransferable<BioAssaySetInfo>
    7374{
    7475  /**
     
    347348    @since 2.5
    348349   */
    349   public BioAssaySetInfo toInfo(BioAssaySetInfo info)
    350   {
    351     super.toInfo(info);   
     350  public BioAssaySetInfo toTransferable(BioAssaySetInfo info)
     351  {
     352    super.toTransferable(info);   
    352353    info.setName(this.getName());
    353354    info.setDescription(this.getDescription());
  • trunk/src/core/net/sf/basedb/core/CommonItem.java

    r3956 r3974  
    8686    @since 2.5
    8787   */
    88   CommonItemInfo toInfo(CommonItemInfo info)
     88  CommonItemInfo toTransferable(CommonItemInfo info)
    8989  {
    90     super.toInfo(info);
     90    super.toTransferable(info);
    9191    info.setDescription(this.getDescription());
    9292    info.setName(this.getName());
  • trunk/src/core/net/sf/basedb/core/DataFileType.java

    r3956 r3974  
    3333import net.sf.basedb.core.query.Restrictions;
    3434import net.sf.basedb.info.DataFileTypeInfo;
     35import net.sf.basedb.info.ToTransferable;
    3536import net.sf.basedb.util.ClassUtil;
    3637
     
    4950public class DataFileType
    5051  extends BasicItem<DataFileTypeData>
    51   implements Nameable, Removable
     52  implements Nameable, Removable, ToTransferable<DataFileTypeInfo>
    5253{
    5354 
     
    364365    @since 2.5
    365366   */
    366   public DataFileTypeInfo toInfo(DataFileTypeInfo info)
    367   {
    368     super.toInfo(info);
     367  public DataFileTypeInfo toTransferable(DataFileTypeInfo info)
     368  {
     369    super.toTransferable(info);
    369370    info.setName(getName());
    370371    info.setDescription(getDescription());
  • trunk/src/core/net/sf/basedb/core/Experiment.java

    r3956 r3974  
    3030import net.sf.basedb.core.query.Hql;
    3131import net.sf.basedb.info.ExperimentInfo;
     32import net.sf.basedb.info.ToTransferable;
    3233
    3334import java.util.Date;
     
    5152public class Experiment
    5253  extends CommonItem<ExperimentData>
    53   implements DiskConsumable, Transactional
     54  implements DiskConsumable, Transactional, ToTransferable<ExperimentInfo>
    5455{
    5556  /**
     
    267268    @since 2.5
    268269   */
    269   public ExperimentInfo toInfo(ExperimentInfo info)
    270   {
    271     super.toInfo(info);
     270  public ExperimentInfo toTransferable(ExperimentInfo info)
     271  {
     272    super.toTransferable(info);
    272273    info.setAbstractText(this.getAbstract());
    273274    info.setAffiliations(this.getAffiliations());
  • trunk/src/core/net/sf/basedb/core/OwnedItem.java

    r3956 r3974  
    122122    @since 2.5
    123123   */
    124   OwnedItemInfo toInfo(OwnedItemInfo info)
     124  OwnedItemInfo toTransferable(OwnedItemInfo info)
    125125  {
    126     super.toInfo(info);
     126    super.toTransferable(info);
    127127    try
    128128    {
  • trunk/src/core/net/sf/basedb/core/Project.java

    r3957 r3974  
    3434import net.sf.basedb.core.query.ResultList;
    3535import net.sf.basedb.info.ProjectInfo;
     36import net.sf.basedb.info.ToTransferable;
    3637
    3738import java.util.ArrayList;
     
    8081public class Project
    8182  extends OwnedItem<ProjectData>
    82   implements Nameable, Removable
     83  implements Nameable, Removable, ToTransferable<ProjectInfo>
    8384{
    8485  /**
     
    582583  }
    583584 
    584   public ProjectInfo toInfo(ProjectInfo info)
    585   {
    586     super.toInfo(info);
     585  public ProjectInfo toTransferable(ProjectInfo info)
     586  {
     587    super.toTransferable(info);
    587588    info.setDescription(this.getDescription());
    588589    info.setName(this.getName());
  • trunk/src/core/net/sf/basedb/core/RawBioAssay.java

    r3956 r3974  
    3939import net.sf.basedb.core.query.Expressions;
    4040import net.sf.basedb.info.RawBioAssayInfo;
     41import net.sf.basedb.info.ToTransferable;
    4142
    4243import java.util.Collection;
     
    6667public class RawBioAssay
    6768  extends AnnotatedItem<RawBioAssayData>
    68   implements DiskConsumable, FileStoreEnabled
     69  implements DiskConsumable, FileStoreEnabled, ToTransferable<RawBioAssayInfo>
    6970{
    7071  /**
     
    426427    @since 2.5
    427428   */
    428   public RawBioAssayInfo toInfo(RawBioAssayInfo info)
    429   {
    430     super.toInfo(info);
     429  public RawBioAssayInfo toTransferable(RawBioAssayInfo info)
     430  {
     431    super.toTransferable(info);
    431432    info.setArrayDesignId(this.getArrayDesign().getId());
    432433    info.setPlatformId(this.getPlatform().getId());
  • trunk/src/core/net/sf/basedb/core/SharedItem.java

    r3956 r3974  
    122122    @since 2.5
    123123   */
    124   SharedItemInfo toInfo(SharedItemInfo info)
     124  SharedItemInfo toTransferable(SharedItemInfo info)
    125125  {
    126     super.toInfo(info);
     126    super.toTransferable(info);
    127127    info.setShared(this.isShared());
    128128    return info;
  • trunk/src/info/net/sf/basedb/info/AnnotationInfo.java

    r3973 r3974  
    3434*/
    3535public class AnnotationInfo
    36   implements Serializable
     36  implements Serializable, Transferable
    3737{
    3838
  • trunk/src/info/net/sf/basedb/info/ArrayDesignInfo.java

    r3959 r3974  
    3737public class ArrayDesignInfo
    3838  extends AnnotatedItemInfo
    39     implements Serializable
     39  implements Serializable
    4040{
    4141  private static final long serialVersionUID = 5869031159593261755L;
  • trunk/src/info/net/sf/basedb/info/BasicItemInfo.java

    r3957 r3974  
    2626
    2727/**
     28  Superclass for all transferable classes that transfer information
     29  about item-classes, ie. classes that are subclasses of
     30  {@link net.sf.basedb.core.BasicItem}.
     31
    2832    @author Martin
    2933    @version 2.5
    30  */
     34*/
    3135public abstract class BasicItemInfo
     36  implements Transferable
    3237{
    3338  private int id;
    34 
     39  private int version;
     40 
    3541  /**
    3642      @param id The id to set.
     
    4854    return id;
    4955  }
     56 
     57  public void setVersion(int version)
     58  {
     59    this.version = version;
     60  }
     61 
     62  public int getVersion()
     63  {
     64    return version;
     65  }
     66 
    5067
    5168}
  • trunk/src/info/net/sf/basedb/info/QueryOptions.java

    r3952 r3974  
    4242 */
    4343public class QueryOptions
     44  implements Transferable
    4445{
    4546  /**
  • trunk/src/info/net/sf/basedb/info/VersionInfo.java

    r3960 r3974  
    3333 */
    3434public class VersionInfo
    35   implements Serializable
     35  implements Serializable, Transferable
    3636{
    3737  private static final long serialVersionUID = 9189853948028180946L;
  • trunk/src/info/net/sf/basedb/info/package.html

    r3960 r3974  
    2828  classes are, for example, used by the webservices implementation, but
    2929  can also be used by other clients with similar needs. The classes
    30   are <code>Serializable</code>.
     30  are {@link java.io.Serializable} and {@link net.sf.basedb.info.Transferable}.
    3131</p>
    3232<p>
     
    3636  For each class in this package, there usually is a corresponding class
    3737  in the business layer, for example {@link net.sf.basedb.info.ProjectInfo} and
    38   {@link net.sf.basedb.core.User}.
     38  {@link net.sf.basedb.core.Project}.
    3939</p>
    4040<p>
    41   Client applications can create instances themselves or use the
    42   {@link net.sf.basedb.core.BasicItem#toInfo(net.sf.basedb.info.BasicInfo)}
    43   method to let the core create an initialised instance. Note! The latter
     41  Client applications can create and initialise instances themselves or use the
     42  {@link net.sf.basedb.info.ToTransferable#toTransferable(net.sf.basedb.info.Transferable)}
     43  method to let the core initialise an instance. Note! The latter
    4444  alternative will of course only work for code executing on the server.
    4545  It will, for example, not work in the webservices client since it doesn't
  • trunk/src/webservices/server/net/sf/basedb/ws/server/RawBioAssayService.java

    r3973 r3974  
    7171      RawBioAssay rawBioAssay = RawBioAssay.getById(dc, rawBioAssayId);
    7272      ArrayDesign arrayDesign = rawBioAssay.getArrayDesign();
    73       if (arrayDesign != null) info = arrayDesign.toInfo(new ArrayDesignInfo());
     73      if (arrayDesign != null) info = arrayDesign.toTransferable(new ArrayDesignInfo());
    7474    }
    7575    finally
  • trunk/src/webservices/server/net/sf/basedb/ws/server/ServicesUtil.java

    r3973 r3974  
    3535import net.sf.basedb.info.AnnotationInfo;
    3636import net.sf.basedb.info.QueryOptions;
     37import net.sf.basedb.info.ToTransferable;
     38import net.sf.basedb.info.Transferable;
    3739
    38 import java.lang.reflect.InvocationTargetException;
    39 import java.lang.reflect.Method;
    4040import java.util.EnumSet;
    4141import java.util.LinkedList;
     
    105105  */
    106106  @SuppressWarnings("unchecked")
    107   public <T> T[] listToInfo(List<?> list, Class<T> clazz)
     107  public <T extends Transferable> T[] listToInfo(List<? extends ToTransferable<T>> list, Class<T> clazz)
    108108  {
    109109    T[] result = (T[])java.lang.reflect.Array.newInstance(clazz, list.size());
    110     int i = 0;
    111     Method toInfo = null;
    112110    try
    113111    {
    114       for (Object o : list)
     112      int i = 0;
     113      for (ToTransferable<T> o : list)
    115114      {
    116         if (toInfo == null) toInfo = o.getClass().getDeclaredMethod("toInfo", clazz);
    117         result[i] = clazz.newInstance();
    118         toInfo.invoke(o, result[i]);
     115        result[i] = o.toTransferable(clazz.newInstance());
    119116        ++i;
    120117      }
    121     }
    122     catch (NoSuchMethodException ex)
    123     {
    124       throw new RuntimeException(ex);
    125118    }
    126119    catch (InstantiationException ex)
     
    129122    }
    130123    catch (IllegalAccessException ex)
    131     {
    132       throw new RuntimeException(ex);
    133     }
    134     catch (InvocationTargetException ex)
    135124    {
    136125      throw new RuntimeException(ex);
Note: See TracChangeset for help on using the changeset viewer.