Changeset 5138


Ignore:
Timestamp:
Nov 22, 2018, 9:03:19 AM (8 months ago)
Author:
Nicklas Nordborg
Message:

References #1081: The release exporter should export more data

Added BloodWriter implementation. The query filter is Consent=Yes and DoNotUse=null. Consent is the only annotation that is exported so far.

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

Legend:

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

    r5088 r5138  
    22
    33import java.util.ArrayList;
     4import java.util.Collection;
    45import java.util.List;
    56
     
    351352  }
    352353 
     354  public static List<Blood> toList(Collection<Sample> samples)
     355  {
     356    List<Blood> blood = new ArrayList<Blood>(samples.size());
     357    for (Sample s : samples)
     358    {
     359      blood.add(new Blood(s));
     360    }
     361    return blood;
     362  }
     363 
    353364  private Blood(Sample sample)
    354365  {
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/release/CohortItem.java

    r5136 r5138  
    4141import net.sf.basedb.reggie.dao.AlignedSequences;
    4242import net.sf.basedb.reggie.dao.Annotationtype;
     43import net.sf.basedb.reggie.dao.Blood;
    4344import net.sf.basedb.reggie.dao.Case;
    4445import net.sf.basedb.reggie.dao.Datafiletype;
     
    8990  private Patient patient;
    9091  private List<Case> cases;
     92  private List<Blood> blood;
    9193  private List<SpecimenTube> specimens;
    9294  private List<NoSpecimen> noSpecimens;
     
    254256  }
    255257
     258  /**
     259    Get all blood sample that belong to this patient. The samples
     260    must have Consent=Yes and DoNotUse=null.
     261    @since 4.21
     262  */
     263  public List<Blood> getBlood()
     264  {
     265    if (blood == null)
     266    {
     267      ItemQuery<Sample> query = queryManager.getBloodQuery(patient);
     268      blood = query == null ? Collections.emptyList() : Blood.toList(query.list(dc));
     269    }
     270    return blood;
     271  }
     272
     273 
    256274  /**
    257275    Get all specimen that belong to this patient and have a valid Case.
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/release/QueryManager.java

    r5136 r5138  
    5050 
    5151  private ItemQuery<Sample> caseQuery;
     52  private ItemQuery<Sample> bloodQuery;
    5253  private ItemQuery<Sample> specimenQuery;
    5354  private ItemQuery<Sample> noSpecimenQuery;
     
    9495 
    9596  /**
     97    Get a query that is returning all blood items that are related to the
     98    given patient. The query is filtered to only return items with
     99    Consent=Yes and DoNotUse=null.
     100    @return A query or null if the patient is null
     101  */
     102  public ItemQuery<Sample> getBloodQuery(Patient patient)
     103  {
     104    if (patient == null) return null;
     105    if (bloodQuery == null)
     106    {
     107      bloodQuery = Sample.getQuery();
     108      initBioMaterialQuery(bloodQuery, Subtype.BLOOD, Subtype.PATIENT, ParentRestriction.SINGLE_ENTITY);
     109      annotationEquals(bloodQuery, Annotationtype.CONSENT, "Yes");
     110      annotationEquals(bloodQuery, Annotationtype.DO_NOT_USE, null);
     111    }
     112    bloodQuery.setEntityParameter("parent", patient.getItem());
     113    return bloodQuery;
     114  }
     115
     116  /**
    96117    Get a query that is returning all specimen tubes that are related
    97118    to the given list of cases. The query is filtered to only return
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/release/ReleaseExporter.java

    r5136 r5138  
    162162      jsonWriter.registerItemWriter(new NotAskedWriter(dc, options));
    163163      jsonWriter.registerItemWriter(new NoWriter(dc, options));
     164      jsonWriter.registerItemWriter(new BloodWriter(dc, options));
    164165      jsonWriter.registerItemWriter(new CaseWriter(dc, options));
    165166      jsonWriter.registerItemWriter(new IncaWriter(dc, options));
Note: See TracChangeset for help on using the changeset viewer.