1- /*
2- * Copyright (c) 2015-2019 LabKey Corporation
3- *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
6- * You may obtain a copy of the License at
7- *
8- * http://www.apache.org/licenses/LICENSE-2.0
9- *
10- * Unless required by applicable law or agreed to in writing, software
11- * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- * See the License for the specific language governing permissions and
14- * limitations under the License.
15- */
16-
17- package org .labkey .hdrl ;
18-
19- import org .apache .logging .log4j .Logger ;
20- import org .apache .logging .log4j .LogManager ;
21- import org .jetbrains .annotations .NotNull ;
22- import org .jetbrains .annotations .Nullable ;
23- import org .labkey .api .data .Container ;
24- import org .labkey .api .data .ContainerManager ;
25- import org .labkey .api .module .DefaultModule ;
26- import org .labkey .api .module .FolderTypeManager ;
27- import org .labkey .api .module .ModuleContext ;
28- import org .labkey .api .query .ValidationException ;
29- import org .labkey .api .util .PageFlowUtil ;
30- import org .labkey .api .util .SystemMaintenance ;
31- import org .labkey .api .view .WebPartFactory ;
32- import org .labkey .hdrl .query .HDRLQuerySchema ;
33- import org .labkey .hdrl .query .LabWareQuerySchema ;
34-
35- import java .util .Collection ;
36- import java .util .Collections ;
37- import java .util .Set ;
38-
39- public class HDRLModule extends DefaultModule
40- {
41- private static final Logger _log = LogManager .getLogger (HDRLModule .class );
42- public static final String NAME = "HDRL" ;
43-
44- @ Override
45- public String getName ()
46- {
47- return NAME ;
48- }
49-
50- @ Override
51- public @ Nullable Double getSchemaVersion ()
52- {
53- return 26.000 ;
54- }
55-
56- @ Override
57- public boolean hasScripts ()
58- {
59- return true ;
60- }
61-
62- @ Override
63- @ NotNull
64- protected Collection <WebPartFactory > createWebPartFactories ()
65- {
66- return Collections .emptyList ();
67- }
68-
69- @ Override
70- protected void init ()
71- {
72- addController (HDRLController .NAME , HDRLController .class );
73- }
74-
75- @ Override
76- public boolean isAvailable (Container container )
77- {
78- return container .isRoot () || container .getActiveModules ().contains (this );
79- }
80-
81- @ Override
82- public void doStartup (ModuleContext moduleContext )
83- {
84- // add a container listener so we'll know when our container is deleted:
85- ContainerManager .addContainerListener (new HDRLContainerListener ());
86-
87- HDRLQuerySchema .register (this );
88- try
89- {
90- LabWareQuerySchema .verifyLabWareDataSource ();
91- LabWareQuerySchema .register (this );
92- }
93- catch (ValidationException e )
94- {
95- _log .error (e .getMessage () + " Check your data source configuration." );
96- }
97-
98- FolderTypeManager .get ().registerFolderType (this , new HDRLFolderType (this ));
99-
100- SystemMaintenance .addTask (new HDRLMaintenanceTask ());
101-
102- HDRLController .registerAdminConsoleLinks ();
103- }
104-
105- @ Override
106- @ NotNull
107- public Collection <String > getSummary (Container c )
108- {
109- return Collections .emptyList ();
110- }
111-
112- @ Override
113- @ NotNull
114- public Set <String > getSchemaNames ()
115- {
116- return PageFlowUtil .set (HDRLQuerySchema .NAME , LabWareQuerySchema .getFullyQualifiedDataSource ());
117- }
118- }
0 commit comments