Exemple #1
0
def processPOST(request):
    graph = get_graph_from_request(request)
    payload = request.body
    insert_rdf(payload, 
               content_type(request), 
               graph)
    
    return HttpResponse(status = 204)  
Exemple #2
0
def compose_annotation(request):
    context = {}
    logging.debug(request)
        
    if request.REQUEST.get('target_link', None):
        context['target_link'] = request.REQUEST.get('target_link')
        return mm_render_to_response(request, context, 'compose_annotation.html')
    
    if isPOST(request):
            insert_rdf('', request.body)
    #target_link = request.REQUEST['target_link']
    #extract_alternative_links(target_link)
    return mm_render_to_response(request, context, 'compose_annotation.html')
 def test_insert_rdf(self):
     tmp_g = insert_rdf(rdf_data, 'application/rdf+xml', graph=ANNO_SUBMITTED)
     final_doc = tmp_g.serialize()
     print tmp_g.serialize()
     self.assertFalse('localhost' in final_doc, "Error ingesting rdf")
     self.assertFalse('annoID' in final_doc, "Error ingesting rdf")
     self.assertFalse('bodyID' in final_doc, "Error ingesting rdf")
     self.assertFalse('localhost/bodyID' in final_doc, "Error ingesting rdf")
     self.assertFalse('localhost/annoID' in final_doc, "Error ingesting rdf")            
 def test_insert_jsonld(self):
     tmp_g = insert_rdf(jsonld_data, 'application/ld+json', graph=ANNO_SUBMITTED)
     final_doc = tmp_g.serialize()
     print tmp_g.serialize()        
     self.assertFalse('localhost' in final_doc, "Error ingesting jsonld")
     self.assertFalse('annoID' in final_doc, "Error ingesting jsonld")
     self.assertFalse('bodyID' in final_doc, "Error ingesting jsonld")
     self.assertFalse('localhost/bodyID' in final_doc, "Error ingesting jsonld")
     self.assertFalse('localhost/annoID' in final_doc, "Error ingesting jsonld")  
 def test_insert_turtle(self):
     tmp_g = insert_rdf(turtle_data, 'text/turtle', graph=ANNO_SUBMITTED)
     final_doc = tmp_g.serialize()
     print tmp_g.serialize()
     self.assertFalse('localhost' in final_doc, "Error ingesting turtle")
     self.assertFalse('annoID' in final_doc, "Error ingesting turtle")
     self.assertFalse('bodyID' in final_doc, "Error ingesting turtle")
     self.assertFalse('chnode: <nodeURI/>' in final_doc, "Error ingesting turtle")
     self.assertFalse('chnode:annoID' in final_doc, "Error ingesting turtle")
     self.assertFalse('chnode:bodyID' in final_doc, "Error ingesting turtle")
Exemple #6
0
def insert(request):
    '''
        Inserts in the triplestore a new annotation under the "ANNO_SUBMITTED" graph
    '''
    req_format = _validateFormat(request)
    
    if request.method == 'POST':
        triples = request.body
        tmp_g = insert_rdf(triples, req_format, graph=ANNO_SUBMITTED) 
        return HttpResponse(__serialize(tmp_g, req_format = req_format))
Exemple #7
0
def processPUT(request):
    graph = get_graph_from_request(request)
    payload = request.body
    
    g = None
    query_object = None
    if graph is None:
        g = ConjunctiveGraph(store=CharmeMiddleware.get_store())        
        query_object = '''
            DROP SILENT DEFAULT;
            '''
        query_object = ''
    else:
        g = ConjunctiveGraph(store=CharmeMiddleware.get_store())        
        query_object = '''
            DROP SILENT GRAPH <%s>;
            '''
        query_object = query_object % (graph)        
    g.update(query_object)
    insert_rdf(payload, 
               content_type(request), 
               graph)
    
    return HttpResponse(status = 204) 
Exemple #8
0
def insert(request):
    '''
        Inserts in the triplestore a new annotation under the "ANNO_SUBMITTED" graph
    '''
    try:
        req_format = _validateFormat(request)
        
    except SerializeError as e:
        messages.add_message(request, messages.ERROR, e)
        return mm_render_to_response_error(request, '400.html', 400)
    
    if isPOST(request) or isOPTIONS(request):
        triples = request.body
        tmp_g = insert_rdf(triples, req_format, graph=ANNO_SUBMITTED) 
        ret_format = validateMimeFormat(request)
        if ret_format is None:
            ret_format = req_format
        return HttpResponse(__serialize(tmp_g, req_format = ret_format), content_type=FORMAT_MAP.get(ret_format))
Exemple #9
0
 def test_usecase_1(self):
     tmp_g = insert_rdf(turtle_usecase1, 'text/turtle', graph=ANNO_SUBMITTED)
     print tmp_g.serialize()