Aufgrund einer Störung des s3 Storage, könnten in nächster Zeit folgende GitLab Funktionen nicht zur Verfügung stehen: LFS, Container Registry, Job Artifacs, Uploads (Wiki, Bilder, Projekt-Exporte). Wir bitten um Verständnis. Es wird mit Hochdruck an der Behebung des Problems gearbeitet. Weitere Informationen zur Störung des Object Storage finden Sie hier: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/59-object-storage-pilot

Commit 8b07a5f3 authored by 0xJMR's avatar 0xJMR
Browse files

Started implementation of VisualizationEMAM.

parent 677e700f
Pipeline #60853 failed with stage
in 10 seconds
# Editor
/.idea
# Build
/target
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- == PROJECT COORDINATES ============================================= -->
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>visualization-emam</artifactId>
<version>0.1.0-SNAPSHOT</version>
<properties>
<!-- .. Libraries ..................................................... -->
<guava.version>18.0</guava.version>
<guice.version>4.2.0</guice.version>
<jsr305.version>3.0.0</jsr305.version>
<junit.version>4.11</junit.version>
<logback.version>1.1.2</logback.version>
<math-pretty-printer.version>0.2.0</math-pretty-printer.version>
<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>
<!-- .. Plugins ....................................................... -->
<assembly.plugin>2.5.3</assembly.plugin>
<compiler.plugin>3.2</compiler.plugin>
<source.plugin>2.4</source.plugin>
<!-- .. Classifiers ................................................... -->
<grammars.classifier>grammars</grammars.classifier>
<!-- .. Misc .......................................................... -->
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- == PROJECT METAINFORMATION ========================================= -->
<name>VisualizationEMAM</name>
<inceptionYear>2018</inceptionYear>
<organization>
<name>SE RWTH Aachen</name>
<url>http://www.se-rwth.de/</url>
</organization>
<developers>
<developer>
<name>Bram Kohlen</name>
</developer>
<developer>
<name>Armin Mokhtarian</name>
</developer>
<developer>
<name>Jean-Marc Ronck</name>
</developer>
</developers>
<dependencies>
<!-- .. Libraries ..................................................... -->
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>${guice.version}</version>
<classifier>no_aop</classifier>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>${jsr305.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>${commons-cli.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-exec</artifactId>
<version>${commons-exec.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>${zip4j.version}</version>
</dependency>
<!-- .. MontiCore .................................................... -->
<!-- .. MontiMath .................................................... -->
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>math-pretty-printer</artifactId>
<version>${math-pretty-printer.version}</version>
</dependency>
<!-- .. Test Libraries ............................................... -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- == DISTRIBUTION ==================================================== -->
<distributionManagement>
<repository>
<id>se-nexus</id>
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-releases/</url>
</repository>
<snapshotRepository>
<id>se-nexus</id>
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<!-- == PROJECT BUILD SETTINGS =========================================== -->
<build>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
</plugin>
<!-- Other Configuration -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler.plugin}</version>
<configuration>
<useIncrementalCompilation>true</useIncrementalCompilation>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<!-- Source Jar Configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${source.plugin}</version>
<executions>
<execution>
<id>create source jar</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
<configuration>
<excludeResources>false</excludeResources>
<includes>
<include>**/*.java</include>
<include>**/*.ftl</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<!-- Other Plugins -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<format>xml</format>
<maxmem>256m</maxmem>
<!-- aggregated reports for multi-module projects -->
<aggregate>true</aggregate>
<check/>
</configuration>
</plugin>
</plugins>
</build>
</project>
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;
import com.google.inject.Singleton;
import de.monticore.lang.monticar.visualization.emam.dependencies.DependenciesModule;
import de.monticore.lang.monticar.visualization.emam.events.EventsModule;
import de.monticore.lang.monticar.visualization.emam.events.EventsService;
import de.monticore.lang.monticar.visualization.emam.executables.ExecutablesModule;
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 java.text.ParseException;
import java.util.Set;
import java.util.logging.Logger;
@Singleton
public class Application {
protected final Logger logger;
protected final Set<ApplicationContribution> contributions;
protected final OptionsService optionsService;
protected final EventsService eventsService;
@Inject
public Application(Logger logger, Set<ApplicationContribution> contributions,
OptionsService optionsService, EventsService eventsService) {
this.logger = logger;
this.contributions = contributions;
this.optionsService = optionsService;
this.eventsService = eventsService;
}
public void start(String[] args) {
try {
this.configure();
this.prepare();
this.run(args);
this.stop();
} catch (ParseException exception) {
this.optionsService.printHelp();
} catch (Exception exception) {
this.logger.severe(exception.getMessage());
System.exit(1);
}
}
protected void configure() throws Exception {
this.logger.info("Configuring Application...");
for (ApplicationContribution contribution : this.contributions) {
contribution.configure(this);
}
}
protected void prepare() throws Exception {
this.logger.info("Preparing Application...");
for (ApplicationContribution contribution : this.contributions) {
contribution.prepare(this);
}
}
protected void run(String[] args) throws Exception {
this.logger.info("Running Application...");
for (ApplicationContribution contribution : this.contributions) {
contribution.start(this, args);
}
}
protected void stop() throws Exception {
this.logger.info("Stopping Application...");
for (ApplicationContribution contribution : this.contributions) {
contribution.stop(this);
}
}
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()
);
Application application = injector.getInstance(Application.class);
application.start(args);
}
}
package de.monticore.lang.monticar.visualization.emam.application;
public interface ApplicationContribution {
default void configure(Application application) throws Exception {}
default void prepare(Application application) throws Exception {}
default void start(Application application, String[] args) throws Exception {}
default void stop(Application application) throws Exception {}
}
package de.monticore.lang.monticar.visualization.emam.application;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
import de.monticore.lang.monticar.visualization.emam.dependencies.DependenciesServiceImpl;
import de.monticore.lang.monticar.visualization.emam.executables.ExecutablesServiceImpl;
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;
public class ApplicationModule extends AbstractModule {
@Override
public void configure() {
Multibinder<ApplicationContribution> contributions =
Multibinder.newSetBinder(binder(), ApplicationContribution.class);
contributions.addBinding().to(DependenciesServiceImpl.class);
contributions.addBinding().to(ExecutablesServiceImpl.class);
contributions.addBinding().to(OptionsServiceImpl.class);
contributions.addBinding().to(URLServiceImpl.class);
contributions.addBinding().to(PathsServiceImpl.class);
contributions.addBinding().to(ModelsServiceImpl.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 java.util.logging.Logger;
public abstract class AbstractDependenciesContribution extends EventBus implements DependenciesContribution {
protected final Logger logger;
protected final PathsService pathsService;
protected final URLService urlService;
@Inject
public AbstractDependenciesContribution(Logger logger, PathsService pathsService, URLService urlService) {
this.logger = logger;
this.pathsService = pathsService;
this.urlService = urlService;
}
}
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;
}
package de.monticore.lang.monticar.visualization.emam.dependencies;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
public class DependenciesModule extends AbstractModule {
@Override
public void configure() {
Multibinder<DependenciesContribution> dependencies =
Multibinder.newSetBinder(binder(), DependenciesContribution.class);
dependencies.addBinding().to(VisualizationDependency.class);
dependencies.addBinding().to(MathPrettyPrinterDependency.class);
bind(DependenciesService.class).to(DependenciesServiceImpl.class);
}
}
package de.monticore.lang.monticar.visualization.emam.dependencies;
public interface DependenciesService {
void download() throws Exception;
void install() throws Exception;
void clean() throws Exception;
}
package de.monticore.lang.monticar.visualization.emam.dependencies;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import de.monticore.lang.monticar.visualization.emam.application.Application;
import de.monticore.lang.monticar.visualization.emam.application.ApplicationContribution;
import java.util.Set;
import java.util.logging.Logger;
@Singleton
public class DependenciesServiceImpl implements DependenciesService, ApplicationContribution {
protected final Logger logger;
protected final Set<DependenciesContribution> contributions;
@Inject
public DependenciesServiceImpl(Logger logger, Set<DependenciesContribution> contributions) {
this.logger = logger;
this.contributions = contributions;
}
@Override
public void download() throws Exception {
this.logger.info("Downloading Dependencies...");
for (DependenciesContribution contribution : this.contributions) {
if (!contribution.isDownloaded()) contribution.download();
}
}
@Override
public void install() throws Exception {
this.logger.info("Installing Dependencies...");
for (DependenciesContribution contribution : this.contributions) {
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();
}
}
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 java.io.IOException;
import java.util.logging.Logger;
public class MathPrettyPrinterDependency extends AbstractDependenciesContribution {
@Inject
public MathPrettyPrinterDependency(Logger logger, PathsServiceImpl pathsService, URLService urlService) {
super(logger, pathsService, urlService);
}
@Override
public boolean isDownloaded() {
return false;
}
@Override
public void download() {
}
@Override
public boolean isInstalled() {
return false;
}
@Override
public void install() {
}
@Override
public boolean isCleaned() {
return false;
}
@Override
public void clean() throws IOException {
}
}
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 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);
}
@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();
}