Java Code Examples for org.apache.jena.graph.Triple#createMatch()

The following examples show how to use org.apache.jena.graph.Triple#createMatch() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSpdxFile.java    From tools with Apache License 2.0 6 votes vote down vote up
@Test
public void testNoassertionCopyright() throws InvalidSPDXAnalysisException {
	model = ModelFactory.createDefaultModel();
	IModelContainer modelContainer = new ModelContainerForTest(model, "http://somethingunique.com/something");
	SpdxFile file = new SpdxFile("filename", null, null, null, 
			COMPLEX_LICENSE, CONJUNCTIVE_LICENSES, SpdxRdfConstants.NOASSERTION_VALUE, null,
			null, new Checksum[] {new Checksum(ChecksumAlgorithm.checksumAlgorithm_sha1,
					"1123456789abcdef0123456789abcdef01234567")}, null, null, null);
	Resource fileResource = file.createResource(modelContainer);
	Node p = model.getProperty(SpdxRdfConstants.SPDX_NAMESPACE, SpdxRdfConstants.PROP_FILE_COPYRIGHT).asNode();
	Triple m = Triple.createMatch(null, p, null);
	ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);	
	while (tripleIter.hasNext()) {
		Triple t = tripleIter.next();
		assertTrue(t.getObject().isURI());
		assertEquals(SpdxRdfConstants.URI_VALUE_NOASSERTION, t.getObject().getURI());
	}
	SpdxFile file2 = new SpdxFile(modelContainer, fileResource.asNode());
	assertEquals(SpdxRdfConstants.NOASSERTION_VALUE, file2.getCopyrightText());
}
 
Example 2
Source File: LicenseInfoFactory.java    From tools with Apache License 2.0 6 votes vote down vote up
/**
 * @param document
 * @param node
 * @return
 * @throws InvalidSPDXAnalysisException 
 */
private static AnyLicenseInfo getLicenseInfoById(IModelContainer modelContainer, Node node) throws InvalidSPDXAnalysisException {
	Node licenseIdPredicate = modelContainer.getModel().getProperty(SpdxRdfConstants.SPDX_NAMESPACE, SpdxRdfConstants.PROP_LICENSE_ID).asNode();
	Triple m = Triple.createMatch(node, licenseIdPredicate, null);
	ExtendedIterator<Triple> tripleIter = modelContainer.getModel().getGraph().find(m);
	if (tripleIter.hasNext()) {
		Triple triple = tripleIter.next();
		String id = triple.getObject().toString(false);
		if (tripleIter.hasNext()) {
			throw(new InvalidSPDXAnalysisException("More than one ID associated with license "+id));
		}
		if (isSpdxListedLicenseID(id)) {
			return new SpdxListedLicense(modelContainer, node);
		} else if (id.startsWith(SpdxRdfConstants.NON_STD_LICENSE_ID_PRENUM)) {
			return new ExtractedLicenseInfo(modelContainer, node);
		} else {
			// could not determine the type from the ID
			// could be a conjunctive or disjunctive license ID
			return null;
		}
	} else {
		throw(new InvalidSPDXAnalysisException("No ID associated with a license"));
	}
}
 
Example 3
Source File: OrLaterOperator.java    From tools with Apache License 2.0 6 votes vote down vote up
@Override
public void getPropertiesFromModel() throws InvalidSPDXAnalysisException {
	Node p = model.getProperty(SpdxRdfConstants.SPDX_NAMESPACE, SpdxRdfConstants.PROP_LICENSE_SET_MEMEBER).asNode();
	Triple m = Triple.createMatch(node, p, null);
	ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);	
	while (tripleIter.hasNext()) {
		Triple t = tripleIter.next();
		if (this.license != null) {
			throw (new InvalidSPDXAnalysisException("More than one license for a license WITH expression"));
		}
		AnyLicenseInfo anyLicense = LicenseInfoFactory.getLicenseInfoFromModel(modelContainer, t.getObject());
		if (!(anyLicense instanceof SimpleLicensingInfo)) {
			throw (new InvalidSPDXAnalysisException("The license for a WITH expression must be of type SimpleLicensingInfo"));
		}
		this.license = (SimpleLicensingInfo)anyLicense;
	}
}
 
