Changeset 1746


Ignore:
Timestamp:
Nov 27, 2012, 1:33:11 PM (9 years ago)
Author:
Nicklas Nordborg
Message:

References #422: Implement wizards for RNA->cDNA processing

Installing 'Stratagene' as a pre-defined extract so that we can use it in the wizards.

Also updated the Rna.findRnaWithoutQc() method so that it ignores all extracts that doesn't have a creation date.

Location:
extensions/net.sf.basedb.reggie/branches/ticket-422/src/net/sf/basedb/reggie
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/branches/ticket-422/src/net/sf/basedb/reggie/dao/Rna.java

    r1745 r1746  
    5555    // Filter on id not equal to any that has a RNAQC child
    5656    query.restrict(Restrictions.neq(Hql.property("id"), Expressions.all(subquery)));
     57    // Filter on creation date (eg. to get rid of 'Stratagene')
     58    query.join(Hql.innerJoin("creationEvent", "ce"));
     59    query.restrict(Restrictions.neq(Hql.property("ce", "eventDate"), null));
    5760   
    5861    query.order(Orders.asc(Hql.property("id")));
  • extensions/net.sf.basedb.reggie/branches/ticket-422/src/net/sf/basedb/reggie/servlet/InstallServlet.java

    r1734 r1746  
    2121import net.sf.basedb.core.BioPlateType;
    2222import net.sf.basedb.core.DbControl;
     23import net.sf.basedb.core.Extract;
    2324import net.sf.basedb.core.Group;
    2425import net.sf.basedb.core.Include;
     
    3839import net.sf.basedb.core.SessionControl;
    3940import net.sf.basedb.core.SharedItem;
     41import net.sf.basedb.core.Type;
    4042import net.sf.basedb.core.plugin.Plugin;
    4143import net.sf.basedb.core.query.Expressions;
     
    142144        jsonChecks.add(checkSubtype(dc, Subtype.CDNA_PROTOCOL, createIfMissing));
    143145        jsonChecks.add(checkSubtype(dc, Subtype.CDNA, createIfMissing, Subtype.MRNA, Subtype.CDNA_PROTOCOL));
    144        
    145 
    146         // Plate geomtries
     146
     147        // Plate geometries
    147148        jsonChecks.add(checkPlateGeometry(dc, Geometry.THREE_BY_TWO, createIfMissing));
    148149        jsonChecks.add(checkPlateGeometry(dc, Geometry.ONE_BY_TWELVE, createIfMissing));
     
    160161        // MIME types
    161162        jsonChecks.add(checkMimeType(dc, Mimetype.GDX, createIfMissing));
     163       
     164        // Special items
     165        jsonChecks.add(checkExtract(dc, "Stratagene", Subtype.RNA, effectiveOptions, createIfMissing));
    162166       
    163167        // Plugin definitions and configurations
     
    10101014    json.put("mimeType", mimeType.getMimeType());
    10111015    json.put("extension", mimeType.getExtension());
    1012      
     1016   
    10131017    List<MimeType> result = mimeType.list(dc);
    10141018    if (result.size() == 0)
     
    10501054 
    10511055  }
     1056 
     1057 
     1058  /**
     1059    Create a MIME type with the given options. The type is created in
     1060    a separate transaction.
     1061    @since 2.x
     1062  */
     1063  public Extract createExtract(SessionControl sc, String name, Subtype subtype)
     1064  {
     1065    Extract extract = null;
     1066    DbControl dc = sc.newDbControl();
     1067    try
     1068    {
     1069      extract = Extract.getNew(dc);
     1070      extract.setName(name);
     1071      extract.setItemSubtype(subtype.get(dc));
     1072      dc.saveItem(extract);
     1073      dc.commit();
     1074    }
     1075    finally
     1076    {
     1077      if (dc != null) dc.close();
     1078    }
     1079    return extract;
     1080  }
     1081 
     1082  /**
     1083    Check for an existing Extract type with the given options.
     1084    A JSONObject is returned with the result. The following
     1085    keys are used:
     1086    <ul>
     1087    <li>itemType: EXTRACT
     1088    <li>name: The name of the extract
     1089    <li>id: The id of the extract if it exists
     1090    <li>status: ok, error, or missing
     1091    <li>message: A descriptive message in case of an error
     1092    </ul>
     1093    @since 2.x
     1094  */
     1095  @SuppressWarnings("unchecked")
     1096  public JSONObject checkExtract(DbControl dc, String name, Subtype subtype, PermissionOptions permissions,
     1097    boolean createIfMissing)
     1098  {
     1099 
     1100    JSONObject json = new JSONObject();
     1101    JSONArray jsonMessages = new JSONArray();
     1102    json.put("itemType", Item.EXTRACT.name());
     1103    json.put("name", name);
     1104
     1105    ItemQuery<Extract> query = Extract.getQuery();
     1106    query.setIncludes(Include.ALL);
     1107    query.restrict(
     1108      Restrictions.eq(
     1109        Hql.property("name"),
     1110        Expressions.parameter("name", name, Type.STRING)
     1111      ));
     1112   
     1113    List<Extract> result = query.list(dc);
     1114    if (result.size() == 0)
     1115    {
     1116      if (createIfMissing)
     1117      {
     1118        Extract extract = createExtract(dc.getSessionControl(), name, subtype);
     1119        json.put("id", extract.getId());
     1120        json.put("status", "ok");
     1121        jsonMessages.add("Created");
     1122      }
     1123      else
     1124      {
     1125        json.put("status", "missing");
     1126        jsonMessages.add("Not found");
     1127      }
     1128    }
     1129    else if (result.size() > 1)
     1130    {
     1131      json.put("status", "error");
     1132      jsonMessages.add("Found > 1 Extract [" + name + "]");
     1133    }
     1134    else
     1135    {
     1136      Extract e = result.get(0);
     1137      json.put("id", e.getId());
     1138      json.put("status", "ok"); // For now -- more checks below
     1139     
     1140      if (!subtype.load(dc).equals(e.getItemSubtype()))
     1141      {
     1142        json.put("status", "error");
     1143        jsonMessages.add("Should have '" + subtype.getName() + "' as subtype.");
     1144      }
     1145     
     1146      if (permissions != null && !permissions.checkPermissions(e))
     1147      {
     1148        if (createIfMissing)
     1149        {
     1150          permissions.applyPermissions(e);
     1151          if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
     1152        }
     1153        else
     1154        {
     1155          json.put("status", "incomplete");
     1156          jsonMessages.add(permissions.getMessage());
     1157        }
     1158      }
     1159     
     1160    }
     1161    if (jsonMessages.size() == 0) jsonMessages.add("Ok");
     1162    json.put("messages", jsonMessages);
     1163    return json;
     1164  }
     1165
    10521166 
    10531167  /**
Note: See TracChangeset for help on using the changeset viewer.