Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into ck/#8-lineLengthDis…
Browse files Browse the repository at this point in the history
…crepancy
  • Loading branch information
ckittl committed Oct 19, 2021
2 parents dca2836 + deca85d commit 73de02e
Show file tree
Hide file tree
Showing 17 changed files with 438 additions and 113 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: gradle
directory: "/"
schedule:
interval: daily
time: "04:00"
open-pull-requests-limit: 10
target-branch: master
reviewers:
- ckittl
- johanneshiry
- t-ober
- sensarmad
68 changes: 35 additions & 33 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer

plugins {
id 'java'
id 'groovy'
id 'maven-publish'
id 'application'
id 'signing'
id 'pmd' //code check, working on source code
id "com.github.spotbugs" version "4.6.0" //code check, working on byte code
id "com.diffplug.spotless" version "5.7.0" //code format
id 'com.github.onslip.gradle-one-jar' version '1.0.5' // pack a self contained jar
id 'org.openjfx.javafxplugin' version '0.0.9' // java 11 javafx plugin for gradle
id "com.github.spotbugs" version "4.7.3" //code check, working on byte code
id "com.diffplug.spotless" version "5.14.3" //code format
id 'com.github.onslip.gradle-one-jar' version '1.0.6' // pack a self contained jar
id 'org.openjfx.javafxplugin' version '0.0.10' // java 11 javafx plugin for gradle
id 'jacoco' // java code coverage plugin
id "org.sonarqube" version "3.0" // sonarqube
id "com.github.johnrengelman.shadow" version "6.1.0" // fat jar
id "org.sonarqube" version "3.3" // sonarqube
id "com.github.johnrengelman.shadow" version "7.1.0" // fat jar
}

ext {
//version (changing these should be considered thoroughly!)
javaVersion = JavaVersion.VERSION_11

javaFxVersion = '15-ea+1'
slf4jVersion = '1.7.26'
slf4jVersion = '1.7.32'

scriptsLocation = 'gradle' + File.separator + 'scripts' + File.separator //location of script plugins
}
Expand All @@ -43,68 +45,68 @@ apply from: scriptsLocation + 'jacoco.gradle'
apply from: scriptsLocation + 'mavenCentralPublish.gradle'

repositories {
jcenter() //searches in bintray's repository 'jCenter', which contains Maven Central
mavenCentral()
maven { url "https://jitpack.io" } // allows for github repos as dependencies
maven { url 'https://oss.sonatype.org/service/local/repositories/snapshots/content' } // snapshot artifacts
}

