-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTargetedMSController.java
More file actions
8240 lines (7092 loc) · 317 KB
/
TargetedMSController.java
File metadata and controls
8240 lines (7092 loc) · 317 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2012-2019 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.labkey.targetedms;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.keypoint.PngEncoder;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import lombok.Getter;
import lombok.Setter;
import org.apache.batik.dom.GenericDOMImplementation;
import org.apache.batik.svggen.SVGGeneratorContext;
import org.apache.batik.svggen.SVGGraphics2D;
import org.apache.batik.svggen.SVGGraphics2DIOException;
import org.apache.batik.svggen.SVGIDGenerator;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.CombinedDomainXYPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.xy.XYDataset;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.labkey.api.action.ApiJsonForm;
import org.labkey.api.action.ApiJsonWriter;
import org.labkey.api.action.ApiResponse;
import org.labkey.api.action.ApiSimpleResponse;
import org.labkey.api.action.ApiUsageException;
import org.labkey.api.action.ExportAction;
import org.labkey.api.action.FormHandlerAction;
import org.labkey.api.action.FormViewAction;
import org.labkey.api.action.HasViewContext;
import org.labkey.api.action.LabKeyError;
import org.labkey.api.action.Marshal;
import org.labkey.api.action.Marshaller;
import org.labkey.api.action.MutatingApiAction;
import org.labkey.api.action.QueryViewAction;
import org.labkey.api.action.ReadOnlyApiAction;
import org.labkey.api.action.ReturnUrlForm;
import org.labkey.api.action.SimpleErrorView;
import org.labkey.api.action.SimpleViewAction;
import org.labkey.api.action.SpringActionController;
import org.labkey.api.admin.AdminUrls;
import org.labkey.api.analytics.AnalyticsService;
import org.labkey.api.attachments.DocumentConversionService;
import org.labkey.api.attachments.SvgSource;
import org.labkey.api.audit.AuditLogService;
import org.labkey.api.audit.provider.SiteSettingsAuditProvider;
import org.labkey.api.collections.LongArrayList;
import org.labkey.api.collections.LongHashMap;
import org.labkey.api.data.CompareType;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerFilter;
import org.labkey.api.data.ContainerManager;
import org.labkey.api.data.DataRegion;
import org.labkey.api.data.DbScope;
import org.labkey.api.data.PropertyManager;
import org.labkey.api.data.PropertyManager.PropertyMap;
import org.labkey.api.data.PropertyManager.WritablePropertyMap;
import org.labkey.api.data.RenderContext;
import org.labkey.api.data.SQLFragment;
import org.labkey.api.data.SimpleFilter;
import org.labkey.api.data.Sort;
import org.labkey.api.data.SqlSelector;
import org.labkey.api.data.Table;
import org.labkey.api.data.TableCustomizer;
import org.labkey.api.data.TableInfo;
import org.labkey.api.data.TableSelector;
import org.labkey.api.exp.api.ExpData;
import org.labkey.api.exp.api.ExpMaterial;
import org.labkey.api.exp.api.ExpRun;
import org.labkey.api.exp.api.ExperimentService;
import org.labkey.api.files.FileContentService;
import org.labkey.api.files.view.FilesWebPart;
import org.labkey.api.module.DefaultFolderType;
import org.labkey.api.module.Module;
import org.labkey.api.module.ModuleHtmlView;
import org.labkey.api.module.ModuleLoader;
import org.labkey.api.module.ModuleProperty;
import org.labkey.api.pipeline.LocalDirectory;
import org.labkey.api.pipeline.PipeRoot;
import org.labkey.api.pipeline.PipelineJob;
import org.labkey.api.pipeline.PipelineService;
import org.labkey.api.pipeline.PipelineUrls;
import org.labkey.api.pipeline.PipelineValidationException;
import org.labkey.api.pipeline.browse.PipelinePathForm;
import org.labkey.api.portal.ProjectUrls;
import org.labkey.api.protein.PeptideCharacteristic;
import org.labkey.api.protein.ProteinService;
import org.labkey.api.query.BatchValidationException;
import org.labkey.api.query.DetailsURL;
import org.labkey.api.query.DuplicateKeyException;
import org.labkey.api.query.FieldKey;
import org.labkey.api.query.FilteredTable;
import org.labkey.api.query.InvalidKeyException;
import org.labkey.api.query.QueryParam;
import org.labkey.api.query.QueryService;
import org.labkey.api.query.QuerySettings;
import org.labkey.api.query.QueryUpdateServiceException;
import org.labkey.api.query.QueryView;
import org.labkey.api.query.UserSchema;
import org.labkey.api.query.ValidationException;
import org.labkey.api.reports.ReportService;
import org.labkey.api.reports.model.ViewCategory;
import org.labkey.api.reports.model.ViewCategoryManager;
import org.labkey.api.reports.report.RedirectReport;
import org.labkey.api.reports.report.ReportDescriptor;
import org.labkey.api.security.ActionNames;
import org.labkey.api.security.AuthenticationManager;
import org.labkey.api.security.Group;
import org.labkey.api.security.LoginUrls;
import org.labkey.api.security.RequiresLogin;
import org.labkey.api.security.RequiresPermission;
import org.labkey.api.security.SecurityManager;
import org.labkey.api.security.User;
import org.labkey.api.security.permissions.AdminPermission;
import org.labkey.api.security.permissions.ApplicationAdminPermission;
import org.labkey.api.security.permissions.InsertPermission;
import org.labkey.api.security.permissions.ReadPermission;
import org.labkey.api.security.permissions.UpdatePermission;
import org.labkey.api.settings.AppProps;
import org.labkey.api.targetedms.RepresentativeDataState;
import org.labkey.api.targetedms.RunRepresentativeDataState;
import org.labkey.api.targetedms.TargetedMSService;
import org.labkey.api.targetedms.TargetedMSUrls;
import org.labkey.api.targetedms.model.QCMetricConfiguration;
import org.labkey.api.targetedms.model.SampleFileInfo;
import org.labkey.api.util.ButtonBuilder;
import org.labkey.api.util.ConfigurationException;
import org.labkey.api.util.ContainerContext;
import org.labkey.api.util.DOM;
import org.labkey.api.util.DOM.Renderable;
import org.labkey.api.util.DateUtil;
import org.labkey.api.util.FileUtil;
import org.labkey.api.util.HelpTopic;
import org.labkey.api.util.HtmlString;
import org.labkey.api.util.JsonUtil;
import org.labkey.api.util.LinkBuilder;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.util.Pair;
import org.labkey.api.util.StringUtilsLabKey;
import org.labkey.api.util.URLHelper;
import org.labkey.api.util.UnexpectedException;
import org.labkey.api.util.logging.LogHelper;
import org.labkey.api.view.ActionURL;
import org.labkey.api.view.GridView;
import org.labkey.api.view.HtmlView;
import org.labkey.api.view.HttpView;
import org.labkey.api.view.JspView;
import org.labkey.api.view.NavTree;
import org.labkey.api.view.NotFoundException;
import org.labkey.api.view.PopupMenu;
import org.labkey.api.view.Portal;
import org.labkey.api.view.RedirectException;
import org.labkey.api.view.UnauthorizedException;
import org.labkey.api.view.VBox;
import org.labkey.api.view.ViewBackgroundInfo;
import org.labkey.api.view.ViewContext;
import org.labkey.api.view.WebPartView;
import org.labkey.api.view.template.ClientDependency;
import org.labkey.api.view.template.PageConfig;
import org.labkey.api.writer.HtmlWriter;
import org.labkey.targetedms.chart.ChromatogramChartMakerFactory;
import org.labkey.targetedms.chart.ComparisonChartMaker;
import org.labkey.targetedms.chromlib.ChromatogramLibraryUtils;
import org.labkey.targetedms.clustergrammer.ClustergrammerClient;
import org.labkey.targetedms.clustergrammer.ClustergrammerHeatMap;
import org.labkey.targetedms.conflict.ConflictPeptide;
import org.labkey.targetedms.conflict.ConflictPrecursor;
import org.labkey.targetedms.conflict.ConflictProtein;
import org.labkey.targetedms.conflict.ConflictTransition;
import org.labkey.targetedms.folderImport.QCFolderConstants;
import org.labkey.targetedms.model.AutoQCPingData;
import org.labkey.targetedms.model.GuideSet;
import org.labkey.targetedms.model.GuideSetKey;
import org.labkey.targetedms.model.GuideSetStats;
import org.labkey.targetedms.model.InstrumentNickname;
import org.labkey.targetedms.model.PeptideOutliers;
import org.labkey.targetedms.model.PrecursorChromInfoLitePlus;
import org.labkey.targetedms.model.QCPlotFragment;
import org.labkey.targetedms.model.RawMetricDataSet;
import org.labkey.targetedms.model.passport.IKeyword;
import org.labkey.targetedms.outliers.OutlierGenerator;
import org.labkey.targetedms.parser.CalibrationCurveEntity;
import org.labkey.targetedms.parser.Chromatogram;
import org.labkey.targetedms.parser.GeneralMolecule;
import org.labkey.targetedms.parser.GeneralMoleculeChromInfo;
import org.labkey.targetedms.parser.Molecule;
import org.labkey.targetedms.parser.MoleculePrecursor;
import org.labkey.targetedms.parser.Peptide;
import org.labkey.targetedms.parser.PeptideGroup;
import org.labkey.targetedms.parser.PeptideSettings;
import org.labkey.targetedms.parser.Precursor;
import org.labkey.targetedms.parser.PrecursorChromInfo;
import org.labkey.targetedms.parser.Protein;
import org.labkey.targetedms.parser.Replicate;
import org.labkey.targetedms.parser.ReplicateAnnotation;
import org.labkey.targetedms.parser.SampleFile;
import org.labkey.targetedms.parser.SampleFileChromInfo;
import org.labkey.targetedms.parser.SkylineBinaryParser;
import org.labkey.targetedms.parser.SkylineDocumentParser;
import org.labkey.targetedms.parser.TransitionChromInfo;
import org.labkey.targetedms.parser.list.ListDefinition;
import org.labkey.targetedms.parser.skyaudit.AuditLogEntry;
import org.labkey.targetedms.parser.speclib.SpeclibReaderException;
import org.labkey.targetedms.pipeline.ChromatogramCrawlerJob;
import org.labkey.targetedms.query.ChromatogramDisplayColumnFactory;
import org.labkey.targetedms.query.ConflictResultsManager;
import org.labkey.targetedms.query.GroupChromatogramsTableInfo;
import org.labkey.targetedms.query.IsotopeLabelManager;
import org.labkey.targetedms.query.LibraryManager;
import org.labkey.targetedms.query.ModificationManager;
import org.labkey.targetedms.query.ModifiedSequenceDisplayColumn;
import org.labkey.targetedms.query.MoleculeManager;
import org.labkey.targetedms.query.MoleculePrecursorManager;
import org.labkey.targetedms.query.PTMPercentsGroupedCustomizer;
import org.labkey.targetedms.query.PeptideChromatogramsTableInfo;
import org.labkey.targetedms.query.PeptideGroupManager;
import org.labkey.targetedms.query.PeptideManager;
import org.labkey.targetedms.query.PrecursorChromatogramsTableInfo;
import org.labkey.targetedms.query.PrecursorManager;
import org.labkey.targetedms.query.QCAnnotationTypeTable;
import org.labkey.targetedms.query.ReplicateManager;
import org.labkey.targetedms.query.SampleFileTable;
import org.labkey.targetedms.query.SkylineListManager;
import org.labkey.targetedms.query.SkylineListSchema;
import org.labkey.targetedms.query.TargetedMSTable;
import org.labkey.targetedms.query.TransitionManager;
import org.labkey.targetedms.search.ModificationSearchWebPart;
import org.labkey.targetedms.view.CalibrationCurveChart;
import org.labkey.targetedms.view.CalibrationCurveView;
import org.labkey.targetedms.view.CalibrationCurvesView;
import org.labkey.targetedms.view.ChromatogramGridView;
import org.labkey.targetedms.view.ChromatogramsDataRegion;
import org.labkey.targetedms.view.DocumentPrecursorsView;
import org.labkey.targetedms.view.DocumentTransitionsView;
import org.labkey.targetedms.view.DocumentView;
import org.labkey.targetedms.view.FiguresOfMeritView;
import org.labkey.targetedms.view.GroupComparisonView;
import org.labkey.targetedms.view.InstrumentSummaryWebPart;
import org.labkey.targetedms.view.LibraryQueryViewWebPart;
import org.labkey.targetedms.view.ModifiedPeptideHtmlMaker;
import org.labkey.targetedms.view.MoleculePrecursorChromatogramsView;
import org.labkey.targetedms.view.PeptidePrecursorChromatogramsView;
import org.labkey.targetedms.view.PeptidePrecursorsView;
import org.labkey.targetedms.view.PeptideTransitionsView;
import org.labkey.targetedms.view.ReplicateSummaryWebPart;
import org.labkey.targetedms.view.SmallMoleculePrecursorsView;
import org.labkey.targetedms.view.SmallMoleculeTransitionsView;
import org.labkey.targetedms.view.TargetedMsRunListView;
import org.labkey.targetedms.view.spectrum.LibrarySpectrumMatch;
import org.labkey.targetedms.view.spectrum.LibrarySpectrumMatchGetter;
import org.labkey.targetedms.view.spectrum.PeptideSpectrumView;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
import org.springframework.web.servlet.ModelAndView;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import static org.labkey.api.targetedms.TargetedMSService.FOLDER_TYPE_PROP_NAME;
import static org.labkey.api.targetedms.TargetedMSService.FolderType;
import static org.labkey.api.targetedms.TargetedMSService.MODULE_NAME;
import static org.labkey.api.targetedms.TargetedMSService.RAW_FILES_DIR;
import static org.labkey.api.targetedms.TargetedMSService.RAW_FILES_TAB;
import static org.labkey.api.util.DOM.A;
import static org.labkey.api.util.DOM.Attribute.height;
import static org.labkey.api.util.DOM.Attribute.href;
import static org.labkey.api.util.DOM.Attribute.id;
import static org.labkey.api.util.DOM.Attribute.method;
import static org.labkey.api.util.DOM.Attribute.src;
import static org.labkey.api.util.DOM.Attribute.style;
import static org.labkey.api.util.DOM.Attribute.width;
import static org.labkey.api.util.DOM.DIV;
import static org.labkey.api.util.DOM.SPAN;
import static org.labkey.api.util.DOM.TD;
import static org.labkey.api.util.DOM.TR;
import static org.labkey.api.util.DOM.UL;
import static org.labkey.api.util.DOM.at;
import static org.labkey.api.util.DOM.cl;
import static org.labkey.targetedms.TargetedMSModule.EXPERIMENT_FOLDER_WEB_PARTS;
import static org.labkey.targetedms.TargetedMSModule.LIBRARY_FOLDER_WEB_PARTS;
import static org.labkey.targetedms.TargetedMSModule.PEPTIDE_TAB_WEB_PARTS;
import static org.labkey.targetedms.TargetedMSModule.PROTEIN_TAB_NAME;
import static org.labkey.targetedms.TargetedMSModule.PROTEIN_TAB_WEB_PARTS;
import static org.labkey.targetedms.TargetedMSModule.QC_FOLDER_WEB_PARTS;
import static org.labkey.targetedms.TargetedMSSchema.QUERY_PTM_PERCENTS_GROUPED_PREFIX;
import static org.labkey.targetedms.TargetedMSSchema.QUERY_PTM_PERCENTS_PREFIX;
public class TargetedMSController extends SpringActionController
{
private static final Logger LOG = LogHelper.getLogger(TargetedMSController.class, "Panorama web user interface activity");
private static final DefaultActionResolver _actionResolver = new DefaultActionResolver(TargetedMSController.class);
public static final String CONFIGURE_TARGETED_MS_FOLDER = "Configure Panorama Folder";
public static final String SVG_ID_GENERATOR_ATTRIBUTE_NAME = SVGIDGenerator.class.getName();
public TargetedMSController()
{
setActionResolver(_actionResolver);
}
public static ActionURL getShowListURL(Container c)
{
return new ActionURL(ShowListAction.class, c);
}
public static ActionURL getShowRunURL(Container c)
{
return new ActionURL(ShowPrecursorListAction.class, c);
}
public static ActionURL getShowRunURL(Container c, long runId)
{
ActionURL url = getShowRunURL(c);
url.addParameter("id", runId);
return url;
}
public static ActionURL getShowCalibrationCurvesURL(Container c, long runId)
{
ActionURL url = new ActionURL(ShowCalibrationCurvesAction.class, c);
url.addParameter("id", runId);
return url;
}
// ------------------------------------------------------------------------
// Action to setup a new folder
// ------------------------------------------------------------------------
@RequiresPermission(ReadPermission.class)
public static class FolderSetupAction extends FormHandlerAction<FolderSetupForm>
{
public static final String DATA_PIPELINE_TAB = "Data Pipeline";
public static final String RUNS_TAB = "Runs";
public static final String ANNOTATIONS_TAB = "Annotations";
public static final String GUIDE_SETS_TAB = "Guide Sets";
public static final String PARETO_PLOT_TAB = "Pareto Plot";
public static final String DATA_PIPELINE_WEBPART = "Data Pipeline";
@Override
public void validateCommand(FolderSetupForm target, Errors errors)
{
}
@Override
public boolean handlePost(FolderSetupForm folderSetupForm, BindException errors)
{
Container c = getContainer();
TargetedMSModule targetedMSModule = null;
for (Module m : c.getActiveModules())
{
if (m instanceof TargetedMSModule)
{
targetedMSModule = (TargetedMSModule) m;
}
}
if (targetedMSModule == null)
{
return true; // no TargetedMS module found - do nothing
}
ModuleProperty moduleProperty = targetedMSModule.getModuleProperties().get(FOLDER_TYPE_PROP_NAME);
switch (FolderType.valueOf(moduleProperty.getValueContainerSpecific(c)))
{
case Experiment:
case ExperimentMAM:
case Library:
case LibraryProtein:
case QC:
return true; // Module type already set to LibraryProtein
case Undefined:
// continue with the remainder of the function
break;
}
if (FolderType.Experiment.toString().equals(folderSetupForm.getFolderType()) ||
FolderType.ExperimentMAM.toString().equals(folderSetupForm.getFolderType()))
{
moduleProperty.saveValue(getUser(), c, folderSetupForm.getFolderType());
// setup the EXPERIMENTAL_DATA default webparts
addDashboardTab(DefaultFolderType.DEFAULT_DASHBOARD, c, EXPERIMENT_FOLDER_WEB_PARTS);
}
else if (FolderType.Library.toString().equals(folderSetupForm.getFolderType()))
{
// setup the CHROMATOGRAM_LIBRARY default webparts
if (folderSetupForm.isPrecursorNormalized())
{
moduleProperty.saveValue(getUser(), c, FolderType.LibraryProtein.toString());
}
else
{
moduleProperty.saveValue(getUser(), c, FolderType.Library.toString());
}
addDashboardTab(DefaultFolderType.DEFAULT_DASHBOARD, c, LIBRARY_FOLDER_WEB_PARTS);
// Add the appropriate web parts to the page
if(folderSetupForm.isPrecursorNormalized())
{
addDashboardTab(PROTEIN_TAB_NAME, c, PROTEIN_TAB_WEB_PARTS);
addDashboardTab(TargetedMSModule.PEPTIDE_TAB_NAME, c, PEPTIDE_TAB_WEB_PARTS);
}
}
else if (FolderType.QC.toString().equals(folderSetupForm.getFolderType()))
{
moduleProperty.saveValue(getUser(), c, FolderType.QC.toString());
addDashboardTab(DefaultFolderType.DEFAULT_DASHBOARD, c, QC_FOLDER_WEB_PARTS);
ArrayList<Portal.WebPart> runsTab = new ArrayList<>();
runsTab.add(Portal.getPortalPart(TargetedMSModule.TARGETED_MS_RUNS_WEBPART_NAME).createWebPart());
Portal.saveParts(c, RUNS_TAB, runsTab);
Portal.addProperty(c, RUNS_TAB, Portal.PROP_CUSTOMTAB);
ArrayList<Portal.WebPart> annotationsTab = new ArrayList<>();
Portal.WebPart annotationsPart = Portal.getPortalPart("Query").createWebPart();
annotationsPart.setProperty(QueryParam.schemaName.toString(), "targetedms");
annotationsPart.setProperty(QueryParam.queryName.toString(), "qcannotation");
annotationsTab.add(annotationsPart);
Portal.WebPart annotationTypesPart = Portal.getPortalPart("Query").createWebPart();
annotationTypesPart.setProperty(QueryParam.schemaName.toString(), "targetedms");
annotationTypesPart.setProperty(QueryParam.queryName.toString(), "qcannotationtype");
annotationsTab.add(annotationTypesPart);
Portal.WebPart replicateAnnotationPart = Portal.getPortalPart("Query").createWebPart();
replicateAnnotationPart.setProperty(QueryParam.schemaName.toString(), "targetedms");
replicateAnnotationPart.setProperty(QueryParam.queryName.toString(), "replicateannotation");
annotationsTab.add(replicateAnnotationPart);
Portal.saveParts(c, ANNOTATIONS_TAB, annotationsTab);
Portal.addProperty(c, ANNOTATIONS_TAB, Portal.PROP_CUSTOMTAB);
ArrayList<Portal.WebPart> guideSetsTab = new ArrayList<>();
Portal.WebPart guideSetsPart = Portal.getPortalPart("Query").createWebPart();
guideSetsPart.setProperty(QueryParam.schemaName.toString(), "targetedms");
guideSetsPart.setProperty(QueryParam.queryName.toString(), "guideset");
guideSetsTab.add(guideSetsPart);
Portal.saveParts(c, GUIDE_SETS_TAB, guideSetsTab);
Portal.addProperty(c, GUIDE_SETS_TAB, Portal.PROP_CUSTOMTAB);
ArrayList<Portal.WebPart> paretoPlotTab = new ArrayList<>();
Portal.WebPart paretoPlotPart = Portal.getPortalPart(TargetedMSModule.TARGETED_MS_PARETO_PLOT).createWebPart();
paretoPlotTab.add(paretoPlotPart);
Portal.saveParts(c, PARETO_PLOT_TAB, paretoPlotTab);
Portal.addProperty(c, PARETO_PLOT_TAB, Portal.PROP_CUSTOMTAB);
}
// Add additional portal pages (tabs) and webparts
addDataPipelineTab(c);
addRawFilesPipelineTab(c);
// Inform listeners so that any additional folder configuration can be done.
TargetedMSService.get().getTargetedMSFolderTypeListeners().forEach(listener -> listener.folderCreated(c, getUser()));
return true;
}
private void addDataPipelineTab(Container c)
{
List<Portal.WebPart> tab = new ArrayList<>();
Portal.WebPart webPart = Portal.getPortalPart(DATA_PIPELINE_WEBPART).createWebPart();
tab.add(webPart);
Portal.saveParts(c, DATA_PIPELINE_TAB, tab);
Portal.addProperty(c, DATA_PIPELINE_TAB, Portal.PROP_CUSTOMTAB);
}
@Override
public URLHelper getSuccessURL(FolderSetupForm folderSetupForm)
{
return getContainer().getStartURL(getUser());
}
}
public static void addDashboardTab(String tab, Container c, String... includeWebParts)
{
ArrayList<Portal.WebPart> newWebParts = new ArrayList<>();
for(String name: includeWebParts)
{
Portal.WebPart webPart = Portal.getPortalPart(name).createWebPart();
newWebParts.add(webPart);
}
Portal.saveParts(c, tab, newWebParts);
if (!DefaultFolderType.DEFAULT_DASHBOARD.equals(tab))
{
Portal.addProperty(c, tab, Portal.PROP_CUSTOMTAB);
}
}
public static class ChromatogramCrawlerForm
{
}
@RequiresPermission(ApplicationAdminPermission.class)
public class ChromatogramCrawlerAction extends FormViewAction<ChromatogramCrawlerForm>
{
@Override
public void validateCommand(ChromatogramCrawlerForm target, Errors errors)
{
}
@Override
public ModelAndView getView(ChromatogramCrawlerForm form, boolean reshow, BindException errors)
{
return new HtmlView("Chromatogram Crawler", DIV("Crawl all containers under the parent " + getContainer().getPath(),
DOM.LK.FORM(at(method, "POST"),
new ButtonBuilder("Start Crawl").submit(true).build())));
}
@Override
public boolean handlePost(ChromatogramCrawlerForm form, BindException errors) throws Exception
{
PipelineJob job = new ChromatogramCrawlerJob(getViewBackgroundInfo(), PipelineService.get().getPipelineRootSetting(ContainerManager.getRoot()));
PipelineService.get().queueJob(job);
return true;
}
@Override
public URLHelper getSuccessURL(ChromatogramCrawlerForm form)
{
return urlProvider(PipelineUrls.class).urlBegin(getContainer());
}
@Override
public void addNavTrail(NavTree root)
{
urlProvider(AdminUrls.class).addAdminNavTrail(root, "Chromatogram Crawler", getClass(), getContainer());
}
}
// ------------------------------------------------------------------------
// Action to create a Raw Data tab
// ------------------------------------------------------------------------
@RequiresPermission(AdminPermission.class)
public static class AddRawDataTabAction extends FormHandlerAction<Object>
{
@Override
public void validateCommand(Object target, Errors errors)
{
}
@Override
public boolean handlePost(Object o, BindException errors)
{
Container c = getContainer();
if(!c.hasActiveModuleByName(MODULE_NAME))
{
return true; // no TargetedMS module found - do nothing
}
addRawFilesPipelineTab(c);
return true;
}
@Override
public URLHelper getSuccessURL(Object o)
{
return urlProvider(ProjectUrls.class).getBeginURL(getContainer(), RAW_FILES_TAB);
}
}
public static void addRawFilesPipelineTab(Container c)
{
FileContentService service = FileContentService.get();
if (null != service)
{
List<Portal.WebPart> tab = new ArrayList<>();
Portal.WebPart webPart = Portal.getPortalPart(FilesWebPart.PART_NAME).createWebPart();
configureRawDataTab(webPart, c, service);
tab.add(webPart);
Portal.saveParts(c, RAW_FILES_TAB, tab);
Portal.addProperty(c, RAW_FILES_TAB, Portal.PROP_CUSTOMTAB);
}
}
public static void configureRawDataTab(Portal.WebPart webPart, Container c, FileContentService service)
{
if (null != service)
{
Path fileRoot = service.getFileRootPath(c, FileContentService.ContentType.files);
if (fileRoot != null)
{
Path rawFileDir = fileRoot.resolve(RAW_FILES_DIR);
if (!Files.exists(rawFileDir))
{
try
{
FileUtil.createDirectories(rawFileDir);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
}
String fileRootString = FileContentService.FILES_LINK + "/" + RAW_FILES_DIR + "/";
webPart.setProperty(FilesWebPart.FILE_ROOT_PROPERTY_NAME, fileRootString);
}
}
// ------------------------------------------------------------------------
// Action to show a list of uploaded documents
// ------------------------------------------------------------------------
@RequiresPermission(AdminPermission.class)
public static class SetupAction extends SimpleViewAction<Object>
{
@Override
public ModelAndView getView(Object o, BindException errors)
{
JspView<?> view = new JspView<>("/org/labkey/targetedms/view/folderSetup.jsp");
view.setFrame(WebPartView.FrameType.NONE);
getPageConfig().setNavTrail(ContainerManager.getCreateContainerWizardSteps(getContainer(), getContainer().getParent()));
getPageConfig().setTemplate(PageConfig.Template.Wizard);
getPageConfig().setTitle(CONFIGURE_TARGETED_MS_FOLDER);
return view;
}
@Override
public void addNavTrail(NavTree root)
{
}
}
// ------------------------------------------------------------------------
// Action to show QC reports
// ------------------------------------------------------------------------
@RequiresPermission(ReadPermission.class)
public static class LeveyJenningsAction extends SimpleViewAction<URLParameterBean>
{
@Override
public ModelAndView getView(URLParameterBean urlParameterBean, BindException errors)
{
return new JspView<>("/org/labkey/targetedms/view/qcTrendPlotReport.jsp");
}
@Override
public void addNavTrail(NavTree root)
{
root.addChild("QC Reports");
}
}
public static class URLParameterBean
{
private String metric;
private String startDate;
private String endDate;
private List<String> _plotTypes;
private Boolean _largePlot;
public String getMetric()
{
return metric;
}
public void setMetric(String metric)
{
this.metric = metric;
}
public String getStartDate()
{
return startDate;
}
public void setStartDate(String startDate)
{
this.startDate = startDate;
}
public String getEndDate()
{
return endDate;
}
public void setEndDate(String endDate)
{
this.endDate = endDate;
}
public void setPlotTypes(List<String> plotTypes)
{
_plotTypes = plotTypes;
}
public List<String> getPlotTypes()
{
return _plotTypes;
}
public Boolean getLargePlot()
{
return _largePlot;
}
public void setLargePlot(Boolean largePlot)
{
_largePlot = largePlot;
}
}
@RequiresPermission(ReadPermission.class)
public static class LeveyJenningsPlotOptionsAction extends MutatingApiAction<LeveyJenningsPlotOptions>
{
@Override
public Object execute(LeveyJenningsPlotOptions form, BindException errors)
{
ApiSimpleResponse response = new ApiSimpleResponse();
PropertyMap properties = null;
// only stash and retrieve plot option properties for logged-in users
if (!getUser().isGuest())
{
WritablePropertyMap writable = PropertyManager.getWritableProperties(getUser(), getContainer(), QCFolderConstants.CATEGORY, true);
Map<String, String> valuesToPersist = form.getAsMapOfStrings();
if (!valuesToPersist.isEmpty())
{
// note: start, end date and selectedAnnotations handled separately since they can be null and we want to persist that
valuesToPersist.put("startDate", form.getStartDate());
valuesToPersist.put("endDate", form.getEndDate());
valuesToPersist.put("selectedAnnotations", form.getSelectedAnnotationsString());
writable.putAll(valuesToPersist);
writable.save();
}
else
{
if (writable.containsKey("selectedAnnotations") && (ReplicateManager.getReplicateAnnotationNameValues(getContainer()).isEmpty()))
{
// If there are no replicate annotations in this folder anymore, remove any saved annotation filters
// Issue 35726: No way to clear previously saved replicate annotation values in QC plots if folder no longer contains annotations
writable.remove("selectedAnnotations");
writable.save();
}
}
properties = writable;
}
if (properties == null || properties.isEmpty())
{
// Fall back on the defaults for the current container
properties = PropertyManager.getProperties(getContainer(), QCFolderConstants.CATEGORY);
}
Map<String, Object> toSend = new HashMap<>(properties);
toSend.putIfAbsent("dateRangeOffset", "180");
response.put("properties", toSend);
return response;
}
}
@RequiresPermission(AdminPermission.class)
public static class SaveQCPlotSettingsAsDefaultAction extends MutatingApiAction<LeveyJenningsPlotOptions>
{
@Override
public Object execute(LeveyJenningsPlotOptions form, BindException errors)
{
PropertyMap current = PropertyManager.getProperties(getUser(), getContainer(), QCFolderConstants.CATEGORY);
WritablePropertyMap defaults = PropertyManager.getWritableProperties(getContainer(), QCFolderConstants.CATEGORY, true);
defaults.clear(); // Clear the map. There may be properties that are no longer applicable (e.g. selectedAnnotations, startDate, endDate).
defaults.putAll(current);
defaults.save();
SiteSettingsAuditProvider.SiteSettingsAuditEvent event = new SiteSettingsAuditProvider.SiteSettingsAuditEvent(
getContainer(), "Panorama QC plot default settings saved for " + getContainer().getPath());
AuditLogService.get().addEvent(getUser(), event);
ApiSimpleResponse response = new ApiSimpleResponse();
response.put("success", true);
return response;
}
}
@RequiresLogin
@RequiresPermission(ReadPermission.class)
public static class RevertToDefaultQCPlotSettingsAction extends MutatingApiAction<LeveyJenningsPlotOptions>
{
@Override
public Object execute(LeveyJenningsPlotOptions form, BindException errors)
{
WritablePropertyMap current = PropertyManager.getWritableProperties(getUser(), getContainer(), QCFolderConstants.CATEGORY, false);
if (current != null)
{
current.delete();
}
ApiSimpleResponse response = new ApiSimpleResponse();
response.put("success", true);
return response;
}
}
public static class LeveyJenningsPlotOptions
{
private String _metric;
private String _metric2;
private String _yAxisScale;
private Boolean _groupedX;
private Boolean _singlePlot;
private Boolean _showExcluded;
private Boolean _showExcludedPrecursors;
private Integer _dateRangeOffset;
private String _startDate;
private String _endDate;
private List<String> _plotTypes;
private Boolean _largePlot;
public List<String> _selectedAnnotations;
private Integer _trailingRuns;
private Integer _calendarMonthsToShow;
private String _heatmapDataSource;
public Map<String, String> getAsMapOfStrings()
{
Map<String, String> valueMap = new HashMap<>();
if (_metric != null)
valueMap.put("metric", _metric);
if (_metric2 != null)
valueMap.put("metric2", _metric2);
if (_yAxisScale != null)
valueMap.put("yAxisScale", _yAxisScale);
if (_groupedX != null)
valueMap.put("groupedX", Boolean.toString(_groupedX));
if (_singlePlot != null)
valueMap.put("singlePlot", Boolean.toString(_singlePlot));
if (_showExcluded != null)
valueMap.put("showExcluded", Boolean.toString(_showExcluded));
if (_showExcludedPrecursors != null)
valueMap.put("showExcludedPrecursors", Boolean.toString(_showExcludedPrecursors));
if (_dateRangeOffset != null)
valueMap.put("dateRangeOffset", Integer.toString(_dateRangeOffset));
if (_plotTypes != null && !_plotTypes.isEmpty())
valueMap.put("plotTypes", StringUtils.join(_plotTypes, ","));
if (_largePlot != null)
valueMap.put("largePlot", Boolean.toString(_largePlot));
if(_selectedAnnotations != null)
valueMap.put("selectedAnnotations", getSelectedAnnotationsString());
if (_trailingRuns != null)
valueMap.put("trailingRuns", Integer.toString(_trailingRuns));
if (_calendarMonthsToShow != null)
valueMap.put("calendarMonthsToShow", Integer.toString(_calendarMonthsToShow));
if (_heatmapDataSource != null)
valueMap.put("heatMapDataSource", _heatmapDataSource);
// note: start and end date handled separately since they can be null and we want to persist that
return valueMap;
}
public void setMetric(String metric)
{
_metric = metric;
}
public void setMetric2(String metric2)
{
_metric2 = metric2;
}
public void setyAxisScale(String yAxisScale)
{
_yAxisScale = yAxisScale;
}
public void setGroupedX(Boolean groupedX)
{
_groupedX = groupedX;
}
public void setSinglePlot(Boolean singlePlot)
{
_singlePlot = singlePlot;
}
public void setShowExcluded(Boolean showExcluded)
{
_showExcluded = showExcluded;
}
public Boolean getShowExcludedPrecursors()
{
return _showExcludedPrecursors;
}
public void setShowExcludedPrecursors(Boolean showExcludedPrecursors)
{
_showExcludedPrecursors = showExcludedPrecursors;
}
public void setDateRangeOffset(Integer dateRangeOffset)
{
_dateRangeOffset = dateRangeOffset;
}
public void setStartDate(String startDate)
{
_startDate = startDate;
}
public String getStartDate()
{
return _startDate;
}
public void setEndDate(String endDate)
{
_endDate = endDate;
}
public String getEndDate()
{
return _endDate;
}
public void setPlotTypes(List<String> plotTypes)
{
_plotTypes = plotTypes;
}
public List<String> getPlotTypes()
{
return _plotTypes;
}
public void setLargePlot(Boolean largePlot)
{
_largePlot = largePlot;
}
public List<String> getSelectedAnnotations()
{
return _selectedAnnotations;
}
public void setSelectedAnnotations(List<String> annotations)
{
_selectedAnnotations = annotations;
}