extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java

Code
Comments
Other
Rev Date Author Line
1284 08 Feb 11 nicklas 1 package net.sf.basedb.reggie.servlet;
1284 08 Feb 11 nicklas 2
1284 08 Feb 11 nicklas 3 import java.io.IOException;
2562 08 Aug 14 nicklas 4 import java.net.URI;
1889 27 Feb 13 nicklas 5 import java.util.ArrayList;
1284 08 Feb 11 nicklas 6 import java.util.Arrays;
1284 08 Feb 11 nicklas 7 import java.util.Collections;
1284 08 Feb 11 nicklas 8 import java.util.HashMap;
1284 08 Feb 11 nicklas 9 import java.util.List;
1284 08 Feb 11 nicklas 10 import java.util.Map;
2159 06 Dec 13 nicklas 11 import java.util.Set;
1284 08 Feb 11 nicklas 12
1284 08 Feb 11 nicklas 13 import javax.servlet.ServletException;
1284 08 Feb 11 nicklas 14 import javax.servlet.http.HttpServlet;
1284 08 Feb 11 nicklas 15 import javax.servlet.http.HttpServletRequest;
1284 08 Feb 11 nicklas 16 import javax.servlet.http.HttpServletResponse;
1284 08 Feb 11 nicklas 17
3116 06 Feb 15 nicklas 18 import org.jdom2.Element;
1284 08 Feb 11 nicklas 19 import org.json.simple.JSONArray;
1284 08 Feb 11 nicklas 20 import org.json.simple.JSONObject;
1284 08 Feb 11 nicklas 21
7399 07 Nov 23 nicklas 22 import net.sf.basedb.core.Annotatable;
1284 08 Feb 11 nicklas 23 import net.sf.basedb.core.AnnotationType;
1463 14 Nov 11 martin 24 import net.sf.basedb.core.AnnotationTypeCategory;
6713 28 Apr 22 nicklas 25 import net.sf.basedb.core.Application;
2157 05 Dec 13 nicklas 26 import net.sf.basedb.core.BasicItem;
3247 14 Apr 15 nicklas 27 import net.sf.basedb.core.ItemList;
1865 19 Feb 13 nicklas 28 import net.sf.basedb.core.BioPlateEventType;
1543 28 Feb 12 nicklas 29 import net.sf.basedb.core.BioPlateType;
3974 26 May 16 nicklas 30 import net.sf.basedb.core.Client;
2565 11 Aug 14 nicklas 31 import net.sf.basedb.core.DataFileType;
1284 08 Feb 11 nicklas 32 import net.sf.basedb.core.DbControl;
3600 13 Nov 15 nicklas 33 import net.sf.basedb.core.Directory;
1865 19 Feb 13 nicklas 34 import net.sf.basedb.core.Extract;
2562 08 Aug 14 nicklas 35 import net.sf.basedb.core.FileServer;
1284 08 Feb 11 nicklas 36 import net.sf.basedb.core.Group;
1570 16 Mar 12 nicklas 37 import net.sf.basedb.core.Include;
1284 08 Feb 11 nicklas 38 import net.sf.basedb.core.Item;
1284 08 Feb 11 nicklas 39 import net.sf.basedb.core.ItemKey;
1570 16 Mar 12 nicklas 40 import net.sf.basedb.core.ItemNotFoundException;
1570 16 Mar 12 nicklas 41 import net.sf.basedb.core.ItemQuery;
1463 14 Nov 11 martin 42 import net.sf.basedb.core.ItemSubtype;
2565 11 Aug 14 nicklas 43 import net.sf.basedb.core.ItemSubtypeFileType;
1546 02 Mar 12 nicklas 44 import net.sf.basedb.core.MimeType;
1284 08 Feb 11 nicklas 45 import net.sf.basedb.core.MultiPermissions;
2157 05 Dec 13 nicklas 46 import net.sf.basedb.core.Nameable;
3600 13 Nov 15 nicklas 47 import net.sf.basedb.core.Path;
1284 08 Feb 11 nicklas 48 import net.sf.basedb.core.Permission;
1606 19 Apr 12 nicklas 49 import net.sf.basedb.core.PlateGeometry;
4673 08 Feb 18 nicklas 50 import net.sf.basedb.core.Platform;
4673 08 Feb 18 nicklas 51 import net.sf.basedb.core.PlatformFileType;
4673 08 Feb 18 nicklas 52 import net.sf.basedb.core.PlatformVariant;
1570 16 Mar 12 nicklas 53 import net.sf.basedb.core.PluginConfiguration;
1570 16 Mar 12 nicklas 54 import net.sf.basedb.core.PluginDefinition;
1309 04 Mar 11 nicklas 55 import net.sf.basedb.core.Project;
1310 04 Mar 11 nicklas 56 import net.sf.basedb.core.ProjectKey;
5876 24 Mar 20 nicklas 57 import net.sf.basedb.core.RawBioAssay;
1284 08 Feb 11 nicklas 58 import net.sf.basedb.core.SessionControl;
1284 08 Feb 11 nicklas 59 import net.sf.basedb.core.SharedItem;
3986 10 Jun 16 nicklas 60 import net.sf.basedb.core.SystemItems;
1865 19 Feb 13 nicklas 61 import net.sf.basedb.core.Tag;
1865 19 Feb 13 nicklas 62 import net.sf.basedb.core.Type;
1570 16 Mar 12 nicklas 63 import net.sf.basedb.core.query.Expressions;
1570 16 Mar 12 nicklas 64 import net.sf.basedb.core.query.Hql;
1570 16 Mar 12 nicklas 65 import net.sf.basedb.core.query.Restrictions;
2598 22 Aug 14 nicklas 66 import net.sf.basedb.reggie.JsonUtil;
1284 08 Feb 11 nicklas 67 import net.sf.basedb.reggie.Reggie;
4002 17 Jun 16 nicklas 68 import net.sf.basedb.reggie.Site;
3116 06 Feb 15 nicklas 69 import net.sf.basedb.reggie.XmlConfig;
5384 26 Apr 19 nicklas 70 import net.sf.basedb.reggie.activity.ActivityDef;
3059 19 Dec 14 nicklas 71 import net.sf.basedb.reggie.counter.CounterService;
1610 23 Apr 12 nicklas 72 import net.sf.basedb.reggie.dao.Annotationtype;
5865 12 Mar 20 nicklas 73 import net.sf.basedb.reggie.dao.BarcodeSet;
1865 19 Feb 13 nicklas 74 import net.sf.basedb.reggie.dao.BiomaterialList;
1865 19 Feb 13 nicklas 75 import net.sf.basedb.reggie.dao.BioplateEventtype;
1543 28 Feb 12 nicklas 76 import net.sf.basedb.reggie.dao.BioplateType;
3988 10 Jun 16 nicklas 77 import net.sf.basedb.reggie.dao.ClientApp;
2839 20 Oct 14 olle 78 import net.sf.basedb.reggie.dao.Consent;
2565 11 Aug 14 nicklas 79 import net.sf.basedb.reggie.dao.Datafiletype;
5356 12 Apr 19 nicklas 80 import net.sf.basedb.reggie.dao.Dna;
2562 08 Aug 14 nicklas 81 import net.sf.basedb.reggie.dao.Fileserver;
2412 09 May 14 nicklas 82 import net.sf.basedb.reggie.dao.FlowCell;
1606 19 Apr 12 nicklas 83 import net.sf.basedb.reggie.dao.Geometry;
2242 21 Feb 14 nicklas 84 import net.sf.basedb.reggie.dao.Histology;
1546 02 Mar 12 nicklas 85 import net.sf.basedb.reggie.dao.Mimetype;
5434 17 May 19 nicklas 86 import net.sf.basedb.reggie.dao.Pipeline;
2041 04 Oct 13 nicklas 87 import net.sf.basedb.reggie.dao.PooledLibrary;
4673 08 Feb 18 nicklas 88 import net.sf.basedb.reggie.dao.Rawdatatype;
1890 01 Mar 13 nicklas 89 import net.sf.basedb.reggie.dao.ReactionPlate;
4458 21 Apr 17 nicklas 90 import net.sf.basedb.reggie.dao.ReferenceDateSource;
2157 05 Dec 13 nicklas 91 import net.sf.basedb.reggie.dao.ReggieRole;
1889 27 Feb 13 nicklas 92 import net.sf.basedb.reggie.dao.Rna;
2225 13 Feb 14 nicklas 93 import net.sf.basedb.reggie.dao.SequencingRun;
7186 22 May 23 nicklas 94 import net.sf.basedb.reggie.dao.SpecimenTube;
1463 14 Nov 11 martin 95 import net.sf.basedb.reggie.dao.Subtype;
7341 11 Sep 23 nicklas 96 import net.sf.basedb.reggie.grid.AscatJobCreator.AllelicImbalanceTest;
4306 17 Jan 17 nicklas 97 import net.sf.basedb.reggie.grid.DemuxJobCreator;
6387 15 Sep 21 nicklas 98 import net.sf.basedb.reggie.grid.TargetedGenotypeJobCreator;
5872 23 Mar 20 nicklas 99 import net.sf.basedb.reggie.grid.VariantCallingJobCreator;
1896 05 Mar 13 nicklas 100 import net.sf.basedb.reggie.plugins.CaliperLibPrepParametersExporter;
1570 16 Mar 12 nicklas 101 import net.sf.basedb.reggie.plugins.CaliperRunParametersExporter;
1570 16 Mar 12 nicklas 102 import net.sf.basedb.reggie.plugins.CaliperSampleNameExporter;
2911 10 Nov 14 nicklas 103 import net.sf.basedb.reggie.plugins.GeneReportsCombinerPlugin;
2911 10 Nov 14 nicklas 104 import net.sf.basedb.reggie.plugins.GeneReportPlugin;
1900 07 Mar 13 nicklas 105 import net.sf.basedb.reggie.plugins.QubitSampleNameExporter;
4034 29 Jul 16 nicklas 106 import net.sf.basedb.reggie.plugins.SetPermissionsForDeliveryPlugin;
5962 03 Jun 20 nicklas 107 import net.sf.basedb.reggie.ssp.SspAnalysis;
5962 03 Jun 20 nicklas 108 import net.sf.basedb.reggie.ssp.SspInfoResult;
5962 03 Jun 20 nicklas 109 import net.sf.basedb.reggie.ssp.SspAnalysis.Info;
5962 03 Jun 20 nicklas 110 import net.sf.basedb.reggie.ssp.SspModel;
6713 28 Apr 22 nicklas 111 import net.sf.basedb.util.StaticCache;
3116 06 Feb 15 nicklas 112 import net.sf.basedb.util.Values;
1284 08 Feb 11 nicklas 113 import net.sf.basedb.util.error.ThrowableUtil;
2562 08 Aug 14 nicklas 114 import net.sf.basedb.util.uri.ConnectionManager;
2562 08 Aug 14 nicklas 115 import net.sf.basedb.util.uri.ConnectionManagerFactory;
2562 08 Aug 14 nicklas 116 import net.sf.basedb.util.uri.ConnectionManagerUtil;
2562 08 Aug 14 nicklas 117 import net.sf.basedb.util.uri.ConnectionParameters;
2562 08 Aug 14 nicklas 118 import net.sf.basedb.util.uri.UriMetadata;
1284 08 Feb 11 nicklas 119
1284 08 Feb 11 nicklas 120 /**
1284 08 Feb 11 nicklas 121   Servlet that verify and install items that are required by other Reggie actions.
1284 08 Feb 11 nicklas 122   @author nicklas
1284 08 Feb 11 nicklas 123 */
1284 08 Feb 11 nicklas 124 public class InstallServlet 
1284 08 Feb 11 nicklas 125   extends HttpServlet 
1284 08 Feb 11 nicklas 126 {
1284 08 Feb 11 nicklas 127
1284 08 Feb 11 nicklas 128   private static final long serialVersionUID = -3216326283682707833L;
1284 08 Feb 11 nicklas 129
1284 08 Feb 11 nicklas 130   public InstallServlet()
1284 08 Feb 11 nicklas 131   {}
1284 08 Feb 11 nicklas 132
1284 08 Feb 11 nicklas 133   @Override
1284 08 Feb 11 nicklas 134   protected void doGet(HttpServletRequest req, HttpServletResponse resp)
1284 08 Feb 11 nicklas 135     throws ServletException, IOException 
1284 08 Feb 11 nicklas 136   {
1284 08 Feb 11 nicklas 137     String cmd = req.getParameter("cmd");
2598 22 Aug 14 nicklas 138     JsonUtil.setJsonResponseHeaders(resp);
1284 08 Feb 11 nicklas 139     
1284 08 Feb 11 nicklas 140     JSONObject json = new JSONObject();
1284 08 Feb 11 nicklas 141     json.put("status", "ok");
1284 08 Feb 11 nicklas 142   
3974 26 May 16 nicklas 143     final SessionControl sc = Reggie.getSessionControl(req);
1284 08 Feb 11 nicklas 144     DbControl dc = null;
1284 08 Feb 11 nicklas 145     try
1284 08 Feb 11 nicklas 146     {
1284 08 Feb 11 nicklas 147       if ("Validate".equals(cmd) || "Install".equals(cmd))
1284 08 Feb 11 nicklas 148       {
6328 14 Jun 21 nicklas 149         dc = sc.newDbControl(":Installation wizard");
5026 15 Oct 18 nicklas 150         
5026 15 Oct 18 nicklas 151         ReggieRole.checkPermission(dc, "'Installation wizard'", ReggieRole.ADMINISTRATOR);
5026 15 Oct 18 nicklas 152         
1284 08 Feb 11 nicklas 153         boolean createIfMissing = "Install".equals(cmd);
1284 08 Feb 11 nicklas 154         JSONArray jsonChecks = new JSONArray();
1309 04 Mar 11 nicklas 155         
2893 04 Nov 14 nicklas 156         Reggie.getConfig();
2893 04 Nov 14 nicklas 157         
1309 04 Mar 11 nicklas 158         // Project checks
1309 04 Mar 11 nicklas 159         jsonChecks.add(checkActiveProject(dc));
1309 04 Mar 11 nicklas 160         
1284 08 Feb 11 nicklas 161         // Group checks
2157 05 Dec 13 nicklas 162         jsonChecks.add(checkReggieRole(dc, ReggieRole.PATIENT_CURATOR, createIfMissing));
2562 08 Aug 14 nicklas 163         jsonChecks.add(checkReggieRole(dc, ReggieRole.SECONDARY_ANALYSIS, createIfMissing));
5582 21 Aug 19 nicklas 164         jsonChecks.add(checkReggieRole(dc, ReggieRole.MIPS_SECONDARY_ANALYSIS, createIfMissing));
3986 10 Jun 16 nicklas 165         jsonChecks.add(checkReggieRole(dc, ReggieRole.SCANB_DELIVERY, createIfMissing));
3986 10 Jun 16 nicklas 166         jsonChecks.add(checkReggieRole(dc, ReggieRole.SCANB_LAB, createIfMissing));
1284 08 Feb 11 nicklas 167
4002 17 Jun 16 nicklas 168         for (Site s : Site.getAllSites())
4002 17 Jun 16 nicklas 169         {
4002 17 Jun 16 nicklas 170           jsonChecks.add(checkReggieRole(dc, s, createIfMissing));
4002 17 Jun 16 nicklas 171         }
4002 17 Jun 16 nicklas 172         
2157 05 Dec 13 nicklas 173         // Role checks
2157 05 Dec 13 nicklas 174         jsonChecks.add(checkReggieRole(dc, ReggieRole.ADMINISTRATOR, createIfMissing));
2157 05 Dec 13 nicklas 175         jsonChecks.add(checkReggieRole(dc, ReggieRole.SAMPLE_PREP, createIfMissing));
2157 05 Dec 13 nicklas 176         jsonChecks.add(checkReggieRole(dc, ReggieRole.HISTOLOGY, createIfMissing));
2157 05 Dec 13 nicklas 177         jsonChecks.add(checkReggieRole(dc, ReggieRole.LIBRARY_PREP, createIfMissing));
2157 05 Dec 13 nicklas 178         jsonChecks.add(checkReggieRole(dc, ReggieRole.LIBRARY_PLATE_DESIGNER, createIfMissing));
5405 08 May 19 nicklas 179         jsonChecks.add(checkReggieRole(dc, ReggieRole.MIPS_LIBRARY_PREP, createIfMissing));
5405 08 May 19 nicklas 180         jsonChecks.add(checkReggieRole(dc, ReggieRole.MIPS_PLATE_DESIGNER, createIfMissing));
3163 04 Mar 15 nicklas 181         jsonChecks.add(checkReggieRole(dc, ReggieRole.PREP_CURATOR, createIfMissing));
2157 05 Dec 13 nicklas 182
2159 06 Dec 13 nicklas 183         int projectId = dc.getSessionControl().getActiveProjectId();
2159 06 Dec 13 nicklas 184         Project activeProject = projectId == 0 ? null : Project.getById(dc, projectId);
2159 06 Dec 13 nicklas 185
2157 05 Dec 13 nicklas 186         Group patientCurator = ReggieRole.PATIENT_CURATOR.get(dc);
2168 10 Dec 13 nicklas 187         PermissionOptions patientCuratorUse = null;
2168 10 Dec 13 nicklas 188         PermissionOptions patientCuratorWrite = null;
2344 09 Apr 14 nicklas 189         PermissionOptions patientCuratorRead = null;
1284 08 Feb 11 nicklas 190         if (patientCurator != null)
1284 08 Feb 11 nicklas 191         {
2344 09 Apr 14 nicklas 192           patientCuratorRead = new PermissionOptions();
2344 09 Apr 14 nicklas 193           patientCuratorRead.set(patientCurator, Permission.READ);
2168 10 Dec 13 nicklas 194           patientCuratorUse = new PermissionOptions();
2168 10 Dec 13 nicklas 195           patientCuratorUse.set(patientCurator, Permission.USE);
2168 10 Dec 13 nicklas 196           patientCuratorWrite = new PermissionOptions();
2168 10 Dec 13 nicklas 197           patientCuratorWrite.set(patientCurator, Permission.WRITE);
2159 06 Dec 13 nicklas 198           if (activeProject != null)
2159 06 Dec 13 nicklas 199           {
2344 09 Apr 14 nicklas 200             patientCuratorRead.set(activeProject, null);
2168 10 Dec 13 nicklas 201             patientCuratorUse.set(activeProject, null);
2168 10 Dec 13 nicklas 202             patientCuratorWrite.set(activeProject, null);
2159 06 Dec 13 nicklas 203           }
1284 08 Feb 11 nicklas 204         }
1284 08 Feb 11 nicklas 205         
2562 08 Aug 14 nicklas 206         Group secondaryAnalysis = ReggieRole.SECONDARY_ANALYSIS.get(dc);
2562 08 Aug 14 nicklas 207         PermissionOptions secondaryAnalysisUse = null;
2562 08 Aug 14 nicklas 208         if (secondaryAnalysis != null)
2562 08 Aug 14 nicklas 209         {
2562 08 Aug 14 nicklas 210           secondaryAnalysisUse = new PermissionOptions();
2562 08 Aug 14 nicklas 211           secondaryAnalysisUse.set(secondaryAnalysis, Permission.USE);
2562 08 Aug 14 nicklas 212           if (activeProject != null)
2562 08 Aug 14 nicklas 213           {
2562 08 Aug 14 nicklas 214             secondaryAnalysisUse.set(activeProject, Permission.READ);
2562 08 Aug 14 nicklas 215           }
2562 08 Aug 14 nicklas 216         }
2562 08 Aug 14 nicklas 217         
2344 09 Apr 14 nicklas 218         PermissionOptions activeProjectRead = null;
2168 10 Dec 13 nicklas 219         PermissionOptions activeProjectUse = null;
2168 10 Dec 13 nicklas 220         PermissionOptions activeProjectWrite = null;
2159 06 Dec 13 nicklas 221         if (activeProject != null)
1310 04 Mar 11 nicklas 222         {
2344 09 Apr 14 nicklas 223           activeProjectRead = new PermissionOptions();
2344 09 Apr 14 nicklas 224           activeProjectRead.set(activeProject, Permission.READ);
2168 10 Dec 13 nicklas 225           activeProjectUse = new PermissionOptions();
2168 10 Dec 13 nicklas 226           activeProjectUse.set(activeProject, Permission.USE);
2168 10 Dec 13 nicklas 227           activeProjectWrite = new PermissionOptions();
2168 10 Dec 13 nicklas 228           activeProjectWrite.set(activeProject, Permission.WRITE);
1310 04 Mar 11 nicklas 229         }
1310 04 Mar 11 nicklas 230         
2344 09 Apr 14 nicklas 231         PermissionOptions effectivePermissionsRead = activeProjectRead == null ?
2344 09 Apr 14 nicklas 232             patientCuratorRead : activeProjectRead;
2168 10 Dec 13 nicklas 233         PermissionOptions effectivePermissionsUse = activeProjectUse == null ?
2168 10 Dec 13 nicklas 234             patientCuratorUse : activeProjectUse;
2168 10 Dec 13 nicklas 235         PermissionOptions effectivePermissionsWrite = activeProjectWrite == null ?
2168 10 Dec 13 nicklas 236             patientCuratorWrite : activeProjectWrite;
1463 14 Nov 11 martin 237         Map<String, Item> subtypeItems = new HashMap<String, Item>();
2565 11 Aug 14 nicklas 238
3986 10 Jun 16 nicklas 239         Group everyone = Group.getById(dc, SystemItems.getId(Group.EVERYONE));
3986 10 Jun 16 nicklas 240         PermissionOptions scanbLabUse = new PermissionOptions();;
3986 10 Jun 16 nicklas 241         scanbLabUse.set(everyone, null);
3986 10 Jun 16 nicklas 242         Group scanbLab = ReggieRole.SCANB_LAB.get(dc);
3986 10 Jun 16 nicklas 243         if (scanbLab != null)
3986 10 Jun 16 nicklas 244         {
3986 10 Jun 16 nicklas 245           scanbLabUse.set(scanbLab, Permission.USE);
3986 10 Jun 16 nicklas 246         }
3986 10 Jun 16 nicklas 247         
3986 10 Jun 16 nicklas 248         PermissionOptions scanbDeliveryUse = new PermissionOptions();
4001 17 Jun 16 nicklas 249         PermissionOptions scanbDeliveryRead = new PermissionOptions();
3986 10 Jun 16 nicklas 250         scanbDeliveryUse.set(everyone, null);
4001 17 Jun 16 nicklas 251         scanbDeliveryRead.set(everyone, null);
3986 10 Jun 16 nicklas 252         Group scanbDelivery = ReggieRole.SCANB_DELIVERY.get(dc);
3986 10 Jun 16 nicklas 253         if (scanbDelivery != null)
3986 10 Jun 16 nicklas 254         {
3986 10 Jun 16 nicklas 255           scanbDeliveryUse.set(scanbDelivery, Permission.USE);
4001 17 Jun 16 nicklas 256           scanbDeliveryRead.set(scanbDelivery, Permission.READ);
3986 10 Jun 16 nicklas 257         }
3986 10 Jun 16 nicklas 258         
6277 03 Jun 21 nicklas 259         jsonChecks.add(checkClient(dc, ClientApp.REGGIE, effectivePermissionsUse.merge(patientCuratorWrite), createIfMissing));
3988 10 Jun 16 nicklas 260         jsonChecks.add(checkClient(dc, ClientApp.SCANB_DELIVERY, scanbDeliveryUse, createIfMissing));
3988 10 Jun 16 nicklas 261         jsonChecks.add(checkClient(dc, ClientApp.WEB_CLIENT, scanbLabUse, createIfMissing));
3974 26 May 16 nicklas 262         
2565 11 Aug 14 nicklas 263         // Must check/install some file subtypes first, since they are used by 'data file types'
2565 11 Aug 14 nicklas 264         JSONObject jsonSubtype_SEQUENCE_DATA = checkSubtype(dc, Subtype.SEQUENCE_DATA, null, createIfMissing);
2565 11 Aug 14 nicklas 265         JSONObject jsonSubtype_ALIGNED_SEQUENCE_DATA = checkSubtype(dc, Subtype.ALIGNED_SEQUENCE_DATA, null, createIfMissing);
6475 05 Nov 21 nicklas 266         JSONObject jsonSubtype_GENOTYPE_CALL_FILE = checkSubtype(dc, Subtype.GENOTYPE_CALL_FILE, null, createIfMissing);
6866 14 Nov 22 nicklas 267         JSONObject jsonSubtype_IDAT_FILE = checkSubtype(dc, Subtype.IDAT, null, createIfMissing);
2565 11 Aug 14 nicklas 268
2565 11 Aug 14 nicklas 269         // Data file types
2565 11 Aug 14 nicklas 270         jsonChecks.add(checkDataFileType(dc, Datafiletype.FASTQ, createIfMissing));
2565 11 Aug 14 nicklas 271         jsonChecks.add(checkDataFileType(dc, Datafiletype.BAM, createIfMissing));
2721 01 Oct 14 nicklas 272         jsonChecks.add(checkDataFileType(dc, Datafiletype.FPKM, createIfMissing));
5706 07 Nov 19 nicklas 273         jsonChecks.add(checkDataFileType(dc, Datafiletype.VCF, createIfMissing));
6542 18 Jan 22 nicklas 274         jsonChecks.add(checkDataFileType(dc, Datafiletype.VCF_DESIGN, createIfMissing));
6475 05 Nov 21 nicklas 275         jsonChecks.add(checkDataFileType(dc, Datafiletype.GTC, createIfMissing));
6866 14 Nov 22 nicklas 276         jsonChecks.add(checkDataFileType(dc, Datafiletype.IDAT, createIfMissing));
1463 14 Nov 11 martin 277         
4673 08 Feb 18 nicklas 278         // Platforms
4673 08 Feb 18 nicklas 279         jsonChecks.add(checkPlatform(dc, Rawdatatype.STRINGTIE, createIfMissing, Datafiletype.GENERIC_RAWDATA, Datafiletype.GTF));
5706 07 Nov 19 nicklas 280         jsonChecks.add(checkPlatform(dc, Rawdatatype.VARIANT_CALL, createIfMissing, Datafiletype.VCF));
6542 18 Jan 22 nicklas 281         jsonChecks.add(checkPlatform(dc, Rawdatatype.ONCOARRAY500K, createIfMissing, Datafiletype.VCF, Datafiletype.VCF_DESIGN));
4673 08 Feb 18 nicklas 282         
1463 14 Nov 11 martin 283         // Subtype checks
2565 11 Aug 14 nicklas 284         jsonChecks.add(checkSubtype(dc, Subtype.PATIENT, null, createIfMissing));
2565 11 Aug 14 nicklas 285         jsonChecks.add(checkSubtype(dc, Subtype.NO, null, createIfMissing));
2565 11 Aug 14 nicklas 286         jsonChecks.add(checkSubtype(dc, Subtype.NOT_ASKED, null, createIfMissing));
2565 11 Aug 14 nicklas 287         jsonChecks.add(checkSubtype(dc, Subtype.CASE, null, createIfMissing, Subtype.PATIENT));
2565 11 Aug 14 nicklas 288         jsonChecks.add(checkSubtype(dc, Subtype.BLOOD, null, createIfMissing, Subtype.PATIENT));
3355 28 May 15 nicklas 289         jsonChecks.add(checkSubtype(dc, Subtype.BLOOD_DNA, null, createIfMissing, Subtype.BLOOD));
2565 11 Aug 14 nicklas 290         jsonChecks.add(checkSubtype(dc, Subtype.SPECIMEN,null, createIfMissing, Subtype.CASE));
2565 11 Aug 14 nicklas 291         jsonChecks.add(checkSubtype(dc, Subtype.NO_SPECIMEN,null, createIfMissing, Subtype.CASE));
5774 04 Dec 19 nicklas 292         jsonChecks.add(checkSubtype(dc, Subtype.TMA_SPECIMEN,null, createIfMissing, Subtype.CASE));
2565 11 Aug 14 nicklas 293         jsonChecks.add(checkSubtype(dc, Subtype.HISTOLOGY_PROTOCOL, null, createIfMissing));
2565 11 Aug 14 nicklas 294         jsonChecks.add(checkSubtype(dc, Subtype.HISTOLOGY, null, createIfMissing, Subtype.SPECIMEN, Subtype.HISTOLOGY_PROTOCOL));
2565 11 Aug 14 nicklas 295         jsonChecks.add(checkSubtype(dc, Subtype.STAINING_PROTOCOL, null, createIfMissing));
2565 11 Aug 14 nicklas 296         jsonChecks.add(checkSubtype(dc, Subtype.STAINED, null, createIfMissing, Subtype.HISTOLOGY, Subtype.STAINING_PROTOCOL));
2565 11 Aug 14 nicklas 297         jsonChecks.add(checkSubtype(dc, Subtype.SAMPLE_HANDLING_PROTOCOL, null, createIfMissing));
2565 11 Aug 14 nicklas 298         jsonChecks.add(checkSubtype(dc, Subtype.EXTRACTION_PROTOCOL, null, createIfMissing));
2565 11 Aug 14 nicklas 299         jsonChecks.add(checkSubtype(dc, Subtype.LYSATE, null, createIfMissing, Subtype.SPECIMEN, Subtype.SAMPLE_HANDLING_PROTOCOL));
2565 11 Aug 14 nicklas 300         jsonChecks.add(checkSubtype(dc, Subtype.DNA, null, createIfMissing, Subtype.LYSATE, Subtype.EXTRACTION_PROTOCOL));
5359 12 Apr 19 nicklas 301         jsonChecks.add(checkSubtype(dc, Subtype.DNA_NORMALIZATION_PROTOCOL, null, createIfMissing, Subtype.DNA));
5359 12 Apr 19 nicklas 302         jsonChecks.add(checkSubtype(dc, Subtype.DNA_NORMALIZED_ALIQUOT, null, createIfMissing, Subtype.DNA, Subtype.DNA_NORMALIZATION_PROTOCOL));
2565 11 Aug 14 nicklas 303         jsonChecks.add(checkSubtype(dc, Subtype.RNA, null, createIfMissing, Subtype.LYSATE, Subtype.EXTRACTION_PROTOCOL));
3269 23 Apr 15 nicklas 304         jsonChecks.add(checkSubtype(dc, Subtype.RNA_NORMALIZATION_PROTOCOL, null, createIfMissing, Subtype.RNA));
3269 23 Apr 15 nicklas 305         jsonChecks.add(checkSubtype(dc, Subtype.RNA_NORMALIZED_ALIQUOT, null, createIfMissing, Subtype.RNA, Subtype.RNA_NORMALIZATION_PROTOCOL));
2565 11 Aug 14 nicklas 306         jsonChecks.add(checkSubtype(dc, Subtype.FLOW_THROUGH, null, createIfMissing, Subtype.LYSATE, Subtype.EXTRACTION_PROTOCOL));
2565 11 Aug 14 nicklas 307         jsonChecks.add(checkSubtype(dc, Subtype.QUALITY_CONTROL, null, createIfMissing));
2565 11 Aug 14 nicklas 308         jsonChecks.add(checkSubtype(dc, Subtype.RNAQC, null, createIfMissing, Subtype.RNA, Subtype.QUALITY_CONTROL));    
2565 11 Aug 14 nicklas 309         jsonChecks.add(checkSubtype(dc, Subtype.MRNA_PROTOCOL, null, createIfMissing));
2898 05 Nov 14 nicklas 310         jsonChecks.add(checkSubtype(dc, Subtype.MRNA, null, createIfMissing, Subtype.RNA_NORMALIZED_ALIQUOT, Subtype.MRNA_PROTOCOL));
2565 11 Aug 14 nicklas 311         jsonChecks.add(checkSubtype(dc, Subtype.CDNA_PROTOCOL, null, createIfMissing));
2565 11 Aug 14 nicklas 312         jsonChecks.add(checkSubtype(dc, Subtype.CDNA, null, createIfMissing, Subtype.MRNA, Subtype.CDNA_PROTOCOL));
2565 11 Aug 14 nicklas 313         jsonChecks.add(checkSubtype(dc, Subtype.LIBRARY_PROTOCOL, null, createIfMissing));
2565 11 Aug 14 nicklas 314         jsonChecks.add(checkSubtype(dc, Subtype.BARCODE, null, createIfMissing));
2565 11 Aug 14 nicklas 315         jsonChecks.add(checkSubtype(dc, Subtype.LIBRARY, null, createIfMissing, Subtype.CDNA, Subtype.BARCODE, Subtype.LIBRARY_PROTOCOL)); 
2565 11 Aug 14 nicklas 316         jsonChecks.add(checkSubtype(dc, Subtype.POOLING_PROTOCOL, null, createIfMissing));
2565 11 Aug 14 nicklas 317         jsonChecks.add(checkSubtype(dc, Subtype.POOLED_LIBRARY, null, createIfMissing, Subtype.LIBRARY, Subtype.POOLING_PROTOCOL)); 
2565 11 Aug 14 nicklas 318         jsonChecks.add(checkSubtype(dc, Subtype.POOLED_LIBRARY_ALIQUOT, null, createIfMissing, Subtype.POOLED_LIBRARY)); 
2565 11 Aug 14 nicklas 319         jsonChecks.add(checkSubtype(dc, Subtype.CLUSTER_PROTOCOL, null, createIfMissing));
2565 11 Aug 14 nicklas 320         jsonChecks.add(checkSubtype(dc, Subtype.CLUSTER_GENERATOR, null, createIfMissing));
2565 11 Aug 14 nicklas 321         jsonChecks.add(checkSubtype(dc, Subtype.FLOW_CELL, null, createIfMissing, Subtype.POOLED_LIBRARY_ALIQUOT, Subtype.CLUSTER_GENERATOR, Subtype.CLUSTER_PROTOCOL)); 
6461 01 Nov 21 nicklas 322         jsonChecks.add(checkSubtype(dc, Subtype.BEAD_CHIP, null, createIfMissing, Subtype.BLOOD_DNA)); 
6477 05 Nov 21 nicklas 323         jsonChecks.add(checkSubtype(dc, Subtype.SCANNER, null, createIfMissing));
6477 05 Nov 21 nicklas 324         jsonChecks.add(checkSubtype(dc, Subtype.SCAN, null, createIfMissing, Subtype.BEAD_CHIP, Subtype.SCANNER));
6475 05 Nov 21 nicklas 325         jsonChecks.add(checkSubtype(dc, Subtype.GENOTYPING_SOFTWARE, null, createIfMissing));
6475 05 Nov 21 nicklas 326         jsonChecks.add(jsonSubtype_GENOTYPE_CALL_FILE);
6475 05 Nov 21 nicklas 327         jsonChecks.add(checkSubtype(dc, Subtype.GENOTYPE_CALL, Datafiletype.GTC, createIfMissing, Subtype.SCAN, Subtype.GENOTYPING_SOFTWARE)); 
6866 14 Nov 22 nicklas 328         jsonChecks.add(checkSubtype(dc, Subtype.METHYLATION_SOFTWARE, null, createIfMissing));
6866 14 Nov 22 nicklas 329         jsonChecks.add(jsonSubtype_IDAT_FILE);
6866 14 Nov 22 nicklas 330         jsonChecks.add(checkSubtype(dc, Subtype.METHYLATION, Datafiletype.IDAT, createIfMissing, Subtype.SCAN, Subtype.METHYLATION_SOFTWARE));
6870 16 Nov 22 nicklas 331         jsonChecks.add(checkSubtype(dc, Subtype.METHYLATION_BETA_JOB, null, createIfMissing));
2565 11 Aug 14 nicklas 332         jsonChecks.add(checkSubtype(dc, Subtype.BIOANALYZER_PDF, null, createIfMissing));
2565 11 Aug 14 nicklas 333         jsonChecks.add(checkSubtype(dc, Subtype.CALIPER_PDF, null, createIfMissing));
2565 11 Aug 14 nicklas 334         jsonChecks.add(checkSubtype(dc, Subtype.CALIPER_RAW_DATA, null, createIfMissing));
2565 11 Aug 14 nicklas 335         jsonChecks.add(checkSubtype(dc, Subtype.CALIPER_WELL_TABLE, null, createIfMissing));
2565 11 Aug 14 nicklas 336         jsonChecks.add(checkSubtype(dc, Subtype.QUBIT_CSV, null, createIfMissing));
2565 11 Aug 14 nicklas 337         jsonChecks.add(checkSubtype(dc, Subtype.SEQUENCER, null, createIfMissing));
2565 11 Aug 14 nicklas 338         jsonChecks.add(checkSubtype(dc, Subtype.SEQUENCING_PROTOCOL, null, createIfMissing));
2565 11 Aug 14 nicklas 339         jsonChecks.add(checkSubtype(dc, Subtype.SEQUENCING_RUN, null, createIfMissing, Subtype.FLOW_CELL, Subtype.SEQUENCER, Subtype.SEQUENCING_PROTOCOL));
4325 30 Jan 17 nicklas 340         jsonChecks.add(checkSubtype(dc, Subtype.SEQUENCING_RUN_JOB, null, createIfMissing));
2565 11 Aug 14 nicklas 341         jsonChecks.add(jsonSubtype_SEQUENCE_DATA);
2565 11 Aug 14 nicklas 342         jsonChecks.add(checkSubtype(dc, Subtype.DEMUX_PROTOCOL, null, createIfMissing));
2565 11 Aug 14 nicklas 343         jsonChecks.add(checkSubtype(dc, Subtype.DEMUX_SOFTWARE, null, createIfMissing));
7053 21 Feb 23 nicklas 344         jsonChecks.add(checkSubtype(dc, Subtype.DEMUXED_SEQUENCES, Datafiletype.FASTQ, createIfMissing, Subtype.SEQUENCING_RUN, Subtype.DEMUX_PROTOCOL, Subtype.DEMUX_SOFTWARE));
2565 11 Aug 14 nicklas 345         jsonChecks.add(checkSubtype(dc, Subtype.MERGE_PROTOCOL, null, createIfMissing));
2565 11 Aug 14 nicklas 346         jsonChecks.add(checkSubtype(dc, Subtype.MERGE_SOFTWARE, null, createIfMissing));
2565 11 Aug 14 nicklas 347         jsonChecks.add(checkSubtype(dc, Subtype.MERGED_SEQUENCES, Datafiletype.FASTQ, createIfMissing, Subtype.DEMUXED_SEQUENCES, Subtype.LIBRARY, Subtype.MERGE_PROTOCOL, Subtype.MERGE_SOFTWARE));
4325 30 Jan 17 nicklas 348         jsonChecks.add(checkSubtype(dc, Subtype.DEMUX_MERGE_JOB, null, createIfMissing));
6181 25 Mar 21 nicklas 349         jsonChecks.add(checkSubtype(dc, Subtype.FASTQ_IMPORT_JOB, null, createIfMissing));
2565 11 Aug 14 nicklas 350         jsonChecks.add(checkSubtype(dc, Subtype.MASKING_PROTOCOL, null, createIfMissing));
2565 11 Aug 14 nicklas 351         jsonChecks.add(checkSubtype(dc, Subtype.MASKING_SOFTWARE, null, createIfMissing));
2565 11 Aug 14 nicklas 352         jsonChecks.add(checkSubtype(dc, Subtype.MASKED_SEQUENCES, null, createIfMissing, Subtype.MERGED_SEQUENCES, Subtype.LIBRARY, Subtype.MASKING_PROTOCOL, Subtype.MASKING_SOFTWARE));
2565 11 Aug 14 nicklas 353         jsonChecks.add(checkSubtype(dc, Subtype.ALIGNMENT_PROTOCOL, null, createIfMissing));
2565 11 Aug 14 nicklas 354         jsonChecks.add(checkSubtype(dc, Subtype.ALIGNMENT_SOFTWARE, null, createIfMissing));
7268 22 Jun 23 nicklas 355         jsonChecks.add(checkSubtype(dc, Subtype.COPY_NUMBER, null, createIfMissing, Subtype.ALIGNED_SEQUENCES, Subtype.COPY_NUMBER_SOFTWARE));
7267 21 Jun 23 nicklas 356         jsonChecks.add(checkSubtype(dc, Subtype.COPY_NUMBER_SOFTWARE, null, createIfMissing));
7268 22 Jun 23 nicklas 357         jsonChecks.add(checkSubtype(dc, Subtype.ASCAT_JOB, null, createIfMissing));
2565 11 Aug 14 nicklas 358         jsonChecks.add(checkSubtype(dc, Subtype.ALIGNED_SEQUENCES, Datafiletype.BAM, createIfMissing, Subtype.MASKED_SEQUENCES, Subtype.LIBRARY, Subtype.ALIGNMENT_PROTOCOL, Subtype.ALIGNMENT_SOFTWARE));
7388 31 Oct 23 nicklas 359         jsonChecks.add(checkSubtype(dc, Subtype.PANEL_OF_NORMAL, null, createIfMissing, Subtype.ALIGNED_SEQUENCES, Subtype.LIBRARY, Subtype.VARIANT_CALLING_SOFTWARE));
4325 30 Jan 17 nicklas 360         jsonChecks.add(checkSubtype(dc, Subtype.MASK_ALIGN_JOB, null, createIfMissing));
4325 30 Jan 17 nicklas 361         jsonChecks.add(checkSubtype(dc, Subtype.CUFFLINKS_JOB, null, createIfMissing));
4543 27 Jun 17 nicklas 362         jsonChecks.add(checkSubtype(dc, Subtype.TOPHAT_CUFFLINKS_JOB, null, createIfMissing));
4588 25 Sep 17 nicklas 363         jsonChecks.add(checkSubtype(dc, Subtype.HISAT_ALIGN_JOB, null, createIfMissing));
7085 31 Mar 23 nicklas 364         jsonChecks.add(checkSubtype(dc, Subtype.BWA_MEM2_ALIGN_JOB, null, createIfMissing));
5826 18 Feb 20 nicklas 365         jsonChecks.add(checkSubtype(dc, Subtype.MIPS_ALIGN_JOB, null, createIfMissing));
4664 30 Jan 18 nicklas 366         jsonChecks.add(checkSubtype(dc, Subtype.STRINGTIE_JOB, null, createIfMissing));
5057 29 Oct 18 nicklas 367         jsonChecks.add(checkSubtype(dc, Subtype.VARIANT_CALLING_SOFTWARE, null, createIfMissing));
5032 16 Oct 18 nicklas 368         jsonChecks.add(checkSubtype(dc, Subtype.MBAF_JOB, null, createIfMissing));
5684 25 Oct 19 nicklas 369         jsonChecks.add(checkSubtype(dc, Subtype.VARIANT_CALLING_JOB, null, createIfMissing));
5772 03 Dec 19 nicklas 370         jsonChecks.add(checkSubtype(dc, Subtype.VARIANT_STATISTICS_JOB, null, createIfMissing));
6387 15 Sep 21 nicklas 371         jsonChecks.add(checkSubtype(dc, Subtype.TARGETED_GENOTYPING_JOB, null, createIfMissing));
5922 27 Apr 20 nicklas 372         jsonChecks.add(checkSubtype(dc, Subtype.SSP_JOB, null, createIfMissing));
3616 23 Nov 15 nicklas 373         jsonChecks.add(checkSubtype(dc, Subtype.REPORT_SOFTWARE, null, createIfMissing));
4325 30 Jan 17 nicklas 374         jsonChecks.add(checkSubtype(dc, Subtype.REPORT_JOB, null, createIfMissing));
2839 20 Oct 14 olle 375         jsonChecks.add(checkSubtype(dc, Subtype.RETRACT, null, createIfMissing));
2839 20 Oct 14 olle 376         jsonChecks.add(checkSubtype(dc, Subtype.RETRO_NO, null, createIfMissing));
2565 11 Aug 14 nicklas 377         jsonChecks.add(jsonSubtype_ALIGNED_SEQUENCE_DATA);
4619 13 Nov 17 nicklas 378         jsonChecks.add(checkSubtype(dc, Subtype.VARIANT_CALL_FORMAT, null, createIfMissing));
2721 01 Oct 14 nicklas 379         jsonChecks.add(checkSubtype(dc, Subtype.RAW_DATA, null, createIfMissing));
3640 02 Dec 15 nicklas 380         jsonChecks.add(checkSubtype(dc, Subtype.FREEZER, null, createIfMissing));
3640 02 Dec 15 nicklas 381       
1865 19 Feb 13 nicklas 382         // Plate geometries
1666 23 May 12 nicklas 383         jsonChecks.add(checkPlateGeometry(dc, Geometry.THREE_BY_TWO, createIfMissing));
1606 19 Apr 12 nicklas 384         jsonChecks.add(checkPlateGeometry(dc, Geometry.ONE_BY_TWELVE, createIfMissing));
6474 04 Nov 21 nicklas 385         jsonChecks.add(checkPlateGeometry(dc, Geometry.ONE_BY_EIGHT, createIfMissing));
1606 19 Apr 12 nicklas 386         jsonChecks.add(checkPlateGeometry(dc, Geometry.NINE_BY_NINE, createIfMissing));
1606 19 Apr 12 nicklas 387         jsonChecks.add(checkPlateGeometry(dc, Geometry.EIGHT_BY_TWELVE, createIfMissing));
3284 29 Apr 15 nicklas 388         jsonChecks.add(checkPlateGeometry(dc, Geometry.EIGHT_BY_TWO, createIfMissing));
1606 19 Apr 12 nicklas 389         
1543 28 Feb 12 nicklas 390         // Bioplate types
3640 02 Dec 15 nicklas 391         jsonChecks.add(checkBioplateType(dc, BioplateType.STORAGE_BOX, createIfMissing));
1543 28 Feb 12 nicklas 392         jsonChecks.add(checkBioplateType(dc, BioplateType.BA_RNAQC, createIfMissing));
1543 28 Feb 12 nicklas 393         jsonChecks.add(checkBioplateType(dc, BioplateType.CALIPER_RNAQC, createIfMissing));
5361 15 Apr 19 nicklas 394         jsonChecks.add(checkBioplateType(dc, BioplateType.PRE_NORMALIZED_DNA, createIfMissing));
1606 19 Apr 12 nicklas 395         jsonChecks.add(checkBioplateType(dc, BioplateType.PARAFFIN_BLOCK, createIfMissing));
1668 25 May 12 nicklas 396         jsonChecks.add(checkBioplateType(dc, BioplateType.HE_GLASS, createIfMissing));
1865 19 Feb 13 nicklas 397         jsonChecks.add(checkBioplateType(dc, BioplateType.MRNA, createIfMissing));
1865 19 Feb 13 nicklas 398         jsonChecks.add(checkBioplateType(dc, BioplateType.CDNA, createIfMissing));
1893 04 Mar 13 nicklas 399         jsonChecks.add(checkBioplateType(dc, BioplateType.LIBRARY, createIfMissing));
5867 18 Mar 20 nicklas 400         jsonChecks.add(checkBioplateType(dc, BioplateType.EXTERNAL_LIBRARY, createIfMissing));
6474 04 Nov 21 nicklas 401         jsonChecks.add(checkBioplateType(dc, BioplateType.EXTERNAL_LIBRARY_STRIP, createIfMissing));
3284 29 Apr 15 nicklas 402         jsonChecks.add(checkBioplateType(dc, BioplateType.NEOPREP, createIfMissing));
5390 29 Apr 19 nicklas 403         jsonChecks.add(checkBioplateType(dc, BioplateType.MIPS, createIfMissing));
5429 16 May 19 nicklas 404         jsonChecks.add(checkBioplateType(dc, BioplateType.BARCODE_TEMPLATE, createIfMissing));
1865 19 Feb 13 nicklas 405
1865 19 Feb 13 nicklas 406         // Bioplate event types
1463 14 Nov 11 martin 407         
1310 04 Mar 11 nicklas 408         // Annotation type checks 
1310 04 Mar 11 nicklas 409         // -- the first batch need to be shared to the PatientCurator group
4001 17 Jun 16 nicklas 410         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PERSONAL_NUMBER, 1, null, createIfMissing, patientCuratorUse, scanbDeliveryRead));
4001 17 Jun 16 nicklas 411         jsonChecks.add(checkAnnotationType(dc, Annotationtype.FAMILY_NAME, 1, null, createIfMissing, patientCuratorUse, scanbDeliveryRead));
4001 17 Jun 16 nicklas 412         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ALL_FIRST_NAMES, 1, null, createIfMissing, patientCuratorUse, scanbDeliveryRead));
1310 04 Mar 11 nicklas 413         
1310 04 Mar 11 nicklas 414         // -- the second batch need only be shared to the active project or to the PatientCurator group
6197 06 Apr 21 nicklas 415         jsonChecks.add(checkAnnotationType(dc, Annotationtype.EXTERNAL_REF, 1, null, createIfMissing, effectivePermissionsUse));
6926 02 Dec 22 nicklas 416         jsonChecks.add(checkAnnotationType(dc, Annotationtype.IMPORT_WARNINGS, 0, null, createIfMissing, patientCuratorUse));
7168 12 May 23 nicklas 417         jsonChecks.add(checkAnnotationType(dc, Annotationtype.TRANSPORT_MESSAGES, 0, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 418         jsonChecks.add(checkAnnotationType(dc, Annotationtype.DATE_OF_BIRTH, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 419         jsonChecks.add(checkAnnotationType(dc, Annotationtype.GENDER, 1, new ValueOptions("F", "M"), createIfMissing, effectivePermissionsUse));
4512 31 May 17 nicklas 420         jsonChecks.add(checkAnnotationType(dc, Annotationtype.LIASON_COMMENT, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 421         jsonChecks.add(checkAnnotationType(dc, Annotationtype.LATERALITY, 1, new ValueOptions("LEFT", "RIGHT"), createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 422         jsonChecks.add(checkAnnotationType(dc, Annotationtype.REASON_IF_NO_SPECIMEN, 1, null, createIfMissing, effectivePermissionsUse));
6574 08 Feb 22 nicklas 423         jsonChecks.add(checkAnnotationType(dc, Annotationtype.EXTERNAL_SPECIMEN_EXISTS, 1, new ValueOptions("Yes", "No"), createIfMissing, effectivePermissionsUse));
6918 01 Dec 22 nicklas 424         jsonChecks.add(checkAnnotationType(dc, Annotationtype.EXTERNAL_STORAGE, 1, null, createIfMissing, effectivePermissionsUse));
7186 22 May 23 nicklas 425         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MOVE_DATE, 1, null, createIfMissing, effectivePermissionsUse));
7186 22 May 23 nicklas 426         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MOVE_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
4037 29 Jul 16 nicklas 427         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PAD, 1,  null, createIfMissing, patientCuratorUse, scanbDeliveryRead));
6990 19 Jan 23 nicklas 428         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ALTERNATE_PAD, 1,  null, createIfMissing, patientCuratorUse));
6711 27 Apr 22 nicklas 429         jsonChecks.add(checkAnnotationType(dc, Annotationtype.TUBE_LABEL, 1,  null, createIfMissing, effectivePermissionsUse));
1608 20 Apr 12 nicklas 430         
4001 17 Jun 16 nicklas 431         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RETRACT_NA_LAB, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 432         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RETRACT_TX_LAB, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 433         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RETRACT_RX_LAB, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 434         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RETRACT_NA_BB, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 435         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RETRACT_TX_BB, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 436         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RETRACT_RX_BB, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 437         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RETRACT_NA_FROZEN, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 438         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RETRACT_TX_FROZEN, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 439         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RETRACT_RX_FROZEN, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 440         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RETRACT_NA_RCC_SYD, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 441         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RETRACT_TX_RCC_SYD, 1, null, createIfMissing, effectivePermissionsUse));
5637 03 Oct 19 nicklas 442         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RETRACT_STATUS, 1, new ValueOptions("ReadyForDestruction", "RetractionCompleted", "Destroyed"), createIfMissing, effectivePermissionsUse));
3085 15 Jan 15 olle 443
4001 17 Jun 16 nicklas 444         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BLOOD_SAMPLING_DATETIME, 1,null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 445         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BLOOD_FREEZER_DATETIME, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 446         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BLOOD_SERUM, 1, new ValueOptions("Yes", "No"), createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 447         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BLOOD_SAMPLE, 1, new ValueOptions("PreNeo", "PreOp", "FollowUp06", "FollowUp12", "FollowUp36"), createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 448         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BLOOD_RCCIDNUMBER, 1, null, createIfMissing, effectivePermissionsUse));
6277 03 Jun 21 nicklas 449         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BD47_ID, 1, null, createIfMissing, effectivePermissionsUse));
1614 24 Apr 12 nicklas 450
4001 17 Jun 16 nicklas 451         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SAMPLING_DATETIME, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 452         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RNALATER_DATETIME, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 453         jsonChecks.add(checkAnnotationType(dc, Annotationtype.CONSENT, 1, new ValueOptions("Yes", "No", "Not asked"), createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 454         jsonChecks.add(checkAnnotationType(dc, Annotationtype.CONSENT_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4458 21 Apr 17 nicklas 455         jsonChecks.add(checkAnnotationType(dc, Annotationtype.REFERENCE_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4458 21 Apr 17 nicklas 456         
4458 21 Apr 17 nicklas 457         Object[] refDateSources = new Object[ReferenceDateSource.values().length];
4458 21 Apr 17 nicklas 458         for (int i = 0; i < ReferenceDateSource.values().length; i++)
4458 21 Apr 17 nicklas 459         {
4458 21 Apr 17 nicklas 460           refDateSources[i] = ReferenceDateSource.values()[i].getTitle();
4458 21 Apr 17 nicklas 461         }
4458 21 Apr 17 nicklas 462         jsonChecks.add(checkAnnotationType(dc, Annotationtype.REFERENCE_DATE_SOURCE, 1, 
4458 21 Apr 17 nicklas 463           new ValueOptions(refDateSources), createIfMissing, effectivePermissionsUse));
6098 11 Jan 21 nicklas 464         jsonChecks.add(checkAnnotationType(dc, Annotationtype.LINKED_CASE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 465         jsonChecks.add(checkAnnotationType(dc, Annotationtype.FROZEN_TISSUE_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 466         jsonChecks.add(checkAnnotationType(dc, Annotationtype.INCA_EXPORT_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 467         jsonChecks.add(checkAnnotationType(dc, Annotationtype.INCA_IMPORT_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 468         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ARRIVAL_DATE, 1, null, createIfMissing, effectivePermissionsUse, scanbDeliveryRead));
4001 17 Jun 16 nicklas 469         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NOF_DELIVERED_TUBES, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 470         jsonChecks.add(checkAnnotationType(dc, Annotationtype.OPERATOR_DELIVERY_COMMENT, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 471         jsonChecks.add(checkAnnotationType(dc, Annotationtype.OTHER_PATH_NOTE, 1, null, createIfMissing, effectivePermissionsUse));
3602 16 Nov 15 nicklas 472         jsonChecks.add(checkAnnotationType(dc, Annotationtype.YELLOW_LABEL, 1, 
3602 16 Nov 15 nicklas 473             new ValueOptions("yellow"), 
4001 17 Jun 16 nicklas 474             createIfMissing, effectivePermissionsUse, scanbDeliveryRead));
4040 29 Jul 16 nicklas 475         jsonChecks.add(checkAnnotationType(dc, Annotationtype.COMPLETED_DATE, 1, null, createIfMissing, effectivePermissionsUse, scanbDeliveryRead));
1610 23 Apr 12 nicklas 476         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SPECIMEN_TYPE, 1,
2801 13 Oct 14 nicklas 477             new ValueOptions("Primary", "LymphnodeRegional", "MetastasisDistant", "RecurrenceLocal", "RecurrenceRegional", "Normal", "Uncertain"), 
4001 17 Jun 16 nicklas 478             createIfMissing, effectivePermissionsUse));
1610 23 Apr 12 nicklas 479         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BIOPSY_TYPE, 1,
2840 20 Oct 14 nicklas 480             new ValueOptions("SpecimenSurgery", "SpecimenCoreBiopsy", "SpecimenCoreBiopsy2nd", "SpecimenFineNeedleAspiration"), 
4001 17 Jun 16 nicklas 481             createIfMissing, effectivePermissionsUse));
3394 12 Jun 15 nicklas 482         jsonChecks.add(checkAnnotationType(dc, Annotationtype.LINKED_SPECIMEN, 1,
3481 09 Sep 15 nicklas 483             new ValueOptions("IpsilateralCoreBiopsy", "ContralateralCoreBiopsy", "IpsilateralSample", "ContralateralSample", "MissingDate"), 
4001 17 Jun 16 nicklas 484             createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 485         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NOF_PIECES, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 486         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MULTIPLE_PIECES, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 487         jsonChecks.add(checkAnnotationType(dc, Annotationtype.OPERATOR_PARTITION_COMMENT, 1, null, createIfMissing, effectivePermissionsUse));        
4001 17 Jun 16 nicklas 488         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PARTITION_DATE, 1, null, createIfMissing, effectivePermissionsUse));
1639 09 May 12 nicklas 489
5774 04 Dec 19 nicklas 490         jsonChecks.add(checkAnnotationType(dc, Annotationtype.TMA_BLOCK, 1, null, createIfMissing, effectivePermissionsUse));
5774 04 Dec 19 nicklas 491         jsonChecks.add(checkAnnotationType(dc, Annotationtype.TMA_BLOCK_POS, 1, null, createIfMissing, effectivePermissionsUse));
5799 18 Dec 19 nicklas 492         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PAD_REQUESTED, 1,  null, createIfMissing, patientCuratorUse));
5798 18 Dec 19 nicklas 493         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SAMPLE_OWNER, 1, null, createIfMissing, effectivePermissionsUse));
5774 04 Dec 19 nicklas 494
4001 17 Jun 16 nicklas 495         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RLT_PLUS, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 496         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BETA_MERCA, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 497         jsonChecks.add(checkAnnotationType(dc, Annotationtype.REAGENT_DX, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 498         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QIA_SHREDDER, 1, null, createIfMissing, effectivePermissionsUse));
2690 24 Sep 14 nicklas 499
4001 17 Jun 16 nicklas 500         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ALLPREP_MINI_KIT, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 501         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ETOH70, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 502         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BUFFER_RW1, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 503         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BUFFER_RPE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 504         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BUFFER_AW1, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 505         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BUFFER_AW2, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 506         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BUFFER_EB, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 507         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RNASE_FREE_WATER, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 508         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ALLPREP_DNA_COL, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 509         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RNEASY_COL, 1, null, createIfMissing, effectivePermissionsUse));
2690 24 Sep 14 nicklas 510         
4001 17 Jun 16 nicklas 511         jsonChecks.add(checkAnnotationType(dc, Annotationtype.EMBED_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 512         jsonChecks.add(checkAnnotationType(dc, Annotationtype.GOOD_STAIN, 1, null, createIfMissing, effectivePermissionsUse));
3121 06 Feb 15 nicklas 513         jsonChecks.add(checkAnnotationType(dc, Annotationtype.IHC, 1, 
3121 06 Feb 15 nicklas 514             new ValueOptions("p63"),
4001 17 Jun 16 nicklas 515             createIfMissing, effectivePermissionsUse));
3169 06 Mar 15 nicklas 516         jsonChecks.add(checkAnnotationType(dc, Annotationtype.IHC_QUALITY, 1, 
3549 19 Oct 15 nicklas 517             new ValueOptions("Good", "Fail", "Inconclusive"),
4001 17 Jun 16 nicklas 518             createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 519         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SCORE_COMPLETE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 520         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SCORE_INVASIVE_CANCER, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 521         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SCORE_INSITU_CANCER, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 522         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SCORE_LYMPHOCYTES, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 523         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SCORE_NORMAL, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 524         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SCORE_STROMA, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 525         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SCORE_FAT, 1, null, createIfMissing, effectivePermissionsUse));
1668 25 May 12 nicklas 526         
4001 17 Jun 16 nicklas 527         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RESERVED_BY, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 528         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QIACUBE_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 529         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QIACUBE_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 530         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QIACUBE_POSITION, 1, new ValueOptions(1, 12), createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 531         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QIACUBE_RUN_NO, 1, new ValueOptions(1, null), createIfMissing, effectivePermissionsUse));
6510 03 Dec 21 nicklas 532         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QIACUBE_RUN_ID, 1, null, createIfMissing, effectivePermissionsUse));
1639 09 May 12 nicklas 533         
4001 17 Jun 16 nicklas 534         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QC_RUN_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 535         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QC_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 536         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QC_HISENSE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 537         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BA_RIN, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 538         jsonChecks.add(checkAnnotationType(dc, Annotationtype.CA_RQS, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 539         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ND_CONC, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 540         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ND_260_BY_280, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 541         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ND_260_BY_230, 1, null, createIfMissing, effectivePermissionsUse));
1409 18 Oct 11 martin 542         
4001 17 Jun 16 nicklas 543         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RNA_TARGET_AMOUNT, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 544         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RNA_MINIMAL_AMOUNT, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 545         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RNA_TARGET_VOLUME, 1, null, createIfMissing, effectivePermissionsUse));
5359 12 Apr 19 nicklas 546         jsonChecks.add(checkAnnotationType(dc, Annotationtype.DNA_TARGET_AMOUNT, 1, null, createIfMissing, effectivePermissionsUse));
5359 12 Apr 19 nicklas 547         jsonChecks.add(checkAnnotationType(dc, Annotationtype.DNA_MINIMAL_AMOUNT, 1, null, createIfMissing, effectivePermissionsUse));
5359 12 Apr 19 nicklas 548         jsonChecks.add(checkAnnotationType(dc, Annotationtype.DNA_TARGET_VOLUME, 1, null, createIfMissing, effectivePermissionsUse));
5899 15 Apr 20 nicklas 549         jsonChecks.add(checkAnnotationType(dc, Annotationtype.LIBPREP_TARGET, 0, 
5899 15 Apr 20 nicklas 550             new ValueOptions("Manual", "NeoPrep", "MIPs", "External"), createIfMissing, effectivePermissionsUse));
5434 17 May 19 nicklas 551         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PIPELINE, 1, 
5546 07 Aug 19 nicklas 552             new ValueOptions(Pipeline.RNA_SEQ.getName(), Pipeline.MIPS.getName(), 
5725 13 Nov 19 nicklas 553               Pipeline.RNASEQ_LEGACY.getName(), Pipeline.RNASEQ_HISAT_STRINGTIE.getName(),
6811 25 Aug 22 nicklas 554               Pipeline.RNASEQ_HISAT_2023.getName(), Pipeline.RNASEQ_STRINGTIE_2023.getName(),
6865 09 Nov 22 nicklas 555               Pipeline.RNASEQ_HISAT_VARIANTCALL.getName(), Pipeline.DNA_GENOTYPING.getName(),
7054 21 Feb 23 nicklas 556               Pipeline.DNA_METHYLATION.getName(), Pipeline.DNA_TUMOR_WGS.getName(),
7411 10 Nov 23 nicklas 557               Pipeline.DNA_NORMAL_WGS.getName(), Pipeline.DNA_PAIRED_VARIANTCALL.getName()), 
5434 17 May 19 nicklas 558             createIfMissing, effectivePermissionsUse));
3269 23 Apr 15 nicklas 559         
5601 13 Sep 19 nicklas 560         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MIPS_PANEL, 1, null, createIfMissing, effectivePermissionsUse));
5447 24 May 19 nicklas 561         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MIPS_POOL_VOLUME, 1, null, createIfMissing, effectivePermissionsUse));
5447 24 May 19 nicklas 562         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MIPS_NORMAL_TUMOR, 1, 
5447 24 May 19 nicklas 563             new ValueOptions("N", "T"), createIfMissing, effectivePermissionsUse));
5447 24 May 19 nicklas 564         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MIPS_FORM, 1, null, createIfMissing, effectivePermissionsUse));
5447 24 May 19 nicklas 565         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MIPS_VARIANT, 1, null, createIfMissing, effectivePermissionsUse));
5447 24 May 19 nicklas 566         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MIPS_VARIANT_LIST, 1, null, createIfMissing, effectivePermissionsUse));
5447 24 May 19 nicklas 567         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MIPS_SCREENING, 1, null, createIfMissing, effectivePermissionsUse));
5663 11 Oct 19 nicklas 568         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BRCA_PATIENTID, 1, null, createIfMissing, effectivePermissionsUse));
5663 11 Oct 19 nicklas 569         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BRCA_PROVNUMMER, 1, null, createIfMissing, effectivePermissionsUse));
5402 07 May 19 nicklas 570         
4001 17 Jun 16 nicklas 571         jsonChecks.add(checkAnnotationType(dc, Annotationtype.USE_FOR_QC, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 572         jsonChecks.add(checkAnnotationType(dc, Annotationtype.DILUTION_CONC, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 573         jsonChecks.add(checkAnnotationType(dc, Annotationtype.DILUTION_VOLUME, 1, null, createIfMissing, effectivePermissionsUse));
3303 04 May 15 nicklas 574         
1889 27 Feb 13 nicklas 575         jsonChecks.add(checkAnnotationType(dc, Annotationtype.FLAG, 1, 
2077 17 Oct 13 nicklas 576             new ValueOptions(
2242 21 Feb 14 nicklas 577               Histology.FLAG_NO_GOOD_STAIN,
2077 17 Oct 13 nicklas 578               Rna.FLAG_NOT_ENOUGH_REMAINING_QUANTITY, Rna.FLAG_LOW_QUALITY_SCORE, Rna.FLAG_MANUAL,
1987 23 May 13 nicklas 579               Rna.FLAG_MRNA_PLATE_FAILED, Rna.FLAG_CDNA_PLATE_FAILED, Rna.FLAG_LIB_PLATE_FAILED,
2077 17 Oct 13 nicklas 580               Rna.FLAG_EXCLUDED_FROM_POOL,
2367 17 Apr 14 nicklas 581               PooledLibrary.FLAG_CLUSTERING_FAILED, PooledLibrary.FLAG_SEQUENCING_FAILED,
6187 26 Mar 21 nicklas 582               Rna.FLAG_DEMUX_FAILED, Rna.FLAG_FASTQ_IMPORT_FAILED, Rna.FLAG_ALIGN_FAILED, Rna.FLAG_HIGH_HET, 
7186 22 May 23 nicklas 583               Rna.FLAG_CUFFLINKS_FAILED, Rna.FLAG_STRINGTIE_FAILED, Consent.FLAG_RETRACTED,
7186 22 May 23 nicklas 584               SpecimenTube.FLAG_MISSING_IN_TRANSPORT_BOX),
4001 17 Jun 16 nicklas 585             createIfMissing, effectivePermissionsUse));
1889 27 Feb 13 nicklas 586         jsonChecks.add(checkAnnotationType(dc, Annotationtype.AUTO_PROCESSING, 1, 
5356 12 Apr 19 nicklas 587             new ValueOptions(
5356 12 Apr 19 nicklas 588               "Disable", "ReProcess", "AutoConfirm", 
5356 12 Apr 19 nicklas 589               Rna.AUTO_PROCESSING_PRE_NORMALIZE, Dna.AUTO_PROCESSING_PRE_NORMALIZE),
4001 17 Jun 16 nicklas 590             createIfMissing, effectivePermissionsUse));
5407 08 May 19 nicklas 591         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PLATE_PROCESSING, 1,
5417 10 May 19 nicklas 592             new ValueOptions("AddAliquots", "DesignMIPs", "Disable"),
5407 08 May 19 nicklas 593             createIfMissing, effectivePermissionsUse));
1890 01 Mar 13 nicklas 594         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PLATE_PROCESS_RESULT, 1,
1890 01 Mar 13 nicklas 595             new ValueOptions(ReactionPlate.PROCESS_SUCCESSFUL, ReactionPlate.PROCESS_FAILED),
4001 17 Jun 16 nicklas 596             createIfMissing, effectivePermissionsUse));
1890 01 Mar 13 nicklas 597         
1865 19 Feb 13 nicklas 598         jsonChecks.add(checkAnnotationType(dc, Annotationtype.POOL_SCHEMA, 1, 
5884 27 Mar 20 nicklas 599             new ValueOptions("1by24offset", "2by24offset", "4by24", "1by16", "1by16offset", "2by16", "2by16offset", 
5884 27 Mar 20 nicklas 600                 "3by16", "4by16", "5by16", "NP1by16", "external32", "external64"), 
4001 17 Jun 16 nicklas 601             createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 602         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BARCODE_VARIANT, 1, null, createIfMissing,  effectivePermissionsUse));
4001 17 Jun 16 nicklas 603         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QUBIT_CONC, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 604         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QUBIT_CONC_AFTER_SPEEDVAC, 1, null, createIfMissing, effectivePermissionsUse));
7286 15 Aug 23 nicklas 605         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QUANTIT_CONC, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 606         jsonChecks.add(checkAnnotationType(dc, Annotationtype.CA_SIZE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 607         jsonChecks.add(checkAnnotationType(dc, Annotationtype.CA_MOLARITY, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 608         jsonChecks.add(checkAnnotationType(dc, Annotationtype.CA_SIZE_ADPT, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 609         jsonChecks.add(checkAnnotationType(dc, Annotationtype.CA_MOLARITY_ADPT, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 610         jsonChecks.add(checkAnnotationType(dc, Annotationtype.LIBRARY_MOLARITY_EST, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 611         jsonChecks.add(checkAnnotationType(dc, Annotationtype.LIBRARY_SIZE_EST, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 612         jsonChecks.add(checkAnnotationType(dc, Annotationtype.LIBRARY_CONC_EST, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 613         jsonChecks.add(checkAnnotationType(dc, Annotationtype.LIBRARY_FRAC_ADPT, 1, null, createIfMissing, effectivePermissionsUse));
5870 20 Mar 20 nicklas 614         jsonChecks.add(checkAnnotationType(dc, Annotationtype.EXTERNAL_PLATE_POS, 1, null, createIfMissing, effectivePermissionsUse));
5870 20 Mar 20 nicklas 615         jsonChecks.add(checkAnnotationType(dc, Annotationtype.EXTERNAL_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 616         jsonChecks.add(checkAnnotationType(dc, Annotationtype.POOL_CONC, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 617         jsonChecks.add(checkAnnotationType(dc, Annotationtype.POOL_MOLARITY, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 618         jsonChecks.add(checkAnnotationType(dc, Annotationtype.POOL_TARGET_VOLUME_PER_LIB, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 619         jsonChecks.add(checkAnnotationType(dc, Annotationtype.POOL_TARGET_MOLARITY, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 620         jsonChecks.add(checkAnnotationType(dc, Annotationtype.POOL_IS_MANUAL, 1, null, createIfMissing, effectivePermissionsUse));
2041 04 Oct 13 nicklas 621         jsonChecks.add(checkAnnotationType(dc, Annotationtype.POOL_MIXING_STRATEGY, 1, 
2041 04 Oct 13 nicklas 622             new ValueOptions(PooledLibrary.MIXING_STRATEGY_FIXED, PooledLibrary.MIXING_STRATEGY_DYNAMIC),
4001 17 Jun 16 nicklas 623             createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 624         jsonChecks.add(checkAnnotationType(dc, Annotationtype.POOL_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 625         jsonChecks.add(checkAnnotationType(dc, Annotationtype.POOL_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 626         jsonChecks.add(checkAnnotationType(dc, Annotationtype.DILUTION_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 627         jsonChecks.add(checkAnnotationType(dc, Annotationtype.DILUTION_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 628         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PURIFICATION_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 629         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PURIFICATION_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 630         jsonChecks.add(checkAnnotationType(dc, Annotationtype.FRAGMENTATION_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 631         jsonChecks.add(checkAnnotationType(dc, Annotationtype.FRAGMENTATION_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 632         jsonChecks.add(checkAnnotationType(dc, Annotationtype.CLEANUP_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 633         jsonChecks.add(checkAnnotationType(dc, Annotationtype.CLEANUP_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 634         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SYNTHESIS_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 635         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SYNTHESIS_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 636         jsonChecks.add(checkAnnotationType(dc, Annotationtype.AMPLIFICATION_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 637         jsonChecks.add(checkAnnotationType(dc, Annotationtype.AMPLIFICATION_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
5450 27 May 19 nicklas 638         jsonChecks.add(checkAnnotationType(dc, Annotationtype.HYBRIDIZATION_DATE, 1, null, createIfMissing, effectivePermissionsUse));
5450 27 May 19 nicklas 639         jsonChecks.add(checkAnnotationType(dc, Annotationtype.HYBRIDIZATION_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
5450 27 May 19 nicklas 640         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PCR_DATE, 1, null, createIfMissing, effectivePermissionsUse));
5450 27 May 19 nicklas 641         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PCR_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 642         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NEOPREP_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 643         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NEOPREP_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
1902 13 Mar 13 nicklas 644
4001 17 Jun 16 nicklas 645         jsonChecks.add(checkAnnotationType(dc, Annotationtype.FLOWCELL_ID, 1, null, createIfMissing, effectivePermissionsUse));
2412 09 May 14 nicklas 646         jsonChecks.add(checkAnnotationType(dc, Annotationtype.FLOWCELL_TYPE, 1, 
5855 09 Mar 20 nicklas 647             new ValueOptions(FlowCell.FLOW_CELL_TYPE_HISEQ, FlowCell.FLOW_CELL_TYPE_NEXTSEQ, FlowCell.FLOW_CELL_TYPE_NOVASEQ),
4001 17 Jun 16 nicklas 648             createIfMissing, effectivePermissionsUse));
7101 06 Apr 23 nicklas 649         jsonChecks.add(checkAnnotationType(dc, Annotationtype.LANE_NUMBER, 1, new ValueOptions(1, 2, 3, 4, 5, 6, 7, 8), createIfMissing, effectivePermissionsUse));
7101 06 Apr 23 nicklas 650         jsonChecks.add(checkAnnotationType(dc, Annotationtype.READ_NUMBER, 1, new ValueOptions(new Object[] {1, 2}), createIfMissing, effectivePermissionsUse));
7108 13 Apr 23 nicklas 651         jsonChecks.add(checkAnnotationType(dc, Annotationtype.READ_LENGTH, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 652         jsonChecks.add(checkAnnotationType(dc, Annotationtype.CLUSTER_START, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 653         jsonChecks.add(checkAnnotationType(dc, Annotationtype.CLUSTER_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 654         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SEQUENCING_CYCLES, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 655         jsonChecks.add(checkAnnotationType(dc, Annotationtype.FAILED_LANES, 0, null, createIfMissing, effectivePermissionsUse));
2224 12 Feb 14 nicklas 656
6461 01 Nov 21 nicklas 657         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BEADCHIP_ID, 1, null, createIfMissing, effectivePermissionsUse));
6461 01 Nov 21 nicklas 658         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BEADCHIP_TYPE, 1, 
6865 09 Nov 22 nicklas 659             new ValueOptions("OncoArray500K", "Epic850K"),
6461 01 Nov 21 nicklas 660             createIfMissing, effectivePermissionsUse));
6461 01 Nov 21 nicklas 661         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BEADCHIP_POSITION, 1, null, createIfMissing, effectivePermissionsUse));
6461 01 Nov 21 nicklas 662         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SCAN_DATE, 1, null, createIfMissing, effectivePermissionsUse));
6476 05 Nov 21 nicklas 663
6476 05 Nov 21 nicklas 664         jsonChecks.add(checkAnnotationType(dc, Annotationtype.CALL_DATE, 1, null, createIfMissing, effectivePermissionsUse));
6476 05 Nov 21 nicklas 665         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NUM_CALLS, 1, null, createIfMissing, effectivePermissionsUse));
6476 05 Nov 21 nicklas 666         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NUM_NO_CALLS, 1, null, createIfMissing, effectivePermissionsUse));
6476 05 Nov 21 nicklas 667         jsonChecks.add(checkAnnotationType(dc, Annotationtype.CALL_RATE, 1, null, createIfMissing, effectivePermissionsUse));
6476 05 Nov 21 nicklas 668         jsonChecks.add(checkAnnotationType(dc, Annotationtype.GC10, 1, null, createIfMissing, effectivePermissionsUse));
6476 05 Nov 21 nicklas 669         jsonChecks.add(checkAnnotationType(dc, Annotationtype.GC50, 1, null, createIfMissing, effectivePermissionsUse));
6476 05 Nov 21 nicklas 670         jsonChecks.add(checkAnnotationType(dc, Annotationtype.LOG_R_DEV, 1, null, createIfMissing, effectivePermissionsUse));
6557 31 Jan 22 nicklas 671
6557 31 Jan 22 nicklas 672         jsonChecks.add(checkAnnotationType(dc, Annotationtype.GENOTYPE_COUNT, 1, null, createIfMissing, effectivePermissionsUse));
6557 31 Jan 22 nicklas 673         jsonChecks.add(checkAnnotationType(dc, Annotationtype.GENOTYPE_REF_PCT, 1, null, createIfMissing, effectivePermissionsUse));
6557 31 Jan 22 nicklas 674         jsonChecks.add(checkAnnotationType(dc, Annotationtype.GENOTYPE_HET_PCT, 1, null, createIfMissing, effectivePermissionsUse));
6557 31 Jan 22 nicklas 675         jsonChecks.add(checkAnnotationType(dc, Annotationtype.GENOTYPE_ALT_PCT, 1, null, createIfMissing, effectivePermissionsUse));
6461 01 Nov 21 nicklas 676         
6876 18 Nov 22 nicklas 677         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NUM_PROBES, 1, null, createIfMissing, effectivePermissionsUse));
6876 18 Nov 22 nicklas 678         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NUM_PROBES_BAD_PVAL, 1, null, createIfMissing, effectivePermissionsUse));
6876 18 Nov 22 nicklas 679         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NUM_PROBES_I, 1, null, createIfMissing, effectivePermissionsUse));
6876 18 Nov 22 nicklas 680         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NUM_PROBES_II, 1, null, createIfMissing, effectivePermissionsUse));
6876 18 Nov 22 nicklas 681         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PROBES_RATE, 1, null, createIfMissing, effectivePermissionsUse));
6876 18 Nov 22 nicklas 682         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MEDIAN_METH, 1, null, createIfMissing, effectivePermissionsUse));
6876 18 Nov 22 nicklas 683         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MEDIAN_UNMETH, 1, null, createIfMissing, effectivePermissionsUse));
6876 18 Nov 22 nicklas 684         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PEAK_METH_I, 1, null, createIfMissing, effectivePermissionsUse));
6876 18 Nov 22 nicklas 685         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PEAK_UNMETH_I, 1, null, createIfMissing, effectivePermissionsUse));
6876 18 Nov 22 nicklas 686         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PEAK_METH_II, 1, null, createIfMissing, effectivePermissionsUse));
6876 18 Nov 22 nicklas 687         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PEAK_UNMETH_II, 1, null, createIfMissing, effectivePermissionsUse));
6878 18 Nov 22 nicklas 688         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ANALYSIS_FLAG, 1, null, createIfMissing, effectivePermissionsUse));
7287 15 Aug 23 nicklas 689
7287 15 Aug 23 nicklas 690         jsonChecks.add(checkAnnotationType(dc, Annotationtype.TAU_MANUAL, 1, null, createIfMissing, effectivePermissionsUse));
7287 15 Aug 23 nicklas 691         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RHO_MANUAL, 1, null, createIfMissing, effectivePermissionsUse));
7287 15 Aug 23 nicklas 692         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PSI_MANUAL, 1, null, createIfMissing, effectivePermissionsUse));
7341 11 Sep 23 nicklas 693         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PENALTY, 1, null, createIfMissing, effectivePermissionsUse));
7341 11 Sep 23 nicklas 694         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MIN_DEPTH, 1, null, createIfMissing, effectivePermissionsUse));
7341 11 Sep 23 nicklas 695         jsonChecks.add(checkAnnotationType(dc, Annotationtype.IMBALANCE_TEST, 1, 
7341 11 Sep 23 nicklas 696           new ValueOptions(AllelicImbalanceTest.LEGACY.getTitle(), 
7341 11 Sep 23 nicklas 697               AllelicImbalanceTest.MAD_SEGMENT.getTitle(), 
7341 11 Sep 23 nicklas 698               AllelicImbalanceTest.BIMODALITY_COEFFICIENT.getTitle()), createIfMissing, effectivePermissionsUse));
7287 15 Aug 23 nicklas 699         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NORMAL_CONTAMINATION, 1, null, createIfMissing, effectivePermissionsUse));
7287 15 Aug 23 nicklas 700         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PLOIDY, 1, null, createIfMissing, effectivePermissionsUse));
7287 15 Aug 23 nicklas 701         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PURITY, 1, null, createIfMissing, effectivePermissionsUse));
7287 15 Aug 23 nicklas 702         jsonChecks.add(checkAnnotationType(dc, Annotationtype.GOODNESS_OF_FIT, 1, null, createIfMissing, effectivePermissionsUse));
7405 08 Nov 23 nicklas 703         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NUMBER_OF_SEGMENTS, 1, null, createIfMissing, effectivePermissionsUse));
7405 08 Nov 23 nicklas 704         jsonChecks.add(checkAnnotationType(dc, Annotationtype.LOH_FRACTION, 1, null, createIfMissing, effectivePermissionsUse));
7405 08 Nov 23 nicklas 705         jsonChecks.add(checkAnnotationType(dc, Annotationtype.GI_SCORE, 1, null, createIfMissing, effectivePermissionsUse));
7341 11 Sep 23 nicklas 706         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NON_ABERRANT, 1, 
7341 11 Sep 23 nicklas 707             new ValueOptions("No", "Yes"), createIfMissing, effectivePermissionsUse));
7293 22 Aug 23 nicklas 708         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ASCAT_RESULT, 1, 
7293 22 Aug 23 nicklas 709             new ValueOptions("Accepted", "NotAccepted", "Undecided", "Failed"), createIfMissing, effectivePermissionsUse));
7287 15 Aug 23 nicklas 710         
4001 17 Jun 16 nicklas 711         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SEQUENCING_START, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 712         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SEQUENCING_TURN_AROUND, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 713         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SEQUENCING_END, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 714         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SEQUENCING_RUN_NUMBER, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 715         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SEQUENCING_OPERATOR, 1, null, createIfMissing, effectivePermissionsUse));
2224 12 Feb 14 nicklas 716         jsonChecks.add(checkAnnotationType(dc, Annotationtype.HISEQ_POSITION, 1, 
2224 12 Feb 14 nicklas 717             new ValueOptions("A", "B"),
4001 17 Jun 16 nicklas 718             createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 719         jsonChecks.add(checkAnnotationType(dc, Annotationtype.DATA_FILES_FOLDER, 1, null, createIfMissing, effectivePermissionsUse));
6209 13 Apr 21 nicklas 720         jsonChecks.add(checkAnnotationType(dc, Annotationtype.RAW_FASTQ, 2, null, createIfMissing, effectivePermissionsUse));
2225 13 Feb 14 nicklas 721         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SEQUENCING_RESULT, 1, 
2225 13 Feb 14 nicklas 722             new ValueOptions(SequencingRun.SEQUENCING_SUCCESSFUL, SequencingRun.SEQUENCING_FIRST_BASE_REPORT_FAILED, SequencingRun.SEQUENCING_FAILED),
4001 17 Jun 16 nicklas 723             createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 724         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SEQUENCING_CONFIRMED, 1, null, createIfMissing, effectivePermissionsUse));
2320 04 Apr 14 nicklas 725
4001 17 Jun 16 nicklas 726         jsonChecks.add(checkAnnotationType(dc, Annotationtype.READ_STRING, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 727         jsonChecks.add(checkAnnotationType(dc, Annotationtype.OMIT_LANES, 0, null, createIfMissing, effectivePermissionsUse));
2364 15 Apr 14 nicklas 728         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ANALYSIS_RESULT, 1, 
3723 25 Jan 16 nicklas 729             new ValueOptions("Successful", "Partial", "Failed"),
4001 17 Jun 16 nicklas 730             createIfMissing, effectivePermissionsUse));
2049 07 Oct 13 nicklas 731         
4001 17 Jun 16 nicklas 732         jsonChecks.add(checkAnnotationType(dc, Annotationtype.READS, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 733         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PF_READS, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 734         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ADAPTER_READS, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 735         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PT_READS, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 736         jsonChecks.add(checkAnnotationType(dc, Annotationtype.FRAGMENT_SIZE_AVG, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 737         jsonChecks.add(checkAnnotationType(dc, Annotationtype.FRAGMENT_SIZE_STDEV, 1, null, createIfMissing, effectivePermissionsUse));
6421 23 Sep 21 nicklas 738         jsonChecks.add(checkAnnotationType(dc, Annotationtype.READLENGTH_AVG_R1, 1, null, createIfMissing, effectivePermissionsUse));
6421 23 Sep 21 nicklas 739         jsonChecks.add(checkAnnotationType(dc, Annotationtype.READLENGTH_AVG_R2, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 740         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PF_NNNN_PCT, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 741         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PF_UNUSED_PCT, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 742         jsonChecks.add(checkAnnotationType(dc, Annotationtype.DEMUX_WARNINGS, 0, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 743         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SKIPPED_TILES, 0, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 744         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PM_READS, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 745         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ALIGNED_PAIRS, 1, null, createIfMissing, effectivePermissionsUse));
7113 14 Apr 23 nicklas 746         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PF_BASES, 1, null, createIfMissing, effectivePermissionsUse));
7113 14 Apr 23 nicklas 747         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PF_Q30_BASES, 1, null, createIfMissing, effectivePermissionsUse));
5843 25 Feb 20 nicklas 748         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ALIGNED_BASES, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 749         jsonChecks.add(checkAnnotationType(dc, Annotationtype.READ_PAIRS_EXAMINED, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 750         jsonChecks.add(checkAnnotationType(dc, Annotationtype.READ_PAIR_DUPLICATES, 1, null, createIfMissing, effectivePermissionsUse));
7104 11 Apr 23 nicklas 751         jsonChecks.add(checkAnnotationType(dc, Annotationtype.READ_PAIR_OPTICAL_DUPLICATES, 1, null, createIfMissing, effectivePermissionsUse));
7106 12 Apr 23 nicklas 752         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MEAN_COVERAGE, 1, null, createIfMissing, effectivePermissionsUse));
7106 12 Apr 23 nicklas 753         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SD_COVERAGE, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 754         jsonChecks.add(checkAnnotationType(dc, Annotationtype.FRACTION_DUPLICATION, 1, null, createIfMissing, effectivePermissionsUse));
7104 11 Apr 23 nicklas 755         jsonChecks.add(checkAnnotationType(dc, Annotationtype.FRACTION_OPTICAL_DUPLICATION, 1, null, createIfMissing, effectivePermissionsUse));
4620 16 Nov 17 nicklas 756         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QC_GENOTYPE_COUNT, 1, null, createIfMissing, effectivePermissionsUse));
4658 26 Jan 18 nicklas 757         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QC_GENOTYPE_HET_PCT, 1, null, createIfMissing, effectivePermissionsUse));
4642 28 Nov 17 nicklas 758         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QC_GENOTYPE_STATUS, 1, 
4642 28 Nov 17 nicklas 759             new ValueOptions("Checked", "Disabled"), 
4642 28 Nov 17 nicklas 760             createIfMissing, effectivePermissionsUse));
4710 20 Mar 18 nicklas 761         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QC_GENOTYPE_VERIFIED, 1, 
4712 22 Mar 18 nicklas 762             new ValueOptions("DNA", "Specimen", "Lysate"),  // See VerifiedMatch.getTitle()
4710 20 Mar 18 nicklas 763             createIfMissing, effectivePermissionsUse));
4648 15 Dec 17 nicklas 764         jsonChecks.add(checkAnnotationType(dc, Annotationtype.QC_GENOTYPE_COMMENT, 1, null, createIfMissing, effectivePermissionsUse));
5046 22 Oct 18 nicklas 765
5057 29 Oct 18 nicklas 766         jsonChecks.add(checkAnnotationType(dc, Annotationtype.VARIANT_CALL_TYPE, 1, 
7396 06 Nov 23 nicklas 767             new ValueOptions("mBAF", "VariantCall", "TargetedGenotype", "PanelOfNormal"),
5057 29 Oct 18 nicklas 768             createIfMissing, effectivePermissionsUse));
5046 22 Oct 18 nicklas 769         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MBAF_SNP_COUNT, 1, null, createIfMissing, effectivePermissionsUse));
5046 22 Oct 18 nicklas 770         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MBAF_SNP_COUNT_FILTERED, 1, null, createIfMissing, effectivePermissionsUse));
5046 22 Oct 18 nicklas 771         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MBAF_MIN_PVALUE, 1, null, createIfMissing, effectivePermissionsUse));
5046 22 Oct 18 nicklas 772         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MBAF_MIN_PREGION, 1, null, createIfMissing, effectivePermissionsUse));
5050 24 Oct 18 nicklas 773         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MBAF_NUM_REGIONS, 1, null, createIfMissing, effectivePermissionsUse));
5050 24 Oct 18 nicklas 774         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MBAF_SIGNIFICANT_REGIONS, 1, null, createIfMissing, effectivePermissionsUse));
2365 16 Apr 14 nicklas 775         
5706 07 Nov 19 nicklas 776         jsonChecks.add(checkAnnotationType(dc, Annotationtype.CALLABLE_BASES, 1, null, createIfMissing, effectivePermissionsUse));
7439 16 Nov 23 nicklas 777         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PANEL_OF_NORMALS, 1, 
7439 16 Nov 23 nicklas 778           new ValueOptions("Novogene", "Sanger", "Cegat"), 
7439 16 Nov 23 nicklas 779           createIfMissing, effectivePermissionsUse));
5721 13 Nov 19 nicklas 780         jsonChecks.add(checkAnnotationType(dc, Annotationtype.VARIANTS_RAW, 1, null, createIfMissing, effectivePermissionsUse));
5706 07 Nov 19 nicklas 781         jsonChecks.add(checkAnnotationType(dc, Annotationtype.VARIANTS_PASSED_FILTER, 1, null, createIfMissing, effectivePermissionsUse));
6387 15 Sep 21 nicklas 782         jsonChecks.add(checkAnnotationType(dc, Annotationtype.TARGETED_GENOTYPE, 1, 
6387 15 Sep 21 nicklas 783             new ValueOptions((Object[])TargetedGenotypeJobCreator.getConfiguredTargetNames()),
6387 15 Sep 21 nicklas 784             createIfMissing, effectivePermissionsUse));
6388 15 Sep 21 nicklas 785         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NUM_TARGETED_GENOTYPES, 1, null, createIfMissing, effectivePermissionsUse));
6388 15 Sep 21 nicklas 786         jsonChecks.add(checkAnnotationType(dc, Annotationtype.NUM_TARGETED_VARIANTS, 1, null, createIfMissing, effectivePermissionsUse));
5706 07 Nov 19 nicklas 787         
4972 20 Sep 18 nicklas 788         jsonChecks.add(checkAnnotationType(dc, Annotationtype.DO_NOT_USE, 1, 
5113 20 Nov 18 nicklas 789             new ValueOptions("Specimen", "Lysate", "RNA", "PreNormalizedRNA", "Library", "Manual"), 
4972 20 Sep 18 nicklas 790             createIfMissing, effectivePermissionsUse));
4972 20 Sep 18 nicklas 791         jsonChecks.add(checkAnnotationType(dc, Annotationtype.DO_NOT_USE_COMMENT, 1, null, createIfMissing, effectivePermissionsUse));
4972 20 Sep 18 nicklas 792         
5865 12 Mar 20 nicklas 793         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BARCODE_SET, 1, 
6887 24 Nov 22 nicklas 794             new ValueOptions(BarcodeSet.TRUSEQ_SINGLE.getName(), BarcodeSet.TRUSEQ_UNIQUE_DUAL.getName(), BarcodeSet.IDT10_UDI.getName()), 
5865 12 Mar 20 nicklas 795             createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 796         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BARCODE_SEQUENCE, 1, null, createIfMissing, effectivePermissionsUse));
5489 12 Jun 19 nicklas 797         jsonChecks.add(checkAnnotationType(dc, Annotationtype.BARCODE_SEQUENCE_2, 1, null, createIfMissing, effectivePermissionsUse));
4001 17 Jun 16 nicklas 798         jsonChecks.add(checkAnnotationType(dc, Annotationtype.SERIAL_NUMBER, 1, null, createIfMissing, effectivePermissionsUse));
6010 18 Sep 20 nicklas 799         jsonChecks.add(checkAnnotationType(dc, Annotationtype.HARDWARE_MODEL, 1, null, createIfMissing, effectivePermissionsUse));
2350 10 Apr 14 nicklas 800         
4001 17 Jun 16 nicklas 801         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PARAMETER_SET, 1, null, createIfMissing, secondaryAnalysisUse));
3616 23 Nov 15 nicklas 802         jsonChecks.add(checkAnnotationType(dc, Annotationtype.REPORT_TEMPLATE, 1, 
5664 14 Oct 19 nicklas 803             new ValueOptions("GENE_REPORT", "PILOT_REPORT", "SCANB_REPORT"), 
4001 17 Jun 16 nicklas 804             createIfMissing, effectivePermissionsUse));
6213 15 Apr 21 nicklas 805         jsonChecks.add(checkAnnotationType(dc, Annotationtype.DEMUX_TYPE, 1, 
6213 15 Apr 21 nicklas 806             new ValueOptions("Picard", "bcl2fastq"), 
6213 15 Apr 21 nicklas 807             createIfMissing, effectivePermissionsUse));
6213 15 Apr 21 nicklas 808         jsonChecks.add(checkAnnotationType(dc, Annotationtype.MERGE_TYPE, 1, 
6213 15 Apr 21 nicklas 809             new ValueOptions("Default", "Import"), 
6213 15 Apr 21 nicklas 810             createIfMissing, effectivePermissionsUse));
4602 29 Sep 17 nicklas 811         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ALIGNMENT_TYPE, 1, 
7131 24 Apr 23 nicklas 812             new ValueOptions("Tophat", "Hisat", "MIPs", "Bwa-mem2"), 
4602 29 Sep 17 nicklas 813             createIfMissing, effectivePermissionsUse));
4662 29 Jan 18 nicklas 814         jsonChecks.add(checkAnnotationType(dc, Annotationtype.EXPRESSION_TYPE, 1, 
4663 29 Jan 18 nicklas 815             new ValueOptions("Cufflinks", "StringTie"), 
4662 29 Jan 18 nicklas 816             createIfMissing, effectivePermissionsUse));
2364 15 Apr 14 nicklas 817         
4138 29 Sep 16 nicklas 818         jsonChecks.add(checkAnnotationType(dc, Annotationtype.OUTTAKE_COMPLETED_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4138 29 Sep 16 nicklas 819         jsonChecks.add(checkAnnotationType(dc, Annotationtype.OUTTAKE_DELIVERED_DATE, 1, null, createIfMissing, effectivePermissionsUse));
4154 06 Oct 16 nicklas 820         jsonChecks.add(checkAnnotationType(dc, Annotationtype.OUTTAKE_TARGET_AMOUNT, 1, null, createIfMissing, effectivePermissionsUse));
4154 06 Oct 16 nicklas 821         jsonChecks.add(checkAnnotationType(dc, Annotationtype.OUTTAKE_TARGET_VOLUME, 1, null, createIfMissing, effectivePermissionsUse));
6326 14 Jun 21 nicklas 822         jsonChecks.add(checkAnnotationType(dc, Annotationtype.OUTTAKE_PARENT_TYPE, 1, 
7037 13 Feb 23 nicklas 823             new ValueOptions("DNA", "RNA", "Lysate", "FlowThrough", "BloodDNA"), createIfMissing, effectivePermissionsUse));
4179 27 Oct 16 nicklas 824         jsonChecks.add(checkAnnotationType(dc, Annotationtype.OUTTAKE_RESULT, 1, 
4179 27 Oct 16 nicklas 825             new ValueOptions("Successful", "Failed"),
4179 27 Oct 16 nicklas 826             createIfMissing, effectivePermissionsUse));
4138 29 Sep 16 nicklas 827         
6864 04 Nov 22 nicklas 828         jsonChecks.add(checkAnnotationType(dc, Annotationtype.ZIP_PASSWORD, 1, null, createIfMissing, patientCuratorUse));
7224 31 May 23 nicklas 829         jsonChecks.add(checkAnnotationType(dc, Annotationtype.FILES_TO_IGNORE, 0, null, createIfMissing, effectivePermissionsUse));
6864 04 Nov 22 nicklas 830         
4699 15 Mar 18 nicklas 831         jsonChecks.add(checkAnnotationType(dc, Annotationtype.INCA2_a_diag_dat, 1, null, createIfMissing, effectivePermissionsUse));
4459 21 Apr 17 nicklas 832         
4536 21 Jun 17 nicklas 833         // Pilot report annotation types
4536 21 Jun 17 nicklas 834         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PILOT_SUBTYPE, 1, 
4568 01 Sep 17 nicklas 835             new ValueOptions("HER2 enriched", "Luminal B", "Luminal A", "Basal", "Normal-like", "unclassified"), 
4536 21 Jun 17 nicklas 836             createIfMissing, effectivePermissionsUse));
4536 21 Jun 17 nicklas 837         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PILOT_GGI, 1, 
4536 21 Jun 17 nicklas 838             new ValueOptions("High", "Low"), createIfMissing, effectivePermissionsUse));
4536 21 Jun 17 nicklas 839         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PILOT_ER, 1, 
4536 21 Jun 17 nicklas 840             new ValueOptions("Negative", "Positive"), createIfMissing, effectivePermissionsUse));
4536 21 Jun 17 nicklas 841         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PILOT_PGR, 1, 
4536 21 Jun 17 nicklas 842             new ValueOptions("Negative", "Positive"), createIfMissing, effectivePermissionsUse));
4536 21 Jun 17 nicklas 843         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PILOT_HER2, 1, 
4536 21 Jun 17 nicklas 844             new ValueOptions("Negative", "Positive"), createIfMissing, effectivePermissionsUse));
4536 21 Jun 17 nicklas 845         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PILOT_KI67, 1, 
4536 21 Jun 17 nicklas 846             new ValueOptions("High", "Low"), createIfMissing, effectivePermissionsUse));
4536 21 Jun 17 nicklas 847         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PILOT_SCORE_LUMA, 1, null, createIfMissing, effectivePermissionsUse));
4536 21 Jun 17 nicklas 848         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PILOT_SCORE_LUMB, 1, null, createIfMissing, effectivePermissionsUse));
4536 21 Jun 17 nicklas 849         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PILOT_SCORE_HER2, 1, null, createIfMissing, effectivePermissionsUse));
4536 21 Jun 17 nicklas 850         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PILOT_SCORE_BASAL, 1, null, createIfMissing, effectivePermissionsUse));
4536 21 Jun 17 nicklas 851         jsonChecks.add(checkAnnotationType(dc, Annotationtype.PILOT_SCORE_NORMAL, 1, null, createIfMissing, effectivePermissionsUse));
4536 21 Jun 17 nicklas 852
5792 16 Dec 19 nicklas 853         // Mutation signatures -- save in array for later AnnotationTypeCategory check
5872 23 Mar 20 nicklas 854         List<Annotationtype> variantCallAnnotations = new ArrayList<>();
5792 16 Dec 19 nicklas 855         for (int index = 0; index < Annotationtype.NUM_MUTATION_SIGNATURES; index++)
5792 16 Dec 19 nicklas 856         {
5872 23 Mar 20 nicklas 857           Annotationtype at = Annotationtype.mutationSignature(index+1);
5872 23 Mar 20 nicklas 858           jsonChecks.add(checkAnnotationType(dc, at, 1, null, createIfMissing, effectivePermissionsUse));
5872 23 Mar 20 nicklas 859           variantCallAnnotations.add(at);
5792 16 Dec 19 nicklas 860         }
5792 16 Dec 19 nicklas 861         
5872 23 Mar 20 nicklas 862         // Interesting genes for the variant calling
5872 23 Mar 20 nicklas 863         for (String gene : new VariantCallingJobCreator.VariantCollector().getGenes())
5872 23 Mar 20 nicklas 864         {
5872 23 Mar 20 nicklas 865           Annotationtype at = Annotationtype.geneVariantAnnotation(gene);
5872 23 Mar 20 nicklas 866           jsonChecks.add(checkAnnotationType(dc, at, 1, null, createIfMissing, effectivePermissionsUse));
5872 23 Mar 20 nicklas 867           variantCallAnnotations.add(at);
5872 23 Mar 20 nicklas 868         }
5872 23 Mar 20 nicklas 869         Annotationtype at = Annotationtype.geneVariantAnnotation("ESR1");
5872 23 Mar 20 nicklas 870         jsonChecks.add(checkAnnotationType(dc, at, 1, null, createIfMissing, effectivePermissionsUse));
5872 23 Mar 20 nicklas 871         variantCallAnnotations.add(at);
5872 23 Mar 20 nicklas 872         
5962 03 Jun 20 nicklas 873         // Single Sample Predictor installation
5962 03 Jun 20 nicklas 874         List<SspModel> validModels = SspModel.getConfiguredModels();
5962 03 Jun 20 nicklas 875         Info sspInfo = null;
5962 03 Jun 20 nicklas 876         try
5962 03 Jun 20 nicklas 877         {
5962 03 Jun 20 nicklas 878           SspAnalysis ssp = new SspAnalysis();
5962 03 Jun 20 nicklas 879           Info tmp = ssp.info(dc, validModels);
5962 03 Jun 20 nicklas 880           if (tmp.getExitStatus() != 0)
5962 03 Jun 20 nicklas 881           {
5962 03 Jun 20 nicklas 882             throw new RuntimeException(tmp.toString(), tmp.getException());
5962 03 Jun 20 nicklas 883           }
5962 03 Jun 20 nicklas 884           sspInfo = tmp;
5962 03 Jun 20 nicklas 885         }
5962 03 Jun 20 nicklas 886         catch (Exception ex)
5962 03 Jun 20 nicklas 887         {
5962 03 Jun 20 nicklas 888           ex.printStackTrace(System.out);
5962 03 Jun 20 nicklas 889           JSONObject jsonSsp = new JSONObject();
5962 03 Jun 20 nicklas 890           jsonSsp.put("itemType", "SSP");
5962 03 Jun 20 nicklas 891           jsonSsp.put("name", "SSP R script");
5962 03 Jun 20 nicklas 892           jsonSsp.put("status", "warning");
5962 03 Jun 20 nicklas 893           JSONArray jsonMessages = new JSONArray();
5962 03 Jun 20 nicklas 894           jsonMessages.add("The SSP R script failed");
5962 03 Jun 20 nicklas 895           jsonSsp.put("stderr", ex.getMessage());
5962 03 Jun 20 nicklas 896           jsonSsp.put("messages", jsonMessages);
5962 03 Jun 20 nicklas 897           jsonChecks.add(jsonSsp);
5962 03 Jun 20 nicklas 898         }
5962 03 Jun 20 nicklas 899         
5962 03 Jun 20 nicklas 900         List<Annotationtype> sspAnnotations = new ArrayList<>();
5962 03 Jun 20 nicklas 901         if (sspInfo != null)
5962 03 Jun 20 nicklas 902         {
5962 03 Jun 20 nicklas 903           for (SspInfoResult info : sspInfo.getInfoResults())
5962 03 Jun 20 nicklas 904           {
5962 03 Jun 20 nicklas 905             jsonChecks.addAll(checkSspInfo(dc, info, sspAnnotations, createIfMissing, effectivePermissionsUse));
5962 03 Jun 20 nicklas 906           }
5962 03 Jun 20 nicklas 907         }
5962 03 Jun 20 nicklas 908         
1463 14 Nov 11 martin 909         // Annotation type categories
1463 14 Nov 11 martin 910         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.PATIENT, createIfMissing, 
1610 23 Apr 12 nicklas 911             Annotationtype.ALL_FIRST_NAMES, Annotationtype.DATE_OF_BIRTH, 
1610 23 Apr 12 nicklas 912             Annotationtype.FAMILY_NAME, Annotationtype.GENDER, Annotationtype.PERSONAL_NUMBER));
1516 19 Jan 12 nicklas 913         
3085 15 Jan 15 olle 914         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.RETRACT, createIfMissing, 
3756 18 Feb 16 olle 915             Annotationtype.RETRACT_NA_LAB,
3091 15 Jan 15 olle 916             Annotationtype.RETRACT_TX_LAB,
3091 15 Jan 15 olle 917             Annotationtype.RETRACT_RX_LAB, 
3756 18 Feb 16 olle 918             Annotationtype.RETRACT_NA_BB,
3091 15 Jan 15 olle 919             Annotationtype.RETRACT_TX_BB,
3091 15 Jan 15 olle 920             Annotationtype.RETRACT_RX_BB,
3756 18 Feb 16 olle 921             Annotationtype.RETRACT_NA_FROZEN,
3091 15 Jan 15 olle 922             Annotationtype.RETRACT_TX_FROZEN,
3091 15 Jan 15 olle 923             Annotationtype.RETRACT_RX_FROZEN,
3756 18 Feb 16 olle 924             Annotationtype.RETRACT_NA_RCC_SYD,
3265 21 Apr 15 olle 925             Annotationtype.RETRACT_TX_RCC_SYD,
3085 15 Jan 15 olle 926             Annotationtype.RETRACT_STATUS));
3085 15 Jan 15 olle 927         
3085 15 Jan 15 olle 928         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.RETRO_NO, createIfMissing, 
3756 18 Feb 16 olle 929             Annotationtype.RETRACT_NA_LAB,
3091 15 Jan 15 olle 930             Annotationtype.RETRACT_TX_LAB,
3091 15 Jan 15 olle 931             Annotationtype.RETRACT_RX_LAB, 
3756 18 Feb 16 olle 932             Annotationtype.RETRACT_NA_BB,
3091 15 Jan 15 olle 933             Annotationtype.RETRACT_TX_BB,
3091 15 Jan 15 olle 934             Annotationtype.RETRACT_RX_BB,
3756 18 Feb 16 olle 935             Annotationtype.RETRACT_NA_FROZEN,
3091 15 Jan 15 olle 936             Annotationtype.RETRACT_TX_FROZEN,
3091 15 Jan 15 olle 937             Annotationtype.RETRACT_RX_FROZEN,
3756 18 Feb 16 olle 938             Annotationtype.RETRACT_NA_RCC_SYD,
3265 21 Apr 15 olle 939             Annotationtype.RETRACT_TX_RCC_SYD,
3085 15 Jan 15 olle 940             Annotationtype.RETRACT_STATUS));
3085 15 Jan 15 olle 941         
1463 14 Nov 11 martin 942         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.CASE, createIfMissing, 
3484 14 Sep 15 nicklas 943             Annotationtype.CONSENT, Annotationtype.CONSENT_DATE, Annotationtype.FROZEN_TISSUE_DATE,
4458 21 Apr 17 nicklas 944             Annotationtype.LATERALITY, Annotationtype.REFERENCE_DATE, Annotationtype.REFERENCE_DATE_SOURCE,
6098 11 Jan 21 nicklas 945             Annotationtype.LINKED_CASE,
5141 22 Nov 18 nicklas 946             Annotationtype.INCA_EXPORT_DATE, Annotationtype.INCA_IMPORT_DATE,
5141 22 Nov 18 nicklas 947             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT));
1516 19 Jan 12 nicklas 948         
1515 19 Jan 12 nicklas 949         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.BLOOD, createIfMissing, 
1610 23 Apr 12 nicklas 950             Annotationtype.CONSENT, Annotationtype.CONSENT_DATE,
1610 23 Apr 12 nicklas 951             Annotationtype.BLOOD_SAMPLING_DATETIME, Annotationtype.BLOOD_FREEZER_DATETIME,
1775 11 Dec 12 olle 952             Annotationtype.BLOOD_SERUM, Annotationtype.BLOOD_SAMPLE,
5141 22 Nov 18 nicklas 953             Annotationtype.BLOOD_RCCIDNUMBER, Annotationtype.OTHER_PATH_NOTE,
6277 03 Jun 21 nicklas 954             Annotationtype.BD47_ID,
5141 22 Nov 18 nicklas 955             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT));
3355 28 May 15 nicklas 956
3355 28 May 15 nicklas 957         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.BLOOD_DNA, createIfMissing, 
6461 01 Nov 21 nicklas 958             Annotationtype.ND_CONC, Annotationtype.BEADCHIP_POSITION,
6461 01 Nov 21 nicklas 959             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT));
3355 28 May 15 nicklas 960
1463 14 Nov 11 martin 961         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.SPECIMEN, createIfMissing, 
1610 23 Apr 12 nicklas 962             Annotationtype.ARRIVAL_DATE, Annotationtype.BIOPSY_TYPE,
1610 23 Apr 12 nicklas 963             Annotationtype.LATERALITY, Annotationtype.NOF_DELIVERED_TUBES,
1610 23 Apr 12 nicklas 964             Annotationtype.NOF_PIECES, Annotationtype.OPERATOR_DELIVERY_COMMENT,
1610 23 Apr 12 nicklas 965             Annotationtype.OPERATOR_PARTITION_COMMENT, Annotationtype.OTHER_PATH_NOTE,
6994 20 Jan 23 nicklas 966             Annotationtype.PAD, Annotationtype.ALTERNATE_PAD, 
6995 20 Jan 23 nicklas 967             Annotationtype.EXTERNAL_OPERATOR, Annotationtype.EXTERNAL_SPECIMEN_EXISTS,
6990 19 Jan 23 nicklas 968             Annotationtype.RNALATER_DATETIME, Annotationtype.SAMPLING_DATETIME, 
6990 19 Jan 23 nicklas 969             Annotationtype.SPECIMEN_TYPE,
6711 27 Apr 22 nicklas 970             Annotationtype.EXTERNAL_REF, Annotationtype.TUBE_LABEL,
3784 16 Mar 16 nicklas 971             Annotationtype.LINKED_SPECIMEN, Annotationtype.YELLOW_LABEL, 
6910 30 Nov 22 nicklas 972             Annotationtype.COMPLETED_DATE, Annotationtype.IMPORT_WARNINGS,
6918 01 Dec 22 nicklas 973             Annotationtype.EXTERNAL_STORAGE,
4972 20 Sep 18 nicklas 974             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
3144 24 Feb 15 nicklas 975             Annotationtype.AUTO_PROCESSING));
1608 20 Apr 12 nicklas 976         
1608 20 Apr 12 nicklas 977         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.NO_SPECIMEN, createIfMissing, 
1677 31 May 12 nicklas 978             Annotationtype.LATERALITY,
6990 19 Jan 23 nicklas 979             Annotationtype.PAD, Annotationtype.ALTERNATE_PAD,
6990 19 Jan 23 nicklas 980             Annotationtype.REASON_IF_NO_SPECIMEN,
6574 08 Feb 22 nicklas 981             Annotationtype.SAMPLING_DATETIME, Annotationtype.RNALATER_DATETIME,
6574 08 Feb 22 nicklas 982             Annotationtype.BIOPSY_TYPE, Annotationtype.OTHER_PATH_NOTE,
6574 08 Feb 22 nicklas 983             Annotationtype.EXTERNAL_SPECIMEN_EXISTS, Annotationtype.EXTERNAL_OPERATOR,
6918 01 Dec 22 nicklas 984             Annotationtype.EXTERNAL_STORAGE,
6574 08 Feb 22 nicklas 985             Annotationtype.LIASON_COMMENT, Annotationtype.LINKED_SPECIMEN, 
6574 08 Feb 22 nicklas 986             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT
1608 20 Apr 12 nicklas 987             ));
6151 26 Feb 21 nicklas 988         
5774 04 Dec 19 nicklas 989         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.TMA_SPECIMEN, createIfMissing, 
5774 04 Dec 19 nicklas 990             Annotationtype.TMA_BLOCK, Annotationtype.TMA_BLOCK_POS,
5799 18 Dec 19 nicklas 991             Annotationtype.PAD, Annotationtype.PAD_REQUESTED, Annotationtype.SAMPLE_OWNER
5774 04 Dec 19 nicklas 992             ));
1608 20 Apr 12 nicklas 993         
2242 21 Feb 14 nicklas 994         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.HISTOLOGY, createIfMissing,
5141 22 Nov 18 nicklas 995             Annotationtype.AUTO_PROCESSING, Annotationtype.FLAG, 
5141 22 Nov 18 nicklas 996             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT));
2242 21 Feb 14 nicklas 997         
1668 25 May 12 nicklas 998         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.STAINED, createIfMissing,
3169 06 Mar 15 nicklas 999             Annotationtype.IHC, Annotationtype.IHC_QUALITY,
2134 11 Nov 13 nicklas 1000             Annotationtype.GOOD_STAIN, Annotationtype.SCORE_COMPLETE, Annotationtype.SCORE_INVASIVE_CANCER,
2134 11 Nov 13 nicklas 1001             Annotationtype.SCORE_INSITU_CANCER, Annotationtype.SCORE_LYMPHOCYTES, Annotationtype.SCORE_NORMAL,
2134 11 Nov 13 nicklas 1002             Annotationtype.SCORE_STROMA, Annotationtype.SCORE_FAT));
1668 25 May 12 nicklas 1003         
6221 23 Apr 21 nicklas 1004         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.SAMPLE_HANDLING_PROTOCOL, createIfMissing, 
6221 23 Apr 21 nicklas 1005             Annotationtype.EXTERNAL_REF
6221 23 Apr 21 nicklas 1006             ));
6221 23 Apr 21 nicklas 1007
1463 14 Nov 11 martin 1008         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.LYSATE, createIfMissing, 
2690 24 Sep 14 nicklas 1009             Annotationtype.PARTITION_DATE, Annotationtype.MULTIPLE_PIECES,
2690 24 Sep 14 nicklas 1010             Annotationtype.RLT_PLUS, Annotationtype.BETA_MERCA,
3469 27 Aug 15 nicklas 1011             Annotationtype.REAGENT_DX, Annotationtype.QIA_SHREDDER,
6711 27 Apr 22 nicklas 1012             Annotationtype.RESERVED_BY, Annotationtype.TUBE_LABEL,
6918 01 Dec 22 nicklas 1013             Annotationtype.EXTERNAL_STORAGE,
4972 20 Sep 18 nicklas 1014             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
4972 20 Sep 18 nicklas 1015             Annotationtype.AUTO_PROCESSING
2690 24 Sep 14 nicklas 1016             ));
1463 14 Nov 11 martin 1017         
6221 23 Apr 21 nicklas 1018         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.EXTRACTION_PROTOCOL, createIfMissing, 
6221 23 Apr 21 nicklas 1019             Annotationtype.EXTERNAL_REF
6221 23 Apr 21 nicklas 1020             ));
6221 23 Apr 21 nicklas 1021         
1543 28 Feb 12 nicklas 1022         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.RNA, createIfMissing,
1639 09 May 12 nicklas 1023             Annotationtype.QIACUBE_DATE, Annotationtype.QIACUBE_OPERATOR,
6510 03 Dec 21 nicklas 1024             Annotationtype.QIACUBE_POSITION, Annotationtype.QIACUBE_RUN_NO, Annotationtype.QIACUBE_RUN_ID,
1865 19 Feb 13 nicklas 1025             Annotationtype.ND_CONC, Annotationtype.ND_260_BY_280, Annotationtype.ND_260_BY_230,
6711 27 Apr 22 nicklas 1026             Annotationtype.QUBIT_CONC, Annotationtype.TUBE_LABEL,
2690 24 Sep 14 nicklas 1027             Annotationtype.ALLPREP_MINI_KIT, Annotationtype.ETOH70,
2690 24 Sep 14 nicklas 1028             Annotationtype.BUFFER_RW1, Annotationtype.BUFFER_RPE,
2690 24 Sep 14 nicklas 1029             Annotationtype.BUFFER_AW1, Annotationtype.BUFFER_AW2,
2690 24 Sep 14 nicklas 1030             Annotationtype.BUFFER_EB, Annotationtype.RNASE_FREE_WATER,
2690 24 Sep 14 nicklas 1031             Annotationtype.ALLPREP_DNA_COL, Annotationtype.RNEASY_COL,
6918 01 Dec 22 nicklas 1032             Annotationtype.IMPORT_WARNINGS, Annotationtype.EXTERNAL_STORAGE,
4972 20 Sep 18 nicklas 1033             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
1889 27 Feb 13 nicklas 1034             Annotationtype.AUTO_PROCESSING, Annotationtype.FLAG));
1543 28 Feb 12 nicklas 1035         
2898 05 Nov 14 nicklas 1036         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.RNA_NORMALIZED_ALIQUOT, createIfMissing, 
2898 05 Nov 14 nicklas 1037             Annotationtype.DILUTION_DATE, Annotationtype.DILUTION_OPERATOR,
6219 20 Apr 21 nicklas 1038             Annotationtype.ND_CONC, Annotationtype.QUBIT_CONC,
2909 07 Nov 14 nicklas 1039             Annotationtype.AUTO_PROCESSING, Annotationtype.FLAG
2898 05 Nov 14 nicklas 1040             ));
2898 05 Nov 14 nicklas 1041         
3269 23 Apr 15 nicklas 1042         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.RNA_NORMALIZATION_PROTOCOL, createIfMissing, 
3829 06 Apr 16 nicklas 1043             Annotationtype.RNA_TARGET_VOLUME, Annotationtype.RNA_TARGET_AMOUNT,
3833 08 Apr 16 nicklas 1044             Annotationtype.RNA_MINIMAL_AMOUNT, Annotationtype.LIBPREP_TARGET
3269 23 Apr 15 nicklas 1045             ));
3269 23 Apr 15 nicklas 1046         
1549 06 Mar 12 nicklas 1047         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.DNA, createIfMissing,
1639 09 May 12 nicklas 1048             Annotationtype.QIACUBE_DATE, Annotationtype.QIACUBE_OPERATOR,
6510 03 Dec 21 nicklas 1049             Annotationtype.QIACUBE_POSITION, Annotationtype.QIACUBE_RUN_NO, Annotationtype.QIACUBE_RUN_ID,
2690 24 Sep 14 nicklas 1050             Annotationtype.ND_CONC, Annotationtype.ND_260_BY_280, Annotationtype.ND_260_BY_230,
6711 27 Apr 22 nicklas 1051             Annotationtype.QUBIT_CONC, Annotationtype.TUBE_LABEL,
2690 24 Sep 14 nicklas 1052             Annotationtype.ALLPREP_MINI_KIT, Annotationtype.ETOH70,
2690 24 Sep 14 nicklas 1053             Annotationtype.BUFFER_RW1, Annotationtype.BUFFER_RPE,
2690 24 Sep 14 nicklas 1054             Annotationtype.BUFFER_AW1, Annotationtype.BUFFER_AW2,
2690 24 Sep 14 nicklas 1055             Annotationtype.BUFFER_EB, Annotationtype.RNASE_FREE_WATER,
4972 20 Sep 18 nicklas 1056             Annotationtype.ALLPREP_DNA_COL, Annotationtype.RNEASY_COL,
5356 12 Apr 19 nicklas 1057             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
6918 01 Dec 22 nicklas 1058             Annotationtype.EXTERNAL_STORAGE,
5356 12 Apr 19 nicklas 1059             Annotationtype.AUTO_PROCESSING, Annotationtype.FLAG
2690 24 Sep 14 nicklas 1060             ));
1639 09 May 12 nicklas 1061         
5359 12 Apr 19 nicklas 1062         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.DNA_NORMALIZED_ALIQUOT, createIfMissing, 
5359 12 Apr 19 nicklas 1063             Annotationtype.DILUTION_DATE, Annotationtype.DILUTION_OPERATOR,
6219 20 Apr 21 nicklas 1064             Annotationtype.ND_CONC, Annotationtype.QUBIT_CONC,
5601 13 Sep 19 nicklas 1065             Annotationtype.MIPS_PANEL, Annotationtype.MIPS_POOL_VOLUME,
5447 24 May 19 nicklas 1066             Annotationtype.MIPS_NORMAL_TUMOR, Annotationtype.MIPS_FORM,
5447 24 May 19 nicklas 1067             Annotationtype.MIPS_VARIANT, Annotationtype.MIPS_VARIANT_LIST, Annotationtype.MIPS_SCREENING,
5407 08 May 19 nicklas 1068             Annotationtype.AUTO_PROCESSING, Annotationtype.FLAG,
5407 08 May 19 nicklas 1069             Annotationtype.PLATE_PROCESSING
5359 12 Apr 19 nicklas 1070             ));
5359 12 Apr 19 nicklas 1071         
5359 12 Apr 19 nicklas 1072         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.DNA_NORMALIZATION_PROTOCOL, createIfMissing, 
5359 12 Apr 19 nicklas 1073             Annotationtype.DNA_TARGET_VOLUME, Annotationtype.DNA_TARGET_AMOUNT,
5449 27 May 19 nicklas 1074             Annotationtype.DNA_MINIMAL_AMOUNT, Annotationtype.LIBPREP_TARGET,
5601 13 Sep 19 nicklas 1075             Annotationtype.MIPS_PANEL
5359 12 Apr 19 nicklas 1076             ));
5359 12 Apr 19 nicklas 1077       
2095 23 Oct 13 nicklas 1078         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.FLOW_THROUGH, createIfMissing,
2095 23 Oct 13 nicklas 1079             Annotationtype.QIACUBE_DATE, Annotationtype.QIACUBE_OPERATOR,
6510 03 Dec 21 nicklas 1080             Annotationtype.QIACUBE_POSITION, Annotationtype.QIACUBE_RUN_NO, Annotationtype.QIACUBE_RUN_ID,
6918 01 Dec 22 nicklas 1081             Annotationtype.TUBE_LABEL, Annotationtype.EXTERNAL_STORAGE,
2690 24 Sep 14 nicklas 1082             Annotationtype.ALLPREP_MINI_KIT, Annotationtype.ETOH70,
2690 24 Sep 14 nicklas 1083             Annotationtype.BUFFER_RW1, Annotationtype.BUFFER_RPE,
2690 24 Sep 14 nicklas 1084             Annotationtype.BUFFER_AW1, Annotationtype.BUFFER_AW2,
2690 24 Sep 14 nicklas 1085             Annotationtype.BUFFER_EB, Annotationtype.RNASE_FREE_WATER,
4972 20 Sep 18 nicklas 1086             Annotationtype.ALLPREP_DNA_COL, Annotationtype.RNEASY_COL,
4972 20 Sep 18 nicklas 1087             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT
2690 24 Sep 14 nicklas 1088             ));
1543 28 Feb 12 nicklas 1089
1546 02 Mar 12 nicklas 1090         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.RNAQC, createIfMissing,
5141 22 Nov 18 nicklas 1091             Annotationtype.BA_RIN, Annotationtype.CA_RQS, Annotationtype.QC_HISENSE, 
5141 22 Nov 18 nicklas 1092             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT));
1865 19 Feb 13 nicklas 1093
2004 29 May 13 nicklas 1094         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.MRNA, createIfMissing,
2004 29 May 13 nicklas 1095           Annotationtype.POOL_SCHEMA, Annotationtype.PLATE_PROCESS_RESULT,
2004 29 May 13 nicklas 1096           Annotationtype.DILUTION_DATE, Annotationtype.DILUTION_OPERATOR,
3832 07 Apr 16 nicklas 1097           Annotationtype.DILUTION_CONC, Annotationtype.DILUTION_VOLUME,
3832 07 Apr 16 nicklas 1098           Annotationtype.USE_FOR_QC,
2004 29 May 13 nicklas 1099           Annotationtype.PURIFICATION_DATE, Annotationtype.PURIFICATION_OPERATOR,
2004 29 May 13 nicklas 1100           Annotationtype.FRAGMENTATION_DATE, Annotationtype.FRAGMENTATION_OPERATOR,
2906 07 Nov 14 nicklas 1101           Annotationtype.AUTO_PROCESSING,
5141 22 Nov 18 nicklas 1102           Annotationtype.CLEANUP_DATE, Annotationtype.CLEANUP_OPERATOR,
5891 07 Apr 20 nicklas 1103           Annotationtype.RNA_TARGET_VOLUME, Annotationtype.RNA_TARGET_AMOUNT,
5436 17 May 19 nicklas 1104           Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
5436 17 May 19 nicklas 1105           Annotationtype.PIPELINE));
2004 29 May 13 nicklas 1106         
2004 29 May 13 nicklas 1107         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.CDNA, createIfMissing,
2004 29 May 13 nicklas 1108           Annotationtype.SYNTHESIS_DATE, Annotationtype.SYNTHESIS_OPERATOR,
5141 22 Nov 18 nicklas 1109           Annotationtype.POOL_SCHEMA, Annotationtype.BARCODE_VARIANT, Annotationtype.PLATE_PROCESS_RESULT,
5436 17 May 19 nicklas 1110           Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
5436 17 May 19 nicklas 1111           Annotationtype.PIPELINE));
2004 29 May 13 nicklas 1112         
1902 13 Mar 13 nicklas 1113         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.LIBRARY, createIfMissing,
3832 07 Apr 16 nicklas 1114             Annotationtype.DILUTION_CONC, Annotationtype.DILUTION_VOLUME,
1987 23 May 13 nicklas 1115             Annotationtype.QUBIT_CONC, Annotationtype.QUBIT_CONC_AFTER_SPEEDVAC, 
7286 15 Aug 23 nicklas 1116             Annotationtype.QUANTIT_CONC,
1987 23 May 13 nicklas 1117             Annotationtype.CA_SIZE, Annotationtype.CA_MOLARITY,
2454 23 May 14 nicklas 1118             Annotationtype.CA_SIZE_ADPT, Annotationtype.CA_MOLARITY_ADPT,
2454 23 May 14 nicklas 1119             Annotationtype.LIBRARY_MOLARITY_EST, Annotationtype.LIBRARY_SIZE_EST,
3309 06 May 15 nicklas 1120             Annotationtype.LIBRARY_CONC_EST, Annotationtype.LIBRARY_FRAC_ADPT,
2004 29 May 13 nicklas 1121             Annotationtype.FLAG, 
2004 29 May 13 nicklas 1122             Annotationtype.AMPLIFICATION_DATE, Annotationtype.AMPLIFICATION_OPERATOR,
5450 27 May 19 nicklas 1123             Annotationtype.HYBRIDIZATION_DATE, Annotationtype.HYBRIDIZATION_OPERATOR,
5450 27 May 19 nicklas 1124             Annotationtype.PCR_DATE, Annotationtype.PCR_OPERATOR,
2004 29 May 13 nicklas 1125             Annotationtype.CLEANUP_DATE, Annotationtype.CLEANUP_OPERATOR,
3319 11 May 15 nicklas 1126             Annotationtype.DILUTION_DATE, Annotationtype.DILUTION_OPERATOR,
3319 11 May 15 nicklas 1127             Annotationtype.NEOPREP_DATE, Annotationtype.NEOPREP_DATE,
4972 20 Sep 18 nicklas 1128             Annotationtype.POOL_SCHEMA, Annotationtype.BARCODE_VARIANT, 
5427 14 May 19 nicklas 1129             Annotationtype.POOL_DATE, Annotationtype.POOL_OPERATOR,
4972 20 Sep 18 nicklas 1130             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
5870 20 Mar 20 nicklas 1131             Annotationtype.PIPELINE, Annotationtype.EXTERNAL_PLATE_POS,
6197 06 Apr 21 nicklas 1132             Annotationtype.EXTERNAL_OPERATOR, Annotationtype.EXTERNAL_REF,
5891 07 Apr 20 nicklas 1133             Annotationtype.RNA_TARGET_VOLUME, Annotationtype.RNA_TARGET_AMOUNT,
4972 20 Sep 18 nicklas 1134             Annotationtype.PLATE_PROCESS_RESULT));
1865 19 Feb 13 nicklas 1135
5425 14 May 19 nicklas 1136         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.LIBRARY_PROTOCOL, createIfMissing, 
6221 23 Apr 21 nicklas 1137           Annotationtype.LIBPREP_TARGET, Annotationtype.EXTERNAL_REF
5425 14 May 19 nicklas 1138           ));
5425 14 May 19 nicklas 1139
1959 03 May 13 nicklas 1140         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.POOLED_LIBRARY, createIfMissing,
2027 30 Sep 13 nicklas 1141             Annotationtype.POOL_MOLARITY, Annotationtype.POOL_CONC, Annotationtype.POOL_TARGET_VOLUME_PER_LIB,
2141 18 Nov 13 nicklas 1142             Annotationtype.POOL_TARGET_MOLARITY, Annotationtype.POOL_IS_MANUAL,
2191 13 Jan 14 nicklas 1143             Annotationtype.POOL_MIXING_STRATEGY, Annotationtype.POOL_DATE, Annotationtype.POOL_OPERATOR,
6197 06 Apr 21 nicklas 1144             Annotationtype.PIPELINE, Annotationtype.EXTERNAL_REF,
2077 17 Oct 13 nicklas 1145             Annotationtype.FLAG, Annotationtype.AUTO_PROCESSING));
1959 03 May 13 nicklas 1146
2021 17 Sep 13 nicklas 1147         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.FLOW_CELL, createIfMissing, 
2412 09 May 14 nicklas 1148             Annotationtype.FLOWCELL_ID, Annotationtype.FLOWCELL_TYPE,
2412 09 May 14 nicklas 1149             Annotationtype.CLUSTER_START, Annotationtype.CLUSTER_OPERATOR,
2226 13 Feb 14 nicklas 1150             Annotationtype.SEQUENCING_CYCLES, Annotationtype.FAILED_LANES,
6203 09 Apr 21 nicklas 1151             Annotationtype.PIPELINE,
2226 13 Feb 14 nicklas 1152             Annotationtype.PLATE_PROCESS_RESULT, Annotationtype.SEQUENCING_RESULT));
2021 17 Sep 13 nicklas 1153         
6461 01 Nov 21 nicklas 1154         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.BEAD_CHIP, createIfMissing, 
6461 01 Nov 21 nicklas 1155             Annotationtype.BEADCHIP_ID, Annotationtype.BEADCHIP_TYPE,
6461 01 Nov 21 nicklas 1156             Annotationtype.PLATE_PROCESS_RESULT, Annotationtype.PIPELINE
6461 01 Nov 21 nicklas 1157           ));
6461 01 Nov 21 nicklas 1158         
6461 01 Nov 21 nicklas 1159         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.SCAN, createIfMissing, 
6461 01 Nov 21 nicklas 1160             Annotationtype.DATA_FILES_FOLDER, Annotationtype.SCAN_DATE,
6461 01 Nov 21 nicklas 1161             Annotationtype.ANALYSIS_RESULT,
6461 01 Nov 21 nicklas 1162             Annotationtype.PIPELINE
6461 01 Nov 21 nicklas 1163           ));
6477 05 Nov 21 nicklas 1164         
6477 05 Nov 21 nicklas 1165         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.SCANNER, createIfMissing, 
7017 27 Jan 23 nicklas 1166             Annotationtype.SERIAL_NUMBER, Annotationtype.HARDWARE_MODEL
6477 05 Nov 21 nicklas 1167           ));
6475 05 Nov 21 nicklas 1168
6475 05 Nov 21 nicklas 1169         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.GENOTYPE_CALL, createIfMissing, 
6476 05 Nov 21 nicklas 1170             Annotationtype.CALL_DATE, Annotationtype.NUM_CALLS, Annotationtype.NUM_NO_CALLS,
6476 05 Nov 21 nicklas 1171             Annotationtype.CALL_RATE, Annotationtype.GC10, Annotationtype.GC50,
6476 05 Nov 21 nicklas 1172             Annotationtype.LOG_R_DEV, Annotationtype.DATA_FILES_FOLDER, 
6512 06 Dec 21 nicklas 1173             Annotationtype.QC_GENOTYPE_COUNT, Annotationtype.QC_GENOTYPE_HET_PCT, 
6512 06 Dec 21 nicklas 1174             Annotationtype.QC_GENOTYPE_STATUS,
6476 05 Nov 21 nicklas 1175             Annotationtype.ANALYSIS_RESULT, Annotationtype.PIPELINE
6475 05 Nov 21 nicklas 1176           ));
6865 09 Nov 22 nicklas 1177
6865 09 Nov 22 nicklas 1178         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.METHYLATION, createIfMissing, 
6880 22 Nov 22 nicklas 1179             Annotationtype.DATA_FILES_FOLDER, Annotationtype.AUTO_PROCESSING,
6876 18 Nov 22 nicklas 1180             Annotationtype.ANALYSIS_RESULT, Annotationtype.PIPELINE,
6876 18 Nov 22 nicklas 1181             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
6876 18 Nov 22 nicklas 1182             Annotationtype.NUM_PROBES, Annotationtype.NUM_PROBES_BAD_PVAL,
6876 18 Nov 22 nicklas 1183             Annotationtype.NUM_PROBES_I, Annotationtype.NUM_PROBES_II,
6876 18 Nov 22 nicklas 1184             Annotationtype.PROBES_RATE,
6876 18 Nov 22 nicklas 1185             Annotationtype.MEDIAN_METH, Annotationtype.MEDIAN_UNMETH,
6876 18 Nov 22 nicklas 1186             Annotationtype.PEAK_METH_I, Annotationtype.PEAK_UNMETH_I,
6878 18 Nov 22 nicklas 1187             Annotationtype.PEAK_METH_II, Annotationtype.PEAK_UNMETH_II,
6878 18 Nov 22 nicklas 1188             Annotationtype.ANALYSIS_FLAG
6876 18 Nov 22 nicklas 1189           ));
6865 09 Nov 22 nicklas 1190
6461 01 Nov 21 nicklas 1191         
2049 07 Oct 13 nicklas 1192         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.SEQUENCING_RUN, createIfMissing, 
2196 13 Jan 14 nicklas 1193             Annotationtype.SEQUENCING_START, Annotationtype.SEQUENCING_TURN_AROUND, Annotationtype.SEQUENCING_END,
2224 12 Feb 14 nicklas 1194             Annotationtype.SEQUENCING_OPERATOR, Annotationtype.SEQUENCING_RUN_NUMBER, Annotationtype.SEQUENCING_CYCLES,
2228 14 Feb 14 nicklas 1195             Annotationtype.HISEQ_POSITION, Annotationtype.DATA_FILES_FOLDER, Annotationtype.SEQUENCING_RESULT,
5470 05 Jun 19 nicklas 1196             Annotationtype.SEQUENCING_CONFIRMED, Annotationtype.AUTO_PROCESSING,
6203 09 Apr 21 nicklas 1197             Annotationtype.PIPELINE
2049 07 Oct 13 nicklas 1198           ));
2049 07 Oct 13 nicklas 1199         
7099 06 Apr 23 nicklas 1200         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.SEQUENCE_DATA, createIfMissing, 
7099 06 Apr 23 nicklas 1201             Annotationtype.READS, Annotationtype.SERIAL_NUMBER, Annotationtype.SEQUENCING_RUN_NUMBER,
7107 12 Apr 23 nicklas 1202             Annotationtype.FLOWCELL_ID, Annotationtype.LANE_NUMBER, Annotationtype.READ_NUMBER,
7108 13 Apr 23 nicklas 1203             Annotationtype.FLOWCELL_TYPE, Annotationtype.READ_LENGTH
7099 06 Apr 23 nicklas 1204           ));
7099 06 Apr 23 nicklas 1205         
7099 06 Apr 23 nicklas 1206         
2320 04 Apr 14 nicklas 1207         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.DEMUXED_SEQUENCES, createIfMissing, 
3032 12 Dec 14 nicklas 1208             Annotationtype.READ_STRING, Annotationtype.OMIT_LANES, 
3032 12 Dec 14 nicklas 1209             Annotationtype.ANALYSIS_RESULT, Annotationtype.AUTO_PROCESSING,
6215 16 Apr 21 nicklas 1210             Annotationtype.DATA_FILES_FOLDER, Annotationtype.RAW_FASTQ,
2434 19 May 14 nicklas 1211             Annotationtype.READS, Annotationtype.PF_READS, Annotationtype.PF_NNNN_PCT, 
5480 10 Jun 19 nicklas 1212             Annotationtype.PF_UNUSED_PCT, Annotationtype.DEMUX_WARNINGS, Annotationtype.SKIPPED_TILES,
5480 10 Jun 19 nicklas 1213             Annotationtype.PIPELINE
2320 04 Apr 14 nicklas 1214           ));
2364 15 Apr 14 nicklas 1215
2364 15 Apr 14 nicklas 1216         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.MERGED_SEQUENCES, createIfMissing, 
2497 05 Jun 14 nicklas 1217             Annotationtype.ANALYSIS_RESULT, 
2689 23 Sep 14 nicklas 1218             Annotationtype.READS, Annotationtype.PF_READS, Annotationtype.ADAPTER_READS, Annotationtype.PT_READS,
2680 18 Sep 14 nicklas 1219             Annotationtype.FRAGMENT_SIZE_AVG, Annotationtype.FRAGMENT_SIZE_STDEV,
6421 23 Sep 21 nicklas 1220             Annotationtype.READLENGTH_AVG_R1, Annotationtype.READLENGTH_AVG_R2,
6215 16 Apr 21 nicklas 1221             Annotationtype.DATA_FILES_FOLDER, 
4972 20 Sep 18 nicklas 1222             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
5480 10 Jun 19 nicklas 1223             Annotationtype.AUTO_PROCESSING,
5480 10 Jun 19 nicklas 1224             Annotationtype.PIPELINE
2364 15 Apr 14 nicklas 1225           ));
2320 04 Apr 14 nicklas 1226         
2420 13 May 14 nicklas 1227         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.MASKED_SEQUENCES, createIfMissing, 
5546 07 Aug 19 nicklas 1228             Annotationtype.PM_READS, Annotationtype.PIPELINE,
5141 22 Nov 18 nicklas 1229             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT
2399 05 May 14 nicklas 1230           ));
2399 05 May 14 nicklas 1231         
2399 05 May 14 nicklas 1232         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.ALIGNED_SEQUENCES, createIfMissing, 
2706 29 Sep 14 nicklas 1233             Annotationtype.DATA_FILES_FOLDER, Annotationtype.ALIGNED_PAIRS,
7113 14 Apr 23 nicklas 1234             Annotationtype.PF_BASES, Annotationtype.PF_Q30_BASES,
7104 11 Apr 23 nicklas 1235             Annotationtype.ALIGNED_BASES, Annotationtype.READ_PAIRS_EXAMINED, 
7106 12 Apr 23 nicklas 1236             Annotationtype.READ_PAIR_DUPLICATES, Annotationtype.READ_PAIR_OPTICAL_DUPLICATES,
7106 12 Apr 23 nicklas 1237             Annotationtype.MEAN_COVERAGE, Annotationtype.SD_COVERAGE,
7104 11 Apr 23 nicklas 1238             Annotationtype.FRACTION_DUPLICATION, Annotationtype.FRACTION_OPTICAL_DUPLICATION,
7104 11 Apr 23 nicklas 1239             Annotationtype.FRAGMENT_SIZE_AVG, Annotationtype.FRAGMENT_SIZE_STDEV, 
7104 11 Apr 23 nicklas 1240             Annotationtype.ANALYSIS_RESULT,
4658 26 Jan 18 nicklas 1241             Annotationtype.QC_GENOTYPE_COUNT, Annotationtype.QC_GENOTYPE_HET_PCT,
4710 20 Mar 18 nicklas 1242             Annotationtype.QC_GENOTYPE_STATUS, Annotationtype.QC_GENOTYPE_VERIFIED,
5546 07 Aug 19 nicklas 1243             Annotationtype.QC_GENOTYPE_COMMENT, Annotationtype.PIPELINE,
5721 13 Nov 19 nicklas 1244             Annotationtype.CALLABLE_BASES, Annotationtype.VARIANTS_RAW,
4972 20 Sep 18 nicklas 1245             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
5046 22 Oct 18 nicklas 1246             Annotationtype.MBAF_SNP_COUNT, Annotationtype.MBAF_SNP_COUNT_FILTERED,
5046 22 Oct 18 nicklas 1247             Annotationtype.MBAF_MIN_PVALUE, Annotationtype.MBAF_MIN_PREGION,
5050 24 Oct 18 nicklas 1248             Annotationtype.MBAF_NUM_REGIONS, Annotationtype.MBAF_SIGNIFICANT_REGIONS,
4972 20 Sep 18 nicklas 1249             Annotationtype.AUTO_PROCESSING
2399 05 May 14 nicklas 1250           ));
2399 05 May 14 nicklas 1251         
7388 31 Oct 23 nicklas 1252         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.PANEL_OF_NORMAL, createIfMissing, 
7389 01 Nov 23 nicklas 1253             Annotationtype.DATA_FILES_FOLDER, Annotationtype.VARIANTS_RAW,
7439 16 Nov 23 nicklas 1254             Annotationtype.CALLABLE_BASES, Annotationtype.PANEL_OF_NORMALS,
7388 31 Oct 23 nicklas 1255             Annotationtype.PIPELINE, Annotationtype.ANALYSIS_RESULT,
7388 31 Oct 23 nicklas 1256             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
7388 31 Oct 23 nicklas 1257             Annotationtype.AUTO_PROCESSING
7388 31 Oct 23 nicklas 1258           ));
7388 31 Oct 23 nicklas 1259         
2350 10 Apr 14 nicklas 1260         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.BARCODE, createIfMissing, 
5489 12 Jun 19 nicklas 1261             Annotationtype.BARCODE_SEQUENCE, Annotationtype.BARCODE_SEQUENCE_2,
5865 12 Mar 20 nicklas 1262             Annotationtype.PIPELINE, Annotationtype.BARCODE_SET
2350 10 Apr 14 nicklas 1263           ));
2350 10 Apr 14 nicklas 1264         
5880 25 Mar 20 nicklas 1265         jsonChecks.add(checkAnnotationTypeCategory(dc, "BarcodeTemplate", null, createIfMissing,
5438 17 May 19 nicklas 1266             Annotationtype.PIPELINE
5438 17 May 19 nicklas 1267           ));
5438 17 May 19 nicklas 1268         
2368 17 Apr 14 nicklas 1269         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.SEQUENCER, createIfMissing, 
6010 18 Sep 20 nicklas 1270           Annotationtype.SERIAL_NUMBER, Annotationtype.HARDWARE_MODEL, Annotationtype.FLOWCELL_TYPE
2368 17 Apr 14 nicklas 1271         ));
2368 17 Apr 14 nicklas 1272         
3114 05 Feb 15 nicklas 1273         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.DEMUX_SOFTWARE, createIfMissing,
6213 15 Apr 21 nicklas 1274             Annotationtype.PARAMETER_SET, Annotationtype.PIPELINE, Annotationtype.EXTERNAL_REF,
6213 15 Apr 21 nicklas 1275             Annotationtype.DEMUX_TYPE
3114 05 Feb 15 nicklas 1276           ));
6213 15 Apr 21 nicklas 1277         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.DEMUX_PROTOCOL, createIfMissing,
6213 15 Apr 21 nicklas 1278             Annotationtype.PIPELINE, Annotationtype.DEMUX_TYPE
6213 15 Apr 21 nicklas 1279           ));
3114 05 Feb 15 nicklas 1280         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.MERGE_SOFTWARE, createIfMissing,
6213 15 Apr 21 nicklas 1281             Annotationtype.PARAMETER_SET, Annotationtype.PIPELINE, Annotationtype.MERGE_TYPE
3114 05 Feb 15 nicklas 1282           ));
6213 15 Apr 21 nicklas 1283         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.MERGE_PROTOCOL, createIfMissing,
6213 15 Apr 21 nicklas 1284             Annotationtype.PIPELINE, Annotationtype.MERGE_TYPE
6213 15 Apr 21 nicklas 1285           ));
3114 05 Feb 15 nicklas 1286         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.MASKING_SOFTWARE, createIfMissing,
6811 25 Aug 22 nicklas 1287             Annotationtype.PARAMETER_SET, Annotationtype.PIPELINE
3114 05 Feb 15 nicklas 1288           ));
3114 05 Feb 15 nicklas 1289         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.ALIGNMENT_SOFTWARE, createIfMissing,
6811 25 Aug 22 nicklas 1290             Annotationtype.PARAMETER_SET, Annotationtype.ALIGNMENT_TYPE, Annotationtype.PIPELINE
3114 05 Feb 15 nicklas 1291           ));
4602 29 Sep 17 nicklas 1292         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.ALIGNMENT_PROTOCOL, createIfMissing,
6811 25 Aug 22 nicklas 1293             Annotationtype.ALIGNMENT_TYPE, Annotationtype.PIPELINE
4602 29 Sep 17 nicklas 1294           ));
5057 29 Oct 18 nicklas 1295         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.VARIANT_CALLING_SOFTWARE, createIfMissing,
6811 25 Aug 22 nicklas 1296             Annotationtype.PARAMETER_SET, Annotationtype.VARIANT_CALL_TYPE, Annotationtype.PIPELINE
5057 29 Oct 18 nicklas 1297           ));
3114 05 Feb 15 nicklas 1298         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.FEATURE_EXTRACTION_SOFTWARE, createIfMissing,
6811 25 Aug 22 nicklas 1299             Annotationtype.PARAMETER_SET, Annotationtype.EXPRESSION_TYPE, Annotationtype.PIPELINE
3114 05 Feb 15 nicklas 1300           ));
4662 29 Jan 18 nicklas 1301         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.FEATURE_EXTRACTION_PROTOCOL, createIfMissing,
6811 25 Aug 22 nicklas 1302             Annotationtype.EXPRESSION_TYPE, Annotationtype.PIPELINE
4662 29 Jan 18 nicklas 1303           ));
4662 29 Jan 18 nicklas 1304
3616 23 Nov 15 nicklas 1305         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.REPORT_SOFTWARE, createIfMissing,
3616 23 Nov 15 nicklas 1306             Annotationtype.PARAMETER_SET, Annotationtype.REPORT_TEMPLATE
3616 23 Nov 15 nicklas 1307           ));
5230 15 Jan 19 nicklas 1308
5230 15 Jan 19 nicklas 1309         jsonChecks.add(checkAnnotationTypeCategory(dc, Rawdatatype.STRINGTIE, createIfMissing, 
5546 07 Aug 19 nicklas 1310             Annotationtype.DATA_FILES_FOLDER, Annotationtype.PIPELINE,
5230 15 Jan 19 nicklas 1311             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
5230 15 Jan 19 nicklas 1312             Annotationtype.ANALYSIS_RESULT, Annotationtype.AUTO_PROCESSING  
5230 15 Jan 19 nicklas 1313           ));
5962 03 Jun 20 nicklas 1314         jsonChecks.add(checkAnnotationTypeCategory(dc, Rawdatatype.STRINGTIE, createIfMissing, 
5962 03 Jun 20 nicklas 1315             sspAnnotations.toArray(new Annotationtype[sspAnnotations.size()])
5962 03 Jun 20 nicklas 1316           ));
3114 05 Feb 15 nicklas 1317         
5706 07 Nov 19 nicklas 1318         jsonChecks.add(checkAnnotationTypeCategory(dc, Rawdatatype.VARIANT_CALL, createIfMissing, 
5706 07 Nov 19 nicklas 1319             Annotationtype.DATA_FILES_FOLDER, Annotationtype.PIPELINE,
7439 16 Nov 23 nicklas 1320             Annotationtype.CALLABLE_BASES, Annotationtype.PANEL_OF_NORMALS,
7410 10 Nov 23 nicklas 1321             Annotationtype.VARIANTS_PASSED_FILTER, Annotationtype.VARIANTS_RAW,
5706 07 Nov 19 nicklas 1322             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
5706 07 Nov 19 nicklas 1323             Annotationtype.ANALYSIS_RESULT, Annotationtype.AUTO_PROCESSING  
5706 07 Nov 19 nicklas 1324           ));
5792 16 Dec 19 nicklas 1325         jsonChecks.add(checkAnnotationTypeCategory(dc, Rawdatatype.VARIANT_CALL, createIfMissing, 
5872 23 Mar 20 nicklas 1326             variantCallAnnotations.toArray(new Annotationtype[variantCallAnnotations.size()])
5792 16 Dec 19 nicklas 1327           ));
5706 07 Nov 19 nicklas 1328         
6538 13 Jan 22 nicklas 1329         jsonChecks.add(checkAnnotationTypeCategory(dc, Rawdatatype.ONCOARRAY500K, createIfMissing, 
6538 13 Jan 22 nicklas 1330             Annotationtype.DATA_FILES_FOLDER, Annotationtype.PIPELINE,
6557 31 Jan 22 nicklas 1331             Annotationtype.GENOTYPE_COUNT, Annotationtype.GENOTYPE_REF_PCT,
6557 31 Jan 22 nicklas 1332             Annotationtype.GENOTYPE_HET_PCT, Annotationtype.GENOTYPE_ALT_PCT,
6538 13 Jan 22 nicklas 1333             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
6538 13 Jan 22 nicklas 1334             Annotationtype.ANALYSIS_RESULT, Annotationtype.AUTO_PROCESSING  
6538 13 Jan 22 nicklas 1335           ));
6538 13 Jan 22 nicklas 1336         
7287 15 Aug 23 nicklas 1337         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.COPY_NUMBER, createIfMissing, 
7287 15 Aug 23 nicklas 1338             Annotationtype.DATA_FILES_FOLDER, Annotationtype.PIPELINE,
7287 15 Aug 23 nicklas 1339             Annotationtype.TAU_MANUAL, Annotationtype.RHO_MANUAL,
7341 11 Sep 23 nicklas 1340             Annotationtype.PSI_MANUAL, Annotationtype.PENALTY,
7341 11 Sep 23 nicklas 1341             Annotationtype.MIN_DEPTH, Annotationtype.IMBALANCE_TEST,
7287 15 Aug 23 nicklas 1342             Annotationtype.NORMAL_CONTAMINATION, Annotationtype.PLOIDY,
7287 15 Aug 23 nicklas 1343             Annotationtype.PURITY, Annotationtype.GOODNESS_OF_FIT,
7405 08 Nov 23 nicklas 1344             Annotationtype.NUMBER_OF_SEGMENTS, Annotationtype.LOH_FRACTION,
7405 08 Nov 23 nicklas 1345             Annotationtype.GI_SCORE,
7341 11 Sep 23 nicklas 1346             Annotationtype.NON_ABERRANT, Annotationtype.ASCAT_RESULT,
7287 15 Aug 23 nicklas 1347             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
7287 15 Aug 23 nicklas 1348             Annotationtype.ANALYSIS_RESULT, Annotationtype.AUTO_PROCESSING
7287 15 Aug 23 nicklas 1349           ));
7287 15 Aug 23 nicklas 1350         
6387 15 Sep 21 nicklas 1351         jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.VARIANT_CALL_FORMAT, createIfMissing,
6388 15 Sep 21 nicklas 1352             Annotationtype.TARGETED_GENOTYPE, Annotationtype.NUM_TARGETED_GENOTYPES,
6388 15 Sep 21 nicklas 1353             Annotationtype.NUM_TARGETED_VARIANTS
6387 15 Sep 21 nicklas 1354           ));
6387 15 Sep 21 nicklas 1355         
5230 15 Jan 19 nicklas 1356         jsonChecks.add(checkAnnotationTypeCategory(dc, Rawdatatype.CUFFLINKS, createIfMissing, 
5546 07 Aug 19 nicklas 1357             Annotationtype.DATA_FILES_FOLDER, Annotationtype.PIPELINE,
5230 15 Jan 19 nicklas 1358             Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
5230 15 Jan 19 nicklas 1359             Annotationtype.ANALYSIS_RESULT, Annotationtype.AUTO_PROCESSING,
6864 04 Nov 22 nicklas 1360             Annotationtype.PILOT_SUBTYPE,
5230 15 Jan 19 nicklas 1361             Annotationtype.PILOT_ER, Annotationtype.PILOT_GGI, Annotationtype.PILOT_HER2,
5230 15 Jan 19 nicklas 1362             Annotationtype.PILOT_KI67, Annotationtype.PILOT_PGR,
5230 15 Jan 19 nicklas 1363             Annotationtype.PILOT_SCORE_BASAL, Annotationtype.PILOT_SCORE_HER2,
5230 15 Jan 19 nicklas 1364             Annotationtype.PILOT_SCORE_LUMA, Annotationtype.PILOT_SCORE_LUMB,
5230 15 Jan 19 nicklas 1365             Annotationtype.PILOT_SCORE_NORMAL, Annotationtype.PILOT_SCORE_NORMAL
5230 15 Jan 19 nicklas 1366           ));
5230 15 Jan 19 nicklas 1367         
5880 25 Mar 20 nicklas 1368         jsonChecks.add(checkAnnotationTypeCategory(dc, "INCA", "Annotation type category for INCA annotations used on Case items. Used by INCA import wizard.", createIfMissing));
5880 25 Mar 20 nicklas 1369         jsonChecks.add(checkAnnotationTypeCategory(dc, "INCA_Release", "This category is for INCA annotations that should be included in data releases.", createIfMissing));
5880 25 Mar 20 nicklas 1370         jsonChecks.add(checkAnnotationTypeCategory(dc, "GEX_Release", "This category is for Cufflinks annotations that should be included in data releases.", createIfMissing));
5880 25 Mar 20 nicklas 1371         jsonChecks.add(checkAnnotationTypeCategory(dc, "VCALL_Release", "This category is for VariantCall annotations that should be included in data releases.", createIfMissing));
5928 29 Apr 20 nicklas 1372         jsonChecks.add(checkAnnotationTypeCategory(dc, "STRINGTIE_Release", "This category is for StringTie annotations that should be included in data releases.", createIfMissing));
4475 27 Apr 17 nicklas 1373         
2565 11 Aug 14 nicklas 1374         // File servers
3772 04 Mar 16 nicklas 1375         jsonChecks.add(checkFileServer(dc, Fileserver.PROJECT_ARCHIVE, effectivePermissionsUse, createIfMissing));
3772 04 Mar 16 nicklas 1376         jsonChecks.add(checkFileServer(dc, Fileserver.EXTERNAL_ARCHIVE, effectivePermissionsUse, createIfMissing));
7046 14 Feb 23 nicklas 1377         jsonChecks.add(checkFileServer(dc, Fileserver.PROJECT_ARCHIVE_DNA, effectivePermissionsUse, createIfMissing));
4431 29 Mar 17 nicklas 1378         jsonChecks.add(checkFileServer(dc, Fileserver.RELEASE_ARCHIVE, effectivePermissionsUse, createIfMissing));
6209 13 Apr 21 nicklas 1379         jsonChecks.add(checkFileServer(dc, Fileserver.IMPORT_GATEWAY, effectivePermissionsUse, createIfMissing));
6177 23 Mar 21 nicklas 1380         jsonChecks.add(checkFileServer(dc, Fileserver.IMPORT_ARCHIVE, effectivePermissionsUse, createIfMissing));
2562 08 Aug 14 nicklas 1381         
3600 13 Nov 15 nicklas 1382         // Directories
4028 26 Jul 16 nicklas 1383         jsonChecks.add(checkDirectory(dc, Histology.IMAGE_DIR, createIfMissing, effectivePermissionsUse));
5784 12 Dec 19 nicklas 1384         jsonChecks.add(checkDirectory(dc, Histology.EXTERNAL_IMAGE_DIR, createIfMissing, effectivePermissionsUse));
4028 26 Jul 16 nicklas 1385         jsonChecks.add(checkDirectory(dc, DemuxJobCreator.DEMULTIPLEX_METRICS_DIR, createIfMissing, effectivePermissionsUse));
4512 31 May 17 nicklas 1386         jsonChecks.add(checkDirectory(dc, Reggie.FROZEN_TISSUE_FILES, createIfMissing, patientCuratorUse));
5397 03 May 19 nicklas 1387         jsonChecks.add(checkDirectory(dc, Reggie.MIPS_IMPORT_FILES, createIfMissing, effectivePermissionsUse));
4028 26 Jul 16 nicklas 1388         jsonChecks.add(checkDirectory(dc, Reggie.SECONDARY_ANALYSIS_DIR, createIfMissing, effectivePermissionsUse));
4028 26 Jul 16 nicklas 1389         jsonChecks.add(checkDirectory(dc, Reggie.EXTERNAL_ANALYSIS_DIR, createIfMissing, effectivePermissionsUse));
4028 26 Jul 16 nicklas 1390         jsonChecks.add(checkDirectory(dc, Reggie.DELIVERY_DIR, createIfMissing, patientCuratorUse, scanbDeliveryRead));
5889 06 Apr 20 nicklas 1391         jsonChecks.add(checkDirectory(dc, Reggie.TEMPLATES_DIR, createIfMissing, effectivePermissionsUse));
6277 03 Jun 21 nicklas 1392         jsonChecks.add(checkDirectory(dc, Reggie.REFERRAL_LOGS_DIR, createIfMissing, effectivePermissionsUse));
5892 07 Apr 20 nicklas 1393         jsonChecks.add(checkDirectory(dc, Reggie.EXTERNAL_LIB_PLATES_DIR, createIfMissing, effectivePermissionsUse));
6960 13 Dec 22 nicklas 1394         jsonChecks.add(checkDirectory(dc, Reggie.EXTERNAL_JSON_IMPORT_DIR, createIfMissing, patientCuratorUse));
7139 27 Apr 23 nicklas 1395         jsonChecks.add(checkDirectory(dc, Reggie.TRANSPORT_BOX_IMPORT_FILES, createIfMissing, effectivePermissionsUse));
3600 13 Nov 15 nicklas 1396         
1865 19 Feb 13 nicklas 1397         // Plugin definitions and configurations
2724 02 Oct 14 nicklas 1398         jsonChecks.add(checkPlugin(dc, CaliperSampleNameExporter.class.getName(), effectivePermissionsUse, createIfMissing));
2022 17 Sep 13 nicklas 1399
2724 02 Oct 14 nicklas 1400         jsonChecks.add(checkPlugin(dc, CaliperRunParametersExporter.class.getName(), effectivePermissionsUse, createIfMissing));
2724 02 Oct 14 nicklas 1401         jsonChecks.add(checkPluginConfiguration(dc, CaliperRunParametersExporter.class.getName(), "Standard sensitivity", effectivePermissionsUse, createIfMissing));
2724 02 Oct 14 nicklas 1402         jsonChecks.add(checkPluginConfiguration(dc, CaliperRunParametersExporter.class.getName(), "High sensitivity", effectivePermissionsUse, createIfMissing));
2022 17 Sep 13 nicklas 1403
2724 02 Oct 14 nicklas 1404         jsonChecks.add(checkPlugin(dc, CaliperLibPrepParametersExporter.class.getName(), effectivePermissionsUse, createIfMissing));
2724 02 Oct 14 nicklas 1405         jsonChecks.add(checkPluginConfiguration(dc, CaliperLibPrepParametersExporter.class.getName(), "HT DNA 1K Ver2 (96)", effectivePermissionsRead, createIfMissing));
2724 02 Oct 14 nicklas 1406         jsonChecks.add(checkPluginConfiguration(dc, CaliperLibPrepParametersExporter.class.getName(), "HT DNA High Sensitivity (96)", effectivePermissionsUse, createIfMissing));
2021 17 Sep 13 nicklas 1407
2724 02 Oct 14 nicklas 1408         jsonChecks.add(checkPlugin(dc, QubitSampleNameExporter.class.getName(), effectivePermissionsUse, createIfMissing));
2022 17 Sep 13 nicklas 1409         
2724 02 Oct 14 nicklas 1410         jsonChecks.add(checkPlugin(dc, "net.sf.basedb.plugins.gtf.GtfReporterImporter", secondaryAnalysisUse, createIfMissing));
2724 02 Oct 14 nicklas 1411         jsonChecks.add(checkPluginConfiguration(dc, "net.sf.basedb.plugins.gtf.GtfReporterImporter", "SCAN-B (transcript_id)", secondaryAnalysisUse, createIfMissing));
2724 02 Oct 14 nicklas 1412         jsonChecks.add(checkPlugin(dc, "net.sf.basedb.plugins.gtf.GtfReporterMapImporter", effectivePermissionsUse, createIfMissing));
2724 02 Oct 14 nicklas 1413         jsonChecks.add(checkPluginConfiguration(dc, "net.sf.basedb.plugins.gtf.GtfReporterMapImporter", "SCAN-B (transcript_id)", secondaryAnalysisUse, createIfMissing));
2724 02 Oct 14 nicklas 1414         jsonChecks.add(checkPlugin(dc, "net.sf.basedb.plugins.RawDataFlatFileImporter", effectivePermissionsUse, createIfMissing));
2724 02 Oct 14 nicklas 1415         jsonChecks.add(checkPluginConfiguration(dc, "net.sf.basedb.plugins.RawDataFlatFileImporter", "SCAN-B (transcript_id)", secondaryAnalysisUse, createIfMissing));
2724 02 Oct 14 nicklas 1416
2911 10 Nov 14 nicklas 1417         jsonChecks.add(checkPlugin(dc, GeneReportPlugin.class.getName(), secondaryAnalysisUse, createIfMissing));
3499 21 Sep 15 nicklas 1418         jsonChecks.add(checkPluginConfiguration(dc, GeneReportPlugin.class.getName(), "Gene report", secondaryAnalysisUse, createIfMissing));
3499 21 Sep 15 nicklas 1419         jsonChecks.add(checkPluginConfiguration(dc, GeneReportPlugin.class.getName(), "Pilot report", secondaryAnalysisUse, createIfMissing));
6087 26 Nov 20 nicklas 1420         jsonChecks.add(checkPluginConfiguration(dc, GeneReportPlugin.class.getName(), "SCAN-B report", secondaryAnalysisUse, createIfMissing));
2911 10 Nov 14 nicklas 1421         jsonChecks.add(checkPlugin(dc, GeneReportsCombinerPlugin.class.getName(), effectivePermissionsUse, createIfMissing));
3500 21 Sep 15 nicklas 1422         jsonChecks.add(checkPluginConfiguration(dc, GeneReportsCombinerPlugin.class.getName(), "Gene report", secondaryAnalysisUse, createIfMissing));
3500 21 Sep 15 nicklas 1423         jsonChecks.add(checkPluginConfiguration(dc, GeneReportsCombinerPlugin.class.getName(), "Pilot report", secondaryAnalysisUse, createIfMissing));
6087 26 Nov 20 nicklas 1424         jsonChecks.add(checkPluginConfiguration(dc, GeneReportsCombinerPlugin.class.getName(), "SCAN-B report", secondaryAnalysisUse, createIfMissing));
4034 29 Jul 16 nicklas 1425
4034 29 Jul 16 nicklas 1426         jsonChecks.add(checkPlugin(dc, SetPermissionsForDeliveryPlugin.class.getName(), patientCuratorUse, createIfMissing));
4034 29 Jul 16 nicklas 1427
1865 19 Feb 13 nicklas 1428         // Biomaterial lists
5962 03 Jun 20 nicklas 1429         jsonChecks.add(checkItemList(dc, BiomaterialList.FLAGGED_RNA, true, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1430         jsonChecks.add(checkItemList(dc, BiomaterialList.FLAGGED_DNA, true, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1431         jsonChecks.add(checkItemList(dc, BiomaterialList.FLAGGED_POOL, true, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1432         jsonChecks.add(checkItemList(dc, BiomaterialList.FLAGGED_HISTOLOGY, true, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1433         jsonChecks.add(checkItemList(dc, BiomaterialList.FLAGGED_SPECIMEN, true, effectivePermissionsWrite, createIfMissing));
7164 12 May 23 nicklas 1434         jsonChecks.add(checkItemList(dc, BiomaterialList.FLAGGED_EXERNAL_SPECIMEN, false, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1435         jsonChecks.add(checkItemList(dc, BiomaterialList.RNA_AUTO_DESIGN_1, true, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1436         jsonChecks.add(checkItemList(dc, BiomaterialList.RNA_AUTO_DESIGN_2, true, effectivePermissionsWrite, createIfMissing));
6179 24 Mar 21 nicklas 1437         jsonChecks.add(checkItemList(dc, BiomaterialList.FASTQ_IMPORT_PIPELINE, true, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1438         jsonChecks.add(checkItemList(dc, BiomaterialList.HISAT_PIPELINE, true, effectivePermissionsWrite, createIfMissing));
6811 25 Aug 22 nicklas 1439         jsonChecks.add(checkItemList(dc, BiomaterialList.HISAT_2023_PIPELINE, true, effectivePermissionsWrite, createIfMissing));
7083 28 Mar 23 nicklas 1440         jsonChecks.add(checkItemList(dc, BiomaterialList.BWA_MEM2_PIPELINE, true, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1441         jsonChecks.add(checkItemList(dc, BiomaterialList.LEGACY_PIPELINE, true, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1442         jsonChecks.add(checkItemList(dc, BiomaterialList.STRINGTIE_PIPELINE, true, effectivePermissionsWrite, createIfMissing));
6815 26 Aug 22 nicklas 1443         jsonChecks.add(checkItemList(dc, BiomaterialList.STRINGTIE_2023_PIPELINE, true, effectivePermissionsWrite, createIfMissing));
6868 15 Nov 22 nicklas 1444         jsonChecks.add(checkItemList(dc, BiomaterialList.METHYLATION_PIPELINE, false, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1445         jsonChecks.add(checkItemList(dc, BiomaterialList.MBAF_PIPELINE, true, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1446         jsonChecks.add(checkItemList(dc, BiomaterialList.VARIANT_CALLING_PIPELINE, true, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1447         jsonChecks.add(checkItemList(dc, BiomaterialList.MIPS_ALIGN_PIPELINE, true, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1448         jsonChecks.add(checkItemList(dc, BiomaterialList.FLAGGED_ALIGNMENT, true, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1449         jsonChecks.add(checkItemList(dc, BiomaterialList.VARIANT_IMPORT_TMP, false, effectivePermissionsWrite, createIfMissing));
6023 26 Oct 20 nicklas 1450         jsonChecks.add(checkItemList(dc, BiomaterialList.GENE_REPORT_CREATE, true, effectivePermissionsWrite, createIfMissing));
6023 26 Oct 20 nicklas 1451         jsonChecks.add(checkItemList(dc, BiomaterialList.PILOT_REPORT_CREATE, true, effectivePermissionsWrite, createIfMissing));
6023 26 Oct 20 nicklas 1452         jsonChecks.add(checkItemList(dc, BiomaterialList.SCANB_REPORT_CREATE, true, effectivePermissionsWrite, createIfMissing));
5962 03 Jun 20 nicklas 1453         jsonChecks.add(checkItemList(dc, BiomaterialList.SSP_PIPELINE, true, effectivePermissionsWrite, createIfMissing));
6387 15 Sep 21 nicklas 1454         jsonChecks.add(checkItemList(dc, BiomaterialList.TARGETED_GENOTYPE_PIPELINE, true, effectivePermissionsWrite, createIfMissing));
6387 15 Sep 21 nicklas 1455         jsonChecks.add(checkItemList(dc, BiomaterialList.VARIANT_INDEX_ALL, true, effectivePermissionsWrite, createIfMissing));
6387 15 Sep 21 nicklas 1456         jsonChecks.add(checkItemList(dc, BiomaterialList.VARIANT_INDEX_FILTERED, true, effectivePermissionsWrite, createIfMissing));
6387 15 Sep 21 nicklas 1457         jsonChecks.add(checkItemList(dc, BiomaterialList.VARIANT_INDEX_TARGETED, true, effectivePermissionsWrite, createIfMissing));
7266 19 Jun 23 nicklas 1458         jsonChecks.add(checkItemList(dc, BiomaterialList.ASCAT_PIPELINE, true, effectivePermissionsWrite, createIfMissing));
7398 07 Nov 23 nicklas 1459         jsonChecks.add(checkItemList(dc, BiomaterialList.WGS_VARIANT_CALLING_PIPELINE, true, effectivePermissionsWrite, createIfMissing));
1865 19 Feb 13 nicklas 1460         
1865 19 Feb 13 nicklas 1461         // MIME types
1865 19 Feb 13 nicklas 1462         jsonChecks.add(checkMimeType(dc, Mimetype.GDX, createIfMissing));
4619 13 Nov 17 nicklas 1463         jsonChecks.add(checkMimeType(dc, Mimetype.VCF, createIfMissing));
6475 05 Nov 21 nicklas 1464         jsonChecks.add(checkMimeType(dc, Mimetype.GTC, createIfMissing));
6866 14 Nov 22 nicklas 1465         jsonChecks.add(checkMimeType(dc, Mimetype.IDAT, createIfMissing));
1865 19 Feb 13 nicklas 1466         
1865 19 Feb 13 nicklas 1467         // Special items
2168 10 Dec 13 nicklas 1468         jsonChecks.add(checkExtract(dc, Rna.STRATAGENE, Subtype.RNA, null, effectivePermissionsUse, createIfMissing));
1890 01 Mar 13 nicklas 1469         jsonChecks.add(checkExtract(dc, Rna.EXTERNAL, Subtype.RNA, 
2168 10 Dec 13 nicklas 1470           "This RNA is used to indicate that a bioplate location is taken by RNA not registered in BASE.", effectivePermissionsUse, createIfMissing));
1865 19 Feb 13 nicklas 1471
1865 19 Feb 13 nicklas 1472         // Tags
5865 12 Mar 20 nicklas 1473         // TruSeq single indexes
1865 19 Feb 13 nicklas 1474         for (int i = 1; i <= 27; i++)
1865 19 Feb 13 nicklas 1475         {
1865 19 Feb 13 nicklas 1476           // Skip 17, 24 and 26 since those are not present in our kits
1865 19 Feb 13 nicklas 1477           if (i == 17 || i == 24 || i == 26) continue;
5437 17 May 19 nicklas 1478           jsonChecks.add(checkTag(dc, "AD"+(i < 10 ? "00" : "0")+i, Subtype.BARCODE, Pipeline.RNA_SEQ,
5865 12 Mar 20 nicklas 1479             BarcodeSet.TRUSEQ_SINGLE, "TruSeq Adapter Index " + i,
2168 10 Dec 13 nicklas 1480             effectivePermissionsUse, createIfMissing));
1865 19 Feb 13 nicklas 1481         }
5865 12 Mar 20 nicklas 1482         // TruSeq Unique Dual indexes
5893 07 Apr 20 nicklas 1483         for (int i = 1; i <= 96; i++)
5865 12 Mar 20 nicklas 1484         {
5865 12 Mar 20 nicklas 1485           jsonChecks.add(checkTag(dc, "UDI"+(i < 10 ? "000" : "00")+i, Subtype.BARCODE, Pipeline.RNA_SEQ,
5865 12 Mar 20 nicklas 1486             BarcodeSet.TRUSEQ_UNIQUE_DUAL, "TruSeq Unique Dual Index " + i,
5865 12 Mar 20 nicklas 1487             effectivePermissionsUse, createIfMissing));
5865 12 Mar 20 nicklas 1488         }
1865 19 Feb 13 nicklas 1489         
1284 08 Feb 11 nicklas 1490         json.put("checks", jsonChecks);
6713 28 Apr 22 nicklas 1491         StaticCache cache = Application.getStaticCache();
5384 26 Apr 19 nicklas 1492
3059 19 Dec 14 nicklas 1493         if (createIfMissing) 
3059 19 Dec 14 nicklas 1494         {
5421 13 May 19 nicklas 1495           ActivityDef.UPDATED_REGGIE.merge(dc, Reggie.VERSION, 1);
3059 19 Dec 14 nicklas 1496           dc.commit();
6713 28 Apr 22 nicklas 1497           cache.store("reggie/installed-version", Reggie.VERSION, 5);
3059 19 Dec 14 nicklas 1498           CounterService.getInstance().setForceCount();
3059 19 Dec 14 nicklas 1499         }
6713 28 Apr 22 nicklas 1500
6713 28 Apr 22 nicklas 1501         String installedVersion = cache.load("reggie/installed-version", 5);
6713 28 Apr 22 nicklas 1502         if (installedVersion == null) installedVersion = Reggie.VERSION;
6713 28 Apr 22 nicklas 1503         json.put("installedVersion", installedVersion);
1284 08 Feb 11 nicklas 1504       }
2157 05 Dec 13 nicklas 1505       
2157 05 Dec 13 nicklas 1506       else if ("GetPermissions".equals(cmd))
2157 05 Dec 13 nicklas 1507       {
6328 14 Jun 21 nicklas 1508         dc = sc.newDbControl(":Installation wizard");
3787 17 Mar 16 nicklas 1509         json.put("permissions", JsonUtil.getPermissions(dc));
3743 12 Feb 16 nicklas 1510         json.put("experimentalFeatures", JsonUtil.getExperimentalFeatures());
6684 20 Apr 22 nicklas 1511         json.put("configIsModified", Reggie.configIsModified());
4624 17 Nov 17 nicklas 1512         
6836 05 Sep 22 nicklas 1513         StaticCache cache = Application.getStaticCache();
6836 05 Sep 22 nicklas 1514         if (!cache.exists("reggie/installed-version"))
6836 05 Sep 22 nicklas 1515         {
6836 05 Sep 22 nicklas 1516           cache.store("reggie/installed-version", Reggie.VERSION, 5);
6836 05 Sep 22 nicklas 1517         }
4624 17 Nov 17 nicklas 1518         AnnotationType autoProc = Annotationtype.AUTO_PROCESSING.get(dc);
7399 07 Nov 23 nicklas 1519         JSONArray jsonAutoProcessingDisabled = new JSONArray();
7399 07 Nov 23 nicklas 1520         json.put("autoProcessingDisabled", jsonAutoProcessingDisabled);
4624 17 Nov 17 nicklas 1521         if (autoProc != null)
4624 17 Nov 17 nicklas 1522         {
7399 07 Nov 23 nicklas 1523           if (isDisabled(dc, BiomaterialList.FASTQ_IMPORT_PIPELINE.get(dc))) jsonAutoProcessingDisabled.add("fastq-import-pipeline-disabled");
7399 07 Nov 23 nicklas 1524           if (isDisabled(dc, Fileserver.IMPORT_GATEWAY.get(dc))) jsonAutoProcessingDisabled.add("json-auto-import-disabled");
7399 07 Nov 23 nicklas 1525           if (isDisabled(dc, BiomaterialList.HISAT_PIPELINE.get(dc))) jsonAutoProcessingDisabled.add("hisat-pipeline-disabled");
7399 07 Nov 23 nicklas 1526           if (isDisabled(dc, BiomaterialList.HISAT_2023_PIPELINE.get(dc))) jsonAutoProcessingDisabled.add("hisat2023-pipeline-disabled");
7399 07 Nov 23 nicklas 1527           if (isDisabled(dc, BiomaterialList.BWA_MEM2_PIPELINE.get(dc))) jsonAutoProcessingDisabled.add("bwamem2-pipeline-disabled");
7399 07 Nov 23 nicklas 1528           if (isDisabled(dc, BiomaterialList.LEGACY_PIPELINE.get(dc))) jsonAutoProcessingDisabled.add("legacy-pipeline-disabled");
7399 07 Nov 23 nicklas 1529           if (isDisabled(dc, BiomaterialList.STRINGTIE_PIPELINE.get(dc))) jsonAutoProcessingDisabled.add("stringtie-pipeline-disabled");
7399 07 Nov 23 nicklas 1530           if (isDisabled(dc, BiomaterialList.STRINGTIE_2023_PIPELINE.get(dc))) jsonAutoProcessingDisabled.add("stringtie2023-pipeline-disabled");
7399 07 Nov 23 nicklas 1531           if (isDisabled(dc, BiomaterialList.MBAF_PIPELINE.get(dc))) jsonAutoProcessingDisabled.add("mbaf-pipeline-disabled");
7399 07 Nov 23 nicklas 1532           if (isDisabled(dc, BiomaterialList.VARIANT_CALLING_PIPELINE.get(dc))) jsonAutoProcessingDisabled.add("variant-calling-pipeline-disabled");
7399 07 Nov 23 nicklas 1533           if (isDisabled(dc, BiomaterialList.TARGETED_GENOTYPE_PIPELINE.get(dc))) jsonAutoProcessingDisabled.add("targeted-genotype-pipeline-disabled");
7399 07 Nov 23 nicklas 1534           if (isDisabled(dc, BiomaterialList.SSP_PIPELINE.get(dc))) jsonAutoProcessingDisabled.add("ssp-pipeline-disabled");
7399 07 Nov 23 nicklas 1535           if (isDisabled(dc, BiomaterialList.GENE_REPORT_CREATE.get(dc))) jsonAutoProcessingDisabled.add("gene-report-disabled");
7399 07 Nov 23 nicklas 1536           if (isDisabled(dc, BiomaterialList.PILOT_REPORT_CREATE.get(dc))) jsonAutoProcessingDisabled.add("pilot-report-disabled");
7399 07 Nov 23 nicklas 1537           if (isDisabled(dc, BiomaterialList.SCANB_REPORT_CREATE.get(dc))) jsonAutoProcessingDisabled.add("scanb-report-disabled");
7399 07 Nov 23 nicklas 1538           if (isDisabled(dc, BiomaterialList.MIPS_ALIGN_PIPELINE.get(dc))) jsonAutoProcessingDisabled.add("mips-align-pipeline-disabled");
7399 07 Nov 23 nicklas 1539           if (isDisabled(dc, BiomaterialList.ASCAT_PIPELINE.get(dc))) jsonAutoProcessingDisabled.add("ascat-pipeline-disabled");
7399 07 Nov 23 nicklas 1540           if (isDisabled(dc, BiomaterialList.WGS_VARIANT_CALLING_PIPELINE.get(dc))) jsonAutoProcessingDisabled.add("wgs-variant-calling-pipeline-disabled");
4624 17 Nov 17 nicklas 1541         }
7399 07 Nov 23 nicklas 1542         JSONArray jsonHiddenWizards = new JSONArray();
7399 07 Nov 23 nicklas 1543         json.put("hiddenWizards", jsonHiddenWizards);
7399 07 Nov 23 nicklas 1544         ItemList variantImport = BiomaterialList.VARIANT_IMPORT_TMP.get(dc);
7399 07 Nov 23 nicklas 1545         if (variantImport == null || variantImport.getSize() == 0) jsonHiddenWizards.add("variant-import-wizard");
2157 05 Dec 13 nicklas 1546         dc.close();
2157 05 Dec 13 nicklas 1547       }
3116 06 Feb 15 nicklas 1548       
3116 06 Feb 15 nicklas 1549       else if ("GetParameterSetInfo".equals(cmd))
3116 06 Feb 15 nicklas 1550       {
3116 06 Feb 15 nicklas 1551         String parameterSet = Values.getStringOrNull(req.getParameter("parameterSet"));
3116 06 Feb 15 nicklas 1552         String targetId = Values.getStringOrNull(req.getParameter("targetId"));
3116 06 Feb 15 nicklas 1553         
3116 06 Feb 15 nicklas 1554         XmlConfig cfg = Reggie.getConfig();
3116 06 Feb 15 nicklas 1555         JSONArray jsonParameters = new JSONArray();
3116 06 Feb 15 nicklas 1556         json.put("parameterSet", parameterSet);
3116 06 Feb 15 nicklas 1557         json.put("parameters", jsonParameters);
3116 06 Feb 15 nicklas 1558         json.put("targetId", targetId);
3116 06 Feb 15 nicklas 1559         
3116 06 Feb 15 nicklas 1560         for (Element e : cfg.getAllInParameterSet(parameterSet))
3116 06 Feb 15 nicklas 1561         {
3116 06 Feb 15 nicklas 1562           JSONObject jsonElement = new JSONObject();
3116 06 Feb 15 nicklas 1563           jsonElement.put("value", e.getTextTrim());
3116 06 Feb 15 nicklas 1564           List<String> fullName = new ArrayList<String>();
3116 06 Feb 15 nicklas 1565           while (e != null)
3116 06 Feb 15 nicklas 1566           {
3117 06 Feb 15 nicklas 1567             String name = e.getName();
3117 06 Feb 15 nicklas 1568             if ("host".equals(name))
3117 06 Feb 15 nicklas 1569             {
3117 06 Feb 15 nicklas 1570               name += "[" + e.getAttributeValue("address") + ":" + e.getAttributeValue("port") + "]";
3117 06 Feb 15 nicklas 1571             }
3117 06 Feb 15 nicklas 1572             fullName.add(0, name);
3116 06 Feb 15 nicklas 1573             e = e.getParentElement();
3116 06 Feb 15 nicklas 1574           }
3116 06 Feb 15 nicklas 1575           jsonElement.put("name", Values.getString(fullName, "/", true));
3116 06 Feb 15 nicklas 1576           jsonParameters.add(jsonElement);
3116 06 Feb 15 nicklas 1577         }
3116 06 Feb 15 nicklas 1578       }
1284 08 Feb 11 nicklas 1579     }
1284 08 Feb 11 nicklas 1580     catch (Throwable t)
1284 08 Feb 11 nicklas 1581     {
1284 08 Feb 11 nicklas 1582       t.printStackTrace();
1284 08 Feb 11 nicklas 1583       json.clear();
1284 08 Feb 11 nicklas 1584       json.put("status", "error");
1284 08 Feb 11 nicklas 1585       json.put("message", t.getMessage());
1284 08 Feb 11 nicklas 1586       json.put("stacktrace", ThrowableUtil.stackTraceToString(t));
1284 08 Feb 11 nicklas 1587     }
1284 08 Feb 11 nicklas 1588     finally
1284 08 Feb 11 nicklas 1589     {
1284 08 Feb 11 nicklas 1590       if (dc != null) dc.close();
1284 08 Feb 11 nicklas 1591       json.writeJSONString(resp.getWriter());
1284 08 Feb 11 nicklas 1592     }
1284 08 Feb 11 nicklas 1593     
1284 08 Feb 11 nicklas 1594     
1284 08 Feb 11 nicklas 1595   }
1284 08 Feb 11 nicklas 1596   
7399 07 Nov 23 nicklas 1597   private boolean isDisabled(DbControl dc, Annotatable item)
7399 07 Nov 23 nicklas 1598   {
7399 07 Nov 23 nicklas 1599     return "Disable".equals(Annotationtype.AUTO_PROCESSING.getAnnotationValue(dc, item));
7399 07 Nov 23 nicklas 1600   }
2157 05 Dec 13 nicklas 1601   
7399 07 Nov 23 nicklas 1602   
5962 03 Jun 20 nicklas 1603   public List<JSONObject> checkSspInfo(DbControl dc, SspInfoResult info, List<Annotationtype> sspAnnotations, 
5962 03 Jun 20 nicklas 1604     boolean createIfMissing, PermissionOptions... permissions)
5962 03 Jun 20 nicklas 1605   {
5962 03 Jun 20 nicklas 1606     SspModel model = info.getModel();
5962 03 Jun 20 nicklas 1607     
5962 03 Jun 20 nicklas 1608     List<JSONObject> jsonChecks = new ArrayList<>();
5962 03 Jun 20 nicklas 1609     JSONObject json = new JSONObject();
5962 03 Jun 20 nicklas 1610     JSONArray jsonMessages = new JSONArray();
5962 03 Jun 20 nicklas 1611     json.put("itemType", "SSP");
5962 03 Jun 20 nicklas 1612     json.put("name", model.getName());
5962 03 Jun 20 nicklas 1613     json.put("status", "ok");
5962 03 Jun 20 nicklas 1614     
5962 03 Jun 20 nicklas 1615     if (model.modelDataExists())
5962 03 Jun 20 nicklas 1616     {
5962 03 Jun 20 nicklas 1617       Annotationtype sspResult = Annotationtype.sspResultAnnotation(model);
5962 03 Jun 20 nicklas 1618       jsonChecks.add(checkAnnotationType(dc, sspResult, 1, 
5962 03 Jun 20 nicklas 1619         new ValueOptions((Object[])info.getTranslatedClasses()), createIfMissing, permissions));
5962 03 Jun 20 nicklas 1620       sspAnnotations.add(sspResult);
5962 03 Jun 20 nicklas 1621       Annotationtype sspScore = Annotationtype.sspScoreAnnotation(model);
5962 03 Jun 20 nicklas 1622       if (sspScore != null)
5962 03 Jun 20 nicklas 1623       {
5962 03 Jun 20 nicklas 1624         jsonChecks.add(checkAnnotationType(dc, sspScore, 1, null, createIfMissing, permissions));
5962 03 Jun 20 nicklas 1625         sspAnnotations.add(sspScore);
5962 03 Jun 20 nicklas 1626       }
5962 03 Jun 20 nicklas 1627     }
5962 03 Jun 20 nicklas 1628     else
5962 03 Jun 20 nicklas 1629     {
5962 03 Jun 20 nicklas 1630       json.put("status", "warning");
5962 03 Jun 20 nicklas 1631       jsonMessages.add("File '"+model.getModelData()+"' not found. This SSP will be disabled.");
5962 03 Jun 20 nicklas 1632     }
5962 03 Jun 20 nicklas 1633
5962 03 Jun 20 nicklas 1634     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
5962 03 Jun 20 nicklas 1635     json.put("messages", jsonMessages);
5962 03 Jun 20 nicklas 1636     jsonChecks.add(json);
5962 03 Jun 20 nicklas 1637     
5962 03 Jun 20 nicklas 1638     return jsonChecks;
5962 03 Jun 20 nicklas 1639   }
5962 03 Jun 20 nicklas 1640   
1284 08 Feb 11 nicklas 1641   /**
1409 18 Oct 11 martin 1642     Creates an annotation type with the given options. The annotation
1409 18 Oct 11 martin 1643     type is created in a separate transaction. The annotation can be enabled for 
1409 18 Oct 11 martin 1644     one or more item-types.
1409 18 Oct 11 martin 1645     
1610 23 Apr 12 nicklas 1646     @since 2.5
1409 18 Oct 11 martin 1647    */
1610 23 Apr 12 nicklas 1648   public AnnotationType createAnnotationType(SessionControl sc, Annotationtype annotationType, 
4001 17 Jun 16 nicklas 1649       int multiplicity, ValueOptions valueOptions, PermissionOptions... permissions)
1409 18 Oct 11 martin 1650   {
1284 08 Feb 11 nicklas 1651     AnnotationType at = null;
6328 14 Jun 21 nicklas 1652     DbControl dc = sc.newDbControl(":Installation wizard");
1284 08 Feb 11 nicklas 1653     try
1284 08 Feb 11 nicklas 1654     {
1610 23 Apr 12 nicklas 1655       at = AnnotationType.getNew(dc, annotationType.getValueType());
1610 23 Apr 12 nicklas 1656       at.setName(annotationType.getName());
5962 03 Jun 20 nicklas 1657       at.setDescription(annotationType.getDescription());
1610 23 Apr 12 nicklas 1658       for (Item it : annotationType.getMainType())
1409 18 Oct 11 martin 1659       {
1409 18 Oct 11 martin 1660         at.enableForItem(it);
1409 18 Oct 11 martin 1661       }
1285 08 Feb 11 nicklas 1662       at.setMultiplicity(multiplicity);
5799 18 Dec 19 nicklas 1663       at.setDisableLogOfValues(annotationType.getDisableChangeHistoryLog());
1639 09 May 12 nicklas 1664       if (valueOptions != null)
1284 08 Feb 11 nicklas 1665       {
1639 09 May 12 nicklas 1666         if (valueOptions.isEnumeration())
1639 09 May 12 nicklas 1667         {
1639 09 May 12 nicklas 1668           at.setEnumeration(true);
1639 09 May 12 nicklas 1669           at.setDisplayAsList(false);
1639 09 May 12 nicklas 1670           at.setValues(valueOptions.getList());
1639 09 May 12 nicklas 1671         }
1639 09 May 12 nicklas 1672         else if (at.getValueType().isNumerical())
1639 09 May 12 nicklas 1673         {
1639 09 May 12 nicklas 1674           Integer max = valueOptions.getMax();
1639 09 May 12 nicklas 1675           if (max != null)
1639 09 May 12 nicklas 1676           {
1639 09 May 12 nicklas 1677             at.setMaxValueLong(max.longValue());
1639 09 May 12 nicklas 1678           }
1639 09 May 12 nicklas 1679           Integer min = valueOptions.getMin();
1639 09 May 12 nicklas 1680           if (min != null)
1639 09 May 12 nicklas 1681           {
1639 09 May 12 nicklas 1682             at.setMinValueLong(min.longValue());
1639 09 May 12 nicklas 1683           }
1639 09 May 12 nicklas 1684         }
1284 08 Feb 11 nicklas 1685       }
4001 17 Jun 16 nicklas 1686       if (permissions != null) 
4001 17 Jun 16 nicklas 1687       {
4001 17 Jun 16 nicklas 1688         for (PermissionOptions p : permissions)
4001 17 Jun 16 nicklas 1689         {
4001 17 Jun 16 nicklas 1690           p.applyPermissions(at);
4001 17 Jun 16 nicklas 1691         }
4001 17 Jun 16 nicklas 1692       }
1284 08 Feb 11 nicklas 1693       dc.saveItem(at);
1284 08 Feb 11 nicklas 1694       dc.commit();
1284 08 Feb 11 nicklas 1695     }
1284 08 Feb 11 nicklas 1696     finally
1284 08 Feb 11 nicklas 1697     {
1284 08 Feb 11 nicklas 1698       if (dc != null) dc.close();
1284 08 Feb 11 nicklas 1699     }
1284 08 Feb 11 nicklas 1700     return at;
1284 08 Feb 11 nicklas 1701   }
1284 08 Feb 11 nicklas 1702
1284 08 Feb 11 nicklas 1703   /**
1284 08 Feb 11 nicklas 1704     Check for an existing annotation type with the given options. A JSONObject is returned
1284 08 Feb 11 nicklas 1705     with the result. The following keys are used:
1284 08 Feb 11 nicklas 1706     <ul>
1284 08 Feb 11 nicklas 1707     <li>itemType: ANNOTATIONTYPE
1284 08 Feb 11 nicklas 1708     <li>name: The name of the annotation type
1284 08 Feb 11 nicklas 1709     <li>id: The id of the annotation type if it exists
1284 08 Feb 11 nicklas 1710     <li>status: ok, error, or missing
1284 08 Feb 11 nicklas 1711     <li>message: A descriptive message in case of an error
1284 08 Feb 11 nicklas 1712     </ul>
1409 18 Oct 11 martin 1713     
1610 23 Apr 12 nicklas 1714     @since 2.5
1409 18 Oct 11 martin 1715   */
1610 23 Apr 12 nicklas 1716   public JSONObject checkAnnotationType(DbControl dc, Annotationtype annotationType, 
4001 17 Jun 16 nicklas 1717       int multiplicity, ValueOptions valueOptions, boolean createIfMissing, 
4001 17 Jun 16 nicklas 1718       PermissionOptions... permissions)
1409 18 Oct 11 martin 1719   {
1284 08 Feb 11 nicklas 1720     JSONObject json = new JSONObject();
1309 04 Mar 11 nicklas 1721     JSONArray jsonMessages = new JSONArray();
1284 08 Feb 11 nicklas 1722     json.put("itemType", Item.ANNOTATIONTYPE.name());
1610 23 Apr 12 nicklas 1723     json.put("name", annotationType.getName());
1284 08 Feb 11 nicklas 1724     
1610 23 Apr 12 nicklas 1725     List<AnnotationType> result = annotationType.list(dc);
1284 08 Feb 11 nicklas 1726     if (result.size() == 0)
1284 08 Feb 11 nicklas 1727     {
1284 08 Feb 11 nicklas 1728       if (createIfMissing)
1284 08 Feb 11 nicklas 1729       {
1610 23 Apr 12 nicklas 1730         AnnotationType at = createAnnotationType(dc.getSessionControl(), annotationType, 
1639 09 May 12 nicklas 1731             multiplicity, valueOptions, permissions);
1284 08 Feb 11 nicklas 1732         json.put("id", at.getId());
1284 08 Feb 11 nicklas 1733         json.put("status", "ok");
1309 04 Mar 11 nicklas 1734         jsonMessages.add("Created");
1284 08 Feb 11 nicklas 1735       }
1284 08 Feb 11 nicklas 1736       else
1284 08 Feb 11 nicklas 1737       {
1284 08 Feb 11 nicklas 1738         json.put("status", "missing");
1309 04 Mar 11 nicklas 1739         jsonMessages.add("Not found");
1284 08 Feb 11 nicklas 1740       }
1284 08 Feb 11 nicklas 1741     }
1284 08 Feb 11 nicklas 1742     else if (result.size() > 1)
1284 08 Feb 11 nicklas 1743     {
1284 08 Feb 11 nicklas 1744       json.put("status", "error");
1309 04 Mar 11 nicklas 1745       jsonMessages.add("Found > 1 annotation type");
1284 08 Feb 11 nicklas 1746     }
1284 08 Feb 11 nicklas 1747     else
1284 08 Feb 11 nicklas 1748     {
1284 08 Feb 11 nicklas 1749       AnnotationType at = result.get(0);
1284 08 Feb 11 nicklas 1750       json.put("id", at.getId());
1309 04 Mar 11 nicklas 1751       json.put("status", "ok");// For now -- more checks below
4001 17 Jun 16 nicklas 1752       if (permissions != null)
1284 08 Feb 11 nicklas 1753       {
4001 17 Jun 16 nicklas 1754         String permissionCheck = null;
4001 17 Jun 16 nicklas 1755         for (PermissionOptions p : permissions)
1570 16 Mar 12 nicklas 1756         {
4001 17 Jun 16 nicklas 1757           if (!p.checkPermissions(at))
4001 17 Jun 16 nicklas 1758           {
4001 17 Jun 16 nicklas 1759             permissionCheck = p.getMessage();
4001 17 Jun 16 nicklas 1760             break;
4001 17 Jun 16 nicklas 1761           }
1570 16 Mar 12 nicklas 1762         }
4001 17 Jun 16 nicklas 1763         
4001 17 Jun 16 nicklas 1764         if (permissionCheck != null)
1570 16 Mar 12 nicklas 1765         {
4001 17 Jun 16 nicklas 1766           if (createIfMissing)
4001 17 Jun 16 nicklas 1767           {
4001 17 Jun 16 nicklas 1768             for (PermissionOptions p : permissions)
4001 17 Jun 16 nicklas 1769             {
4001 17 Jun 16 nicklas 1770               p.applyPermissions(at);
4001 17 Jun 16 nicklas 1771             }
4001 17 Jun 16 nicklas 1772             if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
4001 17 Jun 16 nicklas 1773           }
4001 17 Jun 16 nicklas 1774           else
4001 17 Jun 16 nicklas 1775           {
4001 17 Jun 16 nicklas 1776             json.put("status", "incomplete");
4001 17 Jun 16 nicklas 1777             jsonMessages.add(permissionCheck);
4001 17 Jun 16 nicklas 1778           }
1570 16 Mar 12 nicklas 1779         }
1284 08 Feb 11 nicklas 1780       }
1985 21 May 13 nicklas 1781       boolean allTypesOk = true;
1985 21 May 13 nicklas 1782       boolean fixedTypes = false;
1610 23 Apr 12 nicklas 1783       for (Item it : annotationType.getMainType())
1284 08 Feb 11 nicklas 1784       {
1409 18 Oct 11 martin 1785         if (!at.isEnabledForItem(it))
1409 18 Oct 11 martin 1786         {
1985 21 May 13 nicklas 1787           allTypesOk = false;
1985 21 May 13 nicklas 1788           if (createIfMissing)
1985 21 May 13 nicklas 1789           {
1985 21 May 13 nicklas 1790             at.enableForItem(it);
1985 21 May 13 nicklas 1791             fixedTypes = true;
1985 21 May 13 nicklas 1792           }
1985 21 May 13 nicklas 1793           else
1985 21 May 13 nicklas 1794           {
1985 21 May 13 nicklas 1795             json.put("status", "incomplete");
1985 21 May 13 nicklas 1796             jsonMessages.add("Not enabled for " + it.name());
1985 21 May 13 nicklas 1797           }
1409 18 Oct 11 martin 1798         }
1284 08 Feb 11 nicklas 1799       }
1985 21 May 13 nicklas 1800       if (fixedTypes && jsonMessages.size() == 0) jsonMessages.add("Fixed");
1610 23 Apr 12 nicklas 1801       if (at.getValueType() != annotationType.getValueType())
1284 08 Feb 11 nicklas 1802       {
1284 08 Feb 11 nicklas 1803         json.put("status", "error");
1610 23 Apr 12 nicklas 1804         jsonMessages.add("Is not a " + annotationType.getValueType().name() + " type");
1284 08 Feb 11 nicklas 1805       }
1309 04 Mar 11 nicklas 1806       if (at.getMultiplicity() != multiplicity)
1285 08 Feb 11 nicklas 1807       {
5899 15 Apr 20 nicklas 1808         if (createIfMissing)
5899 15 Apr 20 nicklas 1809         {
5899 15 Apr 20 nicklas 1810           at.setMultiplicity(multiplicity);
5899 15 Apr 20 nicklas 1811           if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
5899 15 Apr 20 nicklas 1812         }
5899 15 Apr 20 nicklas 1813         else
5899 15 Apr 20 nicklas 1814         {
5899 15 Apr 20 nicklas 1815           json.put("status", "incomplete");
5899 15 Apr 20 nicklas 1816           jsonMessages.add("Should have multiplicity=" + (multiplicity == 0 ? "unlimited" : multiplicity));
5899 15 Apr 20 nicklas 1817         }
1285 08 Feb 11 nicklas 1818       }
2351 10 Apr 14 nicklas 1819       if (at.getDisableLogOfValues() != annotationType.getDisableChangeHistoryLog())
2351 10 Apr 14 nicklas 1820       {
2351 10 Apr 14 nicklas 1821         if (createIfMissing)
2351 10 Apr 14 nicklas 1822         {
2351 10 Apr 14 nicklas 1823           at.setDisableLogOfValues(annotationType.getDisableChangeHistoryLog());
2351 10 Apr 14 nicklas 1824           if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
2351 10 Apr 14 nicklas 1825         }
2351 10 Apr 14 nicklas 1826         else
2351 10 Apr 14 nicklas 1827         {
2351 10 Apr 14 nicklas 1828           json.put("status", "incomplete");
2351 10 Apr 14 nicklas 1829           if (annotationType.getDisableChangeHistoryLog())
2351 10 Apr 14 nicklas 1830           {
2351 10 Apr 14 nicklas 1831             jsonMessages.add("Should disable change log");
2351 10 Apr 14 nicklas 1832           }
2351 10 Apr 14 nicklas 1833           else
2351 10 Apr 14 nicklas 1834           {
2351 10 Apr 14 nicklas 1835             jsonMessages.add("Should not disable change log");
2351 10 Apr 14 nicklas 1836           }
2351 10 Apr 14 nicklas 1837         }
2351 10 Apr 14 nicklas 1838       }
1639 09 May 12 nicklas 1839       if (at.isEnumeration() && (valueOptions == null || !valueOptions.isEnumeration()))
1284 08 Feb 11 nicklas 1840       {
1284 08 Feb 11 nicklas 1841         json.put("status", "error");
1309 04 Mar 11 nicklas 1842         jsonMessages.add("Should not be an enumeration");
1284 08 Feb 11 nicklas 1843       }
1639 09 May 12 nicklas 1844       if (valueOptions != null)
1284 08 Feb 11 nicklas 1845       {
1639 09 May 12 nicklas 1846         if (valueOptions.isEnumeration())
1284 08 Feb 11 nicklas 1847         {
1639 09 May 12 nicklas 1848           if (!at.isEnumeration())
1639 09 May 12 nicklas 1849           {
1639 09 May 12 nicklas 1850             json.put("status", "error");
1639 09 May 12 nicklas 1851             jsonMessages.add("Is not enumeration of: " + valueOptions.getList());
1639 09 May 12 nicklas 1852           }
5894 08 Apr 20 nicklas 1853           else
1639 09 May 12 nicklas 1854           {
5894 08 Apr 20 nicklas 1855             List<Object> missing = valueOptions.getMissingOptions(at);
5894 08 Apr 20 nicklas 1856             List<Object> extraOptions = valueOptions.getExtraOptions(at);
5894 08 Apr 20 nicklas 1857             if (missing.size() > 0)
1889 27 Feb 13 nicklas 1858             {
5894 08 Apr 20 nicklas 1859               if (createIfMissing)
5894 08 Apr 20 nicklas 1860               {
5894 08 Apr 20 nicklas 1861                 valueOptions.applyEnumeration(at);
5894 08 Apr 20 nicklas 1862                 if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
5894 08 Apr 20 nicklas 1863               }
5894 08 Apr 20 nicklas 1864               else
5894 08 Apr 20 nicklas 1865               {
5894 08 Apr 20 nicklas 1866                 json.put("status", "incomplete");
5894 08 Apr 20 nicklas 1867                 jsonMessages.add(missing.size() + " missing option(s): " + Values.getString(missing, ", ", true));
5894 08 Apr 20 nicklas 1868               }
1889 27 Feb 13 nicklas 1869             }
5894 08 Apr 20 nicklas 1870             else if (extraOptions.size() > 0)
1889 27 Feb 13 nicklas 1871             {
5894 08 Apr 20 nicklas 1872               json.put("status", "warning");
5894 08 Apr 20 nicklas 1873               jsonMessages.add(extraOptions.size() + " extra option(s): " + Values.getString(extraOptions, ", ", true));
1889 27 Feb 13 nicklas 1874             }
5894 08 Apr 20 nicklas 1875               
1639 09 May 12 nicklas 1876           }
1284 08 Feb 11 nicklas 1877         }
1639 09 May 12 nicklas 1878         if (valueOptions.getMax() != null)
1284 08 Feb 11 nicklas 1879         {
1639 09 May 12 nicklas 1880           if (at.getMaxValueLong() == null || at.getMaxValueLong().longValue() != valueOptions.getMax().longValue())
1639 09 May 12 nicklas 1881           {
1639 09 May 12 nicklas 1882             json.put("status", "error");
1639 09 May 12 nicklas 1883             jsonMessages.add("Should have max allowed value=" + valueOptions.getMax());
1639 09 May 12 nicklas 1884           }
1284 08 Feb 11 nicklas 1885         }
1639 09 May 12 nicklas 1886         if (valueOptions.getMin() != null)
1639 09 May 12 nicklas 1887         {
1639 09 May 12 nicklas 1888           if (at.getMinValueLong() == null || at.getMinValueLong().longValue() != valueOptions.getMin().longValue())
1639 09 May 12 nicklas 1889           {
1639 09 May 12 nicklas 1890             json.put("status", "error");
1639 09 May 12 nicklas 1891             jsonMessages.add("Should have min allowed value=" + valueOptions.getMin());
1639 09 May 12 nicklas 1892           }
1639 09 May 12 nicklas 1893         }
1284 08 Feb 11 nicklas 1894       }
1284 08 Feb 11 nicklas 1895     }
1309 04 Mar 11 nicklas 1896     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
1309 04 Mar 11 nicklas 1897     json.put("messages", jsonMessages);
1284 08 Feb 11 nicklas 1898     return json;
1284 08 Feb 11 nicklas 1899   }
1284 08 Feb 11 nicklas 1900   
1284 08 Feb 11 nicklas 1901   /**
2157 05 Dec 13 nicklas 1902     Create a group or role with the given options. The item is created in
1284 08 Feb 11 nicklas 1903     a separate transaction.
1284 08 Feb 11 nicklas 1904   */
3571 30 Oct 15 nicklas 1905   public <T extends BasicItem & Nameable> T createReggieRole(SessionControl sc, ReggieRole<T> role)
1284 08 Feb 11 nicklas 1906   {
2157 05 Dec 13 nicklas 1907     T r = null;
6328 14 Jun 21 nicklas 1908     DbControl dc = sc.newDbControl(":Installation wizard");
1284 08 Feb 11 nicklas 1909     try
1284 08 Feb 11 nicklas 1910     {
2157 05 Dec 13 nicklas 1911       r = role.create(dc);
2157 05 Dec 13 nicklas 1912       r.setName(role.getName());
3987 10 Jun 16 nicklas 1913       if (role.getActualType() == Item.GROUP)
3987 10 Jun 16 nicklas 1914       {
3987 10 Jun 16 nicklas 1915         Group g = (Group)r;
3987 10 Jun 16 nicklas 1916         g.setHiddenMembers(role.hasHiddenMembers());
3987 10 Jun 16 nicklas 1917       }
2157 05 Dec 13 nicklas 1918       dc.saveItem(r);
1284 08 Feb 11 nicklas 1919       dc.commit();
1284 08 Feb 11 nicklas 1920     }
1284 08 Feb 11 nicklas 1921     finally
1284 08 Feb 11 nicklas 1922     {
1284 08 Feb 11 nicklas 1923       if (dc != null) dc.close();
1284 08 Feb 11 nicklas 1924     }
2157 05 Dec 13 nicklas 1925     return r;
1284 08 Feb 11 nicklas 1926   }
1284 08 Feb 11 nicklas 1927
1284 08 Feb 11 nicklas 1928   /**
2157 05 Dec 13 nicklas 1929     Check for an existing reggie role (a BASE role or group) with the given options.
2157 05 Dec 13 nicklas 1930     A JSONObject is returned with the result. The following keys are used:
1284 08 Feb 11 nicklas 1931     <ul>
2157 05 Dec 13 nicklas 1932     <li>itemType: GROUP or ROLE
2157 05 Dec 13 nicklas 1933     <li>name: The name of the item
2157 05 Dec 13 nicklas 1934     <li>id: The id of the item if it exists
1284 08 Feb 11 nicklas 1935     <li>status: ok, error, or missing
1284 08 Feb 11 nicklas 1936     <li>message: A descriptive message in case of an error
1284 08 Feb 11 nicklas 1937     </ul>
1284 08 Feb 11 nicklas 1938   */
2157 05 Dec 13 nicklas 1939   public JSONObject checkReggieRole(DbControl dc, ReggieRole<? extends BasicItem> role, boolean createIfMissing)
1284 08 Feb 11 nicklas 1940   {
1284 08 Feb 11 nicklas 1941     JSONObject json = new JSONObject();
1309 04 Mar 11 nicklas 1942     JSONArray jsonMessages = new JSONArray();
2157 05 Dec 13 nicklas 1943     json.put("itemType", role.getActualType().name());
2157 05 Dec 13 nicklas 1944     json.put("name", role.getName());
1309 04 Mar 11 nicklas 1945     
2157 05 Dec 13 nicklas 1946     List<? extends BasicItem> result = role.list(dc);
1284 08 Feb 11 nicklas 1947     if (result.size() == 0)
1284 08 Feb 11 nicklas 1948     {
1284 08 Feb 11 nicklas 1949       if (createIfMissing)
1284 08 Feb 11 nicklas 1950       {
2157 05 Dec 13 nicklas 1951         BasicItem g = createReggieRole(dc.getSessionControl(), role);
1284 08 Feb 11 nicklas 1952         json.put("id", g.getId());
1284 08 Feb 11 nicklas 1953         json.put("status", "ok");
1309 04 Mar 11 nicklas 1954         jsonMessages.add("Created");
1284 08 Feb 11 nicklas 1955       }
1284 08 Feb 11 nicklas 1956       else
1284 08 Feb 11 nicklas 1957       {
1284 08 Feb 11 nicklas 1958         json.put("status", "missing");
1309 04 Mar 11 nicklas 1959         jsonMessages.add("Not found");
1284 08 Feb 11 nicklas 1960       }
1284 08 Feb 11 nicklas 1961     }
1284 08 Feb 11 nicklas 1962     else if (result.size() > 1)
1284 08 Feb 11 nicklas 1963     {
1284 08 Feb 11 nicklas 1964       json.put("status", "error");
2157 05 Dec 13 nicklas 1965       jsonMessages.add("Found > 1 " + role.getActualType().toString());
1284 08 Feb 11 nicklas 1966     }
1284 08 Feb 11 nicklas 1967     else
1284 08 Feb 11 nicklas 1968     {
3987 10 Jun 16 nicklas 1969       BasicItem r = result.get(0);
3987 10 Jun 16 nicklas 1970       json.put("id", r.getId());
3987 10 Jun 16 nicklas 1971       json.put("status", "ok"); // For now -- more checks below
3987 10 Jun 16 nicklas 1972       
3987 10 Jun 16 nicklas 1973       if (role.getActualType() == Item.GROUP)
3987 10 Jun 16 nicklas 1974       {
3987 10 Jun 16 nicklas 1975         Group g = (Group)r;
3987 10 Jun 16 nicklas 1976         if (role.hasHiddenMembers())
3987 10 Jun 16 nicklas 1977         {
3987 10 Jun 16 nicklas 1978           if (!g.hasHiddenMembers())
3987 10 Jun 16 nicklas 1979           {
3987 10 Jun 16 nicklas 1980             if (createIfMissing)
3987 10 Jun 16 nicklas 1981             {
3987 10 Jun 16 nicklas 1982               g.setHiddenMembers(true);
3987 10 Jun 16 nicklas 1983               jsonMessages.add("Fixed");
3987 10 Jun 16 nicklas 1984             }
3987 10 Jun 16 nicklas 1985             else
3987 10 Jun 16 nicklas 1986             {
3987 10 Jun 16 nicklas 1987               json.put("status", "incomplete");
3987 10 Jun 16 nicklas 1988               jsonMessages.add("Should have hidden members");
3987 10 Jun 16 nicklas 1989             }
3987 10 Jun 16 nicklas 1990           }
3987 10 Jun 16 nicklas 1991         }
3987 10 Jun 16 nicklas 1992       }
1284 08 Feb 11 nicklas 1993     }
1309 04 Mar 11 nicklas 1994     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
1309 04 Mar 11 nicklas 1995     json.put("messages", jsonMessages);
1284 08 Feb 11 nicklas 1996     return json;
1309 04 Mar 11 nicklas 1997   }
1284 08 Feb 11 nicklas 1998
1309 04 Mar 11 nicklas 1999   public JSONObject checkActiveProject(DbControl dc)
1309 04 Mar 11 nicklas 2000   {
1309 04 Mar 11 nicklas 2001     JSONObject json = new JSONObject();
1309 04 Mar 11 nicklas 2002     JSONArray jsonMessages = new JSONArray();
1309 04 Mar 11 nicklas 2003     json.put("itemType", Item.PROJECT.name());
1309 04 Mar 11 nicklas 2004     
1309 04 Mar 11 nicklas 2005     int projectId = dc.getSessionControl().getActiveProjectId();
1309 04 Mar 11 nicklas 2006     if (projectId == 0)
1309 04 Mar 11 nicklas 2007     {
1309 04 Mar 11 nicklas 2008       json.put("status", "warning");
1309 04 Mar 11 nicklas 2009       json.put("name", "not selected");
1309 04 Mar 11 nicklas 2010       jsonMessages.add("No active project");
1309 04 Mar 11 nicklas 2011     }
1309 04 Mar 11 nicklas 2012     else
1309 04 Mar 11 nicklas 2013     {
1309 04 Mar 11 nicklas 2014       Project p = Project.getById(dc, projectId);
1309 04 Mar 11 nicklas 2015       json.put("name", p.getName());
1309 04 Mar 11 nicklas 2016       json.put("id", projectId);
1309 04 Mar 11 nicklas 2017       json.put("status", "ok");
1309 04 Mar 11 nicklas 2018     }
1309 04 Mar 11 nicklas 2019     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
1309 04 Mar 11 nicklas 2020     json.put("messages", jsonMessages);
1309 04 Mar 11 nicklas 2021     return json;
1284 08 Feb 11 nicklas 2022   }
1284 08 Feb 11 nicklas 2023
1463 14 Nov 11 martin 2024   /**
1463 14 Nov 11 martin 2025     Create a subtype with the given options. The subtype is created in
1463 14 Nov 11 martin 2026     a separate transaction.
1463 14 Nov 11 martin 2027     @since 2.0
1463 14 Nov 11 martin 2028   */
2565 11 Aug 14 nicklas 2029   public ItemSubtype createSubtype(SessionControl sc, Subtype def, Datafiletype fileType, Subtype... relatedTo)
1463 14 Nov 11 martin 2030   {
1463 14 Nov 11 martin 2031     ItemSubtype subtype = null;
6328 14 Jun 21 nicklas 2032     DbControl dc = sc.newDbControl(":Installation wizard");
1463 14 Nov 11 martin 2033     try
1463 14 Nov 11 martin 2034     {
1463 14 Nov 11 martin 2035       subtype = ItemSubtype.getNew(dc, def.getMainType());
1463 14 Nov 11 martin 2036       subtype.setName(def.getName());
1644 15 May 12 nicklas 2037       subtype.setPushAnnotations(def.getPushAnnotations());
1463 14 Nov 11 martin 2038       
2565 11 Aug 14 nicklas 2039       if (fileType != null)
2565 11 Aug 14 nicklas 2040       {
2565 11 Aug 14 nicklas 2041         ItemSubtypeFileType ft = subtype.getAssociatedDataFileType(fileType.load(dc), true);
2565 11 Aug 14 nicklas 2042         ft.setRequired(fileType.isRequired());
2565 11 Aug 14 nicklas 2043         ft.setAllowMultiple(fileType.getAllowMultiple());
2565 11 Aug 14 nicklas 2044       }
2565 11 Aug 14 nicklas 2045       
1463 14 Nov 11 martin 2046       if (relatedTo != null)
1463 14 Nov 11 martin 2047       {
1463 14 Nov 11 martin 2048         for (Subtype related : relatedTo)
1463 14 Nov 11 martin 2049         {
1644 15 May 12 nicklas 2050           ItemSubtype r = related.get(dc);
1644 15 May 12 nicklas 2051           if (r != null) subtype.setRelatedSubtype(r);
1463 14 Nov 11 martin 2052         }
1463 14 Nov 11 martin 2053       }
1463 14 Nov 11 martin 2054       
1463 14 Nov 11 martin 2055       dc.saveItem(subtype);
1463 14 Nov 11 martin 2056       dc.commit();
1463 14 Nov 11 martin 2057     }
1463 14 Nov 11 martin 2058     finally
1463 14 Nov 11 martin 2059     {
1463 14 Nov 11 martin 2060       if (dc != null) dc.close();
1463 14 Nov 11 martin 2061     }
1463 14 Nov 11 martin 2062     return subtype;
1463 14 Nov 11 martin 2063   }
1309 04 Mar 11 nicklas 2064   
1284 08 Feb 11 nicklas 2065   /**
1463 14 Nov 11 martin 2066     Check for an existing item subtype with the given options.
1463 14 Nov 11 martin 2067     A JSONObject is returned with the result. The following 
1463 14 Nov 11 martin 2068     keys are used:
1463 14 Nov 11 martin 2069     <ul>
1463 14 Nov 11 martin 2070     <li>itemType: ITEMSUBTYPE
1463 14 Nov 11 martin 2071     <li>name: The name of the subtype
1463 14 Nov 11 martin 2072     <li>id: The id of the subtype if it exists
1463 14 Nov 11 martin 2073     <li>mainType: The main item type that the subtype applies to
1463 14 Nov 11 martin 2074     <li>status: ok, error, or missing
1463 14 Nov 11 martin 2075     <li>message: A descriptive message in case of an error
2565 11 Aug 14 nicklas 2076     </ul
1463 14 Nov 11 martin 2077     @since 2.0
1463 14 Nov 11 martin 2078   */
1463 14 Nov 11 martin 2079   public JSONObject checkSubtype(DbControl dc, Subtype subtype, 
2565 11 Aug 14 nicklas 2080     Datafiletype fileType, boolean createIfMissing, Subtype... relatedTo)
1463 14 Nov 11 martin 2081   {
1463 14 Nov 11 martin 2082   
1463 14 Nov 11 martin 2083     JSONObject json = new JSONObject();
1463 14 Nov 11 martin 2084     JSONArray jsonMessages = new JSONArray();
1463 14 Nov 11 martin 2085     json.put("itemType", Item.ITEMSUBTYPE.name());
1463 14 Nov 11 martin 2086     json.put("name", subtype.getName());
1463 14 Nov 11 martin 2087     json.put("mainType", subtype.getMainType().name());
1463 14 Nov 11 martin 2088       
1610 23 Apr 12 nicklas 2089     List<ItemSubtype> result = subtype.list(dc);
1463 14 Nov 11 martin 2090     if (result.size() == 0)
1463 14 Nov 11 martin 2091     {
1463 14 Nov 11 martin 2092       if (createIfMissing)
1463 14 Nov 11 martin 2093       {
2565 11 Aug 14 nicklas 2094         ItemSubtype s = createSubtype(dc.getSessionControl(), subtype, fileType, relatedTo);
1463 14 Nov 11 martin 2095         json.put("id", s.getId());
1463 14 Nov 11 martin 2096         json.put("status", "ok");
1463 14 Nov 11 martin 2097         jsonMessages.add("Created");
1463 14 Nov 11 martin 2098       }
1463 14 Nov 11 martin 2099       else
1463 14 Nov 11 martin 2100       {
1463 14 Nov 11 martin 2101         json.put("status", "missing");
1463 14 Nov 11 martin 2102         jsonMessages.add("Not found");
1463 14 Nov 11 martin 2103       }
1463 14 Nov 11 martin 2104     }
1463 14 Nov 11 martin 2105     else if (result.size() > 1)
1463 14 Nov 11 martin 2106     {
1463 14 Nov 11 martin 2107       json.put("status", "error");
1463 14 Nov 11 martin 2108       jsonMessages.add("Found > 1 subtype");
1463 14 Nov 11 martin 2109     }
1463 14 Nov 11 martin 2110     else
1463 14 Nov 11 martin 2111     {
1463 14 Nov 11 martin 2112       ItemSubtype s = result.get(0);
1463 14 Nov 11 martin 2113       json.put("id", s.getId());
1463 14 Nov 11 martin 2114       json.put("status", "ok"); // For now -- more checks below
1463 14 Nov 11 martin 2115       
1627 27 Apr 12 nicklas 2116       if (subtype.getPushAnnotations() != s.getPushAnnotations())
1627 27 Apr 12 nicklas 2117       {
4361 16 Feb 17 nicklas 2118         if (createIfMissing)
4361 16 Feb 17 nicklas 2119         {
4361 16 Feb 17 nicklas 2120           s.setPushAnnotations(subtype.getPushAnnotations());
4361 16 Feb 17 nicklas 2121           jsonMessages.add("Fixed");
4361 16 Feb 17 nicklas 2122         }
4361 16 Feb 17 nicklas 2123         else
4361 16 Feb 17 nicklas 2124         {
4361 16 Feb 17 nicklas 2125           json.put("status", "incomplete");
4361 16 Feb 17 nicklas 2126           jsonMessages.add("Should have 'Push annotations to parent'="+subtype.getPushAnnotations());
4361 16 Feb 17 nicklas 2127         }
1627 27 Apr 12 nicklas 2128       }
1627 27 Apr 12 nicklas 2129       
2565 11 Aug 14 nicklas 2130       if (fileType != null)
2565 11 Aug 14 nicklas 2131       {
2709 30 Sep 14 nicklas 2132         DataFileType dft = fileType.get(dc);
2709 30 Sep 14 nicklas 2133         if (dft != null && !s.isAssociatedDataFileType(dft))
2565 11 Aug 14 nicklas 2134         {
2565 11 Aug 14 nicklas 2135           if (createIfMissing)
2565 11 Aug 14 nicklas 2136           {
2709 30 Sep 14 nicklas 2137             ItemSubtypeFileType ft = s.getAssociatedDataFileType(dft, true);
2565 11 Aug 14 nicklas 2138             ft.setRequired(fileType.isRequired());
2565 11 Aug 14 nicklas 2139             ft.setAllowMultiple(fileType.getAllowMultiple());
2565 11 Aug 14 nicklas 2140             jsonMessages.add("Fixed");
2565 11 Aug 14 nicklas 2141           }
2565 11 Aug 14 nicklas 2142           else
2565 11 Aug 14 nicklas 2143           {
2565 11 Aug 14 nicklas 2144             json.put("status", "incomplete");
2565 11 Aug 14 nicklas 2145             jsonMessages.add("Should be related to '" + fileType.getName() + " file type");
2565 11 Aug 14 nicklas 2146           }
2565 11 Aug 14 nicklas 2147         }
2565 11 Aug 14 nicklas 2148       }
2565 11 Aug 14 nicklas 2149       
1463 14 Nov 11 martin 2150       if (relatedTo != null)
1463 14 Nov 11 martin 2151       {
1463 14 Nov 11 martin 2152         for (Subtype related : relatedTo)
1463 14 Nov 11 martin 2153         {
1463 14 Nov 11 martin 2154           ItemSubtype r = s.getRelatedSubtype(related.getMainType());
1463 14 Nov 11 martin 2155           if (r == null)
1463 14 Nov 11 martin 2156           {
1644 15 May 12 nicklas 2157             r = related.get(dc);
1639 09 May 12 nicklas 2158             if (createIfMissing && r != null)
1639 09 May 12 nicklas 2159             {
1639 09 May 12 nicklas 2160               s.setRelatedSubtype(r);
1639 09 May 12 nicklas 2161               jsonMessages.add("Fixed");
1639 09 May 12 nicklas 2162             }
1639 09 May 12 nicklas 2163             else
1639 09 May 12 nicklas 2164             {
1639 09 May 12 nicklas 2165               json.put("status", "incomplete");
2059 11 Oct 13 nicklas 2166               jsonMessages.add("Should be related to '" + related.getName() + "' [" + related.getMainType().name() + "]");
1639 09 May 12 nicklas 2167             }
1463 14 Nov 11 martin 2168           }
1463 14 Nov 11 martin 2169           else if (!r.getName().equals(related.getName()))
1463 14 Nov 11 martin 2170           {
2109 29 Oct 13 nicklas 2171             if (createIfMissing)
2109 29 Oct 13 nicklas 2172             {
2109 29 Oct 13 nicklas 2173               s.setRelatedSubtype(related.get(dc));
2109 29 Oct 13 nicklas 2174               jsonMessages.add("Fixed");
2109 29 Oct 13 nicklas 2175             }
2109 29 Oct 13 nicklas 2176             else
2109 29 Oct 13 nicklas 2177             {
2109 29 Oct 13 nicklas 2178               json.put("status", "incomplete");
2109 29 Oct 13 nicklas 2179               jsonMessages.add("Should be related to: '" + 
2109 29 Oct 13 nicklas 2180                   related.getName() + "' not '" + r.getName() + "'");
2109 29 Oct 13 nicklas 2181             }
1463 14 Nov 11 martin 2182           }
1463 14 Nov 11 martin 2183         }
1463 14 Nov 11 martin 2184       }
1463 14 Nov 11 martin 2185       
1463 14 Nov 11 martin 2186     }
1463 14 Nov 11 martin 2187     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
1463 14 Nov 11 martin 2188     json.put("messages", jsonMessages);
1463 14 Nov 11 martin 2189     return json;
1463 14 Nov 11 martin 2190
1463 14 Nov 11 martin 2191   }
1463 14 Nov 11 martin 2192   
1463 14 Nov 11 martin 2193   /**
3974 26 May 16 nicklas 2194     Create a Client with the given options. The client is created in
3974 26 May 16 nicklas 2195     a separate transaction.
3974 26 May 16 nicklas 2196     @since 4.5
3974 26 May 16 nicklas 2197   */
3988 10 Jun 16 nicklas 2198   public Client createClient(SessionControl sc, ClientApp client, PermissionOptions permissions)
3974 26 May 16 nicklas 2199   {
3974 26 May 16 nicklas 2200     Client c = null;
6328 14 Jun 21 nicklas 2201     DbControl dc = sc.newDbControl(":Installation wizard");
3974 26 May 16 nicklas 2202     try
3974 26 May 16 nicklas 2203     {
3988 10 Jun 16 nicklas 2204       c = Client.getNew(dc, client.getExternalId());
3988 10 Jun 16 nicklas 2205       c.setName(client.getName());
3974 26 May 16 nicklas 2206       if (permissions != null) permissions.applyPermissions(c);
3974 26 May 16 nicklas 2207       dc.saveItem(c);
3974 26 May 16 nicklas 2208       dc.commit();
3974 26 May 16 nicklas 2209     }
3974 26 May 16 nicklas 2210     finally
3974 26 May 16 nicklas 2211     {
3974 26 May 16 nicklas 2212       if (dc != null) dc.close();
3974 26 May 16 nicklas 2213     }
3974 26 May 16 nicklas 2214     return c;
3974 26 May 16 nicklas 2215   }
3974 26 May 16 nicklas 2216
3974 26 May 16 nicklas 2217   
3974 26 May 16 nicklas 2218   /**
3974 26 May 16 nicklas 2219     Check for an existing client with the given options.
3974 26 May 16 nicklas 2220     A JSONObject is returned with the result. The following 
3974 26 May 16 nicklas 2221     keys are used:
3974 26 May 16 nicklas 2222     <ul>
3974 26 May 16 nicklas 2223     <li>itemType: CLIENT
3974 26 May 16 nicklas 2224     <li>name: The name of the client
3974 26 May 16 nicklas 2225     <li>id: The id of the client if it exists
3974 26 May 16 nicklas 2226     <li>status: ok, error, or missing
3974 26 May 16 nicklas 2227     <li>message: A descriptive message in case of an error
3974 26 May 16 nicklas 2228     </ul>
3974 26 May 16 nicklas 2229     @since 4.5
3974 26 May 16 nicklas 2230   */
3988 10 Jun 16 nicklas 2231   public JSONObject checkClient(DbControl dc, ClientApp client, PermissionOptions permissions, boolean createIfMissing)
3974 26 May 16 nicklas 2232   {
3974 26 May 16 nicklas 2233     JSONObject json = new JSONObject();
3974 26 May 16 nicklas 2234     JSONArray jsonMessages = new JSONArray();
3974 26 May 16 nicklas 2235     json.put("itemType", Item.CLIENT.name());
3988 10 Jun 16 nicklas 2236     json.put("name", client.getName());
3974 26 May 16 nicklas 2237     
3988 10 Jun 16 nicklas 2238     List<Client> result = client.list(dc);
3974 26 May 16 nicklas 2239     if (result.size() == 0)
3974 26 May 16 nicklas 2240     {
3974 26 May 16 nicklas 2241       if (createIfMissing)
3974 26 May 16 nicklas 2242       {
3988 10 Jun 16 nicklas 2243         Client c = createClient(dc.getSessionControl(), client, permissions);
3974 26 May 16 nicklas 2244         json.put("id", c.getId());
3974 26 May 16 nicklas 2245         json.put("status", "ok");
3974 26 May 16 nicklas 2246         jsonMessages.add("Created");
3974 26 May 16 nicklas 2247       }
3974 26 May 16 nicklas 2248       else
3974 26 May 16 nicklas 2249       {
3974 26 May 16 nicklas 2250         json.put("status", "missing");
3974 26 May 16 nicklas 2251         jsonMessages.add("Not found");
3974 26 May 16 nicklas 2252       }
3974 26 May 16 nicklas 2253     }
3974 26 May 16 nicklas 2254     else if (result.size() > 1)
3974 26 May 16 nicklas 2255     {
3974 26 May 16 nicklas 2256       json.put("status", "error");
3974 26 May 16 nicklas 2257       jsonMessages.add("Found > 1 client");
3974 26 May 16 nicklas 2258     }
3974 26 May 16 nicklas 2259     else
3974 26 May 16 nicklas 2260     {
3974 26 May 16 nicklas 2261       Client c = result.get(0);
3974 26 May 16 nicklas 2262       json.put("id", c.getId());
3974 26 May 16 nicklas 2263       json.put("status", "ok"); // For now -- more checks below
3974 26 May 16 nicklas 2264       
3974 26 May 16 nicklas 2265       if (permissions != null && !permissions.checkPermissions(c))
3974 26 May 16 nicklas 2266       {
3974 26 May 16 nicklas 2267         if (createIfMissing)
3974 26 May 16 nicklas 2268         {
3974 26 May 16 nicklas 2269           permissions.applyPermissions(c);
3974 26 May 16 nicklas 2270           if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
3974 26 May 16 nicklas 2271         }
3974 26 May 16 nicklas 2272         else
3974 26 May 16 nicklas 2273         {
3974 26 May 16 nicklas 2274           json.put("status", "incomplete");
3974 26 May 16 nicklas 2275           jsonMessages.add(permissions.getMessage());
3974 26 May 16 nicklas 2276         }
3974 26 May 16 nicklas 2277       }
3974 26 May 16 nicklas 2278     }
3974 26 May 16 nicklas 2279     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
3974 26 May 16 nicklas 2280     json.put("messages", jsonMessages);
3974 26 May 16 nicklas 2281     return json;  
3974 26 May 16 nicklas 2282   }
3974 26 May 16 nicklas 2283
3974 26 May 16 nicklas 2284   
3974 26 May 16 nicklas 2285   /**
1865 19 Feb 13 nicklas 2286     Create a Tag with the given options. The tag is created in
1865 19 Feb 13 nicklas 2287     a separate transaction.
1867 19 Feb 13 nicklas 2288     @since 2.12
1865 19 Feb 13 nicklas 2289   */
5865 12 Mar 20 nicklas 2290   public Tag createTag(SessionControl sc, String name, Subtype subtype, Pipeline pipeline, BarcodeSet barcodeSet, String description, PermissionOptions permissions)
1865 19 Feb 13 nicklas 2291   {
1865 19 Feb 13 nicklas 2292     Tag tag = null;
6328 14 Jun 21 nicklas 2293     DbControl dc = sc.newDbControl(":Installation wizard");
1865 19 Feb 13 nicklas 2294     try
1865 19 Feb 13 nicklas 2295     {
1865 19 Feb 13 nicklas 2296       tag = Tag.getNew(dc);
1865 19 Feb 13 nicklas 2297       tag.setName(name);
1865 19 Feb 13 nicklas 2298       tag.setItemSubtype(subtype.get(dc));
1865 19 Feb 13 nicklas 2299       tag.setDescription(description);
1865 19 Feb 13 nicklas 2300       if (permissions != null) permissions.applyPermissions(tag);
5437 17 May 19 nicklas 2301       if (pipeline != null) pipeline.setAnnotation(dc, tag);
5865 12 Mar 20 nicklas 2302       if (barcodeSet != null) Annotationtype.BARCODE_SET.setAnnotationValue(dc, tag, barcodeSet.getName());
5865 12 Mar 20 nicklas 2303       String seq1 = lookupSequence(name);
5865 12 Mar 20 nicklas 2304       String seq2 = lookupSequence2(name);
5865 12 Mar 20 nicklas 2305       if (seq1 != null) Annotationtype.BARCODE_SEQUENCE.setAnnotationValue(dc, tag, seq1);
5865 12 Mar 20 nicklas 2306       if (seq2 != null) Annotationtype.BARCODE_SEQUENCE_2.setAnnotationValue(dc, tag, seq2);
1865 19 Feb 13 nicklas 2307       dc.saveItem(tag);
1865 19 Feb 13 nicklas 2308       dc.commit();
1865 19 Feb 13 nicklas 2309     }
1865 19 Feb 13 nicklas 2310     finally
1865 19 Feb 13 nicklas 2311     {
1865 19 Feb 13 nicklas 2312       if (dc != null) dc.close();
1865 19 Feb 13 nicklas 2313     }
1865 19 Feb 13 nicklas 2314     return tag;
1865 19 Feb 13 nicklas 2315   }
1865 19 Feb 13 nicklas 2316
1865 19 Feb 13 nicklas 2317   
1865 19 Feb 13 nicklas 2318   /**
1865 19 Feb 13 nicklas 2319     Check for an existing tag with the given options.
1865 19 Feb 13 nicklas 2320     A JSONObject is returned with the result. The following 
1865 19 Feb 13 nicklas 2321     keys are used:
1865 19 Feb 13 nicklas 2322     <ul>
1865 19 Feb 13 nicklas 2323     <li>itemType: TAG
1865 19 Feb 13 nicklas 2324     <li>name: The name of the tag
1865 19 Feb 13 nicklas 2325     <li>id: The id of the subtype if it exists
1865 19 Feb 13 nicklas 2326     <li>status: ok, error, or missing
1865 19 Feb 13 nicklas 2327     <li>message: A descriptive message in case of an error
1865 19 Feb 13 nicklas 2328     </ul>
1867 19 Feb 13 nicklas 2329     @since 2.12
1865 19 Feb 13 nicklas 2330   */
5865 12 Mar 20 nicklas 2331   public JSONObject checkTag(DbControl dc, String name, Subtype subtype, Pipeline pipeline, BarcodeSet barcodeSet, String description, PermissionOptions permissions, boolean createIfMissing)
1865 19 Feb 13 nicklas 2332   {
1865 19 Feb 13 nicklas 2333   
1865 19 Feb 13 nicklas 2334     JSONObject json = new JSONObject();
1865 19 Feb 13 nicklas 2335     JSONArray jsonMessages = new JSONArray();
1865 19 Feb 13 nicklas 2336     json.put("itemType", Item.TAG.name());
1865 19 Feb 13 nicklas 2337     json.put("name", name);
1865 19 Feb 13 nicklas 2338     
1865 19 Feb 13 nicklas 2339     ItemQuery<Tag> query = Tag.getQuery();
1865 19 Feb 13 nicklas 2340     query.restrict(
1865 19 Feb 13 nicklas 2341         Restrictions.eq(
1865 19 Feb 13 nicklas 2342           Hql.property("name"), 
1865 19 Feb 13 nicklas 2343           Expressions.parameter("name", name, Type.STRING)
1865 19 Feb 13 nicklas 2344         ));
1865 19 Feb 13 nicklas 2345     query.include(Include.ALL);
1865 19 Feb 13 nicklas 2346     List<Tag> result = query.list(dc);
1865 19 Feb 13 nicklas 2347     if (result.size() == 0)
1865 19 Feb 13 nicklas 2348     {
1865 19 Feb 13 nicklas 2349       if (createIfMissing)
1865 19 Feb 13 nicklas 2350       {
5865 12 Mar 20 nicklas 2351         Tag t = createTag(dc.getSessionControl(), name, subtype, pipeline, barcodeSet, description, permissions);
1865 19 Feb 13 nicklas 2352         json.put("id", t.getId());
1865 19 Feb 13 nicklas 2353         json.put("status", "ok");
1865 19 Feb 13 nicklas 2354         jsonMessages.add("Created");
1865 19 Feb 13 nicklas 2355       }
1865 19 Feb 13 nicklas 2356       else
1865 19 Feb 13 nicklas 2357       {
1865 19 Feb 13 nicklas 2358         json.put("status", "missing");
1865 19 Feb 13 nicklas 2359         jsonMessages.add("Not found");
1865 19 Feb 13 nicklas 2360       }
1865 19 Feb 13 nicklas 2361     }
1865 19 Feb 13 nicklas 2362     else if (result.size() > 1)
1865 19 Feb 13 nicklas 2363     {
1865 19 Feb 13 nicklas 2364       json.put("status", "error");
1865 19 Feb 13 nicklas 2365       jsonMessages.add("Found > 1 tag");
1865 19 Feb 13 nicklas 2366     }
1865 19 Feb 13 nicklas 2367     else
1865 19 Feb 13 nicklas 2368     {
1865 19 Feb 13 nicklas 2369       Tag t = result.get(0);
1865 19 Feb 13 nicklas 2370       json.put("id", t.getId());
1865 19 Feb 13 nicklas 2371       json.put("status", "ok"); // For now -- more checks below
1865 19 Feb 13 nicklas 2372       
1865 19 Feb 13 nicklas 2373       if (!subtype.load(dc).equals(t.getItemSubtype()))
1865 19 Feb 13 nicklas 2374       {
1865 19 Feb 13 nicklas 2375         json.put("status", "error");
1865 19 Feb 13 nicklas 2376         jsonMessages.add("Should have '" + subtype.getName() + "' as subtype.");
1865 19 Feb 13 nicklas 2377       }
1865 19 Feb 13 nicklas 2378       
1865 19 Feb 13 nicklas 2379       if (permissions != null && !permissions.checkPermissions(t))
1865 19 Feb 13 nicklas 2380       {
1865 19 Feb 13 nicklas 2381         if (createIfMissing)
1865 19 Feb 13 nicklas 2382         {
1865 19 Feb 13 nicklas 2383           permissions.applyPermissions(t);
1865 19 Feb 13 nicklas 2384           if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
1865 19 Feb 13 nicklas 2385         }
1865 19 Feb 13 nicklas 2386         else
1865 19 Feb 13 nicklas 2387         {
1865 19 Feb 13 nicklas 2388           json.put("status", "incomplete");
1865 19 Feb 13 nicklas 2389           jsonMessages.add(permissions.getMessage());
1865 19 Feb 13 nicklas 2390         }
1865 19 Feb 13 nicklas 2391       }
2350 10 Apr 14 nicklas 2392       AnnotationType barcodeSequenceType = Annotationtype.BARCODE_SEQUENCE.get(dc);
5865 12 Mar 20 nicklas 2393       AnnotationType barcodeSequence2Type = Annotationtype.BARCODE_SEQUENCE_2.get(dc);
5865 12 Mar 20 nicklas 2394       if (barcodeSequenceType != null && barcodeSequence2Type != null)
2350 10 Apr 14 nicklas 2395       {
2350 10 Apr 14 nicklas 2396         String barcodeSequence = (String)Annotationtype.BARCODE_SEQUENCE.getAnnotationValue(dc, t);
5865 12 Mar 20 nicklas 2397         String barcodeSequence2 = (String)Annotationtype.BARCODE_SEQUENCE_2.getAnnotationValue(dc, t);
2350 10 Apr 14 nicklas 2398         if (barcodeSequence == null)
2350 10 Apr 14 nicklas 2399         {
2350 10 Apr 14 nicklas 2400           if (createIfMissing)
2350 10 Apr 14 nicklas 2401           {
2350 10 Apr 14 nicklas 2402             barcodeSequence = lookupSequence(name);
2350 10 Apr 14 nicklas 2403             Annotationtype.BARCODE_SEQUENCE.setAnnotationValue(dc, t, barcodeSequence);
2350 10 Apr 14 nicklas 2404             if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
2350 10 Apr 14 nicklas 2405           }
2350 10 Apr 14 nicklas 2406           else
2350 10 Apr 14 nicklas 2407           {
2350 10 Apr 14 nicklas 2408             json.put("status", "incomplete");
2350 10 Apr 14 nicklas 2409             jsonMessages.add("Missing BarcodeSequence annotation");
2350 10 Apr 14 nicklas 2410           }
2350 10 Apr 14 nicklas 2411         }
5865 12 Mar 20 nicklas 2412         if (barcodeSequence2 == null)
5865 12 Mar 20 nicklas 2413         {
5865 12 Mar 20 nicklas 2414           barcodeSequence2 = lookupSequence2(name);
5865 12 Mar 20 nicklas 2415           if (barcodeSequence2 != null)
5865 12 Mar 20 nicklas 2416           {
5865 12 Mar 20 nicklas 2417             if (createIfMissing)
5865 12 Mar 20 nicklas 2418             {
5865 12 Mar 20 nicklas 2419               Annotationtype.BARCODE_SEQUENCE_2.setAnnotationValue(dc, t, barcodeSequence2);
5865 12 Mar 20 nicklas 2420               if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
5865 12 Mar 20 nicklas 2421             }
5865 12 Mar 20 nicklas 2422             else
5865 12 Mar 20 nicklas 2423             {
5865 12 Mar 20 nicklas 2424               json.put("status", "incomplete");
5865 12 Mar 20 nicklas 2425               jsonMessages.add("Missing BarcodeSequence2 annotation");
5865 12 Mar 20 nicklas 2426             }
5865 12 Mar 20 nicklas 2427           }
5865 12 Mar 20 nicklas 2428         }
2350 10 Apr 14 nicklas 2429       }
5437 17 May 19 nicklas 2430       AnnotationType pipelineType = Annotationtype.PIPELINE.get(dc);
5437 17 May 19 nicklas 2431       if (pipelineType != null && pipeline != null)
5437 17 May 19 nicklas 2432       {
5437 17 May 19 nicklas 2433         String existing = (String)Annotationtype.PIPELINE.getAnnotationValue(dc, t);
5437 17 May 19 nicklas 2434         if (existing == null || !existing.equals(pipeline.getName()))
5437 17 May 19 nicklas 2435         {
5437 17 May 19 nicklas 2436           if (createIfMissing)
5437 17 May 19 nicklas 2437           {
5437 17 May 19 nicklas 2438             pipeline.setAnnotation(dc, t);
5437 17 May 19 nicklas 2439             if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
5437 17 May 19 nicklas 2440           }
5437 17 May 19 nicklas 2441           else
5437 17 May 19 nicklas 2442           {
5437 17 May 19 nicklas 2443             json.put("status", "incomplete");
5437 17 May 19 nicklas 2444             jsonMessages.add(existing == null ? "Missing Pipeline annotation" : "Pipeline annotation: expected " + pipeline.getName() + "; found " + existing);
5437 17 May 19 nicklas 2445           }
5437 17 May 19 nicklas 2446         }
5437 17 May 19 nicklas 2447       }
5865 12 Mar 20 nicklas 2448       AnnotationType barcodeSetType = Annotationtype.BARCODE_SET.get(dc);
5865 12 Mar 20 nicklas 2449       if (barcodeSetType != null && barcodeSet != null)
5865 12 Mar 20 nicklas 2450       {
5865 12 Mar 20 nicklas 2451         String existing = (String)Annotationtype.BARCODE_SET.getAnnotationValue(dc, t);
5865 12 Mar 20 nicklas 2452         if (existing == null || !existing.equals(barcodeSet.getName()))
5865 12 Mar 20 nicklas 2453         {
5865 12 Mar 20 nicklas 2454           if (createIfMissing)
5865 12 Mar 20 nicklas 2455           {
5865 12 Mar 20 nicklas 2456             Annotationtype.BARCODE_SET.setAnnotationValue(dc, t, barcodeSet.getName());
5865 12 Mar 20 nicklas 2457             if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
5865 12 Mar 20 nicklas 2458           }
5865 12 Mar 20 nicklas 2459           else
5865 12 Mar 20 nicklas 2460           {
5865 12 Mar 20 nicklas 2461             json.put("status", "incomplete");
5865 12 Mar 20 nicklas 2462             jsonMessages.add(existing == null ? "Missing BarcodeSet annotation" : "BarcodeSet annotation: expected " + barcodeSet.getName() + "; found " + existing);
5865 12 Mar 20 nicklas 2463           }
5865 12 Mar 20 nicklas 2464         }
5865 12 Mar 20 nicklas 2465       }
1865 19 Feb 13 nicklas 2466     }
1865 19 Feb 13 nicklas 2467     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
1865 19 Feb 13 nicklas 2468     json.put("messages", jsonMessages);
1865 19 Feb 13 nicklas 2469     return json;
1865 19 Feb 13 nicklas 2470   
1865 19 Feb 13 nicklas 2471   }
1865 19 Feb 13 nicklas 2472
1865 19 Feb 13 nicklas 2473   
1865 19 Feb 13 nicklas 2474   /**
1463 14 Nov 11 martin 2475     Create an annotation type category with the given options. The category
1463 14 Nov 11 martin 2476     is created in a separate transaction.
4475 27 Apr 17 nicklas 2477     @since 2.5, 4.10
1463 14 Nov 11 martin 2478   */
1610 23 Apr 12 nicklas 2479   public AnnotationTypeCategory createAnnotationTypeCategory(SessionControl sc, 
5880 25 Mar 20 nicklas 2480     String name, String description)
1463 14 Nov 11 martin 2481   {
1463 14 Nov 11 martin 2482     AnnotationTypeCategory cat = null;
6328 14 Jun 21 nicklas 2483     DbControl dc = sc.newDbControl(":Installation wizard");
1463 14 Nov 11 martin 2484     try
1463 14 Nov 11 martin 2485     {
1463 14 Nov 11 martin 2486       cat = AnnotationTypeCategory.getNew(dc);
4475 27 Apr 17 nicklas 2487       cat.setName(name);
5880 25 Mar 20 nicklas 2488       cat.setDescription(description);
1463 14 Nov 11 martin 2489       dc.saveItem(cat);
1463 14 Nov 11 martin 2490       dc.commit();
1463 14 Nov 11 martin 2491     }
1463 14 Nov 11 martin 2492     finally
1463 14 Nov 11 martin 2493     {
1463 14 Nov 11 martin 2494       if (dc != null) dc.close();
1463 14 Nov 11 martin 2495     }
1463 14 Nov 11 martin 2496     return cat;
1463 14 Nov 11 martin 2497   }
5230 15 Jan 19 nicklas 2498   
5230 15 Jan 19 nicklas 2499   public JSONObject checkAnnotationTypeCategory(DbControl dc, Rawdatatype rawdatatype, 
5230 15 Jan 19 nicklas 2500     boolean createIfMissing, Annotationtype... annotationTypes)
5230 15 Jan 19 nicklas 2501   {
5880 25 Mar 20 nicklas 2502     return checkAnnotationTypeCategory(dc, rawdatatype.getName(), "Annotations related to rawdata type: " + rawdatatype.getName(), createIfMissing, annotationTypes);
5230 15 Jan 19 nicklas 2503   }
1463 14 Nov 11 martin 2504
4475 27 Apr 17 nicklas 2505   public JSONObject checkAnnotationTypeCategory(DbControl dc, Subtype subtype, 
4475 27 Apr 17 nicklas 2506     boolean createIfMissing, Annotationtype... annotationTypes)
4475 27 Apr 17 nicklas 2507   {
5880 25 Mar 20 nicklas 2508     return checkAnnotationTypeCategory(dc, subtype.getName(), "Annotations related to subtype: " + subtype.getName(), createIfMissing, annotationTypes);
4475 27 Apr 17 nicklas 2509   }
4475 27 Apr 17 nicklas 2510   
1463 14 Nov 11 martin 2511   /**
1463 14 Nov 11 martin 2512     Check for an existing annotation type category.
1463 14 Nov 11 martin 2513     A JSONObject is returned with the result. The following 
1463 14 Nov 11 martin 2514     keys are used:
1463 14 Nov 11 martin 2515     <ul>
1463 14 Nov 11 martin 2516     <li>itemType: ANNOTATIONTYPECATEGORY
4475 27 Apr 17 nicklas 2517     <li>name: The name of the category
4475 27 Apr 17 nicklas 2518     <li>id: The id of the category if it exists
1463 14 Nov 11 martin 2519     <li>status: ok, error, or missing
1463 14 Nov 11 martin 2520     <li>message: A descriptive message in case of an error
1463 14 Nov 11 martin 2521     </ul>
4475 27 Apr 17 nicklas 2522     @since 4.10
1463 14 Nov 11 martin 2523   */
4475 27 Apr 17 nicklas 2524   public JSONObject checkAnnotationTypeCategory(DbControl dc, String name, 
5880 25 Mar 20 nicklas 2525     String description, boolean createIfMissing, Annotationtype... annotationTypes)
1463 14 Nov 11 martin 2526   {
1463 14 Nov 11 martin 2527   
1463 14 Nov 11 martin 2528     JSONObject json = new JSONObject();
1463 14 Nov 11 martin 2529     JSONArray jsonMessages = new JSONArray();
1463 14 Nov 11 martin 2530     json.put("itemType", Item.ANNOTATIONTYPECATEGORY.name());
4475 27 Apr 17 nicklas 2531     json.put("name", name);
1463 14 Nov 11 martin 2532       
4475 27 Apr 17 nicklas 2533     List<AnnotationTypeCategory> result = Reggie.listAnnotationTypeCategories(dc, name);
1463 14 Nov 11 martin 2534     if (result.size() == 0)
1463 14 Nov 11 martin 2535     {
1463 14 Nov 11 martin 2536       if (createIfMissing)
1463 14 Nov 11 martin 2537       {
5880 25 Mar 20 nicklas 2538         AnnotationTypeCategory cat = createAnnotationTypeCategory(dc.getSessionControl(), name, description);
2080 17 Oct 13 nicklas 2539         // Add the category to annotation types in the original transaction
2080 17 Oct 13 nicklas 2540         if (annotationTypes != null)
2080 17 Oct 13 nicklas 2541         {
2080 17 Oct 13 nicklas 2542           for (Annotationtype annotationType : annotationTypes)
2080 17 Oct 13 nicklas 2543           {
2080 17 Oct 13 nicklas 2544             AnnotationType at = annotationType.load(dc);
2224 12 Feb 14 nicklas 2545             at.addCategory(cat);
2080 17 Oct 13 nicklas 2546           }
2080 17 Oct 13 nicklas 2547         }
2080 17 Oct 13 nicklas 2548
1463 14 Nov 11 martin 2549         json.put("id", cat.getId());
1463 14 Nov 11 martin 2550         json.put("status", "ok");
1463 14 Nov 11 martin 2551         jsonMessages.add("Created");
1463 14 Nov 11 martin 2552       }
1463 14 Nov 11 martin 2553       else
1463 14 Nov 11 martin 2554       {
1463 14 Nov 11 martin 2555         json.put("status", "missing");
1463 14 Nov 11 martin 2556         jsonMessages.add("Not found");
1463 14 Nov 11 martin 2557       }
1463 14 Nov 11 martin 2558     }
1463 14 Nov 11 martin 2559     else if (result.size() > 1)
1463 14 Nov 11 martin 2560     {
1463 14 Nov 11 martin 2561       json.put("status", "error");
1463 14 Nov 11 martin 2562       jsonMessages.add("Found > 1 annotation type category");
1463 14 Nov 11 martin 2563     }
1463 14 Nov 11 martin 2564     else
1463 14 Nov 11 martin 2565     {
1463 14 Nov 11 martin 2566       AnnotationTypeCategory cat = result.get(0);
1463 14 Nov 11 martin 2567       json.put("id", cat.getId());
1463 14 Nov 11 martin 2568       json.put("status", "ok"); // For now -- more checks below
1463 14 Nov 11 martin 2569       
5880 25 Mar 20 nicklas 2570       if (createIfMissing && description != null && cat.getDescription() == null)
5880 25 Mar 20 nicklas 2571       {
5880 25 Mar 20 nicklas 2572         cat.setDescription(description);
5880 25 Mar 20 nicklas 2573       }
5880 25 Mar 20 nicklas 2574       
1463 14 Nov 11 martin 2575       if (annotationTypes != null)
1463 14 Nov 11 martin 2576       {
1610 23 Apr 12 nicklas 2577         for (Annotationtype annotationType : annotationTypes)
1463 14 Nov 11 martin 2578         {
1610 23 Apr 12 nicklas 2579           List<AnnotationType> list = annotationType.list(dc); // Use list() to avoid throwing exceptions if the annotation type doesn't exists yet
1610 23 Apr 12 nicklas 2580           AnnotationType at = list.size() == 1 ? list.get(0) : null;
1463 14 Nov 11 martin 2581           if (at != null && !at.isMember(cat))
1463 14 Nov 11 martin 2582           {
1463 14 Nov 11 martin 2583             if (createIfMissing)
1463 14 Nov 11 martin 2584             {
2224 12 Feb 14 nicklas 2585               at.addCategory(cat);
1463 14 Nov 11 martin 2586               if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
1463 14 Nov 11 martin 2587             }
1463 14 Nov 11 martin 2588             else
1463 14 Nov 11 martin 2589             {
1463 14 Nov 11 martin 2590               json.put("status", "incomplete");
1610 23 Apr 12 nicklas 2591               jsonMessages.add("Not linked with: " + annotationType.getName());
1463 14 Nov 11 martin 2592             }
1463 14 Nov 11 martin 2593           }
1463 14 Nov 11 martin 2594         }
1463 14 Nov 11 martin 2595       }
1463 14 Nov 11 martin 2596     }
1463 14 Nov 11 martin 2597     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
1463 14 Nov 11 martin 2598     json.put("messages", jsonMessages);
1463 14 Nov 11 martin 2599     return json;
1463 14 Nov 11 martin 2600   
1463 14 Nov 11 martin 2601   }
1865 19 Feb 13 nicklas 2602   
1865 19 Feb 13 nicklas 2603   
1865 19 Feb 13 nicklas 2604   /**
1865 19 Feb 13 nicklas 2605     Create a bioplate event type with the given options. The bioplate event type is created in
1865 19 Feb 13 nicklas 2606     a separate transaction.
1867 19 Feb 13 nicklas 2607     @since 2.12
1865 19 Feb 13 nicklas 2608   */
1865 19 Feb 13 nicklas 2609   public BioPlateEventType createBioPlateEventType(SessionControl sc, BioplateEventtype def)
1865 19 Feb 13 nicklas 2610   {
1865 19 Feb 13 nicklas 2611     BioPlateEventType eventType = null;
6328 14 Jun 21 nicklas 2612     DbControl dc = sc.newDbControl(":Installation wizard");
1865 19 Feb 13 nicklas 2613     try
1865 19 Feb 13 nicklas 2614     {
1865 19 Feb 13 nicklas 2615       eventType = BioPlateEventType.getNew(dc, def.getSystemId());
1865 19 Feb 13 nicklas 2616       eventType.setName(def.getName());
1865 19 Feb 13 nicklas 2617       eventType.setDescription(def.getDescription());
1865 19 Feb 13 nicklas 2618       dc.saveItem(eventType);
1865 19 Feb 13 nicklas 2619       dc.commit();
1865 19 Feb 13 nicklas 2620     }
1865 19 Feb 13 nicklas 2621     finally
1865 19 Feb 13 nicklas 2622     {
1865 19 Feb 13 nicklas 2623       if (dc != null) dc.close();
1865 19 Feb 13 nicklas 2624     }
1865 19 Feb 13 nicklas 2625     return eventType;
1865 19 Feb 13 nicklas 2626   }
1463 14 Nov 11 martin 2627
1865 19 Feb 13 nicklas 2628   
1543 28 Feb 12 nicklas 2629   /**
1865 19 Feb 13 nicklas 2630     Check for an existing bioplate event type with the given options.
1865 19 Feb 13 nicklas 2631     A JSONObject is returned with the result. The following 
1865 19 Feb 13 nicklas 2632     keys are used:
1865 19 Feb 13 nicklas 2633     <ul>
1865 19 Feb 13 nicklas 2634     <li>itemType: BIOPLATEEVENTTYPE
1865 19 Feb 13 nicklas 2635     <li>name: The name of the event type
1865 19 Feb 13 nicklas 2636     <li>id: The id of the event type if it exists
1865 19 Feb 13 nicklas 2637     <li>status: ok, error, or missing
1865 19 Feb 13 nicklas 2638     <li>message: A descriptive message in case of an error
1865 19 Feb 13 nicklas 2639     </ul>
1867 19 Feb 13 nicklas 2640     @since 2.12
1865 19 Feb 13 nicklas 2641   */
1865 19 Feb 13 nicklas 2642   public JSONObject checkBioplateEventtype(DbControl dc, BioplateEventtype eventType, 
1865 19 Feb 13 nicklas 2643     boolean createIfMissing)
1865 19 Feb 13 nicklas 2644   {
1865 19 Feb 13 nicklas 2645   
1865 19 Feb 13 nicklas 2646     JSONObject json = new JSONObject();
1865 19 Feb 13 nicklas 2647     JSONArray jsonMessages = new JSONArray();
1865 19 Feb 13 nicklas 2648     json.put("itemType", Item.BIOPLATEEVENTTYPE.name());
1865 19 Feb 13 nicklas 2649     json.put("name", eventType.getName());
1865 19 Feb 13 nicklas 2650     
1865 19 Feb 13 nicklas 2651     List<BioPlateEventType> result = eventType.list(dc);
1865 19 Feb 13 nicklas 2652     if (result.size() == 0)
1865 19 Feb 13 nicklas 2653     {
1865 19 Feb 13 nicklas 2654       if (createIfMissing)
1865 19 Feb 13 nicklas 2655       {
1865 19 Feb 13 nicklas 2656         BioPlateEventType t = createBioPlateEventType(dc.getSessionControl(), eventType);
1865 19 Feb 13 nicklas 2657         json.put("id", t.getId());
1865 19 Feb 13 nicklas 2658         json.put("status", "ok");
1865 19 Feb 13 nicklas 2659         jsonMessages.add("Created");
1865 19 Feb 13 nicklas 2660       }
1865 19 Feb 13 nicklas 2661       else
1865 19 Feb 13 nicklas 2662       {
1865 19 Feb 13 nicklas 2663         json.put("status", "missing");
1865 19 Feb 13 nicklas 2664         jsonMessages.add("Not found");
1865 19 Feb 13 nicklas 2665       }
1865 19 Feb 13 nicklas 2666     }
1865 19 Feb 13 nicklas 2667     else if (result.size() > 1)
1865 19 Feb 13 nicklas 2668     {
1865 19 Feb 13 nicklas 2669       json.put("status", "error");
1865 19 Feb 13 nicklas 2670       jsonMessages.add("Found > 1 bioplate event type");
1865 19 Feb 13 nicklas 2671     }
1865 19 Feb 13 nicklas 2672     else
1865 19 Feb 13 nicklas 2673     {
1865 19 Feb 13 nicklas 2674       BioPlateEventType t = result.get(0);
1865 19 Feb 13 nicklas 2675       json.put("id", t.getId());
1865 19 Feb 13 nicklas 2676       json.put("status", "ok"); // For now -- more checks below
1865 19 Feb 13 nicklas 2677       
1865 19 Feb 13 nicklas 2678     }
1865 19 Feb 13 nicklas 2679     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
1865 19 Feb 13 nicklas 2680     json.put("messages", jsonMessages);
1865 19 Feb 13 nicklas 2681     return json;
1865 19 Feb 13 nicklas 2682   }
1865 19 Feb 13 nicklas 2683
1865 19 Feb 13 nicklas 2684   
1865 19 Feb 13 nicklas 2685
1865 19 Feb 13 nicklas 2686   /**
1543 28 Feb 12 nicklas 2687     Create a bioplate type with the given options. The bioplate type is created in
1543 28 Feb 12 nicklas 2688     a separate transaction.
1543 28 Feb 12 nicklas 2689     @since 2.4
1543 28 Feb 12 nicklas 2690   */
1543 28 Feb 12 nicklas 2691   public BioPlateType createBioPlateType(SessionControl sc, BioplateType def)
1543 28 Feb 12 nicklas 2692   {
1543 28 Feb 12 nicklas 2693     BioPlateType plateType = null;
6328 14 Jun 21 nicklas 2694     DbControl dc = sc.newDbControl(":Installation wizard");
1543 28 Feb 12 nicklas 2695     try
1543 28 Feb 12 nicklas 2696     {
1543 28 Feb 12 nicklas 2697       plateType = BioPlateType.getNew(dc);
1543 28 Feb 12 nicklas 2698       plateType.setName(def.getName());
1543 28 Feb 12 nicklas 2699       plateType.setBioMaterialType(def.getBioMaterialType());
1543 28 Feb 12 nicklas 2700       if (def.getSubtype() != null)
1543 28 Feb 12 nicklas 2701       {
1644 15 May 12 nicklas 2702         ItemSubtype subtype = def.getSubtype().get(dc);
1644 15 May 12 nicklas 2703         if (subtype != null)
1644 15 May 12 nicklas 2704         {
1644 15 May 12 nicklas 2705           plateType.setItemSubtype(subtype);
1644 15 May 12 nicklas 2706         }
1543 28 Feb 12 nicklas 2707       }
1543 28 Feb 12 nicklas 2708       plateType.setLockMode(def.getLockMode());
1543 28 Feb 12 nicklas 2709       
1543 28 Feb 12 nicklas 2710       dc.saveItem(plateType);
1543 28 Feb 12 nicklas 2711       dc.commit();
1543 28 Feb 12 nicklas 2712     }
1543 28 Feb 12 nicklas 2713     finally
1543 28 Feb 12 nicklas 2714     {
1543 28 Feb 12 nicklas 2715       if (dc != null) dc.close();
1543 28 Feb 12 nicklas 2716     }
1543 28 Feb 12 nicklas 2717     return plateType;
1543 28 Feb 12 nicklas 2718   }
1463 14 Nov 11 martin 2719
1543 28 Feb 12 nicklas 2720   
1463 14 Nov 11 martin 2721   /**
1543 28 Feb 12 nicklas 2722     Check for an existing bioplate type with the given options.
1543 28 Feb 12 nicklas 2723     A JSONObject is returned with the result. The following 
1543 28 Feb 12 nicklas 2724     keys are used:
1543 28 Feb 12 nicklas 2725     <ul>
1543 28 Feb 12 nicklas 2726     <li>itemType: BIOPLATETYPE
1543 28 Feb 12 nicklas 2727     <li>name: The name of the bioplate type
1543 28 Feb 12 nicklas 2728     <li>id: The id of the bioplate type if it exists
1543 28 Feb 12 nicklas 2729     <li>bioMaterialType: The bioMaterial type that can be used on bioplates with the given type
1543 28 Feb 12 nicklas 2730     <li>status: ok, error, or missing
1543 28 Feb 12 nicklas 2731     <li>message: A descriptive message in case of an error
1543 28 Feb 12 nicklas 2732     </ul>
1543 28 Feb 12 nicklas 2733     @since 2.0
1543 28 Feb 12 nicklas 2734   */
1543 28 Feb 12 nicklas 2735   public JSONObject checkBioplateType(DbControl dc, BioplateType plateType, 
1543 28 Feb 12 nicklas 2736     boolean createIfMissing)
1543 28 Feb 12 nicklas 2737   {
1543 28 Feb 12 nicklas 2738   
1543 28 Feb 12 nicklas 2739     JSONObject json = new JSONObject();
1543 28 Feb 12 nicklas 2740     JSONArray jsonMessages = new JSONArray();
1543 28 Feb 12 nicklas 2741     json.put("itemType", Item.BIOPLATETYPE.name());
1543 28 Feb 12 nicklas 2742     json.put("name", plateType.getName());
3640 02 Dec 15 nicklas 2743     json.put("bioMaterialType", plateType.getBioMaterialType() == null ? null : plateType.getBioMaterialType().name());
1543 28 Feb 12 nicklas 2744     
1610 23 Apr 12 nicklas 2745     List<BioPlateType> result = plateType.list(dc);
1543 28 Feb 12 nicklas 2746     if (result.size() == 0)
1543 28 Feb 12 nicklas 2747     {
1543 28 Feb 12 nicklas 2748       if (createIfMissing)
1543 28 Feb 12 nicklas 2749       {
1543 28 Feb 12 nicklas 2750         BioPlateType t = createBioPlateType(dc.getSessionControl(), plateType);
1543 28 Feb 12 nicklas 2751         json.put("id", t.getId());
1543 28 Feb 12 nicklas 2752         json.put("status", "ok");
1543 28 Feb 12 nicklas 2753         jsonMessages.add("Created");
1543 28 Feb 12 nicklas 2754       }
1543 28 Feb 12 nicklas 2755       else
1543 28 Feb 12 nicklas 2756       {
1543 28 Feb 12 nicklas 2757         json.put("status", "missing");
1543 28 Feb 12 nicklas 2758         jsonMessages.add("Not found");
1543 28 Feb 12 nicklas 2759       }
1543 28 Feb 12 nicklas 2760     }
1543 28 Feb 12 nicklas 2761     else if (result.size() > 1)
1543 28 Feb 12 nicklas 2762     {
1543 28 Feb 12 nicklas 2763       json.put("status", "error");
1543 28 Feb 12 nicklas 2764       jsonMessages.add("Found > 1 bioplate type");
1543 28 Feb 12 nicklas 2765     }
1543 28 Feb 12 nicklas 2766     else
1543 28 Feb 12 nicklas 2767     {
1543 28 Feb 12 nicklas 2768       BioPlateType t = result.get(0);
1543 28 Feb 12 nicklas 2769       json.put("id", t.getId());
1543 28 Feb 12 nicklas 2770       json.put("status", "ok"); // For now -- more checks below
1543 28 Feb 12 nicklas 2771       
1543 28 Feb 12 nicklas 2772       if (t.getBioMaterialType() != plateType.getBioMaterialType())
1543 28 Feb 12 nicklas 2773       {
1543 28 Feb 12 nicklas 2774         json.put("status", "error");
1543 28 Feb 12 nicklas 2775         jsonMessages.add("Can't be used by '" + plateType.getBioMaterialType() + "' items.");
1543 28 Feb 12 nicklas 2776       }
1543 28 Feb 12 nicklas 2777       
1543 28 Feb 12 nicklas 2778       Subtype subtype = plateType.getSubtype();
1543 28 Feb 12 nicklas 2779       if (subtype != null)
1543 28 Feb 12 nicklas 2780       {
1644 15 May 12 nicklas 2781         ItemSubtype st = subtype.get(dc);
1644 15 May 12 nicklas 2782         if (st == null || !st.equals(t.getItemSubtype()))
1543 28 Feb 12 nicklas 2783         {
1543 28 Feb 12 nicklas 2784           json.put("status", "error");
1543 28 Feb 12 nicklas 2785           jsonMessages.add("Should be locked to '" + subtype.getName() + "' (" + subtype.getMainType() + ") items.");
1543 28 Feb 12 nicklas 2786         }
1543 28 Feb 12 nicklas 2787       }
1543 28 Feb 12 nicklas 2788       
1543 28 Feb 12 nicklas 2789       if (t.getLockMode() != plateType.getLockMode())
1543 28 Feb 12 nicklas 2790       {
1543 28 Feb 12 nicklas 2791         json.put("status", "error");
1543 28 Feb 12 nicklas 2792         jsonMessages.add("Should be using '" + plateType.getLockMode().name() + "' well lock mode");
1543 28 Feb 12 nicklas 2793       }
1543 28 Feb 12 nicklas 2794     }
1543 28 Feb 12 nicklas 2795     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
1543 28 Feb 12 nicklas 2796     json.put("messages", jsonMessages);
1543 28 Feb 12 nicklas 2797     return json;
1543 28 Feb 12 nicklas 2798   
1543 28 Feb 12 nicklas 2799   }
1543 28 Feb 12 nicklas 2800
1546 02 Mar 12 nicklas 2801   /**
1865 19 Feb 13 nicklas 2802     Create a biomaterial list with the given options. The list is created in
1865 19 Feb 13 nicklas 2803     a separate transaction.
1867 19 Feb 13 nicklas 2804     @since 2.12
1865 19 Feb 13 nicklas 2805   */
3247 14 Apr 15 nicklas 2806   public ItemList createItemList(SessionControl sc, BiomaterialList def, PermissionOptions permissions)
1865 19 Feb 13 nicklas 2807   {
3247 14 Apr 15 nicklas 2808     ItemList list = null;
6328 14 Jun 21 nicklas 2809     DbControl dc = sc.newDbControl(":Installation wizard");
1865 19 Feb 13 nicklas 2810     try
1865 19 Feb 13 nicklas 2811     {
3247 14 Apr 15 nicklas 2812       list = ItemList.getNew(dc, def.getBioMaterialType());
1865 19 Feb 13 nicklas 2813       list.setName(def.getName());
1865 19 Feb 13 nicklas 2814       list.setExternalId(def.getExternalId());
3659 09 Dec 15 nicklas 2815       if (def.getSubtype() != null)
3659 09 Dec 15 nicklas 2816       {
3659 09 Dec 15 nicklas 2817         list.setItemSubtype(def.getSubtype().get(dc));
3659 09 Dec 15 nicklas 2818       }
5876 24 Mar 20 nicklas 2819       if (def.getRawdatatype() != null)
5876 24 Mar 20 nicklas 2820       {
5876 24 Mar 20 nicklas 2821         list.setRawDataType(def.getRawdatatype().getRawDataType());
5876 24 Mar 20 nicklas 2822       }
1865 19 Feb 13 nicklas 2823       list.setDescription(def.getDescription());
2038 03 Oct 13 olle 2824       if (permissions != null) permissions.applyPermissions(list);
1865 19 Feb 13 nicklas 2825       
5876 24 Mar 20 nicklas 2826       if (def == BiomaterialList.VARIANT_IMPORT_TMP)
5876 24 Mar 20 nicklas 2827       {
5876 24 Mar 20 nicklas 2828         // Fill this list with all existing variant call raw bioassays
5876 24 Mar 20 nicklas 2829         ItemQuery<RawBioAssay> query = RawBioAssay.getQuery();
5876 24 Mar 20 nicklas 2830         query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
5876 24 Mar 20 nicklas 2831         Rawdatatype.VARIANT_CALL.addFilter(dc, query);
5876 24 Mar 20 nicklas 2832         list.add(query.iterate(dc));
5876 24 Mar 20 nicklas 2833       }
5876 24 Mar 20 nicklas 2834       
1865 19 Feb 13 nicklas 2835       dc.saveItem(list);
1865 19 Feb 13 nicklas 2836       dc.commit();
1865 19 Feb 13 nicklas 2837     }
1865 19 Feb 13 nicklas 2838     finally
1865 19 Feb 13 nicklas 2839     {
1865 19 Feb 13 nicklas 2840       if (dc != null) dc.close();
1865 19 Feb 13 nicklas 2841     }
1865 19 Feb 13 nicklas 2842     return list;
1865 19 Feb 13 nicklas 2843   }
1865 19 Feb 13 nicklas 2844
1865 19 Feb 13 nicklas 2845   
1865 19 Feb 13 nicklas 2846   /**
1865 19 Feb 13 nicklas 2847     Check for an existing biomaterial list with the given options.
1865 19 Feb 13 nicklas 2848     A JSONObject is returned with the result. The following 
1865 19 Feb 13 nicklas 2849     keys are used:
1865 19 Feb 13 nicklas 2850     <ul>
3247 14 Apr 15 nicklas 2851     <li>itemType: ITEMLIST
1865 19 Feb 13 nicklas 2852     <li>name: The name of the biomaterial list
1865 19 Feb 13 nicklas 2853     <li>id: The id of the biomaterial list if it exists
1865 19 Feb 13 nicklas 2854     <li>bioMaterialType: The bioMaterial type that can be stored in the list
1865 19 Feb 13 nicklas 2855     <li>status: ok, error, or missing
1865 19 Feb 13 nicklas 2856     <li>message: A descriptive message in case of an error
1865 19 Feb 13 nicklas 2857     </ul>
1867 19 Feb 13 nicklas 2858     @since 2.12
1865 19 Feb 13 nicklas 2859   */
5962 03 Jun 20 nicklas 2860   public JSONObject checkItemList(DbControl dc, BiomaterialList list, boolean checkAutoProcessing,
2038 03 Oct 13 olle 2861     PermissionOptions permissions, boolean createIfMissing)
1865 19 Feb 13 nicklas 2862   {
1865 19 Feb 13 nicklas 2863   
1865 19 Feb 13 nicklas 2864     JSONObject json = new JSONObject();
1865 19 Feb 13 nicklas 2865     JSONArray jsonMessages = new JSONArray();
3247 14 Apr 15 nicklas 2866     json.put("itemType", Item.ITEMLIST.name());
1865 19 Feb 13 nicklas 2867     json.put("name", list.getName());
1865 19 Feb 13 nicklas 2868     json.put("bioMaterialType", list.getBioMaterialType().name());
1865 19 Feb 13 nicklas 2869     
3247 14 Apr 15 nicklas 2870     List<ItemList> result = list.list(dc);
1865 19 Feb 13 nicklas 2871     if (result.size() == 0)
1865 19 Feb 13 nicklas 2872     {
1865 19 Feb 13 nicklas 2873       if (createIfMissing)
1865 19 Feb 13 nicklas 2874       {
3247 14 Apr 15 nicklas 2875         ItemList l = createItemList(dc.getSessionControl(), list, permissions);
1865 19 Feb 13 nicklas 2876         json.put("id", l.getId());
1865 19 Feb 13 nicklas 2877         json.put("status", "ok");
1865 19 Feb 13 nicklas 2878         jsonMessages.add("Created");
1865 19 Feb 13 nicklas 2879       }
1865 19 Feb 13 nicklas 2880       else
1865 19 Feb 13 nicklas 2881       {
1865 19 Feb 13 nicklas 2882         json.put("status", "missing");
1865 19 Feb 13 nicklas 2883         jsonMessages.add("Not found");
1865 19 Feb 13 nicklas 2884       }
1865 19 Feb 13 nicklas 2885     }
1865 19 Feb 13 nicklas 2886     else if (result.size() > 1)
1865 19 Feb 13 nicklas 2887     {
1865 19 Feb 13 nicklas 2888       json.put("status", "error");
1865 19 Feb 13 nicklas 2889       jsonMessages.add("Found > 1 biomaterial list");
1865 19 Feb 13 nicklas 2890     }
1865 19 Feb 13 nicklas 2891     else
1865 19 Feb 13 nicklas 2892     {
3247 14 Apr 15 nicklas 2893       ItemList l = result.get(0);
1865 19 Feb 13 nicklas 2894       json.put("id", l.getId());
1865 19 Feb 13 nicklas 2895       json.put("status", "ok"); // For now -- more checks below
1865 19 Feb 13 nicklas 2896       
1865 19 Feb 13 nicklas 2897       if (l.getMemberType() != list.getBioMaterialType())
1865 19 Feb 13 nicklas 2898       {
1865 19 Feb 13 nicklas 2899         json.put("status", "error");
1865 19 Feb 13 nicklas 2900         jsonMessages.add("Can't be used by '" + list.getBioMaterialType() + "' items.");
1865 19 Feb 13 nicklas 2901       }
1865 19 Feb 13 nicklas 2902       
3659 09 Dec 15 nicklas 2903       Subtype subtype = list.getSubtype();
3659 09 Dec 15 nicklas 2904       if (subtype != null)
3659 09 Dec 15 nicklas 2905       {
3659 09 Dec 15 nicklas 2906         if (!subtype.get(dc).equals(l.getItemSubtype()))
3659 09 Dec 15 nicklas 2907         {
3659 09 Dec 15 nicklas 2908           if (createIfMissing)
3659 09 Dec 15 nicklas 2909           {
3659 09 Dec 15 nicklas 2910             l.setItemSubtype(subtype.get(dc));
3659 09 Dec 15 nicklas 2911             jsonMessages.add("Fixed");
3659 09 Dec 15 nicklas 2912           }
3659 09 Dec 15 nicklas 2913           else
3659 09 Dec 15 nicklas 2914           {
3659 09 Dec 15 nicklas 2915             json.put("status", "incomplete");
3659 09 Dec 15 nicklas 2916             jsonMessages.add("Should be be set to '" + subtype.getName() + "'");
3659 09 Dec 15 nicklas 2917           }
3659 09 Dec 15 nicklas 2918         }
3659 09 Dec 15 nicklas 2919       }
3659 09 Dec 15 nicklas 2920       
5962 03 Jun 20 nicklas 2921       if (checkAutoProcessing)
4624 17 Nov 17 nicklas 2922       {
5962 03 Jun 20 nicklas 2923         AnnotationType autoProc = Annotationtype.AUTO_PROCESSING.get(dc);
5962 03 Jun 20 nicklas 2924         if (autoProc != null)
4624 17 Nov 17 nicklas 2925         {
5962 03 Jun 20 nicklas 2926           boolean disabled = "Disable".equals(Annotationtype.AUTO_PROCESSING.getAnnotationValue(dc, l));
5962 03 Jun 20 nicklas 2927           if (disabled)
5962 03 Jun 20 nicklas 2928           {
5962 03 Jun 20 nicklas 2929             json.put("status", "warning");
5962 03 Jun 20 nicklas 2930             jsonMessages.add("Auto-processing is disabled. It can be enabled by clearing the AutoProcessing annotation.");
5962 03 Jun 20 nicklas 2931           }
4624 17 Nov 17 nicklas 2932         }
4624 17 Nov 17 nicklas 2933       }
4624 17 Nov 17 nicklas 2934       
2038 03 Oct 13 olle 2935       if (permissions != null && !permissions.checkPermissions(l))
2038 03 Oct 13 olle 2936       {
2038 03 Oct 13 olle 2937         if (createIfMissing)
2038 03 Oct 13 olle 2938         {
2038 03 Oct 13 olle 2939           permissions.applyPermissions(l);
2038 03 Oct 13 olle 2940           if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
2038 03 Oct 13 olle 2941         }
2038 03 Oct 13 olle 2942         else
2038 03 Oct 13 olle 2943         {
2038 03 Oct 13 olle 2944           json.put("status", "incomplete");
2038 03 Oct 13 olle 2945           jsonMessages.add(permissions.getMessage());
2038 03 Oct 13 olle 2946         }
2038 03 Oct 13 olle 2947       }
2038 03 Oct 13 olle 2948
1865 19 Feb 13 nicklas 2949     }
1865 19 Feb 13 nicklas 2950     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
1865 19 Feb 13 nicklas 2951     json.put("messages", jsonMessages);
1865 19 Feb 13 nicklas 2952     return json;
1865 19 Feb 13 nicklas 2953   }
1865 19 Feb 13 nicklas 2954
1865 19 Feb 13 nicklas 2955   
1865 19 Feb 13 nicklas 2956   /**
1546 02 Mar 12 nicklas 2957     Create a MIME type with the given options. The type is created in
1546 02 Mar 12 nicklas 2958     a separate transaction.
1546 02 Mar 12 nicklas 2959     @since 2.4
1546 02 Mar 12 nicklas 2960   */
1546 02 Mar 12 nicklas 2961   public MimeType createMimeType(SessionControl sc, Mimetype def)
1546 02 Mar 12 nicklas 2962   {
1546 02 Mar 12 nicklas 2963     MimeType type = null;
6328 14 Jun 21 nicklas 2964     DbControl dc = sc.newDbControl(":Installation wizard");
1546 02 Mar 12 nicklas 2965     try
1546 02 Mar 12 nicklas 2966     {
1546 02 Mar 12 nicklas 2967       type = MimeType.getNew(dc);
1546 02 Mar 12 nicklas 2968       type.setName(def.getMimeType());
1546 02 Mar 12 nicklas 2969       type.setExtension(def.getExtension());
1546 02 Mar 12 nicklas 2970       type.setDescription(def.getDescription());
1546 02 Mar 12 nicklas 2971       if (def.getFileType() != null)
1546 02 Mar 12 nicklas 2972       {
1644 15 May 12 nicklas 2973         ItemSubtype subtype = def.getFileType().get(dc);
1644 15 May 12 nicklas 2974         if (subtype != null) type.setFileType(subtype);
1546 02 Mar 12 nicklas 2975       }
1546 02 Mar 12 nicklas 2976       
1546 02 Mar 12 nicklas 2977       dc.saveItem(type);
1546 02 Mar 12 nicklas 2978       dc.commit();
1546 02 Mar 12 nicklas 2979     }
1546 02 Mar 12 nicklas 2980     finally
1546 02 Mar 12 nicklas 2981     {
1546 02 Mar 12 nicklas 2982       if (dc != null) dc.close();
1546 02 Mar 12 nicklas 2983     }
1546 02 Mar 12 nicklas 2984     return type;
1546 02 Mar 12 nicklas 2985   }
1543 28 Feb 12 nicklas 2986
1546 02 Mar 12 nicklas 2987   
1543 28 Feb 12 nicklas 2988   /**
1546 02 Mar 12 nicklas 2989     Check for an existing MIME type with the given options.
1546 02 Mar 12 nicklas 2990     A JSONObject is returned with the result. The following 
1546 02 Mar 12 nicklas 2991     keys are used:
1546 02 Mar 12 nicklas 2992     <ul>
1546 02 Mar 12 nicklas 2993     <li>itemType: MIMETYPE
1546 02 Mar 12 nicklas 2994     <li>name: The name of the subtype
1546 02 Mar 12 nicklas 2995     <li>id: The id of the subtype if it exists
1546 02 Mar 12 nicklas 2996     <li>mainType: The main item type that the subtype applies to
1546 02 Mar 12 nicklas 2997     <li>status: ok, error, or missing
1546 02 Mar 12 nicklas 2998     <li>message: A descriptive message in case of an error
1546 02 Mar 12 nicklas 2999     </ul>
1546 02 Mar 12 nicklas 3000     @since 2.4
1546 02 Mar 12 nicklas 3001   */
1546 02 Mar 12 nicklas 3002   public JSONObject checkMimeType(DbControl dc, Mimetype mimeType, 
1546 02 Mar 12 nicklas 3003     boolean createIfMissing)
1546 02 Mar 12 nicklas 3004   {
1546 02 Mar 12 nicklas 3005   
1546 02 Mar 12 nicklas 3006     JSONObject json = new JSONObject();
1546 02 Mar 12 nicklas 3007     JSONArray jsonMessages = new JSONArray();
1546 02 Mar 12 nicklas 3008     json.put("itemType", Item.MIMETYPE.name());
1546 02 Mar 12 nicklas 3009     json.put("name", mimeType.getDescription());
1546 02 Mar 12 nicklas 3010     json.put("mimeType", mimeType.getMimeType());
1546 02 Mar 12 nicklas 3011     json.put("extension", mimeType.getExtension());
1865 19 Feb 13 nicklas 3012     
1546 02 Mar 12 nicklas 3013     List<MimeType> result = mimeType.list(dc);
1546 02 Mar 12 nicklas 3014     if (result.size() == 0)
1546 02 Mar 12 nicklas 3015     {
1546 02 Mar 12 nicklas 3016       if (createIfMissing)
1546 02 Mar 12 nicklas 3017       {
1546 02 Mar 12 nicklas 3018         MimeType type = createMimeType(dc.getSessionControl(), mimeType);
1546 02 Mar 12 nicklas 3019         json.put("id", type.getId());
1546 02 Mar 12 nicklas 3020         json.put("status", "ok");
1546 02 Mar 12 nicklas 3021         jsonMessages.add("Created");
1546 02 Mar 12 nicklas 3022       }
1546 02 Mar 12 nicklas 3023       else
1546 02 Mar 12 nicklas 3024       {
1546 02 Mar 12 nicklas 3025         json.put("status", "missing");
1546 02 Mar 12 nicklas 3026         jsonMessages.add("Not found");
1546 02 Mar 12 nicklas 3027       }
1546 02 Mar 12 nicklas 3028     }
1546 02 Mar 12 nicklas 3029     else if (result.size() > 1)
1546 02 Mar 12 nicklas 3030     {
1546 02 Mar 12 nicklas 3031       json.put("status", "error");
1546 02 Mar 12 nicklas 3032       jsonMessages.add("Found > 1 MIME type");
1546 02 Mar 12 nicklas 3033     }
1546 02 Mar 12 nicklas 3034     else
1546 02 Mar 12 nicklas 3035     {
1546 02 Mar 12 nicklas 3036       MimeType s = result.get(0);
1546 02 Mar 12 nicklas 3037       json.put("id", s.getId());
1546 02 Mar 12 nicklas 3038       json.put("status", "ok"); // For now -- more checks below
1546 02 Mar 12 nicklas 3039       
1546 02 Mar 12 nicklas 3040       if (!s.getName().equals(mimeType.getMimeType()))
1546 02 Mar 12 nicklas 3041       {
1546 02 Mar 12 nicklas 3042         json.put("status", "error");
1546 02 Mar 12 nicklas 3043         jsonMessages.add("Should have '" + mimeType.getMimeType() + "' as MIME type.");
1546 02 Mar 12 nicklas 3044       }
1546 02 Mar 12 nicklas 3045       
1546 02 Mar 12 nicklas 3046     }
1546 02 Mar 12 nicklas 3047     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
1546 02 Mar 12 nicklas 3048     json.put("messages", jsonMessages);
1546 02 Mar 12 nicklas 3049     return json;
1546 02 Mar 12 nicklas 3050   
1546 02 Mar 12 nicklas 3051   }
1606 19 Apr 12 nicklas 3052   
1865 19 Feb 13 nicklas 3053   
1606 19 Apr 12 nicklas 3054   /**
2562 08 Aug 14 nicklas 3055     Create a file server with the given options. The file server is created in
2562 08 Aug 14 nicklas 3056     a separate transaction.
2562 08 Aug 14 nicklas 3057     @since 2.16
2562 08 Aug 14 nicklas 3058   */
2562 08 Aug 14 nicklas 3059   public FileServer createFileServer(SessionControl sc, Fileserver def, PermissionOptions permissions)
2562 08 Aug 14 nicklas 3060   {
2562 08 Aug 14 nicklas 3061     FileServer fs = null;
6328 14 Jun 21 nicklas 3062     DbControl dc = sc.newDbControl(":Installation wizard");
2562 08 Aug 14 nicklas 3063     try
2562 08 Aug 14 nicklas 3064     {
2562 08 Aug 14 nicklas 3065       fs = FileServer.getNew(dc);
2562 08 Aug 14 nicklas 3066       fs.setName(def.getName());
2562 08 Aug 14 nicklas 3067       fs.setConnectionManagerFactoryId(def.getConnectionManagerId());
2562 08 Aug 14 nicklas 3068       fs.setDescription(def.getDescription());
2562 08 Aug 14 nicklas 3069       if (permissions != null) permissions.applyPermissions(fs);
2562 08 Aug 14 nicklas 3070       
2562 08 Aug 14 nicklas 3071       dc.saveItem(fs);
2562 08 Aug 14 nicklas 3072       dc.commit();
2562 08 Aug 14 nicklas 3073     }
2562 08 Aug 14 nicklas 3074     finally
2562 08 Aug 14 nicklas 3075     {
2562 08 Aug 14 nicklas 3076       if (dc != null) dc.close();
2562 08 Aug 14 nicklas 3077     }
2562 08 Aug 14 nicklas 3078     return fs;
2562 08 Aug 14 nicklas 3079   }
2562 08 Aug 14 nicklas 3080
2562 08 Aug 14 nicklas 3081   
2562 08 Aug 14 nicklas 3082   /**
2562 08 Aug 14 nicklas 3083     Check for an existing file server with the given options.
2562 08 Aug 14 nicklas 3084     A JSONObject is returned with the result. The following 
2562 08 Aug 14 nicklas 3085     keys are used:
2562 08 Aug 14 nicklas 3086     <ul>
2562 08 Aug 14 nicklas 3087     <li>itemType: FILESERVER
2562 08 Aug 14 nicklas 3088     <li>name: The name of the fileserver
2562 08 Aug 14 nicklas 3089     <li>id: The id of the fileserver if it exists
2562 08 Aug 14 nicklas 3090     <li>status: ok, error, or missing
2562 08 Aug 14 nicklas 3091     <li>message: A descriptive message in case of an error
2562 08 Aug 14 nicklas 3092     </ul>
2562 08 Aug 14 nicklas 3093     @since 2.16
2562 08 Aug 14 nicklas 3094   */
2562 08 Aug 14 nicklas 3095   public JSONObject checkFileServer(DbControl dc, Fileserver fileServer, 
2562 08 Aug 14 nicklas 3096     PermissionOptions permissions, boolean createIfMissing)
2562 08 Aug 14 nicklas 3097   {
2562 08 Aug 14 nicklas 3098   
2562 08 Aug 14 nicklas 3099     JSONObject json = new JSONObject();
2562 08 Aug 14 nicklas 3100     JSONArray jsonMessages = new JSONArray();
2562 08 Aug 14 nicklas 3101     json.put("itemType", Item.FILESERVER.name());
2562 08 Aug 14 nicklas 3102     json.put("name", fileServer.getName());
2562 08 Aug 14 nicklas 3103     
2562 08 Aug 14 nicklas 3104     FileServer fs = null;
2562 08 Aug 14 nicklas 3105     List<FileServer> result = fileServer.list(dc);
2562 08 Aug 14 nicklas 3106     if (result.size() == 0)
2562 08 Aug 14 nicklas 3107     {
2562 08 Aug 14 nicklas 3108       if (createIfMissing)
2562 08 Aug 14 nicklas 3109       {
2562 08 Aug 14 nicklas 3110         fs = createFileServer(dc.getSessionControl(), fileServer, permissions);
2562 08 Aug 14 nicklas 3111         fs = FileServer.getById(dc, fs.getId());
2562 08 Aug 14 nicklas 3112         json.put("id", fs.getId());
2562 08 Aug 14 nicklas 3113         // Not ok yet, need manual configuration which is checked below
2562 08 Aug 14 nicklas 3114       }
2562 08 Aug 14 nicklas 3115       else
2562 08 Aug 14 nicklas 3116       {
2562 08 Aug 14 nicklas 3117         json.put("status", "missing");
2562 08 Aug 14 nicklas 3118         jsonMessages.add("Not found");
2562 08 Aug 14 nicklas 3119       }
2562 08 Aug 14 nicklas 3120     }
2562 08 Aug 14 nicklas 3121     else if (result.size() > 1)
2562 08 Aug 14 nicklas 3122     {
2562 08 Aug 14 nicklas 3123       json.put("status", "error");
2562 08 Aug 14 nicklas 3124       jsonMessages.add("Found > 1 file server");
2562 08 Aug 14 nicklas 3125     }
2562 08 Aug 14 nicklas 3126     else
2562 08 Aug 14 nicklas 3127     {
2562 08 Aug 14 nicklas 3128       fs = result.get(0);
2562 08 Aug 14 nicklas 3129     }
2562 08 Aug 14 nicklas 3130     
2562 08 Aug 14 nicklas 3131     if (fs != null)
2562 08 Aug 14 nicklas 3132     {
2562 08 Aug 14 nicklas 3133       json.put("id", fs.getId());
2562 08 Aug 14 nicklas 3134       json.put("status", "ok"); // For now -- more checks below
2562 08 Aug 14 nicklas 3135       
2562 08 Aug 14 nicklas 3136       if (permissions != null && !permissions.checkPermissions(fs))
2562 08 Aug 14 nicklas 3137       {
2562 08 Aug 14 nicklas 3138         if (createIfMissing)
2562 08 Aug 14 nicklas 3139         {
2562 08 Aug 14 nicklas 3140           permissions.applyPermissions(fs);
2562 08 Aug 14 nicklas 3141           if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
2562 08 Aug 14 nicklas 3142         }
2562 08 Aug 14 nicklas 3143         else
2562 08 Aug 14 nicklas 3144         {
2562 08 Aug 14 nicklas 3145           json.put("status", "incomplete");
2562 08 Aug 14 nicklas 3146           jsonMessages.add(permissions.getMessage());
2562 08 Aug 14 nicklas 3147         }
2562 08 Aug 14 nicklas 3148       }
2562 08 Aug 14 nicklas 3149       
2562 08 Aug 14 nicklas 3150       if (!fileServer.getConnectionManagerId().equals(fs.getConnectionManagerFactoryId()))
2562 08 Aug 14 nicklas 3151       {
2562 08 Aug 14 nicklas 3152         if (createIfMissing)
2562 08 Aug 14 nicklas 3153         {
2562 08 Aug 14 nicklas 3154           fs.setConnectionManagerFactoryId(fileServer.getConnectionManagerId());
2562 08 Aug 14 nicklas 3155         }
2562 08 Aug 14 nicklas 3156         else
2562 08 Aug 14 nicklas 3157         {
2562 08 Aug 14 nicklas 3158           json.put("status", "incomplete");
2562 08 Aug 14 nicklas 3159           jsonMessages.add("Should use SFTP connection manager");
2562 08 Aug 14 nicklas 3160         }
2562 08 Aug 14 nicklas 3161       }
2562 08 Aug 14 nicklas 3162       
2562 08 Aug 14 nicklas 3163       if (fs.getHost() == null)
2562 08 Aug 14 nicklas 3164       {
2715 30 Sep 14 nicklas 3165         json.put("status", "warning");
2562 08 Aug 14 nicklas 3166         jsonMessages.add("No host name configured");
2562 08 Aug 14 nicklas 3167       }
2562 08 Aug 14 nicklas 3168       
2562 08 Aug 14 nicklas 3169       if (fs.getUsername() == null)
2562 08 Aug 14 nicklas 3170       {
2715 30 Sep 14 nicklas 3171         json.put("status", "warning");
2562 08 Aug 14 nicklas 3172         jsonMessages.add("No user configured");
2562 08 Aug 14 nicklas 3173       }
2562 08 Aug 14 nicklas 3174       
5577 16 Aug 19 nicklas 3175       if (!fs.hasPassword() && !fs.hasSshPrivateKey())
2562 08 Aug 14 nicklas 3176       {
2715 30 Sep 14 nicklas 3177         json.put("status", "warning");
5577 16 Aug 19 nicklas 3178         jsonMessages.add("No password or private-key configured");
2562 08 Aug 14 nicklas 3179       }
2562 08 Aug 14 nicklas 3180
2562 08 Aug 14 nicklas 3181       if (fs.getRootPath() == null)
2562 08 Aug 14 nicklas 3182       {
2715 30 Sep 14 nicklas 3183         json.put("status", "warning");
2562 08 Aug 14 nicklas 3184         jsonMessages.add("No root path configured");
2562 08 Aug 14 nicklas 3185       }
2562 08 Aug 14 nicklas 3186       
2562 08 Aug 14 nicklas 3187       if (fs.getSshFingerprint() == null)
2562 08 Aug 14 nicklas 3188       {
2715 30 Sep 14 nicklas 3189         json.put("status", "warning");
2562 08 Aug 14 nicklas 3190         jsonMessages.add("No SSH fingerprint configured");
2562 08 Aug 14 nicklas 3191       }
2562 08 Aug 14 nicklas 3192       
2562 08 Aug 14 nicklas 3193       if (json.get("status").equals("ok"))
2562 08 Aug 14 nicklas 3194       {
2562 08 Aug 14 nicklas 3195         ConnectionManagerFactory cmf = ConnectionManagerUtil.getFactory(fs.getConnectionManagerFactoryId());
2562 08 Aug 14 nicklas 3196         if (cmf == null)
2562 08 Aug 14 nicklas 3197         {
2562 08 Aug 14 nicklas 3198           json.put("status", "warning");
2562 08 Aug 14 nicklas 3199           jsonMessages.add("SFTP connection manager is not installed");
2562 08 Aug 14 nicklas 3200         }
2562 08 Aug 14 nicklas 3201         else
2562 08 Aug 14 nicklas 3202         {
2562 08 Aug 14 nicklas 3203           ConnectionParameters cp = new ConnectionParameters();
2562 08 Aug 14 nicklas 3204           cp.setHost(fs.getHost());
2562 08 Aug 14 nicklas 3205           cp.setUsername(fs.getUsername());
2562 08 Aug 14 nicklas 3206           cp.setPassword(fs.getPassword());
2562 08 Aug 14 nicklas 3207           cp.setRootPath(fs.getRootPath());
2562 08 Aug 14 nicklas 3208           cp.setSshFingerprint(fs.getSshFingerprint());
5577 16 Aug 19 nicklas 3209           byte[] privateKey = fs.getSshPrivateKey();
5577 16 Aug 19 nicklas 3210           if (privateKey != null && privateKey.length > 0)
5577 16 Aug 19 nicklas 3211           {
5577 16 Aug 19 nicklas 3212             cp.setSshPrivateKey(privateKey);
5577 16 Aug 19 nicklas 3213             cp.setSshPrivateKeyPassword(fs.getSshPrivateKeyPassword());
5577 16 Aug 19 nicklas 3214             cp.setSshPrivateKeyFormat(fs.getSshPrivateKeyFormat());
5577 16 Aug 19 nicklas 3215           }
2562 08 Aug 14 nicklas 3216           URI uri = cp.changeHost(URI.create("sftp://" + fs.getHost() + "/"));
2562 08 Aug 14 nicklas 3217           ConnectionManager cm = cmf.createConnectionManager(uri, cp);
2562 08 Aug 14 nicklas 3218           try
2562 08 Aug 14 nicklas 3219           {
2562 08 Aug 14 nicklas 3220             UriMetadata meta = cm.getMetadata();
2562 08 Aug 14 nicklas 3221           }
5577 16 Aug 19 nicklas 3222           catch (Exception ex)
2562 08 Aug 14 nicklas 3223           {
2562 08 Aug 14 nicklas 3224             json.put("status", "warning");
5577 16 Aug 19 nicklas 3225             json.put("stacktrace", ThrowableUtil.stackTraceToString(ex));
2562 08 Aug 14 nicklas 3226             jsonMessages.add(uri + ": " + ex.getMessage());
2562 08 Aug 14 nicklas 3227           }
2562 08 Aug 14 nicklas 3228         }
2562 08 Aug 14 nicklas 3229       }
2562 08 Aug 14 nicklas 3230     }
2562 08 Aug 14 nicklas 3231     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
2562 08 Aug 14 nicklas 3232     json.put("messages", jsonMessages);
2562 08 Aug 14 nicklas 3233     return json;
2562 08 Aug 14 nicklas 3234   
2562 08 Aug 14 nicklas 3235   }
2562 08 Aug 14 nicklas 3236
3600 13 Nov 15 nicklas 3237   /**
3600 13 Nov 15 nicklas 3238     Create a directory with the given options. The directory is created in
3600 13 Nov 15 nicklas 3239     a separate transaction.
3600 13 Nov 15 nicklas 3240     @since 4.0
3600 13 Nov 15 nicklas 3241   */
4028 26 Jul 16 nicklas 3242   public Directory createDirectory(SessionControl sc, Path path, PermissionOptions... permissions)
3600 13 Nov 15 nicklas 3243   {
3600 13 Nov 15 nicklas 3244     Directory d = null;
6328 14 Jun 21 nicklas 3245     DbControl dc = sc.newDbControl(":Installation wizard");
3600 13 Nov 15 nicklas 3246     try
3600 13 Nov 15 nicklas 3247     {
3600 13 Nov 15 nicklas 3248       d = Directory.getNew(dc, path);
4028 26 Jul 16 nicklas 3249       if (permissions != null) 
4028 26 Jul 16 nicklas 3250       {
4028 26 Jul 16 nicklas 3251         for (PermissionOptions p : permissions)
4028 26 Jul 16 nicklas 3252         {
4028 26 Jul 16 nicklas 3253           p.applyPermissions(d);
4028 26 Jul 16 nicklas 3254         }
4028 26 Jul 16 nicklas 3255       }
3600 13 Nov 15 nicklas 3256       dc.saveItem(d);
3600 13 Nov 15 nicklas 3257       dc.commit();
3600 13 Nov 15 nicklas 3258     }
3600 13 Nov 15 nicklas 3259     finally
3600 13 Nov 15 nicklas 3260     {
3600 13 Nov 15 nicklas 3261       if (dc != null) dc.close();
3600 13 Nov 15 nicklas 3262     }
3600 13 Nov 15 nicklas 3263     return d;
3600 13 Nov 15 nicklas 3264   }
2562 08 Aug 14 nicklas 3265   
2562 08 Aug 14 nicklas 3266   /**
3600 13 Nov 15 nicklas 3267     Check for an existing directory.
3600 13 Nov 15 nicklas 3268     A JSONObject is returned with the result. The following 
3600 13 Nov 15 nicklas 3269     keys are used:
3600 13 Nov 15 nicklas 3270     <ul>
3600 13 Nov 15 nicklas 3271     <li>itemType: DIRECTORY
3600 13 Nov 15 nicklas 3272     <li>name: The full path of the directory
3600 13 Nov 15 nicklas 3273     <li>id: The id of the directory if it exists
3600 13 Nov 15 nicklas 3274     <li>status: ok, error, or missing
3600 13 Nov 15 nicklas 3275     <li>message: A descriptive message in case of an error
3600 13 Nov 15 nicklas 3276     </ul>
3600 13 Nov 15 nicklas 3277     @since 4.0
3600 13 Nov 15 nicklas 3278   */
3600 13 Nov 15 nicklas 3279   public JSONObject checkDirectory(DbControl dc, String name, 
4028 26 Jul 16 nicklas 3280     boolean createIfMissing, PermissionOptions... permissions)
3600 13 Nov 15 nicklas 3281   {
3600 13 Nov 15 nicklas 3282   
3600 13 Nov 15 nicklas 3283     JSONObject json = new JSONObject();
3600 13 Nov 15 nicklas 3284     JSONArray jsonMessages = new JSONArray();
3600 13 Nov 15 nicklas 3285     json.put("itemType", Item.DIRECTORY.name());
3600 13 Nov 15 nicklas 3286     json.put("name", name);
3600 13 Nov 15 nicklas 3287     
3600 13 Nov 15 nicklas 3288     Directory d = null;
3600 13 Nov 15 nicklas 3289     Path path = new Path(name, Path.Type.DIRECTORY);
3600 13 Nov 15 nicklas 3290     try
3600 13 Nov 15 nicklas 3291     {
3600 13 Nov 15 nicklas 3292       d = Directory.getByPath(dc, path);
3600 13 Nov 15 nicklas 3293     }
3600 13 Nov 15 nicklas 3294     catch (RuntimeException ex)
3600 13 Nov 15 nicklas 3295     {}
3600 13 Nov 15 nicklas 3296     
3600 13 Nov 15 nicklas 3297     if (d == null)
3600 13 Nov 15 nicklas 3298     {
3600 13 Nov 15 nicklas 3299       if (createIfMissing)
3600 13 Nov 15 nicklas 3300       {
3600 13 Nov 15 nicklas 3301         d = createDirectory(dc.getSessionControl(), path, permissions);
3600 13 Nov 15 nicklas 3302         d = Directory.getById(dc, d.getId());
3600 13 Nov 15 nicklas 3303         json.put("id", d.getId());
3600 13 Nov 15 nicklas 3304       }
3600 13 Nov 15 nicklas 3305       else
3600 13 Nov 15 nicklas 3306       {
3600 13 Nov 15 nicklas 3307         json.put("status", "missing");
3600 13 Nov 15 nicklas 3308         jsonMessages.add("Not found");
3600 13 Nov 15 nicklas 3309       }
3600 13 Nov 15 nicklas 3310     }
3600 13 Nov 15 nicklas 3311     
3600 13 Nov 15 nicklas 3312     if (d != null)
3600 13 Nov 15 nicklas 3313     {
3600 13 Nov 15 nicklas 3314       json.put("id", d.getId());
3600 13 Nov 15 nicklas 3315       json.put("status", "ok"); // For now -- more checks below
3600 13 Nov 15 nicklas 3316       
4028 26 Jul 16 nicklas 3317       if (permissions != null)
3600 13 Nov 15 nicklas 3318       {
4028 26 Jul 16 nicklas 3319         String permissionCheck = null;
4028 26 Jul 16 nicklas 3320         for (PermissionOptions p : permissions)
3600 13 Nov 15 nicklas 3321         {
4028 26 Jul 16 nicklas 3322           if (!p.checkPermissions(d))
4028 26 Jul 16 nicklas 3323           {
4028 26 Jul 16 nicklas 3324             permissionCheck = p.getMessage();
4028 26 Jul 16 nicklas 3325             break;
4028 26 Jul 16 nicklas 3326           }
3600 13 Nov 15 nicklas 3327         }
4028 26 Jul 16 nicklas 3328         
4028 26 Jul 16 nicklas 3329         if (permissionCheck != null)
3600 13 Nov 15 nicklas 3330         {
4028 26 Jul 16 nicklas 3331           if (createIfMissing)
4028 26 Jul 16 nicklas 3332           {
4028 26 Jul 16 nicklas 3333             for (PermissionOptions p : permissions)
4028 26 Jul 16 nicklas 3334             {
4028 26 Jul 16 nicklas 3335               p.applyPermissions(d);
4028 26 Jul 16 nicklas 3336             }
4028 26 Jul 16 nicklas 3337             if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
4028 26 Jul 16 nicklas 3338           }
4028 26 Jul 16 nicklas 3339           else
4028 26 Jul 16 nicklas 3340           {
4028 26 Jul 16 nicklas 3341             json.put("status", "incomplete");
4028 26 Jul 16 nicklas 3342             jsonMessages.add(permissionCheck);
4028 26 Jul 16 nicklas 3343           }
3600 13 Nov 15 nicklas 3344         }
4028 26 Jul 16 nicklas 3345       }      
3600 13 Nov 15 nicklas 3346     }
3600 13 Nov 15 nicklas 3347     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
3600 13 Nov 15 nicklas 3348     json.put("messages", jsonMessages);
3600 13 Nov 15 nicklas 3349     return json;
3600 13 Nov 15 nicklas 3350   }
3600 13 Nov 15 nicklas 3351
3600 13 Nov 15 nicklas 3352   
3600 13 Nov 15 nicklas 3353   /**
2565 11 Aug 14 nicklas 3354     Create a data file type with the given options. The type is created in
2565 11 Aug 14 nicklas 3355     a separate transaction.
2565 11 Aug 14 nicklas 3356     @since 2.16
2565 11 Aug 14 nicklas 3357   */
2565 11 Aug 14 nicklas 3358   public DataFileType createDataFileType(SessionControl sc, Datafiletype def)
2565 11 Aug 14 nicklas 3359   {
2565 11 Aug 14 nicklas 3360     DataFileType type = null;
6328 14 Jun 21 nicklas 3361     DbControl dc = sc.newDbControl(":Installation wizard");
2565 11 Aug 14 nicklas 3362     try
2565 11 Aug 14 nicklas 3363     {
2565 11 Aug 14 nicklas 3364       type = DataFileType.getNew(dc, def.getExternalId(), def.getItemType());
2565 11 Aug 14 nicklas 3365       type.setName(def.getName());
2565 11 Aug 14 nicklas 3366       type.setExtension(def.getExtension());
2565 11 Aug 14 nicklas 3367       type.setDescription(def.getDescription());
2565 11 Aug 14 nicklas 3368       if (def.getSubtype() != null)
2565 11 Aug 14 nicklas 3369       {
2565 11 Aug 14 nicklas 3370         type.setGenericType(def.getSubtype().get(dc));
2565 11 Aug 14 nicklas 3371       }
2565 11 Aug 14 nicklas 3372       dc.saveItem(type);
2565 11 Aug 14 nicklas 3373       dc.commit();
2565 11 Aug 14 nicklas 3374     }
2565 11 Aug 14 nicklas 3375     finally
2565 11 Aug 14 nicklas 3376     {
2565 11 Aug 14 nicklas 3377       if (dc != null) dc.close();
2565 11 Aug 14 nicklas 3378     }
2565 11 Aug 14 nicklas 3379     return type;
2565 11 Aug 14 nicklas 3380   }
2565 11 Aug 14 nicklas 3381
2565 11 Aug 14 nicklas 3382   
2565 11 Aug 14 nicklas 3383   /**
2565 11 Aug 14 nicklas 3384     Check for an existing data file type with the given options.
2565 11 Aug 14 nicklas 3385     A JSONObject is returned with the result. The following 
2565 11 Aug 14 nicklas 3386     keys are used:
2565 11 Aug 14 nicklas 3387     <ul>
2565 11 Aug 14 nicklas 3388     <li>itemType: DATAFILETYPE
2565 11 Aug 14 nicklas 3389     <li>name: The name of the file type
2565 11 Aug 14 nicklas 3390     <li>id: The id of the file type if it exists
2565 11 Aug 14 nicklas 3391     <li>status: ok, error, or missing
2565 11 Aug 14 nicklas 3392     <li>message: A descriptive message in case of an error
2565 11 Aug 14 nicklas 3393     </ul>
2565 11 Aug 14 nicklas 3394     @since 2.16
2565 11 Aug 14 nicklas 3395   */
2565 11 Aug 14 nicklas 3396   public JSONObject checkDataFileType(DbControl dc, Datafiletype fileType, 
2565 11 Aug 14 nicklas 3397     boolean createIfMissing)
2565 11 Aug 14 nicklas 3398   {
2565 11 Aug 14 nicklas 3399   
2565 11 Aug 14 nicklas 3400     JSONObject json = new JSONObject();
2565 11 Aug 14 nicklas 3401     JSONArray jsonMessages = new JSONArray();
2565 11 Aug 14 nicklas 3402     json.put("itemType", Item.DATAFILETYPE.name());
2565 11 Aug 14 nicklas 3403     json.put("name", fileType.getName());
2565 11 Aug 14 nicklas 3404     
2565 11 Aug 14 nicklas 3405     List<DataFileType> result = fileType.list(dc);
2565 11 Aug 14 nicklas 3406     if (result.size() == 0)
2565 11 Aug 14 nicklas 3407     {
2565 11 Aug 14 nicklas 3408       if (createIfMissing)
2565 11 Aug 14 nicklas 3409       {
2565 11 Aug 14 nicklas 3410         DataFileType type = createDataFileType(dc.getSessionControl(), fileType);
2565 11 Aug 14 nicklas 3411         json.put("id", type.getId());
2565 11 Aug 14 nicklas 3412         json.put("status", "ok");
2565 11 Aug 14 nicklas 3413         jsonMessages.add("Created");
2565 11 Aug 14 nicklas 3414       }
2565 11 Aug 14 nicklas 3415       else
2565 11 Aug 14 nicklas 3416       {
2565 11 Aug 14 nicklas 3417         json.put("status", "missing");
2565 11 Aug 14 nicklas 3418         jsonMessages.add("Not found");
2565 11 Aug 14 nicklas 3419       }
2565 11 Aug 14 nicklas 3420     }
2565 11 Aug 14 nicklas 3421     else if (result.size() > 1)
2565 11 Aug 14 nicklas 3422     {
2565 11 Aug 14 nicklas 3423       json.put("status", "error");
2565 11 Aug 14 nicklas 3424       jsonMessages.add("Found > 1 MIME type");
2565 11 Aug 14 nicklas 3425     }
2565 11 Aug 14 nicklas 3426     else
2565 11 Aug 14 nicklas 3427     {
2565 11 Aug 14 nicklas 3428       DataFileType ft = result.get(0);
2565 11 Aug 14 nicklas 3429       json.put("id", ft.getId());
2565 11 Aug 14 nicklas 3430       json.put("status", "ok"); // For now -- more checks below
2565 11 Aug 14 nicklas 3431       
2565 11 Aug 14 nicklas 3432       if (!ft.getExternalId().equals(fileType.getExternalId()))
2565 11 Aug 14 nicklas 3433       {
2565 11 Aug 14 nicklas 3434         json.put("status", "error");
2565 11 Aug 14 nicklas 3435         jsonMessages.add("Should have '" + fileType.getExternalId() + "' as external id.");
2565 11 Aug 14 nicklas 3436       }
2565 11 Aug 14 nicklas 3437       
2565 11 Aug 14 nicklas 3438       if (!ft.getItemType().equals(fileType.getItemType()))
2565 11 Aug 14 nicklas 3439       {
2565 11 Aug 14 nicklas 3440         json.put("status", "error");
2565 11 Aug 14 nicklas 3441         jsonMessages.add("Should have '" + fileType.getItemType().name() + "' as item type.");
2565 11 Aug 14 nicklas 3442       }
2565 11 Aug 14 nicklas 3443       
2565 11 Aug 14 nicklas 3444       if (fileType.getSubtype() != null)
2565 11 Aug 14 nicklas 3445       {
2565 11 Aug 14 nicklas 3446         ItemSubtype subtype = fileType.getSubtype().get(dc);
2565 11 Aug 14 nicklas 3447         if (subtype != null && !subtype.equals(ft.getGenericType()))
2565 11 Aug 14 nicklas 3448         {
2565 11 Aug 14 nicklas 3449           if (createIfMissing)
2565 11 Aug 14 nicklas 3450           {
2565 11 Aug 14 nicklas 3451             ft.setGenericType(fileType.getSubtype().get(dc));
2565 11 Aug 14 nicklas 3452             jsonMessages.add("Fixed");
2565 11 Aug 14 nicklas 3453           }
2565 11 Aug 14 nicklas 3454           else
2565 11 Aug 14 nicklas 3455           {
2618 01 Sep 14 nicklas 3456             json.put("status", "incomplete");
2565 11 Aug 14 nicklas 3457             jsonMessages.add("Should be related to '" + fileType.getSubtype().getName() + "' subtype.");
2565 11 Aug 14 nicklas 3458           }
2565 11 Aug 14 nicklas 3459         }
2565 11 Aug 14 nicklas 3460       }
2565 11 Aug 14 nicklas 3461     }
2565 11 Aug 14 nicklas 3462     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
2565 11 Aug 14 nicklas 3463     json.put("messages", jsonMessages);
2565 11 Aug 14 nicklas 3464     return json;
2565 11 Aug 14 nicklas 3465   
2565 11 Aug 14 nicklas 3466   }
2565 11 Aug 14 nicklas 3467
2565 11 Aug 14 nicklas 3468   
2565 11 Aug 14 nicklas 3469   /**
4673 08 Feb 18 nicklas 3470     Create a platform variant with the given options. The platform is created in
4673 08 Feb 18 nicklas 3471     a separate transaction.
4673 08 Feb 18 nicklas 3472     @since 4.15
4673 08 Feb 18 nicklas 3473   */
4673 08 Feb 18 nicklas 3474   public PlatformVariant createPlatform(SessionControl sc, Rawdatatype rawType, Datafiletype... fileTypes)
4673 08 Feb 18 nicklas 3475   {
4673 08 Feb 18 nicklas 3476     PlatformVariant pv = null;
6538 13 Jan 22 nicklas 3477     Platform p = null;
6328 14 Jun 21 nicklas 3478     DbControl dc = sc.newDbControl(":Installation wizard");
4673 08 Feb 18 nicklas 3479     try
4673 08 Feb 18 nicklas 3480     {
6538 13 Jan 22 nicklas 3481       try
6538 13 Jan 22 nicklas 3482       {
6538 13 Jan 22 nicklas 3483         p = rawType.getPlatform(dc);
6538 13 Jan 22 nicklas 3484       }
6538 13 Jan 22 nicklas 3485       catch (ItemNotFoundException ex)
6538 13 Jan 22 nicklas 3486       {
6538 13 Jan 22 nicklas 3487         p = Platform.getNew(dc, rawType.getPlatformId(), 1);
6538 13 Jan 22 nicklas 3488         p.setName(rawType.getPlatformName());
6538 13 Jan 22 nicklas 3489         dc.saveItem(p);
6538 13 Jan 22 nicklas 3490       }
4673 08 Feb 18 nicklas 3491       pv = PlatformVariant.getNew(dc, p, rawType.getVariantId(), 1);
4673 08 Feb 18 nicklas 3492       pv.setName(rawType.getName());
4673 08 Feb 18 nicklas 3493       dc.saveItem(pv);
4673 08 Feb 18 nicklas 3494       
4673 08 Feb 18 nicklas 3495       if (fileTypes != null)
4673 08 Feb 18 nicklas 3496       {
4673 08 Feb 18 nicklas 3497         for (Datafiletype fileType : fileTypes)
4673 08 Feb 18 nicklas 3498         {
4673 08 Feb 18 nicklas 3499           List<DataFileType> list = fileType.list(dc); // Use list() to avoid throwing exceptions if the annotation type doesn't exists yet
4673 08 Feb 18 nicklas 3500           DataFileType dft = list.size() == 1 ? list.get(0) : null;
4673 08 Feb 18 nicklas 3501           if (dft != null)
4673 08 Feb 18 nicklas 3502           {
4673 08 Feb 18 nicklas 3503             PlatformFileType pft = p.getFileType(dft, pv, true);
4673 08 Feb 18 nicklas 3504             pft.setAllowMultiple(fileType.getAllowMultiple());
4673 08 Feb 18 nicklas 3505             pft.setRequired(fileType.isRequired());
4673 08 Feb 18 nicklas 3506           }
4673 08 Feb 18 nicklas 3507         }
4673 08 Feb 18 nicklas 3508       }
4673 08 Feb 18 nicklas 3509     
4673 08 Feb 18 nicklas 3510       dc.commit();
4673 08 Feb 18 nicklas 3511     }
4673 08 Feb 18 nicklas 3512     finally
4673 08 Feb 18 nicklas 3513     {
4673 08 Feb 18 nicklas 3514       if (dc != null) dc.close();
4673 08 Feb 18 nicklas 3515     }
4673 08 Feb 18 nicklas 3516     return pv;
4673 08 Feb 18 nicklas 3517   }
4673 08 Feb 18 nicklas 3518
4673 08 Feb 18 nicklas 3519   
4673 08 Feb 18 nicklas 3520   /**
4673 08 Feb 18 nicklas 3521     Check for an existing platform (variant) with the given options.
4673 08 Feb 18 nicklas 3522     A JSONObject is returned with the result. The following 
4673 08 Feb 18 nicklas 3523     keys are used:
4673 08 Feb 18 nicklas 3524     <ul>
4673 08 Feb 18 nicklas 3525     <li>itemType: PLATFORMVARIANT
4673 08 Feb 18 nicklas 3526     <li>name: The name of the platform variant
4673 08 Feb 18 nicklas 3527     <li>id: The id of the platform variant if it exists
4673 08 Feb 18 nicklas 3528     <li>status: ok, error, or missing
4673 08 Feb 18 nicklas 3529     <li>message: A descriptive message in case of an error
4673 08 Feb 18 nicklas 3530     </ul>
4673 08 Feb 18 nicklas 3531     @since 4.15
4673 08 Feb 18 nicklas 3532   */
4673 08 Feb 18 nicklas 3533   public JSONObject checkPlatform(DbControl dc, Rawdatatype rawType, 
4673 08 Feb 18 nicklas 3534     boolean createIfMissing, Datafiletype... fileTypes)
4673 08 Feb 18 nicklas 3535   {
4673 08 Feb 18 nicklas 3536   
4673 08 Feb 18 nicklas 3537     JSONObject json = new JSONObject();
4673 08 Feb 18 nicklas 3538     JSONArray jsonMessages = new JSONArray();
4673 08 Feb 18 nicklas 3539     json.put("itemType", Item.PLATFORMVARIANT.name());
4673 08 Feb 18 nicklas 3540     json.put("name", rawType.getName());
4673 08 Feb 18 nicklas 3541     
4673 08 Feb 18 nicklas 3542     List<PlatformVariant> result = rawType.list(dc);
4673 08 Feb 18 nicklas 3543     if (result.size() == 0)
4673 08 Feb 18 nicklas 3544     {
4673 08 Feb 18 nicklas 3545       if (createIfMissing)
4673 08 Feb 18 nicklas 3546       {
4673 08 Feb 18 nicklas 3547         PlatformVariant pv = createPlatform(dc.getSessionControl(), rawType, fileTypes);
4673 08 Feb 18 nicklas 3548         json.put("id", pv.getId());
4673 08 Feb 18 nicklas 3549         json.put("status", "ok");
4673 08 Feb 18 nicklas 3550         jsonMessages.add("Created");
4673 08 Feb 18 nicklas 3551       }
4673 08 Feb 18 nicklas 3552       else
4673 08 Feb 18 nicklas 3553       {
4673 08 Feb 18 nicklas 3554         json.put("status", "missing");
4673 08 Feb 18 nicklas 3555         jsonMessages.add("Not found");
4673 08 Feb 18 nicklas 3556       }
4673 08 Feb 18 nicklas 3557     }
4673 08 Feb 18 nicklas 3558     else if (result.size() > 1)
4673 08 Feb 18 nicklas 3559     {
4673 08 Feb 18 nicklas 3560       json.put("status", "error");
4673 08 Feb 18 nicklas 3561       jsonMessages.add("Found > 1 platform");
4673 08 Feb 18 nicklas 3562     }
4673 08 Feb 18 nicklas 3563     else
4673 08 Feb 18 nicklas 3564     {
4673 08 Feb 18 nicklas 3565       PlatformVariant pv = result.get(0);
4673 08 Feb 18 nicklas 3566       Platform p = pv.getPlatform();
4673 08 Feb 18 nicklas 3567       json.put("id", pv.getId());
4673 08 Feb 18 nicklas 3568       json.put("status", "ok"); // For now -- more checks below
4673 08 Feb 18 nicklas 3569       
4673 08 Feb 18 nicklas 3570       if (!pv.getExternalId().equals(rawType.getVariantId()))
4673 08 Feb 18 nicklas 3571       {
4673 08 Feb 18 nicklas 3572         json.put("status", "error");
4673 08 Feb 18 nicklas 3573         jsonMessages.add("Should have '" + rawType.getVariantId() + "' as external id.");
4673 08 Feb 18 nicklas 3574       }
4673 08 Feb 18 nicklas 3575       
4673 08 Feb 18 nicklas 3576       if (fileTypes != null)
4673 08 Feb 18 nicklas 3577       {
4673 08 Feb 18 nicklas 3578         for (Datafiletype fileType : fileTypes)
4673 08 Feb 18 nicklas 3579         {
4673 08 Feb 18 nicklas 3580           List<DataFileType> list = fileType.list(dc); // Use list() to avoid throwing exceptions if the annotation type doesn't exists yet
4673 08 Feb 18 nicklas 3581           DataFileType dft = list.size() == 1 ? list.get(0) : null;
4673 08 Feb 18 nicklas 3582           if (dft != null)
4673 08 Feb 18 nicklas 3583           {
4673 08 Feb 18 nicklas 3584             PlatformFileType pft = p.getFileType(dft, pv, createIfMissing);
4673 08 Feb 18 nicklas 3585             if (pft == null)
4673 08 Feb 18 nicklas 3586             {
4673 08 Feb 18 nicklas 3587               json.put("status", "incomplete");
4673 08 Feb 18 nicklas 3588               jsonMessages.add("Not linked with: " + fileType.getName());
4673 08 Feb 18 nicklas 3589             }
4673 08 Feb 18 nicklas 3590             else if (!pft.isInDatabase())
4673 08 Feb 18 nicklas 3591             {
4673 08 Feb 18 nicklas 3592               pft.setAllowMultiple(fileType.getAllowMultiple());
4673 08 Feb 18 nicklas 3593               pft.setRequired(fileType.isRequired());
4673 08 Feb 18 nicklas 3594               if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
4673 08 Feb 18 nicklas 3595             }
4673 08 Feb 18 nicklas 3596           }
4673 08 Feb 18 nicklas 3597         }
4673 08 Feb 18 nicklas 3598       }
4673 08 Feb 18 nicklas 3599     }
4673 08 Feb 18 nicklas 3600     
4673 08 Feb 18 nicklas 3601     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
4673 08 Feb 18 nicklas 3602     json.put("messages", jsonMessages);
4673 08 Feb 18 nicklas 3603     return json;
4673 08 Feb 18 nicklas 3604   
4673 08 Feb 18 nicklas 3605   }
4673 08 Feb 18 nicklas 3606
4673 08 Feb 18 nicklas 3607   /**
1865 19 Feb 13 nicklas 3608     Create a MIME type with the given options. The type is created in
1865 19 Feb 13 nicklas 3609     a separate transaction.
1867 19 Feb 13 nicklas 3610     @since 2.12
1865 19 Feb 13 nicklas 3611   */
1865 19 Feb 13 nicklas 3612   public Extract createExtract(SessionControl sc, String name, Subtype subtype, String description, PermissionOptions permissions)
1865 19 Feb 13 nicklas 3613   {
1865 19 Feb 13 nicklas 3614     Extract extract = null;
6328 14 Jun 21 nicklas 3615     DbControl dc = sc.newDbControl(":Installation wizard");
1865 19 Feb 13 nicklas 3616     try
1865 19 Feb 13 nicklas 3617     {
1865 19 Feb 13 nicklas 3618       extract = Extract.getNew(dc);
1865 19 Feb 13 nicklas 3619       extract.setName(name);
1865 19 Feb 13 nicklas 3620       extract.setItemSubtype(subtype.get(dc));
1865 19 Feb 13 nicklas 3621       extract.setDescription(description);
1865 19 Feb 13 nicklas 3622       if (permissions != null) permissions.applyPermissions(extract);
1865 19 Feb 13 nicklas 3623       dc.saveItem(extract);
1865 19 Feb 13 nicklas 3624       dc.commit();
1865 19 Feb 13 nicklas 3625     }
1865 19 Feb 13 nicklas 3626     finally
1865 19 Feb 13 nicklas 3627     {
1865 19 Feb 13 nicklas 3628       if (dc != null) dc.close();
1865 19 Feb 13 nicklas 3629     }
1865 19 Feb 13 nicklas 3630     return extract;
1865 19 Feb 13 nicklas 3631   }
1865 19 Feb 13 nicklas 3632   
1865 19 Feb 13 nicklas 3633   /**
1865 19 Feb 13 nicklas 3634     Check for an existing Extract type with the given options.
1865 19 Feb 13 nicklas 3635     A JSONObject is returned with the result. The following 
1865 19 Feb 13 nicklas 3636     keys are used:
1865 19 Feb 13 nicklas 3637     <ul>
1865 19 Feb 13 nicklas 3638     <li>itemType: EXTRACT
1865 19 Feb 13 nicklas 3639     <li>name: The name of the extract
1865 19 Feb 13 nicklas 3640     <li>id: The id of the extract if it exists
1865 19 Feb 13 nicklas 3641     <li>status: ok, error, or missing
1865 19 Feb 13 nicklas 3642     <li>message: A descriptive message in case of an error
1865 19 Feb 13 nicklas 3643     </ul>
1867 19 Feb 13 nicklas 3644     @since 2.12
1865 19 Feb 13 nicklas 3645   */
1865 19 Feb 13 nicklas 3646   public JSONObject checkExtract(DbControl dc, String name, Subtype subtype, String description, PermissionOptions permissions,
1865 19 Feb 13 nicklas 3647     boolean createIfMissing)
1865 19 Feb 13 nicklas 3648   {
1865 19 Feb 13 nicklas 3649   
1865 19 Feb 13 nicklas 3650     JSONObject json = new JSONObject();
1865 19 Feb 13 nicklas 3651     JSONArray jsonMessages = new JSONArray();
1865 19 Feb 13 nicklas 3652     json.put("itemType", Item.EXTRACT.name());
1865 19 Feb 13 nicklas 3653     json.put("name", name);
1865 19 Feb 13 nicklas 3654
1865 19 Feb 13 nicklas 3655     ItemQuery<Extract> query = Extract.getQuery();
1865 19 Feb 13 nicklas 3656     query.setIncludes(Include.ALL);
1865 19 Feb 13 nicklas 3657     query.restrict(
1865 19 Feb 13 nicklas 3658       Restrictions.eq(
1865 19 Feb 13 nicklas 3659         Hql.property("name"), 
1865 19 Feb 13 nicklas 3660         Expressions.parameter("name", name, Type.STRING)
1865 19 Feb 13 nicklas 3661       ));
1865 19 Feb 13 nicklas 3662     
1865 19 Feb 13 nicklas 3663     List<Extract> result = query.list(dc);
1865 19 Feb 13 nicklas 3664     if (result.size() == 0)
1865 19 Feb 13 nicklas 3665     {
1865 19 Feb 13 nicklas 3666       if (createIfMissing)
1865 19 Feb 13 nicklas 3667       {
1865 19 Feb 13 nicklas 3668         Extract extract = createExtract(dc.getSessionControl(), name, subtype, description, permissions);
1865 19 Feb 13 nicklas 3669         json.put("id", extract.getId());
1865 19 Feb 13 nicklas 3670         json.put("status", "ok");
1865 19 Feb 13 nicklas 3671         jsonMessages.add("Created");
1865 19 Feb 13 nicklas 3672       }
1865 19 Feb 13 nicklas 3673       else
1865 19 Feb 13 nicklas 3674       {
1865 19 Feb 13 nicklas 3675         json.put("status", "missing");
1865 19 Feb 13 nicklas 3676         jsonMessages.add("Not found");
1865 19 Feb 13 nicklas 3677       }
1865 19 Feb 13 nicklas 3678     }
1865 19 Feb 13 nicklas 3679     else if (result.size() > 1)
1865 19 Feb 13 nicklas 3680     {
1865 19 Feb 13 nicklas 3681       json.put("status", "error");
1865 19 Feb 13 nicklas 3682       jsonMessages.add("Found > 1 Extract [" + name + "]");
1865 19 Feb 13 nicklas 3683     }
1865 19 Feb 13 nicklas 3684     else
1865 19 Feb 13 nicklas 3685     {
1865 19 Feb 13 nicklas 3686       Extract e = result.get(0);
1865 19 Feb 13 nicklas 3687       json.put("id", e.getId());
1865 19 Feb 13 nicklas 3688       json.put("status", "ok"); // For now -- more checks below
1865 19 Feb 13 nicklas 3689       
1865 19 Feb 13 nicklas 3690       if (!subtype.load(dc).equals(e.getItemSubtype()))
1865 19 Feb 13 nicklas 3691       {
1865 19 Feb 13 nicklas 3692         json.put("status", "error");
1865 19 Feb 13 nicklas 3693         jsonMessages.add("Should have '" + subtype.getName() + "' as subtype.");
1865 19 Feb 13 nicklas 3694       }
1865 19 Feb 13 nicklas 3695       
1865 19 Feb 13 nicklas 3696       if (permissions != null && !permissions.checkPermissions(e))
1865 19 Feb 13 nicklas 3697       {
1865 19 Feb 13 nicklas 3698         if (createIfMissing)
1865 19 Feb 13 nicklas 3699         {
1865 19 Feb 13 nicklas 3700           permissions.applyPermissions(e);
1865 19 Feb 13 nicklas 3701           if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
1865 19 Feb 13 nicklas 3702         }
1865 19 Feb 13 nicklas 3703         else
1865 19 Feb 13 nicklas 3704         {
1865 19 Feb 13 nicklas 3705           json.put("status", "incomplete");
1865 19 Feb 13 nicklas 3706           jsonMessages.add(permissions.getMessage());
1865 19 Feb 13 nicklas 3707         }
1865 19 Feb 13 nicklas 3708       }
1865 19 Feb 13 nicklas 3709       
1865 19 Feb 13 nicklas 3710     }
1865 19 Feb 13 nicklas 3711     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
1865 19 Feb 13 nicklas 3712     json.put("messages", jsonMessages);
1865 19 Feb 13 nicklas 3713     return json;
1865 19 Feb 13 nicklas 3714   }
1865 19 Feb 13 nicklas 3715
1865 19 Feb 13 nicklas 3716   
1865 19 Feb 13 nicklas 3717   /**
1606 19 Apr 12 nicklas 3718     Create a Plate geometry with the given options. The geometry is created in
1606 19 Apr 12 nicklas 3719     a separate transaction.
1606 19 Apr 12 nicklas 3720     @since 2.5
1606 19 Apr 12 nicklas 3721   */
1606 19 Apr 12 nicklas 3722   public PlateGeometry createPlateGeometry(SessionControl sc, Geometry def)
1606 19 Apr 12 nicklas 3723   {
1606 19 Apr 12 nicklas 3724     PlateGeometry g = null;
6328 14 Jun 21 nicklas 3725     DbControl dc = sc.newDbControl(":Installation wizard");
1606 19 Apr 12 nicklas 3726     try
1606 19 Apr 12 nicklas 3727     {
1606 19 Apr 12 nicklas 3728       g = PlateGeometry.getNew(dc, def.getRows(), def.getColumns());
1606 19 Apr 12 nicklas 3729       g.setName(def.getName());
1606 19 Apr 12 nicklas 3730       dc.saveItem(g);
1606 19 Apr 12 nicklas 3731       dc.commit();
1606 19 Apr 12 nicklas 3732     }
1606 19 Apr 12 nicklas 3733     finally
1606 19 Apr 12 nicklas 3734     {
1606 19 Apr 12 nicklas 3735       if (dc != null) dc.close();
1606 19 Apr 12 nicklas 3736     }
1606 19 Apr 12 nicklas 3737     return g;
1606 19 Apr 12 nicklas 3738   }
1546 02 Mar 12 nicklas 3739
1606 19 Apr 12 nicklas 3740   
1606 19 Apr 12 nicklas 3741   /**
1606 19 Apr 12 nicklas 3742     Check for an existing Plate geometry type with the given options.
1606 19 Apr 12 nicklas 3743     A JSONObject is returned with the result. The following 
1606 19 Apr 12 nicklas 3744     keys are used:
1606 19 Apr 12 nicklas 3745     <ul>
1606 19 Apr 12 nicklas 3746     <li>itemType: PLATEGEOMETRY
1606 19 Apr 12 nicklas 3747     <li>name: The name of the geometry
1606 19 Apr 12 nicklas 3748     <li>id: The id of the geometry if it exists
1606 19 Apr 12 nicklas 3749     <li>rows: The number of rows
1606 19 Apr 12 nicklas 3750     <li>column: The number of columns
1606 19 Apr 12 nicklas 3751     <li>status: ok, error, or missing
1606 19 Apr 12 nicklas 3752     <li>message: A descriptive message in case of an error
1606 19 Apr 12 nicklas 3753     </ul>
1606 19 Apr 12 nicklas 3754     @since 2.5
1606 19 Apr 12 nicklas 3755   */
1606 19 Apr 12 nicklas 3756   public JSONObject checkPlateGeometry(DbControl dc, Geometry geometry, boolean createIfMissing)
1606 19 Apr 12 nicklas 3757   {
1606 19 Apr 12 nicklas 3758   
1606 19 Apr 12 nicklas 3759     JSONObject json = new JSONObject();
1606 19 Apr 12 nicklas 3760     JSONArray jsonMessages = new JSONArray();
1606 19 Apr 12 nicklas 3761     json.put("itemType", Item.PLATEGEOMETRY.name());
1606 19 Apr 12 nicklas 3762     json.put("name", geometry.getName());
1606 19 Apr 12 nicklas 3763     json.put("rows", geometry.getRows());
1606 19 Apr 12 nicklas 3764     json.put("columns", geometry.getColumns());
1606 19 Apr 12 nicklas 3765       
1606 19 Apr 12 nicklas 3766     List<PlateGeometry> result = geometry.list(dc);
1606 19 Apr 12 nicklas 3767     if (result.size() == 0)
1606 19 Apr 12 nicklas 3768     {
1606 19 Apr 12 nicklas 3769       if (createIfMissing)
1606 19 Apr 12 nicklas 3770       {
1606 19 Apr 12 nicklas 3771         PlateGeometry g = createPlateGeometry(dc.getSessionControl(), geometry);
1606 19 Apr 12 nicklas 3772         json.put("id", g.getId());
1606 19 Apr 12 nicklas 3773         json.put("status", "ok");
1606 19 Apr 12 nicklas 3774         jsonMessages.add("Created");
1606 19 Apr 12 nicklas 3775       }
1606 19 Apr 12 nicklas 3776       else
1606 19 Apr 12 nicklas 3777       {
1606 19 Apr 12 nicklas 3778         json.put("status", "missing");
1606 19 Apr 12 nicklas 3779         jsonMessages.add("Not found");
1606 19 Apr 12 nicklas 3780       }
1606 19 Apr 12 nicklas 3781     }
1606 19 Apr 12 nicklas 3782     else if (result.size() > 1)
1606 19 Apr 12 nicklas 3783     {
1606 19 Apr 12 nicklas 3784       json.put("status", "error");
1606 19 Apr 12 nicklas 3785       jsonMessages.add("Found > 1 geometry");
1606 19 Apr 12 nicklas 3786     }
1606 19 Apr 12 nicklas 3787     else
1606 19 Apr 12 nicklas 3788     {
1606 19 Apr 12 nicklas 3789       PlateGeometry g = result.get(0);
1606 19 Apr 12 nicklas 3790       json.put("id", g.getId());
1606 19 Apr 12 nicklas 3791       json.put("status", "ok"); // For now -- more checks below
1606 19 Apr 12 nicklas 3792     }
1606 19 Apr 12 nicklas 3793     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
1606 19 Apr 12 nicklas 3794     json.put("messages", jsonMessages);
1606 19 Apr 12 nicklas 3795     return json;
1606 19 Apr 12 nicklas 3796   
1606 19 Apr 12 nicklas 3797   }
1606 19 Apr 12 nicklas 3798
2724 02 Oct 14 nicklas 3799   public JSONObject checkPlugin(DbControl dc, String clazz,
1570 16 Mar 12 nicklas 3800     PermissionOptions permissions, boolean createIfMissing)
1570 16 Mar 12 nicklas 3801   {
1570 16 Mar 12 nicklas 3802     JSONObject json = new JSONObject();
1570 16 Mar 12 nicklas 3803     JSONArray jsonMessages = new JSONArray();
1570 16 Mar 12 nicklas 3804     json.put("itemType", Item.PLUGINDEFINITION.name());
2724 02 Oct 14 nicklas 3805     json.put("name", clazz);
1570 16 Mar 12 nicklas 3806     
1570 16 Mar 12 nicklas 3807     try
1570 16 Mar 12 nicklas 3808     {
2724 02 Oct 14 nicklas 3809       PluginDefinition plugin = PluginDefinition.getByClassName(dc, clazz);
1570 16 Mar 12 nicklas 3810       
1570 16 Mar 12 nicklas 3811       json.put("id", plugin.getId());
1570 16 Mar 12 nicklas 3812       json.put("name", plugin.getName());
1570 16 Mar 12 nicklas 3813       json.put("status", "ok"); // For now -- more checks below
1570 16 Mar 12 nicklas 3814       
1570 16 Mar 12 nicklas 3815       if (permissions != null && !permissions.checkPermissions(plugin))
1570 16 Mar 12 nicklas 3816       {
1570 16 Mar 12 nicklas 3817         if (createIfMissing)
1570 16 Mar 12 nicklas 3818         {
1570 16 Mar 12 nicklas 3819           permissions.applyPermissions(plugin);
1570 16 Mar 12 nicklas 3820           if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
1570 16 Mar 12 nicklas 3821         }
1570 16 Mar 12 nicklas 3822         else
1570 16 Mar 12 nicklas 3823         {
1570 16 Mar 12 nicklas 3824           json.put("status", "incomplete");
1570 16 Mar 12 nicklas 3825           jsonMessages.add(permissions.getMessage());
1570 16 Mar 12 nicklas 3826         }
1570 16 Mar 12 nicklas 3827       }
1570 16 Mar 12 nicklas 3828     }
1570 16 Mar 12 nicklas 3829     catch (ItemNotFoundException ex)
1570 16 Mar 12 nicklas 3830     {
1570 16 Mar 12 nicklas 3831       jsonMessages.add("Not installed");
1570 16 Mar 12 nicklas 3832       json.put("status", "error");
1570 16 Mar 12 nicklas 3833     }
1570 16 Mar 12 nicklas 3834     
1570 16 Mar 12 nicklas 3835     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
1570 16 Mar 12 nicklas 3836     json.put("messages", jsonMessages);
1570 16 Mar 12 nicklas 3837     return json;
1570 16 Mar 12 nicklas 3838   }
1546 02 Mar 12 nicklas 3839
2724 02 Oct 14 nicklas 3840   public JSONObject checkPluginConfiguration(DbControl dc, String clazz, String configName,
1570 16 Mar 12 nicklas 3841     PermissionOptions permissions, boolean createIfMissing)
1570 16 Mar 12 nicklas 3842   {
1570 16 Mar 12 nicklas 3843     JSONObject json = new JSONObject();
1570 16 Mar 12 nicklas 3844     JSONArray jsonMessages = new JSONArray();
1570 16 Mar 12 nicklas 3845     json.put("itemType", Item.PLUGINCONFIGURATION.name());
1570 16 Mar 12 nicklas 3846     json.put("name", configName);
1570 16 Mar 12 nicklas 3847     
1570 16 Mar 12 nicklas 3848     try
1570 16 Mar 12 nicklas 3849     {
2724 02 Oct 14 nicklas 3850       PluginDefinition plugin = PluginDefinition.getByClassName(dc, clazz);
1570 16 Mar 12 nicklas 3851       
1570 16 Mar 12 nicklas 3852       ItemQuery<PluginConfiguration> query = plugin.getPluginConfigurations();
1570 16 Mar 12 nicklas 3853       query.include(Include.ALL);
1570 16 Mar 12 nicklas 3854       query.restrict(Restrictions.eq(Hql.property("name"), Expressions.string(configName)));
1570 16 Mar 12 nicklas 3855       
1570 16 Mar 12 nicklas 3856       List<PluginConfiguration> result = query.list(dc);
1570 16 Mar 12 nicklas 3857       
1570 16 Mar 12 nicklas 3858       if (result.size() == 0)
1570 16 Mar 12 nicklas 3859       {
1570 16 Mar 12 nicklas 3860         json.put("status", "error");
1570 16 Mar 12 nicklas 3861         jsonMessages.add("Not installed");
1570 16 Mar 12 nicklas 3862       }
1570 16 Mar 12 nicklas 3863       else if (result.size() > 1)
1570 16 Mar 12 nicklas 3864       {
1570 16 Mar 12 nicklas 3865         json.put("status", "error");
1570 16 Mar 12 nicklas 3866         jsonMessages.add("Found > 1 configuration");
1570 16 Mar 12 nicklas 3867       }
1570 16 Mar 12 nicklas 3868       else
1570 16 Mar 12 nicklas 3869       {
1570 16 Mar 12 nicklas 3870         PluginConfiguration config = result.get(0);
1570 16 Mar 12 nicklas 3871         json.put("id", config.getId());
1570 16 Mar 12 nicklas 3872         json.put("status", "ok"); // For now -- more checks below
1570 16 Mar 12 nicklas 3873         
1570 16 Mar 12 nicklas 3874         if (permissions != null && !permissions.checkPermissions(config))
1570 16 Mar 12 nicklas 3875         {
1570 16 Mar 12 nicklas 3876           if (createIfMissing)
1570 16 Mar 12 nicklas 3877           {
1570 16 Mar 12 nicklas 3878             permissions.applyPermissions(config);
1570 16 Mar 12 nicklas 3879             if (jsonMessages.size() == 0) jsonMessages.add("Fixed");
1570 16 Mar 12 nicklas 3880           }
1570 16 Mar 12 nicklas 3881           else
1570 16 Mar 12 nicklas 3882           {
1570 16 Mar 12 nicklas 3883             json.put("status", "incomplete");
1570 16 Mar 12 nicklas 3884             jsonMessages.add(permissions.getMessage());
1570 16 Mar 12 nicklas 3885           }
1570 16 Mar 12 nicklas 3886         }
1570 16 Mar 12 nicklas 3887       }
1570 16 Mar 12 nicklas 3888     }
1570 16 Mar 12 nicklas 3889     catch (ItemNotFoundException ex)
1570 16 Mar 12 nicklas 3890     {
1570 16 Mar 12 nicklas 3891       jsonMessages.add("Not installed");
1570 16 Mar 12 nicklas 3892       json.put("status", "error");
1570 16 Mar 12 nicklas 3893     }
1570 16 Mar 12 nicklas 3894     
1570 16 Mar 12 nicklas 3895     if (jsonMessages.size() == 0) jsonMessages.add("Ok");
1570 16 Mar 12 nicklas 3896     json.put("messages", jsonMessages);
1570 16 Mar 12 nicklas 3897     return json;
1570 16 Mar 12 nicklas 3898   }
1570 16 Mar 12 nicklas 3899
2350 10 Apr 14 nicklas 3900   private Map<String, String> barcodeSequences;
5865 12 Mar 20 nicklas 3901   private Map<String, String> barcodeSequences2;
2350 10 Apr 14 nicklas 3902   /**
2350 10 Apr 14 nicklas 3903     Maps barcode name (AD001, AD002, ...) to gene sequence.
2350 10 Apr 14 nicklas 3904   */
2350 10 Apr 14 nicklas 3905   private String lookupSequence(String barcode)
2350 10 Apr 14 nicklas 3906   {
2350 10 Apr 14 nicklas 3907     if (barcodeSequences == null)
2350 10 Apr 14 nicklas 3908     {
2350 10 Apr 14 nicklas 3909       barcodeSequences = new HashMap<String, String>();
2350 10 Apr 14 nicklas 3910       barcodeSequences.put("AD001", "ATCACGA");
2350 10 Apr 14 nicklas 3911       barcodeSequences.put("AD002", "CGATGTA");
2350 10 Apr 14 nicklas 3912       barcodeSequences.put("AD003", "TTAGGCA");
2350 10 Apr 14 nicklas 3913       barcodeSequences.put("AD004", "TGACCAA");
2350 10 Apr 14 nicklas 3914       barcodeSequences.put("AD005", "ACAGTGA");
2350 10 Apr 14 nicklas 3915       barcodeSequences.put("AD006", "GCCAATA");
2350 10 Apr 14 nicklas 3916       barcodeSequences.put("AD007", "CAGATCA");
2350 10 Apr 14 nicklas 3917       barcodeSequences.put("AD008", "ACTTGAA");
2350 10 Apr 14 nicklas 3918       barcodeSequences.put("AD009", "GATCAGA");
2350 10 Apr 14 nicklas 3919       barcodeSequences.put("AD010", "TAGCTTA");
2350 10 Apr 14 nicklas 3920       barcodeSequences.put("AD011", "GGCTACA");
2350 10 Apr 14 nicklas 3921       barcodeSequences.put("AD012", "CTTGTAA");
2350 10 Apr 14 nicklas 3922       barcodeSequences.put("AD013", "AGTCAAA");
2350 10 Apr 14 nicklas 3923       barcodeSequences.put("AD014", "AGTTCCA");
2350 10 Apr 14 nicklas 3924       barcodeSequences.put("AD015", "ATGTCAA");
2350 10 Apr 14 nicklas 3925       barcodeSequences.put("AD016", "CCGTCCA");
2350 10 Apr 14 nicklas 3926       barcodeSequences.put("AD018", "GTCCGCA");
2350 10 Apr 14 nicklas 3927       barcodeSequences.put("AD019", "GTGAAAA");
2350 10 Apr 14 nicklas 3928       barcodeSequences.put("AD020", "GTGGCCA");
2350 10 Apr 14 nicklas 3929       barcodeSequences.put("AD021", "GTTTCGA");
2350 10 Apr 14 nicklas 3930       barcodeSequences.put("AD022", "CGTACGA");
2350 10 Apr 14 nicklas 3931       barcodeSequences.put("AD023", "GAGTGGA");
2350 10 Apr 14 nicklas 3932       barcodeSequences.put("AD025", "ACTGATA");
2350 10 Apr 14 nicklas 3933       barcodeSequences.put("AD027", "ATTCCTA");
5865 12 Mar 20 nicklas 3934       
5865 12 Mar 20 nicklas 3935       barcodeSequences.put("UDI0001", "CCGCGGTT");
5865 12 Mar 20 nicklas 3936       barcodeSequences.put("UDI0002", "TTATAACC");
5865 12 Mar 20 nicklas 3937       barcodeSequences.put("UDI0003", "GGACTTGG");
5865 12 Mar 20 nicklas 3938       barcodeSequences.put("UDI0004", "AAGTCCAA");
5865 12 Mar 20 nicklas 3939       barcodeSequences.put("UDI0005", "ATCCACTG");
5865 12 Mar 20 nicklas 3940       barcodeSequences.put("UDI0006", "GCTTGTCA");
5865 12 Mar 20 nicklas 3941       barcodeSequences.put("UDI0007", "CAAGCTAG");
5865 12 Mar 20 nicklas 3942       barcodeSequences.put("UDI0008", "TGGATCGA");
5865 12 Mar 20 nicklas 3943       barcodeSequences.put("UDI0009", "AGTTCAGG");
5865 12 Mar 20 nicklas 3944       barcodeSequences.put("UDI0010", "GACCTGAA");
5865 12 Mar 20 nicklas 3945       barcodeSequences.put("UDI0011", "TCTCTACT");
5865 12 Mar 20 nicklas 3946       barcodeSequences.put("UDI0012", "CTCTCGTC");
5865 12 Mar 20 nicklas 3947       barcodeSequences.put("UDI0013", "CCAAGTCT");
5865 12 Mar 20 nicklas 3948       barcodeSequences.put("UDI0014", "TTGGACTC");
5865 12 Mar 20 nicklas 3949       barcodeSequences.put("UDI0015", "GGCTTAAG");
5865 12 Mar 20 nicklas 3950       barcodeSequences.put("UDI0016", "AATCCGGA");
5865 12 Mar 20 nicklas 3951       barcodeSequences.put("UDI0017", "TAATACAG");
5865 12 Mar 20 nicklas 3952       barcodeSequences.put("UDI0018", "CGGCGTGA");
5865 12 Mar 20 nicklas 3953       barcodeSequences.put("UDI0019", "ATGTAAGT");
5865 12 Mar 20 nicklas 3954       barcodeSequences.put("UDI0020", "GCACGGAC");
5865 12 Mar 20 nicklas 3955       barcodeSequences.put("UDI0021", "GGTACCTT");
5865 12 Mar 20 nicklas 3956       barcodeSequences.put("UDI0022", "AACGTTCC");
5865 12 Mar 20 nicklas 3957       barcodeSequences.put("UDI0023", "GCAGAATT");
5865 12 Mar 20 nicklas 3958       barcodeSequences.put("UDI0024", "ATGAGGCC");
5865 12 Mar 20 nicklas 3959       barcodeSequences.put("UDI0025", "ACTAAGAT");
5865 12 Mar 20 nicklas 3960       barcodeSequences.put("UDI0026", "GTCGGAGC");
5865 12 Mar 20 nicklas 3961       barcodeSequences.put("UDI0027", "CTTGGTAT");
5865 12 Mar 20 nicklas 3962       barcodeSequences.put("UDI0028", "TCCAACGC");
5865 12 Mar 20 nicklas 3963       barcodeSequences.put("UDI0029", "CCGTGAAG");
5865 12 Mar 20 nicklas 3964       barcodeSequences.put("UDI0030", "TTACAGGA");
5865 12 Mar 20 nicklas 3965       barcodeSequences.put("UDI0031", "GGCATTCT");
5865 12 Mar 20 nicklas 3966       barcodeSequences.put("UDI0032", "AATGCCTC");
5893 07 Apr 20 nicklas 3967       barcodeSequences.put("UDI0033", "TACCGAGG");
5893 07 Apr 20 nicklas 3968       barcodeSequences.put("UDI0034", "CGTTAGAA");
5893 07 Apr 20 nicklas 3969       barcodeSequences.put("UDI0035", "AGCCTCAT");
5893 07 Apr 20 nicklas 3970       barcodeSequences.put("UDI0036", "GATTCTGC");
5893 07 Apr 20 nicklas 3971       barcodeSequences.put("UDI0037", "TCGTAGTG");
5893 07 Apr 20 nicklas 3972       barcodeSequences.put("UDI0038", "CTACGACA");
5893 07 Apr 20 nicklas 3973       barcodeSequences.put("UDI0039", "TAAGTGGT");
5893 07 Apr 20 nicklas 3974       barcodeSequences.put("UDI0040", "CGGACAAC");
5893 07 Apr 20 nicklas 3975       barcodeSequences.put("UDI0041", "ATATGGAT");
5893 07 Apr 20 nicklas 3976       barcodeSequences.put("UDI0042", "GCGCAAGC");
5893 07 Apr 20 nicklas 3977       barcodeSequences.put("UDI0043", "AAGATACT");
5893 07 Apr 20 nicklas 3978       barcodeSequences.put("UDI0044", "GGAGCGTC");
5893 07 Apr 20 nicklas 3979       barcodeSequences.put("UDI0045", "ATGGCATG");
5893 07 Apr 20 nicklas 3980       barcodeSequences.put("UDI0046", "GCAATGCA");
5893 07 Apr 20 nicklas 3981       barcodeSequences.put("UDI0047", "GTTCCAAT");
5893 07 Apr 20 nicklas 3982       barcodeSequences.put("UDI0048", "ACCTTGGC");
5893 07 Apr 20 nicklas 3983       barcodeSequences.put("UDI0049", "ATATCTCG");
5893 07 Apr 20 nicklas 3984       barcodeSequences.put("UDI0050", "GCGCTCTA");
5893 07 Apr 20 nicklas 3985       barcodeSequences.put("UDI0051", "AACAGGTT");
5893 07 Apr 20 nicklas 3986       barcodeSequences.put("UDI0052", "GGTGAACC");
5893 07 Apr 20 nicklas 3987       barcodeSequences.put("UDI0053", "CAACAATG");
5893 07 Apr 20 nicklas 3988       barcodeSequences.put("UDI0054", "TGGTGGCA");
5893 07 Apr 20 nicklas 3989       barcodeSequences.put("UDI0055", "AGGCAGAG");
5893 07 Apr 20 nicklas 3990       barcodeSequences.put("UDI0056", "GAATGAGA");
5893 07 Apr 20 nicklas 3991       barcodeSequences.put("UDI0057", "TGCGGCGT");
5893 07 Apr 20 nicklas 3992       barcodeSequences.put("UDI0058", "CATAATAC");
5893 07 Apr 20 nicklas 3993       barcodeSequences.put("UDI0059", "GATCTATC");
5893 07 Apr 20 nicklas 3994       barcodeSequences.put("UDI0060", "AGCTCGCT");
5893 07 Apr 20 nicklas 3995       barcodeSequences.put("UDI0061", "CGGAACTG");
5893 07 Apr 20 nicklas 3996       barcodeSequences.put("UDI0062", "TAAGGTCA");
5893 07 Apr 20 nicklas 3997       barcodeSequences.put("UDI0063", "TTGCCTAG");
5893 07 Apr 20 nicklas 3998       barcodeSequences.put("UDI0064", "CCATTCGA");
5893 07 Apr 20 nicklas 3999       barcodeSequences.put("UDI0065", "ACACTAAG");
5893 07 Apr 20 nicklas 4000       barcodeSequences.put("UDI0066", "GTGTCGGA");
5893 07 Apr 20 nicklas 4001       barcodeSequences.put("UDI0067", "TTCCTGTT");
5893 07 Apr 20 nicklas 4002       barcodeSequences.put("UDI0068", "CCTTCACC");
5893 07 Apr 20 nicklas 4003       barcodeSequences.put("UDI0069", "GCCACAGG");
5893 07 Apr 20 nicklas 4004       barcodeSequences.put("UDI0070", "ATTGTGAA");
5893 07 Apr 20 nicklas 4005       barcodeSequences.put("UDI0071", "ACTCGTGT");
5893 07 Apr 20 nicklas 4006       barcodeSequences.put("UDI0072", "GTCTACAC");
5893 07 Apr 20 nicklas 4007       barcodeSequences.put("UDI0073", "CAATTAAC");
5893 07 Apr 20 nicklas 4008       barcodeSequences.put("UDI0074", "TGGCCGGT");
5893 07 Apr 20 nicklas 4009       barcodeSequences.put("UDI0075", "AGTACTCC");
5893 07 Apr 20 nicklas 4010       barcodeSequences.put("UDI0076", "GACGTCTT");
5893 07 Apr 20 nicklas 4011       barcodeSequences.put("UDI0077", "TGCGAGAC");
5893 07 Apr 20 nicklas 4012       barcodeSequences.put("UDI0078", "CATAGAGT");
5893 07 Apr 20 nicklas 4013       barcodeSequences.put("UDI0079", "ACAGGCGC");
5893 07 Apr 20 nicklas 4014       barcodeSequences.put("UDI0080", "GTGAATAT");
5893 07 Apr 20 nicklas 4015       barcodeSequences.put("UDI0081", "AACTGTAG");
5893 07 Apr 20 nicklas 4016       barcodeSequences.put("UDI0082", "GGTCACGA");
5893 07 Apr 20 nicklas 4017       barcodeSequences.put("UDI0083", "CTGCTTCC");
5893 07 Apr 20 nicklas 4018       barcodeSequences.put("UDI0084", "TCATCCTT");
5893 07 Apr 20 nicklas 4019       barcodeSequences.put("UDI0085", "AGGTTATA");
5893 07 Apr 20 nicklas 4020       barcodeSequences.put("UDI0086", "GAACCGCG");
5893 07 Apr 20 nicklas 4021       barcodeSequences.put("UDI0087", "CTCACCAA");
5893 07 Apr 20 nicklas 4022       barcodeSequences.put("UDI0088", "TCTGTTGG");
5893 07 Apr 20 nicklas 4023       barcodeSequences.put("UDI0089", "TATCGCAC");
5893 07 Apr 20 nicklas 4024       barcodeSequences.put("UDI0090", "CGCTATGT");
5893 07 Apr 20 nicklas 4025       barcodeSequences.put("UDI0091", "GTATGTTC");
5893 07 Apr 20 nicklas 4026       barcodeSequences.put("UDI0092", "ACGCACCT");
5893 07 Apr 20 nicklas 4027       barcodeSequences.put("UDI0093", "TACTCATA");
5893 07 Apr 20 nicklas 4028       barcodeSequences.put("UDI0094", "CGTCTGCG");
5893 07 Apr 20 nicklas 4029       barcodeSequences.put("UDI0095", "TCGATATC");
5893 07 Apr 20 nicklas 4030       barcodeSequences.put("UDI0096", "CTAGCGCT");
2350 10 Apr 14 nicklas 4031     }
2350 10 Apr 14 nicklas 4032     
2350 10 Apr 14 nicklas 4033     return barcodeSequences.get(barcode);
2350 10 Apr 14 nicklas 4034   }
5865 12 Mar 20 nicklas 4035   
5865 12 Mar 20 nicklas 4036   /**
5865 12 Mar 20 nicklas 4037     Maps barcode name to gene sequence for second barcode.
5865 12 Mar 20 nicklas 4038   */
5865 12 Mar 20 nicklas 4039   private String lookupSequence2(String barcode)
5865 12 Mar 20 nicklas 4040   {
5865 12 Mar 20 nicklas 4041     if (barcodeSequences2 == null)
5865 12 Mar 20 nicklas 4042     {
5865 12 Mar 20 nicklas 4043       barcodeSequences2 = new HashMap<String, String>();
5865 12 Mar 20 nicklas 4044       
5865 12 Mar 20 nicklas 4045       barcodeSequences2.put("UDI0001", "AGCGCTAG");
5865 12 Mar 20 nicklas 4046       barcodeSequences2.put("UDI0002", "GATATCGA");
5865 12 Mar 20 nicklas 4047       barcodeSequences2.put("UDI0003", "CGCAGACG");
5865 12 Mar 20 nicklas 4048       barcodeSequences2.put("UDI0004", "TATGAGTA");
5865 12 Mar 20 nicklas 4049       barcodeSequences2.put("UDI0005", "AGGTGCGT");
5865 12 Mar 20 nicklas 4050       barcodeSequences2.put("UDI0006", "GAACATAC");
5865 12 Mar 20 nicklas 4051       barcodeSequences2.put("UDI0007", "ACATAGCG");
5865 12 Mar 20 nicklas 4052       barcodeSequences2.put("UDI0008", "GTGCGATA");
5865 12 Mar 20 nicklas 4053       barcodeSequences2.put("UDI0009", "CCAACAGA");
5865 12 Mar 20 nicklas 4054       barcodeSequences2.put("UDI0010", "TTGGTGAG");
5865 12 Mar 20 nicklas 4055       barcodeSequences2.put("UDI0011", "CGCGGTTC");
5865 12 Mar 20 nicklas 4056       barcodeSequences2.put("UDI0012", "TATAACCT");
5865 12 Mar 20 nicklas 4057       barcodeSequences2.put("UDI0013", "AAGGATGA");
5865 12 Mar 20 nicklas 4058       barcodeSequences2.put("UDI0014", "GGAAGCAG");
5865 12 Mar 20 nicklas 4059       barcodeSequences2.put("UDI0015", "TCGTGACC");
5865 12 Mar 20 nicklas 4060       barcodeSequences2.put("UDI0016", "CTACAGTT");
5865 12 Mar 20 nicklas 4061       barcodeSequences2.put("UDI0017", "ATATTCAC");
5865 12 Mar 20 nicklas 4062       barcodeSequences2.put("UDI0018", "GCGCCTGT");
5865 12 Mar 20 nicklas 4063       barcodeSequences2.put("UDI0019", "ACTCTATG");
5865 12 Mar 20 nicklas 4064       barcodeSequences2.put("UDI0020", "GTCTCGCA");
5865 12 Mar 20 nicklas 4065       barcodeSequences2.put("UDI0021", "AAGACGTC");
5865 12 Mar 20 nicklas 4066       barcodeSequences2.put("UDI0022", "GGAGTACT");
5865 12 Mar 20 nicklas 4067       barcodeSequences2.put("UDI0023", "ACCGGCCA");
5865 12 Mar 20 nicklas 4068       barcodeSequences2.put("UDI0024", "GTTAATTG");
5865 12 Mar 20 nicklas 4069       barcodeSequences2.put("UDI0025", "AACCGCGG");
5865 12 Mar 20 nicklas 4070       barcodeSequences2.put("UDI0026", "GGTTATAA");
5865 12 Mar 20 nicklas 4071       barcodeSequences2.put("UDI0027", "CCAAGTCC");
5865 12 Mar 20 nicklas 4072       barcodeSequences2.put("UDI0028", "TTGGACTT");
5865 12 Mar 20 nicklas 4073       barcodeSequences2.put("UDI0029", "CAGTGGAT");
5865 12 Mar 20 nicklas 4074       barcodeSequences2.put("UDI0030", "TGACAAGC");
5865 12 Mar 20 nicklas 4075       barcodeSequences2.put("UDI0031", "CTAGCTTG");
5865 12 Mar 20 nicklas 4076       barcodeSequences2.put("UDI0032", "TCGATCCA");
5893 07 Apr 20 nicklas 4077       barcodeSequences2.put("UDI0033", "CCTGAACT");
5893 07 Apr 20 nicklas 4078       barcodeSequences2.put("UDI0034", "TTCAGGTC");
5893 07 Apr 20 nicklas 4079       barcodeSequences2.put("UDI0035", "AGTAGAGA");
5893 07 Apr 20 nicklas 4080       barcodeSequences2.put("UDI0036", "GACGAGAG");
5893 07 Apr 20 nicklas 4081       barcodeSequences2.put("UDI0037", "AGACTTGG");
5893 07 Apr 20 nicklas 4082       barcodeSequences2.put("UDI0038", "GAGTCCAA");
5893 07 Apr 20 nicklas 4083       barcodeSequences2.put("UDI0039", "CTTAAGCC");
5893 07 Apr 20 nicklas 4084       barcodeSequences2.put("UDI0040", "TCCGGATT");
5893 07 Apr 20 nicklas 4085       barcodeSequences2.put("UDI0041", "CTGTATTA");
5893 07 Apr 20 nicklas 4086       barcodeSequences2.put("UDI0042", "TCACGCCG");
5893 07 Apr 20 nicklas 4087       barcodeSequences2.put("UDI0043", "ACTTACAT");
5893 07 Apr 20 nicklas 4088       barcodeSequences2.put("UDI0044", "GTCCGTGC");
5893 07 Apr 20 nicklas 4089       barcodeSequences2.put("UDI0045", "AAGGTACC");
5893 07 Apr 20 nicklas 4090       barcodeSequences2.put("UDI0046", "GGAACGTT");
5893 07 Apr 20 nicklas 4091       barcodeSequences2.put("UDI0047", "AATTCTGC");
5893 07 Apr 20 nicklas 4092       barcodeSequences2.put("UDI0048", "GGCCTCAT");
5893 07 Apr 20 nicklas 4093       barcodeSequences2.put("UDI0049", "ATCTTAGT");
5893 07 Apr 20 nicklas 4094       barcodeSequences2.put("UDI0050", "GCTCCGAC");
5893 07 Apr 20 nicklas 4095       barcodeSequences2.put("UDI0051", "ATACCAAG");
5893 07 Apr 20 nicklas 4096       barcodeSequences2.put("UDI0052", "GCGTTGGA");
5893 07 Apr 20 nicklas 4097       barcodeSequences2.put("UDI0053", "CTTCACGG");
5893 07 Apr 20 nicklas 4098       barcodeSequences2.put("UDI0054", "TCCTGTAA");
5893 07 Apr 20 nicklas 4099       barcodeSequences2.put("UDI0055", "AGAATGCC");
5893 07 Apr 20 nicklas 4100       barcodeSequences2.put("UDI0056", "GAGGCATT");
5893 07 Apr 20 nicklas 4101       barcodeSequences2.put("UDI0057", "CCTCGGTA");
5893 07 Apr 20 nicklas 4102       barcodeSequences2.put("UDI0058", "TTCTAACG");
5893 07 Apr 20 nicklas 4103       barcodeSequences2.put("UDI0059", "ATGAGGCT");
5893 07 Apr 20 nicklas 4104       barcodeSequences2.put("UDI0060", "GCAGAATC");
5893 07 Apr 20 nicklas 4105       barcodeSequences2.put("UDI0061", "CACTACGA");
5893 07 Apr 20 nicklas 4106       barcodeSequences2.put("UDI0062", "TGTCGTAG");
5893 07 Apr 20 nicklas 4107       barcodeSequences2.put("UDI0063", "ACCACTTA");
5893 07 Apr 20 nicklas 4108       barcodeSequences2.put("UDI0064", "GTTGTCCG");
5893 07 Apr 20 nicklas 4109       barcodeSequences2.put("UDI0065", "ATCCATAT");
5893 07 Apr 20 nicklas 4110       barcodeSequences2.put("UDI0066", "GCTTGCGC");
5893 07 Apr 20 nicklas 4111       barcodeSequences2.put("UDI0067", "AGTATCTT");
5893 07 Apr 20 nicklas 4112       barcodeSequences2.put("UDI0068", "GACGCTCC");
5893 07 Apr 20 nicklas 4113       barcodeSequences2.put("UDI0069", "CATGCCAT");
5893 07 Apr 20 nicklas 4114       barcodeSequences2.put("UDI0070", "TGCATTGC");
5893 07 Apr 20 nicklas 4115       barcodeSequences2.put("UDI0071", "ATTGGAAC");
5893 07 Apr 20 nicklas 4116       barcodeSequences2.put("UDI0072", "GCCAAGGT");
5893 07 Apr 20 nicklas 4117       barcodeSequences2.put("UDI0073", "CGAGATAT");
5893 07 Apr 20 nicklas 4118       barcodeSequences2.put("UDI0074", "TAGAGCGC");
5893 07 Apr 20 nicklas 4119       barcodeSequences2.put("UDI0075", "AACCTGTT");
5893 07 Apr 20 nicklas 4120       barcodeSequences2.put("UDI0076", "GGTTCACC");
5893 07 Apr 20 nicklas 4121       barcodeSequences2.put("UDI0077", "CATTGTTG");
5893 07 Apr 20 nicklas 4122       barcodeSequences2.put("UDI0078", "TGCCACCA");
5893 07 Apr 20 nicklas 4123       barcodeSequences2.put("UDI0079", "CTCTGCCT");
5893 07 Apr 20 nicklas 4124       barcodeSequences2.put("UDI0080", "TCTCATTC");
5893 07 Apr 20 nicklas 4125       barcodeSequences2.put("UDI0081", "ACGCCGCA");
5893 07 Apr 20 nicklas 4126       barcodeSequences2.put("UDI0082", "GTATTATG");
5893 07 Apr 20 nicklas 4127       barcodeSequences2.put("UDI0083", "GATAGATC");
5893 07 Apr 20 nicklas 4128       barcodeSequences2.put("UDI0084", "AGCGAGCT");
5893 07 Apr 20 nicklas 4129       barcodeSequences2.put("UDI0085", "CAGTTCCG");
5893 07 Apr 20 nicklas 4130       barcodeSequences2.put("UDI0086", "TGACCTTA");
5893 07 Apr 20 nicklas 4131       barcodeSequences2.put("UDI0087", "CTAGGCAA");
5893 07 Apr 20 nicklas 4132       barcodeSequences2.put("UDI0088", "TCGAATGG");
5893 07 Apr 20 nicklas 4133       barcodeSequences2.put("UDI0089", "CTTAGTGT");
5893 07 Apr 20 nicklas 4134       barcodeSequences2.put("UDI0090", "TCCGACAC");
5893 07 Apr 20 nicklas 4135       barcodeSequences2.put("UDI0091", "AACAGGAA");
5893 07 Apr 20 nicklas 4136       barcodeSequences2.put("UDI0092", "GGTGAAGG");
5893 07 Apr 20 nicklas 4137       barcodeSequences2.put("UDI0093", "CCTGTGGC");
5893 07 Apr 20 nicklas 4138       barcodeSequences2.put("UDI0094", "TTCACAAT");
5893 07 Apr 20 nicklas 4139       barcodeSequences2.put("UDI0095", "ACACGAGT");
5893 07 Apr 20 nicklas 4140       barcodeSequences2.put("UDI0096", "GTGTAGAC");
5865 12 Mar 20 nicklas 4141     }
5865 12 Mar 20 nicklas 4142     
5865 12 Mar 20 nicklas 4143     return barcodeSequences2.get(barcode);
5865 12 Mar 20 nicklas 4144   }
2350 10 Apr 14 nicklas 4145
1570 16 Mar 12 nicklas 4146   
1546 02 Mar 12 nicklas 4147   /**
1639 09 May 12 nicklas 4148     Store options for enumerated annotation types and min/max values for numerical annotations.
1284 08 Feb 11 nicklas 4149   */
1639 09 May 12 nicklas 4150   static class ValueOptions
1284 08 Feb 11 nicklas 4151   {
1284 08 Feb 11 nicklas 4152     private final Object[] options;
1639 09 May 12 nicklas 4153     private final Integer min;
1639 09 May 12 nicklas 4154     private final Integer max;
1639 09 May 12 nicklas 4155     
1639 09 May 12 nicklas 4156     /**
1639 09 May 12 nicklas 4157       The annotation type is an enumerated annotation type with the following options.
1639 09 May 12 nicklas 4158     */
1639 09 May 12 nicklas 4159     ValueOptions(Object... options)
1284 08 Feb 11 nicklas 4160     {
1284 08 Feb 11 nicklas 4161       this.options = options;
1639 09 May 12 nicklas 4162       this.min = null;
1639 09 May 12 nicklas 4163       this.max = null;
1284 08 Feb 11 nicklas 4164     }
1284 08 Feb 11 nicklas 4165     
1284 08 Feb 11 nicklas 4166     /**
1639 09 May 12 nicklas 4167       The annotation type is a numeric annotation type with the following restrictions.
1639 09 May 12 nicklas 4168     */
1639 09 May 12 nicklas 4169     ValueOptions(Integer min, Integer max)
1639 09 May 12 nicklas 4170     {
1639 09 May 12 nicklas 4171       this.min = min;
1639 09 May 12 nicklas 4172       this.max = max;
1639 09 May 12 nicklas 4173       this.options = null;
1639 09 May 12 nicklas 4174     }
1639 09 May 12 nicklas 4175     
1639 09 May 12 nicklas 4176     boolean isEnumeration()
1639 09 May 12 nicklas 4177     {
1639 09 May 12 nicklas 4178       return options != null;
1639 09 May 12 nicklas 4179     }
1639 09 May 12 nicklas 4180     
1639 09 May 12 nicklas 4181     Integer getMin()
1639 09 May 12 nicklas 4182     {
1639 09 May 12 nicklas 4183       return min;
1639 09 May 12 nicklas 4184     }
1639 09 May 12 nicklas 4185     
1639 09 May 12 nicklas 4186     Integer getMax()
1639 09 May 12 nicklas 4187     {
1639 09 May 12 nicklas 4188       return max;
1639 09 May 12 nicklas 4189     }
1639 09 May 12 nicklas 4190     
1639 09 May 12 nicklas 4191     /**
1284 08 Feb 11 nicklas 4192       Get the options as a List.
1284 08 Feb 11 nicklas 4193     */
1284 08 Feb 11 nicklas 4194     List<?> getList()
1284 08 Feb 11 nicklas 4195     {
1284 08 Feb 11 nicklas 4196       return Arrays.asList(options);
1284 08 Feb 11 nicklas 4197     }
1284 08 Feb 11 nicklas 4198     
1284 08 Feb 11 nicklas 4199     /**
1284 08 Feb 11 nicklas 4200       Get the options as an array.
1284 08 Feb 11 nicklas 4201     */
1284 08 Feb 11 nicklas 4202     Object[] getArray()
1284 08 Feb 11 nicklas 4203     {
1284 08 Feb 11 nicklas 4204       return options;
1284 08 Feb 11 nicklas 4205     }
1889 27 Feb 13 nicklas 4206     
1889 27 Feb 13 nicklas 4207     /**
1889 27 Feb 13 nicklas 4208       Add options missing in the current annotation type.
1889 27 Feb 13 nicklas 4209     */
1889 27 Feb 13 nicklas 4210     void applyEnumeration(AnnotationType at)
1889 27 Feb 13 nicklas 4211     {
1889 27 Feb 13 nicklas 4212       List<Object> values = new ArrayList<Object>(at.getValues());
1889 27 Feb 13 nicklas 4213       for (Object opt : options)
1889 27 Feb 13 nicklas 4214       {
1889 27 Feb 13 nicklas 4215         if (!values.contains(opt)) values.add(opt);
1889 27 Feb 13 nicklas 4216       }
1889 27 Feb 13 nicklas 4217       at.setValues(values);
1889 27 Feb 13 nicklas 4218     }
5894 08 Apr 20 nicklas 4219     
5894 08 Apr 20 nicklas 4220     /**
5894 08 Apr 20 nicklas 4221       Get all required options that are missing in the current
5894 08 Apr 20 nicklas 4222       annotation type.
5894 08 Apr 20 nicklas 4223       @since 4.26
5894 08 Apr 20 nicklas 4224     */
5894 08 Apr 20 nicklas 4225     List<Object> getMissingOptions(AnnotationType at)
5894 08 Apr 20 nicklas 4226     {
5894 08 Apr 20 nicklas 4227       List<Object> missing = new ArrayList<Object>();
5894 08 Apr 20 nicklas 4228       List<Object> values = at.getValues();
5894 08 Apr 20 nicklas 4229       for (Object opt : options)
5894 08 Apr 20 nicklas 4230       {
5894 08 Apr 20 nicklas 4231         if (!values.contains(opt)) missing.add(opt);
5894 08 Apr 20 nicklas 4232       }
5894 08 Apr 20 nicklas 4233       return missing;
5894 08 Apr 20 nicklas 4234     }
5894 08 Apr 20 nicklas 4235     
5894 08 Apr 20 nicklas 4236     
5894 08 Apr 20 nicklas 4237     /**
5894 08 Apr 20 nicklas 4238       Get all extract options that are defined by the current annotation
5894 08 Apr 20 nicklas 4239       type.
5894 08 Apr 20 nicklas 4240       @since 4.26
5894 08 Apr 20 nicklas 4241     */
5894 08 Apr 20 nicklas 4242     List<Object> getExtraOptions(AnnotationType at)
5894 08 Apr 20 nicklas 4243     {
5894 08 Apr 20 nicklas 4244       List<Object> extra = new ArrayList<Object>();
5894 08 Apr 20 nicklas 4245       List<?> all = getList();
5894 08 Apr 20 nicklas 4246       for (Object v : at.getValues())
5894 08 Apr 20 nicklas 4247       {
5894 08 Apr 20 nicklas 4248         if (!all.contains(v)) extra.add(v);
5894 08 Apr 20 nicklas 4249       }
5894 08 Apr 20 nicklas 4250       return extra;
5894 08 Apr 20 nicklas 4251     }
5894 08 Apr 20 nicklas 4252
1284 08 Feb 11 nicklas 4253   }
1284 08 Feb 11 nicklas 4254   
1284 08 Feb 11 nicklas 4255   /**
1284 08 Feb 11 nicklas 4256     Store permissions that can be applied to shareable items.
1284 08 Feb 11 nicklas 4257   */
1284 08 Feb 11 nicklas 4258   static class PermissionOptions
1284 08 Feb 11 nicklas 4259   {
1284 08 Feb 11 nicklas 4260     private Map<Group, Permission> groupPermissions;
1310 04 Mar 11 nicklas 4261     private Map<Project, Permission> projectPermissions;
1284 08 Feb 11 nicklas 4262     private String message;
1284 08 Feb 11 nicklas 4263     
1284 08 Feb 11 nicklas 4264     PermissionOptions()
1284 08 Feb 11 nicklas 4265     {
1284 08 Feb 11 nicklas 4266       groupPermissions = new HashMap<Group, Permission>();
1310 04 Mar 11 nicklas 4267       projectPermissions = new HashMap<Project, Permission>();
1284 08 Feb 11 nicklas 4268     }
1284 08 Feb 11 nicklas 4269
1284 08 Feb 11 nicklas 4270     /**
6277 03 Jun 21 nicklas 4271       Merge the permission options in this instance with
6277 03 Jun 21 nicklas 4272       another instance. The merge creates a new instance
6277 03 Jun 21 nicklas 4273       and doesn't affect either this nor the other instance.
6277 03 Jun 21 nicklas 4274     */
6277 03 Jun 21 nicklas 4275     PermissionOptions merge(PermissionOptions other)
6277 03 Jun 21 nicklas 4276     {
6277 03 Jun 21 nicklas 4277       PermissionOptions merged = new PermissionOptions();
6277 03 Jun 21 nicklas 4278       merged.groupPermissions.putAll(this.groupPermissions);
6277 03 Jun 21 nicklas 4279       merged.projectPermissions.putAll(projectPermissions);
6277 03 Jun 21 nicklas 4280       
6277 03 Jun 21 nicklas 4281       for (Map.Entry<Project, Permission> entry : other.projectPermissions.entrySet())
6277 03 Jun 21 nicklas 4282       {
6277 03 Jun 21 nicklas 4283         Project p = entry.getKey();
6277 03 Jun 21 nicklas 4284         Permission perm = entry.getValue();
6277 03 Jun 21 nicklas 4285         boolean doMerge = true;
6277 03 Jun 21 nicklas 4286         if (merged.projectPermissions.containsKey(p))
6277 03 Jun 21 nicklas 4287         {
6277 03 Jun 21 nicklas 4288           // Should we replace?
6277 03 Jun 21 nicklas 4289           Permission p1 = merged.projectPermissions.get(p);
6277 03 Jun 21 nicklas 4290           if (p1 != null)
6277 03 Jun 21 nicklas 4291           {
6277 03 Jun 21 nicklas 4292             if (perm == null || perm.ordinal() < p1.ordinal()) doMerge = false;
6277 03 Jun 21 nicklas 4293           }
6277 03 Jun 21 nicklas 4294         }
6277 03 Jun 21 nicklas 4295         if (doMerge) merged.projectPermissions.put(p, perm);
6277 03 Jun 21 nicklas 4296       }
6277 03 Jun 21 nicklas 4297       
6277 03 Jun 21 nicklas 4298       for (Map.Entry<Group, Permission> entry : other.groupPermissions.entrySet())
6277 03 Jun 21 nicklas 4299       {
6277 03 Jun 21 nicklas 4300         Group g = entry.getKey();
6277 03 Jun 21 nicklas 4301         Permission perm = entry.getValue();
6277 03 Jun 21 nicklas 4302         boolean doMerge = true;
6277 03 Jun 21 nicklas 4303         if (merged.groupPermissions.containsKey(g))
6277 03 Jun 21 nicklas 4304         {
6277 03 Jun 21 nicklas 4305           // Should we replace?
6277 03 Jun 21 nicklas 4306           Permission p1 = merged.groupPermissions.get(g);
6277 03 Jun 21 nicklas 4307           if (p1 != null)
6277 03 Jun 21 nicklas 4308           {
6277 03 Jun 21 nicklas 4309             if (perm == null || perm.ordinal() < p1.ordinal()) doMerge = false;
6277 03 Jun 21 nicklas 4310           }
6277 03 Jun 21 nicklas 4311         }
6277 03 Jun 21 nicklas 4312         if (doMerge) merged.groupPermissions.put(g, perm);
6277 03 Jun 21 nicklas 4313       }
6277 03 Jun 21 nicklas 4314       
6277 03 Jun 21 nicklas 4315       return merged;
6277 03 Jun 21 nicklas 4316     }
6277 03 Jun 21 nicklas 4317     
6277 03 Jun 21 nicklas 4318     /**
1284 08 Feb 11 nicklas 4319       Set a permission for the given group.
1284 08 Feb 11 nicklas 4320     */
1284 08 Feb 11 nicklas 4321     void set(Group g, Permission p)
1284 08 Feb 11 nicklas 4322     {
1284 08 Feb 11 nicklas 4323       groupPermissions.put(g, p);
1284 08 Feb 11 nicklas 4324     }
1284 08 Feb 11 nicklas 4325
1284 08 Feb 11 nicklas 4326     /**
1310 04 Mar 11 nicklas 4327       Set a permission for the given project.
1310 04 Mar 11 nicklas 4328     */
1310 04 Mar 11 nicklas 4329     void set(Project pr, Permission p)
1310 04 Mar 11 nicklas 4330     {
1310 04 Mar 11 nicklas 4331       projectPermissions.put(pr, p);
1310 04 Mar 11 nicklas 4332     }
1310 04 Mar 11 nicklas 4333
1310 04 Mar 11 nicklas 4334     /**
1284 08 Feb 11 nicklas 4335       Check if the given item includes at least all the required permissions.
1284 08 Feb 11 nicklas 4336       @return TRUE if all permissions are ok, FALSE if not (call getMessage())
1284 08 Feb 11 nicklas 4337       to get more information.
1284 08 Feb 11 nicklas 4338     */
1284 08 Feb 11 nicklas 4339     boolean checkPermissions(SharedItem item)
1284 08 Feb 11 nicklas 4340     {
1310 04 Mar 11 nicklas 4341       ProjectKey pKey = item.getProjectKey();
1310 04 Mar 11 nicklas 4342       for (Map.Entry<Project, Permission> entry : projectPermissions.entrySet())
1310 04 Mar 11 nicklas 4343       {
1310 04 Mar 11 nicklas 4344         Project pr = entry.getKey();
1310 04 Mar 11 nicklas 4345         Permission p = entry.getValue();
2159 06 Dec 13 nicklas 4346         
2159 06 Dec 13 nicklas 4347         Set<Permission> permissions = pKey != null ? pKey.getPermissions(pr) : null;
2159 06 Dec 13 nicklas 4348         if (p == null)
1310 04 Mar 11 nicklas 4349         {
2159 06 Dec 13 nicklas 4350           // The item should not be shared to project 'pr'
2159 06 Dec 13 nicklas 4351           if (permissions != null && permissions.size() > 0)
2159 06 Dec 13 nicklas 4352           {
2159 06 Dec 13 nicklas 4353             message = "Should not be shared to project: " + pr.getName() + " (" + permissions + ")";
2159 06 Dec 13 nicklas 4354             return false;
2159 06 Dec 13 nicklas 4355           }
1310 04 Mar 11 nicklas 4356         }
2159 06 Dec 13 nicklas 4357         else
2159 06 Dec 13 nicklas 4358         {
2159 06 Dec 13 nicklas 4359           // The item should be shared to project 'pr' with permission 'p'
2159 06 Dec 13 nicklas 4360           if (pKey == null || !permissions.contains(p))
2159 06 Dec 13 nicklas 4361           {
2159 06 Dec 13 nicklas 4362             message = "Not shared to project: " + pr.getName() + " (" + p + ")";
2159 06 Dec 13 nicklas 4363             return false;
2159 06 Dec 13 nicklas 4364           }
2159 06 Dec 13 nicklas 4365         }
1310 04 Mar 11 nicklas 4366       }
1284 08 Feb 11 nicklas 4367       ItemKey key = item.getItemKey();
1284 08 Feb 11 nicklas 4368       for (Map.Entry<Group, Permission> entry : groupPermissions.entrySet())
1284 08 Feb 11 nicklas 4369       {
1284 08 Feb 11 nicklas 4370         Group g = entry.getKey();
1284 08 Feb 11 nicklas 4371         Permission p = entry.getValue();
2159 06 Dec 13 nicklas 4372         
2238 20 Feb 14 nicklas 4373         Set<Permission> permissions = key != null ? key.getPermissions(g) : null;
2159 06 Dec 13 nicklas 4374         if (p == null)
1284 08 Feb 11 nicklas 4375         {
2159 06 Dec 13 nicklas 4376           // The item should not be shared to group 'g'
2159 06 Dec 13 nicklas 4377           if (permissions != null && permissions.size() > 0)
2159 06 Dec 13 nicklas 4378           {
2159 06 Dec 13 nicklas 4379             message = "Should not be shared to group: " + g.getName() + " (" + permissions + ")";
2159 06 Dec 13 nicklas 4380             return false;
2159 06 Dec 13 nicklas 4381           }
1284 08 Feb 11 nicklas 4382         }
2159 06 Dec 13 nicklas 4383         else
2159 06 Dec 13 nicklas 4384         {
2159 06 Dec 13 nicklas 4385           // The item should be shared to group 'g' with permission 'p'
2159 06 Dec 13 nicklas 4386           if (key == null || !key.getPermissions(g).contains(p))
2159 06 Dec 13 nicklas 4387           {
2159 06 Dec 13 nicklas 4388             message = "Not shared to group: " + g.getName() + " (" + p + ")";
2159 06 Dec 13 nicklas 4389             return false;
2159 06 Dec 13 nicklas 4390           }
2159 06 Dec 13 nicklas 4391         }
2159 06 Dec 13 nicklas 4392
1284 08 Feb 11 nicklas 4393       }
1284 08 Feb 11 nicklas 4394       return true;
1284 08 Feb 11 nicklas 4395     }
1284 08 Feb 11 nicklas 4396     
1284 08 Feb 11 nicklas 4397     /**
1284 08 Feb 11 nicklas 4398       More information about missing permission from the checkPermissions() method.
1284 08 Feb 11 nicklas 4399     */
1284 08 Feb 11 nicklas 4400     String getMessage()
1284 08 Feb 11 nicklas 4401     {
1284 08 Feb 11 nicklas 4402       return message;
1284 08 Feb 11 nicklas 4403     }
1284 08 Feb 11 nicklas 4404   
1284 08 Feb 11 nicklas 4405     /**
1284 08 Feb 11 nicklas 4406       Apply all permissions to the given item.
1284 08 Feb 11 nicklas 4407     */
1284 08 Feb 11 nicklas 4408     void applyPermissions(SharedItem item)
1284 08 Feb 11 nicklas 4409     {
6864 04 Nov 22 nicklas 4410       if (!item.isInDatabase())
6864 04 Nov 22 nicklas 4411       {
6864 04 Nov 22 nicklas 4412         // Reset is needed for new items since otherwise BASE may set default values
6864 04 Nov 22 nicklas 4413         item.setProjectKey(null);
6864 04 Nov 22 nicklas 4414         item.setItemKey(null);
6864 04 Nov 22 nicklas 4415       }
1284 08 Feb 11 nicklas 4416       MultiPermissions mp = new MultiPermissions(Collections.singleton(item));
1284 08 Feb 11 nicklas 4417       for (Map.Entry<Group, Permission> entry : groupPermissions.entrySet())
1284 08 Feb 11 nicklas 4418       {
1284 08 Feb 11 nicklas 4419         Group g = entry.getKey();
1284 08 Feb 11 nicklas 4420         Permission p = entry.getValue();
2159 06 Dec 13 nicklas 4421         if (p == null)
2159 06 Dec 13 nicklas 4422         {
2159 06 Dec 13 nicklas 4423           mp.setPermissions(g, null);
2159 06 Dec 13 nicklas 4424         }
2159 06 Dec 13 nicklas 4425         else
2159 06 Dec 13 nicklas 4426         {
2159 06 Dec 13 nicklas 4427           mp.addPermissions(g, Collections.singleton(p));
2159 06 Dec 13 nicklas 4428         }
1284 08 Feb 11 nicklas 4429       }
1310 04 Mar 11 nicklas 4430       for (Map.Entry<Project, Permission> entry : projectPermissions.entrySet())
1310 04 Mar 11 nicklas 4431       {
1310 04 Mar 11 nicklas 4432         Project pr = entry.getKey();
1310 04 Mar 11 nicklas 4433         Permission p = entry.getValue();
2159 06 Dec 13 nicklas 4434         if (p == null)
2159 06 Dec 13 nicklas 4435         {
2159 06 Dec 13 nicklas 4436           mp.setPermissions(pr, null);
2159 06 Dec 13 nicklas 4437         }
2159 06 Dec 13 nicklas 4438         else
2159 06 Dec 13 nicklas 4439         {
2159 06 Dec 13 nicklas 4440           mp.addPermissions(pr, Collections.singleton(p));
2159 06 Dec 13 nicklas 4441         }
1310 04 Mar 11 nicklas 4442       }
1284 08 Feb 11 nicklas 4443       mp.updateKeys(item.getDbControl());
1284 08 Feb 11 nicklas 4444     }
1284 08 Feb 11 nicklas 4445   }
1284 08 Feb 11 nicklas 4446 }