Example 4
Source File: SPDXLicenseInfoFactory.java    From tools with Apache License 2.0 6 votes vote down vote up
/**
 * @param model
 * @param node
 * @return
 * @throws InvalidSPDXAnalysisException 
 */
private static SPDXLicenseInfo getLicenseInfoById(Model model, Node node) throws InvalidSPDXAnalysisException {
	Node licenseIdPredicate = model.getProperty(SpdxRdfConstants.SPDX_NAMESPACE, SpdxRdfConstants.PROP_LICENSE_ID).asNode();
	Triple m = Triple.createMatch(node, licenseIdPredicate, null);
	ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);
	if (tripleIter.hasNext()) {
		Triple triple = tripleIter.next();
		String id = triple.getObject().toString(false);
		if (tripleIter.hasNext()) {
			throw(new InvalidSPDXAnalysisException("More than one ID associated with license "+id));
		}
		if (isStandardLicenseID(id)) {
			return new SPDXStandardLicense(model, node);
		} else if (id.startsWith(SpdxRdfConstants.NON_STD_LICENSE_ID_PRENUM)) {
			return new SPDXNonStandardLicense(model, node);
		} else {
			// could not determine the type from the ID
			// could be a conjunctive or disjunctive license ID
			return null;
		}
	} else {
		throw(new InvalidSPDXAnalysisException("No ID associated with a license"));
	}
}
 
Example 5
Source File: RdfModelObject.java    From tools with Apache License 2.0 6 votes vote down vote up
/**
 * Find all annotations with a subject of this object
 * @param nameSpace
 * @param propertyName
 * @return
 * @throws InvalidSPDXAnalysisException 
 */
protected Annotation[] findAnnotationPropertyValues(String nameSpace,
		String propertyName) throws InvalidSPDXAnalysisException {
	if (this.model == null || this.node == null) {
		return null;
	}
	List<Annotation> retval = Lists.newArrayList();
	Node p = model.getProperty(nameSpace, propertyName).asNode();
	Triple m = Triple.createMatch(node, p, null);
	ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);	
	while (tripleIter.hasNext()) {
		Triple t = tripleIter.next();
		retval.add(new Annotation(this.modelContainer, t.getObject()));
	}
	return retval.toArray(new Annotation[retval.size()]);
}
 
Example 6
Source File: SPDXDocument.java    From tools with Apache License 2.0 6 votes vote down vote up
/**
 * @return the spdxPackage
 * @throws InvalidSPDXAnalysisException 
 */
public SPDXPackage getSpdxPackage() throws InvalidSPDXAnalysisException {
	if (this.spdxPackage != null) {
		return this.spdxPackage;
	}
	Node spdxDocNode = getSpdxDocNode();
	if (spdxDocNode == null) {
		throw(new InvalidSPDXAnalysisException("Must set an SPDX doc before getting an SPDX package"));
	}
	Node p = model.getProperty(SPDX_NAMESPACE, PROP_SPDX_PACKAGE).asNode();
	Triple m = Triple.createMatch(spdxDocNode, p, null);
	ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);	
	SPDXPackage newSpdxPackage = null;
	while (tripleIter.hasNext()) {
		Triple t = tripleIter.next();
		newSpdxPackage = new SPDXPackage(t.getObject(), this);
	}
	this.spdxPackage = newSpdxPackage;
	return newSpdxPackage;
}
 
Example 7
Source File: SPDXDocument.java    From tools with Apache License 2.0 6 votes vote down vote up
/**
 * Find all property string values belonging to the subject
 * @param subject
 * @param nameSpace
 * @param propertyName
 * @return string values of the properties or null if the subject or propertyName is null
 */
