-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathrlabkey-api-list.xml
More file actions
152 lines (146 loc) · 6.15 KB
/
Copy pathrlabkey-api-list.xml
File metadata and controls
152 lines (146 loc) · 6.15 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
<ApiTests xmlns="http://labkey.org/query/xml">
<test name="create list by inferring fields" type="post">
<url>
<![CDATA[
library(Rlabkey)
df <- data.frame(intKey=c(1:3), customInt=c(1:3), customString=c("aaa", "bbb", "ccc"), customDec=c(1.1, 2.2, 3.3))
fields <- labkey.domain.inferFields(baseUrl=labkey.url.base, folderPath="%projectName%", df)
indices = labkey.domain.createIndices(list("intKey", "customInt"), TRUE)
indices = labkey.domain.createIndices(list("customInt"), FALSE, indices)
dd <- labkey.domain.createDesign(name="test list", fields=fields, indices=indices)
print(labkey.domain.create(baseUrl=labkey.url.base, folderPath="%projectName%", domainKind="IntList", domainDesign=dd, options=list(keyName = "intKey")))
]]>
</url>
<response>
<![CDATA[
$success
[1] TRUE
$name
[1] "test list"
]]>
</response>
</test>
<test name="insert rows into the list" type="post">
<url>
<![CDATA[
library(Rlabkey)
newrow <- data.frame(
customInt=1
, customString="custom string value"
, customDec="1.234E-5") # issue 51160
print(labkey.insertRows(baseUrl=labkey.url.base, folderPath="%projectName%", schemaName="lists", queryName="test list", toInsert=newrow))
]]>
</url>
<response>
<![CDATA[
$queryName
[1] "test list"
$schemaName
[1] "lists"
$rows[[1]]$customInt
[1] 1
$rows[[1]]$customString
[1] "custom string value"
$rows[[1]]$customDec
[1] 1.234e-05
]]>
</response>
</test>
<test name="update the list domain" type="post">
<url>
<![CDATA[
library(Rlabkey)
## change the type of one of the columns
domain <- labkey.domain.get(baseUrl=labkey.url.base, folderPath="%projectName%", schemaName="lists", queryName="test list")
domain$fields[3,]$rangeURI = "xsd:string"
domain$fields[3,]$name = "changed to string"
print(labkey.domain.save(baseUrl=labkey.url.base, folderPath="%projectName%", schemaName="lists", queryName="test list", domainDesign=domain))
]]>
</url>
<response>
<![CDATA[
$success
[1] TRUE
]]>
</response>
</test>
<test name="update the list domain two" type="post">
<url>
<![CDATA[
library(Rlabkey)
## remove one of the columns
df <- data.frame(intKey=c(1:3), customInt=c(1:3))
fields <- labkey.domain.inferFields(baseUrl=labkey.url.base, folderPath="%projectName%", df)
oldDesign <- labkey.domain.get(baseUrl=labkey.url.base, folderPath="%projectName%", schemaName="lists", queryName="test list")
newDesign <- labkey.domain.createDesign(name="test list", fields=fields)
newDesign$domainId = oldDesign$domainId
newDesign$domainURI = oldDesign$domainURI
newDesign$fields[1,]$propertyId = oldDesign$fields[1,]$propertyId
newDesign$fields[1,]$propertyURI = oldDesign$fields[1,]$propertyURI
newDesign$fields[2,]$propertyId = oldDesign$fields[2,]$propertyId
newDesign$fields[2,]$propertyURI = oldDesign$fields[2,]$propertyURI
print(labkey.domain.save(baseUrl=labkey.url.base, folderPath="%projectName%", schemaName="lists", queryName="test list", domainDesign=newDesign))
newrow <- data.frame(
customInt=2
, customString="custom string value")
print(labkey.insertRows(baseUrl=labkey.url.base, folderPath="%projectName%", schemaName="lists", queryName="test list", toInsert=newrow))
]]>
</url>
<response>
<![CDATA[
$success
[1] TRUE
]]>
</response>
</test>
<test name="drop the list domain" type="post">
<url>
<![CDATA[
library(Rlabkey)
print(labkey.domain.drop(baseUrl=labkey.url.base, folderPath="%projectName%", schemaName="lists", queryName="test list"))
]]>
</url>
<response>
<![CDATA[
[1] "Domain deleted"
$success
[1] TRUE
]]>
</response>
</test>
<test name="create a domain from a domain template" type="post">
<url>
<![CDATA[
library(Rlabkey)
print(labkey.domain.create(baseUrl=labkey.url.base, folderPath="%projectName%", domainTemplate="Priority", module="simpletest", domainGroup="todolist"))
]]>
</url>
<response>
<![CDATA[
$success
[1] TRUE
$templateDescription
[1] "simpletest: todolist#Priority"
$name
[1] "Priority"
]]>
</response>
</test>
<test name="create list and load data" type="post">
<url>
<![CDATA[
library(Rlabkey)
df <- data.frame(intKey=c(1:3), customInt=c(1:3), customString=c("aaa", "bbb", "ccc"))
info <- labkey.domain.createAndLoad(baseUrl=labkey.url.base, folderPath="%projectName%", domainKind="IntList", df=df, name="test list with load data", options=list(keyName = "intKey"))
print(paste("Create successful = ", info$success, sep=""))
print(paste("Rows via createAndLoad = ", info$rowCount, sep=""))
]]>
</url>
<response>
<![CDATA[
Create successful = TRUE
Rows via createAndLoad = 3
]]>
</response>
</test>
</ApiTests>