private void addParent(Class<?> clazz, OWLClass owlClass, Session session, Map<UID, RDFSResource> resources) { RDFSClass<RDFSResource> parent = processClass(session, clazz, resources); if (parent != null) { owlClass.addSuperClass(parent); } }
public void export(Format format, OutputStream os) { try { export(); repository.export(format, ns2prefix, null, os); } finally { try { os.close(); } catch (IOException e) { throw new RepositoryException(e); } } }
owlClass = new ReferenceClass(cuid); } else { owlClass = (OWLClass) resources.get(cuid); addParent(clazz.getSuperclass(), owlClass, session, resources); addParent(iface, owlClass, session, resources); for (Object constant : clazz.getEnumConstants()) { Enum enumValue = (Enum) constant; oneOf.add(new AnyThing(new UID(cuid.ns(), enumValue.name()), owlClass, enumValue.ordinal())); processProperty(session, resources, owlClass, cuid, mappedPath);
@Test public void test() throws IOException { Configuration configuration = new DefaultConfiguration(User.class, Project.class, Gender.class, Various.class); MiniRepository repository = new MiniRepository(); SchemaGen schemaGen = new SchemaGen(); schemaGen.addExportNamespace(TEST.NS); schemaGen.setConfiguration(configuration); schemaGen.setRepository(repository); schemaGen.export(); CloseableIterator<STMT> stmts = repository.findStatements(null, CORE.enumOrdinal, null, null, false); try { System.out.println(stmts.next()); System.out.println(stmts.next()); assertFalse(stmts.hasNext()); } finally { stmts.close(); } Session session = SessionUtil.openSession(repository, OWLClass.class.getPackage(), RDFSClass.class.getPackage()); session.findInstances(RDFSClass.class); }
if (property.getRange().isEmpty()) { RDFSClass<?> componentType = processClass(session, mappedProperty.getComponentType(), resources); if (useTypedLists && componentType != null) { property.addRange(new TypedList(cuid.ns(), componentType)); processClass(session, mappedProperty.getComponentType(), resources); if (componentType != null) { RDFSClass<?> range = processClass(session, mappedProperty.getType(), resources); if (range != null) { owlClass.setAllValuesFrom(property, getDatatype(range, resources));
public void export() { SessionFactoryImpl sessionFactory = new SessionFactoryImpl(); sessionFactory.setConfiguration(new DefaultConfiguration(RDFSClass.class.getPackage(), OWLClass.class.getPackage())); sessionFactory.setRepository(repository); sessionFactory.initialize(); Session session = sessionFactory.openSession(); if (ontology != null) { Ontology ont = new Ontology(new UID(ontology)); if (ontologyImports != null) { for (String oimport : ontologyImports) { ont.addImport(new Ontology(new UID(oimport))); } } session.save(ont); } Map<UID, RDFSResource> resources = new HashMap<UID, RDFSResource>(); resources.put(RDF.List, new RDFSClass<RDFSResource>(RDF.List)); resources.put(RDF.first, new RDFProperty(RDF.first)); resources.put(RDF.rest, new RDFProperty(RDF.rest)); resources.put(RDF.type, new RDFProperty(RDF.type)); resources.put(RDFS.label, new RDFProperty(RDFS.label)); resources.put(RDFS.comment, new RDFProperty(RDFS.comment)); resources.put(RDFS.Resource, new RDFSClass<Object>(RDFS.Resource)); // process classes for (MappedClass mappedClass : configuration.getMappedClasses()) { processClass(session, mappedClass.getJavaClass(), resources); } // save resources session.saveAll(resources.values().toArray()); }