diff --git a/AdministrationExample/META-INF/MANIFEST.MF b/AdministrationExample/META-INF/MANIFEST.MF index 0d0b65d..5892acd 100644 --- a/AdministrationExample/META-INF/MANIFEST.MF +++ b/AdministrationExample/META-INF/MANIFEST.MF @@ -1,14 +1,15 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: AdministrationExample -Bundle-SymbolicName: AdministrationExample;singleton:=true -Bundle-Version: 0.0.1.qualifier -Bundle-Vendor: -Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-16 -Automatic-Module-Name: AdministrationExample -Require-Bundle: org.eclipse.emf.ecore, - org.eclipse.emf.ecore.xmi, - org.emoflon.smartemf -Export-Package: AdministrationExample, - AdministrationExample.impl +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: AdministrationExample +Bundle-SymbolicName: AdministrationExample;singleton:=true +Bundle-Version: 0.0.1.qualifier +Bundle-Vendor: +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Automatic-Module-Name: AdministrationExample +Require-Bundle: org.eclipse.emf.ecore, + org.eclipse.emf.ecore.xmi, + org.emoflon.smartemf +Export-Package: AdministrationExample, + AdministrationExample.impl + diff --git a/AdministrationTransformRule/META-INF/MANIFEST.MF b/AdministrationTransformRule/META-INF/MANIFEST.MF index 1840948..8ad2216 100644 --- a/AdministrationTransformRule/META-INF/MANIFEST.MF +++ b/AdministrationTransformRule/META-INF/MANIFEST.MF @@ -1,21 +1,21 @@ -Manifest-Version: 1.0 -Automatic-Module-Name: AdministrationTransformRule -Bundle-ManifestVersion: 2 -Bundle-Name: AdministrationTransformRule -Bundle-Vendor: My Company -Bundle-Version: 1.0.0.qualifier -Bundle-SymbolicName: AdministrationTransformRule; singleton:=true -Bundle-ActivationPolicy: lazy -Import-Package: org.apache.commons.logging;version="1.2.0", - org.apache.log4j -Bundle-RequiredExecutionEnvironment: JavaSE-16 -Require-Bundle: org.emoflon.ibex.common, - org.emoflon.ibex.gt, - org.emoflon.ibex.patternmodel, - org.emoflon.ibex.gt.democles, - org.emoflon.ibex.gt.hipe, - AdministrationExample;bundle-version="0.0.1" -Export-Package: AdministrationTransformRule.api, - AdministrationTransformRule.api.matches, - AdministrationTransformRule.api.rules - +Manifest-Version: 1.0 +Automatic-Module-Name: AdministrationTransformRule +Bundle-ManifestVersion: 2 +Bundle-Name: AdministrationTransformRule +Bundle-Vendor: My Company +Bundle-Version: 1.0.0.qualifier +Bundle-SymbolicName: AdministrationTransformRule; singleton:=true +Bundle-ActivationPolicy: lazy +Import-Package: org.apache.commons.logging;version="1.2.0", + org.apache.log4j +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Require-Bundle: org.emoflon.ibex.common, + org.emoflon.ibex.gt, + org.emoflon.ibex.patternmodel, + org.emoflon.ibex.gt.democles, + org.emoflon.ibex.gt.hipe, + AdministrationExample;bundle-version="0.0.1" +Export-Package: AdministrationTransformRule.api, + AdministrationTransformRule.api.matches, + AdministrationTransformRule.api.rules + diff --git a/AdministrationTransformRule/src/AdministrationTransformRule/AdministrationValidator.java b/AdministrationTransformRule/src/AdministrationTransformRule/AdministrationValidator.java index 95b8162..643c5a8 100644 --- a/AdministrationTransformRule/src/AdministrationTransformRule/AdministrationValidator.java +++ b/AdministrationTransformRule/src/AdministrationTransformRule/AdministrationValidator.java @@ -9,7 +9,7 @@ public class AdministrationValidator extends AdministrationTransformRuleDemocles public AdministrationValidator() { - String filePathUrl = workspacePath + "Hospital2Administration\\instances\\trg.xmi"; + String filePathUrl = workspacePath + "Hospital2Administration/instances/trg.xmi"; loadModel(URI.createFileURI(filePathUrl)); diff --git a/Hospital2Administration/META-INF/MANIFEST.MF b/Hospital2Administration/META-INF/MANIFEST.MF index c39e776..acd9c86 100644 --- a/Hospital2Administration/META-INF/MANIFEST.MF +++ b/Hospital2Administration/META-INF/MANIFEST.MF @@ -1,34 +1,34 @@ -Manifest-Version: 1.0 -Bundle-Name: %pluginName -Bundle-ManifestVersion: 2 -Bundle-Version: 0.0.1 -Bundle-ClassPath: . -Bundle-Vendor: %providerName -Bundle-Localization: plugin -Bundle-SymbolicName: Hospital2Administration;singleton:=true -Automatic-Module-Name: Hospital2Administration -Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-16 -Export-Package: org.emoflon.ibex.tgg.run.hospital2administration.config, - Hospital2Administration, - Hospital2Administration.impl -Require-Bundle: AdministrationExample;visibility:=reexport, - HospitalExample;bundle-version="0.0.1";visibility:=reexport, - org.apache.log4j, - com.google.guava, - org.sat4j.core, - org.sat4j.pb, - org.eclipse.emf.ecore.xmi, - org.emoflon.ibex.common, - org.emoflon.ibex.tgg.language, - org.emoflon.ibex.tgg.runtime;visibility:=reexport, - org.emoflon.ibex.tgg.ui.debug, - org.emoflon.ibex.tgg.ui.debug.adapter, - org.eclipse.xtend.lib, - org.emoflon.ibex.tgg.runtime.democles, - org.eclipse.core.runtime, - org.eclipse.emf.ecore;visibility:=reexport, - org.emoflon.ibex.tgg.runtime.hipe, - Hospital2Administration, - org.emoflon.smartemf - +Manifest-Version: 1.0 +Bundle-Name: %pluginName +Bundle-ManifestVersion: 2 +Bundle-Version: 0.0.1 +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-SymbolicName: Hospital2Administration;singleton:=true +Automatic-Module-Name: Hospital2Administration +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Export-Package: org.emoflon.ibex.tgg.run.hospital2administration.config, + Hospital2Administration, + Hospital2Administration.impl +Require-Bundle: AdministrationExample;visibility:=reexport, + HospitalExample;bundle-version="0.0.1";visibility:=reexport, + org.apache.log4j, + com.google.guava, + org.sat4j.core, + org.sat4j.pb, + org.eclipse.emf.ecore.xmi, + org.emoflon.ibex.common, + org.emoflon.ibex.tgg.language, + org.emoflon.ibex.tgg.runtime;visibility:=reexport, + org.emoflon.ibex.tgg.ui.debug, + org.emoflon.ibex.tgg.ui.debug.adapter, + org.eclipse.xtend.lib, + org.emoflon.ibex.tgg.runtime.democles, + org.eclipse.core.runtime, + org.eclipse.emf.ecore;visibility:=reexport, + org.emoflon.ibex.tgg.runtime.hipe, + Hospital2Administration, + org.emoflon.smartemf + diff --git a/Hospital2AdministrationSolutions/META-INF/MANIFEST.MF b/Hospital2AdministrationSolutions/META-INF/MANIFEST.MF index 0bd8c3f..eb16b7d 100644 --- a/Hospital2AdministrationSolutions/META-INF/MANIFEST.MF +++ b/Hospital2AdministrationSolutions/META-INF/MANIFEST.MF @@ -1,32 +1,33 @@ -Manifest-Version: 1.0 -Bundle-Name: %pluginName -Bundle-ManifestVersion: 2 -Bundle-Version: 0.0.1 -Bundle-ClassPath: . -Bundle-Vendor: %providerName -Bundle-Localization: plugin -Bundle-SymbolicName: Hospital2AdministrationSolutions;singleton:=true -Automatic-Module-Name: Hospital2AdministrationSolutions -Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-16 -Export-Package: org.emoflon.ibex.tgg.run.hospital2administrationsolutions.config, - Hospital2AdministrationSolutions, - Hospital2AdministrationSolutions.impl -Require-Bundle: AdministrationExample;visibility:=reexport, - HospitalExample;bundle-version="0.0.1";visibility:=reexport, - org.apache.log4j, - com.google.guava, - org.sat4j.core, - org.sat4j.pb, - org.eclipse.emf.ecore.xmi, - org.emoflon.ibex.common, - org.emoflon.ibex.tgg.language, - org.emoflon.ibex.tgg.runtime;visibility:=reexport, - org.emoflon.ibex.tgg.ui.debug, - org.emoflon.ibex.tgg.ui.debug.adapter, - org.eclipse.xtend.lib, - org.emoflon.ibex.tgg.runtime.democles, - org.eclipse.core.runtime, - org.eclipse.emf.ecore;visibility:=reexport, - org.emoflon.ibex.tgg.runtime.hipe, - org.emoflon.smartemf +Manifest-Version: 1.0 +Bundle-Name: %pluginName +Bundle-ManifestVersion: 2 +Bundle-Version: 0.0.1 +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-SymbolicName: Hospital2AdministrationSolutions;singleton:=true +Automatic-Module-Name: Hospital2AdministrationSolutions +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Export-Package: org.emoflon.ibex.tgg.run.hospital2administrationsolutions.config, + Hospital2AdministrationSolutions, + Hospital2AdministrationSolutions.impl +Require-Bundle: AdministrationExample;visibility:=reexport, + HospitalExample;bundle-version="0.0.1";visibility:=reexport, + org.apache.log4j, + com.google.guava, + org.sat4j.core, + org.sat4j.pb, + org.eclipse.emf.ecore.xmi, + org.emoflon.ibex.common, + org.emoflon.ibex.tgg.language, + org.emoflon.ibex.tgg.runtime;visibility:=reexport, + org.emoflon.ibex.tgg.ui.debug, + org.emoflon.ibex.tgg.ui.debug.adapter, + org.eclipse.xtend.lib, + org.emoflon.ibex.tgg.runtime.democles, + org.eclipse.core.runtime, + org.eclipse.emf.ecore;visibility:=reexport, + org.emoflon.ibex.tgg.runtime.hipe, + org.emoflon.smartemf + diff --git a/HospitalExample/META-INF/MANIFEST.MF b/HospitalExample/META-INF/MANIFEST.MF index d84f60e..1295e5d 100644 --- a/HospitalExample/META-INF/MANIFEST.MF +++ b/HospitalExample/META-INF/MANIFEST.MF @@ -1,14 +1,15 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: HospitalExample -Bundle-SymbolicName: HospitalExample;singleton:=true -Bundle-Version: 0.0.1.qualifier -Bundle-Vendor: -Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-16 -Automatic-Module-Name: HospitalExample -Require-Bundle: org.eclipse.emf.ecore, - org.eclipse.emf.ecore.xmi, - org.emoflon.smartemf -Export-Package: HospitalExample, - HospitalExample.impl +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: HospitalExample +Bundle-SymbolicName: HospitalExample;singleton:=true +Bundle-Version: 0.0.1.qualifier +Bundle-Vendor: +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Automatic-Module-Name: HospitalExample +Require-Bundle: org.eclipse.emf.ecore, + org.eclipse.emf.ecore.xmi, + org.emoflon.smartemf +Export-Package: HospitalExample, + HospitalExample.impl + diff --git a/HospitalTransformRules/META-INF/MANIFEST.MF b/HospitalTransformRules/META-INF/MANIFEST.MF index 6963673..64c2a0d 100644 --- a/HospitalTransformRules/META-INF/MANIFEST.MF +++ b/HospitalTransformRules/META-INF/MANIFEST.MF @@ -1,16 +1,18 @@ -Manifest-Version: 1.0 -Bundle-Name: HospitalTransformRules -Bundle-ManifestVersion: 2 -Bundle-Version: 0.0.1 -Bundle-SymbolicName: HospitalTransformRules;singleton:=true -Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-16 -Require-Bundle: org.emoflon.ibex.common, - org.emoflon.ibex.gt, - org.emoflon.ibex.patternmodel, - org.emoflon.ibex.gt.democles, - org.emoflon.ibex.gt.hipe, - HospitalExample;bundle-version="0.0.1" -Export-Package: HospitalTransformRules.api, - HospitalTransformRules.api.matches, - HospitalTransformRules.api.rules +Manifest-Version: 1.0 +Bundle-Name: HospitalTransformRules +Bundle-ManifestVersion: 2 +Bundle-Version: 0.0.1 +Bundle-SymbolicName: HospitalTransformRules;singleton:=true +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Require-Bundle: org.emoflon.ibex.common, + org.emoflon.ibex.gt, + org.emoflon.ibex.patternmodel, + org.emoflon.ibex.gt.democles, + org.emoflon.ibex.gt.hipe, + HospitalExample;bundle-version="0.0.1", + org.eclipse.emf.ecore +Export-Package: HospitalTransformRules.api, + HospitalTransformRules.api.matches, + HospitalTransformRules.api.rules + diff --git a/HospitalTransformRules/hospital.xmi b/HospitalTransformRules/hospital.xmi index 73deaa5..5888ee6 100644 --- a/HospitalTransformRules/hospital.xmi +++ b/HospitalTransformRules/hospital.xmi @@ -1,68 +1,66 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HospitalTransformRules/src/HospitalTransformRules/HospitalRules.java b/HospitalTransformRules/src/HospitalTransformRules/HospitalRules.java index 2810951..118101b 100644 --- a/HospitalTransformRules/src/HospitalTransformRules/HospitalRules.java +++ b/HospitalTransformRules/src/HospitalTransformRules/HospitalRules.java @@ -2,6 +2,11 @@ import java.io.IOException; import java.util.Random; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.emoflon.smartemf.persistence.SmartEMFResourceFactoryImpl; import HospitalExample.Carelevel; import HospitalTransformRules.api.HospitalTransformRulesAPI; @@ -27,12 +32,8 @@ public static void main(String[] args) throws IOException { // Main method to ap // hospitalrules.api.trackModelStates(false); hospitalrules.createHospital(); hospitalrules.validateHospital(); - try { - hospitalrules.api.getModel().getResources().get(0).save(null); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + persistModel(HospitalValidator.hospitalFilePath, hospitalrules.api); + hospitalrules.api.terminate(); // hospitalrules.api.displayModelStates(); } @@ -67,16 +68,7 @@ public void createHospital() { // Method where hospital rules are applied step b api.assignPatientToRoom().apply(); } - - try { - api.getModel().getResources().get(0).save(null); - - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - + persistModel(HospitalValidator.hospitalFilePath, api); } public void validateHospital() { // Method to validate the ruleset via print outputs @@ -129,5 +121,31 @@ public void validateHospital() { // Method to validate the ruleset via print out System.out.println("Error, there are no rooms in the hospital"); } + + /** + * Saves the model to given file path. + * + * @param path File path as string. + * @param api The transformation rules API (eMoflon). + */ + public static void persistModel(final String path, final HospitalTransformRulesAPI api) { + // Workaround: Always use absolute path + final URI absPath = URI.createFileURI(System.getProperty("user.dir") + "/" + path); + + // Create new model for saving + final ResourceSet rs = new ResourceSetImpl(); + rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new SmartEMFResourceFactoryImpl(null)); + // ^null is okay if all paths are absolute + final Resource r = rs.createResource(absPath); + // Fetch model contents from eMoflon API + r.getContents().add(api.getModel().getResources().get(0).getContents().get(0)); + try { + r.save(null); + } catch (final IOException e) { + e.printStackTrace(); + } + // Hand model back to owner + api.getModel().getResources().get(0).getContents().addAll(r.getContents()); + } } diff --git a/HospitalTransformRules/src/HospitalTransformRules/HospitalValidator.java b/HospitalTransformRules/src/HospitalTransformRules/HospitalValidator.java index 4123643..8c9ae53 100644 --- a/HospitalTransformRules/src/HospitalTransformRules/HospitalValidator.java +++ b/HospitalTransformRules/src/HospitalTransformRules/HospitalValidator.java @@ -5,8 +5,10 @@ public class HospitalValidator extends HospitalTransformRulesHiPEApp { + public static String hospitalFilePath = "hospital.xmi"; + public HospitalValidator() { - createModel(URI.createURI("hospital.xmi")); + createModel(URI.createURI(hospitalFilePath)); } } diff --git a/tutorial-doc/.gitignore b/tutorial-doc/.gitignore index 75f6b8f..a558241 100644 --- a/tutorial-doc/.gitignore +++ b/tutorial-doc/.gitignore @@ -229,3 +229,6 @@ TSWLatexianTemp* TUDthesis.pdf logo/tud_logo.pdf LaTeX2e+Proceedings+Templates+download/ + +emoflon-tutorial.pdf + diff --git a/tutorial-doc/chapters/gt.tex b/tutorial-doc/chapters/gt.tex index 33f3c05..ce2a49d 100644 --- a/tutorial-doc/chapters/gt.tex +++ b/tutorial-doc/chapters/gt.tex @@ -697,45 +697,33 @@ \subsection{Java implementation of the ruleset} 12\hspace{1.5cm}\textcolor{Tan}{hospitalrules}.validateHospital(); -13\hspace{1cm}\textcolor{Purple}{try} \{ +13\hspace{1.5cm}persistModel(HospitalValidator.hospitalFilePath, \textcolor{Tan}{hospitalrules}\textcolor{blue}{api}); -14\hspace{1.5cm}\textcolor{Tan}{hospitalrules}.\textcolor{blue}{api}.getModel().getResources().get(0).save(null); +14\hspace{1.5cm}\textcolor{Tan}{hospitalrules}.\textcolor{blue}{api}.terminate(); -15\hspace{1cm}\} +15\hspace{1.0cm}\} -16\hspace{1cm}\textcolor{Purple}{catch} (IOException e) \{ +16\hspace{1.0cm}\textcolor{Purple}{public void} createHospital() \{ -17\hspace{1.5cm}// TODO Auto-generated catch block +17\hspace{1.5cm}\textcolor{blue}{api}.hospital().apply(); -18\hspace{1.5cm}\textcolor{Tan}{e}.printStackTrace(); +18\hspace{1.5cm}\textcolor{blue}{api}.reception().apply(); -19\hspace{1cm}\} +19\hspace{1.5cm}\textcolor{Purple}{for}(\textcolor{Purple}{int} \textcolor{Tan}{i}=0; \textcolor{Tan}{i}<4; \textcolor{Tan}{i}++) \{ -20\hspace{1cm}\textcolor{Tan}{hospitalrules}.\textcolor{blue}{api}.terminate(); +20\hspace{2.0cm}\textcolor{blue}{api}.department(i+2, 4).apply(); -21\hspace{0.5cm}\} +21\hspace{1.5cm}\} -22\hspace{0.5cm}\textcolor{Purple}{public void} createHospital() \{ +22\hspace{1.5cm}\textcolor{Purple}{for}(\textcolor{Purple}{int} \textcolor{Tan}{i}=0; \textcolor{Tan}{i}<16; \textcolor{Tan}{i}++) \{ -23\hspace{1cm}\textcolor{blue}{api}.hospital().apply(); +23\hspace{2.0cm}\textcolor{blue}{api}.room(4, Carelevel.get(\textcolor{blue}{rnd}.nextInt(3))).apply(); -24\hspace{1cm}\textcolor{blue}{api}.reception().apply(); +24\hspace{1.5cm}\} -25\hspace{1cm}\textcolor{Purple}{for}(\textcolor{Purple}{int} \textcolor{Tan}{i}=0; \textcolor{Tan}{i}<4; \textcolor{Tan}{i}++) \{ +25\hspace{1.5cm}… -26\hspace{1.5cm}\textcolor{blue}{api}.department(i+2, 4).apply(); - -27\hspace{1cm}\} - -28\hspace{1cm}\textcolor{Purple}{for}(\textcolor{Purple}{int} \textcolor{Tan}{i}=0; \textcolor{Tan}{i}<16; \textcolor{Tan}{i}++) \{ - -29\hspace{1.5cm}\textcolor{blue}{api}.room(4, Carelevel.get(\textcolor{blue}{rnd}.nextInt(3))).apply(); - -30\hspace{1cm}\} - -\hspace{0.7cm}… - -\hspace{0.7cm}\} +26\hspace{1.0cm}\} } @@ -748,7 +736,7 @@ \subsection{Java implementation of the ruleset} \textbf{Saving the project:} -Another important thing to note is happening on \textbf{line 14} where we save our hospital model. It is important to note that the hospital instance we have initialized in the \textsf{HospitalValidator} will \textbf{not be stored} anywhere. If we want to keep it for usage in the future, we have to \textbf{save it with a separate command} as we are doing it in line 14.\newline The URI \textsf{hospital.xmi} is saved in the project folder of the \textsf{HospitalTransformRules} project.\newline +Another important thing to note is happening on \textbf{line 13} where we save our hospital model. The method \textsf{persistModel(...)} is a utility method that can be found at the end of this source file. It is important to note that the hospital instance we have initialized in the \textsf{HospitalValidator} will \textbf{not be stored} anywhere. If we want to keep it for usage in the future, we have to \textbf{save it with a separate command} as we are doing it in line 13.\newline The URI \textsf{hospital.xmi} is saved in the project folder of the \textsf{HospitalTransformRules} project.\newline \textbf{Rule application:} @@ -789,26 +777,19 @@ \subsection{Java implementation of the ruleset} You can run the java application by \textbf{right-clicking} on the \textsf{HospitalRule.java} and selecting the \textsf{Run as Java Application} option. If you look at the output in the console, and it should look like this:\newline {\setstretch{1.2} - -\textsf{10 Patients are in the hospital right now} - -\textsf{10 Patients are in a room} - \textsf{One instance of a hospital has been created} +\textsf{One instance of a reception has been created} + \textsf{At least one department instance has been created} \textsf{16 nurses are in the hospital right now and 16 nurses are busy} -\textsf{At least one doctor is in the hospital} - -\textsf{4 doctors are in the hospital right now and 4 doctors are busy} +\textsf{4 doctors are in the hospital right now and 3 doctors are busy} \textsf{At least one patient is in the hospital} -\textsf{The hospital consists of at least one room} - -\textsf{10 Patients are in the hospital right now and 10 patients are in a room}\newline +\textsf{11 Patients are in the hospital right now and 11 patients are in a room}\newline }