-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Change CSE GLSK import from DOM parsing to Jaxb unmarshalling Signed-off-by: Vincent BOCHET <vincent.bochet@rte-france.com> * Implement CSE GLSK import for export corner Signed-off-by: Vincent BOCHET <vincent.bochet@rte-france.com> * Variable naming and code improvement Signed-off-by: Vincent BOCHET <vincent.bochet@rte-france.com> * Update XSD for GLSK files to match functional specifications Signed-off-by: Vincent BOCHET <vincent.bochet@rte-france.com> * Fix inversion between timeseries and timeseriesexport for inarea and outarea countries Signed-off-by: Vincent BOCHET <vincent.bochet@rte-france.com> * Add tests for block and node wrappers & for merged GLSK files import Signed-off-by: Vincent BOCHET <vincent.bochet@rte-france.com> * Fix gsk-document.xsd import for schema validation Signed-off-by: Vincent BOCHET <vincent.bochet@rte-france.com> * Adapt GlskDocumentImporter for CSE Import EC and CSE Valid EC Signed-off-by: Vincent BOCHET <vincent.bochet@rte-france.com> * Rename some variables Signed-off-by: Vincent BOCHET <vincent.bochet@rte-france.com> --------- Signed-off-by: Vincent BOCHET <vincent.bochet@rte-france.com>
- Loading branch information
1 parent
4e2ad61
commit e73f815
Showing
21 changed files
with
12,459 additions
and
242 deletions.
There are no files selected for viewing
This file contains 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
67 changes: 67 additions & 0 deletions
67
glsk/glsk-document-cse/src/main/java/com/powsybl/glsk/cse/BlockWrapper.java
This file contains 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,67 @@ | ||
/* | ||
* Copyright (c) 2023, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package com.powsybl.glsk.cse; | ||
|
||
import xsd.etso_core_cmpts.QuantityType; | ||
|
||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* @author Vincent BOCHET {@literal <vincent.bochet at rte-france.com>} | ||
*/ | ||
public final class BlockWrapper { | ||
private final Object block; | ||
|
||
public BlockWrapper(Object block) { | ||
this.block = block; | ||
} | ||
|
||
public Object getBlock() { | ||
return block; | ||
} | ||
|
||
public Optional<BigInteger> getOrder() { | ||
try { | ||
BigInteger order = (BigInteger) block.getClass().getDeclaredField("order").get(block); | ||
return Optional.ofNullable(order); | ||
} catch (NoSuchFieldException | IllegalAccessException e) { | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
public Optional<BigDecimal> getMaximumShift() { | ||
try { | ||
QuantityType maximumShift = (QuantityType) block.getClass().getDeclaredField("maximumShift").get(block); | ||
return Optional.ofNullable(maximumShift).map(QuantityType::getV); | ||
} catch (NoSuchFieldException | IllegalAccessException e) { | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
public Optional<BigDecimal> getFactor() { | ||
try { | ||
QuantityType factor = (QuantityType) block.getClass().getDeclaredField("factor").get(block); | ||
return Optional.ofNullable(factor).map(QuantityType::getV); | ||
} catch (NoSuchFieldException | IllegalAccessException e) { | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
public Optional<List<NodeWrapper>> getNodeList() { | ||
try { | ||
List<Object> objectList = (List<Object>) block.getClass().getDeclaredField("node").get(block); | ||
return Optional.ofNullable(objectList) | ||
.map(list -> list.stream().map(NodeWrapper::new).collect(Collectors.toList())); | ||
} catch (NoSuchFieldException | IllegalAccessException e) { | ||
return Optional.empty(); | ||
} | ||
} | ||
} |
This file contains 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 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
Oops, something went wrong.