Difference between revisions of "BeanshellView"

From Protege Wiki
Jump to: navigation, search
(Added some examples)
Line 1: Line 1:
 
{{Plugin
 
{{Plugin
|Description=Some coding just doesn't justify setting up an entire java build environment. Some coding requires immediate feedback. Using the Beanshell view, any user can now access the power of the P4 to query and manipulate ontologies or even interact with the UI.
+
|Description=Some coding just doesn't justify setting up an entire java build environment. Some coding requires immediate feedback. Using the Beanshell view, any user can now access the power of the P4 to query and manipulate ontologies or even interact with the UI. For more information see the Beanshell Website
 
 
Most of P4 can be accessed from the OWLEditorKit or OWLModelManager (variables eKit and mngr respectively).
 
 
 
For more information see the Beanshell Website
 
 
|PluginType=View
 
|PluginType=View
 
|ForApplication1=Protege-OWL
 
|ForApplication1=Protege-OWL
Line 17: Line 13:
 
|Affiliation2=The University Of Manchester
 
|Affiliation2=The University Of Manchester
 
}}
 
}}
 +
<br style="clear: both;" />
 +
 
== Examples ==
 
== Examples ==
  
Here are some code examples you could try
+
Most of P4 can be accessed from the OWLEditorKit or OWLModelManager (variables '''eKit''' and '''mngr''' respectively).
 +
 
 +
Here are some code examples you could try.
  
 
=== Creating a new class in the current ontology ===
 
=== Creating a new class in the current ontology ===
Line 27: Line 27:
 
   changes = fac.createOWLClass("myNewClass", ont.getURI());
 
   changes = fac.createOWLClass("myNewClass", ont.getURI());
 
   mngr.applyChanges(changes.getOntologyChanges());
 
   mngr.applyChanges(changes.getOntologyChanges());
 +
  c = changes.getOWLEntity();
  
 
=== Check if the current ontology is valid OWL DL ===
 
=== Check if the current ontology is valid OWL DL ===

Revision as of 09:51, November 14, 2008

BeanshellView

by Nick Drummond

Screenshot

Type View
Author(s) Nick Drummond
Last Update November 14, 2008
License LGPL
Homepage BeanshellView website
For Application
Topic(s)
Affiliation

Some coding just doesn't justify setting up an entire java build environment. Some coding requires immediate feedback. Using the Beanshell view, any user can now access the power of the P4 to query and manipulate ontologies or even interact with the UI. For more information see the Beanshell Website

Versions & Compatibility

This section lists available versions of BeanshellView.

VersionCompatible withDependencies
BeanshellView 1.1.1Protege-OWL 4.2
Protege-OWL 4.1
BeanshellView 1.0.0Protege-OWL 4.0

If you click on the button below to add a new version of BeanshellView, you will be asked to define a page title for the new version. Please adhere to the naming convention of BeanshellView X.X.X when you define the new page!

Changelog

VersionChanges in this version
BeanshellView 1.1.1see page for more details
BeanshellView 1.0.0see page for more details



Examples

Most of P4 can be accessed from the OWLEditorKit or OWLModelManager (variables eKit and mngr respectively).

Here are some code examples you could try.

Creating a new class in the current ontology

 ont = mngr.getActiveOntology();
 fac = mngr.getOWLEntityFactory();
 changes = fac.createOWLClass("myNewClass", ont.getURI());
 mngr.applyChanges(changes.getOntologyChanges());
 c = changes.getOWLEntity();

Check if the current ontology is valid OWL DL

 import  org.semanticweb.owl.profiles.*;
 dlProfile = new OWLDLProfile();
 ont = mngr.getActiveOntology();
 dlProfile.checkOntology(ont, mngr.getOWLOntologyManager());
 report = dlProfile.checkOntology(ont, mngr.getOWLOntologyManager());
 print(report.isInProfile());
 nonDLConstructs = report.getDisallowedConstructs();
 for (c : nonDLConstructs) {
 print(c);
 }

Pick a class to use in a script

 uiHelper = new UIHelper(eKit);
 c = uiHelper.pickOWLClass();
 print(c);

Use a reasoner

First make sure a reasoner has been selected and the ontology is classified.

 import org.semanticweb.owl.inference.*;
 r = mngr.getReasoner();
 c = // get your class here - for example as above
 subs = OWLReasonerAdapter.flattenSetOfSets(r.getSubClasses(c));
 print(subs);

Note the use of OWLReasonerAdapter as the reasoners return equivalence sets.