universAAL / tools.eclipse-plugins

Tools in form of Eclipse plugins that help developers use universAAL
2 stars 1 forks source link

OWL file generation from JAVA does not work #445

Open softwareEngineersOrg opened 4 years ago

softwareEngineersOrg commented 4 years ago

Hi,

I have some problem with generate owl. I try to generate owl file from java source. I'm trying to follow the instructions

https://github.com/universAAL/tools.eclipse-plugins/wiki/Transformation-OWL-UML-Java

Unfortunately, it doesn't generate this owl file. When I click 1OWLCreator.java file in model explorer, i see only code below with some error comment on 4, 6, 8 line

package org.universAAL.ontology.test_0.creator;

.1.1Ontology; ("Syntax error on tokens, delete the tokens")

public class 1OWLCreator { ("Syntax error on token "1", delete the tokens")

private static 1Ontology ontology = new 1Ontology(); (Multiple markers at this line, ("Syntax error on tokens, delete the tokens", ("Syntax error on tokens, delete the tokens")

private static MessageContentSerializer contentSerializer = new TurtleSerializer();

public static void main(String[] args) { OntologyManagement.getInstance().register(null, ontology); String serializedOntology = contentSerializer.serialize(ontology); try { BufferedWriter out = new BufferedWriter(new FileWriter("1.owl", false)); out.write(serializedOntology); out.close(); } catch (IOException e) { System.out.println("Exception ");

}

File file = new File("1.owl");
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
IRI documentIRI = IRI.create(file);
OWLOntology owlOntology;
try {
    owlOntology = manager.loadOntologyFromOntologyDocument(documentIRI);
    System.out.println("Loaded ontology: " + owlOntology);

    OWLOntologyFormat format = manager.getOntologyFormat(owlOntology);

    RDFXMLOntologyFormat rdfxmlFormat = new RDFXMLOntologyFormat();
    if(format.isPrefixOWLOntologyFormat()) {
        rdfxmlFormat.copyPrefixesFrom(format.asPrefixOWLOntologyFormat());
    }
    manager.saveOntology(owlOntology, rdfxmlFormat, IRI.create(file));
    System.out.println("Saved ontology " + owlOntology + " in file 1.owl");
} catch (OWLOntologyCreationException e1) {
    e1.printStackTrace();
} catch (OWLOntologyStorageException e) {
    e.printStackTrace();
}

return;

} }

Thank you in advance for your suggestions. I need to generate an owl file in this tool, according to the universAAl manual.

Please help me! Artur