jsharmony-cms
Version:
138 lines (133 loc) • 8.16 kB
JSON
{
"code_redirect_url_type": {
"type": "code",
"caption": "Redirect URL Type",
"init_data": [
{ "code_val": "BEGINS", "code_txt": "Begins With", "code_seq": 1 },
{ "code_val": "BEGINSICASE", "code_txt": "Begins With (Case Insensitive)", "code_seq": 2 },
{ "code_val": "EXACT", "code_txt": "Exact Match", "code_seq": 3 },
{ "code_val": "EXACTICASE", "code_txt": "Exact Match (Case Insensitive)", "code_seq": 4 },
{ "code_val": "REGEX", "code_txt": "Regular Expression", "code_seq": 5 },
{ "code_val": "REGEXICASE", "code_txt": "Regular Expression (Case Insensitive)", "code_seq": 6 },
]
},
"code_redirect_http_code": {
"type": "code",
"caption": "Redirect HTTP Code",
"init_data": [
{ "code_val": "301", "code_txt": "301 (Permanent)", "code_seq": 1 },
{ "code_val": "302", "code_txt": "302 (Temporary)", "code_seq": 2 },
{ "code_val": "PASSTHRU", "code_txt": "Pass-thru (Proxy)", "code_seq": 3 }
]
},
"redirect": {
"type": "table",
"caption": ["Redirect","Redirects"],
"columns": [
{ "name": "redirect_id", "type": "bigint", "key": true, "identity": true, "null": false },
{ "name": "redirect_key", "type": "bigint", "foreignkey": { "redirect": "redirect_id" } },
{ "name": "site_id", "type": "bigint", "null": false },
{ "name": "redirect_orig_id", "type": "bigint", "foreignkey": { "redirect": "redirect_id" } },
{ "name": "redirect_url", "type": "varchar", "length": 1024, "null": false },
{ "name": "redirect_url_type", "type": "varchar", "length": 32, "foreignkey": { "code_redirect_url_type": "code_val" }, "null": false, "default": "EXACT" },
{ "name": "redirect_seq", "type": "int" },
{ "name": "redirect_dest", "type": "varchar", "length": 1024, "null": false },
{ "name": "redirect_http_code", "type": "varchar", "length": 32, "foreignkey": { "code_redirect_http_code": "code_val" }, "null": false, "default": "301" },
{ "name": "redirect_etstmp", "type": "datetime", "length": 7, "default": { "sql": "%%%%%%jsh.map.timestamp%%%%%%" } },
{ "name": "redirect_euser", "type": "varchar", "length": 20, "default": { "sql": "%%%%%%jsh.map.current_user%%%%%%" } },
{ "name": "redirect_mtstmp", "type": "datetime", "length": 7 },
{ "name": "redirect_muser", "type": "varchar", "length": 20 },
{ "name": "redirect_snotes", "type": "varchar", "length": -1 }
],
"triggers": [
{ "on": ["insert"], "exec": [
"setif(null(redirect.redirect_key),redirect_key,redirect.redirect_id);"
]
},
{ "on": ["validate_insert"], "exec": [
"errorif((inserted(site_id) is not null) and not exists(select site_id from {schema}.site where site_id=inserted(site_id)),'Site ID not found');",
]
},
{ "on": ["validate_update"], "exec": [
"errorif(update(redirect_key) and (deleted(redirect_key) is not null),'Cannot update redirect_key');",
"errorif((inserted(site_id) is not null) and not exists(select site_id from {schema}.site where site_id=inserted(site_id)),'Site ID not found');",
]
},
{ "on": ["update", "insert"], "exec": [
"set(redirect_mtstmp,%%%%%%jsh.map.timestamp%%%%%%);",
"set(redirect_muser,%%%%%%jsh.map.current_user%%%%%%);"
]
}
]
},
"v_my_redirect": {
"type": "view",
"caption": ["Redirect", "Redirects"],
"tables": {
"redirect": {
"columns": [
"redirect_id",
"redirect_key",
"site_id",
"redirect_orig_id",
"redirect_url",
"redirect_url_type",
"redirect_seq",
"redirect_dest",
"redirect_http_code",
"redirect_etstmp",
"redirect_euser",
"redirect_mtstmp",
"redirect_muser"
]
},
"branch_redirect": {
"join_type": "inner",
"join_columns": {
"branch_redirect.redirect_id": "redirect.redirect_id",
"branch_redirect.branch_id": "{schema}.my_current_branch_id()"
}
}
},
"triggers": [
{ "on": ["insert"], "exec": [
[
"errorif({schema}.my_current_branch_is_editable()=0,'Cannot update a read-only revision');",
"errorif({schema}.my_current_branch_is_merging()=1,'Cannot update revision when a merge is in progress');",
"with_insert_identity(redirect, redirect_id, ",
" insert into redirect(site_id, redirect_url, redirect_url_type, redirect_seq, redirect_dest, redirect_http_code) values({schema}.my_current_site_id(), inserted(redirect_url), inserted(redirect_url_type), inserted(redirect_seq), inserted(redirect_dest), inserted(redirect_http_code)),",
" return_insert_key(redirect, redirect_key, (redirect_key=@@INSERT_ID));",
" insert into branch_redirect(branch_id, redirect_key, redirect_id, branch_redirect_action) values ({schema}.my_current_branch_id(), @@INSERT_ID, @@INSERT_ID, 'ADD');",
" update branch_redirect set redirect_orig_id=redirect_id,branch_redirect_action=NULL where branch_id={schema}.my_current_branch_id() and redirect_key = @@INSERT_ID and {schema}.my_current_branch_is_versioned()=0;",
" update branch set branch_data_mtstmp = %%%%%%jsh.map.timestamp%%%%%%, branch_data_muser = %%%%%%jsh.map.current_user%%%%%% where branch_id = {schema}.my_current_branch_id();",
" increment_changes()",
")"
]
]
},
{ "on": ["update"], "exec": [
[
"errorif({schema}.my_current_branch_is_editable()=0,'Cannot update a read-only revision');",
"errorif({schema}.my_current_branch_is_merging()=1,'Cannot update revision when a merge is in progress');",
"with_insert_identity(redirect, redirect_id, ",
" insert into redirect(site_id, redirect_key, redirect_orig_id, redirect_url, redirect_url_type, redirect_seq, redirect_dest, redirect_http_code) values(deleted(site_id), deleted(redirect_key), deleted(redirect_id), inserted(redirect_url), inserted(redirect_url_type), inserted(redirect_seq), inserted(redirect_dest), inserted(redirect_http_code)),",
" update branch_redirect set redirect_id=@@INSERT_ID,branch_redirect_action=(case branch_redirect_action when 'ADD' then 'ADD' else 'UPDATE' end) where branch_id={schema}.my_current_branch_id() and redirect_key = deleted(redirect_key);",
" update branch_redirect set redirect_orig_id=redirect_id,branch_redirect_action=NULL where branch_id={schema}.my_current_branch_id() and redirect_key = deleted(redirect_key) and {schema}.my_current_branch_is_versioned()=0;",
" update branch set branch_data_mtstmp = %%%%%%jsh.map.timestamp%%%%%%, branch_data_muser = %%%%%%jsh.map.current_user%%%%%% where branch_id = {schema}.my_current_branch_id();",
" increment_changes()",
")"
]
]
},
{ "on": ["delete"], "exec": [
"errorif({schema}.my_current_branch_is_editable()=0,'Cannot update a read-only revision');",
"errorif({schema}.my_current_branch_is_merging()=1,'Cannot update revision when a merge is in progress');",
"update branch_redirect set redirect_id=null,branch_redirect_action='DELETE' where branch_id={schema}.my_current_branch_id() and redirect_key = deleted(redirect_key) and ((branch_redirect_action is null) or (branch_redirect_action in ('UPDATE','DELETE')))",
"delete from branch_redirect where branch_id={schema}.my_current_branch_id() and redirect_key = deleted(redirect_key) and (branch_redirect_action='ADD' or {schema}.my_current_branch_is_versioned()=0)",
"update branch set branch_data_mtstmp = %%%%%%jsh.map.timestamp%%%%%%, branch_data_muser = %%%%%%jsh.map.current_user%%%%%% where branch_id = {schema}.my_current_branch_id();",
"increment_changes()"
]
}
]
}
}