public Shape withPropertyConstraint(PropertyConstraint constraint) { checkNotNull(constraint); URI predicate = constraint.predicate(); checkArgument(!this.constraints.containsKey(predicate),"Shape already defines constraints for predicate '"+predicate+"'"); this.constraints.put(predicate,constraint); return this; }
shapeInd.addValue(shaclTerm("property"), pcInd); pcInd.addValue(vocabularyTerm(RDF.TYPE), externalIndividual(shaclTerm("PropertyConstraint"))); pcInd.addValue(shaclTerm("predicate"), externalIndividual(pc.predicate())); populateDescription(pcInd, pc); populateCardinality(pcInd, pc.cardinality()); populateNodeKind(pcInd, pc.nodeKind()); populateHasValues(pcInd, pc.literals(), translator); populateHasValues(pcInd, pc.individuals(dataset), translator); Set<Value> allowedValues=Sets.newHashSet(); allowedValues.addAll(pc.allowedLiterals()); allowedValues.addAll(pc.allowedIndividuals(dataset)); populateAllowedValues(pcInd, allowedValues, translator); populateValueType(pcInd,pc.valueType()); populateDatatype(pcInd,pc.datatype()); Shape valueShape = pc.valueShape(); if(valueShape!=null) { populateValueShape(pcInd,cache.individual(valueShape));
Constraints. propertyConstraint(uri("property")). withLabel("property-constraint"). withComment("A property constraint"). withCardinality(Cardinality.mandatory()). withNodeKind(NodeKind.NODE). withDatatype(uri("datatype")). withValueType(uri("valueType")). withAllowedValues( Literals.duration(13, TimeUnit.SECONDS), managedIndividual(dataSet,"one","template1")). withValue( Literals.of(new Date()).date(), localIndividual(dataSet,"two"));
Constraints. propertyConstraint(uri("property")). withLabel("property-constraint"). withComment("A property constraint"). withCardinality(Cardinality.mandatory()). withNodeKind(NodeKind.NODE). withDatatype(uri("datatype")). withValueType(uri("valueType")). withAllowedValues( Literals.duration(13, TimeUnit.SECONDS), managedIndividual(dataSet,"one","template1")). withValue( Literals.of(new Date()).date(), localIndividual(dataSet,"two"));
public static PropertyConstraint propertyConstraint(URI predicate) { return new PropertyConstraint(predicate); }