Skip to content

Commit

Permalink
formulate feature editing queries (issue #43)
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Oct 27, 2016
1 parent 57a8ef1 commit 376901c
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions flat/style/flat.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1410,10 +1410,10 @@ function editor_submit(addtoqueue) {
if (editdata[i].higherorder[j].oldvalue) {
if (editdata[i].higherorder[j].value) {
//edit
queries.push(useclause + " EDIT " + editdata[i].higherorder[j].type + " WHERE text = \"" + escape_fql_value(editdata[i].higherorder[j].oldvalue) + "\" WITH text \"" + escape_fql_value(editdata[i].higherorder[j].value) + "\" annotator \"" + escape_fql_value(username) + "\" annotatortype \"manual\" datetime now FORMAT flat RETURN ancestor-focus");
queries.push(useclause + " EDIT " + editdata[i].higherorder[j].type + " WHERE text = \"" + escape_fql_value(editdata[i].higherorder[j].oldvalue) + "\" WITH text \"" + escape_fql_value(editdata[i].higherorder[j].value) + "\" annotator \"" + escape_fql_value(username) + "\" annotatortype \"manual\" datetime now FOR ID " + editdata[i].id + " FORMAT flat RETURN ancestor-focus");
} else {
//delete
queries.push(useclause + " DELETE " + editdata[i].higherorder[j].type + " WHERE text = \"" + escape_fql_value(editdata[i].higherorder[j].oldvalue) + "\" FORMAT flat RETURN ancestor-focus");
queries.push(useclause + " DELETE " + editdata[i].higherorder[j].type + " WHERE text = \"" + escape_fql_value(editdata[i].higherorder[j].oldvalue) + "\" FOR ID " + editdata[i].id + " FORMAT flat RETURN ancestor-focus");
}
} else if (editdata[i].higherorder[j].value !== "") {
//add
Expand All @@ -1426,7 +1426,29 @@ function editor_submit(addtoqueue) {
}
}
} else if ((editdata[i].higherorder[j].type == 'feat')) {
//TODO: formulate query for features
//formulate query for features
if ((editdata[i].higherorder[j].oldclass) && (editdata[i].higherorder[j].oldsubset) && ( (!editdata[i].higherorder[j].class) || (!editdata[i].higherorder[j].subset))) {
//deletion
queries.push(useclause + " DELETE " + editdata[i].higherorder[j].type + " WHERE subset = \"" + escape_fql_value(editdata[i].higherorder[j].oldsubset) + " AND \" class = \"" + escape_fql_value(editdata[i].higherorder[j].oldsubset) + "\" FOR ID " + editdata[i].id + " FORMAT flat RETURN ancestor-focus");
} else if ((!editdata[i].higherorder[j].oldclass) && (!editdata[i].higherorder[j].oldsubset)) {
//add
if (editdata[i].id !== undefined) {
queries.push(useclause + " ADD " + editdata[i].higherorder[j].type + " WITH subset \"" + escape_fql_value(editdata[i].higherorder[j].subset) + "\" class \"" + escape_fql_value(editdata[i].higherorder[j].class) + "\" FOR ID " + editdata[i].id + " FORMAT flat RETURN ancestor-focus");
} else {
//undefined ID, means parent annotation is new as well, select it by value:
parentselector = build_parentselector_query(editdata[i], sortededittargets);
queries.push(useclause + " ADD " + editdata[i].higherorder[j].type + " WITH subset \"" + escape_fql_value(editdata[i].higherorder[j].subset) + "\" class \"" + escape_fql_value(editdata[i].higherorder[j].class) + "\" FOR " + parentselector + " FORMAT flat RETURN ancestor-focus");
}
} else if ((editdata[i].higherorder[j].oldclass) && (editdata[i].highorder[j].oldclass != higherorder[j].class) && (editdata[i].higherorder[j].oldsubset == editdata[i].higherorder[j].subset)) {
//edit of class
queries.push(useclause + " EDIT " + editdata[i].higherorder[j].type + " WHERE subset = \"" + escape_fql_value(editdata[i].higherorder[j].subset) + "\" AND class = \"" + escape_fql_value(editdata[i].higherorder[j].class) + "\" WITH class \"" + escape_fql_value(editdata[i].higherorder[j].class) + "\" FOR ID " + editdata[i].id + " FORMAT flat RETURN ancestor-focus");
} else if ((editdata[i].higherorder[j].oldsubset) && (editdata[i].highorder[j].oldsubset != higherorder[j].subset) && (editdata[i].higherorder[j].oldclass == editdata[i].higherorder[j].class)) {
//edit of subset
queries.push(useclause + " EDIT " + editdata[i].higherorder[j].type + " WHERE subset = \"" + escape_fql_value(editdata[i].higherorder[j].subset) + "\" AND class = \"" + escape_fql_value(editdata[i].higherorder[j].class) + "\" WITH subset \"" + escape_fql_value(editdata[i].higherorder[j].subset) + "\" FOR ID " + editdata[i].id + " FORMAT flat RETURN ancestor-focus");
} else {
//edit of class and subset
queries.push(useclause + " EDIT " + editdata[i].higherorder[j].type + " WHERE subset = \"" + escape_fql_value(editdata[i].higherorder[j].subset) + "\" AND class = \"" + escape_fql_value(editdata[i].higherorder[j].class) + "\" WITH subset \"" + escape_fql_value(editdata[i].higherorder[j].subset) + "\" class \"" + escape_fql_value(editdata[i].higherorder[j].class) + "\" FOR ID " + editdata[i].id + " FORMAT flat RETURN ancestor-focus");
}
}
}
}
Expand Down

0 comments on commit 376901c

Please sign in to comment.