Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions modules/simpletest/resources/queries/lists/People.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ function stripPrefix(row)
}
}

// Disable managed columns from a script
function managedColumns() {
return false;
}

function beforeInsert(row, errors)
{
// Test row map is case-insensitive
Expand All @@ -32,12 +37,9 @@ function beforeInsert(row, errors)

stripPrefix(row);

// var result = LABKEY.Query.deleteRows({
// schemaName: "lists",
// queryName: "People",
// rowDataArray: [{Key: 100}]
// });
// console.log("Result of deleteRows: ", result);
// Test disabling managed columns from a script by placing an invalid key/value on the row.
// If this script managed columns, then this would fail.
row.ImNotManagedInsert = "I'm not managed insert";
}

function afterInsert(row, errors)
Expand All @@ -58,6 +60,10 @@ function beforeUpdate(row, oldRow, errors)
throw new Error("beforeUpdate oldRow properties must be case-insensitive.");

stripPrefix(row);

// Test disabling managed columns from a script by placing an invalid key/value on the row.
// If this script managed columns, then this would fail.
row.ImNotManagedUpdate = "I'm not managed update";
}

function afterUpdate(row, oldRow, errors)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,89 +1,47 @@
/*
* 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 shared = require("TriggerTestModule/SharedTriggerLib");
var console = require("console");

function managedColumns() {
return shared.managedColumns();
}

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);
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";
}

shared.beforeInsert(row, errors);
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);
if(row.Comments == "BeforeUpdate")
row.Country = "Before Update changed me";
else if(row.comments == "BeforeUpdate")
row.country = "Before Update changed me";
shared.beforeUpdate(row, oldRow, errors);
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" || row.comments == "BeforeDelete")
errors[null] = "This is the Before Delete Error";

console.log(shared.sampleFunc("exp.data: this is from the shared function"));
shared.beforeDelete(row, errors);
}

function afterInsert(row, errors) {
console.log("exp.data: afterInsert: row is: " + row);

if(row.Comments == "AfterInsert" || row.comments == "AfterInsert")
errors[null] = "This is the After Insert Error";

console.log(shared.sampleFunc("exp.data: this is from the shared function"));
shared.afterInsert(row, errors);
}

function afterUpdate(row, oldRow, errors) {
console.log("exp.data: afterUpdate: row is: " + row);

if(row.Comments == "AfterUpdate" || row.comments == "AfterUpdate")
errors[null] = "This is the After Update Error";

shared.afterUpdate(row, oldRow, errors);
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" || 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"));
shared.afterDelete(row, errors);
}

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"));
}
88 changes: 61 additions & 27 deletions modules/triggerTestModule/resources/queries/lists/Employees.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,108 @@
/*
* Copyright (c) 2016-2018 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: ["boomerang", "employeeId"],
update: ["boomerang", "company", "employeeId"],
ignored: ["notes"],
};
}

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("list: beforeInsert: row is: " + row);
if(row.name == "Emp 2")
if (row.name === "Emp 2")
row.company = "Inserting Single";
else if(row.name == "Emp 5")
else if (row.name === "Emp 5")
row.company = "Importing TSV";
else if(row.name == "Emp 6")
else if (row.name === "Emp 6")
row.company = "API BeforeInsert";
else if (row.name === "Managed Insert")
row.employeeId = "EMP-INS";
else if (row.name === "Managed Struct") {
row.employeeId = "EMP-STRUCT";
row.undeclaredCol = "bad";
}
else if (row.name === "Managed Struct Remove") {
row.employeeId = "EMP-STRUCT-REM";
delete row.SSN;
}

if (!row.employeeId) {
row.employeeId = "EMP-INS1";
}

row.notes = "This is a note";

if (row.SSN !== "-123") {
row.boomeRANG = "Back at ya!";
}
console.log("list: edited row is: " + row);
console.log(shared.sampleFunc("list: this is from the shared function"));
}

function beforeUpdate(row, oldRow, errors) {
console.log("list: beforeUpdate: row is: " + row);
if(row.name == "Emp 3" || row.name == "Emp 8" )
if (row.company === "Company Up")
row.company = "Before Update changed me";
else if (row.name === "Managed Update") {
row.company = "Managed Co";
row.employeeId = "EMP-UPD";
}
else if (row.name === "Managed Struct") {
row.company = "Struct Co";
row.employeeId = "EMP-STRUCT";
row.undeclaredCol = "bad";
}
else if (row.name === "Managed Struct Remove") {
row.company = "Struct Remove Co";
row.employeeId = "EMP-STRUCT-REM";
delete row.SSN;
}

if (!row.employeeId) {
row.employeeId = "EMP-UPD1";
}

row.notes = "This is a note";

if (row.SSN !== "-123") {
row.boomeRANG = "Back at me!";
}
console.log("list: old row is: " + oldRow);
console.log(shared.sampleFunc("list: this is from the shared function"));
}

function beforeDelete(row, errors) {
console.log("list: beforeDelete: row is: " + row);
if(row.company == "Inserting Single" || row.company == "DeleteMe")
if (row.company === "Inserting Single" || row.company === "DeleteMe")
errors[null] = "This is the Before Delete Error";

console.log(shared.sampleFunc("list: this is from the shared function"));
}

function afterInsert(row, errors) {
console.log("list: afterInsert: row is: " + row);

if(row.name == "Emp 1")
if (row.name === "Emp 1")
errors[null] = "This is the After Insert Error";

console.log(shared.sampleFunc("list: this is from the shared function"));
}

function afterUpdate(row, oldRow, errors) {
console.log("list: afterUpdate: row is: " + row);

if(row.name == "Emp 2" || row.name == "Emp 6" )
if (row.company === "Company After Update Error")
errors[null] = "This is the After Update Error";
//throw new Error("This is the After Update Error");

console.log("list: old row is: " +oldRow);
console.log(shared.sampleFunc("list: this is from the shared function"));
}

function afterDelete(row, errors) {
console.log("list: afterDelete: row is: " + row);

if(row.company == "Before Update changed me")
if (row.company === "Before Update changed me")
errors[null] = "This is the After Delete Error";

console.log(shared.sampleFunc("list: this is from the shared function"));
}

function complete(event, errors) {
console.log("list: complete got triggered with event: " + event);
console.log(shared.sampleFunc("list: this is from the shared function"));
}
22 changes: 22 additions & 0 deletions modules/triggerTestModule/resources/queries/lists/Unmanaged.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var console = require("console");

function managedColumns() {
return false;
}

function beforeInsert(row, errors) {
console.log("list: beforeInsert: row is: " + row);

// Flower is not marked as a managed column, but managed columns are disabled
if (row.type === 'A') {
row.flower = 'Rose';
}
}

function beforeUpdate(row, oldRow, errors) {
console.log("list: beforeUpdate: row is: " + row);

if (row.type === 'A') {
row.hemisphere = 'Northern';
}
}
Loading
Loading