Commit 0046909c authored by Jean-Marc Ronck's avatar Jean-Marc Ronck
Browse files

Merge branch 'development' into 'master'

New Installation / Update Procedure and a few Bug Fixes

See merge request !2
parents 507a4371 7715ab3c
Pipeline #76595 passed with stage
in 6 minutes and 48 seconds
......@@ -2,4 +2,8 @@
/.idea
# Build
/target
\ No newline at end of file
/target
/src/main/resources/math-pretty-printer/
/src/main/resources/visualisation/
/src/main/resources/visualization.zip
/src/main/resources/math-pretty-printer.zip
\ No newline at end of file
......@@ -2,10 +2,10 @@
<p align="center">
<a>
<img src="https://img.shields.io/badge/Version-0.1.0-blue.svg?longCache=true&style=flat-square"/>
<img src="https://img.shields.io/badge/Version-0.1.1-blue.svg?longCache=true&style=flat-square"/>
</a>
<a href="https://rwth-aachen.sciebo.de/s/igDWzLpdO5zYHBj/download?path=%2Fshared%2F18.07.20.visualization-emam&files=visualization-emam.zip">
<img src="https://img.shields.io/badge/Download-18.07.20-blue.svg?longCache=true&style=flat-square"/>
<a href="https://rwth-aachen.sciebo.de/s/igDWzLpdO5zYHBj/download?path=%2Fshared%2F18.10.02.visualization-emam&files=visualization-emam.zip">
<img src="https://img.shields.io/badge/Download-18.10.02-blue.svg?longCache=true&style=flat-square"/>
</a>
</p>
......
<project name="VisualizationEMAM" basedir=".">
<target name="visualization.exists()">
<condition property="!visualization.exists">
<not><available file="src/main/resources/visualisation/embeddedmontiarc-svggenerator.jar"/></not>
</condition>
</target>
<target name="visualization.download()" depends="visualization.exists()" if="!visualization.exists">
<get src="https://rwth-aachen.sciebo.de/s/igDWzLpdO5zYHBj/download?path=%2Fshared%2F${visualization.version}.visualisation&amp;files=visualisation.zip"
dest="src/main/resources/visualization.zip"
verbose="false"/>
<unzip src="src/main/resources/visualization.zip"
dest="src/main/resources"/>
<delete file="src/main/resources/visualisation/emam2ema.jar"/>
<delete file="src/main/resources/visualization.zip"/>
</target>
<target name="math-pretty-printer.exists()">
<condition property="!math-pretty-printer.exists">
<not><available file="src/main/resources/math-pretty-printer/math-pretty-printer.jar"/></not>
</condition>
</target>
<target name="math-pretty-printer.download()" depends="math-pretty-printer.exists()" if="!math-pretty-printer.exists">
<get src="https://rwth-aachen.sciebo.de/s/igDWzLpdO5zYHBj/download?path=%2Fshared%2F${math-pretty-printer.version}.math-pretty-printer&amp;files=math-pretty-printer.zip"
dest="src/main/resources/math-pretty-printer.zip"
verbose="false"/>
<unzip src="src/main/resources/math-pretty-printer.zip"
dest="src/main/resources"/>
<delete file="src/main/resources/math-pretty-printer.zip"/>
</target>
</project>
\ No newline at end of file
......@@ -6,7 +6,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>visualization-emam</artifactId>
<version>0.2.0-SNAPSHOT</version>
<version>0.1.1</version>
<properties>
......@@ -21,7 +21,7 @@
<commons-cli.version>1.4</commons-cli.version>
<commons-exec.version>1.3</commons-exec.version>
<commons-io.version>2.4</commons-io.version>
<zip4j.version>1.3.2</zip4j.version>
<commons-codec.version>1.11</commons-codec.version>
<monticore.version>5.0.0</monticore.version>
<!-- .. Plugins ....................................................... -->
......@@ -29,6 +29,7 @@
<assembly.plugin>2.5.3</assembly.plugin>
<compiler.plugin>3.2</compiler.plugin>
<source.plugin>2.4</source.plugin>
<antrun.version>1.8</antrun.version>
<!-- .. Classifiers ................................................... -->
......@@ -39,6 +40,11 @@
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- .. Resources ..................................................... -->
<visualization.version>18.07.16</visualization.version>
<math-pretty-printer.version>18.10.01</math-pretty-printer.version>
</properties>
<!-- == PROJECT METAINFORMATION ========================================= -->
......@@ -98,9 +104,9 @@
</dependency>
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>${zip4j.version}</version>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec.version}</version>
</dependency>
......@@ -238,6 +244,43 @@
<check/>
</configuration>
</plugin>
<!-- Resource Download -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${antrun.version}</version>
<executions>
<execution>
<id>Download Visualization</id>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant antfile="build.xml">
<target name="visualization.download()"/>
</ant>
</target>
</configuration>
</execution>
<execution>
<id>Download MathPrettyPrinter</id>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant antfile="build.xml">
<target name="math-pretty-printer.download()"/>
</ant>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
......
package de.monticore.lang.monticar.visualization.emam.application;
import com.google.common.eventbus.EventBus;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
......@@ -14,7 +13,7 @@ import de.monticore.lang.monticar.visualization.emam.models.ModelsModule;
import de.monticore.lang.monticar.visualization.emam.options.OptionsModule;
import de.monticore.lang.monticar.visualization.emam.options.OptionsService;
import de.monticore.lang.monticar.visualization.emam.paths.PathsModule;
import de.monticore.lang.monticar.visualization.emam.url.URLModule;
import de.monticore.lang.monticar.visualization.emam.resources.ResourcesModule;
import java.text.ParseException;
import java.util.Set;
......@@ -89,8 +88,8 @@ public class Application {
public static void main(String[] args) {
Injector injector = Guice.createInjector(
new ApplicationModule(), new DependenciesModule(), new ExecutablesModule(),
new OptionsModule(), new PathsModule(), new URLModule(), new ModelsModule(),
new EventsModule(), new GeneratorModule()
new OptionsModule(), new PathsModule(), new ModelsModule(), new EventsModule(),
new GeneratorModule(), new ResourcesModule()
);
Application application = injector.getInstance(Application.class);
......
......@@ -8,7 +8,7 @@ import de.monticore.lang.monticar.visualization.emam.generator.HTMLGeneratorImpl
import de.monticore.lang.monticar.visualization.emam.models.ModelsServiceImpl;
import de.monticore.lang.monticar.visualization.emam.options.OptionsServiceImpl;
import de.monticore.lang.monticar.visualization.emam.paths.PathsServiceImpl;
import de.monticore.lang.monticar.visualization.emam.url.URLServiceImpl;
import de.monticore.lang.monticar.visualization.emam.resources.ResourcesServiceImpl;
public class ApplicationModule extends AbstractModule {
@Override
......@@ -19,7 +19,7 @@ public class ApplicationModule extends AbstractModule {
contributions.addBinding().to(DependenciesServiceImpl.class);
contributions.addBinding().to(ExecutablesServiceImpl.class);
contributions.addBinding().to(OptionsServiceImpl.class);
contributions.addBinding().to(URLServiceImpl.class);
contributions.addBinding().to(ResourcesServiceImpl.class);
contributions.addBinding().to(PathsServiceImpl.class);
contributions.addBinding().to(ModelsServiceImpl.class);
contributions.addBinding().to(HTMLGeneratorImpl.class);
......
package de.monticore.lang.monticar.visualization.emam.dependencies;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import de.monticore.lang.monticar.visualization.emam.paths.PathsService;
import de.monticore.lang.monticar.visualization.emam.url.URLService;
import de.monticore.lang.monticar.visualization.emam.resources.ResourcesService;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.logging.Logger;
public abstract class AbstractDependenciesContribution extends EventBus implements DependenciesContribution {
public abstract class AbstractDependenciesContribution implements DependenciesContribution {
protected final Logger logger;
protected final PathsService pathsService;
protected final URLService urlService;
protected final ResourcesService resourcesService;
@Inject
public AbstractDependenciesContribution(Logger logger, PathsService pathsService, URLService urlService) {
public AbstractDependenciesContribution(Logger logger, PathsService pathsService, ResourcesService resourcesService) {
this.logger = logger;
this.pathsService = pathsService;
this.urlService = urlService;
this.resourcesService = resourcesService;
}
protected boolean isInstalled(String id) throws Exception {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
DigestUtils digestUtils = new DigestUtils(messageDigest);
InputStream toInstall = this.resourcesService.getResourceAsStream(id);
File installed = this.pathsService.getPathAsFile(id);
return installed.exists() && Arrays.equals(digestUtils.digest(toInstall), digestUtils.digest(installed));
}
protected void install(String id) throws IOException {
InputStream toInstall = this.resourcesService.getResourceAsStream(id);
File destination = this.pathsService.getPathAsFile(id);
FileUtils.copyInputStreamToFile(toInstall, destination);
}
}
package de.monticore.lang.monticar.visualization.emam.dependencies;
import net.lingala.zip4j.exception.ZipException;
import java.io.IOException;
public interface DependenciesContribution {
boolean isDownloaded();
void download() throws IOException;
boolean isInstalled();
void install() throws ZipException;
boolean isCleaned();
void clean() throws IOException;
boolean isInstalled() throws Exception;
void install() throws IOException;
}
package de.monticore.lang.monticar.visualization.emam.dependencies;
public interface DependenciesService {
void download() throws Exception;
void install() throws Exception;
void clean() throws Exception;
}
......@@ -20,12 +20,8 @@ public class DependenciesServiceImpl implements DependenciesService, Application
}
@Override
public void download() throws Exception {
this.logger.info("Downloading Dependencies...");
for (DependenciesContribution contribution : this.contributions) {
if (!contribution.isDownloaded()) contribution.download();
}
public void prepare(Application application) throws Exception {
this.install();
}
@Override
......@@ -36,20 +32,4 @@ public class DependenciesServiceImpl implements DependenciesService, Application
if (!contribution.isInstalled()) contribution.install();
}
}
@Override
public void clean() throws Exception {
this.logger.info("Cleaning Installation Files...");
for (DependenciesContribution contribution : this.contributions) {
if (!contribution.isCleaned()) contribution.clean();
}
}
@Override
public void prepare(Application application) throws Exception {
this.download();
this.install();
this.clean();
}
}
......@@ -2,68 +2,24 @@ package de.monticore.lang.monticar.visualization.emam.dependencies;
import com.google.inject.Inject;
import de.monticore.lang.monticar.visualization.emam.paths.PathsServiceImpl;
import de.monticore.lang.monticar.visualization.emam.url.URLService;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import org.apache.commons.io.FileUtils;
import de.monticore.lang.monticar.visualization.emam.resources.ResourcesService;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Path;
import java.util.logging.Logger;
public class MathPrettyPrinterDependency extends AbstractDependenciesContribution {
@Inject
public MathPrettyPrinterDependency(Logger logger, PathsServiceImpl pathsService, URLService urlService) {
super(logger, pathsService, urlService);
public MathPrettyPrinterDependency(Logger logger, PathsServiceImpl pathsService, ResourcesService resourcesService) {
super(logger, pathsService, resourcesService);
}
@Override
public boolean isDownloaded() {
File mppZIP = this.pathsService.getPathAsFile("math-pretty-printer.zip");
return this.isInstalled() || mppZIP.exists();
}
@Override
public void download() throws IOException {
URL mppURL = this.urlService.getURL("math-pretty-printer.zip");
Path mppZIP = this.pathsService.getPath("math-pretty-printer.zip");
this.logger.info("Downloading \"math-pretty-printer.zip\"...");
FileUtils.copyURLToFile(mppURL, mppZIP.toFile());
}
@Override
public boolean isInstalled() {
File mppJAR = this.pathsService.getPathAsFile("math-pretty-printer.jar");
return mppJAR.exists();
public boolean isInstalled() throws Exception {
return super.isInstalled("math-pretty-printer.jar");
}
@Override
public void install() throws ZipException {
File mppZIP = this.pathsService.getPathAsFile("math-pretty-printer.zip");
Path projectDirectory = this.pathsService.getPath("visualization-emam");
ZipFile zipFile = new ZipFile(mppZIP);
this.logger.info("Installing \"math-pretty-printer.zip\"...");
zipFile.extractAll(projectDirectory.toString());
}
@Override
public boolean isCleaned() {
File mppZIP = this.pathsService.getPathAsFile("math-pretty-printer.zip");
return !mppZIP.exists();
}
@Override
public void clean() throws IOException {
File mppZIP = this.pathsService.getPathAsFile("math-pretty-printer.zip");
this.logger.info("Deleting \"math-pretty-printer.zip\"...");
FileUtils.forceDelete(mppZIP);
public void install() throws IOException {
super.install("math-pretty-printer.jar");
}
}
......@@ -2,68 +2,24 @@ package de.monticore.lang.monticar.visualization.emam.dependencies;
import com.google.inject.Inject;
import de.monticore.lang.monticar.visualization.emam.paths.PathsService;
import de.monticore.lang.monticar.visualization.emam.url.URLService;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import org.apache.commons.io.FileUtils;
import de.monticore.lang.monticar.visualization.emam.resources.ResourcesService;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Path;
import java.util.logging.Logger;
public class VisualizationDependency extends AbstractDependenciesContribution {
@Inject
public VisualizationDependency(Logger logger, PathsService pathsService, URLService urlService) {
super(logger, pathsService, urlService);
public VisualizationDependency(Logger logger, PathsService pathsService, ResourcesService resourcesService) {
super(logger, pathsService, resourcesService);
}
@Override
public boolean isDownloaded() {
File visualizationZIP = this.pathsService.getPathAsFile("visualization.zip");
return this.isInstalled() || visualizationZIP.exists();
}
@Override
public void download() throws IOException {
URL visualizationURL = this.urlService.getURL("visualization.zip");
Path visualizationZIP = this.pathsService.getPath("visualization.zip");
this.logger.info("Downloading \"visualization.zip\"...");
FileUtils.copyURLToFile(visualizationURL, visualizationZIP.toFile());
}
@Override
public boolean isInstalled() {
File visualizationJAR = this.pathsService.getPathAsFile("visualization.jar");
return visualizationJAR.exists();
public boolean isInstalled() throws Exception {
return super.isInstalled("visualization.jar");
}
@Override
public void install() throws ZipException {
File visualizationZIP = this.pathsService.getPathAsFile("visualization.zip");
Path projectDirectory = this.pathsService.getPath("visualization-emam");
ZipFile zipFile = new ZipFile(visualizationZIP);
this.logger.info("Installing \"visualization.zip\"...");
zipFile.extractAll(projectDirectory.toString());
}
@Override
public boolean isCleaned() {
File visualizationZIP = this.pathsService.getPathAsFile("visualization.zip");
return !visualizationZIP.exists();
}
@Override
public void clean() throws IOException {
File visualizationZIP = this.pathsService.getPathAsFile("visualization.zip");
this.logger.info("Deleting \"visualization.zip\"...");
FileUtils.forceDelete(visualizationZIP);
public void install() throws IOException {
super.install("visualization.jar");
}
}
......@@ -51,7 +51,9 @@ public class MathPrettyPrinterExecutable extends JavaExecutablesContribution {
public void execute() throws IOException {
String[] arguments = this.buildArguments();
this.logger.info("Executing MathPrettyPrinter...");
super.execute(arguments);
this.logger.info("...MathPrettyPrinter executed.");
}
@Override
......
......@@ -60,7 +60,9 @@ public class VisualizationExecutable extends JavaExecutablesContribution {
public void execute() throws IOException {
String[] arguments = this.buildArguments();
this.logger.info("Executing Visualization...");
super.execute(arguments);
this.logger.info("...Visualization executed.");
}
@Override
......
......@@ -55,6 +55,8 @@ public class HTMLGeneratorImpl implements HTMLGenerator, ApplicationContribution
@Subscribe
public void onExecutablesExecuted(ExecutablesExecutedEvent event) {
this.logger.info("Generating \"index.html\"...");
this.generate();
this.logger.info("...\"index.html\" has been generated.");
}
}
package de.monticore.lang.monticar.visualization.emam.generator;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import de.monticore.generating.GeneratorEngine;
import de.monticore.generating.GeneratorSetup;
import de.monticore.generating.templateengine.GlobalExtensionManagement;
import de.monticore.lang.monticar.visualization.emam.options.OptionsParsedEvent;
import de.monticore.lang.monticar.visualization.emam.options.OptionsService;
import org.apache.commons.cli.ParseException;
import java.io.File;
import java.util.logging.Logger;
......
......@@ -37,8 +37,13 @@ public class ModelPathVisitorImpl extends SimpleFileVisitor<Path> implements Mod
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attributes) throws IOException {
if (file.toString().endsWith(".emam")) {
String fileName = file.toString();
this.logger.info("Splitting \"" + fileName + "\"...");
List<File> models = this.splitter.split(file.toFile());
this.logger.info("...\"" + fileName + "\" has been split.");
this.registry.addAllModels(models);
}
......
......@@ -6,12 +6,8 @@ public class MathPrettyPrinterPath implements PathsContribution {
@Override
public void addToRegistry(PathsService registry) {
Path projectDirectory = registry.getPath("visualization-emam");
Path mathPrettyPrinterPath = projectDirectory.resolve("math-pretty-printer");
Path mathPrettyPrinterZIP = projectDirectory.resolve("math-pretty-printer.zip");
Path mathPrettyPrinterJAR = mathPrettyPrinterPath.resolve("math-pretty-printer.jar");
Path mathPrettyPrinterJAR = projectDirectory.resolve("math-pretty-printer.jar");
registry.addPath("math-pretty-printer", mathPrettyPrinterPath);
registry.addPath("math-pretty-printer.zip", mathPrettyPrinterZIP);
registry.addPath("math-pretty-printer.jar", mathPrettyPrinterJAR);
}
}
......@@ -26,6 +26,7 @@ public class PathsServiceImpl implements PathsService, ApplicationContribution {
this.paths = new HashMap<>();
this.addUserHome();
this.addEmbeddedMontiArcDirectory();
this.addProjectDirectory();
}
......@@ -33,12 +34,19 @@ public class PathsServiceImpl implements PathsService, ApplicationContribution {
String pathString = System.getProperty("user.home");
Path path = Paths.get(pathString);
this.paths.put("user.home", path);
this.paths.put("~", path);
}
protected void addEmbeddedMontiArcDirectory() {
Path userhome = this.paths.get("~");
Path embeddedMontiArcDirectory = userhome.resolve(".embeddedmontiarc");
this.paths.put(".embeddedmontiarc", embeddedMontiArcDirectory);
}
protected void addProjectDirectory() {
Path userHome = this.paths.get("user.home");
Path projectDirectory = userHome.resolve("visualization-emam");