-
Notifications
You must be signed in to change notification settings - Fork 0
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
NTCAnnual values as backup when periods are missing from NTCRed file #217
Changes from 1 commit
b2ca862
81cf200
71911b4
c70c686
1a0cbc9
f2ba9b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,7 @@ | |
import com.farao_community.farao.cse.data.xsd.*; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.*; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Collectors; | ||
|
||
|
@@ -27,7 +24,7 @@ public DailyNtcDocument(OffsetDateTime targetDateTime, NTCReductionsDocument ntc | |
this.ntcReductionsDocument = ntcReductionsDocument; | ||
} | ||
|
||
Map<String, LineInformation> getLineInformationPerLineId(Predicate<TLine> lineSelector) { | ||
Map<String, Optional<LineInformation>> getLineInformationPerLineId(Predicate<TLine> lineSelector) { | ||
List<TSpecialLines> tSpecialLines = ntcReductionsDocument.getSpecialLines(); | ||
if (tSpecialLines.isEmpty()) { | ||
return Collections.emptyMap(); | ||
|
@@ -38,8 +35,12 @@ Map<String, LineInformation> getLineInformationPerLineId(Predicate<TLine> lineSe | |
.collect(Collectors.toMap( | ||
TLine::getCode, | ||
tLine -> { | ||
TNTC tNtc = NtcUtil.getTNtcFromLine(targetDateTime, tLine); | ||
return new LineInformation(tLine.getCNtc().value(), tNtc.getType(), tNtc.getV().doubleValue()); | ||
Optional<TNTC> optionalTntc = NtcUtil.getTNtcFromLineFromNtcRedFile(targetDateTime, tLine); | ||
if (optionalTntc.isPresent()) { | ||
return Optional.of(new LineInformation(tLine.getCNtc().value(), optionalTntc.get().getType(), optionalTntc.get().getV().doubleValue())); | ||
} else { | ||
return Optional.empty(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it necessary to put all line-codes in the Map, even if they are not associated with any data? |
||
} | ||
} | ||
)); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,7 @@ | |
import com.farao_community.farao.cse.data.xsd.ntc_adapted.*; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.*; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Collectors; | ||
|
||
|
@@ -27,7 +24,7 @@ public DailyNtcDocumentAdapted(OffsetDateTime targetDateTime, NTCReductionsDocum | |
this.ntcReductionsDocument = ntcReductionsDocument; | ||
} | ||
|
||
Map<String, LineInformation> getLineInformationPerLineId(Predicate<TLine> lineSelector) { | ||
Map<String, Optional<LineInformation>> getLineInformationPerLineId(Predicate<TLine> lineSelector) { | ||
TSpecialLines tSpecialLines = ntcReductionsDocument.getSpecialLinesImport(); | ||
if (tSpecialLines == null || tSpecialLines.getLine() == null || tSpecialLines.getLine().isEmpty()) { | ||
return Collections.emptyMap(); | ||
|
@@ -37,8 +34,12 @@ Map<String, LineInformation> getLineInformationPerLineId(Predicate<TLine> lineSe | |
.collect(Collectors.toMap( | ||
TLine::getCode, | ||
tLine -> { | ||
TNTC tNtc = NtcUtilAdapted.getTNtcFromLine(targetDateTime, tLine); | ||
return new LineInformation(tLine.getCNtc().value(), tNtc.getType(), tNtc.getV().doubleValue()); | ||
Optional<TNTC> optionalTntc = NtcUtilAdapted.getTNtcFromLineFromNtcRedFile(targetDateTime, tLine); | ||
if (optionalTntc.isPresent()) { | ||
return Optional.of(new LineInformation(tLine.getCNtc().value(), optionalTntc.get().getType(), optionalTntc.get().getV().doubleValue())); | ||
} else { | ||
return Optional.empty(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as DailyNtcDocument: https://github.com/farao-community/gridcapa-cse/pull/217/files#r1933765489 |
||
} | ||
kahyami marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
)); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider simplifying the design by avoiding Optional wrapping.
As previously suggested by @vbochetRTE, wrapping every value in Optional might be overcomplicating the design. Instead, consider only including lines that have actual data in the map.
Here's a simpler approach:
Benefits of this approach:
Also applies to: 42-47