Skip to content

Commit 47046c8

Browse files
Merge branch 'dev' into ms/#642-find-and-add-standard-asset-types
2 parents 18c5929 + 4e2509f commit 47046c8

23 files changed

+123
-140
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8686
### Changed
8787
- Writers used to write time series are closed right away
8888
- Changed class name in FlexOptionsResult.toString [#693](https://github.com/ie3-institute/PowerSystemDataModel/issues/693)
89+
- Deleted parameter decimalPlaces and changed naming of serialization method [#710](https://github.com/ie3-institute/PowerSystemDataModel/issues/710)
8990

9091
## [2.0.1] - 2021-07-08
9192

docs/readthedocs/io/csvfiles.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ However, note that this hierarchy is only meant to be used in conjunction with i
194194
The class :code:`DefaultInputHierarchy` offers some helpful methods to validate and create a default input file
195195
hierarchy.
196196

197-
De-Serialization (loading models)
197+
De-serialization (loading models)
198198
=================================
199199
Having an instance of :ref:`Grid Container<grid_container_model>` is most of the time the target whenever you load your
200200
grid. It consists of the three main blocks:

docs/uml/main/input/CharacteristicDatamodelConcept.puml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ package models {
3333
+ {static} REQUIRED_FORMAT: String
3434
- x: ComparableQuantity<A>
3535
- y: ComparableQuantity<O>
36-
+ deSerialize(int): String
36+
+ serialize(): String
3737
- {static} buildExceptionMessage(String): String
3838
- {static} buildExceptionMessage(String, String): String
3939
}
@@ -43,7 +43,7 @@ package models {
4343
# characteristicPrefix: String
4444
# decimalPlaces: int
4545
# points: SortedSet<CharacteristicPoint<A,O>>
46-
+ deSerialize(): String
46+
+ serialize(): String
4747
+ {static} buildStartingRegex(String): String
4848
- extractCoordinateList(String): String
4949
- buildCoordinatesFromString(String, Unit<A>, Unit<O>): SortedSet<CharacteristicPoint<A, O>>

src/main/java/edu/ie3/datamodel/io/connectors/CsvFileConnector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ CsvFileDefinition buildFileDefinition(T timeSeries, String[] headLineElements, S
333333
/**
334334
* Builds a new file definition consisting of file name and head line elements
335335
*
336-
* @param clz Class that is meant to be de-serialized into this file
336+
* @param clz Class that is meant to be serialized into this file
337337
* @param headLineElements Array of head line elements
338338
* @param csvSep Separator for csv columns
339339
* @return A suitable file definition

src/main/java/edu/ie3/datamodel/io/processor/EntityProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.slf4j.LoggerFactory;
1818

1919
/**
20-
* Internal API Interface for EntityProcessors. Main purpose is to 'de-serialize' models into a
20+
* Internal API Interface for EntityProcessors. Main purpose is to 'serialize' models into a
2121
* fieldName to value representation to allow for an easy processing into a database or file sink
2222
* e.g. .csv
2323
*
@@ -47,7 +47,7 @@ protected EntityProcessor(Class<? extends T> registeredClass) {
4747
/**
4848
* Standard call to handle an entity
4949
*
50-
* @param entity the entity that should be 'de-serialized' into a map of fieldName to fieldValue
50+
* @param entity the entity that should be 'serialized' into a map of fieldName to fieldValue
5151
* @return an optional Map with fieldName to fieldValue or an empty optional if an error occurred
5252
* during processing
5353
*/

src/main/java/edu/ie3/datamodel/io/processor/Processor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ protected String processMethodResult(Object methodReturnObject, Method method, S
279279
"QV",
280280
"ReactivePowerCharacteristic",
281281
"CharacteristicInput" -> resultStringBuilder.append(
282-
((CharacteristicInput<?, ?>) methodReturnObject).deSerialize());
282+
((CharacteristicInput<?, ?>) methodReturnObject).serialize());
283283
case "UUID[]" -> resultStringBuilder.append(processUUIDArray((UUID[]) methodReturnObject));
284284
case "ControlStrategy" -> resultStringBuilder.append(
285285
((ControlStrategy) methodReturnObject).getKey());

src/main/java/edu/ie3/datamodel/io/processor/result/ResultEntityProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import javax.measure.quantity.Power;
2424

2525
/**
26-
* 'De-serializer' for {@link ResultEntity}s into a fieldName to value representation to allow for
27-
* an easy processing into a database or file sink e.g. .csv It is important that the units used in
26+
* 'Serializer' for {@link ResultEntity}s into a fieldName to value representation to allow for an
27+
* easy processing into a database or file sink e.g. .csv It is important that the units used in
2828
* this class are equal to the units used {@link SystemParticipantResultFactory} to prevent invalid
2929
* interpretation of unit prefixes!
3030
*

src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public CsvFileSink(
9292
* ProcessorProvider} by calling {@link ProcessorProvider#ProcessorProvider()}
9393
*
9494
* @param baseFolderPath the base folder path where the files should be put into
95-
* @param processorProvider the processor provided that should be used for entity de-serialization
95+
* @param processorProvider the processor provided that should be used for entity serialization
9696
* @param fileNamingStrategy the data sink file naming strategy that should be used
9797
* @param initFiles true if the files should be created during initialization (might create files,
9898
* that only consist of a headline, because no data will be written into them), false

src/main/java/edu/ie3/datamodel/models/input/system/characteristic/CharacteristicInput.java

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
public abstract class CharacteristicInput<A extends Quantity<A>, O extends Quantity<O>>
2222
implements Serializable {
2323
protected final String characteristicPrefix;
24-
protected final int decimalPlaces;
2524

2625
private final SortedSet<CharacteristicPoint<A, O>> points;
2726

@@ -30,24 +29,17 @@ public abstract class CharacteristicInput<A extends Quantity<A>, O extends Quant
3029
*
3130
* @param points Set of points that describe the characteristic
3231
* @param characteristicPrefix Prefix, that prepends the actual characteristic
33-
* @param decimalPlaces Desired amount of decimal places when de-serializing the characteristic
3432
*/
3533
protected CharacteristicInput(
36-
SortedSet<CharacteristicPoint<A, O>> points, String characteristicPrefix, int decimalPlaces) {
34+
SortedSet<CharacteristicPoint<A, O>> points, String characteristicPrefix) {
3735
this.points = Collections.unmodifiableSortedSet(points);
3836
this.characteristicPrefix = characteristicPrefix;
39-
this.decimalPlaces = decimalPlaces;
4037
}
4138

4239
protected CharacteristicInput(
43-
String input,
44-
Unit<A> abscissaUnit,
45-
Unit<O> ordinateUnit,
46-
String characteristicPrefix,
47-
int decimalPlaces)
40+
String input, Unit<A> abscissaUnit, Unit<O> ordinateUnit, String characteristicPrefix)
4841
throws ParsingException {
4942
this.characteristicPrefix = characteristicPrefix;
50-
this.decimalPlaces = decimalPlaces;
5143

5244
if (!input.startsWith(characteristicPrefix + ":{") || !input.endsWith("}"))
5345
throw new ParsingException(
@@ -114,31 +106,28 @@ public SortedSet<CharacteristicPoint<A, O>> getPoints() {
114106
}
115107

116108
/**
117-
* De-serialize the characteristic to a commonly understood string
109+
* Serialize the characteristic to a commonly understood string
118110
*
119-
* @return the characteristic as de-serialized string
111+
* @return the characteristic as serialized string
120112
*/
121-
public String deSerialize() {
113+
public String serialize() {
122114
return characteristicPrefix
123115
+ ":{"
124-
+ points.stream()
125-
.map(point -> point.deSerialize(decimalPlaces))
126-
.collect(Collectors.joining(","))
116+
+ points.stream().map(CharacteristicPoint::serialize).collect(Collectors.joining(","))
127117
+ "}";
128118
}
129119

130120
@Override
131121
public boolean equals(Object o) {
132122
if (this == o) return true;
133123
if (!(o instanceof CharacteristicInput<?, ?> that)) return false;
134-
return decimalPlaces == that.decimalPlaces
135-
&& characteristicPrefix.equals(that.characteristicPrefix)
136-
&& points.equals(that.points);
124+
125+
return characteristicPrefix.equals(that.characteristicPrefix) && points.equals(that.points);
137126
}
138127

139128
@Override
140129
public int hashCode() {
141-
return Objects.hash(characteristicPrefix, decimalPlaces, points);
130+
return Objects.hash(characteristicPrefix, points);
142131
}
143132

144133
@Override

src/main/java/edu/ie3/datamodel/models/input/system/characteristic/CharacteristicPoint.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,13 @@ public ComparableQuantity<O> getY() {
9696
}
9797

9898
/**
99-
* De-serializes the given point to a string
99+
* Serializes the given point to a string
100100
*
101-
* @param decimalPlaces Desired amount of decimal places
102-
* @return The de-serialized point
101+
* @return The serialized point
103102
*/
104-
public String deSerialize(int decimalPlaces) {
105-
String formattingString = String.format("(%%.%sf,%%.%sf)", decimalPlaces, decimalPlaces);
103+
public String serialize() {
106104
return String.format(
107-
Locale.ENGLISH, formattingString, x.getValue().doubleValue(), y.getValue().doubleValue());
105+
Locale.ENGLISH, "(%s,%s)", x.getValue().doubleValue(), y.getValue().doubleValue());
108106
}
109107

110108
@Override

0 commit comments

Comments
 (0)