-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDataClassTest.js
More file actions
132 lines (114 loc) · 4.42 KB
/
DataClassTest.js
File metadata and controls
132 lines (114 loc) · 4.42 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
/*
* Copyright (c) 2016-2017 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/
var shared = require("TriggerTestModule/EmployeeLib");
var console = require("console");
function managedColumns() {
return {
insert: ["Country"],
update: ["Country"],
};
}
function init(event, errors) {
console.log("init got triggered with event: " + event);
console.log(shared.sampleFunc("this is from the shared function"));
}
function beforeInsert(row, errors) {
console.log("exp.data: beforeInsert: row is: " + row);
var name = row.Name || row.name;
if (name === "Managed Insert") {
row.Country = "MANAGED-INS";
} else if (name === "Managed Struct") {
row.Country = "MANAGED-STRUCT";
row.undeclaredCol = "bad";
} else if (name === "Managed Struct Remove") {
row.Country = "MANAGED-STRUCT-REM";
delete row.Comments;
delete row.comments;
}
if (name === "Managed Unhandled") {
delete row.Country;
} else {
if (row.Comments) {
if (row.Comments === "Individual Test") {
row.Country = "Inserting Single";
row.Comments = "BeforeDelete"; //set this for next test step
} else if (row.Comments === "Import Test") {
row.Country = "Importing TSV";
} else if (row.Comments === "API Test") {
row.Country = "API BeforeInsert";
}
} else {
if (row.comments === "Individual Test") {
row.country = "Inserting Single";
row.comments = "BeforeDelete"; //set this for next test step
} else if (row.comments === "Import Test") {
row.country = "Importing TSV";
} else if (row.comments === "API Test") {
row.country = "API BeforeInsert";
}
}
if (!row.Country)
row.Country = "DC-DEFAULT";
}
console.log("exp.data: edited row is: " + row);
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
}
function beforeUpdate(row, oldRow, errors) {
console.log("exp.data: beforeUpdate: row is: " + row);
var comments = row.Comments || row.comments;
if (comments === "Managed Update") {
row.Country = "MANAGED-UPD";
}
else if (comments === "Managed Struct") {
row.Country = "MANAGED-STRUCT";
row.undeclaredCol = "bad";
}
else if (comments === "Managed Struct Remove") {
row.Country = "MANAGED-STRUCT-REM";
delete row.Comments;
}
if (comments === "Managed Unhandled") {
delete row.Country;
} else {
if (row.Comments === "BeforeUpdate")
row.Country = "Before Update changed me";
else if (row.comments === "BeforeUpdate")
row.country = "Before Update changed me";
if (!row.Country)
row.Country = "DC-DEFAULT-UPD";
}
console.log("exp.data: old row is: " + oldRow);
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
}
function beforeDelete(row, errors) {
console.log("exp.data: beforeDelete: row is: " + row);
if (row.comments === "BeforeDelete")
errors[null] = "This is the Before Delete Error";
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
}
function afterInsert(row, errors) {
console.log("exp.data: afterInsert: row is: " + row);
if (row.comments === "AfterInsert")
errors[null] = "This is the After Insert Error";
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
}
function afterUpdate(row, oldRow, errors) {
console.log("exp.data: afterUpdate: row is: " + row);
if (row.comments === "AfterUpdate")
errors[null] = "This is the After Update Error";
console.log("exp.data: old row is: " +oldRow);
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
}
function afterDelete(row, errors) {
console.log("exp.data: afterDelete: row is: " + row);
if (row.country === "Before Update changed me")
errors[null] = "This is the After Delete Error";
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
}
function complete(event, errors) {
console.log("exp.data: complete got triggered with event: " + event);
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
}