Task Validation
- Cleaned up the 'import' command due to the new validation code.
This commit is contained in:
@@ -93,6 +93,9 @@ int CmdImport::execute (std::string& output)
|
|||||||
trim (*line), ","),
|
trim (*line), ","),
|
||||||
"]"),
|
"]"),
|
||||||
"[");
|
"[");
|
||||||
|
// Skip blanks. May be caused by the trim calls above.
|
||||||
|
if (! object.length ())
|
||||||
|
continue;
|
||||||
|
|
||||||
// Parse the whole thing.
|
// Parse the whole thing.
|
||||||
json::value* root = json::parse (object);
|
json::value* root = json::parse (object);
|
||||||
@@ -100,7 +103,6 @@ int CmdImport::execute (std::string& output)
|
|||||||
{
|
{
|
||||||
json::object* root_obj = (json::object*)root;
|
json::object* root_obj = (json::object*)root;
|
||||||
Task task;
|
Task task;
|
||||||
task.set ("uuid", uuid ());
|
|
||||||
|
|
||||||
// For each object element...
|
// For each object element...
|
||||||
json_object_iter i;
|
json_object_iter i;
|
||||||
@@ -192,15 +194,13 @@ int CmdImport::execute (std::string& output)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task.validate ();
|
context.tdb2.add (task);
|
||||||
|
++count;
|
||||||
std::cout << " "
|
std::cout << " "
|
||||||
<< task.get ("uuid")
|
<< task.get ("uuid")
|
||||||
<< " "
|
<< " "
|
||||||
<< task.get ("description")
|
<< task.get ("description")
|
||||||
<< "\n";
|
<< "\n";
|
||||||
context.tdb2.add (task);
|
|
||||||
++count;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw std::string ("Not a JSON object: ") + *line;
|
throw std::string ("Not a JSON object: ") + *line;
|
||||||
|
|||||||
Reference in New Issue
Block a user