-
Notifications
You must be signed in to change notification settings - Fork 7
Adding processor for graphic inputs #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2cecd77
Switching to package org.locationtech.jts.io.geojson as geographic re…
ckittl 5a1ecd6
Extending test data + documenting hierarchy
ckittl e807a62
De-serializing graphic input models
ckittl 78f7145
Merge remote-tracking branch 'remotes/origin/jh/#73-extend-processors…
johanneshiry 04f369c
Merge branch 'master' into ck/#73-graphicInputProcessors
ckittl 7b2c9a2
merge master into feature
johanneshiry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@startuml | ||
Interface GridTestData | ||
Interface ComplexTopology | ||
Interface SystemParticipantTestData | ||
|
||
GridTestData <|-- ComplexTopology | ||
GridTestData <|-- SystemParticipantTestData | ||
@enduml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/edu/ie3/datamodel/io/processor/input/GraphicInputProcessor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* © 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.processor.input; | ||
|
||
import edu.ie3.datamodel.io.processor.EntityProcessor; | ||
import edu.ie3.datamodel.models.input.graphics.GraphicInput; | ||
import edu.ie3.datamodel.models.input.graphics.LineGraphicInput; | ||
import edu.ie3.datamodel.models.input.graphics.NodeGraphicInput; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import javax.measure.Quantity; | ||
|
||
/** | ||
* Processor to deserialize all children of {@link GraphicInput} to a mapping from field name to | ||
* value (as string representation). All necessary processes are already apparent in the {@link | ||
* EntityProcessor}, therefore, no additional implementations have to be made. | ||
*/ | ||
public class GraphicInputProcessor extends EntityProcessor<GraphicInput> { | ||
public static final List<Class<? extends GraphicInput>> eligibleEntityClasses = | ||
Collections.unmodifiableList(Arrays.asList(NodeGraphicInput.class, LineGraphicInput.class)); | ||
|
||
public GraphicInputProcessor(Class<? extends GraphicInput> registeredClass) { | ||
super(registeredClass); | ||
} | ||
|
||
@Override | ||
protected Optional<String> handleProcessorSpecificQuantity( | ||
Quantity<?> quantity, String fieldName) { | ||
throw new UnsupportedOperationException( | ||
"No specific quantity handling required for graphic input models."); | ||
} | ||
|
||
@Override | ||
protected List<Class<? extends GraphicInput>> getAllEligibleClasses() { | ||
return eligibleEntityClasses; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/test/groovy/edu/ie3/datamodel/io/processor/input/GraphicInputProcessorTest.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package edu.ie3.datamodel.io.processor.input | ||
|
||
import edu.ie3.datamodel.models.input.graphics.LineGraphicInput | ||
import edu.ie3.datamodel.models.input.graphics.NodeGraphicInput | ||
import edu.ie3.test.common.GridTestData | ||
import edu.ie3.util.TimeTools | ||
import spock.lang.Specification | ||
|
||
import java.time.ZoneId | ||
|
||
class GraphicInputProcessorTest extends Specification { | ||
static { | ||
TimeTools.initialize(ZoneId.of("UTC"), Locale.GERMANY, "yyyy-MM-dd HH:mm:ss") | ||
} | ||
|
||
def "The GraphicInputProcessor should de-serialize a provided NodeGraphicInput with point correctly"(){ | ||
given: | ||
GraphicInputProcessor processor = new GraphicInputProcessor(NodeGraphicInput.class) | ||
NodeGraphicInput validNode = GridTestData.nodeGraphicC | ||
Map expected = [ | ||
"uuid" : "09aec636-791b-45aa-b981-b14edf171c4c", | ||
"graphicLayer" : "main", | ||
"path" : "", | ||
"point" : "{\"type\":\"Point\",\"coordinates\":[0.0,10],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", | ||
"node" : "bd837a25-58f3-44ac-aa90-c6b6e3cd91b2" | ||
] | ||
|
||
when: | ||
Optional<LinkedHashMap<String, String>> actual = processor.handleEntity(validNode) | ||
|
||
then: | ||
actual.isPresent() | ||
actual.get() == expected | ||
} | ||
|
||
def "The GraphicInputProcessor should de-serialize a provided NodeGraphicInput with path correctly"(){ | ||
given: | ||
GraphicInputProcessor processor = new GraphicInputProcessor(NodeGraphicInput.class) | ||
NodeGraphicInput validNode = GridTestData.nodeGraphicD | ||
Map expected = [ | ||
"uuid" : "9ecad435-bd16-4797-a732-762c09d4af25", | ||
"graphicLayer" : "main", | ||
"path" : "{\"type\":\"LineString\",\"coordinates\":[[-1,0.0],[1,0.0]],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", | ||
"point" : "", | ||
"node" : "6e0980e0-10f2-4e18-862b-eb2b7c90509b" | ||
] | ||
|
||
when: | ||
Optional<LinkedHashMap<String, String>> actual = processor.handleEntity(validNode) | ||
|
||
then: | ||
actual.isPresent() | ||
actual.get() == expected | ||
} | ||
|
||
def "The GraphicInputProcessor should de-serialize a provided LineGraphicInput correctly"(){ | ||
given: | ||
GraphicInputProcessor processor = new GraphicInputProcessor(LineGraphicInput.class) | ||
LineGraphicInput validNode = GridTestData.lineGraphicCtoD | ||
Map expected = [ | ||
"uuid" : "ece86139-3238-4a35-9361-457ecb4258b0", | ||
"graphicLayer" : "main", | ||
"path" : "{\"type\":\"LineString\",\"coordinates\":[[0.0,0.0],[0.0,10]],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", | ||
"line" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7" | ||
] | ||
|
||
when: | ||
Optional<LinkedHashMap<String, String>> actual = processor.handleEntity(validNode) | ||
|
||
then: | ||
actual.isPresent() | ||
actual.get() == expected | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.