public void setContentPropertyStringValue(NeedContentPropertyType type, Property p, String value) { Collection<Resource> nodes = getContentNodes(type); for (Resource node : nodes) { node.removeAll(p); node.addLiteral(p, value); } }
/** * @param url the sourceUrl to set */ public void setSeeAlso(String[] url) { this.seeAlso = url; if (this.exceptionNode != null) { Property seeAlsoPropery = model.createProperty(SpdxRdfConstants.RDFS_NAMESPACE, SpdxRdfConstants.RDFS_PROP_SEE_ALSO); this.resource.removeAll(seeAlsoPropery); if (url != null) { for (int i = 0; i < url.length; i++) { this.resource.addProperty(seeAlsoPropery, url[i]); } } } }
/** * @param url the sourceUrl to set */ public void setSeeAlso(String[] url) { this.seeAlso = url; if (this.exceptionNode != null) { Property seeAlsoPropery = model.createProperty(SpdxRdfConstants.RDFS_NAMESPACE, SpdxRdfConstants.RDFS_PROP_SEE_ALSO); this.resource.removeAll(seeAlsoPropery); if (url != null) { for (int i = 0; i < url.length; i++) { this.resource.addProperty(seeAlsoPropery, url[i]); } } } }
public void setNeedState(NeedState state) { Resource stateRes = NeedState.ACTIVE.equals(state) ? WON.NEED_STATE_ACTIVE : WON.NEED_STATE_INACTIVE; Resource need = getNeedNode(NeedGraphType.SYSINFO); need.removeAll(WON.IS_IN_STATE); need.addProperty(WON.IS_IN_STATE, stateRes); }
public static RDFNode resolveIoResourceRef(Resource testCase, Property property, // String basePath, Map<String, RDFNode> cache, BiFunction<String, Model, RDFNode> rdfizer) { RDFNode result; Statement stmt = testCase.getProperty(property); if (stmt != null) { String str = stmt.getString(); // String filePath = basePath + "/" + str; // Resource ioResource = new ClassPathResource(filoPath); RDFNode res = cache.computeIfAbsent(str, (ref) -> { RDFNode r = rdfizer.apply(str, testCase.getModel()); // processQuery(ioResource, // testCase.getModel()); return r; }); testCase.removeAll(property); testCase.addProperty(property, res); result = res; } else { result = null; } return result; }
public void setShapesGraphReference(URI shapesGraphReference) { createContentNodeIfNonExist(NeedContentPropertyType.GOAL); Collection<Resource> nodes = getContentNodes(NeedContentPropertyType.GOAL); for (Resource node : nodes) { node.removeAll(WON.HAS_SHAPES_GRAPH); node.addProperty(WON.HAS_SHAPES_GRAPH, getNeedModel().getResource(shapesGraphReference.toString())); } }
public static RDFNode resolveIoResourceRef(Resource testCase, Property property, // String basePath, Map<String, RDFNode> cache, BiFunction<String, Model, RDFNode> rdfizer) { RDFNode result; Statement stmt = testCase.getProperty(property); if (stmt != null) { String str = stmt.getString(); // String filePath = basePath + "/" + str; // Resource ioResource = new ClassPathResource(filoPath); RDFNode res = cache.computeIfAbsent(str, (ref) -> { RDFNode r = rdfizer.apply(str, testCase.getModel()); // processQuery(ioResource, // testCase.getModel()); return r; }); testCase.removeAll(property); testCase.addProperty(property, res); result = res; } else { result = null; } return result; }
public StateBuilder replaceProperty(Property property, RDFNode value) { if (property == null) throw new IllegalArgumentException("Property cannot be null"); getResource().removeAll(property); getUriBuilder().replaceQueryParam(property.getLocalName(), (Object[])null); if (value != null) property(property, value); return this; }
public void setConnectionContainerUri(String containerUri) { Resource container = getSysInfoModel().createResource(containerUri); Resource need = getNeedNode(NeedGraphType.SYSINFO); need.removeAll(WON.HAS_CONNECTIONS); need.addProperty(WON.HAS_CONNECTIONS, container); }
public void setWonNodeUri(String nodeUri) { Resource node = getSysInfoModel().createResource(nodeUri); Resource need = getNeedNode(NeedGraphType.SYSINFO); need.removeAll(WON.HAS_WON_NODE); need.addProperty(WON.HAS_WON_NODE, node); }
public void updateConforms() { boolean conforms = true; StmtIterator it = report.listProperties(SH.result); while(it.hasNext()) { Statement s = it.next(); if(s.getResource().hasProperty(RDF.type, SH.ValidationResult)) { conforms = false; it.close(); break; } } report.removeAll(SH.conforms); report.addProperty(SH.conforms, conforms ? JenaDatatypes.TRUE : JenaDatatypes.FALSE); }
public void updateConforms() { boolean conforms = true; StmtIterator it = report.listProperties(SH.result); while(it.hasNext()) { Statement s = it.next(); if(s.getResource().hasProperty(RDF.type, SH.ValidationResult)) { conforms = false; it.close(); break; } } report.removeAll(SH.conforms); report.addProperty(SH.conforms, conforms ? JenaDatatypes.TRUE : JenaDatatypes.FALSE); }
public void testRemoveAllBoring() { final Model m1 = ModelHelper.modelWithStatements(this, "x P a; y Q b"); final Model m2 = ModelHelper.modelWithStatements(this, "x P a; y Q b"); ModelHelper.resource(m2, "x").removeAll(ModelHelper.property(m2, "Z")); ModelHelper.assertIsoModels("m2 should be unchanged", m1, m2); }
public void testRemoveAllBoring() { final Model m1 = ModelHelper.modelWithStatements(this, "x P a; y Q b"); final Model m2 = ModelHelper.modelWithStatements(this, "x P a; y Q b"); ModelHelper.resource(m2, "x").removeAll(ModelHelper.property(m2, "Z")); ModelHelper.assertIsoModels("m2 should be unchanged", m1, m2); }
public void testRemoveAllRemoves() { final String ps = "x P a; x P b", rest = "x Q c; y P a; y Q b"; final Model m = ModelHelper.modelWithStatements(this, ps + "; " + rest); final Resource r = ModelHelper.resource(m, "x"); final Resource r2 = r.removeAll(ModelHelper.property(m, "P")); Assert.assertSame("removeAll should deliver its receiver", r, r2); ModelHelper.assertIsoModels("x's P-values should go", ModelHelper.modelWithStatements(this, rest), m); }
public void testRemoveAllRemoves() { final String ps = "x P a; x P b", rest = "x Q c; y P a; y Q b"; final Model m = ModelHelper.modelWithStatements(this, ps + "; " + rest); final Resource r = ModelHelper.resource(m, "x"); final Resource r2 = r.removeAll(ModelHelper.property(m, "P")); Assert.assertSame("removeAll should deliver its receiver", r, r2); ModelHelper.assertIsoModels("x's P-values should go", ModelHelper.modelWithStatements(this, rest), m); }
/** * Listeners on deductions graph should be preserved across rebind operations */ public void testDeductionListener() { final String NS = PrintUtil.egNS; // Data: (eg:i eg:p 'foo') Model base = ModelFactory.createDefaultModel(); Resource i = base.createResource(NS + "i"); Property p = base.createProperty(NS + "p"); i.addProperty(p, "foo"); // Inf model List<Rule> rules = Rule.parseRules( "(?x eg:p ?y) -> (?x eg:q ?y). " ); GenericRuleReasoner reasoner = new GenericRuleReasoner(rules); InfModel infModel = ModelFactory.createInfModel(reasoner, base); TestListener listener = new TestListener(); infModel.getDeductionsModel().register(listener); infModel.rebind(); infModel.prepare(); assertEquals("foo", listener.getLastValue()); i.removeAll(p); i.addProperty(p, "bar"); infModel.rebind(); infModel.prepare(); assertEquals("bar", listener.getLastValue()); }
/** * Test remove operations on an RDFS reasoner instance. * This is an example to test that rebing is invoked correctly rather * than an RDFS-specific test. */ public void testRDFSRemove() { InfModel m = ModelFactory.createRDFSModel(ModelFactory.createDefaultModel()); String NS = PrintUtil.egNS; Property p = m.createProperty(NS, "p"); Resource D = m.createResource(NS + "D"); Resource i = m.createResource(NS + "i"); Resource c = m.createResource(NS + "c"); Resource d = m.createResource(NS + "d"); p.addProperty(RDFS.domain, D); i.addProperty(p, c); i.addProperty(p, d); TestUtil.assertIteratorValues(this, i.listProperties(), new Object[] { m.createStatement(i, p, c), m.createStatement(i, p, d), m.createStatement(i, RDF.type, D), m.createStatement(i, RDF.type, RDFS.Resource), }); i.removeAll(p); TestUtil.assertIteratorValues(this, i.listProperties(), new Object[] { }); }
/** * Listeners on deductions graph should be preserved across rebind operations */ public void testDeductionListener() { final String NS = PrintUtil.egNS; // Data: (eg:i eg:p 'foo') Model base = ModelFactory.createDefaultModel(); Resource i = base.createResource(NS + "i"); Property p = base.createProperty(NS + "p"); i.addProperty(p, "foo"); // Inf model List<Rule> rules = Rule.parseRules( "(?x eg:p ?y) -> (?x eg:q ?y). " ); GenericRuleReasoner reasoner = new GenericRuleReasoner(rules); InfModel infModel = ModelFactory.createInfModel(reasoner, base); TestListener listener = new TestListener(); infModel.getDeductionsModel().register(listener); infModel.rebind(); infModel.prepare(); assertEquals("foo", listener.getLastValue()); i.removeAll(p); i.addProperty(p, "bar"); infModel.rebind(); infModel.prepare(); assertEquals("bar", listener.getLastValue()); }
/** * Test remove operations on an RDFS reasoner instance. * This is an example to test that rebing is invoked correctly rather * than an RDFS-specific test. */ public void testRDFSRemove() { InfModel m = ModelFactory.createRDFSModel(ModelFactory.createDefaultModel()); String NS = PrintUtil.egNS; Property p = m.createProperty(NS, "p"); Resource D = m.createResource(NS + "D"); Resource i = m.createResource(NS + "i"); Resource c = m.createResource(NS + "c"); Resource d = m.createResource(NS + "d"); p.addProperty(RDFS.domain, D); i.addProperty(p, c); i.addProperty(p, d); TestUtil.assertIteratorValues(this, i.listProperties(), new Object[] { m.createStatement(i, p, c), m.createStatement(i, p, d), m.createStatement(i, RDF.type, D), m.createStatement(i, RDF.type, RDFS.Resource), }); i.removeAll(p); TestUtil.assertIteratorValues(this, i.listProperties(), new Object[] { }); }