@Override public SDBConnectionDesc open(Assembler a, Resource root, Mode mode) { SDBConnectionDesc sDesc = SDBConnectionDesc.blank() ; sDesc.setType( GraphUtils.getStringValue(root, AssemblerVocab.pSDBtype) ) ; sDesc.setHost( GraphUtils.getStringValue(root, AssemblerVocab.pSDBhost) ) ; sDesc.setName( GraphUtils.getStringValue(root, AssemblerVocab.pSDBname) ) ; sDesc.setUser( GraphUtils.getStringValue(root, AssemblerVocab.pSDBuser) ) ; sDesc.setPassword( GraphUtils.getStringValue(root, AssemblerVocab.pSDBpassword) ) ; sDesc.setDriver( GraphUtils.getStringValue(root, AssemblerVocab.pDriver) ) ; sDesc.setJdbcURL( GraphUtils.getStringValue(root, AssemblerVocab.pJDBC) ) ; sDesc.setPoolSize( GraphUtils.getStringValue(root, AssemblerVocab.pPoolSize) ) ; sDesc.setLabel( GraphUtils.getStringValue(root, RDFS.label) ) ; if ( sDesc.getUser() == null ) sDesc.setUser(Access.getUser()) ; if ( sDesc.getPassword() == null ) sDesc.setPassword(Access.getPassword()) ; return sDesc ; } }
@Override public Model open(Assembler a, Resource root, Mode mode) { String file = GraphUtils.getStringValue(root, HDTJenaConstants.pFileName) ; boolean loadInMemory = Boolean.parseBoolean(GraphUtils.getStringValue(root, HDTJenaConstants.pKeepInMemory)); try { // FIXME: Read more properties. Cache config? HDT hdt; if(loadInMemory) { hdt = HDTManager.loadIndexedHDT(file, null); } else { hdt = HDTManager.mapIndexedHDT(file, null); } HDTGraph graph = new HDTGraph(hdt); return ModelFactory.createModelForGraph(graph); } catch (IOException e) { log.error("Error reading HDT file: {}", file, e); throw new AssemblerException(root, "Error reading HDT file: "+file+" / "+e.toString()); } }
String dbType = GraphUtils.getStringValue(root, AssemblerVocab.pSDBtype) ;
sdbConnDesc = (SDBConnectionDesc)a.open(c) ; String layoutName = GraphUtils.getStringValue(root, AssemblerVocab.pLayout) ; String dbType = chooseDBType(root, sdbConnDesc) ; for ( Resource r : x ) String n = GraphUtils.getStringValue(r, AssemblerVocab.featureNameProperty) ; String v = GraphUtils.getStringValue(r, AssemblerVocab.featureValueProperty) ; Feature f = new Feature(new Feature.Name(n), v) ; fSet.addFeature(f) ; String engineName = GraphUtils.getStringValue(root, AssemblerVocab.pMySQLEngine) ; storeDesc.engineType = null ; if ( engineName != null ) String storageType = GraphUtils.getStringValue(root, AssemblerVocab.pStorageType) ; if ( storageType != null ) try { storeDesc.storageType= SAPStorageType.convert(storageType) ; }
String main = GraphUtils.getStringValue(root, AssemblerVocab.pMain) ; if ( main == null ) main = GraphUtils.getStringValue(root, AssemblerVocab.pClassname) ; cd.setCmd(main) ; String name = GraphUtils.getStringValue(entry, AssemblerVocab.pArgName) ; String value = GraphUtils.getStringValue(entry, AssemblerVocab.pArgValue) ; if ( value == null ) throw new CommandAssemblerException(entry, "Strange entry: "+entry) ;
@Override public Object open(Assembler a, Resource cmd, Mode mode) { if ( cmd.hasProperty(AssemblerVocab.pQueryFile) && cmd.hasProperty(AssemblerVocab.pQueryString) ) throw new CommandAssemblerException(cmd, "Both "+FmtUtils.stringForResource(AssemblerVocab.pQueryString)+" and "+FmtUtils.stringForResource(AssemblerVocab.pQueryFile)+" present") ; if ( ! cmd.hasProperty(AssemblerVocab.pQueryFile) && ! cmd.hasProperty(AssemblerVocab.pQueryString) ) throw new CommandAssemblerException(cmd, "No queryString or queryFile present") ; String queryString = GraphUtils.getStringValue(cmd, AssemblerVocab.pQueryString) ; if ( queryString == null ) { String filename = GraphUtils.getStringValue(cmd, AssemblerVocab.pQueryFile) ; queryString = FileManager.get().readWholeFileAsUTF8(filename) ; } // Base?? // Convert to another exception? return QueryFactory.create(queryString) ; } }
@Override public Object open(Assembler a, Resource root, Mode mode) { // Query Resource queryDesc = getUniqueResource(root, AssemblerVocab.pQuery) ; Query query = (Query)a.open(a, queryDesc, mode) ; // Dataset Resource datasetDesc = getUniqueResource(root, AssemblerVocab.pDataset) ; Dataset dataset = (Dataset)a.open(a, datasetDesc, mode) ; // Output format String s = GraphUtils.getStringValue(root, AssemblerVocab.pOutputFormat) ; if ( s == null ) s = "text" ; ResultsFormat format = ResultsFormat.lookup(s) ; QueryExecution qExec = QueryExecutionFactory.create(query, dataset) ; return new QExec(query, qExec, format) ; } }
/** Format:: access:entry [ :user "user2" ; :graphs (<http://host/graphname3> ) ] */ private void parseStruct(Multimap<String, Node> map, Resource root, Resource r) { if ( ! GraphUtils.exactlyOneProperty(r, VocabSecurity.pUser) ) throw new AssemblerException(root, "Expected exactly one access:user property for "+r); if ( ! GraphUtils.exactlyOneProperty(r, VocabSecurity.pGraphs) ) throw new AssemblerException(root, "Expected exactly one access:graphs property for "+r); String user = GraphUtils.getStringValue(r, VocabSecurity.pUser); r.listProperties(VocabSecurity.pGraphs).mapWith(s->s.getObject()).forEachRemaining(x->{ List<Node> graphs = new ArrayList<>(); if ( x.isURIResource() ) { //System.out.printf("S: user %s : access : %s\n", user, x.asNode()); graphs.add(x.asNode()); } else { // List? RDFList list = x.as(RDFList.class); list.iterator().forEachRemaining(rn->{ graphs.add(rn.asNode()); }); } accessEntries(root, map, user, graphs); }); }
String locationDir = getStringValue(root, pLocation) ; Resource dataset = getResourceValue(root, pDataset) ;
String locationDir = getStringValue(root, pLocation) ; Resource dataset = getResourceValue(root, pDataset) ;
static Dataset make(Resource root) { if ( !exactlyOneProperty(root, pLocation) ) throw new AssemblerException(root, "No location given") ; String dir = getStringValue(root, pLocation) ; Location loc = Location.create(dir) ; DatasetGraph dsg = TDBFactory.createDatasetGraph(loc) ; if ( root.hasProperty(pUnionDefaultGraph) ) { Node b = root.getProperty(pUnionDefaultGraph).getObject().asNode() ; NodeValue nv = NodeValue.makeNode(b) ; if ( nv.isBoolean() ) dsg.getContext().set(TDB.symUnionDefaultGraph, nv.getBoolean()) ; else Log.warn(DatasetAssemblerTDB.class, "Failed to recognize value for union graph setting (ignored): " + b) ; } /* <r> rdf:type tdb:DatasetTDB ; tdb:location "dir" ; //ja:context [ ja:cxtName "arq:queryTimeout" ; ja:cxtValue "10000" ] ; tdb:unionGraph true ; # or "true" */ AssemblerUtils.setContext(root, dsg.getContext()); return DatasetFactory.wrap(dsg) ; }
static Dataset make(Resource root) { if ( !exactlyOneProperty(root, pLocation) ) throw new AssemblerException(root, "No location given") ; String dir = getStringValue(root, pLocation) ; Location loc = Location.create(dir) ; DatasetGraph dsg = DatabaseMgr.connectDatasetGraph(loc) ; if ( root.hasProperty(pUnionDefaultGraph) ) { Node b = root.getProperty(pUnionDefaultGraph).getObject().asNode() ; NodeValue nv = NodeValue.makeNode(b) ; if ( nv.isBoolean() ) dsg.getContext().set(TDB2.symUnionDefaultGraph, nv.getBoolean()) ; else Log.warn(DatasetAssemblerTDB.class, "Failed to recognize value for union graph setting (ignored): " + b) ; } /* <r> rdf:type tdb:DatasetTDB2 ; tdb:location "dir" ; //ja:context [ ja:cxtName "arq:queryTimeout" ; ja:cxtValue "10000" ] ; tdb:unionGraph true ; # or "true" */ AssemblerUtils.setContext(root, dsg.getContext()); return DatasetFactory.wrap(dsg) ; }