Changeset 3797


Ignore:
Timestamp:
Sep 28, 2007, 8:35:54 AM (16 years ago)
Author:
Nicklas Nordborg
Message:

References #721: Changes systemId to externalId

Location:
branches/filedb/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/filedb/src/core/common-queries.xml

    r3793 r3797  
    28132813  </query>
    28142814 
    2815   <query id="GET_PLATFORM_FOR_SYSTEM_ID" type="HQL">
     2815  <query id="GET_PLATFORM_FOR_EXTERNAL_ID" type="HQL">
    28162816    <sql>
    28172817      SELECT plf
    28182818      FROM PlatformData plf
    2819       WHERE plf.systemId = :systemId
    2820     </sql>
    2821     <description>
    2822       A Hibernate query that loads a platform by system ID.
    2823     </description>
    2824   </query>
    2825  
    2826   <query id="GET_DATAFILETYPE_FOR_SYSTEM_ID" type="HQL">
     2819      WHERE plf.externalId = :externalId
     2820    </sql>
     2821    <description>
     2822      A Hibernate query that loads a platform by external ID.
     2823    </description>
     2824  </query>
     2825 
     2826  <query id="GET_PLATFORMVARIANT_FOR_EXTERNAL_ID" type="HQL">
     2827    <sql>
     2828      SELECT plv
     2829      FROM PlatformVariantData plv
     2830      WHERE plv.externalId = :externalId
     2831    </sql>
     2832    <description>
     2833      A Hibernate query that loads a platform variant by external ID.
     2834    </description>
     2835  </query>
     2836 
     2837  <query id="GET_DATAFILETYPE_FOR_EXTERNAL_ID" type="HQL">
    28272838    <sql>
    28282839      SELECT dft
    28292840      FROM DataFileTypeData dft
    2830       WHERE dft.systemId = :systemId
    2831     </sql>
    2832     <description>
    2833       A Hibernate query that loads a file set member type by system ID.
     2841      WHERE dft.externalId = :externalId
     2842    </sql>
     2843    <description>
     2844      A Hibernate query that loads a data file type by external ID.
    28342845    </description>
    28352846  </query>
  • branches/filedb/src/core/net/sf/basedb/core/ArrayDesign.java

    r3783 r3797  
    284284  public boolean isAffyChip()
    285285  {
    286     return Platform.AFFYMETRIX.equals(getData().getPlatform().getSystemId());
     286    return Platform.AFFYMETRIX.equals(getData().getPlatform().getExternalId());
    287287  }
    288288
  • branches/filedb/src/core/net/sf/basedb/core/DataFileType.java

    r3793 r3797  
    4343public class DataFileType
    4444  extends BasicItem<DataFileTypeData>
    45   implements Nameable, Removable, SystemItem
     45  implements Nameable, Removable
    4646{
    4747 
     
    7070   
    7171    @param dc The DbControl to use for database access
    72     @param systemId The system ID of the new type, must be
     72    @param externalId The external ID of the new type, must be
    7373      unique for all file types
    7474    @param itemType The type of item that files of this type can
     
    7777    @return The new file set member type object
    7878  */
    79   public static DataFileType getNew(DbControl dc, String systemId, Item itemType)
     79  public static DataFileType getNew(DbControl dc, String externalId, Item itemType)
    8080  {
    8181    DataFileType type = dc.newItem(DataFileType.class);
    82     type.setSystemId(systemId);
     82    type.setExternalId(externalId);
    8383    type.setName("New data file type");
    8484    type.setItemType(itemType);
     
    107107 
    108108  /**
     109    Get a <code>DataFileType</code> item when you know the external ID.
     110 
     111    @param dc The <code>DbControl</code> which will be used for
     112      permission checking and database access.
     113    @param externalId The external ID of the item to load
     114    @return The <code>DataFileType</code> item.
     115    @throws ItemNotFoundException If an item with the specified ID is not found
     116    @throws PermissionDeniedException If the logged in user doesn't have
     117      read permission for the item
     118    @throws BaseException If there is another error
     119  */
     120  public static DataFileType getByExternalId(DbControl dc, String externalId)
     121    throws ItemNotFoundException, PermissionDeniedException, BaseException
     122  {
     123    if (externalId != null) externalId = externalId.trim();
     124    org.hibernate.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
     125      "GET_DATAFILETYPE_FOR_EXTERNAL_ID");
     126    /*
     127      SELECT dft
     128      FROM DataFileTypeData dft
     129      WHERE dft.externalId = :externalId
     130    */
     131    query.setString("externalId", externalId);
     132    DataFileType dft = dc.getItem(DataFileType.class, HibernateUtil.loadData(DataFileTypeData.class, query));
     133    if (dft == null) throw new ItemNotFoundException("DataFileType[externalId="+externalId+"]");
     134    return dft;
     135  }
     136 
     137  /**
    109138    Get a query configured to retrieve <code>DataFileType</code> items.
    110139    @return An {@link ItemQuery} object
     
    158187    checkPermission(Permission.WRITE);
    159188    NameableUtil.setDescription(getData(), description);
    160   }
    161   // -------------------------------------------
    162   /*
    163     From the SystemItem interface
    164     -------------------------------------------
    165   */
    166   public String getSystemId()
    167   {
    168     return getData().getSystemId();
    169   }
    170   public boolean isSystemItem()
    171   {
    172     return getData().getSystemId() != null;
    173189  }
    174190  // -------------------------------------------
     
    239255 
    240256  /**
    241     Set the system ID. Null is not allowed and the length must
    242     be less than {@link #MAX_SYSTEM_ID_LENGTH}.
    243   */
    244   private void setSystemId(String systemId)
    245   {
    246     getData().setSystemId(StringUtil.setNotNullString(systemId, "systemId", MAX_SYSTEM_ID_LENGTH));
     257    The maximum length of the external ID that can be stored in the database.
     258    @see #setExternalId(String)
     259  */
     260  public static final int MAX_EXTERNAL_ID_LENGTH = DataFileTypeData.MAX_EXTERNAL_ID_LENGTH;
     261
     262  /**
     263    Get the external id for the data file type.
     264  */
     265  public String getExternalId()
     266  {
     267    return getData().getExternalId();
     268  }
     269 
     270  private void setExternalId(String externalId)
     271    throws PermissionDeniedException, InvalidDataException, BaseException
     272  {
     273    getData().setExternalId(StringUtil.setNullableString(
     274      externalId, "externalId", MAX_EXTERNAL_ID_LENGTH));
    247275  }
    248276 
  • branches/filedb/src/core/net/sf/basedb/core/Install.java

    r3796 r3797  
    21912191    Create a {@link Platform}.
    21922192  */
    2193   private static PlatformData createPlatform(String systemId, String name, String description,
     2193  private static PlatformData createPlatform(String externalId, String name, String description,
    21942194    boolean fileOnly, String rawDataType, int channels, PlatformFT... fileTypes)
    21952195    throws BaseException
     
    22032203      if (platform == null)
    22042204      {
    2205         org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, "GET_PLATFORM_FOR_SYSTEM_ID");
    2206         query.setString("systemId", systemId);
     2205        org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     2206          "GET_PLATFORM_FOR_EXTERNAL_ID");
     2207        query.setString("externalId", externalId);
    22072208        platform = HibernateUtil.loadData(PlatformData.class, query);
    22082209      }
     
    22102211      if (platform != null)
    22112212      {
    2212         log.info("createPlatform: EXISTS [systemId="+systemId+"]");
     2213        log.info("createPlatform: EXISTS [externalId="+externalId+"]");
    22132214        HibernateUtil.commit(tx);
    22142215      }
     
    22162217      {
    22172218        platform = new PlatformData();
    2218         platform.setSystemId(systemId);
     2219        platform.setExternalId(externalId);
    22192220        platform.setName(name);
    22202221        platform.setDescription(description);
     
    22432244       
    22442245        HibernateUtil.commit(tx);
    2245         if (systemId != null) SystemItems.add(platform);
    2246         log.info("createPlatform: OK [systemId="+systemId+"]");
     2246        log.info("createPlatform: OK [externalId="+externalId+"]");
    22472247      }
    22482248    }
     
    22502250    {
    22512251      if(tx != null) HibernateUtil.rollback(tx);
    2252       log.error("createPlatform: FAILED [systemId="+systemId+"]", ex);
     2252      log.error("createPlatform: FAILED [externalId="+externalId+"]", ex);
    22532253      throw ex;
    22542254    }
     
    22602260  */
    22612261  private static DataFileTypeData createDataFileType(
    2262     String systemId, String name, String description,
     2262    String externalId, String name, String description,
    22632263    Item itemType, String extension, FileTypeData genericType,
    22642264    String validatorClass, String metadataReaderClass)
     
    22742274      {
    22752275        org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
    2276           "GET_DATAFILETYPE_FOR_SYSTEM_ID");
    2277         query.setString("systemId", systemId);
     2276          "GET_DATAFILETYPE_FOR_EXTERNAL_ID");
     2277        query.setString("externalId", externalId);
    22782278        fileType = HibernateUtil.loadData(DataFileTypeData.class, query);
    22792279      }
     
    22812281      if (fileType != null)
    22822282      {
    2283         log.info("createDataFileType: EXISTS [systemId="+systemId+"]");
     2283        log.info("createDataFileType: EXISTS [externalId="+externalId+"]");
    22842284        HibernateUtil.commit(tx);
    22852285      }
     
    22872287      {
    22882288        fileType = new DataFileTypeData();
    2289         fileType.setSystemId(systemId);
     2289        fileType.setExternalId(externalId);
    22902290        fileType.setName(name);
    22912291        fileType.setDescription(description);
     
    22982298        HibernateUtil.saveData(session, fileType);
    22992299        HibernateUtil.commit(tx);
    2300         if (systemId != null) SystemItems.add(fileType);
    2301         log.info("createDataFileType: OK [systemId="+systemId+"]");
     2300        log.info("createDataFileType: OK [externalId="+externalId+"]");
    23022301      }
    23032302    }
     
    23052304    {
    23062305      if(tx != null) HibernateUtil.rollback(tx);
    2307       log.error("createDataFileType: FAILED [systemId="+systemId+"]", ex);
     2306      log.error("createDataFileType: FAILED [externalId="+externalId+"]", ex);
    23082307      throw ex;
    23092308    }
  • branches/filedb/src/core/net/sf/basedb/core/Platform.java

    r3793 r3797  
    4242public class Platform
    4343  extends BasicItem<PlatformData>
    44   implements Nameable, Removable, SystemItem
     44  implements Nameable, Removable
    4545{
    4646 
     
    7070   
    7171    @param dc The DbControl to use for database access
    72     @param systemId The system ID of the platform, must be
     72    @param externalId The external ID of the platform, must be
    7373      unique for all platforms
    7474    @param channels Number of channels in this platform
    7575    @return The new platform object
    7676  */
    77   public static Platform getNew(DbControl dc, String systemId, int channels)
     77  public static Platform getNew(DbControl dc, String externalId, int channels)
    7878  {
    7979    Platform p = dc.newItem(Platform.class);
    8080    p.getData().setFileOnly(true);
    81     p.setSystemId(systemId);
     81    p.setExternalId(externalId);
    8282    p.setChannels(channels);
    8383    return p;
     
    8888   
    8989    @param dc The DbControl to use for database access
    90     @param systemId The system ID of the platform, must be
     90    @param externalId The external ID of the platform, must be
    9191      unique for all platforms
    9292    @param rawDataType A specific raw data type this platform will be locked
     
    9494    @return The new platform object
    9595  */
    96   public static Platform getNew(DbControl dc, String systemId, RawDataType rawDataType)
     96  public static Platform getNew(DbControl dc, String externalId, RawDataType rawDataType)
    9797  {
    9898    Platform p = dc.newItem(Platform.class);
    9999    p.getData().setFileOnly(false);
    100     p.setSystemId(systemId);
     100    p.setExternalId(externalId);
    101101    p.setRawDataType(rawDataType);
    102102    return p;
     
    124124 
    125125  /**
     126    Get a <code>Platform</code> item when you know the external ID.
     127 
     128    @param dc The <code>DbControl</code> which will be used for
     129      permission checking and database access.
     130    @param externalId The external ID of the item to load
     131    @return The <code>Platform</code> item.
     132    @throws ItemNotFoundException If an item with the specified ID is not found
     133    @throws PermissionDeniedException If the logged in user doesn't have
     134      read permission for the item
     135    @throws BaseException If there is another error
     136  */
     137  public static Platform getByExternalId(DbControl dc, String externalId)
     138    throws ItemNotFoundException, PermissionDeniedException, BaseException
     139  {
     140    if (externalId != null) externalId = externalId.trim();
     141    org.hibernate.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
     142      "GET_PLATFORM_FOR_EXTERNAL_ID");
     143    /*
     144      SELECT plf
     145      FROM PlatformData plf
     146      WHERE plf.externalId = :externalId
     147    */
     148    query.setString("externalId", externalId);
     149    Platform p = dc.getItem(Platform.class, HibernateUtil.loadData(PlatformData.class, query));
     150    if (p == null) throw new ItemNotFoundException("Platform[externalId="+externalId+"]");
     151    return p;
     152  }
     153 
     154  /**
    126155    Get a query configured to retrieve <code>Platform</code> items.
    127156    @return An {@link ItemQuery} object
     
    175204    checkPermission(Permission.WRITE);
    176205    NameableUtil.setDescription(getData(), description);
    177   }
    178   // -------------------------------------------
    179   /*
    180     From the SystemItem interface
    181     -------------------------------------------
    182   */
    183   public String getSystemId()
    184   {
    185     return getData().getSystemId();
    186   }
    187   public boolean isSystemItem()
    188   {
    189     return getData().getSystemId() != null;
    190206  }
    191207  // -------------------------------------------
     
    275291    return using;
    276292  }
     293  /**
     294    Deny deletion of the GENERIC platform. It is required by the
     295    system.
     296  */
     297  @Override
     298  protected void initPermissions(int granted, int denied)
     299  {
     300    if (GENERIC.equals(getExternalId()))
     301    {
     302      denied |= Permission.deny(Permission.DELETE);
     303    }
     304    super.initPermissions(granted, denied);
     305  }
    277306  // -------------------------------------------
    278307 
    279308  /**
    280     Set the system ID. Null is not allowed and the length must
    281     be less than {@link #MAX_SYSTEM_ID_LENGTH}.
    282   */
    283   private void setSystemId(String systemId)
    284   {
    285     getData().setSystemId(StringUtil.setNotNullString(systemId, "systemId", MAX_SYSTEM_ID_LENGTH));
     309    The maximum length of the external ID that can be stored in the database.
     310    @see #setExternalId(String)
     311  */
     312  public static final int MAX_EXTERNAL_ID_LENGTH = PlatformData.MAX_EXTERNAL_ID_LENGTH;
     313 
     314  /**
     315    Get the external id for the platform.
     316  */
     317  public String getExternalId()
     318  {
     319    return getData().getExternalId();
     320  }
     321 
     322  private void setExternalId(String externalId)
     323    throws PermissionDeniedException, InvalidDataException, BaseException
     324  {
     325    getData().setExternalId(StringUtil.setNullableString(
     326      externalId, "externalId", MAX_EXTERNAL_ID_LENGTH));
    286327  }
    287328 
     
    338379    {
    339380      // TODO - autogenerate a raw data type in a proper way
    340       rdt = new RawDataType(getSystemId(), getName(), getDescription(), getData().getChannels(),
     381      rdt = new RawDataType(getExternalId(), getName(), getDescription(), getData().getChannels(),
    341382        "file", null, null, null);
    342383    }
  • branches/filedb/src/core/net/sf/basedb/core/PlatformVariant.java

    r3793 r3797  
    3737public class PlatformVariant
    3838  extends BasicItem<PlatformVariantData>
    39   implements Nameable, Removable, SystemItem
     39  implements Nameable, Removable
    4040{
    4141 
     
    7272   
    7373    @param dc The DbControl to use for database access
    74     @param systemId The system ID of the variant, it must be
     74    @param externalId The external ID of the variant, it must be
    7575      unique for all variants
    7676    @param channels Number of channels in this variant
    7777    @return The new variant object
    7878  */
    79   public static PlatformVariant getNew(DbControl dc, Platform p, String systemId, int channels)
     79  public static PlatformVariant getNew(DbControl dc, Platform p, String externalId, int channels)
    8080  {
    8181    PlatformVariant v = dc.newItem(PlatformVariant.class);
    8282    v.setPlatform(p);
    8383    v.getData().setFileOnly(true);
    84     v.setSystemId(systemId);
     84    v.setExternalId(externalId);
    8585    v.setChannels(channels);
    8686    return v;
     
    9292   
    9393    @param dc The DbControl to use for database access
    94     @param systemId The system ID of the platform variant, must be
     94    @param externalId The external ID of the platform variant, must be
    9595      unique for all variants (including those for other platforms)
    9696    @param rawDataType A specific raw data type this platform will be locked
     
    9898    @return The new platform object
    9999  */
    100   public static PlatformVariant getNew(DbControl dc, Platform p, String systemId, RawDataType rawDataType)
     100  public static PlatformVariant getNew(DbControl dc, Platform p, String externalId, RawDataType rawDataType)
    101101  {
    102102    PlatformVariant v = dc.newItem(PlatformVariant.class);
    103103    v.setPlatform(p);
    104104    v.getData().setFileOnly(false);
    105     v.setSystemId(systemId);
     105    v.setExternalId(externalId);
    106106    v.setRawDataType(rawDataType);
    107107    return v;
     
    129129 
    130130  /**
     131    Get a <code>PlatformVariant</code> item when you know the external ID.
     132 
     133    @param dc The <code>DbControl</code> which will be used for
     134      permission checking and database access.
     135    @param externalId The external ID of the item to load
     136    @return The <code>PlatformVariant</code> item.
     137    @throws ItemNotFoundException If an item with the specified ID is not found
     138    @throws PermissionDeniedException If the logged in user doesn't have
     139      read permission for the item
     140    @throws BaseException If there is another error
     141  */
     142  public static PlatformVariant getByExternalId(DbControl dc, String externalId)
     143    throws ItemNotFoundException, PermissionDeniedException, BaseException
     144  {
     145    if (externalId != null) externalId = externalId.trim();
     146    org.hibernate.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
     147      "GET_PLATFORMVARIANT_FOR_EXTERNAL_ID");
     148    /*
     149      SELECT plv
     150      FROM PlatformVariantData plv
     151      WHERE plv.externalId = :externalId
     152    */
     153    query.setString("externalId", externalId);
     154    PlatformVariant v = dc.getItem(PlatformVariant.class, HibernateUtil.loadData(PlatformVariantData.class, query));
     155    if (v == null) throw new ItemNotFoundException("PlatformVariant[externalId="+externalId+"]");
     156    return v;
     157  }
     158 
     159  /**
    131160    Get a query configured to retrieve <code>Platform</code> items.
    132161    @return An {@link ItemQuery} object
     
    180209    checkPermission(Permission.WRITE);
    181210    NameableUtil.setDescription(getData(), description);
    182   }
    183   // -------------------------------------------
    184   /*
    185     From the SystemItem interface
    186     -------------------------------------------
    187   */
    188   public String getSystemId()
    189   {
    190     return getData().getSystemId();
    191   }
    192   public boolean isSystemItem()
    193   {
    194     return getData().getSystemId() != null;
    195211  }
    196212  // -------------------------------------------
     
    300316 
    301317  /**
    302     Set the system ID. Null is not allowed and the length must
    303     be less than {@link #MAX_SYSTEM_ID_LENGTH}.
    304   */
    305   private void setSystemId(String systemId)
    306   {
    307     getData().setSystemId(StringUtil.setNotNullString(systemId, "systemId",
    308       MAX_SYSTEM_ID_LENGTH));
     318    The maximum length of the external ID that can be stored in the database.
     319    @see #setExternalId(String)
     320  */
     321  public static final int MAX_EXTERNAL_ID_LENGTH = PlatformVariantData.MAX_EXTERNAL_ID_LENGTH;
     322 
     323  /**
     324    Get the external id for the platform variant.
     325  */
     326  public String getExternalId()
     327  {
     328    return getData().getExternalId();
     329  }
     330 
     331  private void setExternalId(String externalId)
     332    throws PermissionDeniedException, InvalidDataException, BaseException
     333  {
     334    getData().setExternalId(StringUtil.setNullableString(
     335      externalId, "externalId", MAX_EXTERNAL_ID_LENGTH));
    309336  }
    310337 
  • branches/filedb/src/core/net/sf/basedb/core/SystemItem.java

    r3764 r3797  
    2525package net.sf.basedb.core;
    2626
    27 import net.sf.basedb.core.data.PlatformData;
     27import net.sf.basedb.core.data.SystemData;
    2828
    2929/**
     
    6262  */
    6363  public static final int MAX_SYSTEM_ID_LENGTH =
    64     PlatformData.MAX_SYSTEM_ID_LENGTH;
     64    SystemData.MAX_SYSTEM_ID_LENGTH;
    6565 
    6666 
  • branches/filedb/src/core/net/sf/basedb/core/data/DataFileTypeData.java

    r3793 r3797  
    3737public class DataFileTypeData
    3838  extends BasicData
    39   implements NameableData, RemovableData, SystemData
     39  implements NameableData, RemovableData
    4040{
    4141
     
    6868 
    6969  /*
    70     From the SystemData interface
    71     -------------------------------------------
    72   */
    73   private String systemId;
    74   /**
    75     Get the system id for the item. We override the Hibernate declaration to make
    76     the column NOT NULL and UNIQUE.
    77     @return The id of the item
    78     @hibernate.property column="`system_id`" type="string" length="255"
    79       not-null="true" update="false" unique="true"
    80   */
    81   public String getSystemId()
    82   {
    83     return systemId;
    84   }
    85   public void setSystemId(String systemId)
    86   {
    87     this.systemId = systemId;
    88   }
    89   // -------------------------------------------
    90  
    91   /*
    9270    From the RemovableData interface
    9371    -------------------------------------------
     
    10482  // -------------------------------------------
    10583
     84  /**
     85    The maximum length of the external ID that can be stored in the database.
     86    @see #setExternalId(String)
     87  */
     88  public static final int MAX_EXTERNAL_ID_LENGTH = 255;
     89  private String externalId;
     90  /**
     91    Get the external id for the item.
     92    @return The external id of the item
     93    @hibernate.property column="`external_id`" type="string" length="255"
     94      not-null="true" update="false" unique="true"
     95  */
     96  public String getExternalId()
     97  {
     98    return externalId;
     99  }
     100  public void setExternalId(String externalId)
     101  {
     102    this.externalId = externalId;
     103  }
     104 
    106105  /**
    107106    The maximum length of the file extension that can be stored in the
  • branches/filedb/src/core/net/sf/basedb/core/data/PlatformData.java

    r3793 r3797  
    3939public class PlatformData
    4040  extends BasicData
    41   implements NameableData, RemovableData, SystemData
     41  implements NameableData, RemovableData
    4242{
    4343
     
    7070
    7171  /*
    72     From the SystemData interface
    73     -------------------------------------------
    74   */
    75   private String systemId;
    76   /**
    77     Get the system id for the item. We override the Hibernate declaration to make
    78     the column NOT NULL and UNIQUE.
    79     @return The id of the item
    80     @hibernate.property column="`system_id`" type="string" length="255"
    81       not-null="true" update="false" unique="true"
    82   */
    83   public String getSystemId()
    84   {
    85     return systemId;
    86   }
    87   public void setSystemId(String systemId)
    88   {
    89     this.systemId = systemId;
    90   }
    91   // -------------------------------------------
    92 
    93   /*
    9472    From the RemovableData interface
    9573    -------------------------------------------
     
    10684  // -------------------------------------------
    10785
     86  /**
     87    The maximum length of the external ID that can be stored in the database.
     88    @see #setExternalId(String)
     89  */
     90  public static final int MAX_EXTERNAL_ID_LENGTH = 255;
     91  private String externalId;
     92  /**
     93    Get the external id for the item.
     94    @return The external id of the item
     95    @hibernate.property column="`external_id`" type="string" length="255"
     96      not-null="true" update="false" unique="true"
     97  */
     98  public String getExternalId()
     99  {
     100    return externalId;
     101  }
     102  public void setExternalId(String externalId)
     103  {
     104    this.externalId = externalId;
     105  }
     106 
    108107  private boolean fileOnly;
    109108  /**
  • branches/filedb/src/core/net/sf/basedb/core/data/PlatformVariantData.java

    r3793 r3797  
    3737public class PlatformVariantData
    3838  extends BasicData
    39   implements NameableData, RemovableData, SystemData
     39  implements NameableData, RemovableData
    4040{
    4141
     
    6868
    6969  /*
    70     From the SystemData interface
    71     -------------------------------------------
    72   */
    73   private String systemId;
    74   /**
    75     Get the system id for the item. We override the Hibernate declaration to make
    76     the column NOT NULL and UNIQUE.
    77     @return The id of the item
    78     @hibernate.property column="`system_id`" type="string" length="255"
    79       not-null="true" update="false" unique="true"
    80   */
    81   public String getSystemId()
    82   {
    83     return systemId;
    84   }
    85   public void setSystemId(String systemId)
    86   {
    87     this.systemId = systemId;
    88   }
    89   // -------------------------------------------
    90 
    91   /*
    9270    From the RemovableData interface
    9371    -------------------------------------------
     
    10482  // -------------------------------------------
    10583
     84  /**
     85    The maximum length of the external ID that can be stored in the database.
     86    @see #setExternalId(String)
     87  */
     88  public static final int MAX_EXTERNAL_ID_LENGTH = 255;
     89  private String externalId;
     90  /**
     91    Get the external id for the item.
     92    @return The external id of the item
     93    @hibernate.property column="`external_id`" type="string" length="255"
     94      not-null="true" update="false" unique="true"
     95  */
     96  public String getExternalId()
     97  {
     98    return externalId;
     99  }
     100  public void setExternalId(String externalId)
     101  {
     102    this.externalId = externalId;
     103  }
     104 
    106105  private boolean fileOnly;
    107106  /**
  • branches/filedb/src/test/TestArrayDesign.java

    r3793 r3797  
    134134    {
    135135      dc = TestUtil.getDbControl();
    136       Platform platform = Platform.getById(dc, SystemItems.getId(platformId));
     136      Platform platform = Platform.getByExternalId(dc, platformId);
    137137      ArrayDesign ad = ArrayDesign.getNew(dc, platform);
    138138      if (setAll)
     
    386386      dc = TestUtil.getDbControl();
    387387      ArrayDesign ad = ArrayDesign.getById(dc, arrayDesignId);
    388       if (Platform.AFFYMETRIX.equals(ad.getPlatform().getSystemId()))
     388      if (Platform.AFFYMETRIX.equals(ad.getPlatform().getExternalId()))
    389389      {
    390390        throw new BaseException("Cannot add features from wells on an affy arraydesign");
  • branches/filedb/src/test/TestDataFileType.java

    r3793 r3797  
    3030import net.sf.basedb.core.ItemResultList;
    3131import net.sf.basedb.core.Permission;
    32 import net.sf.basedb.core.Platform;
    3332import net.sf.basedb.core.PlatformVariant;
    34 import net.sf.basedb.core.RawDataTypes;
    3533import net.sf.basedb.core.SystemItems;
    3634
     
    6563  }
    6664
    67   static int test_create(String name, String systemId, Item itemType, int genericTypeId)
     65  static int test_create(String name, String externalId, Item itemType, int genericTypeId)
    6866  {
    6967    if (!TestUtil.hasPermission(Permission.CREATE, Item.DATAFILETYPE)) return 0;
     
    7472      dc = TestUtil.getDbControl();
    7573      FileType genericType = genericTypeId == 0 ? null : FileType.getById(dc, genericTypeId);
    76       DataFileType type = DataFileType.getNew(dc, systemId, itemType);
     74      DataFileType type = DataFileType.getNew(dc, externalId, itemType);
    7775      type.setGenericType(genericType);
    7876      type.setName(name);
     
    174172    if (!TestUtil.getSilent())
    175173    {
    176       write("   \tID \tName      \tDescription\tSystem ID");
     174      write("   \tID \tName      \tDescription\\tExternal ID");
    177175      write("-- \t-- \t--------- \t-----------\t---------");
    178176    }
     
    185183    {
    186184      System.out.println(i+":\t"+type.getId()+"\t"+type.getName()+"\t"+
    187           type.getDescription() + "\t" + type.getSystemId());
     185          type.getDescription() + "\t" + type.getExternalId());
    188186    }
    189187  }
     
    195193    {
    196194      System.out.println(i+":\t"+v.getId()+"\t"+v.getName()+"\t"+
    197           v.getDescription() + "\t" + v.getSystemId() + "\t" + v.isFileOnly() + "\t" +
     195          v.getDescription() + "\t" + v.getExternalId() + "\t" + v.isFileOnly() + "\t" +
    198196          v.getRawDataType() + "\t" + v.getPlatform());
    199197    }
     
    205203  }
    206204
    207   static int test_create_variant(int platformId, String name, String systemId, Boolean fileOnly, int channels, String rawDataType)
    208   {
    209     if (platformId == 0 || !TestUtil.hasPermission(Permission.CREATE, Item.PLATFORMVARIANT)) return 0;
     205  static int get_id_for_external(String externalId)
     206  {
    210207    int id = 0;
    211208    DbControl dc = null;
     
    213210    {
    214211      dc = TestUtil.getDbControl();
    215      
    216       Platform p = Platform.getById(dc, platformId);
    217      
    218       PlatformVariant v = null;
    219       if (fileOnly == null)
    220       {
    221         v = PlatformVariant.getNew(dc, p, systemId);
    222       }
    223       else if (fileOnly == true)
    224       {
    225         v = PlatformVariant.getNew(dc, p, systemId, channels);
    226       }
    227       else
    228       {
    229         v = PlatformVariant.getNew(dc, p, systemId, RawDataTypes.getRawDataType(rawDataType));
    230       }
    231       v.setName(name);
    232       dc.saveItem(v);
    233       dc.commit();
    234       id = v.getId();
    235       dc = TestUtil.getDbControl();
    236       dc.reattachItem(v);
    237       write_item(0, v);
    238       write("--Create platform variant OK");
    239     }
    240     catch (Throwable ex)
    241     {
    242       write("--Create platform variant FAILED");
    243       ex.printStackTrace();
    244       ok = false;
    245     }
    246     finally
    247     {
    248       if (dc != null) dc.close();
    249     }
    250     return id;
    251   }
    252  
    253   static void test_list_variants(int platformId, int expectedResults)
    254   {
    255     if (platformId == 0) return;
    256     DbControl dc = null;
    257     try
    258     {
    259       dc = TestUtil.getDbControl();
    260       Platform p = Platform.getById(dc, platformId);
    261       ItemResultList<PlatformVariant> l = p.getVariants().list(dc);
    262       for (int i = 0; i<l.size(); i++)
    263       {
    264         write_item(i, l.get(i));
    265       }
    266       if (expectedResults >= 0 && expectedResults != l.size())
    267       {
    268         throw new BaseException("Expected "+expectedResults+" results, not "+l.size());
    269       }
    270       write("--List platform variants OK ("+l.size()+")");
    271     }
    272     catch (Throwable ex)
    273     {
    274       write("--List platform variants FAILED");
    275       ex.printStackTrace();
    276       ok = false;
    277     }
    278     finally
    279     {
    280       if (dc != null) dc.close();
    281     }
    282   }
    283 
    284   static void test_delete_variant(int variantId)
    285   {
    286     if (variantId == 0) return;
    287     DbControl dc = null;
    288     try
    289     {
    290       dc = TestUtil.getDbControl();
    291       PlatformVariant v = PlatformVariant.getById(dc, variantId);
    292       dc.deleteItem(v);
    293       dc.commit();
    294       write("--Delete platform variant OK");
    295     }
    296     catch (Throwable ex)
    297     {
    298       write("--Delete platform variant FAILED");
    299       ex.printStackTrace();
    300       ok = false;
    301     }
    302     finally
    303     {
    304       if (dc != null) dc.close();
    305     }
     212      DataFileType type = DataFileType.getByExternalId(dc, externalId);
     213      id = type.getId();
     214      write("--Get data file type (" + externalId + ") OK");
     215    }
     216    catch (Throwable ex)
     217    {
     218      write("--Get data file type (" + externalId + ") FAILED");
     219      ex.printStackTrace();
     220      ok = false;
     221    }
     222    finally
     223    {
     224      if (dc != null) dc.close();
     225    }
     226    return id;   
    306227  }
    307228
  • branches/filedb/src/test/TestPlatform.java

    r3793 r3797  
    5454    write_header();
    5555    // Standard tests: create, load and list
    56     test_load(SystemItems.getId(Platform.AFFYMETRIX));
    57    
     56
    5857    int id1 = test_create("Db and file", "test.db.and.file", false, 0, null);
    5958    int id2 = test_create("File-only", "test.file.only", true, 1, null);
     
    7069    // File types
    7170    int fileTypeId = TestDataFileType.test_create("test.datafile", "test.datafile", Item.RAWBIOASSAY, SystemItems.getId(FileType.RAW_DATA));
    72     test_add_filetype(id2, 0, SystemItems.getId("affymetrix.cel"), true);
    73     test_add_filetype(id2, idVariant2, SystemItems.getId("affymetrix.cdf"), false);
     71    int celId = TestDataFileType.get_id_for_external("affymetrix.cel");
     72    int cdfId = TestDataFileType.get_id_for_external("affymetrix.cdf");
     73    test_add_filetype(id2, 0, celId, true);
     74    test_add_filetype(id2, idVariant2, cdfId, false);
    7475    test_add_filetype(id2, idVariant2b, fileTypeId, false);
    7576    test_list_filetypes(id2, 0, false, 3);
     
    199200    if (!TestUtil.getSilent())
    200201    {
    201       write("   \tID \tName      \tDescription\tSystem ID\tFile only\tRaw data type");
     202      write("   \tID \tName      \tDescription\tExternal ID\tFile only\tRaw data type");
    202203      write("-- \t-- \t--------- \t-----------\t---------\t---------\t-------------");
    203204    }
     
    210211    {
    211212      System.out.println(i+":\t"+p.getId()+"\t"+p.getName()+"\t"+
    212           p.getDescription() + "\t" + p.getSystemId() + "\t" + p.isFileOnly() + "\t" +
     213          p.getDescription() + "\t" + p.getExternalId() + "\t" + p.isFileOnly() + "\t" +
    213214          p.getRawDataType());
    214215    }
     
    221222    {
    222223      System.out.println(i+":\t"+v.getId()+"\t"+v.getName()+"\t"+
    223           v.getDescription() + "\t" + v.getSystemId() + "\t" + v.isFileOnly() + "\t" +
     224          v.getDescription() + "\t" + v.getExternalId() + "\t" + v.isFileOnly() + "\t" +
    224225          v.getRawDataType() + "\t" + v.getPlatform());
    225226    }
  • branches/filedb/src/test/TestRawBioAssay.java

    r3793 r3797  
    109109    {
    110110      dc = TestUtil.getDbControl();
    111       Platform platform = Platform.getById(dc, SystemItems.getId(platformId));
     111      Platform platform = Platform.getByExternalId(dc, platformId);
    112112      RawBioAssay rba = RawBioAssay.getNew(dc, platform, RawDataTypes.getRawDataType(rawDataType));
    113113      if (setAll)
     
    536536      dc = TestUtil.getDbControl();
    537537      RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId);
    538       DataFileType type = DataFileType.getById(dc, SystemItems.getId(fileType));
     538      DataFileType type = DataFileType.getByExternalId(dc, fileType);
    539539      File file = File.getById(dc, fileId);
    540540      rba.getFileSet().setMember(file, type);
Note: See TracChangeset for help on using the changeset viewer.