private String[] findDocPropertieStringValues(Node subject, String nameSpace, String propertyName) {
	if (subject == null || propertyName == null) {
		return null;
	}
	List<String> alResult = Lists.newArrayList();
	Node p = model.getProperty(nameSpace, propertyName).asNode();
	Triple m = Triple.createMatch(subject, p, null);
	ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);	
	while (tripleIter.hasNext()) {
		Triple t = tripleIter.next();
		if (t.getObject().isURI()) {
			if (t.getObject().getURI().equals(SpdxRdfConstants.URI_VALUE_NONE)) {
				alResult.add(SpdxRdfConstants.NONE_VALUE);
			} else if (t.getObject().getURI().equals(SpdxRdfConstants.URI_VALUE_NOASSERTION)) {
				alResult.add(SpdxRdfConstants.NOASSERTION_VALUE);
			} else {
				alResult.add(t.getObject().toString(false));
			}
		} else {
			alResult.add(t.getObject().toString(false));
		}
	}
	String[] retval = new String[alResult.size()];
	return alResult.toArray(retval);
}
 
Example 8
Source File: SpdxDocumentContainer.java    From tools with Apache License 2.0 6 votes vote down vote up
/**
 * @throws InvalidSPDXAnalysisException 
 * 
 */
private void upgradeDescribesToRelationship() throws InvalidSPDXAnalysisException {
	Node p = model.getProperty(SPDX_NAMESPACE, PROP_SPDX_PACKAGE).asNode();
	Triple m = Triple.createMatch(this.documentNode, p, null);
	ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);	
	List<SpdxPackage> describedPackages = Lists.newArrayList();
	while (tripleIter.hasNext()) {
		Triple t = tripleIter.next();
		describedPackages.add(new SpdxPackage(this, t.getObject()));
	}
	for (SpdxPackage pkg:describedPackages) {
		Relationship describes = new Relationship(pkg, 
				Relationship.RelationshipType.DESCRIBES, "");
		this.getSpdxDocument().addRelationship(describes);
	}
}
 
Example 9
Source File: SPDXDocument.java    From tools with Apache License 2.0 6 votes vote down vote up
/**
 * @return the reviewers
 * @throws InvalidSPDXAnalysisException 
 */
public SPDXReview[] getReviewers() throws InvalidSPDXAnalysisException {
	Node spdxDocNode = getSpdxDocNode();
	if (spdxDocNode == null) {
		throw(new InvalidSPDXAnalysisException("Must have an SPDX document to get reviewers"));
	}
	List<SPDXReview> als = Lists.newArrayList();
	als.clear();
	Node p = model.getProperty(SPDX_NAMESPACE, PROP_SPDX_REVIEWED_BY).asNode();
	Triple m = Triple.createMatch(spdxDocNode, p, null);
	ExtendedIterator<Triple >tripleIter = model.getGraph().find(m);	
	while (tripleIter.hasNext()) {
		Triple t = tripleIter.next();
		als.add(new SPDXReview(model, t.getObject()));
	}
	SPDXReview[] reviewers = new SPDXReview[als.size()];
	reviewers = als.toArray(reviewers);
	return reviewers;
}
 
Example 10
Source File: SPDXDocument.java    From tools with Apache License 2.0 5 votes vote down vote up
public SpdxPackageVerificationCode getVerificationCode() throws InvalidSPDXAnalysisException {			
	SpdxPackageVerificationCode retval = null;
	Node p = model.getProperty(SPDX_NAMESPACE, PROP_PACKAGE_VERIFICATION_CODE).asNode();
	Triple m = Triple.createMatch(this.node, p, null);
	ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);	
	while (tripleIter.hasNext()) {
		Triple t = tripleIter.next();
		retval = new SpdxPackageVerificationCode(model, t.getObject());
	}
	return retval;
}
 
Example 11
Source File: PointerFactory.java    From tools with Apache License 2.0 5 votes vote down vote up
/**
 * Get the single pointer class based on the element type specified in the model
 * @param modelContainer
 * @param node
 * @return
 * @throws InvalidSPDXAnalysisException 
 */
