Added AppController M24

parent 8df826a5
/classes/
*.class
*.lst
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
*.iml
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Maven template
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
pom.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
### Eclipse template
.project
.classpath
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
/classes/
*.class
*.lst
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
*.iml
.idea/
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Maven template
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
pom.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
### Eclipse template
.project
.classpath
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
#Windows specific
*~
This diff is collapsed.
# DECIDE Application Controller
The Application Controller Library provides a consistent way for handling the AppDescription and History json files to every project that has to operate on these files.
## Table of Contents
1. [Features](#features)
1. [Installation](#installation)
1. [Getting started](#getting-started)
1. [The Model](#the-model)
1. [The Interface](#the-interface)
1. [License](#license)
## Features
- :sunglasses: A simple and intuitive interface
- :hammer_and_wrench: Internal handling of state in git repository and filesystem
## Building from Source
The project is available via Git repository. If you have access, do the following steps:
```shell
$> git clone https://gitlab.fokus.fraunhofer.de/DECIDE/app-controller.git
$> cd app-controller
```
The project uses Maven as build tool. After build you will find the jar and a fat jar in the target directory. To build use the follwoing command:
```shell
$> mvn clean package
```
Use `-DskipTests` if the test repository is not accessible for you. If you would like to do the tests, edit the test class `AppManagerTest` and provide the necessary remote repository values.
## Installation
For non-Maven based projects you can take the build jar file located in the target directory after executing the build command and put it in the classpath of your application. There is also a fat jar provided containing all dependecies if required.
For Maven based projects you need to install it in a Maven repository which your application can access. E.g. to put it in your local maven repository, you can simply call
`$> mvn install`
Finally, your application pom.xml requires the following dependency:
```xml
<dependency>
<groupId>eu.DECIDEh2020</groupId>
<artifactId>app-controller</artifactId>
<version>0.0.2</version>
</dependency>
```
## Getting started
A small example on getting the `AppDescription` and saving it using the `AppManager`:
```java
AppManager appManager = AppManager.open(String gitRef, String username, String password, Path localPath);
//get the Appdescription
AppDescription appDescription = appManager.getAppDescription();
//do something with the AppDescription
//then save
appManager.writeAndSync(appDescription, "Added new Microservices");
//close the AppManager
appManager.close();
```
Since the `AppManager` also implements the `Closeable` interface you can also use the `try-with-resources` statement to work on the `AppDescription`.
```java
Path path = FileSystems.getDefault().getPath("path/to/git/dir");
try (AppManager appManager = AppManager.open("https://git.ref/", "username", "password", path)) {
AppDescription appDescription = appManager.getAppDescription();
//work on the AppDescription & save it with AppManager
appManager.writeAndSync(appDescription, "Added NFRs");
} catch (IOException e) {
e.printStackTrace();
}
```
For further examples please take a look at the test cases.
## The Model
### `AppDescription`
The library implements the application description and all its properties as POJOs with corresponding getters and setters. See package `eu.DECIDEh2020.appManager.models` for an overview. During serialization any empty or null properties will be ommitted.
For more flexibility during the development of DECIDE some model classes allow the setting and getting of additional properties that are not part of the schema. These classes are so far:
* `AppDescription`
* `Nfr`
* `Pattern`
* `Container`
* `VirtualMachine`
They have the special setter `setAdditionalProperties()` and getter `getAdditionalProperties()`, which sets and gets any JsonNode objects as values.
### `List<HistoryEntry>`
## The Interface
In general there are three main classes:
* `AppDescriptionFactory`
* `AppDescriptionHelper`
* `AppManager`
* `HistoryFactory`
* `HistoryManager`
### `AppDescriptionFactory`
This class provides static methods for creating, loading, saving and validating app description instances.
### `AppDescriptionHelper`
This class provides convenient methods to access internal information of the app description by processing any conventions made by the project. E.g. retreives groups and lists defined by tags.
### `AppManager`
This class offers encapsulation to any persistency. Current implementation covers a git repository.
### `HistoryFactory`
This class provides static methods for creating, loading, saving and validating history instances.
### `HistoryManager`
This class encapsulates the history model inside the app context. Therefore it can only be instantiated from an app manager.
## License
[Eclipse Public License version 2.0.](LICENSE.txt)
\ No newline at end of file
# DECIDE Application Controller Library
The Application Controller Library provides a consistent way for handling the AppDescription and History json files to every project that has to operate on these files.
## Table of Contents
1. [Features](#features)
1. [Installation](#installation)
1. [Getting started](#getting-started)
1. [Validation Exception Handling](#validation-exception-handling)
1. [The Model](#the-model)
1. [The Interface](#the-interface)
1. [License](#license)
## Features
- :sunglasses: A simple and intuitive interface
- :hammer_and_wrench: Internal handling of state in git repository and filesystem
## Building from Source
The project is available via Git repository. If you have access, do the following steps:
```bash
$> git clone https://gitlab.fokus.fraunhofer.de/DECIDE/app-controller.git
$> cd app-controller
```
The project uses Maven as build tool. After build you will find the jar and a fat jar in the target directory. To build use the follwoing command:
```bash
$> mvn clean package
```
Use `-DskipTests` if the test repository is not accessible for you. If you would like to do the tests, edit the test class `AppManagerTest` and provide the necessary remote repository values.
## Installation
For non-Maven based projects you can take the build jar file located in the target directory after executing the build command and put it in the classpath of your application. There is also a fat jar provided containing all dependecies if required.
For Maven based projects you need to install it in a Maven repository which your application can access. E.g. to put it in your local maven repository, you can simply call
`$> mvn install`
Finally, your application pom.xml requires the following dependency:
```xml
<dependency>
<groupId>eu.DECIDEh2020</groupId>
<artifactId>app-controller</artifactId>
<version>0.0.2</version>
</dependency>
```
## Getting started
A small example on getting the `AppDescription` and saving it using the `AppManager`:
```java
AppManager appManager = AppManager.open(String gitRef, String username, String password, Path localPath);
// get the Appdescription
AppDescription appDescription = appManager.getAppDescription();
// do something with the AppDescription
// then save
appManager.writeAndSync(appDescription, "Added new Microservices");
// close the AppManager
appManager.close();
```
Since the `AppManager` also implements the `Closeable` interface you can also use the `try-with-resources` statement to work on the `AppDescription`.
```java
Path path = FileSystems.getDefault().getPath("path/to/git/dir");
try (AppManager appManager = AppManager.open("https://git.ref/", "username", "password", path)) {
AppDescription appDescription = appManager.getAppDescription();
//work on the AppDescription & save it with AppManager
appManager.writeAndSync(appDescription, "Added NFRs");
} catch (AppManagerException | IOException e) {
e.printStackTrace();
}
```
For further examples please take a look at the test cases.
## Validation Exception Handling
A `DECIDEValidationException` is usually a wrapper for the underlying validation library validation errors. The AppController utilizes the JSON Schema Validator from everit-org. You can easily access the original `ValidationException` if you need more details beyond the main message.
```java
try {
AppDescription appDescription = appManager.getAppDescription();
} catch (DECIDEValidationException e) {
ValidationException original = (ValidationException)e.getCause();
// get a list of all sub messages
List<String> messages = original.getAllMessages();
// get all sub exceptions. Each one is again a ValidationException
List<ValidationException> original.getCausingExceptions();
// getting a fancy pretty printed json structure containing all sub errors
String json = original.getJSON().toString(4);
} catch (IOEXception e) {
}
```
Please note that `DECIDEValidationException` is also a subclass of `AppManagerException`.
## The Model
### `AppDescription`
The library implements the application description and all its properties as POJOs with corresponding getters and setters. See package `eu.DECIDEh2020.appManager.models` for an overview. During serialization any empty or null properties will be ommitted.
For more flexibility during the development of DECIDE some model classes allow the setting and getting of additional properties that are not part of the schema. These classes are so far:
* `AppDescription`
* `Nfr`
* `Pattern`
* `Container`
* `VirtualMachine`
They have the special setter `setAdditionalProperties()` and getter `getAdditionalProperties()`, which sets and gets any JsonNode objects as values.
### `List<HistoryEntry>`
## The Interface
In general there are three main classes:
* `AppDescriptionFactory`
* `AppDescriptionHelper`
* `AppManager`
* `HistoryFactory`
* `HistoryManager`
### `AppDescriptionFactory`
This class provides static methods for creating, loading, saving and validating app description instances.
### `AppDescriptionHelper`
This class provides convenient methods to access internal information of the app description by processing any conventions made by the project. E.g. retreives groups and lists defined by tags.
### `AppManager`
This class offers encapsulation to any persistency. Current implementation covers a git repository.
### `HistoryFactory`
This class provides static methods for creating, loading, saving and validating history instances.
### `HistoryManager`
This class encapsulates the history model inside the app context. Therefore it can only be instantiated from an app manager.
## License
[GNU Affero General Public License Version 3](LICENSE.txt)
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>eu.DECIDEh2020</groupId>
<artifactId>app-controller</artifactId>
<version>0.0.12</version>
<repositories>
<repository>
<id>jgit-repository</id>
<url>https://repo.eclipse.org/content/groups/releases/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>4.11.0.201803080745-r</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.github.everit-org.json-schema</groupId>
<artifactId>org.everit.json.schema</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile>
</configuration>