package org.arachb.owlbuilder.lib;

import java.util.Map;

import org.arachb.arachadmin.PropertyBean;
import org.arachb.owlbuilder.Owlbuilder;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLObject;
import org.semanticweb.owlapi.model.OWLObjectProperty;

public class PropertyTerm implements NamedGeneratingEntity {

	private final PropertyBean bean;
	
	public PropertyTerm(PropertyBean pb){
		bean = pb;
	}

	@Override
	public OWLObject generateOWL(Owlbuilder b, Map<String, OWLObject> elements) throws Exception {
		IRI propertyIRI = IRI.create(bean.getSourceId());
		OWLObjectProperty elementProperty = b.getDataFactory().getOWLObjectProperty(propertyIRI);
		elements.put(bean.getSourceId(), elementProperty);
		return elementProperty;
	}

	
	/**
	 * Doesn't call any generateOWL methods, so don't bother creating name table
	 * 
	 */
	@Override
	public OWLObject generateOWL(Owlbuilder b) throws Exception{
		IRI propertyIRI = IRI.create(bean.getSourceId());
		return b.getDataFactory().getOWLObjectProperty(propertyIRI);
	}

	
	public String getSourceId() {
		return bean.getSourceId();
	}


}

@@ -541,16 +541,91 @@
 ption %7B%0A
+%09%09assert (bean.getSourceId() != null): %22bean (id = %25d) has null sourceId%22;%0A
 %09%09IRI pr

add assert to check the bean has a sourceId - all properties should have an IRI