dependencies {
// ie³ github repository
compile ('com.github.ie3-institute:PowerSystemDataModel:2.0-SNAPSHOT') {
implementation ('com.github.ie3-institute:PowerSystemDataModel:2.0.1') {
/* Exclude nested logging and ie³ related dependencies */
exclude group: 'org.slf4j'
exclude group: 'com.github.ie3-institute'
}

compile ('com.github.ie3-institute:PowerSystemUtils:1.5-SNAPSHOT') {
implementation ('com.github.ie3-institute:PowerSystemUtils:1.5.3') {
/* Exclude nested logging and ie³ related dependencies */
exclude group: 'org.slf4j'
exclude group: 'com.github.ie3-institute'
}

// gluon hq
compile 'com.gluonhq:maps:2.0.0-ea+3'
implementation 'com.gluonhq.attach:util:4.0.7'
implementation 'com.gluonhq:maps:2.0.0-ea+3'
implementation 'com.gluonhq.attach:util:4.0.13'
implementation 'com.gluonhq.attach:storage:4.0.7:desktop'

// JGraphT
compile 'org.jgrapht:jgrapht-core:1.3.1'
compile 'org.jgrapht:jgrapht-ext:1.3.1'
implementation 'org.jgrapht:jgrapht-core:1.5.1'
implementation 'org.jgrapht:jgrapht-ext:1.5.1'


// javafx
compile "org.openjfx:javafx-fxml:$javaFxVersion"
compile "org.openjfx:javafx-swing:$javaFxVersion"
compile "org.openjfx:javafx-graphics:$javaFxVersion"
compile "org.openjfx:javafx-web:$javaFxVersion"
implementation 'org.controlsfx:controlsfx:11.0.1'
implementation "org.openjfx:javafx-fxml:$javaFxVersion"
implementation "org.openjfx:javafx-swing:$javaFxVersion"
implementation "org.openjfx:javafx-graphics:$javaFxVersion"
implementation "org.openjfx:javafx-web:$javaFxVersion"
implementation 'org.controlsfx:controlsfx:11.1.0'

// Apache POI
compile 'org.apache.poi:poi-ooxml:4.1.0'
implementation 'org.apache.poi:poi-ooxml:5.0.0'

// rx java
compile 'io.reactivex:rxjava:1.3.8'
implementation 'io.reactivex:rxjava:1.3.8'

// logging
compile "org.slf4j:slf4j-api:${slf4jVersion}" // slf4j wrapper
compile 'com.lmax:disruptor:+' //async logging
compile 'org.apache.logging.log4j:log4j-api:+' // log4j
compile 'org.apache.logging.log4j:log4j-core:+' // log4j
compile 'org.apache.logging.log4j:log4j-slf4j-impl:+' // log4j -> slf4j
implementation "org.slf4j:slf4j-api:${slf4jVersion}" // slf4j wrapper
implementation 'com.lmax:disruptor:3.4.4' //async logging
implementation 'org.apache.logging.log4j:log4j-api:2.14.1' // log4j
implementation 'org.apache.logging.log4j:log4j-core:2.14.1' // log4j
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.14.1' // log4j -> slf4j


// testing
testCompile 'junit:junit:+'
testCompile 'org.spockframework:spock-core:2.0-M1-groovy-2.5'
testCompile 'cglib:cglib-nodep:+' //enables mocking of classes (in addition to interfaces)
compile 'org.mockito:mockito-core:+' //mocking framework
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
testImplementation 'cglib:cglib-nodep:3.3.0' //enables mocking of classes (in addition to interfaces)
implementation 'org.mockito:mockito-core:3.12.4' //mocking framework

// pbf parser //
compile 'com.github.johanneshiry:OSMonaut:1.1'
implementation 'com.github.johanneshiry:OSMonaut:v1.1.1'
}

wrapper {
gradleVersion = '6.7'
gradleVersion = '7.2'
}

javafx {
Expand All @@ -131,7 +133,7 @@ task printVersion {

shadowJar {

transform(com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer) {
transform(AppendingTransformer) {
resource = 'reference.conf'
}
zip64 = true
Expand Down
10 changes: 4 additions & 6 deletions gradle/scripts/pmd.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// pmd is a code check tool, working on source code

pmd {
ignoreFailures true // dont let the build fail on rule violations

// pmd rule priority is a range from 1 to 5, with 1 being the highest priority
// the default rule priority is 5
rulePriority 2
}
consoleOutput = true
toolVersion = "6.21.0"
rulesMinimumPriority = 2
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
21 changes: 3 additions & 18 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -64,29 +64,14 @@ echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@
import edu.ie3.netpad.io.event.ReadGridEvent;
import edu.ie3.netpad.io.event.SaveGridEvent;
import edu.ie3.netpad.map.event.MapEvent;
import edu.ie3.netpad.tool.LineLengthResolutionMode;
import edu.ie3.netpad.tool.controller.ToolController;
import edu.ie3.netpad.tool.controller.ToolDialogs;
import edu.ie3.netpad.tool.event.FixLineLengthRequestEvent;
import edu.ie3.netpad.tool.event.LayoutGridRequestEvent;
import edu.ie3.netpad.tool.event.LayoutGridResponse;
import edu.ie3.netpad.tool.event.ToolEvent;
import edu.ie3.netpad.tool.grid.LineLengthFixer;
import edu.ie3.netpad.tool.grid.LineLengthResolutionMode;
import edu.ie3.util.geo.GeoUtils;
import edu.ie3.util.quantities.PowerSystemUnits;
import java.util.*;
Expand Down Expand Up @@ -229,7 +230,8 @@ private ChangeListener<ToolEvent> toolEventListener() {
FixLineLengthRequestEvent event = (FixLineLengthRequestEvent) newValue;
LineLengthResolutionMode resolutionMode = event.getResolutionMode();
Set<Integer> selectedSubnets = event.getSelectedSubnets();
fixLineLength(resolutionMode, selectedSubnets);
LineLengthFixer.execute(resolutionMode, selectedSubnets, subGrids)
.ifPresent(this::handleReadGridEvent);
} else {
throw new RuntimeException("Invalid GridContainer provided!");
}
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/edu/ie3/netpad/io/controller/IoController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

import edu.ie3.datamodel.exceptions.FileException;
import edu.ie3.datamodel.exceptions.ParsingException;
import edu.ie3.datamodel.io.TarballUtils;
import edu.ie3.datamodel.io.csv.DefaultDirectoryHierarchy;
import edu.ie3.datamodel.io.csv.FileNamingStrategy;
import edu.ie3.datamodel.io.csv.HierarchicFileNamingStrategy;
import edu.ie3.datamodel.io.naming.EntityPersistenceNamingStrategy;
import edu.ie3.datamodel.io.naming.HierarchicFileNamingStrategy;
import edu.ie3.datamodel.io.processor.ProcessorProvider;
import edu.ie3.datamodel.io.sink.CsvFileSink;
import edu.ie3.datamodel.io.source.csv.*;
Expand All @@ -30,6 +29,7 @@
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ChangeListener;
Expand Down Expand Up @@ -101,8 +101,8 @@ public boolean loadGridFromArchive(
/* Extract the content of the tarball */
Path folderPath;
try {
folderPath = TarballUtils.extract(absoluteArchivePath.toPath(), tmpDirectory, false);
} catch (FileException e) {
folderPath = FileIOUtils.extractDir(absoluteArchivePath.toPath(), tmpDirectory).get();
} catch (ExecutionException | InterruptedException e) {
logger.error("Cannot read from archive, as extraction failed.", e);
return false;
}
Expand Down Expand Up @@ -134,12 +134,12 @@ public boolean loadGridFromDirectory(
IoDialogs.CsvIoData.DirectoryHierarchy hierarchy) {
/* Collect the information needed to obtain the grid structure */
String gridName = extractGridName(absoluteFilePath);
FileNamingStrategy fileNamingStrategy;
EntityPersistenceNamingStrategy fileNamingStrategy;
String baseDirectory;
switch (hierarchy) {
case FLAT:
baseDirectory = absoluteFilePath.toString();
fileNamingStrategy = new FileNamingStrategy();
fileNamingStrategy = new EntityPersistenceNamingStrategy();
break;
case HIERARCHIC:
/* Remove the last part from the path and possibly the last File separator */
Expand Down Expand Up @@ -279,9 +279,9 @@ private void saveGridCompressed(
ZonedDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddhhmmssSSS")));
saveGridToCsv(targetDirectory, gridContainer, hierarchy, csvSeparator);
Path targetFile = Paths.get(FilenameUtils.concat(targetPath, gridName + ".tar.gz"));
TarballUtils.compress(Paths.get(targetDirectory), targetFile);
FileIOUtils.compressDir(Paths.get(targetDirectory), targetFile).get();
FileIOUtils.deleteRecursively(tmpDirectory);
} catch (IOException | FileException e) {
} catch (IOException | ExecutionException | InterruptedException e) {
throw new IoControllerException("Cannot save '" + gridName + "'.", e);
}
}
Expand All @@ -300,9 +300,9 @@ private void saveGridToCsv(
IoDialogs.CsvIoData.DirectoryHierarchy hierarchy,
String csvSeparator) {
/* Persist the raw csv data */
FileNamingStrategy fileNamingStrategy =
EntityPersistenceNamingStrategy fileNamingStrategy =
hierarchy == IoDialogs.CsvIoData.DirectoryHierarchy.FLAT
? new FileNamingStrategy()
? new EntityPersistenceNamingStrategy()
: new HierarchicFileNamingStrategy(
new DefaultDirectoryHierarchy(targetDirectory, gridContainer.getGridName()));
CsvFileSink csvFileSink =
Expand Down
34 changes: 16 additions & 18 deletions src/main/java/edu/ie3/netpad/tool/controller/ToolDialogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
*/
package edu.ie3.netpad.tool.controller;

import static edu.ie3.netpad.tool.LineLengthResolutionMode.ELECTRICAL;
import static edu.ie3.netpad.tool.LineLengthResolutionMode.GEOGRAPHICAL;
import static edu.ie3.netpad.tool.grid.LineLengthResolutionMode.ELECTRICAL;
import static edu.ie3.netpad.tool.grid.LineLengthResolutionMode.GEOGRAPHICAL;
import static javafx.scene.control.CheckBoxTreeItem.checkBoxSelectionChangedEvent;

import edu.ie3.datamodel.models.input.container.SubGridContainer;
import edu.ie3.datamodel.models.voltagelevels.VoltageLevel;
import edu.ie3.netpad.exception.NetPadPlusPlusException;
import edu.ie3.netpad.grid.controller.GridController;
import edu.ie3.netpad.tool.LineLengthResolutionMode;
import edu.ie3.netpad.tool.grid.LineLengthResolutionMode;
import java.util.*;
import java.util.stream.Collectors;
import javafx.beans.binding.Bindings;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
Expand Down Expand Up @@ -152,20 +151,19 @@ private static Collection<CheckBoxTreeItem<String>> buildTreeItems(
new CheckBoxTreeItem<>(Integer.toString(subGrid.getSubnet()));
checkBoxTreeItem.addEventHandler(
checkBoxSelectionChangedEvent(),
(EventHandler<CheckBoxTreeItem.TreeModificationEvent<String>>)
event -> {
CheckBoxTreeItem<String> chk = event.getTreeItem();
try {
int subnetNumber = Integer.parseInt(chk.getValue());
if (chk.isSelected()) {
selectedSubnets.add(subnetNumber);
} else {
selectedSubnets.remove(subnetNumber);
}
} catch (NumberFormatException nfe) {
logger.error("Unable to parse '{}' to integer.", chk.getValue());
}
});
event -> {
CheckBoxTreeItem<Object> chk = event.getTreeItem();
try {
int subnetNumber = Integer.parseInt((String) chk.getValue());
if (chk.isSelected()) {
selectedSubnets.add(subnetNumber);
} else {
selectedSubnets.remove(subnetNumber);
}
} catch (NumberFormatException nfe) {
logger.error("Unable to parse '{}' to integer.", chk.getValue());
}
});
checkBoxTreeItem.setSelected(true);

voltageLvlChkBox.getChildren().add(checkBoxTreeItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
package edu.ie3.netpad.tool.event;

import edu.ie3.netpad.tool.LineLengthResolutionMode;
import edu.ie3.netpad.tool.grid.LineLengthResolutionMode;
import java.util.Objects;
import java.util.Set;

Expand Down
Loading

0 comments on commit 73de02e

Please sign in to comment.