private static SinglePointer getElementByType(
		IModelContainer modelContainer, Node node) throws InvalidSPDXAnalysisException {
	Node rdfTypePredicate = modelContainer.getModel().getProperty(SpdxRdfConstants.RDF_NAMESPACE, 
			SpdxRdfConstants.RDF_PROP_TYPE).asNode();
	Triple m = Triple.createMatch(node, rdfTypePredicate, null);
	ExtendedIterator<Triple> tripleIter = modelContainer.getModel().getGraph().find(m);	// find the type(s)
	if (tripleIter.hasNext()) {
		Triple triple = tripleIter.next();
		if (tripleIter.hasNext()) {
			throw(new InvalidSPDXAnalysisException("More than one type associated with a SinglePointer"));
		}
		Node typeNode = triple.getObject();
		if (!typeNode.isURI()) {
			throw(new InvalidSPDXAnalysisException("Invalid type for a SinglePointer - not a URI"));
		}
		// need to parse the URI
		String typeUri = typeNode.getURI();
		if (!typeUri.startsWith(SpdxRdfConstants.RDF_POINTER_NAMESPACE)) {
			throw(new InvalidSPDXAnalysisException("Invalid type for a SinglePointer - not an RDF Pointer type (namespace must begin with "+
						SpdxRdfConstants.RDF_POINTER_NAMESPACE));
		}
		String type = typeUri.substring(SpdxRdfConstants.RDF_POINTER_NAMESPACE.length());
		if (type.equals(SpdxRdfConstants.CLASS_POINTER_BYTE_OFFSET_POINTER)) {
			return new ByteOffsetPointer(modelContainer, node);
		} else if (type.equals(SpdxRdfConstants.CLASS_POINTER_LINE_CHAR_POINTER)) {
			return new LineCharPointer(modelContainer, node);
		} else {
			throw(new InvalidSPDXAnalysisException("Unsupported type for SinglePointer '"+type+"'"));
		}
	} else {
		return null;
	}
}
 
Example 12
Source File: SPDXDocument.java    From tools with Apache License 2.0 5 votes vote down vote up
/**
 * @return the spdx doc node from the model
 */
private Node getSpdxDocNode() {
	Node spdxDocNode = null;
	Node rdfTypePredicate = this.model.getProperty(RDF_NAMESPACE, RDF_PROP_TYPE).asNode();
	Node spdxDocObject = this.model.getProperty(SPDX_NAMESPACE, CLASS_SPDX_ANALYSIS).asNode();
	Triple m = Triple.createMatch(null, rdfTypePredicate, spdxDocObject);
	ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);	// find the document
	while (tripleIter.hasNext()) {
		Triple docTriple = tripleIter.next();
		spdxDocNode = docTriple.getSubject();
	}
	return spdxDocNode;
}
 
Example 13
Source File: SPDXFile.java    From tools with Apache License 2.0 5 votes vote down vote up
public String getComment() {
	if (this.model != null && this.resource != null) {
		Node p = model.getProperty(SpdxRdfConstants.RDFS_NAMESPACE, SpdxRdfConstants.RDFS_PROP_COMMENT).asNode();
		Triple m = Triple.createMatch(this.resource.asNode(), p, null);
		ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);	
		while (tripleIter.hasNext()) {
			this.comment = tripleIter.next().getObject().toString(false);
		}
	}
	return this.comment;
}
 
Example 14
Source File: ExtractedLicenseInfo.java    From tools with Apache License 2.0 5 votes vote down vote up
/**
 * @return
 */
@Override
   public List<String> verify() {
	List<String> retval = Lists.newArrayList();
	String id = this.getLicenseId();
	if (id == null || id.isEmpty()) {
		retval.add("Missing required license ID");
	} else {
		String idError = SpdxVerificationHelper.verifyNonStdLicenseid(id);
		if (idError != null && !idError.isEmpty()) {
			retval.add(idError);
		}
	}
	String licenseText = this.getExtractedText();
	if (licenseText == null || licenseText.isEmpty()) {
		retval.add("Missing required license text for " + id);
	}
	// comment
	// make sure there is not more than one comment
	try {
		if (node != null) {
			Node p = model.getProperty(SpdxRdfConstants.RDFS_NAMESPACE, SpdxRdfConstants.RDFS_PROP_COMMENT).asNode();
			Triple m = Triple.createMatch(node, p, null);
			ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);
			int count = 0;
			while (tripleIter.hasNext()) {
				count++;
				tripleIter.next();
			}
			if (count > 1) {
				retval.add("More than one comment on Extracted License Info id "+id.toString());
			}
		}
	} catch (Exception e) {
		retval.add("Error getting license comments: "+e.getMessage());
	}

	return retval;
}
 
