Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b5fb4fd
fixed documentation
johanneshiry Mar 31, 2020
86c54e4
adapted Jenkinsfile for builds without PR
johanneshiry Mar 31, 2020
ce6a95a
added interfaces for classes holding nodes or types
johanneshiry Mar 31, 2020
4cb0463
added Nodes interface to corresponding classes
johanneshiry Mar 31, 2020
6bfa59f
added Extractor for nested models
johanneshiry Mar 31, 2020
8b50db6
moved extractor and new interfaces to own class
johanneshiry Mar 31, 2020
795fcc3
- added ExtractorException
johanneshiry Mar 31, 2020
7e1a634
fmt
johanneshiry Mar 31, 2020
bddcb0e
disabled passed tests login in tests.gradle
johanneshiry Mar 31, 2020
2c07caf
disabled passed tests logging for allTests()
johanneshiry Mar 31, 2020
8869594
introduced new interfaces to avoid model adaptions for Extractor
johanneshiry Mar 31, 2020
39e83f7
added type interface to classes that hold a type
johanneshiry Mar 31, 2020
27cc3bd
added ExtractorTest + minor adaptions
johanneshiry Mar 31, 2020
1376151
extended tests for CsvFileSink
johanneshiry Mar 31, 2020
5547b54
reduced constructor complexity in CsvFileSink
johanneshiry Mar 31, 2020
c47866f
fmt
johanneshiry Mar 31, 2020
d45c2a9
addressing codacy issues
johanneshiry Mar 31, 2020
7b484fb
added new interfaces to InputDatamodelConcept.puml
johanneshiry Apr 1, 2020
25008b0
added missing documentation + fmt
johanneshiry Apr 1, 2020
17e7438
fix a wrong cast in CsvFileSink
johanneshiry Apr 1, 2020
65040e1
fmt
johanneshiry Apr 1, 2020
f6d8106
Merge branch 'master' into jh/#78-nested-model-extractor
ckittl Apr 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -314,23 +314,36 @@ if (env.BRANCH_NAME == "master") {
getFeatureBranchProps()

node {
// curl the api to get debugging details
def jsonObj = getGithubPRJsonObj(env.CHANGE_ID, orgNames.get(0), projects.get(0))

// This displays colors using the 'xterm' ansi color map.
def repoName = ""
// init variables depending of this build is triggered by a branch with PR or without PR
if (env.CHANGE_ID == null) {
// no PR exists
featureBranchName = env.BRANCH_NAME
repoName = orgNames.get(0) + "/" + projects.get(0)
} else {
// PR exists
/// curl the api to get debugging details
def jsonObj = getGithubPRJsonObj(env.CHANGE_ID, orgNames.get(0), projects.get(0))

featureBranchName = jsonObj.head.ref
repoName = jsonObj.head.repo.full_name

}


ansiColor('xterm') {
try {
// set java version
setJavaVersion(javaVersionId)

/// set the build name
featureBranchName = jsonObj.head.ref
currentBuild.displayName = featureBranchName + " (" + currentBuild.displayName + ")"

// notify rocket chat about the started feature branch run
rocketSend channel: rocketChatChannel, emoji: ':jenkins_triggered:',
message: "feature branch build triggered:\n" +
"*repo:* ${jsonObj.head.repo.full_name}\n" +
"*repo:* ${repoName}\n" +
"*branch:* ${featureBranchName}\n"
rawMessage: true

Expand Down Expand Up @@ -383,7 +396,7 @@ if (env.BRANCH_NAME == "master") {
// notify rocket chat
rocketSend channel: rocketChatChannel, emoji: ':jenkins_party:',
message: "feature branch test successful!\n" +
"*repo:* ${jsonObj.head.repo.full_name}\n" +
"*repo:* ${repoName}\n" +
"*branch:* ${featureBranchName}\n"
rawMessage: true
}
Expand All @@ -401,7 +414,7 @@ if (env.BRANCH_NAME == "master") {
// notify rocket chat
rocketSend channel: rocketChatChannel, emoji: ':jenkins_explode:',
message: "feature branch test failed!\n" +
"*repo:* ${jsonObj.head.repo.full_name}\n" +
"*repo:* ${repoName}\n" +
"*branch:* ${featureBranchName}\n"
rawMessage: true
}
Expand Down
30 changes: 30 additions & 0 deletions docs/uml/main/InputDatamodelConcept.puml
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
@startuml

'extractor interface information

interface Nested

interface Node
Node --|> Nested

interface Nodes
Nodes --|> Nested

interface NodeC
NodeC --|> Nested

interface Type
Type --|> Nested



abstract Class UniqueEntity {
+ uuid: UUID
}
Expand All @@ -24,6 +42,7 @@ abstract Class SystemParticipantInput {
- qCharacteristics: String
}
SystemParticipantInput --|> AssetInput
SystemParticipantInput --|> Node

Class OperatorInput {
+ name: String
Expand All @@ -35,6 +54,7 @@ abstract Class ConnectorInput {
+ nodeB: NodeInput
}
ConnectorInput --|> AssetInput
ConnectorInput --|> Nodes

abstract Class AssetCharacteristicsInput<T extends AssetTypeInput> {
- type: T
Expand Down Expand Up @@ -208,12 +228,14 @@ Class WecInput{
- marketReaction: Boolean
}
WecInput --|> SystemParticipantInput
WecInput --|> Type

Class ChpInput {
- type: ChpTypeInput
- marketReaction: Boolean
}
ChpInput --|> SystemParticipantInput
ChpInput --|> Type

Class BmInput {
- type: BmTypeInput
Expand All @@ -223,11 +245,13 @@ Class BmInput {
- costControlled: Boolean
}
BmInput --|> SystemParticipantInput
BmInput --|> Type

Class EvInput {
- type: EvTypeInput
}
EvInput --|> SystemParticipantInput
EvInput --|> Type

Class LoadInput {
- scenario: String
Expand All @@ -242,11 +266,13 @@ Class StorageInput {
- behaviour: String
}
StorageInput --|> SystemParticipantInput
StorageInput --|> Type

Class HpInput {
- type: HpTypeInput
}
HpInput --|> SystemParticipantInput
HpInput --|> Type

Abstract Class ThermalUnitInput {
- uuid: UUID
Expand Down Expand Up @@ -314,6 +340,7 @@ Class LineInput {
+ geoPosition: LineString
}
LineInput --|> ConnectorInput
LineInput --|> Type

Class SwitchInput {
+ closed: Boolean
Expand All @@ -331,12 +358,15 @@ Class Transformer2WInput {
+ type: Transformer2WTypeInput
}
Transformer2WInput --|> TransformerInput
Transformer2WInput --|> Type

Class Transformer3WInput {
+ nodeC: NodeInput
+ type: Transformer3WTypeInput
}
Transformer3WInput --|> TransformerInput
Transformer3WInput --|> NodeC
Transformer3WInput --|> Type

abstract Class GraphicInput {
+ graphicLayer: String
Expand Down
4 changes: 2 additions & 2 deletions gradle/scripts/tests.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test {
}
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
events "skipped", "failed"
}
}

Expand All @@ -24,7 +24,7 @@ task allTests(type: Test) {

useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
events "skipped", "failed"
}

filter {
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/edu/ie3/datamodel/exceptions/ExtractorException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* © 2020. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.exceptions;

/**
* Exception that should be used whenevery something invalid happens in a implementation of a {@link
* edu.ie3.datamodel.io.connectors.DataConnector}
*
* @version 0.1
* @since 20.03.20
*/
public class ExtractorException extends Exception {

public ExtractorException(final String message, final Throwable cause) {
super(message, cause);
}

public ExtractorException(final Throwable cause) {
super(cause);
}

public ExtractorException(final String message) {
super(message);
}
}
59 changes: 59 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/extractor/Extractor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* © 2020. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.io.extractor;

import edu.ie3.datamodel.exceptions.ExtractorException;
import edu.ie3.datamodel.models.input.InputEntity;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
* A simple utility class that can be used by sinks to extract nested elements (e.g. nodes, types)
* that should be persisted.
*
* @version 0.1
* @since 31.03.20
*/
public class Extractor {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to have a simple static class. So then you could save the instantiation.

Suggested change
public class Extractor {
public class NestedEntityUtils {
public NestedEntityUtils() {
throw new IllegalStateException("Do not instantiate static utility class");
}


private final List<InputEntity> extractedEntities;

public Extractor(Nested nestedEntity) throws ExtractorException {
this.extractedEntities = extractElements(nestedEntity);
}

private List<InputEntity> extractElements(Nested nestedEntity) throws ExtractorException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private List<InputEntity> extractElements(Nested nestedEntity) throws ExtractorException {
private Set<InputEntity> extractElements(Collection<Nested> nestedEntities) throws ExtractorException {
return Collections.unmodifiableSet(nestedEntities.stream().map(nested -> {
if (nestedEntities instanceof Node) {
return Collections.singletonList(((Node) nestedEntities).getNode());
} else if (nestedEntities instanceof NodeC) {
return Collections.singletonList(((NodeC) nestedEntities).getNodeC());
} else if (nestedEntities instanceof Nodes) {
return Arrays.asList(((Nodes) nestedEntities).getNodeA(), ((Nodes) nestedEntities).getNodeB());
} else if (nestedEntities instanceof Type) {
return Collections.singletonList(((Type) nestedEntities).getType());
} else {
return new ArrayList<InputEntity>();
}
}).flatMap(List::stream).collect(Collectors.toSet()));
}

This automatically would ensure, that duplicated nodes etc. are only apparent once.

List<InputEntity> resultingList = new ArrayList<>();
if (nestedEntity instanceof Node) {
resultingList.add(((Node) nestedEntity).getNode());
}
if (nestedEntity instanceof NodeC) {
resultingList.add(((NodeC) nestedEntity).getNodeC());
}
if (nestedEntity instanceof Nodes) {
resultingList.addAll(
Arrays.asList(((Nodes) nestedEntity).getNodeA(), ((Nodes) nestedEntity).getNodeB()));
}
if (nestedEntity instanceof Type) {
resultingList.add(((Type) nestedEntity).getType());
}
if (resultingList.isEmpty()) {
throw new ExtractorException(
"The interface 'Nested' is not meant to be extended. The provided entity of class '"
+ nestedEntity.getClass().getSimpleName()
+ "' and cannot be processed by "
+ "the extractor! Currently only the interfaces 'Node', 'NodeC', ‘Nodes‘ and ‘Type' are supported!");
}

return Collections.unmodifiableList(resultingList);
}

public List<InputEntity> getExtractedEntities() {
return extractedEntities;
}
}
17 changes: 17 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/extractor/Nested.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* © 2020. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.io.extractor;

/**
* This interface should be implemented only by other interfaces that should be used by the {@link
* Extractor} It provides the entry point for the extraction method in the {@link Extractor}. If
* this interface is implemented by other interfaces one has to take care about, that the
* corresponding method {@link Extractor.extractElements()} is extended accordingly.
*
* @version 0.1
* @since 31.03.20
*/
public interface Nested {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public interface Nested {}
public interface NestedEntity {}

20 changes: 20 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/extractor/Node.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* © 2020. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.io.extractor;

import edu.ie3.datamodel.models.input.NodeInput;

/**
* Interface that should be implemented by all elements holding a {@link NodeInput} and should be
* processable by the {@link Extractor}
*
* @version 0.1
* @since 31.03.20
*/
public interface Node extends Nested {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about pimpin the Nodes interface and letting go Node and NodeC? See comments below.


NodeInput getNode();
}
21 changes: 21 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/extractor/NodeC.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* © 2020. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.io.extractor;

import edu.ie3.datamodel.models.input.NodeInput;

/**
* Interface that should be implemented by all elements holding a third {@link NodeInput} and should
* be processable by the {@link Extractor}. For now, this only holds true by the {@link
* edu.ie3.datamodel.models.input.connector.Transformer3WInput}
*
* @version 0.1
* @since 31.03.20
*/
public interface NodeC extends Nested {

NodeInput getNodeC();
}
24 changes: 24 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/extractor/Nodes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* © 2020. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.io.extractor;

import edu.ie3.datamodel.models.input.NodeInput;

/**
* Interface that should be implemented by all elements holding a two {@link NodeInput} elements and
* should be processable by the {@link Extractor}. For now, this only holds true by all {@link
* edu.ie3.datamodel.models.input.connector.ConnectorInput} and {@link
* edu.ie3.datamodel.models.input.connector.TransformerInput}
*
* @version 0.1
* @since 31.03.20
*/
public interface Nodes extends Nested {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public interface Nodes extends Nested {
public interface WithNestedNodes extends Nested {

It is not really an Interface describing nodes conceptually, but an entity, that has nodes.


NodeInput getNodeA();

NodeInput getNodeB();
Comment on lines +21 to +23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NodeInput getNodeA();
NodeInput getNodeB();
Collection<NodeInput> getNodes();

}
20 changes: 20 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/extractor/Type.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* © 2020. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.io.extractor;

import edu.ie3.datamodel.models.input.AssetTypeInput;

/**
* Interface that should be implemented by all elements holding a {@link AssetTypeInput} and should
* be processable by the {@link Extractor}.
*
* @version 0.1
* @since 31.03.20
*/
public interface Type extends Nested {

AssetTypeInput getType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ private Collection<EntityProcessor<? extends UniqueEntity>> allProcessors() {
Collection<EntityProcessor<? extends UniqueEntity>> resultingProcessors = new ArrayList<>();

// todo add missing processors here
// AssetInput
// Input Entity Processor
for (Class<? extends InputEntity> cls : InputEntityProcessor.eligibleEntityClasses) {
resultingProcessors.add(new InputEntityProcessor(cls));
}

// SystemParticipantResults
// Result Entity Processor
for (Class<? extends ResultEntity> cls : ResultEntityProcessor.eligibleEntityClasses) {
resultingProcessors.add(new ResultEntityProcessor(cls));
}
Expand Down
Loading