本文整理汇总了Java中com.hp.hpl.jena.ontology.DatatypeProperty类的典型用法代码示例。如果您正苦于以下问题:Java DatatypeProperty类的具体用法?Java DatatypeProperty怎么用?Java DatatypeProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatatypeProperty类属于com.hp.hpl.jena.ontology包,在下文中一共展示了DatatypeProperty类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getOntProperty
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
private OntProperty getOntProperty(ConceptName propName) {
Resource ir;
try {
ir = getOntResourceInExistingModel(propName);
if (ir != null) {
if (logger.isDebugEnabled()) {
exploreProperty(ir.as(OntProperty.class));
}
ConceptType it = getOntResourceConceptType(ir);
if (it.equals(ConceptType.ANNOTATIONPROPERTY)) {
return ir.as(AnnotationProperty.class);
}
else if (it.equals(ConceptType.OBJECTPROPERTY)) {
return ir.as(ObjectProperty.class);
}
else if (it.equals(ConceptType.DATATYPEPROPERTY)) {
return ir.as(DatatypeProperty.class);
}
}
} catch (ConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:27,代码来源:ModelManager.java
示例2: getRange
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
private OntResource getRange(OntProperty prop) {
OntResource range = prop.getRange();
if (range == null) {
ExtendedIterator<? extends OntProperty> titr = null;
if (prop.canAs(ObjectProperty.class)) {
titr = ((ObjectProperty) prop.as(ObjectProperty.class))
.listSuperProperties(true);
} else if (prop.canAs(DatatypeProperty.class)) {
titr = ((DatatypeProperty) prop.as(DatatypeProperty.class))
.listSuperProperties(true);
}
if (titr != null) {
while (titr.hasNext()) {
OntProperty tr = titr.next();
range = getRange((OntProperty) tr);
if (range != null) {
titr.close();
return range;
}
}
titr.close();
}
}
return range;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:26,代码来源:ModelManager.java
示例3: dtPropertyToSadl
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
private String dtPropertyToSadl(ModelConcepts concepts, OntResource prop) {
StringBuilder sb = new StringBuilder();
sb.append(uriToSadlString(concepts, prop));
addNotesAndAliases(sb, prop);
if (prop.canAs(DatatypeProperty.class)) {
propertyToSadl(sb, concepts, prop);
}
else {
sb.append(" is a property");
}
if (!sb.toString().contains("with values")) {
sb.append(" with values of type data");
}
addEndOfStatement(sb, 1);
return sb.toString();
}
开发者ID:crapo,项目名称:sadlos2,代码行数:17,代码来源:OwlToSadl.java
示例4: getSuperPropertyType
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
private Resource getSuperPropertyType(Resource ontRsrc) {
StmtIterator sitr = theModel.listStatements(null, RDFS.subPropertyOf, ontRsrc);
if (sitr.hasNext()) {
Statement s = sitr.nextStatement();
Resource superprop = s.getSubject();
if (superprop.canAs(ObjectProperty.class)) {
return OWL.ObjectProperty;
}
else if (superprop.canAs(DatatypeProperty.class)) {
return OWL.DatatypeProperty;
}
else {
return getSuperPropertyType(superprop);
}
}
return null;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:18,代码来源:OwlToSadl.java
示例5: processStatement
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
public void processStatement(EquationStatement element)
throws JenaProcessorException, InvalidNameException, InvalidTypeException, TranslationException {
SadlResource nm = element.getName();
EList<SadlParameterDeclaration> params = element.getParameter();
SadlTypeReference rtype = element.getReturnType();
Expression bdy = element.getBody();
Equation eq = createEquation(element, nm, rtype, params, bdy);
addEquation(element.eResource(), eq, nm);
Individual eqinst = getTheJenaModel().createIndividual(getDeclarationExtensions().getConceptUri(nm),
getTheJenaModel().getOntClass(SadlConstants.SADL_BASE_MODEL_EQUATION_URI));
DatatypeProperty dtp = getTheJenaModel().getDatatypeProperty(SadlConstants.SADL_BASE_MODEL_EQ_EXPRESSION_URI);
Literal literal = getTheJenaModel().createTypedLiteral(eq.toString());
if (eqinst != null && dtp != null) {
// these can be null during clean/build with resource open in editor
eqinst.addProperty(dtp, literal);
}
}
开发者ID:crapo,项目名称:sadlos2,代码行数:18,代码来源:JenaBasedSadlModelProcessor.java
示例6: createDatatypeProperty
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
private DatatypeProperty createDatatypeProperty(String newName, String superSRUri) throws JenaProcessorException {
DatatypeProperty newProp = getTheJenaModel().createDatatypeProperty(newName);
logger.debug("New datatype property '" + newProp.getURI() + "' created");
if (superSRUri != null) {
OntProperty superProp = getTheJenaModel().getOntProperty(superSRUri);
if (superProp == null) {
// throw new JenaProcessorException("Unable to find super property '" +
// superSRUri + "'");
if (superProp == null) {
getTheJenaModel().createDatatypeProperty(superSRUri);
}
}
newProp.addSuperProperty(superProp);
logger.debug(" Datatype property '" + newProp.getURI() + "' given super property '" + superSRUri + "'");
}
return newProp;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:18,代码来源:JenaBasedSadlModelProcessor.java
示例7: isNumericWithImpliedProperty
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
private boolean isNumericWithImpliedProperty(TypeCheckInfo tci, Expression expr) throws DontTypeCheckException, InvalidNameException, InvalidTypeException, TranslationException {
if (tci.getImplicitProperties() != null) {
Iterator<ConceptName> litr = tci.getImplicitProperties().iterator();
while (litr.hasNext()) {
ConceptName cn = litr.next();
Property prop = theJenaModel.getProperty(cn.getUri());
if (prop.canAs(ObjectProperty.class)) {
cn.setType(ConceptType.OBJECTPROPERTY);
}
else if (prop.canAs(DatatypeProperty.class)) {
cn.setType(ConceptType.DATATYPEPROPERTY);
}
else {
cn.setType(ConceptType.RDFPROPERTY);
}
TypeCheckInfo newtci = getTypeInfoFromRange(cn, prop, expr);
if (isNumeric(newtci)) {
return true;
}
}
}
return false;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:24,代码来源:JenaBasedSadlModelValidator.java
示例8: useImpliedPropertyToMatchNumericOperator
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
private boolean useImpliedPropertyToMatchNumericOperator(EObject expr, TypeCheckInfo tci, String sideId) throws DontTypeCheckException, InvalidTypeException, TranslationException, InvalidNameException {
if (tci != null && tci.getImplicitProperties() != null) {
Iterator<ConceptName> ipitr = tci.getImplicitProperties().iterator();
while (ipitr.hasNext()) {
ConceptName cn = ipitr.next();
Property prop = theJenaModel.getProperty(cn.getUri());
if (prop.canAs(ObjectProperty.class)) {
cn.setType(ConceptType.OBJECTPROPERTY);
}
else if (prop.canAs(DatatypeProperty.class)) {
cn.setType(ConceptType.DATATYPEPROPERTY);
}
else {
cn.setType(ConceptType.RDFPROPERTY);
}
TypeCheckInfo newltci = getTypeInfoFromRange(cn, prop, expr);
if (isNumeric(newltci)) {
issueAcceptor.addInfo("Implied property '" + getModelProcessor().conceptIdentifierToString(cn) + "' used (" + sideId + ") to pass type check", expr);
addImpliedPropertiesUsed(expr, prop);
return true;
}
}
}
return false;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:26,代码来源:JenaBasedSadlModelValidator.java
示例9: modificar
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
public void modificar() {
try {
facultadSelecionada.setNombre(facultadSelecionada.getNombre().toUpperCase());
this.facultadFacade.edit(facultadSelecionada);
ModeloBean ont = (ModeloBean) FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get("modeloBean");
String nS = ont.getPrefijo();
OntModel modelo = ont.getModelOnt();
OntClass claseFac = modelo.getOntClass(nS + clase);
Individual facultad = modelo.createIndividual(nS +clase+facultadSelecionada.getCodFac(), claseFac);
DatatypeProperty nomFac = modelo.getDatatypeProperty(nS + "nombre_facultad");
facultad.setPropertyValue(nomFac, ont.getModelOnt().createTypedLiteral(facultadSelecionada.getNombre()));
ont.guardarModelo(modelo);
facultadSelecionada=null;
listaSelecionada=null;
listaFacultad = this.facultadFacade.findAll();
FacesContext.getCurrentInstance().getExternalContext().redirect("Lista.xhtml");
} catch (Exception e) {
System.out.println(e.toString());
FacesContext.getCurrentInstance().
addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"Problema al modificar la Facultad", ""));
}
}
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:24,代码来源:FacultadBean.java
示例10: isDataProperty
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
public boolean isDataProperty(String uri) {
DatatypeProperty dp = ontModel.getDatatypeProperty(uri);
if (dp != null)
return true;
return false;
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:9,代码来源:OntologyHandler.java
示例11: Build
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
public void Build(String path) throws IOException {
List<HNode> sortedLeafHNodes = new ArrayList<HNode>();
worksheet.getHeaders().getSortedLeafHNodes(sortedLeafHNodes);
OntModel autoOntology = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
String ns = Namespaces.KARMA;
autoOntology.setNsPrefix("karma", ns);
OntClass topClass = autoOntology.createClass( ns + worksheet.getTitle().replaceAll(" ", "_")); // replace blank spaces with undrscore
for (HNode hNode : sortedLeafHNodes){
DatatypeProperty dp = autoOntology.createDatatypeProperty(ns+hNode.getColumnName().trim().replaceAll(" ", "_"));
dp.addDomain(topClass);
dp.addRange(XSD.xstring);
}
// OntClass thingClass = autoOntology.createClass(Uris.THING_URI);
ObjectProperty op = autoOntology.createObjectProperty(ns + "relatedTo");
op.addDomain(topClass);
// op.addRange(thingClass);
Writer outUTF8 =null;
try {
outUTF8 = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(path), "UTF8"));
autoOntology.write(outUTF8, null);
outUTF8.flush();
outUTF8.close();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:31,代码来源:AutoOntology.java
示例12: doTestDatatypeRangeValidation
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
private void doTestDatatypeRangeValidation(RDFDatatype over12Type, OntModelSpec spec) {
OntModel ont = ModelFactory.createOntologyModel(spec);
String NS = "http://jena.hpl.hp.com/example#";
Resource over12 = ont.createResource( over12Type.getURI() );
DatatypeProperty hasValue = ont.createDatatypeProperty(NS + "hasValue");
hasValue.addRange( over12 );
ont.createResource(NS + "a").addProperty(hasValue, "15", over12Type);
ont.createResource(NS + "b").addProperty(hasValue, "16", over12Type);
ont.createResource(NS + "c").addProperty(hasValue, "10", over12Type);
ValidityReport validity = ont.validate();
assertTrue (! validity.isValid());
Iterator<Report> ritr = validity.getReports();
while (ritr.hasNext()) {
System.out.println("For spec '" + spec + "': " + ritr.next().toString());
}
ont.write(System.out);
// Check culprit reporting
ValidityReport.Report report = (validity.getReports().next());
Triple culprit = (Triple)report.getExtension();
assertEquals(culprit.getSubject().getURI(), NS + "c");
assertEquals(culprit.getPredicate(), hasValue.asNode());
// ont.createTypedLiteral("15", over12Type).getValue();
// ont.createTypedLiteral("16", over12Type).getValue();
// ont.createTypedLiteral("12", over12Type).getValue();
}
开发者ID:crapo,项目名称:sadlos2,代码行数:30,代码来源:TestUserDefinedDatatype.java
示例13: getConceptType
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
private ConceptType getConceptType(RDFNode concept) {
// get concept in model with imports
if (concept.isURIResource()) {
Resource newconcept = getTheJenaModelWithImports().getResource(concept.asResource().getURI());
if (newconcept != null) {
if (newconcept.canAs(OntClass.class)){
return ConceptType.ONTCLASS;
}
else if (newconcept.canAs(ObjectProperty.class)){
return ConceptType.OBJECTPROPERTY;
}
else if (newconcept.canAs(DatatypeProperty.class)) {
return ConceptType.DATATYPEPROPERTY;
}
else if (newconcept.canAs(AnnotationProperty.class)) {
return ConceptType.ANNOTATIONPROPERTY;
}
else if (newconcept.canAs(Individual.class)) {
return ConceptType.INDIVIDUAL;
}
else if (newconcept.canAs(Property.class)){
return ConceptType.RDFPROPERTY;
}
}
}
else if (concept.canAs(OntClass.class)){
return ConceptType.ONTCLASS;
}
else if (concept.canAs(Individual.class)){
return ConceptType.INDIVIDUAL;
}
return null;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:34,代码来源:OntologyGraphGenerator.java
示例14: addDtProperty
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
public boolean addDtProperty(DatatypeProperty dtProperty) {
if (!dtProperties.contains(dtProperty)) {
dtProperties.add(dtProperty);
return true;
}
return false;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:8,代码来源:OwlToSadl.java
示例15: applyImpliedPropertiesToSide
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
private Object applyImpliedPropertiesToSide(Object side, Expression element) throws TranslationException {
Map<EObject, List<Property>> impprops = OntModelProvider.getAllImpliedProperties(getCurrentResource());
if (impprops != null) {
Iterator<EObject> imppropitr = impprops.keySet().iterator();
while (imppropitr.hasNext()) {
EObject eobj = imppropitr.next();
String uri = null;
if (eobj instanceof SadlResource) {
uri = getDeclarationExtensions().getConceptUri((SadlResource) eobj);
} else if (eobj instanceof Name) {
uri = getDeclarationExtensions().getConceptUri(((Name) eobj).getName());
}
if (uri != null) {
if (side instanceof NamedNode) {
if (((NamedNode) side).toFullyQualifiedString().equals(uri)) {
List<Property> props = impprops.get(eobj);
if (props != null && props.size() > 0) {
if (props.size() > 1) {
throw new TranslationException("More than 1 implied property found!");
}
// apply impliedProperties
NamedNode pred = new NamedNode(props.get(0).getURI());
if (props.get(0) instanceof DatatypeProperty) {
pred.setNodeType(NodeType.DataTypeProperty);
} else if (props.get(0) instanceof ObjectProperty) {
pred.setNodeType(NodeType.ObjectProperty);
} else {
pred.setNodeType(NodeType.PropertyNode);
}
return new TripleElement((NamedNode) side, pred, new VariableNode(getNewVar(element)));
}
}
}
}
}
}
return side;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:40,代码来源:JenaBasedSadlModelProcessor.java
示例16: setPropertyConceptNameType
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
public void setPropertyConceptNameType(ConceptName predcn, Property predProp) {
if (predProp instanceof ObjectProperty) {
predcn.setType(ConceptType.OBJECTPROPERTY);
} else if (predProp instanceof DatatypeProperty) {
predcn.setType(ConceptType.DATATYPEPROPERTY);
} else if (predProp instanceof AnnotationProperty) {
predcn.setType(ConceptType.ANNOTATIONPROPERTY);
} else {
predcn.setType(ConceptType.RDFPROPERTY);
}
}
开发者ID:crapo,项目名称:sadlos2,代码行数:12,代码来源:JenaBasedSadlModelProcessor.java
示例17: getOrCreateDatatypeProperty
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
private DatatypeProperty getOrCreateDatatypeProperty(String propUri) throws JenaProcessorException {
DatatypeProperty prop = getTheJenaModel().getDatatypeProperty(propUri);
if (prop == null) {
prop = createDatatypeProperty(propUri, null);
}
return prop;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:8,代码来源:JenaBasedSadlModelProcessor.java
示例18: checkForExistingCompatibleDatatypeProperty
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
private boolean checkForExistingCompatibleDatatypeProperty(String propUri, RDFNode rngNode) {
DatatypeProperty prop = getTheJenaModel().getDatatypeProperty(propUri);
if (prop != null) {
OntResource rng = prop.getRange();
if (rng != null && rng.equals(rngNode)) {
return true;
}
}
return false;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:11,代码来源:JenaBasedSadlModelProcessor.java
示例19: modify
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
public Alterator modify( Properties params ) {
String p = params.getProperty( ParametersIds.ADD_PROPERTIES );
if ( p == null ) return null;
float percentage = Float.parseFloat( p );
List<OntProperty> properties = this.getOntologyProperties();
List<OntClass> classes = this.getOntologyClasses();
ObjectProperty property = null;
DatatypeProperty d = null;
Random classRand = new Random();
int index;
int nbClasses = classes.size(); //the number of classes
int nbProperties = properties.size(); //the number of properties
int toBeAdd = Math.round( percentage*nbProperties ); //the number of properties to be add
for ( int i=0; i<toBeAdd/2; i++ ) { //add object properties
//p = modifiedModel.createObjectProperty( modifiedOntologyNS + "OBJECT_PROPERTY_" + getRandomString() );
property = modifiedModel.createObjectProperty( modifiedOntologyNS + getRandomString() );
index = classRand.nextInt( nbClasses ); //pick random domain
property.addDomain( classes.get( index ) );
index = classRand.nextInt( nbClasses ); //pick random range
property.addRange( classes.get( index ) );
}
for ( int i=toBeAdd/2; i<toBeAdd; i++ ) { //add datatype properties
//d = modifiedModel.createDatatypeProperty( modifiedOntologyNS + "DATATYPE_PROPERTY_" + getRandomString() );
d = modifiedModel.createDatatypeProperty( modifiedOntologyNS + getRandomString() );
index = classRand.nextInt( nbClasses ); //add domain
d.addDomain( classes.get( index ) );
d.addRange( XSD.xstring ); //add range -> string
}
return this; // useless
}
开发者ID:dozed,项目名称:align-api-project,代码行数:33,代码来源:AddProperties.java
示例20: nuevo
import com.hp.hpl.jena.ontology.DatatypeProperty; //导入依赖的package包/类
public void nuevo() {
Docente doc = new Docente();
doc.setApellido(apellido.toUpperCase());
doc.setNombre(nombre.toUpperCase());
doc.setCodocente(codocente);
doc.setTipo(tipo);
try {
this.docenteFacade.create(doc);
ModeloBean ont = (ModeloBean) FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get("modeloBean");
String nS = ont.getPrefijo();
OntModel modelo = ont.getModelOnt();
OntClass claseDoc = modelo.getOntClass(nS + clase);
Individual docente = modelo.createIndividual(nS + clase + codocente, claseDoc);
DatatypeProperty codigo_docente = modelo.getDatatypeProperty(nS + "identificacion_persona");
DatatypeProperty apellido_docente = modelo.getDatatypeProperty(nS + "apellido_persona");
DatatypeProperty nombre_docente = modelo.getDatatypeProperty(nS + "nombre_persona");
DatatypeProperty tip = modelo.getDatatypeProperty(nS + "tipo_vinculacion");
docente.setPropertyValue(nombre_docente, modelo.createTypedLiteral(doc.getNombre()));
docente.setPropertyValue(apellido_docente, modelo.createTypedLiteral(doc.getApellido()));
docente.setPropertyValue(codigo_docente, modelo.createTypedLiteral(doc.getCodocente()));
int vinculacion = 0;
if (doc.getTipo() == 'I') {
vinculacion = 1;
}
System.out.println(vinculacion);
docente.setPropertyValue(tip, modelo.createTypedLiteral(vinculacion, XSDDatatype.XSDint));
ont.guardarModelo(modelo);
reset();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Registro Exitoso", ""));
} catch (Exception e) {
System.out.println(e.toString());
FacesContext.getCurrentInstance().
addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error al registrar docente ", ""));
}
}
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:37,代码来源:DocenteBean.java
注:本文中的com.hp.hpl.jena.ontology.DatatypeProperty类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论