本文整理汇总了Java中cz.cvut.kbss.jopa.CommonVocabulary类的典型用法代码示例。如果您正苦于以下问题:Java CommonVocabulary类的具体用法?Java CommonVocabulary怎么用?Java CommonVocabulary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommonVocabulary类属于cz.cvut.kbss.jopa包,在下文中一共展示了CommonVocabulary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyDataPresence
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
public void verifyDataPresence(Collection<Triple> data, EntityManager em) throws Exception {
final OWLOntology ontology = em.unwrap(OWLOntology.class);
final OWLDataFactory df = ontology.getOWLOntologyManager().getOWLDataFactory();
for (Triple t : data) {
final OWLNamedIndividual ind = df.getOWLNamedIndividual(IRI.create(t.getSubject()));
if (t.getProperty().toString().equals(CommonVocabulary.RDF_TYPE)) {
final OWLClass cls = df.getOWLClass(IRI.create(t.getValue().toString()));
assertTrue(ontology.containsAxiom(df.getOWLClassAssertionAxiom(cls, ind)));
} else if (t.getValue() instanceof URI) {
final OWLObjectProperty op = df.getOWLObjectProperty(IRI.create(t.getProperty()));
final OWLNamedIndividual obj = df.getOWLNamedIndividual(IRI.create((URI) t.getValue()));
assertTrue(ontology.containsAxiom(df.getOWLObjectPropertyAssertionAxiom(op, ind, obj)));
} else {
final OWLAnnotationProperty ap = df.getOWLAnnotationProperty(IRI.create(t.getProperty()));
final OWLLiteral value = OwlapiUtils.createOWLLiteralFromValue(t.getValue(), df, t.getLanguage());
final OWLAxiom apAxiom = df.getOWLAnnotationAssertionAxiom(ap, ind.getIRI(), value);
final OWLDataProperty dp = df.getOWLDataProperty(IRI.create(t.getProperty()));
final OWLAxiom dpAxiom = df.getOWLDataPropertyAssertionAxiom(dp, ind, value);
assertTrue(ontology.containsAxiom(apAxiom) || ontology.containsAxiom(dpAxiom));
}
}
}
示例2: visitFieldExtractsValueOfAnnotationPropertyAndAddsNodeToTheRoot
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
@Test
public void visitFieldExtractsValueOfAnnotationPropertyAndAddsNodeToTheRoot() throws Exception {
final Organization org = Generator.generateOrganization();
treeBuilder.openInstance(org);
treeBuilder.visitField(Organization.class.getDeclaredField("name"), org.getName());
assertFalse(treeBuilder.getTreeRoot().getItems().isEmpty());
assertTrue(treeBuilder.getTreeRoot().getItems()
.contains(JsonNodeFactory.createLiteralNode(CommonVocabulary.RDFS_LABEL, org.getName())));
}
示例3: indexEntityAttributes
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
private static <T> Map<URI, FieldSpecification<? super T, ?>> indexEntityAttributes(EntityType<T> et) {
final Map<URI, FieldSpecification<? super T, ?>> atts = new HashMap<>(et.getAttributes()
.size());
for (Attribute<? super T, ?> at : et.getAttributes()) {
atts.put(at.getIRI().toURI(), at);
}
if (et.getTypes() != null) {
atts.put(URI.create(CommonVocabulary.RDF_TYPE), et.getTypes());
}
return atts;
}
示例4: buildsMetamodelOfEntityWithNamespaceUsedOnAttribute
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
@Test
public void buildsMetamodelOfEntityWithNamespaceUsedOnAttribute() {
when(finderMock.getEntities()).thenReturn(Collections.singleton(EntityWithNamespace.class));
builder.buildMetamodel(finderMock);
final EntityType<EntityWithNamespaceAttributes> result =
(EntityType<EntityWithNamespaceAttributes>) builder.getEntityClass(EntityWithNamespaceAttributes.class);
assertEquals("http://www.example2.org/EntityWithNamespaceAttributes", result.getIRI().toString());
final Attribute<? super EntityWithNamespaceAttributes, ?> labelAtt = result.getAttribute("label");
assertEquals(CommonVocabulary.RDFS_LABEL, labelAtt.getIRI().toString());
final Attribute<? super EntityWithNamespaceAttributes, ?> descriptionAtt = result.getAttribute("description");
assertEquals(CommonVocabulary.DC_DESCRIPTION, descriptionAtt.getIRI().toString());
}
示例5: queryWithEntityMappingLoadsReferencedEntityAndInheritedAttributes
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
@Test
public void queryWithEntityMappingLoadsReferencedEntityAndInheritedAttributes() {
final List res = getEntityManager().createNativeQuery("SELECT * WHERE {" +
"?x a ?type ;" +
"?hasA ?y ;" +
"?rdfsLabel ?label ;" +
"?hasDescription ?description ;" +
"?hasInt ?intAttribute ." +
"}", OWLClassT.MAPPING_NAME)
.setParameter("type", URI.create(Vocabulary.C_OWL_CLASS_T))
.setParameter("hasA", URI.create(Vocabulary.P_HAS_OWL_CLASS_A))
.setParameter("rdfsLabel", URI.create(CommonVocabulary.RDFS_LABEL))
.setParameter("hasDescription", URI.create(CommonVocabulary.DC_DESCRIPTION))
.setParameter("hasInt", URI.create(Vocabulary.P_T_INTEGER_ATTRIBUTE))
.getResultList();
final Map<URI, OWLClassT> expected = new HashMap<>();
QueryTestEnvironment.getData(OWLClassT.class).forEach(t -> expected.put(t.getUri(), t));
assertEquals(expected.size(), res.size());
for (Object row : res) {
assertTrue(row instanceof OWLClassT);
final OWLClassT tActual = (OWLClassT) row;
assertTrue(expected.containsKey(tActual.getUri()));
final OWLClassT tExpected = expected.get(tActual.getUri());
assertEquals(tExpected.getName(), tActual.getName());
assertEquals(tExpected.getDescription(), tActual.getDescription());
assertEquals(tExpected.getIntAttribute(), tActual.getIntAttribute());
verifyOwlClassAInstance(tExpected.getOwlClassA(), tActual.getOwlClassA());
}
}
示例6: selectLoadsInstanceOfMostConcreteSubclassOfAbstractEntity
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
@Test
public void selectLoadsInstanceOfMostConcreteSubclassOfAbstractEntity() {
final OWLClassT t = Generators.getRandomItem(QueryTestEnvironment.getData(OWLClassT.class));
final EntityManager em = getEntityManager();
final OWLClassSParent result =
em.createNativeQuery("SELECT ?x WHERE { ?x ?hasName ?name . }", OWLClassSParent.class)
.setParameter("hasName", URI.create(CommonVocabulary.RDFS_LABEL))
.setParameter("name", t.getName(), "en").getSingleResult();
assertNotNull(result);
assertTrue(result instanceof OWLClassT);
verifyEntityTAttributes(t, (OWLClassT) result);
}
示例7: selectLoadsInstanceOfMostConcreteSubclassOfConcreteEntity
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
@Test
public void selectLoadsInstanceOfMostConcreteSubclassOfConcreteEntity() {
final OWLClassT t = Generators.getRandomItem(QueryTestEnvironment.getData(OWLClassT.class));
final EntityManager em = getEntityManager();
final OWLClassS result =
em.createNativeQuery("SELECT ?x WHERE { ?x ?hasName ?name . }", OWLClassS.class)
.setParameter("hasName", URI.create(CommonVocabulary.RDFS_LABEL))
.setParameter("name", t.getName(), "en").getSingleResult();
assertNotNull(result);
assertTrue(result instanceof OWLClassT);
verifyEntityTAttributes(t, (OWLClassT) result);
}
示例8: initAxiomsForR
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
private Collection<Axiom<?>> initAxiomsForR(URI uri, String name) {
final NamedResource nr = NamedResource.create(uri);
final String typeIri = OWLClassR.class.getDeclaredAnnotation(OWLClass.class).iri();
return Arrays.asList(new AxiomImpl<>(nr, Assertion.createClassAssertion(false),
new Value<>(NamedResource.create(typeIri))),
new AxiomImpl<>(nr,
Assertion.createAnnotationPropertyAssertion(URI.create(CommonVocabulary.RDFS_LABEL), false),
new Value<>(name)));
}
示例9: getAttributeIdentifierReturnsIriOfOWLAnnotationProperty
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
@Test
public void getAttributeIdentifierReturnsIriOfOWLAnnotationProperty() throws Exception {
final String id = BeanAnnotationProcessor.getAttributeIdentifier(Organization.class.getDeclaredField("name"));
assertEquals(CommonVocabulary.RDFS_LABEL, id);
}
示例10: ensureCreated
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
private JDefinedClass ensureCreated(final ContextDefinition ctx,
final String pkg, final JCodeModel cm, final OWLClass clazz,
final OWLOntology ontology) {
if (classes.containsKey(clazz)) {
return classes.get(clazz);
}
JDefinedClass cls;
String name = pkg + javaClassId(ontology, clazz, ctx);
try {
cls = cm._class(name);
cls.annotate(
cz.cvut.kbss.jopa.model.annotations.OWLClass.class)
.param("iri", entities.get(clazz));
final JDocComment dc = cls.javadoc();
dc.add("This class was generated by the OWL2Java tool version " + VERSION);
// if (clazz.equals(f.getOWLThing())) {
// RDFS label
final JClass ftLabel = cm.ref(String.class);
final JFieldVar fvLabel = addField("name", cls, ftLabel);
fvLabel.annotate(OWLAnnotationProperty.class).param("iri",
cm.ref(CommonVocabulary.class).staticRef("RDFS_LABEL"));
// DC description
final JClass ftDescription = cm.ref(String.class);
final JFieldVar fvDescription = addField("description", cls, ftDescription);
fvDescription.annotate(OWLAnnotationProperty.class).param("iri",
cm.ref(CommonVocabulary.class).staticRef("DC_DESCRIPTION"));
// @Types Set<String> types;
final JClass ftTypes = cm.ref(Set.class).narrow(String.class);
final JFieldVar fvTypes = addField("types", cls, ftTypes);
fvTypes.annotate(Types.class);
// @Id public final String id;
final JClass ftId = cm.ref(String.class);
final JFieldVar fvId = addField("id", cls, ftId);
JAnnotationUse a = fvId.annotate(Id.class);
a.param("generated", true);
// @Properties public final Map<String,Set<String>> properties;
final JClass ftProperties = cm.ref(Map.class).narrow(
cm.ref(String.class),
cm.ref(Set.class).narrow(String.class));
final JFieldVar fvProperties = addField("properties", cls,
ftProperties);
fvProperties.annotate(Properties.class);
// }
} catch (JClassAlreadyExistsException e) {
LOG.trace("Class already exists. Using the existing version. {}", e.getMessage());
cls = cm._getClass(name);
}
classes.put(clazz, cls);
return cls;
}
示例11: getQueryString
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
@Override
public String getQueryString() {
return "\"" + value + "\"^^<" + CommonVocabulary.XSD_LONG + ">";
}
示例12: getQueryString
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
@Override
public String getQueryString() {
return "\"" + value + "\"^^<" + CommonVocabulary.XSD_BOOLEAN + ">";
}
示例13: getQueryString
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
@Override
public String getQueryString() {
return "\"" + value + "\"^^<" + CommonVocabulary.XSD_DATETIME + ">";
}
示例14: getQueryString
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
@Override
public String getQueryString() {
return "\"" + value + "\"^^<" + CommonVocabulary.XSD_INT + ">";
}
示例15: getQueryString
import cz.cvut.kbss.jopa.CommonVocabulary; //导入依赖的package包/类
@Override
public String getQueryString() {
return "\"" + value +"\"^^<" + CommonVocabulary.XSD_SHORT + ">";
}