public Model getObservationActivity() { Model activity = ModelFactory.createDefaultModel(); Resource mp = ResourceCommons.generateURI(); activity.add(mp, RDF.type, DAQ.MetricProfile); activity.add(mp, DAQ.totalDatasetTriples, ResourceCommons.generateTypeLiteral(count)); return activity; }
public ProblemReport(Resource computedOn, File file) throws IOException{ reportURI = ResourceCommons.generateURI(); m.add(new StatementImpl(reportURI, RDF.type, QPRO.QualityReport)); m.add(new StatementImpl(reportURI, QPRO.computedOn, computedOn)); this.serialisationFile = file; this.serialisationFile.createNewFile(); this.serialisationOutput = new DataOutputStream(new BufferedOutputStream( Files.newOutputStream( Paths.get(this.serialisationFile.getPath()), StandardOpenOption.APPEND ) )); }
categoryURI = this.categoryExists(categoryType); if (categoryURI == null){ categoryURI = ResourceCommons.generateURI(); this.metadata.add(categoryURI, RDF.type, categoryType); dimensionURI = this.dimensionExists(dimensionType); if (dimensionURI == null){ dimensionURI = ResourceCommons.generateURI(); Property dimensionProperty = this.metadata.createProperty(DAQHelper.getPropertyResource(dimensionType).getURI()); this.metadata.add(categoryURI, dimensionProperty, dimensionURI); metricURI = this.metricExists(metricType); if (metricURI == null){ metricURI = ResourceCommons.generateURI(); Property metricProperty = this.metadata.createProperty(DAQHelper.getPropertyResource(metricType).getURI()); this.metadata.add(dimensionURI, metricProperty, metricURI); Resource observationURI = ResourceCommons.generateURI(); this.metadata.add(metricURI, DAQ.hasObservation, observationURI); this.metadata.add(observationURI, DAQ.metric, metricURI); this.metadata.add(observationURI, DAQ.computedOn, this.computedOn); this.metadata.add(observationURI, DAQ.value, ResourceCommons.generateTypeLiteral(metric.metricValue())); this.metadata.add(observationURI, DAQ.isEstimate, ResourceCommons.generateBooleanTypeLiteral(metric.isEstimate())); ResIterator itr = obsActivity.listSubjectsWithProperty(RDF.type, ResourceCommons.asRDFNode(DAQ.MetricProfile.asNode())); Resource subj = itr.nextResource();
@Override public void addProblem(Quad problematicElement) { this.isEmpty = false; Resource bNode = ResourceCommons.generateRDFBlankNode().asResource(); Quad q = problematicElement; this._m.add(new StatementImpl(bNode, RDF.type, RDF.Statement)); this._m.add(new StatementImpl(bNode, RDF.subject, ResourceCommons.asRDFNode(q.getSubject()))); this._m.add(new StatementImpl(bNode, RDF.predicate, ResourceCommons.asRDFNode(q.getPredicate()))); this._m.add(new StatementImpl(bNode, RDF.object, ResourceCommons.asRDFNode(q.getObject()))); if (q.getGraph() != null){ _m.add(new StatementImpl(bNode, QPRO.inGraph, ResourceCommons.asRDFNode(q.getGraph()))); } _m.add(new StatementImpl(this.problemList, RDF.li(seqCounter), ResourceCommons.asRDFNode(bNode.asNode()))); seqCounter++; totalTriples+=5; if (this.totalTriples >= MAX_TRIPLES) { this.commit(); } }
Resource bn = ResourceCommons.generateRDFBlankNode().asResource(); returnModel.add(bn, LMI.javaPackageName, returnModel.createLiteral(jpn)); returnModel.add(bn, RDFS.label, returnModel.createLiteral(label));
public static Set<ComparingDatasetObject> compareDatasetsOnMetric(Set<String> datasetPLDs, String metric) { Resource metricResource = ResourceCommons.toResource(metric); Set<ComparingDatasetObject> cdoSet = new HashSet<ComparingDatasetObject>(); datasetPLDs.forEach(pld -> { String graphName = graphs.get(StringUtils.strippedURI(pld)); Model qualityMetadata = d.getNamedModel(graphName); ObservationObject obs = new ObservationObject(ObservationHelper.getLatestObservation(ObservationHelper.extractObservations(qualityMetadata, metricResource))); ComparingDatasetObject datasetObject = new ComparingDatasetObject(); datasetObject.setMetric(metric); datasetObject.setObservation(obs); datasetObject.setName(pld); cdoSet.add(datasetObject); }); return cdoSet; } }
@Override public void addProblem(Quad problematicElement) { dataset.begin(ReadWrite.WRITE) ; try { this.isEmpty = false; Model m = dataset.getNamedModel(this.namedGraph); Resource bNode = ResourceCommons.generateRDFBlankNode().asResource(); Quad q = problematicElement; m.add(new StatementImpl(bNode, RDF.type, RDF.Statement)); m.add(new StatementImpl(bNode, RDF.subject, ResourceCommons.asRDFNode(q.getSubject()))); m.add(new StatementImpl(bNode, RDF.predicate, ResourceCommons.asRDFNode(q.getPredicate()))); m.add(new StatementImpl(bNode, RDF.object, ResourceCommons.asRDFNode(q.getObject()))); if (q.getGraph() != null){ m.add(new StatementImpl(bNode, QPRO.inGraph, ResourceCommons.asRDFNode(q.getGraph()))); } m.add(new StatementImpl(this.problemList, RDF.li(seqCounter), ResourceCommons.asRDFNode(bNode.asNode()))); seqCounter++; dataset.commit(); } finally { dataset.end() ; } }
@Deprecated public ProblemReport(Resource computedOn){ reportURI = ResourceCommons.generateURI(); m.add(new StatementImpl(reportURI, RDF.type, QPRO.QualityReport)); m.add(new StatementImpl(reportURI, QPRO.computedOn, computedOn)); }
@Override public void addProblem(Resource problematicElement) { this.isEmpty = false; this._m.add(new StatementImpl(this.problemList, RDF.li(seqCounter), ResourceCommons.asRDFNode(problematicElement.asNode()))); seqCounter++; totalTriples++; if (this.totalTriples >= MAX_TRIPLES) { this.commit(); } }
private static void execute(int size, Resource metric, int itr) { for (int cnt = 0; cnt < itr; cnt++) { ProblemCollection<Quad> problemCollection = new ProblemCollectionQuad(metric); long start = System.nanoTime(); for (int i = 0; i < size; i++) { Quad q = new Quad(null, new Triple(ResourceCommons.generateURI().asNode(), ResourceCommons.generateURI().asNode(), ResourceCommons.generateURI().asNode())); problemCollection.addProblem(q); } ((ProblemCollectionQuad)problemCollection).commit(); long write = System.nanoTime() - start; problemCollection.cleanup(); System.gc(); System.out.println(String.format("[%s] %s Write took %s ms, Write/tp :%s", cnt, problemCollection.getClass().getName(), TimeUnit.NANOSECONDS.toMillis(write), TimeUnit.SECONDS.toNanos(size) / write)); } }
public void sniff(Quad quad){ counter++; if (quad.getGraph() != null){ if (this._temp != null && this._temp.getGraphURI() != null){ if (quad.getGraph().getURI().equals(this._temp.getGraphURI().getURI())){ this._temp.addTriplesToMetadata(quad); } } else { if (this.temporaryResources.containsKey(quad.getGraph().toString())){ Model m = this.temporaryResources.get(quad.getGraph().toString()); m.add(ResourceCommons.asRDFNode(quad.getSubject()).asResource(), m.createProperty(quad.getPredicate().getURI()), ResourceCommons.asRDFNode(quad.getObject())); this.temporaryResources.put(quad.getGraph().toString(), m); } else { Model m = ModelFactory.createDefaultModel(); m.add(ResourceCommons.asRDFNode(quad.getSubject()).asResource(), m.createProperty(quad.getPredicate().getURI()), ResourceCommons.asRDFNode(quad.getObject())); this.temporaryResources.put(quad.getGraph().toString(), m); } } } if (quad.getObject().isURI()){ if (quad.getObject().getURI().equals(DAQ.QualityGraph.getURI())){ this._temp = new TemporaryGraphMetadataCacheObject(ResourceCommons.asRDFNode(quad.getObject()).asResource()); } } }
public ProblemCollection(Resource metricURI) { logger.debug("is HPC Enabled? {}", isHPCEnabled); if (isHPCEnabled) { logger.debug("Creating in-memory problem collection files"); dataset = DatasetFactory.createTxnMem(); } else { StoreParams custom64BitParams = StoreParamsBuilder.create() .fileMode(FileMode.mapped) .node2NodeIdCacheSize(10000000) .nodeId2NodeCacheSize(10000000) .build(); location = Location.create(TDB_DIRECTORY); logger.info("TDB Location is {} for Metric {}", TDB_DIRECTORY, metricURI.getURI()); logger.debug("Creating TDB problem collection files"); if (SystemTDB.is64bitSystem) { TDBFactory.setup(location, custom64BitParams) ; dataset = TDBFactory.createDataset(location); } else { dataset = TDBFactory.createDataset(location); } } this.problemURI = ResourceCommons.generateURI(); // TODO: change to something more meaningful this.metricURI = metricURI; this.namedGraph = ResourceCommons.generateURI().toString(); }
/** * Since each assessed dataset should have only one quality * metadata graph, we need to check if it already exists * in the cache. * * @param datasetURI - The assessed dataset * @param sparqlEndpoint - True if the datasetURI is a sparql endpoint. */ public QualityMetadata(Resource datasetURI, boolean sparqlEndpoint){ this.computedOn = datasetURI; if (sparqlEndpoint){ //TODO:sparqlendpoint //query, do not check in cache as it would not be feasible to store sparql endpoint results in cache //if exists set qualityGraphURI } if (cacheMgr.existsInCache(cacheName, datasetURI)){ _temp = (TemporaryGraphMetadataCacheObject) cacheMgr.getFromCache(cacheName, datasetURI); this.qualityGraph = _temp.getGraphURI(); this.metadata.add(_temp.getMetadataModel()); this.metadataPresent = true; } else { this.qualityGraph = ResourceCommons.generateURI(); } }
public ProblemReportTDB(Resource computedOn){ TDB.sync(dataset); dataset.begin(ReadWrite.WRITE); reportURI = ResourceCommons.generateURI(); m.add(new StatementImpl(reportURI, RDF.type, QPRO.QualityReport)); m.add(new StatementImpl(reportURI, QPRO.computedOn, computedOn)); }
/** * Used when the assessed dataset is stored in memory * (Jena Dataset), * * @param dataset - Assessed Jena Dataset * @param computedOn - The resource indicating the metrics computed on */ public QualityMetadata(Dataset dataset, Resource computedOn){ this.computedOn = computedOn; ResIterator qualityGraphRes = dataset.getDefaultModel().listSubjectsWithProperty(RDF.type, DAQ.QualityGraph); if (qualityGraphRes.hasNext()){ this.qualityGraph = qualityGraphRes.next(); this.metadata.add(dataset.getNamedModel(this.qualityGraph.getURI())); this.metadataPresent = true; } else { this.qualityGraph = ResourceCommons.generateURI(); } }