/guid/9202a8c04000641f80000000076239ca rename

author:

contributor:

published:

updated:

source uri:

Acre Doc /freebase/acre_doc

Handler:

Default Configuration:

Acre Doc /freebase/acre_doc

Handler:

Default Configuration:

Summary

var topicid = acre.environ.params.id;

function subPropQuery(p){
// deal with unique or non-unique
...

Content

var topicid = acre.environ.params.id;

function subPropQuery(p){
// deal with unique or non-unique
switch (p.expected_type.id) {
case "/type/int":
case "/type/float":
case "/type/boolean":
case "/type/rawstring":
case "/type/uri":
case "/type/text":
case "/type/datetime":
case "/type/bytestring":
case "/type/id":
case "/type/key":
case "/type/value":
return [{"value":null, "optional":true, "limit":10}];
// Localization?
case "type/text":
return [{"id":null,"name":null,"lang":"lang/en","optional":true, "limit":10}];
//need to special case these
case "/common/document":
case "/common/image":
default:
return [{"id":null,"name":null,"optional":true, "limit":10}];
}
};

function propQuery(p){
var q = subPropQuery(p);
for (sp in p.expected_type.properties) {
q[0][p.expected_type.properties[sp].id] = subPropQuery(p.expected_type.properties[sp]);
}
return q;
};


function constructQuery(schema){
var q = {"id":topicid,"name":null};

for (t in schema.type) {
for (p in schema.type[t].properties) {
q[schema.type[t].properties[p].id] = propQuery(schema.type[t].properties[p]);
};
};

acre.print('{\"query\":' + JSON.stringify(q) + '}' + '\n\n\n');
return (q);
}

var schemaIntrospection = acre.mqlread({
"id" : topicid,
"type" : [
{
"id" : null,
"properties" : [
{
"expected_type" : {
"/freebase/property_hints/display_none" : {
"optional" : "forbidden",
"value" : true
},
"/freebase/type_hints/mediator" : null,
"id" : null,
"name" : null,
"properties" : [
{
"/freebase/property_hints/disambiguator" : true,
"/freebase/property_hints/display_none" : {
"optional" : "forbidden",
"value" : true
},
"expected_type" : {
"id" : null
},
"id" : null,
"index" : null,
"name" : null,
"optional" : true,
"sort" : "index",
"unique" : null
}
]
},
"id" : null,
"index" : null,
"name" : null,
"sort" : "index",
"unique" : null
}
]
}
]
});

acre.start_response(200, {
'content-type': 'text/plain; charset="UTF-8"'

});

//acre.print(JSON.stringify(schemaIntrospection) + '\n\n');

var data = acre.mqlread(constructQuery(schemaIntrospection));

acre.print(JSON.stringify(data) + '\n');

acre.exit();

Created by: jdouglas Mar 6, 2008
Last edited by: Constant Gardener Process Aug 18, 2009

Recent Discussions about None

There is no discussion about this document.

Start the Discussion »
Explore the Data
View all the data we have for /guid/9202a8c04000641f80000000076239ca
Flag this Document
Why do you want to flag this document?