Example 15
Source File: SPDXDocument.java    From tools with Apache License 2.0 5 votes vote down vote up
/**
 * Removes all SPDX files by the given name
 * @param fileName Name of SPDX file to be removed
 * @throws InvalidSPDXAnalysisException 
 */
public void removeFile(String fileName) throws InvalidSPDXAnalysisException {
	List<Node> filesToRemove = Lists.newArrayList();
	Node fileNameProperty = model.getProperty(SPDX_NAMESPACE, PROP_FILE_NAME).asNode();
	Property docFileProperty = model.getProperty(SPDX_NAMESPACE, PROP_SPDX_FILE_REFERENCE);
	Property pkgFileProperty = model.createProperty(SPDX_NAMESPACE, PROP_PACKAGE_FILE);
	Resource docResource = getResource(getSpdxDocNode());
	Resource pkgResource = getResource(this.node);
	Triple m = Triple.createMatch(getSpdxDocNode(), docFileProperty.asNode(), null);
	ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);	
	//TODO: See if there is a more efficient search method for files
	while (tripleIter.hasNext()) {
		Triple t = tripleIter.next();
		Node fileObject = t.getObject();
		Triple fileNameMatch = Triple.createMatch(fileObject, fileNameProperty, null);
		ExtendedIterator<Triple> fileNameIterator = model.getGraph().find(fileNameMatch);
		while (fileNameIterator.hasNext()) {
			Triple fileNameTriple = fileNameIterator.next();
			String searchFileName = fileNameTriple.getObject().toString(false); 
			if (searchFileName.equals(fileName)) {
				filesToRemove.add(fileObject);
			}
		}
	}
	for (int i = 0; i < filesToRemove.size(); i++) {
		// remove the references files
		RDFNode o = model.getRDFNode(filesToRemove.get(i));
		model.removeAll(docResource, docFileProperty, o);
		// remove the package files
		model.removeAll(pkgResource, pkgFileProperty, o);				
	}
}
 
Example 16
Source File: SPDXDocument.java    From tools with Apache License 2.0 5 votes vote down vote up
/**
 * @param files the files to set
 * @throws InvalidSPDXAnalysisException 
 */
public void setFiles(SPDXFile[] files) throws InvalidSPDXAnalysisException {
	// Delete all existing files
	List<Node> alFileNodes = Lists.newArrayList();
	Node n = model.getProperty(SPDX_NAMESPACE, PROP_PACKAGE_FILE).asNode();
	Triple m = Triple.createMatch(this.node, n, null);
	ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);	
	while (tripleIter.hasNext()) {
		Triple t = tripleIter.next();
		alFileNodes.add(t.getObject());
	}
	removeProperties(node, PROP_PACKAGE_FILE);
	removeProperties(getSpdxDocNode(), PROP_SPDX_FILE_REFERENCE);	// NOTE: In version 2.0, we will need to remove just the files which were in the package

	for (Node fileNode : alFileNodes) {
		model.removeAll(getResource(fileNode), null, null);
	}
	
	if (files != null) {
		Resource s = getResource(this.node);
		Property p = model.createProperty(SPDX_NAMESPACE, PROP_PACKAGE_FILE);
		Resource docResource = getResource(getSpdxDocNode());
		Property docP = model.createProperty(SPDX_NAMESPACE, PROP_SPDX_FILE_REFERENCE);
		for (int i = 0; i < files.length; i++) {				
			Resource file = files[i].createResource(getDocument(), getDocumentNamespace() + getNextSpdxElementRef());
			s.addProperty(p, file);
			docResource.addProperty(docP, file);
		}
	}
}
 
Example 17
Source File: SpdxDocumentContainer.java    From tools with Apache License 2.0 5 votes vote down vote up
public List<SpdxPackage> findAllPackages() throws InvalidSPDXAnalysisException {
	Node rdfTypePredicate = model.getProperty(SpdxRdfConstants.RDF_NAMESPACE, 
			SpdxRdfConstants.RDF_PROP_TYPE).asNode();
	Node packageTypeObject = model.createResource(SPDX_NAMESPACE + CLASS_SPDX_PACKAGE).asNode();
	Triple m = Triple.createMatch(null, rdfTypePredicate, packageTypeObject);
	List<SpdxPackage> retval = Lists.newArrayList();
	ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);	
	while (tripleIter.hasNext()) {
		retval.add((SpdxPackage)SpdxElementFactory.createElementFromModel(this, tripleIter.next().getSubject()));
	}
	return retval;
}
 
