private static String guessNamespace(Model temp) { List<Resource> res = temp.listSubjectsWithProperty(RDF.type, OWL.Ontology).toList(); Map<String, Integer> tempMap = new HashMap<String, Integer>(); for (Resource r : res) { String ns = r.getNameSpace(); tempMap.put(ns, (tempMap.containsKey(ns)) ? (tempMap.get(ns) + 1) : 1); } if (tempMap.size() > 0) return (String) sortByValue(tempMap).keySet().toArray()[0]; else return null; }
public Collection<TestGenerator> getTestGeneratorsFromModel(Model model) { return getTestGeneratorsFromResourceList( model.listResourcesWithProperty(RDF.type, RDFUNITv.TestGenerator).toList() ); }
public Collection<Pattern> getPatternsFromModel(Model model) { return getPatternsFromResourceList( model.listResourcesWithProperty(RDF.type, RDFUNITv.Pattern).toList() ); }
public static List<SHResult> getAllTopLevelResults(Model model) { List<SHResult> results = new LinkedList<SHResult>(); for(Resource type : RESULT_TYPES) { for(Resource r : model.listResourcesWithProperty(RDF.type, type).toList()) { if(!model.contains(null, SH.detail, r)) { results.add(r.as(SHResult.class)); } } } return results; }
public Collection<Pattern> getPatternsFromModel(Model model) { return getPatternsFromResourceList( model.listResourcesWithProperty(RDF.type, RDFUNITv.Pattern).toList() ); }
public static List<SHResult> getAllTopLevelResults(Model model) { List<SHResult> results = new LinkedList<SHResult>(); for(Resource type : RESULT_TYPES) { for(Resource r : model.listResourcesWithProperty(RDF.type, type).toList()) { if(!model.contains(null, SH.detail, r)) { results.add(r.as(SHResult.class)); } } } return results; }
public Collection<TestGenerator> getTestGeneratorsFromModel(Model model) { return getTestGeneratorsFromResourceList( model.listResourcesWithProperty(RDF.type, RDFUNITv.TestGenerator).toList() ); }
public Collection<TestCase> getTestCasesFromModel(Model model) { ConcurrentLinkedQueue<TestCase> testCases = new ConcurrentLinkedQueue<>(); model.listResourcesWithProperty(RDF.type, RDFUNITv.ManualTestCase).toList() .parallelStream() .forEach(resource -> testCases.add(ManualTestCaseReader.create().read(resource))); model.listResourcesWithProperty(RDF.type, RDFUNITv.PatternBasedTestCase) .toList() .parallelStream() .forEach(resource -> { try { testCases.add(PatternBasedTestCaseReader.create().read(resource)); } catch (IllegalArgumentException ex) { log.warn("Cannot create PatternBasedTestCase {}", resource.toString(), ex); } }); return ImmutableList.copyOf(testCases); }
public static List<Resource> loadTestSuitesSqcf(String baseFile) { Model testSuitesModel = RDFDataMgr.loadModel(baseFile, Lang.TURTLE); normalizeSqcfModel(testSuitesModel); List<Resource> result = testSuitesModel.listSubjectsWithProperty(SparqlQcVocab.hasTest).toList(); //enrichTestCasesWithLabels(testSuitesModel); return result; }
public static List<Resource> loadTestSuitesSqcf(String baseFile) { Model testSuitesModel = RDFDataMgr.loadModel(baseFile, Lang.TURTLE); normalizeSqcfModel(testSuitesModel); List<Resource> result = testSuitesModel.listSubjectsWithProperty(SparqlQcVocab.hasTest).toList(); //enrichTestCasesWithLabels(testSuitesModel); return result; }
public static List<Resource> loadTestSuites(Model testSuitesModel, String baseFile) throws IOException { List<Resource> result = testSuitesModel .listResourcesWithProperty(RDF.type, SparqlQcVocab.TestSuite).toList(); for (Resource testSuite : result) { loadTestSuite(testSuite, baseFile); } enrichTestCasesWithLabels(testSuitesModel); return result; }
public static List<Resource> loadTestSuites(Model testSuitesModel, String baseFile) throws IOException { List<Resource> result = testSuitesModel .listResourcesWithProperty(RDF.type, SparqlQcVocab.TestSuite).toList(); for (Resource testSuite : result) { loadTestSuite(testSuite, baseFile); } enrichTestCasesWithLabels(testSuitesModel); return result; }
public static boolean isCompatibleWith(Resource platform) { if(get().isCompatibleWithExactly(platform)) { return true; } // Warning: this does assume that no loops exist for(Resource include : platform.getModel().listSubjectsWithProperty(DASH.includedExecutionPlatform, platform).toList()) { if(isCompatibleWith(include)) { return true; } } return false; }
public static boolean isCompatibleWith(Resource platform) { if(get().isCompatibleWithExactly(platform)) { return true; } // Warning: this does assume that no loops exist for(Resource include : platform.getModel().listSubjectsWithProperty(DASH.includedExecutionPlatform, platform).toList()) { if(isCompatibleWith(include)) { return true; } } return false; }
public static void addDetails(Resource parentResult, Model nestedResults) { if(!nestedResults.isEmpty()) { parentResult.getModel().add(nestedResults); for(Resource type : SHACLUtil.RESULT_TYPES) { for(Resource nestedResult : nestedResults.listSubjectsWithProperty(RDF.type, type).toList()) { if(!parentResult.getModel().contains(null, SH.detail, nestedResult)) { parentResult.addProperty(SH.detail, nestedResult); } } } } } }
public void testListSubjects() { fill(model); final List<Resource> L = model.listSubjects().toList(); Assert.assertEquals(TestObjects.numberSubjects, L.size()); final Set<Resource> wanted = subjectSet(TestObjects.numberSubjects); Assert.assertEquals(wanted, GraphTestBase.iteratorToSet(L.iterator())); }
public static void addDetails(Resource parentResult, Model nestedResults) { if(!nestedResults.isEmpty()) { parentResult.getModel().add(nestedResults); for(Resource type : SHACLUtil.RESULT_TYPES) { for(Resource nestedResult : nestedResults.listSubjectsWithProperty(RDF.type, type).toList()) { if(!parentResult.getModel().contains(null, SH.detail, nestedResult)) { parentResult.addProperty(SH.detail, nestedResult); } } } } } }
public void testListSubjects() { fill(model); final List<Resource> L = model.listSubjects().toList(); Assert.assertEquals(TestObjects.numberSubjects, L.size()); final Set<Resource> wanted = subjectSet(TestObjects.numberSubjects); Assert.assertEquals(wanted, GraphTestBase.iteratorToSet(L.iterator())); }
public static void main(String[] args) throws Exception { CommandLine commandLine = parseArguments(args); if (commandLine.hasOption("h")) { displayHelp(); System.exit(0); } RdfReader input = getInputReader(commandLine); RdfWriter output = getOutputWriter(commandLine); Model model = ModelFactory.createDefaultModel(); for (Resource testExecutionResource: input.read().listResourcesWithProperty(RDF.type, RDFUNITv.TestExecution).toList()) { TestExecution testExecution = TestExecutionReader.create().read(testExecutionResource); Collection<QualityMeasure> report = new DqvReport(testExecution, MetricMapper.createDefault()).getQualityMeasures(); DqvReportWriter.create(report).write(model); } output.write(model); }
@Test public void retrieveSubjectsOfBnode() { final String NS = "urn:test:"; final Resource s = ResourceFactory.createResource(NS + "s"); final Property p = ResourceFactory.createProperty(NS + "p"); final Property q = ResourceFactory.createProperty(NS + "q"); final Resource o = ResourceFactory.createResource(); final OntModel pelletModel = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); pelletModel.add(q, RDFS.subPropertyOf, p); pelletModel.add(s, q, o); assertEquals(Collections.singletonList(s), pelletModel.listSubjectsWithProperty(p, o).toList()); }