Changeset 3793


Ignore:
Timestamp:
Sep 27, 2007, 1:38:19 PM (15 years ago)
Author:
Nicklas Nordborg
Message:

References #721: Many core classes in place. Work has started on the web interface
for registering data file types and platforms.

Location:
branches/filedb
Files:
18 added
25 edited
3 moved

Legend:

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

    r3764 r3793  
    28242824  </query>
    28252825 
    2826   <query id="GET_FILESETMEMBERTYPE_FOR_SYSTEM_ID" type="HQL">
    2827     <sql>
    2828       SELECT fsmt
    2829       FROM FileSetMemberTypeData fsmt
    2830       WHERE fsmt.systemId = :systemId
     2826  <query id="GET_DATAFILETYPE_FOR_SYSTEM_ID" type="HQL">
     2827    <sql>
     2828      SELECT dft
     2829      FROM DataFileTypeData dft
     2830      WHERE dft.systemId = :systemId
    28312831    </sql>
    28322832    <description>
     
    28352835  </query>
    28362836
     2837  <query id="GET_FILESETMEMBERS_FOR_DATAFILETYPE" type="HQL">
     2838    <sql>
     2839      SELECT {1}
     2840      FROM FileSetMemberData mbr
     2841      WHERE mbr.dataFileType = :dataFileType
     2842    </sql>
     2843    <description>
     2844      A Hibernate query that gets file set members of a specific
     2845      data file type.
     2846    </description>
     2847  </query>
     2848
     2849
    28372850</predefined-queries>
  • branches/filedb/src/core/net/sf/basedb/core/DataFileType.java

    r3783 r3793  
    2626import java.util.Set;
    2727
    28 import net.sf.basedb.core.data.FileSetMemberTypeData;
     28import net.sf.basedb.core.data.DataFileTypeData;
     29import net.sf.basedb.core.filehandler.DataFileMetadataReader;
     30import net.sf.basedb.core.filehandler.DataFileValidator;
     31import net.sf.basedb.core.query.Hql;
     32import net.sf.basedb.core.query.Restrictions;
     33import net.sf.basedb.util.ClassUtil;
    2934
    3035/**
    31   This class is used to represent a type file that is used to
     36  This class is used to represent a type of file that is used to
    3237  hold data instead of importing it into the database.
    3338
     
    3641  @base.modified $Date$
    3742*/
    38 public class FileSetMemberType
    39   extends BasicItem<FileSetMemberTypeData>
     43public class DataFileType
     44  extends BasicItem<DataFileTypeData>
    4045  implements Nameable, Removable, SystemItem
    4146{
     
    4348  /**
    4449    The type of item represented by this class.
    45     @see Item#FILESETMEMBERTYPE
     50    @see Item#DATAFILETYPE
    4651    @see #getType()
    4752  */
    48   public static final Item TYPE = Item.FILESETMEMBERTYPE;
    49 
    50  
    51   /**
    52     Create a new file set member type.
     53  public static final Item TYPE = Item.DATAFILETYPE;
     54
     55  /**
     56    The maximum length of the file extension that can be stored in the database.
     57    @see #setExtension(String)
     58  */
     59  public static final int MAX_EXTENSION_LENGTH = DataFileTypeData.MAX_EXTENSION_LENGTH;
     60
     61  /**
     62    The maximum length of the class names that can be stored in the database.
     63    @see #setValidatorClass(String)
     64    @see #setMetadataReaderClass(String)
     65  */
     66  public static final int MAX_CLASSNAME_LENGTH = DataFileTypeData.MAX_CLASSNAME_LENGTH;
     67
     68  /**
     69    Create a new data file type.
    5370   
    5471    @param dc The DbControl to use for database access
    5572    @param systemId The system ID of the new type, must be
    5673      unique for all file types
     74    @param itemType The type of item that files of this type can
     75      be attached to. The item must implement the {@link FileStoreEnabled}
     76      interface
    5777    @return The new file set member type object
    5878  */
    59   public static FileSetMemberType getNew(DbControl dc, String systemId)
    60   {
    61     FileSetMemberType type = dc.newItem(FileSetMemberType.class);
     79  public static DataFileType getNew(DbControl dc, String systemId, Item itemType)
     80  {
     81    DataFileType type = dc.newItem(DataFileType.class);
    6282    type.setSystemId(systemId);
    63     type.setName("New file type");
     83    type.setName("New data file type");
     84    type.setItemType(itemType);
    6485    return type;
    6586  }
    6687
    6788  /**
    68     Get a <code>FileSetMemberType</code> object when you know the ID.
     89    Get a <code>DataFileType</code> object when you know the ID.
    6990
    7091    @param dc The <code>DbControl</code> which will be used for
    7192      permission checking and database access.
    7293    @param id The ID of the item to load
    73     @return The <code>FileSetMemberType</code> item
     94    @return The <code>DataFileType</code> item
    7495    @throws ItemNotFoundException If an item with the specified ID is not found
    7596    @throws PermissionDeniedException If the logged in user doesn't have
     
    7798    @throws BaseException If there is another error
    7899  */
    79   public static FileSetMemberType getById(DbControl dc, int id)
     100  public static DataFileType getById(DbControl dc, int id)
    80101    throws ItemNotFoundException, PermissionDeniedException, BaseException
    81102  {
    82     FileSetMemberType type = dc.loadItem(FileSetMemberType.class, id);
    83     if (type == null) throw new ItemNotFoundException("FileSetMemberType[id="+id+"]");
     103    DataFileType type = dc.loadItem(DataFileType.class, id);
     104    if (type == null) throw new ItemNotFoundException("DataFileType[id="+id+"]");
    84105    return type;
    85106  }
    86107 
    87108  /**
    88     Get a query configured to retrieve <code>FileSetMemberType</code> items.
     109    Get a query configured to retrieve <code>DataFileType</code> items.
    89110    @return An {@link ItemQuery} object
    90111  */
    91   public static ItemQuery<FileSetMemberType> getQuery()
     112  public static ItemQuery<DataFileType> getQuery()
    92113    throws BaseException
    93114  {
    94     return new ItemQuery<FileSetMemberType>(FileSetMemberType.class);
     115    return new ItemQuery<DataFileType>(DataFileType.class);
    95116  }
    96117
     
    100121    @param data the data.
    101122  */
    102   FileSetMemberType(FileSetMemberTypeData data)
     123  DataFileType(DataFileTypeData data)
    103124  {
    104125    super(data);
     
    183204    org.hibernate.Session session = getDbControl().getHibernateSession();
    184205    org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
    185       "TODO", "count(*)");
     206      "GET_FILESETMEMBERS_FOR_DATAFILETYPE", "count(*)");
    186207    /*
    187208      SELECT {1}
    188       FROM RawBioAssayData rba
    189       WHERE rba.platform = :platform
     209      FROM FileSetMemberData mbr
     210      WHERE mbr.dataFileType = :dataFileType
    190211    */
    191     query.setEntity("fileType", this.getData());
     212    query.setEntity("dataFileType", this.getData());
    192213    long count = HibernateUtil.loadData(Long.class, query);
    193214    return count > 0 || super.isUsed();
     
    196217    Get all:
    197218    <ul>
    198     <li>{@link FileSetMember}:s and using this file type
     219    <li>{@link FileSetMember}:s using this file type
    199220    <ul>
    200221  */
     
    205226    org.hibernate.Session session = getDbControl().getHibernateSession();
    206227    org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
    207       "TODO", "rba.id");
     228      "GET_FILESETMEMBERS_FOR_DATAFILETYPE", "mbr.id");
    208229      /*
    209230        SELECT {1}
    210         FROM RawBioAssayData rba
    211         WHERE rba.platform = :platform
     231        FROM FileSetMemberData mbr
     232        WHERE mbr.dataFileType = :dataFileType
    212233      */
    213     query.setEntity("fileType", this.getData());
     234    query.setEntity("dataFileType", this.getData());
    214235    addUsingItems(using, Item.FILESETMEMBER, query);
    215236    return using;
     
    226247  }
    227248 
    228 
     249  /**
     250    Get the generic file type for this data file type.
     251    @return A <code>FileType</code> item
     252  */
     253  public FileType getGenericType()
     254  {
     255    return getDbControl().getItem(FileType.class, getData().getGenericType());
     256  }
     257 
     258  /**
     259    Set the generic file type of this item. Null is not allowed.
     260    @param genericType The generic type
     261    @throws PermissionDeniedException If the logged in user doesn't
     262      have write permission
     263  */
     264  public void setGenericType(FileType genericType)
     265  {
     266    checkPermission(Permission.WRITE);
     267    getData().setGenericType(genericType == null ? null : genericType.getData());
     268  }
     269 
     270  /**
     271    Get the common file extension for data files of this type.
     272    @return A string or null if there is no common file extension
     273  */
     274  public String getExtension()
     275  {
     276    return getData().getExtension();
     277  }
     278
     279  /**
     280    Set the most common gile extension for data file of this
     281    type.
     282    @param extension The extension or null
     283    @throws PermissionDeniedException If the logged in user doesn't
     284      have write permission
     285    @throws StringTooLongException If the string is longer that {@link #MAX_EXTENSION_LENGTH}.
     286  */
     287  public void setExtension(String extension)
     288  {
     289    checkPermission(Permission.WRITE);
     290    getData().setExtension(StringUtil.setNullableString(extension, "extension", MAX_EXTENSION_LENGTH));
     291  }
     292
     293  private void setItemType(Item itemType)
     294  {
     295    if (itemType == null) throw new InvalidUseOfNullException("itemType");
     296    if (!FileStoreEnabled.class.isAssignableFrom(itemType.getItemClass()))
     297    {
     298      throw new InvalidDataException(itemType + " isn't a subclass of FileStoreEnabled");
     299    }
     300    getData().setItemType(itemType.getValue());
     301  }
     302 
     303  /**
     304    Get the type of item files of this type can be used on. The
     305    item should implement the {@link FileStoreEnabled} interface.
     306    @return An <code>Item</code> object
     307  */
     308  public Item getItemType()
     309  {
     310    return Item.fromValue(getData().getItemType());
     311  }
     312 
     313  /**
     314    Get the class name of the Java class that is used to validate the files of
     315    this type. The class must implement the {@link DataFileValidator} interface.
     316    @return A class name or null if no validator exists
     317  */
     318  public String getValidatorClass()
     319  {
     320    return getData().getValidatorClass();
     321  }
     322 
     323  /**
     324    Set the class name of the Java class that is used to validate the files of
     325    this type. The class must implement the {@link DataFileValidator} interface.
     326    @param validatorClass The name of the class or null to disable validation
     327    @throws PermissionDeniedException If the logged in user doesn't
     328      have write permission
     329    @throws StringTooLongException If the string is longer that {@link #MAX_CLASSNAME_LENGTH}.
     330    @throws InvalidDataException If the named class isn't found or
     331      doesn't implement the <code>DataFileValidator</code> interface.
     332  */
     333  public void setValidatorClass(String validatorClass)
     334  {
     335    checkPermission(Permission.WRITE);
     336    if (validatorClass != null)
     337    {
     338      try
     339      {
     340        ClassUtil.checkAndLoadClass(null, validatorClass, true, DataFileValidator.class);
     341      }
     342      catch (Throwable t)
     343      {
     344        throw new InvalidDataException(t);
     345      }
     346    }
     347    getData().setValidatorClass(StringUtil.setNullableString(validatorClass, "validatorClass", MAX_EXTENSION_LENGTH));
     348  }
     349 
     350  /**
     351    Get the class name of the Java class that is used to extract metadata from files of
     352    this type. The class must implement the {@link DataFileMetadataReader} interface.
     353    @return A class name or null if no validator exists
     354  */
     355  public String getMetadataReaderClass()
     356  {
     357    return getData().getMetadataReaderClass();
     358  }
     359 
     360  /**
     361    Set the class name of the Java class that is used to extract metadata from files of
     362    this type. The class must implement the {@link DataFileMetadataReader} interface.
     363    @param metadataReaderClass The name of the class or null to disable validation
     364    @throws PermissionDeniedException If the logged in user doesn't
     365      have write permission
     366    @throws StringTooLongException If the string is longer that {@link #MAX_CLASSNAME_LENGTH}.
     367    @throws InvalidDataException If the named class isn't found or doesn't
     368      implement the <code>DataFileMetadataReader</code> interface
     369  */
     370  public void setMetadataReaderClass(String metadataReaderClass)
     371  {
     372    checkPermission(Permission.WRITE);
     373    if (metadataReaderClass != null)
     374    {
     375      try
     376      {
     377        ClassUtil.checkAndLoadClass(null, metadataReaderClass, true, DataFileMetadataReader.class);
     378      }
     379      catch (Throwable t)
     380      {
     381        throw new InvalidDataException(t);
     382      }
     383    }
     384    getData().setMetadataReaderClass(StringUtil.setNullableString(metadataReaderClass,
     385      "metadataReaderClass", MAX_EXTENSION_LENGTH));
     386  }
     387 
     388  /**
     389    Get a query that returns all platforms/variants that are using this
     390    file type.
     391    @return A query object
     392  */
     393  public ItemQuery<PlatformFileType> getPlatforms()
     394  {
     395    ItemQuery<PlatformFileType> query = PlatformFileType.getQuery(null, null, false);
     396    query.restrictPermanent(
     397      Restrictions.eq(
     398        Hql.property("dataFileType"),
     399        Hql.entity(this)
     400      )
     401    );
     402    return query;
     403  }
     404 
    229405}
  • branches/filedb/src/core/net/sf/basedb/core/FileSet.java

    r3783 r3793  
    2424package net.sf.basedb.core;
    2525
     26import java.util.HashSet;
    2627import java.util.Map;
    2728import java.util.Set;
    2829
    2930import net.sf.basedb.core.query.EntityQuery;
     31import net.sf.basedb.core.query.Expressions;
     32import net.sf.basedb.core.query.Hql;
     33import net.sf.basedb.core.query.Restrictions;
    3034
    3135import net.sf.basedb.core.data.FileSetData;
    3236import net.sf.basedb.core.data.FileSetMemberData;
    33 import net.sf.basedb.core.data.FileSetMemberTypeData;
     37import net.sf.basedb.core.data.DataFileTypeData;
    3438
    3539/**
     
    257261      file
    258262  */
    259   public void setMember(File file, FileSetMemberType type)
     263  public void setMember(File file, DataFileType type)
    260264  {
    261265    checkPermission(Permission.WRITE);
     
    264268    file.checkPermission(Permission.USE);
    265269   
    266     Map<FileSetMemberTypeData, FileSetMemberData> members = getData().getMembers();
     270    Map<DataFileTypeData, FileSetMemberData> members = getData().getMembers();
    267271    FileSetMemberData member = members.get(type.getData());
    268272    if (member == null)
     
    274278    else
    275279    {
    276       member.setFile(file.getData());
     280      if (!file.getData().equals(member.getFile()))
     281      {
     282        member.setFile(file.getData());
     283        member.setValid(null);
     284      }
    277285    }
    278286  }
     
    280288  /**
    281289    Check if the file set contains a file of the specified type.
    282     @param type A <code>FileSetMemberType</code> object
     290    @param type A <code>DataFileType</code> object
    283291    @return TRUE if the file set contains a file of
    284292      the specified type, FALSE otherwise
    285293  */
    286   public boolean hasMember(FileSetMemberType type)
     294  public boolean hasMember(DataFileType type)
    287295  {
    288296    if (type == null) return false;
     
    292300  /**
    293301    Get the member of the given type.
    294     @param type A <code>FileSetMemberType</code> object
     302    @param type A <code>DataFileType</code> object
    295303    @return A FileSetMember object or null if no member
    296304      of the specified type exists
    297305  */
    298   public FileSetMember getMember(FileSetMemberType type)
     306  public FileSetMember getMember(DataFileType type)
    299307  {
    300308    if (type == null) return null;
     
    306314  /**
    307315    Remove the member of the given type.
    308     @param type A <code>FileSetMemberType</code> object
     316    @param type A <code>DataFileType</code> object
    309317    @throws InvalidUseOfNullException If type is null
    310318    @throws PermissionDeniedException If the logged in user
    311319      doesn't have write permission for this file set
    312320   */
    313   public void removeMember(FileSetMemberType type)
     321  public void removeMember(DataFileType type)
    314322  {
    315323    checkPermission(Permission.WRITE);
     
    327335  }
    328336 
     337  /**
     338    Get a query that return the {@link DataFileType} for all members
     339    of this file set.
     340    @return A query object
     341  */
     342  public ItemQuery<DataFileType> getMemberTypes()
     343  {
     344    ItemQuery<DataFileType> query = DataFileType.getQuery();
     345    Set<DataFileTypeData> memberTypes = getData().getMembers().keySet();
     346    Set<Integer> memberIds = new HashSet<Integer>(memberTypes.size());
     347    for (DataFileTypeData member : memberTypes)
     348    {
     349      memberIds.add(member.getId());
     350    }
     351    query.restrictPermanent(
     352      Restrictions.in(
     353        Hql.property("id"),
     354        Expressions.parameter("members")
     355      )
     356    );
     357    query.setPermanentParameter("members", memberIds, null);
     358    return query;
     359  }
     360 
     361  /**
     362    Checks if this file set contains a file for
     363    each {@link DataFileType} that is required according to
     364    what has been specified by the {@link Platform} and
     365    {@link PlatformVariant}.
     366    @return TRUE if all files are present, FALSE otherwise. If the
     367      items has no platform TRUE is always returned
     368    @see PlatformFileType#isRequired()
     369  */
     370  public boolean hasAllRequiredFiles()
     371  {
     372    FileStoreEnabled item = getItem();
     373    Platform platform = item.getPlatform();
     374    PlatformVariant variant = item.getVariant();
     375    if (platform == null) return true;
     376   
     377    ItemQuery<PlatformFileType> query = platform.getFileTypes(variant, variant == null);
     378    query.restrict(
     379      Restrictions.eq(
     380        Hql.property("required"),
     381        Expressions.parameter("isRequired", true, Type.BOOLEAN)
     382      )
     383    );
     384   
     385    Set<DataFileTypeData> memberTypes = getData().getMembers().keySet();
     386    for (PlatformFileType pft : query.list(getDbControl()))
     387    {
     388      if (!memberTypes.contains(pft.getData().getDataFileType()))
     389      {
     390        return false;
     391      }
     392    }
     393    return true;
     394  }
     395 
     396  /**
     397    Get a query that is returning all data file types that
     398    have been
     399    @return A query or null if no platform is associated with this
     400      item
     401  */
     402  public ItemQuery<PlatformFileType> getMissingDataFileTypes()
     403  {
     404    FileStoreEnabled item = getItem();
     405    Platform platform = item.getPlatform();
     406    PlatformVariant variant = item.getVariant();
     407    if (platform == null) return null;
     408
     409    ItemQuery<PlatformFileType> query = platform.getFileTypes(variant, variant == null);
     410    // Get all required platform file types
     411    query.restrict(
     412      Restrictions.eq(
     413        Hql.property("required"),
     414        Expressions.parameter("isRequired", true, Type.BOOLEAN)
     415      )
     416    );
     417
     418    Set<DataFileTypeData> memberTypes = getData().getMembers().keySet();
     419    Set<Integer> memberIds = new HashSet<Integer>(memberTypes.size());
     420    for (DataFileTypeData member : memberTypes)
     421    {
     422      memberIds.add(member.getId());
     423    }
     424    // Ignore all platform file types that we already have
     425    query.restrictPermanent(
     426      Restrictions.not(
     427        Restrictions.in(
     428          Hql.property("dataFileType.id"),
     429          Expressions.parameter("members")
     430        )
     431      )
     432    );
     433    query.setPermanentParameter("members", memberIds, null);
     434    return query;
     435  }
     436 
     437 
    329438 
    330439  private static class QueryRuntimeFilterImpl
  • branches/filedb/src/core/net/sf/basedb/core/FileSetMember.java

    r3783 r3793  
    4949  /**
    5050    Create a new member in a file set.
    51     @see FileSet#setMember(File, FileSetMemberType)
     51    @see FileSet#setMember(File, DataFileType)
    5252  */
    53   static FileSetMember getNew(DbControl dc, FileSet fileSet, File file, FileSetMemberType type)
     53  static FileSetMember getNew(DbControl dc, FileSet fileSet, File file, DataFileType type)
    5454  {
    5555    FileSetMember member = dc.newItem(FileSetMember.class);
     
    5757    data.setFileSet(fileSet.getData());
    5858    data.setFile(file.getData());
    59     data.setFileType(type.getData());
     59    data.setDataFileType(type.getData());
     60    data.setValid(null);
    6061    return member;
    6162  }
     
    147148    @return A file set member type item
    148149  */
    149   public FileSetMemberType getMemberType()
     150  public DataFileType getDataFileType()
    150151  {
    151     return getDbControl().getItem(FileSetMemberType.class, getData().getFileType());
     152    return getDbControl().getItem(DataFileType.class, getData().getDataFileType());
     153  }
     154 
     155  /**
     156    Check if the file has been validated and if it passed or not.
     157    @return NULL if the file hasn't been validated, TRUE or FALSE
     158      to indicate the result of the validation
     159  */
     160  public Boolean isValid()
     161  {
     162    return getData().isValid();
    152163  }
    153164
  • branches/filedb/src/core/net/sf/basedb/core/FileStoreEnabled.java

    r3783 r3793  
    5757  /**
    5858    Get the platform the item is related to. The platform is used to
    59     limit the {@link FileSetMemberType}:s that can be added to the file set.
     59    limit the {@link DataFileType}:s that can be added to the file set.
    6060    @return A platform or null if the items is not related to any platform.
    6161  */
     
    6464  /**
    6565    Get the platform variant the item is related to. The platform is used to
    66     limit the {@link FileSetMemberType}:s that can be added to the file set.
     66    limit the {@link DataFileType}:s that can be added to the file set.
    6767    @return A platform or null if the items is not related to any variant.
    6868  */
  • branches/filedb/src/core/net/sf/basedb/core/Install.java

    r3783 r3793  
    2828import net.sf.basedb.core.data.ColoringData;
    2929import net.sf.basedb.core.data.DirectoryData;
    30 import net.sf.basedb.core.data.FileSetMemberTypeData;
     30import net.sf.basedb.core.data.DataFileTypeData;
    3131import net.sf.basedb.core.data.FileTypeData;
    3232import net.sf.basedb.core.data.FormulaData;
     
    330330      createRoleKey(Item.PLATFORM, "Platforms", "Gives access to platforms", guests_use_administrators_all);
    331331      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);
     332      createRoleKey(Item.DATAFILETYPE, "Data file types", "Gives access to data file types", guests_use_administrators_all);
    333333
    334334      // Annotations
     
    678678      // File set member types
    679679      if (progress != null) progress.display((int)(25*progress_factor), "--Creating data file types...");
    680       FileSetMemberTypeData celFile = createFileSetMemberType(
     680      DataFileTypeData celFile = createDataFileType(
    681681        "affymetrix.cel", "CEL file", "Affymetrix CEL file",
    682         Item.RAWBIOASSAY, "cel", rawDataType, true,
    683         "todo", "todo");
    684       FileSetMemberTypeData cdfFile = createFileSetMemberType(
     682        Item.RAWBIOASSAY, "cel", rawDataType, 
     683        "net.sf.basedb.core.filehandler.CelFileHandler",
     684        "net.sf.basedb.core.filehandler.CelFileHandler");
     685      DataFileTypeData cdfFile = createDataFileType(
    685686        "affymetrix.cdf", "CDF file", "Affymetrix CDF file",
    686         Item.ARRAYDESIGN, "cdf", reporterMapType, true,
    687         "todo", "todo");
     687        Item.ARRAYDESIGN, "cdf", reporterMapType, 
     688        "net.sf.basedb.core.filehandler.CdfFileHandler",
     689        "net.sf.basedb.core.filehandler.CdfFileHandler");
    688690     
    689691      // Platforms and variants
     
    691693      createPlatform("generic", "Generic", "Generic platform which expects data to be imported into the database",
    692694        false, null, 0);
    693       createPlatform("affymetrix", "Affymetrix", "Affymetrix platform",
    694         true, null, 1, celFile, cdfFile);
     695      createPlatform("affymetrix", "Affymetrix", "Affymetrix platform", true, null, 1,
     696        new PlatformFT(celFile, true),
     697        new PlatformFT(cdfFile, true)
     698      );
    695699     
    696700      if (progress != null) progress.display(100, "Database initialised successfully.");
     
    21882192  */
    21892193  private static PlatformData createPlatform(String systemId, String name, String description,
    2190     boolean fileOnly, String rawDataType, int channels, FileSetMemberTypeData... fileTypes)
     2194    boolean fileOnly, String rawDataType, int channels, PlatformFT... fileTypes)
    21912195    throws BaseException
    21922196  {
     
    22282232        if (fileTypes != null)
    22292233        {
    2230           for (FileSetMemberTypeData fileType : fileTypes)
     2234          for (PlatformFT pft : fileTypes)
    22312235          {
    22322236            PlatformFileTypeData platformFile = new PlatformFileTypeData();
    2233             platformFile.setFileType(fileType);
    22342237            platformFile.setPlatform(platform);
     2238            platformFile.setDataFileType(pft.fileType);
     2239            platformFile.setRequired(pft.required);
    22352240            HibernateUtil.saveData(session, platformFile);
    22362241          }
     
    22522257
    22532258  /**
    2254     Create a {@link FileSetMemberType}.
    2255   */
    2256   private static FileSetMemberTypeData createFileSetMemberType(
     2259    Create a {@link DataFileType}.
     2260  */
     2261  private static DataFileTypeData createDataFileType(
    22572262    String systemId, String name, String description,
    2258     Item itemType, String extension, FileTypeData genericType, boolean required,
     2263    Item itemType, String extension, FileTypeData genericType,
    22592264    String validatorClass, String metadataReaderClass)
    22602265    throws BaseException
    22612266  {
    22622267    org.hibernate.Transaction tx = null;
    2263     FileSetMemberTypeData fileType = null;
     2268    DataFileTypeData fileType = null;
    22642269    try
    22652270    {
     
    22692274      {
    22702275        org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
    2271           "GET_FILESETMEMBERTYPE_FOR_SYSTEM_ID");
     2276          "GET_DATAFILETYPE_FOR_SYSTEM_ID");
    22722277        query.setString("systemId", systemId);
    2273         fileType = HibernateUtil.loadData(FileSetMemberTypeData.class, query);
     2278        fileType = HibernateUtil.loadData(DataFileTypeData.class, query);
    22742279      }
    22752280     
    22762281      if (fileType != null)
    22772282      {
    2278         log.info("createFileSetMemberType: EXISTS [systemId="+systemId+"]");
    2279         HibernateUtil.commit(tx);
    2280       }
    2281       else
    2282       {
    2283         fileType = new FileSetMemberTypeData();
     2283        log.info("createDataFileType: EXISTS [systemId="+systemId+"]");
     2284        HibernateUtil.commit(tx);
     2285      }
     2286      else
     2287      {
     2288        fileType = new DataFileTypeData();
    22842289        fileType.setSystemId(systemId);
    22852290        fileType.setName(name);
     
    22882293        fileType.setExtension(extension);
    22892294        fileType.setGenericType(genericType);
    2290         fileType.setRequired(required);
    22912295        fileType.setValidatorClass(validatorClass);
    22922296        fileType.setMetadataReaderClass(metadataReaderClass);
     
    22952299        HibernateUtil.commit(tx);
    22962300        if (systemId != null) SystemItems.add(fileType);
    2297         log.info("createFileSetMemberType: OK [systemId="+systemId+"]");
     2301        log.info("createDataFileType: OK [systemId="+systemId+"]");
    22982302      }
    22992303    }
     
    23012305    {
    23022306      if(tx != null) HibernateUtil.rollback(tx);
    2303       log.error("createFileSetMemberType: FAILED [systemId="+systemId+"]", ex);
     2307      log.error("createDataFileType: FAILED [systemId="+systemId+"]", ex);
    23042308      throw ex;
    23052309    }
     
    23072311  }
    23082312 
     2313  private static class PlatformFT
     2314  {
     2315    private final DataFileTypeData fileType;
     2316    private final boolean required;
     2317   
     2318    private PlatformFT(DataFileTypeData fileType, boolean required)
     2319    {
     2320      this.fileType = fileType;
     2321      this.required = required;
     2322    }
     2323  }
     2324 
    23092325}
  • branches/filedb/src/core/net/sf/basedb/core/Item.java

    r3783 r3793  
    529529   
    530530  /**
    531     The item is a {@link FileSetMemberType}
    532   */
    533   FILESETMEMBERTYPE(355, "File set member type", "fsmt", FileSetMemberType.class, FileSetMemberTypeData.class, null,
     531    The item is a {@link DataFileType}
     532  */
     533  DATAFILETYPE(355, "Data file type", "dft", DataFileType.class, DataFileTypeData.class, null,
    534534    980)
    535535   
  • branches/filedb/src/core/net/sf/basedb/core/Metadata.java

    r3679 r3793  
    5454  private static Set<Item> ownableItems;
    5555  private static Set<Item> diskConsumableItems;
     56  private static Set<Item> fileStoreEnabledItems;
    5657
    5758  private static boolean isInitialised = false;
     
    6566    ownableItems = Collections.unmodifiableSet(getImplementingItems(Ownable.class));
    6667    diskConsumableItems = Collections.unmodifiableSet(getImplementingItems(DiskConsumable.class));
     68    fileStoreEnabledItems = Collections.unmodifiableSet(getImplementingItems(FileStoreEnabled.class));
    6769    isInitialised = true;
    6870  }
     
    7981    ownableItems = null;
    8082    diskConsumableItems = null;
     83    fileStoreEnabledItems = null;
    8184  }
    8285
     
    171174  }
    172175
     176  /**
     177    Get a set containing all {@link FileStoreEnabled} item types.
     178    The set cannot be modified.
     179  */
     180  public static Set<Item> getFileStoreEnabledItems()
     181  {
     182    return fileStoreEnabledItems;
     183  }
     184 
     185 
    173186  /**
    174187    Cache of Metadata instances. Only one instance for each type
  • branches/filedb/src/core/net/sf/basedb/core/Platform.java

    r3783 r3793  
    310310      }
    311311      rdt = rawDataType.getId();
     312      getData().setChannels(rawDataType.getChannels());
    312313    }
    313314    getData().setRawDataType(rdt);
     
    386387    already been registered this method does nothing.
    387388    @param type The file type
     389    @param required If a file of this type is required or not
    388390    @param variant An optional variant
    389391    @throws PermissionDeniedException If the logged in user doesn't
     
    391393    @throws InvalidUseOfNullException If type is null
    392394  */
    393   public void addFileType(FileSetMemberType type, PlatformVariant variant)
     395  public void addFileType(DataFileType type, boolean required, PlatformVariant variant)
    394396  {
    395397    checkPermission(Permission.WRITE);
     
    399401    {
    400402      PlatformFileType platformFileType =
    401         PlatformFileType.getNew(getDbControl(), this, variant, type);
     403        PlatformFileType.getNew(getDbControl(), this, variant, type, required);
    402404      getData().getFileTypes().put(index, platformFileType.getData());
    403405      getDbControl().saveItemIf(this, platformFileType, false);
     
    418420    @throws InvalidUseOfNullException If type is null
    419421  */
    420   public void removeFileType(FileSetMemberType type, PlatformVariant variant)
     422  public void removeFileType(DataFileType type, PlatformVariant variant)
    421423  {
    422424    checkPermission(Permission.WRITE);
  • branches/filedb/src/core/net/sf/basedb/core/PlatformFileType.java

    r3783 r3793  
    2626import net.sf.basedb.core.data.PlatformFileTypeData;
    2727import net.sf.basedb.core.query.Hql;
     28import net.sf.basedb.core.query.Restriction;
    2829import net.sf.basedb.core.query.Restrictions;
    2930
    3031/**
    31   This class represents a specific {@link FileSetMemberType}
     32  This class represents a specific {@link DataFileType}
    3233  that is part of a platform.
    3334
     
    4950 
    5051  static PlatformFileType getNew(DbControl dc, Platform platform, PlatformVariant variant,
    51     FileSetMemberType fileType)
     52    DataFileType fileType, boolean required)
    5253  {
    5354    PlatformFileType type = dc.newItem(PlatformFileType.class);
     
    5556    data.setPlatform(platform.getData());
    5657    data.setVariant(variant == null ? null : variant.getData());
    57     data.setFileType(fileType.getData());
     58    data.setDataFileType(fileType.getData());
     59    data.setRequired(required);
    5860    return type;
    5961  }
     
    6264  /**
    6365    Get the file types that have been registered for a specific platform
    64     and variant.
     66    and variant. If the <code>restrict</code> parameter is TRUE the query will
     67    be restricted to return fewer items. It works like this:
     68   
     69    <ul>
     70    <li>It has no meaning if both <code>platform</code> and
     71      <code>variant</code> is null
     72    <li>If <code>variant</code> is null, the query will return file
     73      types for all variants if <code>restrict=false</code>. If
     74      <code>restrict=true</code> the query will only return items
     75      registered as common file types for all variants
     76    <li>If <code>variant</code> isn't null, the query will return file
     77      types that have been registered for that variant plus file
     78      types registered as common for all variants if <code>restrict=false</code>.
     79      If <code>restrict=true</code> the query will only return file types
     80      registered for that particular variant.
     81    </ul>
     82   
     83    Note! If a variant is given but no platform, the platform will
     84    automatically be set from the variant.
    6585   
    6686    @param platform A platform object or null to return items for
     
    6888    @param variant A platform variant or null to return items for all
    6989      variants
     90    @param restrict Indicates if the query should be restricted to inlcude
     91      fewer items
    7092    @return A query returning <code>PlatformFileType</code> items
    7193  */
     
    7496  {
    7597    ItemQuery<PlatformFileType> query = new ItemQuery<PlatformFileType>(PlatformFileType.class);
     98    if (platform == null && variant != null) platform = variant.getPlatform();
    7699    if (platform != null)
    77100    {
     
    82105        )
    83106      );
     107     
     108      Restriction commonVariant =
     109        Restrictions.eq(Hql.property("variant"), null);
     110      if (variant == null)
     111      {
     112        if (restrict)
     113        {
     114          // Only load file types that are common to all variants
     115          query.restrictPermanent(commonVariant);
     116        }
     117      }
     118      else
     119      {
     120        Restriction specificVariant =
     121          Restrictions.eq(Hql.property("variant"), Hql.entity(variant));
     122        if (restrict)
     123        {
     124          // Only load file types specific to the variant
     125          query.restrictPermanent(specificVariant);
     126        }
     127        else
     128        {
     129          // Load common + specific file types
     130          query.restrictPermanent(Restrictions.or(specificVariant, commonVariant));
     131        }
     132      }
     133     
    84134    }
    85135    return query;
     
    129179    @return A file set member type item
    130180  */
    131   public FileSetMemberType getMemberType()
     181  public DataFileType getDataFileType()
    132182  {
    133     return getDbControl().getItem(FileSetMemberType.class, getData().getFileType());
     183    return getDbControl().getItem(DataFileType.class, getData().getDataFileType());
     184  }
     185 
     186  /**
     187    Check if a file of this type is required or not.
     188    Note! The requirement is not enforced by the core. It should be used as a
     189    hint to client applications so they can create a proper GUI. To check
     190    if a {@link FileSet} contains all files that have been marked as required
     191    use TODO.
     192  */
     193  public boolean isRequired()
     194  {
     195    return getData().isRequired();
    134196  }
    135197
  • branches/filedb/src/core/net/sf/basedb/core/PlatformVariant.java

    r3783 r3793  
    389389      have write permission to the platform
    390390    @throws InvalidUseOfNullException If type is null
    391     @see Platform#addFileType(FileSetMemberType, PlatformVariant)
    392   */
    393   public void addFileType(FileSetMemberType type)
    394   {
    395     getPlatform().addFileType(type, this);
     391    @see Platform#addFileType(DataFileType, boolean, PlatformVariant)
     392  */
     393  public void addFileType(DataFileType type, boolean required)
     394  {
     395    getPlatform().addFileType(type, required, this);
    396396  }
    397397
     
    404404      have write permission to the platform
    405405    @throws InvalidUseOfNullException If type is null
    406     @see Platform#removeFileType(FileSetMemberType, PlatformVariant)
    407   */
    408   public void removeFileType(FileSetMemberType type)
     406    @see Platform#removeFileType(DataFileType, PlatformVariant)
     407  */
     408  public void removeFileType(DataFileType type)
    409409  {
    410410    getPlatform().removeFileType(type, this);
  • branches/filedb/src/core/net/sf/basedb/core/PluginDefinition.java

    r3679 r3793  
    976976        if (unloadBefore) JarClassLoader.unload(jarPath);
    977977        ClassLoader cl = JarClassLoader.getInstance(jarPath, Application.autoUnloadPlugins());
    978         c = cl.loadClass(className);
    979       }
    980       if (!Plugin.class.isAssignableFrom(c))
    981       {
    982         throw new InvalidDataException("Class does not implement net.sf.basedb.core.plugin.Plugin: "+className);
     978        c = ClassUtil.checkAndLoadClass(cl, className, true, Plugin.class);
    983979      }
    984980      return (Plugin)c.newInstance();
  • branches/filedb/src/core/net/sf/basedb/core/data/DataFileTypeData.java

    r3764 r3793  
    3131  @author Nicklas
    3232  @version 2.5
    33   @see net.sf.basedb.core.FileSetMemberType
     33  @see net.sf.basedb.core.DataFileType
    3434  @base.modified $Date$
    35   @hibernate.class table="`FileSetMemberTypes`" lazy="false"
     35  @hibernate.class table="`DataFileTypes`" lazy="false"
    3636*/
    37 public class FileSetMemberTypeData
     37public class DataFileTypeData
    3838  extends BasicData
    3939  implements NameableData, RemovableData, SystemData
     
    7272  */
    7373  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  */
    7481  public String getSystemId()
    7582  {
     
    125132  /**
    126133    Get the class name of the Java class that is the validator for
    127     this file type. The class must implement the {@link net.sf.basedb.core.FileValidator}
     134    this file type. The class must implement the {@link net.sf.basedb.core.filehandler.DataFileValidator}
    128135    interface. Null if there is no validator for this file type.
    129136    @hibernate.property column="`validator_class`" type="string" length="255" not-null="false"
     
    141148  /**
    142149    Get the class name of the Java class that extracts metadata from
    143     this file type. The class must implement the {@link net.sf.basedb.core.MetadataExtractor}
     150    this file type. The class must implement the {@link net.sf.basedb.core.filehandler.DataFileMetadataReader}
    144151    interface. Null if there is no extractor for this file type.
    145152    @hibernate.property column="`extractor_class`" type="string" length="255" not-null="false"
     
    168175  }
    169176 
    170   private boolean required;
    171   /**
    172     If a file of this type is required or not.
    173     @hibernate.property column="`required`" type="boolean" not-null="true"
    174   */
    175   public boolean isRequired()
    176   {
    177     return required;
    178   }
    179   public void setRequired(boolean required)
    180   {
    181     this.required = required;
    182   }
    183  
    184177  private FileTypeData genericType;
    185178  /**
    186179    Get the generic file type of files with this member type.
    187180    @hibernate.many-to-one outer-join="false"
    188     @hibernate.column name="`filetype_id`" not-null="true"
     181    @hibernate.column name="`filetype_id`" not-null="false"
    189182  */
    190183  public FileTypeData getGenericType()
  • branches/filedb/src/core/net/sf/basedb/core/data/FileSetData.java

    r3783 r3793  
    5656  }
    5757 
    58   private Map<FileSetMemberTypeData, FileSetMemberData> members;
     58  private Map<DataFileTypeData, FileSetMemberData> members;
    5959  /**
    6060    The members of this file set. This is the inverse end.
     
    6262    @hibernate.map lazy="true" cascade="delete" inverse="true"
    6363    @hibernate.collection-key column="`fileset_id`"
    64     @hibernate.index-many-to-many column="`filesetmembertype_id`" class="net.sf.basedb.core.data.FileSetMemberTypeData"
     64    @hibernate.index-many-to-many column="`datafiletype_id`" class="net.sf.basedb.core.data.DataFileTypeData"
    6565    @hibernate.collection-one-to-many class="net.sf.basedb.core.data.FileSetMemberData"
    6666  */
    67   public Map<FileSetMemberTypeData, FileSetMemberData> getMembers()
     67  public Map<DataFileTypeData, FileSetMemberData> getMembers()
    6868  {
    6969    if (members == null)
    7070    {
    71       members = new HashMap<FileSetMemberTypeData, FileSetMemberData>();
     71      members = new HashMap<DataFileTypeData, FileSetMemberData>();
    7272    }
    7373    return members;
    7474  }
    75   void setMembers(Map<FileSetMemberTypeData, FileSetMemberData> members)
     75  void setMembers(Map<DataFileTypeData, FileSetMemberData> members)
    7676  {
    7777    this.members = members;
  • branches/filedb/src/core/net/sf/basedb/core/data/FileSetMemberData.java

    r3783 r3793  
    5454  }
    5555 
    56   private FileSetMemberTypeData fileType;
     56  private DataFileTypeData fileType;
    5757  /**
    5858    Get the type of this file. A set may only contain one file for each type.
    5959    @hibernate.many-to-one outer-join="false" update="false"
    60     @hibernate.column name="`filesetmembertype_id`" not-null="true" unique-key="uniquetype"
     60    @hibernate.column name="`datafiletype_id`" not-null="true" unique-key="uniquetype"
    6161  */
    62   public FileSetMemberTypeData getFileType()
     62  public DataFileTypeData getDataFileType()
    6363  {
    6464    return fileType;
    6565  }
    66   public void setFileType(FileSetMemberTypeData fileType)
     66  public void setDataFileType(DataFileTypeData fileType)
    6767  {
    6868    this.fileType = fileType;
     
    8383    this.file = file;
    8484  }
     85 
     86  private Boolean valid;
     87  /**
     88    If the file has been validated or not. A null value indicates that
     89    the file hasn't been validated. A FALSE value indicates an invalid
     90    file.
     91    @hibernate.property column="`valid`" type="boolean" not-null="false"
     92  */
     93  public Boolean isValid()
     94  {
     95    return valid;
     96  }
     97  public void setValid(Boolean valid)
     98  {
     99    this.valid = valid;
     100  }
     101
    85102
    86103}
  • branches/filedb/src/core/net/sf/basedb/core/data/FileTypeIndex.java

    r3783 r3793  
    4141  {}
    4242 
    43   public FileTypeIndex(PlatformVariantData variant, FileSetMemberTypeData fileType)
     43  public FileTypeIndex(PlatformVariantData variant, DataFileTypeData fileType)
    4444  {
    4545    this.fileType = fileType;
     
    4949  private transient PlatformVariantData variant;
    5050  /**
    51     @hibernate.property column="`location`" type="int"
     51    @hibernate.many-to-one column="`variant_id`" outer-join="false"
    5252  */
    5353  public PlatformVariantData getVariant()
     
    6060  }
    6161
    62   private transient FileSetMemberTypeData fileType;
     62  private transient DataFileTypeData fileType;
    6363  /**
    64     @hibernate.property column="`location`" type="int"
     64    @hibernate.many-to-one column="`datafiletype_id`" outer-join="false"
    6565  */
    66   public FileSetMemberTypeData getFileType()
     66  public DataFileTypeData getFileType()
    6767  {
    6868    return fileType;
    6969  }
    70   void setFileType(FileSetMemberTypeData fileType)
     70  void setFileType(DataFileTypeData fileType)
    7171  {
    7272    this.fileType = fileType;
  • branches/filedb/src/core/net/sf/basedb/core/data/PlatformData.java

    r3783 r3793  
    7474  */
    7575  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  */
    7683  public String getSystemId()
    7784  {
  • branches/filedb/src/core/net/sf/basedb/core/data/PlatformFileTypeData.java

    r3783 r3793  
    3838{
    3939 
    40   private FileSetMemberTypeData fileType;
     40  private DataFileTypeData fileType;
    4141  /**
    4242    Get the file type.
    4343    @hibernate.many-to-one outer-join="false" update="false"
    44     @hibernate.column name="`filesetmembertype_id`" not-null="true"
     44    @hibernate.column name="`datafiletype_id`" not-null="true"
    4545  */
    46   public FileSetMemberTypeData getFileType()
     46  public DataFileTypeData getDataFileType()
    4747  {
    4848    return fileType;
    4949  }
    50   public void setFileType(FileSetMemberTypeData fileType)
     50  public void setDataFileType(DataFileTypeData fileType)
    5151  {
    5252    this.fileType = fileType;
     
    8282    this.variant = variant;
    8383  }
     84 
     85  private boolean required;
     86  /**
     87    If a file of this type is required or not.
     88    @hibernate.property column="`required`" type="boolean" not-null="true"
     89  */
     90  public boolean isRequired()
     91  {
     92    return required;
     93  }
     94  public void setRequired(boolean required)
     95  {
     96    this.required = required;
     97  }
    8498
    8599}
  • branches/filedb/src/core/net/sf/basedb/core/data/PlatformVariantData.java

    r3783 r3793  
    7272  */
    7373  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  */
    7481  public String getSystemId()
    7582  {
  • branches/filedb/src/core/net/sf/basedb/util/ClassUtil.java

    r3679 r3793  
    106106  }
    107107
     108  /**
     109    Check if a specified class exists and, optionally, if it has public no-argument
     110    constructor and implements a set of specific interfaces or superclasses.
     111   
     112    @param loader The classloader used to load the class, or null
     113      to use the default classloader
     114    @param name The fully qualified name of class to check
     115    @param publicNoArgConstructor TRUE to check if a public no-argument constructor exists
     116    @param interfaces An array of class objects representing interfaces or superclasses
     117      that the class to check must implement or extend
     118    @return The <code>Class</code> object for the named class
     119    @throws ClassNotFoundException If a class with the specified name isn't found
     120    @throws NoSuchMethodException If a public no-argument constructor isn't found
     121    @throws ClassCastException If the class doesn't implement or extend all of
     122      the interfaces/superclasses
     123    @since 2.5
     124  */
     125  public static Class<?> checkAndLoadClass(ClassLoader loader, String name,
     126    boolean publicNoArgConstructor, Class<?>... interfaces)
     127    throws ClassNotFoundException, NoSuchMethodException, ClassCastException
     128  {
     129    if (loader == null) loader = ClassUtil.class.getClassLoader();
     130    Class<?> clazz = loader.loadClass(name);
     131    if (publicNoArgConstructor)
     132    {
     133      clazz.getConstructor((Class<?>[])null);
     134    }
     135    if (interfaces != null)
     136    {
     137      for (Class<?> iFace : interfaces)
     138      {
     139        if (iFace != null && !iFace.isAssignableFrom(clazz))
     140        {
     141          throw new ClassCastException("Class '" + name + "' is not a '" + iFace.getName() + "'");
     142        }
     143      }
     144    }
     145    return clazz;
     146  }
    108147
    109148}
  • branches/filedb/src/test/TestAll.java

    r3700 r3793  
    102102    results.put("TestPlateMapping", TestPlateMapping.test_all());
    103103
     104    // Experimental platforms and data file types
     105    results.put("TestDataFileType", TestDataFileType.test_all());
     106    results.put("TestPlatform", TestPlatform.test_all());
     107   
    104108    // Array LIMS -- Arrays
    105109    results.put("TestArrayDesign", TestArrayDesign.test_all());
    106 //    results.put("TestAffyChip", TestAffyChip.test_all());
    107110    results.put("TestArrayBatch", TestArrayBatch.test_all());
    108111    results.put("TestArraySlide", TestArraySlide.test_all());
  • branches/filedb/src/test/TestArrayDesign.java

    r3783 r3793  
    3333import net.sf.basedb.core.File;
    3434import net.sf.basedb.core.FileSetMember;
    35 import net.sf.basedb.core.FileSetMemberType;
     35import net.sf.basedb.core.DataFileType;
    3636import net.sf.basedb.core.Item;
    3737import net.sf.basedb.core.Permission;
     
    301301    {
    302302      System.out.println(i+":\t"+member.getId()+"\t"+member.getFile().getName()+"\t"+
    303         member.getMemberType().getName());
     303        member.getDataFileType().getName());
    304304    }
    305305  }
     
    604604      dc = TestUtil.getDbControl();
    605605      ArrayDesign ad = ArrayDesign.getById(dc, arrayDesignId);
    606       FileSetMemberType type = FileSetMemberType.getById(dc, SystemItems.getId(fileType));
     606      DataFileType type = DataFileType.getById(dc, SystemItems.getId(fileType));
    607607      File file = File.getById(dc, fileId);
    608608      ad.getFileSet().setMember(file, type);
  • branches/filedb/src/test/TestDataFileType.java

    r3783 r3793  
    2525import net.sf.basedb.core.BaseException;
    2626import net.sf.basedb.core.DbControl;
    27 import net.sf.basedb.core.FileSetMemberType;
     27import net.sf.basedb.core.DataFileType;
     28import net.sf.basedb.core.FileType;
    2829import net.sf.basedb.core.Item;
    2930import net.sf.basedb.core.ItemResultList;
     
    3435import net.sf.basedb.core.SystemItems;
    3536
    36 public class TestFileSetMemberType
     37public class TestDataFileType
    3738{
    3839
     
    4950  static boolean test_all()
    5051  {
    51     write("++Testing file set member types");
     52    write("++Testing data file types");
    5253    write_header();
    5354    // Standard tests: create, load and list
    5455    test_load(SystemItems.getId("affymetrix.cel"));
    5556   
    56     int id1 = test_create("Test file type", "test.filetype");
     57    int id1 = test_create("Test file type", "test.filetype", Item.RAWBIOASSAY, SystemItems.getId(FileType.RAW_DATA));
    5758    test_list();
    5859
     
    6061    if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter();
    6162    test_delete(id1);
    62     write("++Testing file set member types "+(ok ? "OK" : "Failed")+"\n");
     63    write("++Testing data file types "+(ok ? "OK" : "Failed")+"\n");
    6364    return ok;
    6465  }
    6566
    66   static int test_create(String name, String systemId)
    67   {
    68     if (!TestUtil.hasPermission(Permission.CREATE, Item.FILESETMEMBERTYPE)) return 0;
     67  static int test_create(String name, String systemId, Item itemType, int genericTypeId)
     68  {
     69    if (!TestUtil.hasPermission(Permission.CREATE, Item.DATAFILETYPE)) return 0;
    6970    int id = 0;
    7071    DbControl dc = null;
     
    7273    {
    7374      dc = TestUtil.getDbControl();
    74      
    75       FileSetMemberType type = FileSetMemberType.getNew(dc, systemId);
     75      FileType genericType = genericTypeId == 0 ? null : FileType.getById(dc, genericTypeId);
     76      DataFileType type = DataFileType.getNew(dc, systemId, itemType);
     77      type.setGenericType(genericType);
    7678      type.setName(name);
    7779      dc.saveItem(type);
     
    7981      id = type.getId();
    8082      write_item(0, type);
    81       write("--Create file set member type OK");
    82     }
    83     catch (Throwable ex)
    84     {
    85       write("--Create file set member type FAILED");
     83      write("--Create data file type OK");
     84    }
     85    catch (Throwable ex)
     86    {
     87      write("--Create data file type FAILED");
    8688      ex.printStackTrace();
    8789      ok = false;
     
    102104    {
    103105      dc = TestUtil.getDbControl();
    104       FileSetMemberType type = FileSetMemberType.getById(dc, id);
     106      DataFileType type = DataFileType.getById(dc, id);
    105107      write_item(0, type);
    106       write("--Load file set member type OK");
    107     }
    108     catch (Throwable ex)
    109     {
    110       write("--Load file set member type FAILED");
     108      write("--Load data file type OK");
     109    }
     110    catch (Throwable ex)
     111    {
     112      write("--Load data file type FAILED");
    111113      ex.printStackTrace();
    112114      ok = false;
     
    124126    {
    125127      dc = TestUtil.getDbControl();
    126       ItemResultList<FileSetMemberType> l = FileSetMemberType.getQuery().list(dc);
     128      ItemResultList<DataFileType> l = DataFileType.getQuery().list(dc);
    127129      for (int i = 0; i<l.size(); i++)
    128130      {
    129131        write_item(i, l.get(i));
    130132      }
    131       write("--List file set member types OK ("+l.size()+")");
    132     }
    133     catch (Throwable ex)
    134     {
    135       write("--List file set member types FAILED");
     133      write("--List data file types OK ("+l.size()+")");
     134    }
     135    catch (Throwable ex)
     136    {
     137      write("--List data file types FAILED");
    136138      ex.printStackTrace();
    137139      ok = false;
     
    150152    {
    151153      dc = TestUtil.getDbControl();
    152       FileSetMemberType l = FileSetMemberType.getById(dc, id);
     154      DataFileType l = DataFileType.getById(dc, id);
    153155      dc.deleteItem(l);
    154156      dc.commit();
    155       write("--Delete file set member type OK");
    156     }
    157     catch (Throwable ex)
    158     {
    159       write("--Delete file set member type FAILED");
     157      write("--Delete data file type OK");
     158    }
     159    catch (Throwable ex)
     160    {
     161      write("--Delete data file type FAILED");
    160162      ex.printStackTrace();
    161163      ok = false;
     
    177179  }
    178180 
    179   static void write_item(int i, FileSetMemberType type)
     181  static void write_item(int i, DataFileType type)
    180182    throws BaseException
    181183  {
  • branches/filedb/src/test/TestPlatform.java

    r3783 r3793  
    2525import net.sf.basedb.core.BaseException;
    2626import net.sf.basedb.core.DbControl;
    27 import net.sf.basedb.core.FileSetMemberType;
     27import net.sf.basedb.core.DataFileType;
     28import net.sf.basedb.core.FileType;
    2829import net.sf.basedb.core.Item;
    2930import net.sf.basedb.core.ItemResultList;
     
    6263    // Variants
    6364    int idVariant1 = test_create_variant(id1, "Variant of db and file", "test.db.and.file.v1", null, 0, null);
    64     int idVariant2 = test_create_variant(id2, "Variant file-only", "test.file.only.v1", null, 0, null);
     65    int idVariant2 = test_create_variant(id2, "Variant #1 file-only", "test.file.only.v1", null, 0, null);
     66    int idVariant2b = test_create_variant(id2, "Variant #2 file-only", "test.file.only.v2", null, 0, null);
    6567    int idVariant3 = test_create_variant(id3, "Locked to agilent", "test.locked.agilent", false, 0, "agilent");
    6668    test_list_variants(id1, 1);
    6769   
    6870    // File types
    69     test_add_filetype(id2, 0, SystemItems.getId("affymetrix.cel"));
    70     test_add_filetype(id2, idVariant2, SystemItems.getId("affymetrix.cdf"));
    71     test_list_filetypes(id2, 0, 1);
     71    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);
     74    test_add_filetype(id2, idVariant2b, fileTypeId, false);
     75    test_list_filetypes(id2, 0, false, 3);
     76    test_list_filetypes(id2, 0, true, 1);
     77    test_list_filetypes(id2, idVariant2, false, 2);
     78    test_list_filetypes(id2, idVariant2, true, 1);
    7279   
    7380    // Standard test: Delete
     
    7784    test_delete(id2);
    7885    test_delete(id3);
     86    TestDataFileType.test_delete(fileTypeId);
    7987    write("++Testing platform "+(ok ? "OK" : "Failed")+"\n");
    8088    return ok;
     
    218226  }
    219227 
     228  static void write_item(int i, PlatformFileType ft)
     229    throws BaseException
     230  {
     231    if (!TestUtil.getSilent())
     232    {
     233      System.out.println(i+":\t"+ft.getId()+"\t"+ft.getPlatform()+"\t"+
     234          ft.getVariant() + "\t" + ft.getDataFileType());
     235    }
     236  }
     237 
    220238  static void write(String message)
    221239  {
     
    324342  }
    325343
    326   static void test_add_filetype(int platformId, int variantId, int fileTypeId)
     344  static void test_add_filetype(int platformId, int variantId, int fileTypeId, boolean required)
    327345  {
    328346    if (platformId == 0 || fileTypeId == 0) return;
     
    334352      Platform p = Platform.getById(dc, platformId);
    335353      PlatformVariant v = variantId == 0 ? null : PlatformVariant.getById(dc, variantId);
    336       FileSetMemberType fileType = FileSetMemberType.getById(dc, fileTypeId);
    337      
    338       p.addFileType(fileType, v);
     354      DataFileType fileType = DataFileType.getById(dc, fileTypeId);
     355     
     356      p.addFileType(fileType, required, v);
    339357     
    340358      dc.commit();
    341       write("--Add file type OK");
    342     }
    343     catch (Throwable ex)
    344     {
    345       write("--Add file type FAILED");
     359      write("--Add file type to platform OK");
     360    }
     361    catch (Throwable ex)
     362    {
     363      write("--Add file type to platform FAILED");
    346364      ex.printStackTrace();
    347365      ok = false;
     
    353371  }
    354372 
    355   static void test_list_filetypes(int platformId, int variantId, int expectedResults)
     373  static void test_list_filetypes(int platformId, int variantId, boolean restrict, int expectedResults)
    356374  {
    357375    if (platformId == 0) return;
     
    362380      Platform p = Platform.getById(dc, platformId);
    363381      PlatformVariant v = variantId == 0 ? null : PlatformVariant.getById(dc, variantId);
    364       ItemResultList<PlatformFileType> l = p.getFileTypes(v, false).list(dc);
     382      ItemResultList<PlatformFileType> l = p.getFileTypes(v, restrict).list(dc);
    365383      for (int i = 0; i<l.size(); i++)
    366384      {
  • branches/filedb/src/test/TestRawBioAssay.java

    r3783 r3793  
    8080    test_set_file(id3, "affymetrix.cel", celId);
    8181    test_list_files(id3, 1);
     82    test_list_file_types(id3, 1);
    8283   
    8384    if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter();
     
    281282    {
    282283      System.out.println(i+":\t"+member.getId()+"\t"+member.getFile().getName()+"\t"+
    283         member.getMemberType().getName());
    284     }
    285   }
    286    
     284        member.getDataFileType().getName());
     285    }
     286  }
     287 
     288  static void write_item(int i, DataFileType type)
     289    throws BaseException
     290  {
     291    if (!TestUtil.getSilent())
     292    {
     293      System.out.println(i+":\t"+type.getId()+"\t"+type.getName()+"\t"+
     294        type.getDescription());
     295    }
     296  }
     297
    287298 
    288299  static void write(String message)
     
    525536      dc = TestUtil.getDbControl();
    526537      RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId);
    527       FileSetMemberType type = FileSetMemberType.getById(dc, SystemItems.getId(fileType));
     538      DataFileType type = DataFileType.getById(dc, SystemItems.getId(fileType));
    528539      File file = File.getById(dc, fileId);
    529540      rba.getFileSet().setMember(file, type);
     
    573584    }
    574585  }
     586 
     587  static void test_list_file_types(int rawBioAssayId, int expectedResults)
     588  {
     589    if (rawBioAssayId == 0) return;
     590    DbControl dc = null;
     591    try
     592    {
     593      dc = TestUtil.getDbControl();
     594      RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId);
     595      ItemResultList<DataFileType> l = rba.getFileSet().getMemberTypes().list(dc);
     596      for (int i = 0; i<l.size(); i++)
     597      {
     598        write_item(i, l.get(i));
     599      }
     600      if (expectedResults >= 0 && expectedResults != l.size())
     601      {
     602        throw new BaseException("Expected "+expectedResults+" results, not "+l.size());
     603      }
     604      write("--List file types OK ("+l.size()+")");
     605    }
     606    catch (Throwable ex)
     607    {
     608      write("--List file types FAILED");
     609      ex.printStackTrace();
     610      ok = false;
     611    }
     612    finally
     613    {
     614      if (dc != null) dc.close();
     615    }
     616  }
    575617}
  • branches/filedb/www/include/menu.jsp

    r3679 r3793  
    666666    }
    667667    %>
     668    <%
     669    // Administrate -> Platforms menu
     670    final boolean hasPlatforms = sc.hasPermission(Permission.READ, Item.PLATFORM);
     671    final boolean hasFileSetMemberTypes = sc.hasPermission(Permission.READ, Item.DATAFILETYPE);
     672    final boolean hasTopPlatforms = hasPlatforms || hasFileSetMemberTypes;
     673    if (hasTopPlatforms)
     674    {
     675      %>
     676      <m:menu
     677        id="platforms"
     678        style="display: none"
     679        >
     680        <m:menuitem
     681          title="Experimental platforms"
     682          onclick="<%="Menu.openUrl('"+root+"admin/platforms/index.jsp?ID="+ID+"')"%>"
     683          tooltip="<%=hasPlatforms ? "Administrate experimental platforms" : "You do not have permission to administrate experimental platforms"%>"
     684          enabled="<%=hasPlatforms%>"
     685        />
     686        <m:menuitem
     687          title="Data file types"
     688          onclick="<%="Menu.openUrl('"+root+"admin/datafiletypes/index.jsp?ID="+ID+"')"%>"
     689          tooltip="<%=hasFileSetMemberTypes ? "Administrate data file types" : "You do not have permission to administrate data file types"%>"
     690          enabled="<%=hasFileSetMemberTypes%>"
     691        />
     692      </m:menu>
     693      <%
     694    }
     695    %>
    668696   
    669697    <%
     
    731759      hasUsers || hasGroups || hasRoles || hasQuota || hasTypes || hasPlugins ||
    732760      hasSoftware || hasHardware || hasProtocols || hasClients || hasNews ||
    733       hasDiskUsage || hasServer;
     761      hasDiskUsage || hasServer || hasTopPlatforms;
    734762
    735763    if (hasAdministrate)
     
    803831        />
    804832        <m:menuseparator />
     833        <m:submenu
     834          subid="platforms"
     835          title="Platforms"
     836          tooltip="Administrate experimental platforms"
     837          enabled="<%=hasTopPlatforms%>"
     838        />
    805839        <m:submenu
    806840          subid="types"
  • branches/filedb/www/include/scripts/main.js

    r3719 r3793  
    263263    var regExp = new RegExp(className);
    264264    obj.className = obj.className.replace(className, '');
     265  }
     266 
     267  this.addOrRemoveClass = function(obj, className, addIfTrue)
     268  {
     269    if (addIfTrue)
     270    {
     271      this.addClass(obj, className);
     272    }
     273    else
     274    {
     275      this.removeClass(obj, className);
     276    }
    265277  }
    266278 
     
    425437    this.controllers['EXTRAVALUETYPE'] = { url:'admin/extravaluetypes/index.jsp', width:500, height:360 };
    426438    this.controllers['EXTRAVALUE'] = { url:'views/experiments/extravalues/index.jsp', width:500, height:340, edit:false };
     439    this.controllers['PLATFORM'] = { url:'admin/platforms/index.jsp', width:540, height:400 };
     440    this.controllers['PLATFORMVARIANT'] = { url:'admin/platforms/variants/index.jsp', width:540, height:400 };
     441    this.controllers['DATAFILETYPE'] = { url:'admin/datafiletypes/index.jsp', width:600, height:480 };
    427442  }
    428443 
     
    10911106  this.isInteger = function(value)
    10921107  {
    1093     return (value.search(/^\d+$/) != -1);
     1108    return (value.search(/^\-?\d+$/) != -1);
    10941109  }
    10951110
  • branches/filedb/www/include/styles/main.css

    r3719 r3793  
    168168  background: #D0F0FF;
    169169}
    170 
     170input.unchangeable, select.unchangeable, textarea.unchangeable {
     171  background: #FFF0D0;
     172}
    171173a.disabled {
    172174  color: #666666;
Note: See TracChangeset for help on using the changeset viewer.