Skip to content

Commit

Permalink
new test script for an association table with a unique association an…
Browse files Browse the repository at this point in the history
…d some other columns
  • Loading branch information
jrchudy committed Jul 18, 2024
1 parent cc8bc87 commit bcb4310
Show file tree
Hide file tree
Showing 5 changed files with 270 additions and 0 deletions.
41 changes: 41 additions & 0 deletions testScripts/createAssociationEdit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
var dataUtils = require('./../import.js');
var Catalog = require('./../model/catalog.js');

var configuration = {
setup: {
"catalog": {},
"schema": {
"name": "edit_w_association",
"createNew": true,
"path": "schema/edit_w_association.json"
},
"tables": {
"createNew": true
},
"entities": {
"createNew": true,
"path": "data/edit_w_association"
}
},
url: process.env.ERMREST_URL,
authCookie: process.env.AUTH_COOKIE,
cleanup: false
};

dataUtils.importData(configuration).then(function(data) {
console.log("Data imported with catalogId " + data.catalogId);
console.log("Please remember to clean up the catalog.");

// Anyone in "isrd-staff" can read ACL
// return Catalog.addACLs(data.schema.url, data.catalogId, {"select": ["https://auth.globus.org/176baec4-ed26-11e5-8e88-22000ab4b42b"]});
// Anyone can read ACL
return Catalog.addACLs(data.schema.url, data.catalogId, {"select": ["*"]});
}, function(err) {
console.log("Unable to import data");
console.dir(err);
}).then(function(data) {
console.log("ACLs set");
}, function(err) {
console.log("Unable to set ACLs");
console.dir(err);
});
1 change: 1 addition & 0 deletions testScripts/data/edit_w_association/association.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id": 1, "order": 2, "fk_to_main": "experiment_1", "fk_to_leaf": "name_2"}]
10 changes: 10 additions & 0 deletions testScripts/data/edit_w_association/leaf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[{"id": 1, "col_for_association": "name_1"},
{"id": 2, "col_for_association": "name_2"},
{"id": 3, "col_for_association": "name_3"},
{"id": 4, "col_for_association": "name_4"},
{"id": 5, "col_for_association": "name_5"},
{"id": 6, "col_for_association": "name_6"},
{"id": 7, "col_for_association": "name_7"},
{"id": 8, "col_for_association": "name_8"},
{"id": 9, "col_for_association": "name_9"},
{"id": 10, "col_for_association": "name_10"}]
5 changes: 5 additions & 0 deletions testScripts/data/edit_w_association/main.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[{"id": 1, "col_for_association": "experiment_1"},
{"id": 2, "col_for_association": "experiment_2"},
{"id": 3, "col_for_association": "experiment_3"},
{"id": 4, "col_for_association": "experiment_4"},
{"id": 5, "col_for_association": "experiment_5"}]
213 changes: 213 additions & 0 deletions testScripts/schema/edit_w_association.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
{
"schema_name": "edit_w_association",
"tables": {
"main": {
"kind": "table",
"schema_name": "edit_w_association",
"table_name": "main",
"keys": [
{
"unique_columns": [
"id"
]
},
{
"unique_columns": [
"col_for_association"
]
}
],
"column_definitions": [
{
"name": "id",
"nullok": false,
"type": {
"typename": "text"
}
},
{
"name": "col_for_association",
"type": {
"typename": "text"
}
}
],
"annotations": {
"tag:isrd.isi.edu,2016:visible-columns": {
"detailed": [
"id", "col_for_association", "RID"
]
}
}
},
"association": {
"kind": "table",
"schema_name": "edit_w_association",
"table_name": "association",
"column_definitions": [
{
"name": "id",
"nullok": false,
"type": {
"typename": "serial4"
}
},
{
"name": "order",
"default": 1,
"type": {
"typename": "int4"
}
},
{
"name": "fk_to_leaf",
"nullok": false,
"type": {
"typename": "text"
}
},
{
"name": "fk_to_main",
"nullok": false,
"type": {
"typename": "text"
}
}
],
"keys": [
{
"unique_columns": [
"id"
]
},
{
"unique_columns": [
"fk_to_main",
"fk_to_leaf"
]
}
],
"foreign_keys": [
{
"RID": "14-381J",
"foreign_key_columns": [
{
"schema_name": "edit_w_association",
"table_name": "association",
"column_name": "fk_to_leaf"
}
],
"referenced_columns": [
{
"schema_name": "edit_w_association",
"table_name": "leaf",
"column_name": "col_for_association"
}
],
"names": [
[
"edit_w_association",
"leaf_fkey"
]
]
},
{
"foreign_key_columns": [
{
"schema_name": "edit_w_association",
"table_name": "association",
"column_name": "fk_to_main"
}
],
"referenced_columns": [
{
"schema_name": "edit_w_association",
"table_name": "main",
"column_name": "col_for_association"
}
],
"names": [
[
"edit_w_association",
"main_fkey"
]
]
}
],
"annotations": {
"tag:isrd.isi.edu,2016:visible-columns": {
"entry": [
"order",
[
"edit_w_association",
"leaf_fkey"
],
[
"edit_w_association",
"main_fkey"
]
],
"compact": [
"order",
[
"edit_w_association",
"main_fkey"
],
[
"edit_w_association",
"leaf_fkey"
]
],
"detailed": "compact"
}
}
},
"leaf": {
"kind": "table",
"schema_name": "edit_w_association",
"table_name": "leaf",
"keys": [
{
"unique_columns": [
"id"
]
},
{
"unique_columns": [
"col_for_association"
]
}
],
"column_definitions": [
{
"name": "id",
"nullok": false,
"type": {
"typename": "text"
}
},
{
"name": "col_for_association",
"type": {
"typename": "text"
}
}
],
"annotations": {
"tag:isrd.isi.edu,2016:table-display": {
"entry": {
"selector_ux_mode": "simple-search-dropdown"
},
"row_name": {
"row_markdown_pattern": "{{{col_for_association}}}"
}
},
"tag:isrd.isi.edu,2016:visible-columns": {
"compact": [
"id", "col_for_association"
]
}
}
}
}
}

0 comments on commit bcb4310

Please sign in to comment.