private static Property configTextQueryProperty( Resource endpoint, Property ifUnspecified ) { Resource tqp = endpoint.getPropertyResourceValue( ELDA_API.textQueryProperty ); return tqp == null ? ifUnspecified : tqp.as(Property.class); }
private static Property configTextContentProperty( Resource endpoint, Property ifUnspecified ) { Resource tcp = endpoint.getPropertyResourceValue( ELDA_API.textContentProperty ); return tcp == null ? ifUnspecified : tcp.as(Property.class); }
private static AnyList configTextSearchOperand(Resource endpoint, AnyList ifUnspecified) { Resource tso = endpoint.getPropertyResourceValue( ELDA_API.textSearchOperand ); return tso == null ? ifUnspecified : convertList(tso); }
@Test( groups = {MUST}, description = "Each LDP Direct Container representation must contain exactly " + "one triple whose subject is the LDPC URI, and whose predicate " + "is either ldp:hasMemberRelation or ldp:isMemberOfRelation. " + "The object of the triple is constrained by other sections, " + "such as ldp:hasMemberRelation or ldp:isMemberOfRelation, " + "based on the membership triple pattern used by the container.") @SpecTest( specRefUri = LdpTestSuite.SPEC_URI + "#ldpdc-containtriples", testMethod = METHOD.AUTOMATED, approval = STATUS.WG_APPROVED) public void testMemberRelationOrIsMemberOfRelationTripleExists() throws URISyntaxException { Model containerModel = getAsModel(directContainer); Resource container = containerModel.getResource(directContainer); Resource hasMemberRelation = container.getPropertyResourceValue(containerModel.createProperty(LDP.hasMemberRelation.stringValue())); Resource isMemberOfRelation = container.getPropertyResourceValue(containerModel.createProperty(LDP.isMemberOfRelation.stringValue())); if (hasMemberRelation == null) { assertNotNull(isMemberOfRelation, "LDP DirectContainer must have either ldp:hasMemberRelation or ldp:isMemberOfRelation"); } else { assertNull(isMemberOfRelation, "LDP DirectContainer cannot have both ldp:hasMemberRelation and ldp:isMemberOfRelation"); } }
@Test( groups = {MUST}, description = "Each LDP Direct Container representation MUST contain exactly " + "one triple whose subject is the LDPC URI, whose predicate is the " + "ldp:membershipResource, and whose object is the LDPC's membership-" + "constant-URI. Commonly the LDPC's URI is the membership-constant-URI," + " but LDP does not require this.") @SpecTest( specRefUri = LdpTestSuite.SPEC_URI + "#ldpdc-containres", testMethod = METHOD.AUTOMATED, approval = STATUS.WG_APPROVED) public void testMemberResourceTriple() throws URISyntaxException { Model containerModel = getAsModel(directContainer); Resource container = containerModel.getResource(directContainer); Resource membershipResource = container.getPropertyResourceValue(containerModel.createProperty(LDP.membershipResource.stringValue())); assertNotNull(membershipResource); }
private boolean hasMembershipTriples(Model containerModel) { Resource container = containerModel.getResource(directContainer); Resource membershipResource = container.getPropertyResourceValue(containerModel.createProperty(LDP.membershipResource.stringValue())); Resource hasMemberRelation = container.getPropertyResourceValue(containerModel.createProperty(LDP.hasMemberRelation.stringValue())); assertNotNull(membershipResource, MSG_MBRRES_NOTFOUND); // First verify the membership triples exist if (hasMemberRelation != null) { return membershipResource.hasProperty(containerModel.createProperty(hasMemberRelation.getURI())); } // Not if membership triple is not of form: (container, membership predicate, member), it may be the inverse. Resource isMemberOfRelation = container.getPropertyResourceValue(containerModel.createProperty(LDP.isMemberOfRelation.stringValue())); return containerModel.contains(null, containerModel.createProperty(isMemberOfRelation.getURI()), membershipResource); }
public void validateResourceMap(Resource resmap, File base_dir, Model model, String... visitedRems) throws PackageValidationException { /* * Keep track of visited rems to avoid infinite loops. * It's done as varargs here to avoid refactoring the method signature. */ List<String> rems = new ArrayList<String>(Arrays.asList(visitedRems)); if (rems.contains(resmap.getURI())) { return; } else { rems.add(resmap.getURI()); } if (!model.contains(resmap, DESCRIBES_PROPERTY)) { checkAndLoad(resmap, base_dir, model); } Resource agg = resmap.getPropertyResourceValue(DESCRIBES_PROPERTY); if (agg == null) { throw new PackageValidationException("The resource map " + resmap.getURI() + " does not descripe an aggregation."); } visitAggregation(agg, base_dir, model, rems); }
private void visitAggregatedResources(Resource agg, File base_dir, Model model, List<String> visitedRems) throws PackageValidationException { NodeIterator iter = model.listObjectsOfProperty(agg, AGGREGATES_PROPERTY); while (iter.hasNext()) { Resource res = iter.next().asResource(); if (res.hasProperty(IS_DESCRIBED_BY_PROPERTY)) { validateResourceMap(res.getPropertyResourceValue(IS_DESCRIBED_BY_PROPERTY), base_dir, model, visitedRems.toArray(new String[0])); } } }
public static Source sourceFromSpec( FileManager fm, Resource sourceConfig, AuthMap am ) { Resource endpoint = sourceConfig.getPropertyResourceValue( API.sparqlEndpoint ); if (endpoint == null) EldaException.BadSpecification( "no SPARQL endpoint specified for " + sourceConfig ); if (endpoint.hasProperty( RDF.type, ELDA_API.Combiner )) return new CombinedSource( fm, am, endpoint ); String sparqlEndpointString = endpoint.getURI(); return sparqlEndpointString.startsWith( LocalSource.PREFIX ) ? new LocalSource( fm, endpoint ) : sparqlEndpointString.startsWith( HereSource.PREFIX ) ? new HereSource( sourceConfig.getModel(), endpoint ) : sparqlEndpointString.startsWith( TDBManager.PREFIX ) ? new TDBSource( endpoint ) : new SparqlSource( endpoint, am ) ; } }
@Test( groups = {SHOULD, "ldpMember"}, description = "LDP Direct Containers SHOULD use the ldp:member predicate " + "as an LDPC's membership predicate if there is no obvious " + "predicate from an application vocabulary to use.") @SpecTest( specRefUri = LdpTestSuite.SPEC_URI + "#ldpdc-mbrpred", testMethod = METHOD.AUTOMATED, approval = STATUS.WG_APPROVED) public void testUseMemberPredicate() throws URISyntaxException { Model containerModel = getAsModel(directContainer); Resource container = containerModel.getResource(directContainer); if (container.hasProperty(containerModel.createProperty(LDP.isMemberOfRelation.stringValue()))) { throw new SkipException(Thread.currentThread().getStackTrace()[1].getMethodName(), "This test does not apply to containers using the ldp:isMemberOfRelation membership pattern.", skipLog); } Resource hasMemberRelation = container.getPropertyResourceValue(containerModel.createProperty(LDP.hasMemberRelation.stringValue())); assertEquals(LDP.member.stringValue(), hasMemberRelation.getURI(), "LDP Direct Containers should use the ldp:member predicate if " + "there is no obvious predicate from the application vocabulary. You can disable this test using the 'testLdpMember' parameter in testng.xml."); }
private void visitAggregatedResources(Resource agg, State state) throws StatefulIngestServiceException { NodeIterator iter = state.model.listObjectsOfProperty(agg, AGGREGATES_PROPERTY); while (iter.hasNext()) { Resource res = iter.next().asResource(); if (res.hasProperty(IS_DESCRIBED_BY_PROPERTY)) { // Careful about this, this is where we could have a loop... visitResourceMap(res.getPropertyResourceValue(IS_DESCRIBED_BY_PROPERTY), state); } else { visitByteStream(res, state); } } }
Resource agg = resmap.getPropertyResourceValue(DESCRIBES_PROPERTY);
while (stmtIter.hasNext()) { Statement stmt = stmtIter.next(); Resource type = stmt.getSubject().getPropertyResourceValue(RDF.type); if (type == null || !type.equals(RDF.Statement)) { statementsToRemove.add(stmt);
Model containerModel = getResponse.as(Model.class, new RdfObjectMapper(directContainer)); Resource container = containerModel.getResource(directContainer); Resource membershipResource = container.getPropertyResourceValue(containerModel.createProperty(LDP.membershipResource.stringValue())); Resource hasMemberRelation = container.getPropertyResourceValue(containerModel.createProperty(LDP.hasMemberRelation.stringValue())); assertNotNull(membershipResource);
Resource membershipResource = container.getPropertyResourceValue(containerModel.createProperty(LDP.membershipResource.stringValue())); Resource hasMemberRelation = container.getPropertyResourceValue(containerModel.createProperty(LDP.hasMemberRelation.stringValue())); Resource isMemberOfRelation = null; assertNotNull(membershipResource, MSG_MBRRES_NOTFOUND); } else { isMemberOfRelation = container.getPropertyResourceValue(containerModel.createProperty(LDP.isMemberOfRelation.stringValue())); } else { isMemberOfRelation = container.getPropertyResourceValue(containerModel.createProperty(LDP.isMemberOfRelation.stringValue())); assertFalse(containerModel.contains(containerModel.getResource(location), containerModel.createProperty(isMemberOfRelation.getURI()), membershipResource), "The LDPC server must remove the corresponding membership triple when an LDPR is deleted (isMemberOfRelation).");