Example 18
Source File: SPDXDocument.java    From tools with Apache License 2.0 5 votes vote down vote up
/**
 * @param id
 * @return true if the license ID is already in the model as an extracted license info
 * @throws InvalidSPDXAnalysisException 
 */
protected boolean extractedLicenseExists(String id) throws InvalidSPDXAnalysisException {
	Node p = model.getProperty(SPDX_NAMESPACE, PROP_LICENSE_ID).asNode();
	Node o = NodeFactory.createLiteral(id);
	Triple m = Triple.createMatch(null, p, o);
	ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);	
	return tripleIter.hasNext();
}
 
Example 19
Source File: SpdxElementFactory.java    From tools with Apache License 2.0 4 votes vote down vote up
/**
 * @param modelContainer
 * @param node
 * @return
 * @throws InvalidSPDXAnalysisException 
 */
private static SpdxElement getElementByType(IModelContainer modelContainer,
		Node node) throws InvalidSPDXAnalysisException {
	Node rdfTypePredicate = modelContainer.getModel().getProperty(SpdxRdfConstants.RDF_NAMESPACE, 
			SpdxRdfConstants.RDF_PROP_TYPE).asNode();
	Triple m = Triple.createMatch(node, rdfTypePredicate, null);
	ExtendedIterator<Triple> tripleIter = modelContainer.getModel().getGraph().find(m);	// find the type(s)
	if (tripleIter.hasNext()) {
		Triple triple = tripleIter.next();
		if (tripleIter.hasNext()) {
			throw(new InvalidSPDXAnalysisException("More than one type associated with an SPDX Element"));
		}
		Node typeNode = triple.getObject();
		if (!typeNode.isURI()) {
			throw(new InvalidSPDXAnalysisException("Invalid type for an SPDX Element - not a URI"));
		}
		// need to parse the URI
		String typeUri = typeNode.getURI();
		if (!typeUri.startsWith(SpdxRdfConstants.SPDX_NAMESPACE)) {
			throw(new InvalidSPDXAnalysisException("Invalid type for an SPDX Element - not an SPDX type"));
		}
		String type = typeUri.substring(SpdxRdfConstants.SPDX_NAMESPACE.length());
		if (type.equals(SpdxRdfConstants.CLASS_SPDX_FILE)) {
			return new SpdxFile(modelContainer, node);
		} else if (type.equals(SpdxRdfConstants.CLASS_SPDX_PACKAGE)) {
			return new SpdxPackage(modelContainer, node);
		} else if (type.equals(SpdxRdfConstants.CLASS_SPDX_SNIPPET)) {
			return new SpdxSnippet(modelContainer, node);
		} else if (type.equals(SpdxRdfConstants.CLASS_SPDX_ITEM)) {
			return new SpdxItem(modelContainer, node);
		} else if (type.equals(SpdxRdfConstants.CLASS_SPDX_ELEMENT)) {
			return new SpdxElement(modelContainer, node);
		} else if (type.equals(SpdxRdfConstants.CLASS_SPDX_DOCUMENT)) {
			return new SpdxDocumentContainer(modelContainer.getModel()).getSpdxDocument();
		} else {
			throw(new InvalidSPDXAnalysisException("Invalid type for element '"+type+"'"));
		}
	} else {
		return null;
	}
}
 
Example 20
Source File: SpdxElementFactory.java    From tools with Apache License 2.0 3 votes vote down vote up
/**
 * Returns true if a value for a property exists for the subject node
 * @param modelContainer
 * @param node
 * @param namespace
 * @param propertyName
 * @return
 */
private static boolean propertyExists(IModelContainer modelContainer,
		Node node, String namespace, String propertyName) {
	Node p = modelContainer.getModel().getProperty(namespace, propertyName).asNode();
	Triple m = Triple.createMatch(node, p, null);
	ExtendedIterator<Triple> tripleIter = modelContainer.getModel().getGraph().find(m);	
	return tripleIter.hasNext();
}