-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathBuild.AviationSample.cls
107 lines (95 loc) · 4.21 KB
/
Build.AviationSample.cls
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
/// This is from https://github.com/intersystems/Samples-Aviation.
/// This class builds the downloaded sample files from https://github.com/intersystems/Samples-Aviation.
/// Use or operation of this code is subject to acceptance of the license available in the code repository for this code.
Class Build.AviationSample Extends %RegisteredObject
{
/// This method prompts the user for the name of the directory that contains the downloaded files
/// and then builds the sample.
ClassMethod Build()
{
write !, "This is the setup method for the Samples-Aviation sample, which is meant for "
write !, "use with the InterSystems IRIS Text Analytics capabilities. To use this sample,"
write !, "you must have an InterSystems IRIS license that includes analytics capabilities."
write !!, "To continue, please specify the full path of the directory that contains this "
write !, "sample. (This is the directory that contains the README.md and LICENSE files.)",!
read "Your input: ",stagingroot
if ($ZSTRIP(stagingroot,"<>W")="") {
write !, "Not a valid directory. Quitting..."
quit
}
set exists=##class(%File).DirectoryExists(stagingroot)
if 'exists {
write !, "Directory not found. Quitting..."
quit
}
set OK=..run(stagingroot,1)
if OK {
write !!, "IMPORTANT: If there were build errors while setting up this sample, your"
write !, "license might not include analytics capabilities. "
write !, "(This setup code does not check your license.)"
write !!, "Before using this sample, see the README.md file for information on setting up"
write !, "a web application in this namespace and enabling that web application to use"
write !, "analytics capabilities."
write !!, "Then open the Management Portal and access the Analytics menu in this namespace."
write !, "See the README.md file for details on this sample and links to documentation."
} else {
write !!, "Setup was unsuccessful. Make sure that the directory you specified"
write !, "contains the sample files for *this* sample."
}
}
/// This method enables you to build the sample with a minimum of output to the Terminal.
/// stagingroot is the name of the directory that contains the downloaded files.
/// interactive controls whether this method displays output.
/// Build calls this method with interactive=1.
ClassMethod run(stagingroot As %String = "", interactive As %Boolean = 0)
{
//repeat this test here in case we go directly to this method
if $ZSTRIP(stagingroot,"<>W")="" {
if interactive {
write !, "Not a valid directory... Quitting."
}
return 0
}
// load and compile classes ***************************
set dir=stagingroot_"/cls/" ;works on both Windows and Unix
if '##class(%File).DirectoryExists(dir) {
if interactive {
write !!, "Looking for "_dir
write !, "but it does not exist... Quitting."
}
return 0
}
if interactive {
write !!, "Loading and compiling classes..."
}
do $system.OBJ.LoadDir(dir,"ck",,1)
// Load data from exported global ******************************
if interactive {
write !, "Loading data..."
}
set file=stagingroot_"/gbl/aviation.xml" ;works on both Windows and Unix
if '##class(%File).Exists(file) {
if interactive {
write !!, "Looking for "_file
write !, "but it does not exist... Quitting."
}
return 0
}
do $system.OBJ.Load(file)
// Execute the setup code in the loaded classes *********************
if '##class(%Dictionary.CompiledClass).%ExistsId("Aviation.Utils") {
if interactive {
write !!, "Looking for the class Aviation.Utils but it does not exist... Quitting."
}
return 0
}
if interactive {
write !, "Running the Aviation.Utils.SetupStandalone() method to initialize the NLP domain"
}
do ##class(Aviation.Utils).SetupStandalone()
if interactive {
write !!, "If you would also like to set up the Aviation demo for use with InterSystems IRIS BI, run ##class(Aviation.Utils).SetupCube()"
}
return 1
}
}