diff --git a/flat/style/flat.editor.js b/flat/style/flat.editor.js index 9add295..3d6d119 100644 --- a/flat/style/flat.editor.js +++ b/flat/style/flat.editor.js @@ -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 @@ -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"); + } } } }