Skip to content

Commit

Permalink
Merge pull request #23 from IntelLabs/bug-fixes
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
vishakha041 authored Apr 27, 2018
2 parents a412b78 + 9f385f8 commit bb5a437
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
13 changes: 11 additions & 2 deletions src/PMGDQueryHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,12 @@ void PMGDQueryHandler::build_results(Iterator &ni,
for (; ni; ni.next()) {
for (int i = 0; i < keyids.size(); ++i) {
Property j_p;
if (!ni->check_property(keyids[i], j_p))
continue;
PMGDPropList &list = rmap[qn.response_keys(i)];
PMGDProp *p_p = list.add_values();
if (!ni->check_property(keyids[i], j_p)) {
construct_missing_property(p_p);
continue;
}
construct_protobuf_property(j_p, p_p);
}
count++;
Expand Down Expand Up @@ -584,3 +586,10 @@ void PMGDQueryHandler::construct_protobuf_property(const Property &j_p, PMGDProp
p_p->set_blob_value(j_p.blob_value().value, j_p.blob_value().size);
}
}

void PMGDQueryHandler::construct_missing_property(PMGDProp *p_p)
{
// Assumes matching enum values!
p_p->set_type(PMGDProp::StringType);
p_p->set_string_value("Missing property");
}
1 change: 1 addition & 0 deletions src/PMGDQueryHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ namespace VDMS {
const PMGDQueryNode &qn,
PMGDCmdResponse *response);
void construct_protobuf_property(const PMGD::Property &j_p, PMGDProp*p_p);
void construct_missing_property(PMGDProp *p_p);

void set_response(PMGDCmdResponse *response, PMGDCmdErrorCode error_code,
std::string error_msg)
Expand Down
5 changes: 3 additions & 2 deletions src/RSCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,10 @@ int AddEntity::construct_protobuf(PMGDQuery& query,
Json::Value& error)
{
const Json::Value& cmd = jsoncmd[_cmd_name];
bool link = cmd.isMember("link");

int node_ref = get_value<int>(cmd, "_ref",
query.get_available_reference());
link ? query.get_available_reference() : -1);

query.AddNode(
node_ref,
Expand All @@ -165,7 +166,7 @@ int AddEntity::construct_protobuf(PMGDQuery& query,
cmd["constraints"]
);

if (cmd.isMember("link")) {
if (link) {
add_link(query, cmd["link"], node_ref, VDMS_GENERIC_LINK);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/AddAndFind_query.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"Age": [">", 0, "<=", 100 ]
},
"results": {
"list":["Name","Age","Email"],
"list":["Name","Age","Email", "Study"],
"sort" :"Age"
}
}
Expand Down
10 changes: 9 additions & 1 deletion tests/json_queries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,15 @@ TEST(QueryHandler, AddAndFind){
if (cmd =="FindEntity")
out_query_num++;

if (j == 12) { // Last FindEntiyu
if (j == 11) { // Second Last FindEntity
EXPECT_EQ(query["FindEntity"]["entities"][2]["Study"].asString(),
"Missing property");

EXPECT_EQ(query["FindEntity"]["entities"][3]["Study"].asString(),
"Missing property");
}

if (j == 12) { // Last FindEntiy
EXPECT_EQ(query["FindEntity"]["entities"][0]["Birthday"].asString(),
"1946-10-07T17:59:24-07:00");

Expand Down
2 changes: 0 additions & 2 deletions utils/src/api_schema/api_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@
"results": { "type": "object" },
"unique": { "type": "boolean" }
},

"required": ["class"],
"additionalProperties": false
},

Expand Down

0 comments on commit bb5a437

Please sign in to comment.