Changeset 3764


Ignore:
Timestamp:
Sep 21, 2007, 2:51:18 PM (14 years ago)
Author:
Nicklas Nordborg
Message:

References #721. Added data layer classes and some core classes.

Location:
branches/filedb/src
Files:
10 added
7 edited

Legend:

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

    r3741 r3764  
    27652765  </query>
    27662766
     2767  <query id="GET_RAWBIOASSAYS_FOR_PLATFORM" type="HQL">
     2768    <sql>
     2769      SELECT {1}
     2770      FROM RawBioAssayData rba
     2771      WHERE rba.platform = :platform
     2772    </sql>
     2773    <description>
     2774      A Hibernate query that gets raw bioassays
     2775      with a given platform.
     2776    </description>
     2777  </query>
     2778
     2779  <query id="GET_ARRAYDESIGNS_FOR_PLATFORM" type="HQL">
     2780    <sql>
     2781      SELECT {1}
     2782      FROM ArrayDesignData ad
     2783      WHERE ad.platform = :platform
     2784    </sql>
     2785    <description>
     2786      A Hibernate query that gets array designs
     2787      with a given platform.
     2788    </description>
     2789  </query>
     2790 
     2791  <query id="GET_RAWBIOASSAYS_FOR_VARIANT" type="HQL">
     2792    <sql>
     2793      SELECT {1}
     2794      FROM RawBioAssayData rba
     2795      WHERE rba.variant = :variant
     2796    </sql>
     2797    <description>
     2798      A Hibernate query that gets raw bioassays
     2799      with a given platform variant.
     2800    </description>
     2801  </query>
     2802
     2803  <query id="GET_ARRAYDESIGNS_FOR_VARIANT" type="HQL">
     2804    <sql>
     2805      SELECT {1}
     2806      FROM ArrayDesignData ad
     2807      WHERE ad.variant = :variant
     2808    </sql>
     2809    <description>
     2810      A Hibernate query that gets array designs
     2811      with a given platform variant.
     2812    </description>
     2813  </query>
     2814 
     2815  <query id="GET_PLATFORM_FOR_SYSTEM_ID" type="HQL">
     2816    <sql>
     2817      SELECT plf
     2818      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_FILESETMEMBERTYPE_FOR_SYSTEM_ID" type="HQL">
     2827    <sql>
     2828      SELECT fsmt
     2829      FROM FileSetMemberTypeData fsmt
     2830      WHERE fsmt.systemId = :systemId
     2831    </sql>
     2832    <description>
     2833      A Hibernate query that loads a file set member type by system ID.
     2834    </description>
     2835  </query>
     2836
    27672837</predefined-queries>
  • branches/filedb/src/core/net/sf/basedb/core/Install.java

    r3741 r3764  
    2828import net.sf.basedb.core.data.ColoringData;
    2929import net.sf.basedb.core.data.DirectoryData;
     30import net.sf.basedb.core.data.FileSetMemberTypeData;
    3031import net.sf.basedb.core.data.FileTypeData;
    3132import net.sf.basedb.core.data.FormulaData;
     
    3334import net.sf.basedb.core.data.HardwareTypeData;
    3435import net.sf.basedb.core.data.MimeTypeData;
     36import net.sf.basedb.core.data.PlatformData;
     37import net.sf.basedb.core.data.PlatformFileTypeData;
    3538import net.sf.basedb.core.data.PluginConfigurationData;
    3639import net.sf.basedb.core.data.ProtocolTypeData;
     
    162165    throws BaseException
    163166  {
    164     final int total_progress_steps = 24;
     167    final int total_progress_steps = 26;
    165168    final float progress_factor = 100 / total_progress_steps;
    166169    if (progress != null) progress.display(0, "Initialising database...");
     
    323326      createRoleKey(Item.SOFTWARETYPE, "Software types", "Gives access to software types", all_use_administrators_write);
    324327      createRoleKey(Item.SOFTWARE, "Software", "Gives access to software", power_users_create);
    325  
     328     
     329      // Platforms, platform variants, platform file types
     330      createRoleKey(Item.PLATFORM, "Platforms", "Gives access to platforms", guests_use_administrators_all);
     331      createRoleKey(Item.PLATFORMVARIANT, "Platform variants", "Gives access to platform variants", guests_use_administrators_all);
     332      createRoleKey(Item.FILESETMEMBERTYPE, "Data file types", "Gives access to data file types", guests_use_administrators_all);
     333
    326334      // Annotations
    327335      createRoleKey(Item.ANNOTATIONTYPE, "Annotation types", "Gives access to annotation types", power_users_create);
     
    667675      if (progress != null) progress.display((int)(24*progress_factor), "--Creating job agents...");
    668676      // TODO
     677     
     678      // File set member types
     679      if (progress != null) progress.display((int)(25*progress_factor), "--Creating data file types...");
     680      FileSetMemberTypeData celFile = createFileSetMemberType(
     681        "affymetric.cel", "CEL file", "Affymetrix CEL file",
     682        Item.RAWBIOASSAY, "cel", rawDataType, true,
     683        "todo", "todo");
     684      FileSetMemberTypeData cdfFile = createFileSetMemberType(
     685        "affymetric.cdf", "CDF file", "Affymetrix CDF file",
     686        Item.ARRAYDESIGN, "cdf", reporterMapType, true,
     687        "todo", "todo");
     688     
     689      // Platforms and variants
     690      if (progress != null) progress.display((int)(26*progress_factor), "--Creating platforms...");
     691      createPlatform("generic", "Generic", "Generic platform which expects data to be imported into the database",
     692        false, null, 0);
     693      createPlatform("affymetrix", "Affymetrix", "Affymetrix platform",
     694        true, null, 1, celFile, cdfFile);
    669695     
    670696      if (progress != null) progress.display(100, "Database initialised successfully.");
     
    21562182    }
    21572183    return formula;
     2184  }
     2185 
     2186  /**
     2187    Create a {@link Platform}.
     2188  */
     2189  private static PlatformData createPlatform(String systemId, String name, String description,
     2190    boolean fileOnly, String rawDataType, int channels, FileSetMemberTypeData... fileTypes)
     2191    throws BaseException
     2192  {
     2193    org.hibernate.Transaction tx = null;
     2194    PlatformData platform = null;
     2195    try
     2196    {
     2197      tx = HibernateUtil.newTransaction(session);
     2198   
     2199      if (platform == null)
     2200      {
     2201        org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, "GET_PLATFORM_FOR_SYSTEM_ID");
     2202        query.setString("systemId", systemId);
     2203        platform = HibernateUtil.loadData(PlatformData.class, query);
     2204      }
     2205     
     2206      if (platform != null)
     2207      {
     2208        log.info("createPlatform: EXISTS [systemId="+systemId+"]");
     2209        HibernateUtil.commit(tx);
     2210      }
     2211      else
     2212      {
     2213        platform = new PlatformData();
     2214        platform.setSystemId(systemId);
     2215        platform.setName(name);
     2216        platform.setDescription(description);
     2217        platform.setFileOnly(fileOnly);
     2218        if (fileOnly)
     2219        {
     2220          platform.setChannels(channels);
     2221        }
     2222        else
     2223        {
     2224          platform.setRawDataType(rawDataType);
     2225        }
     2226        HibernateUtil.saveData(session, platform);
     2227 
     2228        if (fileTypes != null)
     2229        {
     2230          for (FileSetMemberTypeData fileType : fileTypes)
     2231          {
     2232            PlatformFileTypeData platformFile = new PlatformFileTypeData();
     2233            platformFile.setFileType(fileType);
     2234            platformFile.setPlatform(platform);
     2235            HibernateUtil.saveData(session, platformFile);
     2236          }
     2237        }
     2238       
     2239        HibernateUtil.commit(tx);
     2240        log.info("createPlatform: OK [systemId="+systemId+"]");
     2241      }
     2242    }
     2243    catch (BaseException ex)
     2244    {
     2245      if(tx != null) HibernateUtil.rollback(tx);
     2246      log.error("createPlatform: FAILED [systemId="+systemId+"]", ex);
     2247      throw ex;
     2248    }
     2249    return platform;
     2250  }
     2251
     2252  /**
     2253    Create a {@link FileSetMemberType}.
     2254  */
     2255  private static FileSetMemberTypeData createFileSetMemberType(
     2256    String systemId, String name, String description,
     2257    Item itemType, String extension, FileTypeData genericType, boolean required,
     2258    String validatorClass, String metadataReaderClass)
     2259    throws BaseException
     2260  {
     2261    org.hibernate.Transaction tx = null;
     2262    FileSetMemberTypeData fileType = null;
     2263    try
     2264    {
     2265      tx = HibernateUtil.newTransaction(session);
     2266   
     2267      if (fileType == null)
     2268      {
     2269        org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     2270          "GET_FILESETMEMBERTYPE_FOR_SYSTEM_ID");
     2271        query.setString("systemId", systemId);
     2272        fileType = HibernateUtil.loadData(FileSetMemberTypeData.class, query);
     2273      }
     2274     
     2275      if (fileType != null)
     2276      {
     2277        log.info("createFileSetMemberType: EXISTS [systemId="+systemId+"]");
     2278        HibernateUtil.commit(tx);
     2279      }
     2280      else
     2281      {
     2282        fileType = new FileSetMemberTypeData();
     2283        fileType.setSystemId(systemId);
     2284        fileType.setName(name);
     2285        fileType.setDescription(description);
     2286        fileType.setItemType(itemType.getValue());
     2287        fileType.setExtension(extension);
     2288        fileType.setGenericType(genericType);
     2289        fileType.setRequired(required);
     2290        fileType.setValidatorClass(validatorClass);
     2291        fileType.setMetadataReaderClass(metadataReaderClass);
     2292 
     2293        HibernateUtil.saveData(session, fileType);
     2294        HibernateUtil.commit(tx);
     2295        log.info("createFileSetMemberType: OK [systemId="+systemId+"]");
     2296      }
     2297    }
     2298    catch (BaseException ex)
     2299    {
     2300      if(tx != null) HibernateUtil.rollback(tx);
     2301      log.error("createFileSetMemberType: FAILED [systemId="+systemId+"]", ex);
     2302      throw ex;
     2303    }
     2304    return fileType;
    21582305  }
     2306 
    21592307}
  • branches/filedb/src/core/net/sf/basedb/core/Item.java

    r3679 r3764  
    496496  */
    497497  DATACUBEEXTRAVALUE(326, "Data cube extra value", "dev", DataCubeExtraValue.class, DataCubeExtraValueData.class, null,
    498     250);
     498    250),
     499   
     500  /**
     501    The item is a {@link Platform}
     502  */
     503  PLATFORM(350, "Platform", "plf", Platform.class, PlatformData.class, null,
     504    970),
     505   
     506  /**
     507    The item is a {@link PlatformVariant}
     508  */
     509  PLATFORMVARIANT(351, "Platform variant", "plv", PlatformVariant.class, PlatformVariantData.class, null,
     510    965),
     511   
     512  /**
     513    The item is a {@link PlatformFileType}
     514  */
     515  PLATFORMFILETYPE(352, "Platform file type", "pft", null, PlatformFileTypeData.class, null,
     516    960),
     517   
     518  /**
     519    The item is a {@link FileSet}
     520  */
     521  FILESET(353, "File set", "fs", null, FileSetData.class, null,
     522    950),
     523
     524  /**
     525    The item is a {@link FileSetMember}
     526  */
     527  FILESETMEMBER(354, "File set member", "fsm", null, FileSetMemberData.class, null,
     528    955),
     529   
     530  /**
     531    The item is a {@link FileSetMemberType}
     532  */
     533  FILESETMEMBERTYPE(355, "File set member type", "fsmt", null, FileSetMemberTypeData.class, null,
     534    980),
     535   
     536    ;
    499537
    500538  static int MAX_VALUE = 0;
  • branches/filedb/src/core/net/sf/basedb/core/SystemItem.java

    r3679 r3764  
    2424*/
    2525package net.sf.basedb.core;
     26
     27import net.sf.basedb.core.data.PlatformData;
    2628
    2729/**
     
    5658{
    5759  /**
     60    The maximum length of the system ID that can be stored in the database.
     61    @see #getSystemId()
     62  */
     63  public static final int MAX_SYSTEM_ID_LENGTH =
     64    PlatformData.MAX_SYSTEM_ID_LENGTH;
     65 
     66 
     67  /**
    5868    Get the system id for the item.
    5969    @return The id of the item or null if it is not a system item
  • branches/filedb/src/core/net/sf/basedb/core/data/ArrayDesignData.java

    r3741 r3764  
    4040public class ArrayDesignData
    4141  extends AnnotatedData
     42  implements FileStoreEnabledData
    4243{
    4344  public ArrayDesignData()
    4445  {}
    4546
     47  /*
     48    From the FileStoreEnabledData interface
     49    -------------------------------------------
     50  */
     51  private FileSetData fileSet;
     52  public FileSetData getFileSet()
     53  {
     54     return fileSet;
     55  }
     56  public void setFileSet(FileSetData fileSet)
     57  {
     58     this.fileSet = fileSet;
     59  }
     60  // -------------------------------------------
     61 
     62  private PlatformData platform;
     63  /**
     64    Get the platform this raw bioassay uses
     65    @since 2.5
     66    @hibernate.many-to-one outer-join="false" update="false"
     67    @hibernate.column name="`platform_id`" not-null="true"
     68  */
     69  public PlatformData getPlatform()
     70  {
     71    return platform;
     72  }
     73  public void setPlatform(PlatformData platform)
     74  {
     75    this.platform = platform;
     76  }
     77 
     78  private PlatformVariantData variant;
     79  /**
     80    Get the platform variant this raw bioassay uses, or null.
     81    @since 2.5
     82    @hibernate.many-to-one outer-join="false" update="false"
     83    @hibernate.column name="`variant_id`"
     84  */
     85  public PlatformVariantData getVariant()
     86  {
     87    return variant;
     88  }
     89  public void setVariant(PlatformVariantData variant)
     90  {
     91    this.variant = variant;
     92  }
     93 
    4694  private boolean affyChip;
    4795  /**
    4896    Check if this design is an Affymetrix chip.
    4997    @hibernate.property column="`affy_chip`" type="boolean" not-null="true" update="false"
     98    @deprecated Has been replaced by platform
    5099  */
    51100  public boolean isAffyChip()
     
    53102    return affyChip;
    54103  }
     104  /**
     105    @deprecated Has been replaced by platform
     106  */
    55107  public void setAffyChip(boolean affyChip)
    56108  {
  • branches/filedb/src/core/net/sf/basedb/core/data/RawBioAssayData.java

    r3679 r3764  
    4343public class RawBioAssayData
    4444  extends AnnotatedData
    45   implements DiskConsumableData
     45  implements DiskConsumableData, FileStoreEnabledData
    4646{
    4747
     
    6464  }
    6565  // -------------------------------------------
    66 
     66  /*
     67    From the FileStoreEnabledData interface
     68    -------------------------------------------
     69  */
     70  private FileSetData fileSet;
     71  public FileSetData getFileSet()
     72  {
     73     return fileSet;
     74  }
     75  public void setFileSet(FileSetData fileSet)
     76  {
     77     this.fileSet = fileSet;
     78  }
     79  // -------------------------------------------
     80 
     81  private PlatformData platform;
     82  /**
     83    Get the platform this raw bioassay uses
     84    @since 2.5
     85    @hibernate.many-to-one outer-join="false" update="false"
     86    @hibernate.column name="`platform_id`" not-null="true"
     87  */
     88  public PlatformData getPlatform()
     89  {
     90    return platform;
     91  }
     92  public void setPlatform(PlatformData platform)
     93  {
     94    this.platform = platform;
     95  }
     96 
     97  private PlatformVariantData variant;
     98  /**
     99    Get the platform variant this raw bioassay uses, or null.
     100    @since 2.5
     101    @hibernate.many-to-one outer-join="false" update="false"
     102    @hibernate.column name="`variant_id`"
     103  */
     104  public PlatformVariantData getVariant()
     105  {
     106    return variant;
     107  }
     108  public void setVariant(PlatformVariantData variant)
     109  {
     110    this.variant = variant;
     111  }
     112 
    67113  private ScanData scan;
    68114  /**
  • branches/filedb/src/core/net/sf/basedb/core/data/SystemData.java

    r3679 r3764  
    6565  extends IdentifiableData
    6666{
     67
     68  /**
     69    The maximum length of the system ID of the item that can be
     70    stored in the database.
     71    @see #getSystemId()
     72    @since 2.5
     73  */
     74  public static int MAX_SYSTEM_ID_LENGTH = 255;
     75   
    6776  /**
    6877    Get the system id for the item.
Note: See TracChangeset for help on using the changeset viewer.