コード例 #1
0
  @Override
  public void create(Collection errors) throws OntologyLoadException {
    project = Project.createNewProject(factory, errors);
    owlModel = (JenaOWLModel) project.getKnowledgeBase();

    if (ontologyName == null) {
      ontologyName = FactoryUtils.generateOntologyURIBase();
    }
    try {
      FactoryUtils.addOntologyToTripleStore(
          owlModel, owlModel.getTripleStoreModel().getActiveTripleStore(), ontologyName);
    } catch (AlreadyImportedException e) {
      throw new RuntimeException("This shouldn't happen", e);
    }
    addViewSettings(project.getSources());
  }
コード例 #2
0
 @SuppressWarnings("unchecked")
 public JenaOWLModel reload(JenaOWLModel owlModel) throws Exception {
   Collection errors = new ArrayList();
   OntModel ontModel = owlModel.getOntModel();
   ByteArrayOutputStream stream = new ByteArrayOutputStream();
   Jena.dumpRDF(ontModel, stream);
   String str = stream.toString();
   StringReader reader = new StringReader(str);
   if (log.isLoggable(Level.FINE)) {
     log.fine("Saved ontology to string");
     log.fine(str);
     log.fine("reloading...");
   }
   OwlProjectFromReaderCreator creator = new OwlProjectFromReaderCreator();
   creator.setReader(reader);
   creator.create(errors);
   return creator.getOwlModel();
 }
コード例 #3
0
  ProtegeSettingsPanel(final JenaOWLModel owlModel) {
    this.owlModel = owlModel;

    importMetaCBox = new JCheckBox("Import Protege metadata ontology");
    importMetaCBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (importMetaCBox.isSelected()) {
              enableProtegeOntology();
            } else {
              disableProtegeOntology();
            }
          }
        });
    if (owlModel.isProtegeMetaOntologyImported()) {
      importMetaCBox.setSelected(true);
      if (!isMetadataOntologyImportedDirectly(OWLUtil.getActiveOntology(owlModel))) {
        importMetaCBox.setEnabled(false);
      }
    }

    userDatatypesCBox = new JCheckBox("Support user-defined XML Schema datatypes (numeric ranges)");
    userDatatypesCBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setUserDefinedDatatypesSupported(owlModel, userDatatypesCBox.isSelected());
            ProtegeUI.reloadUI(owlModel);
          }
        });
    userDatatypesCBox.setEnabled(importMetaCBox.isSelected());
    userDatatypesCBox.setSelected(ProtegeSettingsPanel.isUserDefinedDatatypesSupported(owlModel));

    setBorder(BorderFactory.createTitledBorder("Protege Features"));
    setLayout(new GridLayout(2, 1));
    add(importMetaCBox);
    add(userDatatypesCBox);
  }
コード例 #4
0
 public JenaOWLModel reloadWithJenaLoader(JenaOWLModel owlModel) throws Exception {
   ByteArrayOutputStream stream = new ByteArrayOutputStream();
   Jena.dumpRDF(owlModel.getOntModel(), stream);
   String str = stream.toString();
   return ProtegeOWL.createJenaOWLModelFromReader(new StringReader(str));
 }