com.eduworks.cruncher.ontology.CruncherOntologyCreateObjectProperty Maven / Gradle / Ivy
package com.eduworks.cruncher.ontology;
import java.io.InputStream;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
import com.eduworks.ontology.Ontology;
import com.eduworks.resolver.Context;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.ReadWrite;
import com.hp.hpl.jena.shared.ClosedException;
public class CruncherOntologyCreateObjectProperty extends CruncherOntology
{
@Override
public Object resolve(Context c, Map parameters, Map dataStreams) throws JSONException
{
String directory = decodeValue(optAsString("directory", "", c, parameters, dataStreams));
String ontologyId = decodeValue(optAsString("ontologyId", "", c, parameters, dataStreams));
String propertyId = decodeValue(optAsString("propertyId", "", c, parameters, dataStreams));
JSONObject vals = new JSONObject(decodeValue(optAsString("vals", "{}", c, parameters, dataStreams)));
Ontology o = null;
JSONObject jsonRepresentation = null;
Dataset tdbDataset = getDataSet(directory,ReadWrite.WRITE,c);
try
{
try
{
o = getOntology(ontologyId, tdbDataset, c);
}
catch (ClosedException e)
{
clearContextData(c);
return resolve(c,parameters, dataStreams);
}
jsonRepresentation = o.createObjectProperty(propertyId, vals).getJSONRepresentation();
}
catch (RuntimeException e)
{
throw e;
}
finally
{
if (o != null)
o.close(false);
}
return jsonRepresentation;
}
@Override
public String getDescription()
{
return "Creates a new object property in the ontology specified, vals defines any superclasses, domain, and range the property could have, as well as other"
+ " properties such as transitive, reflexive, etc. An object property is a property that relates two different instances";
}
@Override
public String getReturn()
{
return "JSONObject";
}
@Override
public String getAttribution()
{
return ATTRIB_NONE;
}
@Override
public JSONObject getParameters() throws JSONException
{
return jo("ontologyId", "String", "directory", "String", "propertyId", "String", "vals", "Object");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy