Skip to content
Snippets Groups Projects
Commit 896fdee8 authored by Alexander Marinc's avatar Alexander Marinc
Browse files

Added preliminary version of the Java to OWL support

parent a2de5084
No related branches found
No related tags found
No related merge requests found
Showing
with 140 additions and 22 deletions
......@@ -57,7 +57,8 @@ public class CreateOntologyPOM {
static Dependency[] dependencies = new Dependency[] {
dep("org.apache.felix", "org.osgi.core", "1.0.1"),
dep("org.universAAL.middleware","mw.data.representation", "1.1.0"),
dep("org.universAAL.middleware", "mw.data.serialization", "1.1.0"),
dep("org.universAAL.middleware", "mw.data.representation", "1.1.0"),
dep("org.universAAL.middleware", "mw.bus.model", "1.1.0"),
dep("org.universAAL.middleware", "mw.container.xfaces", "1.1.0"),
dep("org.universAAL.middleware", "mw.container.osgi","1.1.0" ),
......@@ -65,8 +66,7 @@ public class CreateOntologyPOM {
dep("org.universAAL.middleware", "mw.bus.context", "1.1.0"),
dep("org.universAAL.middleware", "mw.bus.ui", "1.1.0"),
dep("org.universAAL.ontology", "ont.phWorld", "1.1.0"),
dep("org.universAAL.ontology", "ont.profile", "1.1.0")
dep("org.universAAL.ontology", "ont.profile", "1.1.0")
};
static Repository[] repositories = new Repository[] {
......
......@@ -147,6 +147,14 @@ public class OntologyMainPage extends WizardPage {
txtMavendescription = new Text(container, SWT.BORDER);
txtMavendescription.setText("mavenDescription");
txtMavendescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
Label label_2 = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
label_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
btnGenerateJavaToOWL = new Button(container, SWT.CHECK);
btnGenerateJavaToOWL.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
btnGenerateJavaToOWL.setText("Generate Java to OWL support file");
m_bindingContext = initDataBindings();
}
......@@ -160,6 +168,7 @@ public class OntologyMainPage extends WizardPage {
private Label lblMavenVersion;
private Label lblJavaPackageName;
private Text txtJavaPackageName;
private Button btnGenerateJavaToOWL;
public void setModel(OntologyProjectModel model) {
this.model = model;
......@@ -215,6 +224,10 @@ public class OntologyMainPage extends WizardPage {
IObservableValue modelPackageNameObserveValue_1 = BeansObservables.observeValue(model, "packageName");
bindingContext.bindValue(txtJavaPackageNameObserveTextObserveWidget, modelPackageNameObserveValue_1, null, null);
//
IObservableValue btnGenerateJavaToOWLObserveSelectionObserveWidget = SWTObservables.observeDelayedValue(100, SWTObservables.observeSelection(btnGenerateJavaToOWL));
IObservableValue modelbtnGenerateJavaToOWLObserveValue = BeansObservables.observeValue(model, "generateJavaToOWL");
bindingContext.bindValue(btnGenerateJavaToOWLObserveSelectionObserveWidget, modelbtnGenerateJavaToOWLObserveValue, null, null);
//
return bindingContext;
}
}
......@@ -15,6 +15,7 @@ public class OntologyProjectModel {
String parentPackageName = "pck";
boolean useSimpleMode = true;
boolean generateJavaToOWL = true;
String projectName;
String packageName;
......@@ -75,6 +76,16 @@ public class OntologyProjectModel {
support.firePropertyChange("useSimpleMode", this.useSimpleMode, this.useSimpleMode = useDerivedValues);
}
}
public boolean isGenerateJavaToOWL() {
return generateJavaToOWL;
}
public void setGenerateJavaToOWL(boolean useDerivedValues) {
if (this.generateJavaToOWL != useDerivedValues) {
support.firePropertyChange("generateJavaToOWL", this.generateJavaToOWL, this.generateJavaToOWL = useDerivedValues);
}
}
public String getProjectName() {
return projectName;
......
package org.universaal.tools.modelling.ontology.wizard.wizards;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
import org.apache.maven.model.Model;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
......@@ -13,6 +19,7 @@ import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
......@@ -227,6 +234,12 @@ public class OntologyProjectWizard extends Wizard implements INewWizard {
// ignore
}
}
try {
listener.getNewProject().setPersistentProperty(new QualifiedName("generateJavaToOWL", "generateJavaToOWL"), ontologyProjectModel.isGenerateJavaToOWL() ? "true" : "false");
} catch (CoreException e) {
e.printStackTrace();
}
} finally {
workspace.removeResourceChangeListener(listener);
}
......
......@@ -36,6 +36,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
......@@ -128,6 +129,12 @@ public abstract class TransformationHandler extends AbstractHandler implements E
public void doTransform(IFile inputFile, ExecutionEvent event) {
IWorkbenchWindow window = null;
try {
window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
} catch (ExecutionException e2) {
e2.printStackTrace();
}
myConsole = findConsole("MOFScript2 Console");
try {
FontData data = new FontData ("Arial", 9, 9);
......@@ -139,8 +146,14 @@ public abstract class TransformationHandler extends AbstractHandler implements E
}
stream = myConsole.newMessageStream();
stream.setActivateOnWrite(true);
// check if OWLSupport should be generated. TODO: I do not think that persistent properties are the best solution
String generateOWLSupport = "false";
try {
generateOWLSupport = inputFile.getProject().getPersistentProperty(new QualifiedName("generateJavaToOWL", "generateJavaToOWL"));
} catch (CoreException e1) {
e1.printStackTrace();
}
IPath path = new Path(transformationFileName);
URL l = FileLocator.find(Platform.getBundle(thisBundleName), path, null);
......@@ -243,6 +256,8 @@ public abstract class TransformationHandler extends AbstractHandler implements E
execMgr.setRootDirectory(findRootDirectory(project));
System.setProperty("org.universaal.tools.transformationcommand.javadir",
getTrimmedJavaDirectoryFromPreferences() );
System.setProperty("org.universaal.tools.transformationcommand.javaowlsupport",
generateOWLSupport);
// if true, files are not generated to the file system, but populated into a filemodel
// which can be fetched afterwards. Value false will result in standard file generation
......
......@@ -28,6 +28,7 @@ texttransformation OntologyUML2JavaV2 (in uml:"http://www.eclipse.org/uml2/3.0.0
var projectInfo: Hashtable
var importedModels: Hashtable
var javaBasePath:String
var javaOWLSupport:String
var datatypeImportMap:Hashtable
var ontologyClassList:Hashtable
......@@ -47,6 +48,7 @@ texttransformation OntologyUML2JavaV2 (in uml:"http://www.eclipse.org/uml2/3.0.0
var ontologyNameList:Hashtable
javaBasePath = getEnv("org.universaal.tools.transformationcommand.javadir")
javaOWLSupport = getEnv("org.universaal.tools.transformationcommand.javaowlsupport")
if (self.hasStereotype("owlOntology")) {
......@@ -109,6 +111,9 @@ texttransformation OntologyUML2JavaV2 (in uml:"http://www.eclipse.org/uml2/3.0.0
p.generateFactory(ontologyClassList)
if (javaOWLSupport.equals("true"))
p.generateCreator(ontologyClassList)
//at the package to list of ontologies
ontologyNameList.put(p.name.trim(), ontologyName)
......@@ -230,6 +235,7 @@ package ' importName ';
import org.universAAL.middleware.owl.BoundingValueRestriction;
import org.universAAL.middleware.owl.DataRepOntology;
import org.universAAL.middleware.owl.ManagedIndividual;
import org.universAAL.middleware.owl.MergedRestriction;
import org.universAAL.middleware.owl.OntClassInfoSetup;
import org.universAAL.middleware.owl.Ontology;
......@@ -465,7 +471,52 @@ public final class ' ontologyName.firstToUpper() 'Ontology extends Ontology {
}
return datatypeImportMap.get(theTypeName)
}
// generate Creator
uml.Package::generateCreator(ontologyClassList:Hashtable) {
var pName:String = self.getFullPackageName()
file( javaBasePath + "/" + pName.substring(0, pName.lastIndexOf(".")).replace("\\.", "/") + '/creator/' + ontologyName.firstToUpper() + "OWLCreator.java" )
'
package ' pName.substring(0, pName.lastIndexOf(".")) '.creator;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import org.universAAL.middleware.owl.OntologyManagement;
import org.universAAL.middleware.sodapop.msg.MessageContentSerializer;
import org.universAAL.serialization.turtle.TurtleParser;
import ' pName '.' ontologyName.firstToUpper() 'Ontology;
public class ' ontologyName.firstToUpper() 'OWLCreator {
private static ' ontologyName.firstToUpper() 'Ontology ontology = new ' ontologyName.firstToUpper() 'Ontology();
private static MessageContentSerializer contentSerializer = new TurtleParser();
public static void main(String[] args) {
OntologyManagement.getInstance().register(ontology);
String serializedOntology = contentSerializer.serialize(ontology);
try {
BufferedWriter out = new BufferedWriter(new FileWriter("' ontologyName.firstToUpper() '.owl", false));
out.write(serializedOntology);
out.close();
} catch (IOException e) {
System.out.println("Exception ");
}
return;
}
}
'
}
// generate Factory
uml.Package::generateFactory(ontologyClassList:Hashtable) {
var pName:String = self.getFullPackageName()
......@@ -1327,6 +1378,11 @@ public class ' ontologyName.firstToUpper() 'Factory extends ResourceFactoryImpl
<artifactId>org.osgi.core</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.universAAL.middleware</groupId>
<artifactId>mw.data.serialization</artifactId>
<version>1.1.0</version>
</dependency>
'// <!--
' <dependency>
<groupId>org.universAAL.middleware</groupId>
......
......@@ -5,6 +5,16 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.trolltech.qtjambi.juicBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.trolltech.qtjambi.juicBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.trolltech.qtjambi.juicBuilder</name>
<arguments>
......
......@@ -26,29 +26,29 @@
<listEntry value="obr"/>
</listAttribute>
<mapAttribute key="org.ops4j.pax.cursor.provisionItems">
<mapEntry key="wrap:mvn:org.universAAL.ui/ui.handler.gui.tableLayout/1.0-SNAPSHOT" value="true@true@5@false"/>
<mapEntry key="mvn:org.universAAL.support/jena.osgi" value="true@true@5@false"/>
<mapEntry key="wrap:mvn:org.universAAL.ui/ui.handler.gui.tableLayout/1.0-SNAPSHOT" value="true@true@5@false"/>
<mapEntry key="mvn:org.universAAL.middleware/mw.data.representation/1.1.1-SNAPSHOT" value="true@true@4@false"/>
<mapEntry key="mvn:org.apache.felix/org.apache.felix.configadmin/1.2.4" value="true@true@2@false"/>
<mapEntry key="mvn:org.universAAL.middleware/mw.container.xfaces/1.1.1-SNAPSHOT" value="true@true@4@false"/>
<mapEntry key="mvn:org.apache.felix/org.apache.felix.configadmin/1.2.4" value="true@true@2@false"/>
<mapEntry key="wrap:mvn:jp.go.ipa/jgcl/1.0" value="true@true@2@false"/>
<mapEntry key="mvn:org.universAAL.middleware/mw.bus.ui/1.1.1-SNAPSHOT" value="true@true@5@false"/>
<mapEntry key="mvn:org.universAAL.ui/ui.dm/1.1.1-SNAPSHOT" value="true@true@6@true"/>
<mapEntry key="wrap:mvn:mysql/mysql-connector-java/5.1.6" value="true@true@2@false"/>
<mapEntry key="mvn:org.universAAL.ui/ui.dm/1.1.1-SNAPSHOT" value="true@true@6@true"/>
<mapEntry key="wrap:mvn:java3d/vecmath/1.3.1" value="true@true@2@false"/>
<mapEntry key="wrap:mvn:org.ops4j.pax.confman/pax-confman-propsloader/0.2.2" value="true@true@3@false"/>
<mapEntry key="wrap:mvn:org.bouncycastle/jce.jdk13/144" value="true@true@2@false"/>
<mapEntry key="mvn:org.universAAL.context/ctxt.jena.converter/1.1.1-SNAPSHOT" value="true@true@5@false"/>
<mapEntry key="mvn:org.universAAL.middleware/mw.bus.model/1.1.1-SNAPSHOT" value="true@true@3@false"/>
<mapEntry key="wrap:mvn:org.ops4j.pax.logging/pax-logging-api/1.6.0" value="true@true@2@false"/>
<mapEntry key="mvn:org.universAAL.middleware/mw.container.osgi/1.1.1-SNAPSHOT" value="true@true@5@false"/>
<mapEntry key="wrap:mvn:java3d/j3d-core/1.3.1" value="true@true@2@false"/>
<mapEntry key="mvn:org.universAAL.middleware/mw.container.osgi/1.1.1-SNAPSHOT" value="true@true@5@false"/>
<mapEntry key="wrap:mvn:org.ops4j.pax.logging/pax-logging-api/1.6.0" value="true@true@2@false"/>
<mapEntry key="mvn:org.universAAL.middleware/mw.bus.context/1.1.1-SNAPSHOT" value="true@true@5@false"/>
<mapEntry key="wrap:mvn:org.ops4j.pax.logging/pax-logging-service/1.6.0" value="true@true@3@false"/>
<mapEntry key="mvn:org.universAAL.tools.ucc/ucc.viewjambi/1.1.1-SNAPSHOT" value="true@true@8@true"/>
<mapEntry key="mvn:org.universAAL.ontology/ont.profile/1.1.1-SNAPSHOT" value="true@true@6@false"/>
<mapEntry key="mvn:org.universAAL.tools.ucc/ucc.model/1.1.1-SNAPSHOT" value="true@true@7@true"/>
<mapEntry key="mvn:org.universAAL.tools.ucc/ucc.viewjambi/1.1.1-SNAPSHOT" value="true@true@8@true"/>
<mapEntry key="wrap:mvn:org.ops4j.pax.logging/pax-logging-service/1.6.0" value="true@true@3@false"/>
<mapEntry key="mvn:org.universAAL.middleware/mw.data.serialization/1.1.1-SNAPSHOT" value="true@true@4@false"/>
<mapEntry key="mvn:org.universAAL.tools.ucc/ucc.model/1.1.1-SNAPSHOT" value="true@true@7@true"/>
<mapEntry key="mvn:org.universAAL.tools.ucc/ucc.api/1.1.1-SNAPSHOT" value="true@true@7@true"/>
<mapEntry key="mvn:org.universAAL.tools.ucc/ucc.core/1.1.1-SNAPSHOT" value="true@true@7@true"/>
<mapEntry key="wrap:mvn:org.osgi/osgi_R4_compendium/1.0" value="true@true@2@false"/>
......@@ -63,29 +63,29 @@
<listEntry value="--overwriteSystemBundles=false"/>
<listEntry value="--log=DEBUG"/>
<listEntry value="--profiles=obr"/>
<listEntry value="wrap:mvn:org.universAAL.ui/ui.handler.gui.tableLayout/1.0-SNAPSHOT@5"/>
<listEntry value="mvn:org.universAAL.support/jena.osgi@5"/>
<listEntry value="wrap:mvn:org.universAAL.ui/ui.handler.gui.tableLayout/1.0-SNAPSHOT@5"/>
<listEntry value="mvn:org.universAAL.middleware/mw.data.representation/1.1.1-SNAPSHOT@4"/>
<listEntry value="mvn:org.apache.felix/org.apache.felix.configadmin/1.2.4@2"/>
<listEntry value="mvn:org.universAAL.middleware/mw.container.xfaces/1.1.1-SNAPSHOT@4"/>
<listEntry value="mvn:org.apache.felix/org.apache.felix.configadmin/1.2.4@2"/>
<listEntry value="wrap:mvn:jp.go.ipa/jgcl/1.0@2"/>
<listEntry value="mvn:org.universAAL.middleware/mw.bus.ui/1.1.1-SNAPSHOT@5"/>
<listEntry value="mvn:org.universAAL.ui/ui.dm/1.1.1-SNAPSHOT@6@update"/>
<listEntry value="wrap:mvn:mysql/mysql-connector-java/5.1.6@2"/>
<listEntry value="mvn:org.universAAL.ui/ui.dm/1.1.1-SNAPSHOT@6@update"/>
<listEntry value="wrap:mvn:java3d/vecmath/1.3.1@2"/>
<listEntry value="wrap:mvn:org.ops4j.pax.confman/pax-confman-propsloader/0.2.2@3"/>
<listEntry value="wrap:mvn:org.bouncycastle/jce.jdk13/144@2"/>
<listEntry value="mvn:org.universAAL.context/ctxt.jena.converter/1.1.1-SNAPSHOT@5"/>
<listEntry value="mvn:org.universAAL.middleware/mw.bus.model/1.1.1-SNAPSHOT@3"/>
<listEntry value="wrap:mvn:org.ops4j.pax.logging/pax-logging-api/1.6.0@2"/>
<listEntry value="mvn:org.universAAL.middleware/mw.container.osgi/1.1.1-SNAPSHOT@5"/>
<listEntry value="wrap:mvn:java3d/j3d-core/1.3.1@2"/>
<listEntry value="mvn:org.universAAL.middleware/mw.container.osgi/1.1.1-SNAPSHOT@5"/>
<listEntry value="wrap:mvn:org.ops4j.pax.logging/pax-logging-api/1.6.0@2"/>
<listEntry value="mvn:org.universAAL.middleware/mw.bus.context/1.1.1-SNAPSHOT@5"/>
<listEntry value="wrap:mvn:org.ops4j.pax.logging/pax-logging-service/1.6.0@3"/>
<listEntry value="mvn:org.universAAL.tools.ucc/ucc.viewjambi/1.1.1-SNAPSHOT@8@update"/>
<listEntry value="mvn:org.universAAL.ontology/ont.profile/1.1.1-SNAPSHOT@6"/>
<listEntry value="mvn:org.universAAL.tools.ucc/ucc.model/1.1.1-SNAPSHOT@7@update"/>
<listEntry value="mvn:org.universAAL.tools.ucc/ucc.viewjambi/1.1.1-SNAPSHOT@8@update"/>
<listEntry value="wrap:mvn:org.ops4j.pax.logging/pax-logging-service/1.6.0@3"/>
<listEntry value="mvn:org.universAAL.middleware/mw.data.serialization/1.1.1-SNAPSHOT@4"/>
<listEntry value="mvn:org.universAAL.tools.ucc/ucc.model/1.1.1-SNAPSHOT@7@update"/>
<listEntry value="mvn:org.universAAL.tools.ucc/ucc.api/1.1.1-SNAPSHOT@7@update"/>
<listEntry value="mvn:org.universAAL.tools.ucc/ucc.core/1.1.1-SNAPSHOT@7@update"/>
<listEntry value="wrap:mvn:org.osgi/osgi_R4_compendium/1.0@2"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment