Changeset 2565


Ignore:
Timestamp:
Aug 11, 2014, 8:36:01 AM (7 years ago)
Author:
Nicklas Nordborg
Message:

References #533: Add secondary analysis section to Reggie

Installing file types for FASTQ/BAM and associating them with the MergedSequences? and AlignedSequences? bioassay type.

Location:
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Subtype.java

    r2420 r2565  
    358358  */
    359359  public static final Subtype QUBIT_CSV = new Subtype("Qubit CSV", Item.FILE, false);
     360
     361  /**
     362    File subtype for sequence data files.
     363    @since 2.16
     364  */
     365  public static final Subtype SEQUENCE_DATA = new Subtype("Sequence data", Item.FILE, false);
     366
     367  /**
     368    File subtype for aligned sequence data files.
     369    @since 2.16
     370  */
     371  public static final Subtype ALIGNED_SEQUENCE_DATA = new Subtype("Aligned sequence data", Item.FILE, false);
    360372 
    361373  /**
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java

    r2562 r2565  
    2626import net.sf.basedb.core.BioPlateEventType;
    2727import net.sf.basedb.core.BioPlateType;
     28import net.sf.basedb.core.DataFileType;
    2829import net.sf.basedb.core.DbControl;
    2930import net.sf.basedb.core.Extract;
     
    3637import net.sf.basedb.core.ItemQuery;
    3738import net.sf.basedb.core.ItemSubtype;
     39import net.sf.basedb.core.ItemSubtypeFileType;
    3840import net.sf.basedb.core.MimeType;
    3941import net.sf.basedb.core.MultiPermissions;
     
    6062import net.sf.basedb.reggie.dao.BioplateEventtype;
    6163import net.sf.basedb.reggie.dao.BioplateType;
     64import net.sf.basedb.reggie.dao.Datafiletype;
    6265import net.sf.basedb.reggie.dao.Fileserver;
    6366import net.sf.basedb.reggie.dao.FlowCell;
     
    190193            patientCuratorWrite : activeProjectWrite;
    191194        Map<String, Item> subtypeItems = new HashMap<String, Item>();
     195
     196        // Must check/install some file subtypes first, since they are used by 'data file types'
     197        JSONObject jsonSubtype_SEQUENCE_DATA = checkSubtype(dc, Subtype.SEQUENCE_DATA, null, createIfMissing);
     198        JSONObject jsonSubtype_ALIGNED_SEQUENCE_DATA = checkSubtype(dc, Subtype.ALIGNED_SEQUENCE_DATA, null, createIfMissing);
     199
     200        // Data file types
     201        jsonChecks.add(checkDataFileType(dc, Datafiletype.FASTQ, createIfMissing));
     202        jsonChecks.add(checkDataFileType(dc, Datafiletype.BAM, createIfMissing));
    192203       
    193204        // Subtype checks
    194         jsonChecks.add(checkSubtype(dc, Subtype.PATIENT, createIfMissing));
    195         jsonChecks.add(checkSubtype(dc, Subtype.NO, createIfMissing));
    196         jsonChecks.add(checkSubtype(dc, Subtype.NOT_ASKED, createIfMissing));
    197         jsonChecks.add(checkSubtype(dc, Subtype.CASE, createIfMissing, Subtype.PATIENT));
    198         jsonChecks.add(checkSubtype(dc, Subtype.BLOOD, createIfMissing, Subtype.PATIENT));
    199         jsonChecks.add(checkSubtype(dc, Subtype.SPECIMEN,createIfMissing, Subtype.CASE));
    200         jsonChecks.add(checkSubtype(dc, Subtype.NO_SPECIMEN,createIfMissing, Subtype.CASE));
    201         jsonChecks.add(checkSubtype(dc, Subtype.HISTOLOGY_PROTOCOL, createIfMissing));
    202         jsonChecks.add(checkSubtype(dc, Subtype.HISTOLOGY, createIfMissing, Subtype.SPECIMEN, Subtype.HISTOLOGY_PROTOCOL));
    203         jsonChecks.add(checkSubtype(dc, Subtype.STAINING_PROTOCOL, createIfMissing));
    204         jsonChecks.add(checkSubtype(dc, Subtype.STAINED, createIfMissing, Subtype.HISTOLOGY, Subtype.STAINING_PROTOCOL));
    205         jsonChecks.add(checkSubtype(dc, Subtype.SAMPLE_HANDLING_PROTOCOL, createIfMissing));
    206         jsonChecks.add(checkSubtype(dc, Subtype.EXTRACTION_PROTOCOL, createIfMissing));
    207         jsonChecks.add(checkSubtype(dc, Subtype.LYSATE, createIfMissing, Subtype.SPECIMEN, Subtype.SAMPLE_HANDLING_PROTOCOL));
    208         jsonChecks.add(checkSubtype(dc, Subtype.DNA, createIfMissing, Subtype.LYSATE, Subtype.EXTRACTION_PROTOCOL));
    209         jsonChecks.add(checkSubtype(dc, Subtype.RNA, createIfMissing, Subtype.LYSATE, Subtype.EXTRACTION_PROTOCOL));
    210         jsonChecks.add(checkSubtype(dc, Subtype.FLOW_THROUGH, createIfMissing, Subtype.LYSATE, Subtype.EXTRACTION_PROTOCOL));
    211         jsonChecks.add(checkSubtype(dc, Subtype.QUALITY_CONTROL, createIfMissing));
    212         jsonChecks.add(checkSubtype(dc, Subtype.RNAQC, createIfMissing, Subtype.RNA, Subtype.QUALITY_CONTROL));   
    213         jsonChecks.add(checkSubtype(dc, Subtype.MRNA_PROTOCOL, createIfMissing));
    214         jsonChecks.add(checkSubtype(dc, Subtype.MRNA, createIfMissing, Subtype.RNA, Subtype.MRNA_PROTOCOL));
    215         jsonChecks.add(checkSubtype(dc, Subtype.CDNA_PROTOCOL, createIfMissing));
    216         jsonChecks.add(checkSubtype(dc, Subtype.CDNA, createIfMissing, Subtype.MRNA, Subtype.CDNA_PROTOCOL));
    217         jsonChecks.add(checkSubtype(dc, Subtype.LIBRARY_PROTOCOL, createIfMissing));
    218         jsonChecks.add(checkSubtype(dc, Subtype.BARCODE, createIfMissing));
    219         jsonChecks.add(checkSubtype(dc, Subtype.LIBRARY, createIfMissing, Subtype.CDNA, Subtype.BARCODE, Subtype.LIBRARY_PROTOCOL));
    220         jsonChecks.add(checkSubtype(dc, Subtype.POOLING_PROTOCOL, createIfMissing));
    221         jsonChecks.add(checkSubtype(dc, Subtype.POOLED_LIBRARY, createIfMissing, Subtype.LIBRARY, Subtype.POOLING_PROTOCOL));
    222         jsonChecks.add(checkSubtype(dc, Subtype.POOLED_LIBRARY_ALIQUOT, createIfMissing, Subtype.POOLED_LIBRARY));
    223         jsonChecks.add(checkSubtype(dc, Subtype.CLUSTER_PROTOCOL, createIfMissing));
    224         jsonChecks.add(checkSubtype(dc, Subtype.CLUSTER_GENERATOR, createIfMissing));
    225         jsonChecks.add(checkSubtype(dc, Subtype.FLOW_CELL, createIfMissing, Subtype.POOLED_LIBRARY_ALIQUOT, Subtype.CLUSTER_GENERATOR, Subtype.CLUSTER_PROTOCOL));
    226         jsonChecks.add(checkSubtype(dc, Subtype.BIOANALYZER_PDF, createIfMissing));
    227         jsonChecks.add(checkSubtype(dc, Subtype.CALIPER_PDF, createIfMissing));
    228         jsonChecks.add(checkSubtype(dc, Subtype.CALIPER_RAW_DATA, createIfMissing));
    229         jsonChecks.add(checkSubtype(dc, Subtype.CALIPER_WELL_TABLE, createIfMissing));
    230         jsonChecks.add(checkSubtype(dc, Subtype.QUBIT_CSV, createIfMissing));
    231         jsonChecks.add(checkSubtype(dc, Subtype.SEQUENCER, createIfMissing));
    232         jsonChecks.add(checkSubtype(dc, Subtype.SEQUENCING_PROTOCOL, createIfMissing));
    233         jsonChecks.add(checkSubtype(dc, Subtype.SEQUENCING_RUN, createIfMissing, Subtype.FLOW_CELL, Subtype.SEQUENCER, Subtype.SEQUENCING_PROTOCOL));
    234         jsonChecks.add(checkSubtype(dc, Subtype.DEMUX_PROTOCOL, createIfMissing));
    235         jsonChecks.add(checkSubtype(dc, Subtype.DEMUX_SOFTWARE, createIfMissing));
    236         jsonChecks.add(checkSubtype(dc, Subtype.DEMUXED_SEQUENCES, createIfMissing, Subtype.SEQUENCING_RUN, Subtype.DEMUX_PROTOCOL, Subtype.DEMUX_SOFTWARE));
    237         jsonChecks.add(checkSubtype(dc, Subtype.MERGE_PROTOCOL, createIfMissing));
    238         jsonChecks.add(checkSubtype(dc, Subtype.MERGE_SOFTWARE, createIfMissing));
    239         jsonChecks.add(checkSubtype(dc, Subtype.MERGED_SEQUENCES, createIfMissing, Subtype.DEMUXED_SEQUENCES, Subtype.LIBRARY, Subtype.MERGE_PROTOCOL, Subtype.MERGE_SOFTWARE));
    240         jsonChecks.add(checkSubtype(dc, Subtype.MASKING_PROTOCOL, createIfMissing));
    241         jsonChecks.add(checkSubtype(dc, Subtype.MASKING_SOFTWARE, createIfMissing));
    242         jsonChecks.add(checkSubtype(dc, Subtype.MASKED_SEQUENCES, createIfMissing, Subtype.MERGED_SEQUENCES, Subtype.LIBRARY, Subtype.MASKING_PROTOCOL, Subtype.MASKING_SOFTWARE));
    243         jsonChecks.add(checkSubtype(dc, Subtype.ALIGNMENT_PROTOCOL, createIfMissing));
    244         jsonChecks.add(checkSubtype(dc, Subtype.ALIGNMENT_SOFTWARE, createIfMissing));
    245         jsonChecks.add(checkSubtype(dc, Subtype.ALIGNED_SEQUENCES, createIfMissing, Subtype.MASKED_SEQUENCES, Subtype.LIBRARY, Subtype.ALIGNMENT_PROTOCOL, Subtype.ALIGNMENT_SOFTWARE));
    246 
     205        jsonChecks.add(checkSubtype(dc, Subtype.PATIENT, null, createIfMissing));
     206        jsonChecks.add(checkSubtype(dc, Subtype.NO, null, createIfMissing));
     207        jsonChecks.add(checkSubtype(dc, Subtype.NOT_ASKED, null, createIfMissing));
     208        jsonChecks.add(checkSubtype(dc, Subtype.CASE, null, createIfMissing, Subtype.PATIENT));
     209        jsonChecks.add(checkSubtype(dc, Subtype.BLOOD, null, createIfMissing, Subtype.PATIENT));
     210        jsonChecks.add(checkSubtype(dc, Subtype.SPECIMEN,null, createIfMissing, Subtype.CASE));
     211        jsonChecks.add(checkSubtype(dc, Subtype.NO_SPECIMEN,null, createIfMissing, Subtype.CASE));
     212        jsonChecks.add(checkSubtype(dc, Subtype.HISTOLOGY_PROTOCOL, null, createIfMissing));
     213        jsonChecks.add(checkSubtype(dc, Subtype.HISTOLOGY, null, createIfMissing, Subtype.SPECIMEN, Subtype.HISTOLOGY_PROTOCOL));
     214        jsonChecks.add(checkSubtype(dc, Subtype.STAINING_PROTOCOL, null, createIfMissing));
     215        jsonChecks.add(checkSubtype(dc, Subtype.STAINED, null, createIfMissing, Subtype.HISTOLOGY, Subtype.STAINING_PROTOCOL));
     216        jsonChecks.add(checkSubtype(dc, Subtype.SAMPLE_HANDLING_PROTOCOL, null, createIfMissing));
     217        jsonChecks.add(checkSubtype(dc, Subtype.EXTRACTION_PROTOCOL, null, createIfMissing));
     218        jsonChecks.add(checkSubtype(dc, Subtype.LYSATE, null, createIfMissing, Subtype.SPECIMEN, Subtype.SAMPLE_HANDLING_PROTOCOL));
     219        jsonChecks.add(checkSubtype(dc, Subtype.DNA, null, createIfMissing, Subtype.LYSATE, Subtype.EXTRACTION_PROTOCOL));
     220        jsonChecks.add(checkSubtype(dc, Subtype.RNA, null, createIfMissing, Subtype.LYSATE, Subtype.EXTRACTION_PROTOCOL));
     221        jsonChecks.add(checkSubtype(dc, Subtype.FLOW_THROUGH, null, createIfMissing, Subtype.LYSATE, Subtype.EXTRACTION_PROTOCOL));
     222        jsonChecks.add(checkSubtype(dc, Subtype.QUALITY_CONTROL, null, createIfMissing));
     223        jsonChecks.add(checkSubtype(dc, Subtype.RNAQC, null, createIfMissing, Subtype.RNA, Subtype.QUALITY_CONTROL));   
     224        jsonChecks.add(checkSubtype(dc, Subtype.MRNA_PROTOCOL, null, createIfMissing));
     225        jsonChecks.add(checkSubtype(dc, Subtype.MRNA, null, createIfMissing, Subtype.RNA, Subtype.MRNA_PROTOCOL));
     226        jsonChecks.add(checkSubtype(dc, Subtype.CDNA_PROTOCOL, null, createIfMissing));
     227        jsonChecks.add(checkSubtype(dc, Subtype.CDNA, null, createIfMissing, Subtype.MRNA, Subtype.CDNA_PROTOCOL));
     228        jsonChecks.add(checkSubtype(dc, Subtype.LIBRARY_PROTOCOL, null, createIfMissing));
     229        jsonChecks.add(checkSubtype(dc, Subtype.BARCODE, null, createIfMissing));
     230        jsonChecks.add(checkSubtype(dc, Subtype.LIBRARY, null, createIfMissing, Subtype.CDNA, Subtype.BARCODE, Subtype.LIBRARY_PROTOCOL));
     231        jsonChecks.add(checkSubtype(dc, Subtype.POOLING_PROTOCOL, null, createIfMissing));
     232        jsonChecks.add(checkSubtype(dc, Subtype.POOLED_LIBRARY, null, createIfMissing, Subtype.LIBRARY, Subtype.POOLING_PROTOCOL));
     233        jsonChecks.add(checkSubtype(dc, Subtype.POOLED_LIBRARY_ALIQUOT, null, createIfMissing, Subtype.POOLED_LIBRARY));
     234        jsonChecks.add(checkSubtype(dc, Subtype.CLUSTER_PROTOCOL, null, createIfMissing));
     235        jsonChecks.add(checkSubtype(dc, Subtype.CLUSTER_GENERATOR, null, createIfMissing));
     236        jsonChecks.add(checkSubtype(dc, Subtype.FLOW_CELL, null, createIfMissing, Subtype.POOLED_LIBRARY_ALIQUOT, Subtype.CLUSTER_GENERATOR, Subtype.CLUSTER_PROTOCOL));
     237        jsonChecks.add(checkSubtype(dc, Subtype.BIOANALYZER_PDF, null, createIfMissing));
     238        jsonChecks.add(checkSubtype(dc, Subtype.CALIPER_PDF, null, createIfMissing));
     239        jsonChecks.add(checkSubtype(dc, Subtype.CALIPER_RAW_DATA, null, createIfMissing));
     240        jsonChecks.add(checkSubtype(dc, Subtype.CALIPER_WELL_TABLE, null, createIfMissing));
     241        jsonChecks.add(checkSubtype(dc, Subtype.QUBIT_CSV, null, createIfMissing));
     242        jsonChecks.add(checkSubtype(dc, Subtype.SEQUENCER, null, createIfMissing));
     243        jsonChecks.add(checkSubtype(dc, Subtype.SEQUENCING_PROTOCOL, null, createIfMissing));
     244        jsonChecks.add(checkSubtype(dc, Subtype.SEQUENCING_RUN, null, createIfMissing, Subtype.FLOW_CELL, Subtype.SEQUENCER, Subtype.SEQUENCING_PROTOCOL));
     245        jsonChecks.add(jsonSubtype_SEQUENCE_DATA);
     246        jsonChecks.add(checkSubtype(dc, Subtype.DEMUX_PROTOCOL, null, createIfMissing));
     247        jsonChecks.add(checkSubtype(dc, Subtype.DEMUX_SOFTWARE, null, createIfMissing));
     248        jsonChecks.add(checkSubtype(dc, Subtype.DEMUXED_SEQUENCES, null, createIfMissing, Subtype.SEQUENCING_RUN, Subtype.DEMUX_PROTOCOL, Subtype.DEMUX_SOFTWARE));
     249        jsonChecks.add(checkSubtype(dc, Subtype.MERGE_PROTOCOL, null, createIfMissing));
     250        jsonChecks.add(checkSubtype(dc, Subtype.MERGE_SOFTWARE, null, createIfMissing));
     251        jsonChecks.add(checkSubtype(dc, Subtype.MERGED_SEQUENCES, Datafiletype.FASTQ, createIfMissing, Subtype.DEMUXED_SEQUENCES, Subtype.LIBRARY, Subtype.MERGE_PROTOCOL, Subtype.MERGE_SOFTWARE));
     252        jsonChecks.add(checkSubtype(dc, Subtype.MASKING_PROTOCOL, null, createIfMissing));
     253        jsonChecks.add(checkSubtype(dc, Subtype.MASKING_SOFTWARE, null, createIfMissing));
     254        jsonChecks.add(checkSubtype(dc, Subtype.MASKED_SEQUENCES, null, createIfMissing, Subtype.MERGED_SEQUENCES, Subtype.LIBRARY, Subtype.MASKING_PROTOCOL, Subtype.MASKING_SOFTWARE));
     255        jsonChecks.add(checkSubtype(dc, Subtype.ALIGNMENT_PROTOCOL, null, createIfMissing));
     256        jsonChecks.add(checkSubtype(dc, Subtype.ALIGNMENT_SOFTWARE, null, createIfMissing));
     257        jsonChecks.add(checkSubtype(dc, Subtype.ALIGNED_SEQUENCES, Datafiletype.BAM, createIfMissing, Subtype.MASKED_SEQUENCES, Subtype.LIBRARY, Subtype.ALIGNMENT_PROTOCOL, Subtype.ALIGNMENT_SOFTWARE));
     258        jsonChecks.add(jsonSubtype_ALIGNED_SEQUENCE_DATA);
     259       
    247260        // Plate geometries
    248261        jsonChecks.add(checkPlateGeometry(dc, Geometry.THREE_BY_TWO, createIfMissing));
     
    548561        ));
    549562       
     563        // File servers
    550564        jsonChecks.add(checkFileServer(dc, Fileserver.PROJECT_ARCHIVE, secondaryAnalysisUse, createIfMissing));
    551565       
     
    954968    @since 2.0
    955969  */
    956   public ItemSubtype createSubtype(SessionControl sc, Subtype def, Subtype... relatedTo)
     970  public ItemSubtype createSubtype(SessionControl sc, Subtype def, Datafiletype fileType, Subtype... relatedTo)
    957971  {
    958972    ItemSubtype subtype = null;
     
    963977      subtype.setName(def.getName());
    964978      subtype.setPushAnnotations(def.getPushAnnotations());
     979     
     980      if (fileType != null)
     981      {
     982        ItemSubtypeFileType ft = subtype.getAssociatedDataFileType(fileType.load(dc), true);
     983        ft.setRequired(fileType.isRequired());
     984        ft.setAllowMultiple(fileType.getAllowMultiple());
     985      }
    965986     
    966987      if (relatedTo != null)
     
    9941015    <li>status: ok, error, or missing
    9951016    <li>message: A descriptive message in case of an error
    996     </ul>
     1017    </ul
    9971018    @since 2.0
    9981019  */
    9991020  @SuppressWarnings("unchecked")
    10001021  public JSONObject checkSubtype(DbControl dc, Subtype subtype,
    1001     boolean createIfMissing, Subtype... relatedTo)
     1022    Datafiletype fileType, boolean createIfMissing, Subtype... relatedTo)
    10021023  {
    10031024 
     
    10131034      if (createIfMissing)
    10141035      {
    1015         ItemSubtype s = createSubtype(dc.getSessionControl(), subtype, relatedTo);
     1036        ItemSubtype s = createSubtype(dc.getSessionControl(), subtype, fileType, relatedTo);
    10161037        json.put("id", s.getId());
    10171038        json.put("status", "ok");
     
    10391060        json.put("status", "error");
    10401061        jsonMessages.add("Should have 'Push annotations to parent'="+subtype.getPushAnnotations());
     1062      }
     1063     
     1064      if (fileType != null)
     1065      {
     1066        if (!s.isAssociatedDataFileType(fileType.load(dc)))
     1067        {
     1068          if (createIfMissing)
     1069          {
     1070            ItemSubtypeFileType ft = s.getAssociatedDataFileType(fileType.load(dc), true);
     1071            ft.setRequired(fileType.isRequired());
     1072            ft.setAllowMultiple(fileType.getAllowMultiple());
     1073            jsonMessages.add("Fixed");
     1074          }
     1075          else
     1076          {
     1077            json.put("status", "incomplete");
     1078            jsonMessages.add("Should be related to '" + fileType.getName() + " file type");
     1079          }
     1080        }
    10411081      }
    10421082     
     
    18991939            jsonMessages.add(uri + ": " + ex.getMessage());
    19001940            ex.printStackTrace();
     1941          }
     1942        }
     1943      }
     1944    }
     1945    if (jsonMessages.size() == 0) jsonMessages.add("Ok");
     1946    json.put("messages", jsonMessages);
     1947    return json;
     1948 
     1949  }
     1950
     1951 
     1952  /**
     1953    Create a data file type with the given options. The type is created in
     1954    a separate transaction.
     1955    @since 2.16
     1956  */
     1957  public DataFileType createDataFileType(SessionControl sc, Datafiletype def)
     1958  {
     1959    DataFileType type = null;
     1960    DbControl dc = sc.newDbControl();
     1961    try
     1962    {
     1963      type = DataFileType.getNew(dc, def.getExternalId(), def.getItemType());
     1964      type.setName(def.getName());
     1965      type.setExtension(def.getExtension());
     1966      type.setDescription(def.getDescription());
     1967      if (def.getSubtype() != null)
     1968      {
     1969        type.setGenericType(def.getSubtype().get(dc));
     1970      }
     1971      dc.saveItem(type);
     1972      dc.commit();
     1973    }
     1974    finally
     1975    {
     1976      if (dc != null) dc.close();
     1977    }
     1978    return type;
     1979  }
     1980
     1981 
     1982  /**
     1983    Check for an existing data file type with the given options.
     1984    A JSONObject is returned with the result. The following
     1985    keys are used:
     1986    <ul>
     1987    <li>itemType: DATAFILETYPE
     1988    <li>name: The name of the file type
     1989    <li>id: The id of the file type if it exists
     1990    <li>status: ok, error, or missing
     1991    <li>message: A descriptive message in case of an error
     1992    </ul>
     1993    @since 2.16
     1994  */
     1995  @SuppressWarnings("unchecked")
     1996  public JSONObject checkDataFileType(DbControl dc, Datafiletype fileType,
     1997    boolean createIfMissing)
     1998  {
     1999 
     2000    JSONObject json = new JSONObject();
     2001    JSONArray jsonMessages = new JSONArray();
     2002    json.put("itemType", Item.DATAFILETYPE.name());
     2003    json.put("name", fileType.getName());
     2004   
     2005    List<DataFileType> result = fileType.list(dc);
     2006    if (result.size() == 0)
     2007    {
     2008      if (createIfMissing)
     2009      {
     2010        DataFileType type = createDataFileType(dc.getSessionControl(), fileType);
     2011        json.put("id", type.getId());
     2012        json.put("status", "ok");
     2013        jsonMessages.add("Created");
     2014      }
     2015      else
     2016      {
     2017        json.put("status", "missing");
     2018        jsonMessages.add("Not found");
     2019      }
     2020    }
     2021    else if (result.size() > 1)
     2022    {
     2023      json.put("status", "error");
     2024      jsonMessages.add("Found > 1 MIME type");
     2025    }
     2026    else
     2027    {
     2028      DataFileType ft = result.get(0);
     2029      json.put("id", ft.getId());
     2030      json.put("status", "ok"); // For now -- more checks below
     2031     
     2032      if (!ft.getExternalId().equals(fileType.getExternalId()))
     2033      {
     2034        json.put("status", "error");
     2035        jsonMessages.add("Should have '" + fileType.getExternalId() + "' as external id.");
     2036      }
     2037     
     2038      if (!ft.getItemType().equals(fileType.getItemType()))
     2039      {
     2040        json.put("status", "error");
     2041        jsonMessages.add("Should have '" + fileType.getItemType().name() + "' as item type.");
     2042      }
     2043     
     2044      if (fileType.getSubtype() != null)
     2045      {
     2046        ItemSubtype subtype = fileType.getSubtype().get(dc);
     2047        if (subtype != null && !subtype.equals(ft.getGenericType()))
     2048        {
     2049          if (createIfMissing)
     2050          {
     2051            ft.setGenericType(fileType.getSubtype().get(dc));
     2052            jsonMessages.add("Fixed");
     2053          }
     2054          else
     2055          {
     2056            json.put("status", "warning");
     2057            jsonMessages.add("Should be related to '" + fileType.getSubtype().getName() + "' subtype.");
    19012058          }
    19022059        }
Note: See TracChangeset for help on using the changeset viewer.