|
|
|
@ -18,6 +18,7 @@ import org.semanticweb.owlapi.io.StreamDocumentTarget;
|
|
|
|
|
import org.semanticweb.owlapi.model.OWLOntology;
|
|
|
|
|
|
|
|
|
|
import de.unibremen.informatik.hets.protege.ImportHetsAction;
|
|
|
|
|
import de.unibremen.informatik.hets.model.HetFile;
|
|
|
|
|
import org.semanticweb.owlapi.model.IRI;
|
|
|
|
|
|
|
|
|
|
public class ExportHetsAction extends ProtegeOWLAction {
|
|
|
|
@ -41,27 +42,6 @@ public class ExportHetsAction extends ProtegeOWLAction {
|
|
|
|
|
public void dispose() throws Exception {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String dumpOntologyToString(String name) {
|
|
|
|
|
String result;
|
|
|
|
|
|
|
|
|
|
OWLOntologyManager ontologymanager = this.getOWLModelManager().getOWLOntologyManager();
|
|
|
|
|
ByteArrayOutputStream outputstream = new ByteArrayOutputStream();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
ontologymanager.saveOntology(ontologymanager.getOntology(IRI.create("http://informatik.uni-bremen.de/hets/"+name+".het")), outputstream);
|
|
|
|
|
} catch (OWLOntologyStorageException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
result = outputstream.toString();
|
|
|
|
|
result = result.replaceAll("(?m)^Prefix: .*$", "");
|
|
|
|
|
result = result.replaceAll("(?m)^Ontology: .*$", "");
|
|
|
|
|
result = result.replaceAll("(?m)^Import: .*$", "");
|
|
|
|
|
result = result.replaceAll("(?m)^\\s*$[\n\r]{1,}", "");
|
|
|
|
|
result = result.replaceAll("(?m)(^.*$)", " $1");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
@ -81,6 +61,7 @@ public class ExportHetsAction extends ProtegeOWLAction {
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Set<String> exts = new HashSet<String>();
|
|
|
|
|
exts.add("het");
|
|
|
|
|
exts.add("owl");
|
|
|
|
@ -103,5 +84,26 @@ public class ExportHetsAction extends ProtegeOWLAction {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
HetFile hetfile = ImportedHetFile.getHetFile();
|
|
|
|
|
|
|
|
|
|
Set<String> exts = new HashSet<String>();
|
|
|
|
|
exts.add("het");
|
|
|
|
|
exts.add("owl");
|
|
|
|
|
File f = UIUtil.saveFile(this.getOWLWorkspace(), "title", "description", exts, "foobar.het");
|
|
|
|
|
|
|
|
|
|
if (f.exists()) {
|
|
|
|
|
// TODO: ask if overwrite
|
|
|
|
|
f.delete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
FileOutputStream outputFile = new FileOutputStream(f, true);
|
|
|
|
|
outputFile.write(hetfile.toString(this.getOWLModelManager().getOWLOntologyManager()).getBytes());
|
|
|
|
|
outputFile.close();
|
|
|
|
|
} catch (IOException e1) {
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|