1 5 6 package org.joseki.server.processors; 7 8 import org.joseki.server.* ; 9 import org.joseki.vocabulary.JosekiVocab; 11 12 import com.hp.hpl.jena.rdf.model.* ; 13 14 23 public class QueryModelProcessor implements Processor 24 { 25 public QueryModelProcessor() 26 { 27 } 28 29 31 public void init(Resource processor, Resource binding) { } 32 33 36 public Model exec(Request request) throws ExecutionException 37 { 38 ModelSource aModel = request.getModelSource(); 39 QueryProcessor qProc = null ; 40 try 41 { 42 aModel.startOperation(true); 43 Model queryModel = (Model) request.getDataArgs().get(0); 44 45 try 46 { 47 NodeIterator nIter = 49 queryModel.listObjectsOfProperty(JosekiVocab.requestQueryLanguage) ; 50 51 if ( nIter == null || ! nIter.hasNext() ) 53 nIter = queryModel.listObjectsOfProperty(JosekiVocab.queryOperationName) ; 54 55 for (; nIter.hasNext();) 56 { 57 RDFNode n = nIter.nextNode(); 58 if (n instanceof Literal) 59 { 60 String queryLangName = ((Literal) n).getString(); 61 qProc = aModel.getProcessorRegistry().findQueryProcessor(queryLangName); 62 } 63 } 64 } 65 catch (RDFException ex) 66 { 67 aModel.abortOperation(); 68 throw new ExecutionException(ExecutionError.rcArgumentUnreadable, 69 "Failed to extract query language name") ; 70 } 71 if ( qProc == null ) 73 throw new ExecutionException(ExecutionError.rcOperationNotSupported, 74 "No query language found") ; 75 return qProc.exec(request) ; 76 } finally { aModel.endOperation() ; } 77 78 } 80 81 84 public String getInterfaceURI() 85 { 86 return JosekiVocab.opQueryModel ; 87 } 88 89 92 public int argsNeeded() 93 { 94 return Processor.ARGS_ONE ; 95 } 96 97 } 98 99 100 126 | Popular Tags |