Skip to content
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

Update powsyblcore dependency to 6.1.0 #363

Merged
merged 28 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6a36137
Adaptat
rolnico Nov 27, 2023
0b58a19
correct tests + swap switchAttributes with switchImpl, double edges f…
rolnico Nov 27, 2023
e6e1186
Add notification to listeners + delete unused dependency + fix tests …
rolnico Nov 29, 2023
1a06637
added javadoc
rolnico Nov 30, 2023
2cf7713
added javadoc
rolnico Nov 30, 2023
58e2063
fix
rolnico Nov 30, 2023
dee1cfc
delete unused method
rolnico Nov 30, 2023
0608922
fix imports
rolnico Nov 30, 2023
1cfe1d1
replaced BranchStatus with OperatingStatus + delete duplicated depend…
rolnico Dec 6, 2023
0916e73
replaced switch by java17 enhanced switch
rolnico Nov 29, 2023
8c501f4
bump to powsybl-core 6.1.1 and powsybl-dependencies 2023.4.0 + add mi…
rolnico Nov 29, 2023
84d91b1
Merge branch 'main' into nro/update_powsyblcore_to_6.1
rolnico Jan 9, 2024
268afcd
deleted redundant import of powsybl-core + fixed description for cons…
rolnico Jan 10, 2024
6b9e1f1
typo
rolnico Jan 10, 2024
10d487a
extracted method isSwitchOperableAndPresent to avoid duplication
rolnico Jan 10, 2024
9b697a9
change variable name from limitType to type for consistency
rolnico Jan 10, 2024
254328a
error message changed for consistency
rolnico Jan 10, 2024
c5f66ef
removed unused import
rolnico Jan 10, 2024
9ca08c2
removed unused import
rolnico Jan 10, 2024
896f709
initialise reportercontext
rolnico Jan 11, 2024
0625c8f
changed createObjectMapper
rolnico Jan 24, 2024
bcb9a61
update powsybl-dependency to 2023.4.1
rolnico Jan 24, 2024
f615e46
changed description
rolnico Jan 24, 2024
3357658
Extends Idenfiable instead of Connectable
rolnico Jan 24, 2024
1c848c3
added JavaTimeModule back to objectMapper
rolnico Jan 24, 2024
6b015b6
Apply suggestions from code review
rolnico Jan 24, 2024
a481862
corrections
rolnico Jan 24, 2024
9d9bc99
corrections continued
rolnico Jan 24, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@
*/
package com.powsybl.network.store.client;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.joda.JodaModule;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.google.common.base.Stopwatch;
import com.powsybl.commons.json.JsonUtil;
import com.powsybl.network.store.client.util.ExecutorUtil;
import com.powsybl.network.store.iidm.impl.AbstractForwardingNetworkStoreClient;
import com.powsybl.network.store.model.AttributeFilter;
import com.powsybl.network.store.iidm.impl.NetworkCollectionIndex;
import com.powsybl.network.store.model.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -562,8 +566,10 @@ private static <T extends IdentifiableAttributes> void cloneBuffer(NetworkCollec
public void cloneNetwork(UUID networkUuid, int sourceVariantNum, int targetVariantNum, String targetVariantId) {
delegate.cloneNetwork(networkUuid, sourceVariantNum, targetVariantNum, targetVariantId);

var objectMapper = JsonUtil.createObjectMapper();
objectMapper.registerModule(new JodaModule());
var objectMapper = JsonUtil.createObjectMapper()
.registerModule(new JavaTimeModule())
.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false);

//can't use allBuffers because of generics compile error...
cloneBuffer(switchResourcesToFlush, networkUuid, sourceVariantNum, targetVariantNum, objectMapper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,12 @@ private static NetworkStoreClient createStoreClient(RestClient restClient, Prelo
Objects.requireNonNull(preloadingStrategy);
LOGGER.info("Preloading strategy: {}", preloadingStrategy);
var cachedClient = new CachedNetworkStoreClient(new BufferedNetworkStoreClient(new RestNetworkStoreClient(restClient), executorService));
switch (preloadingStrategy) {
case NONE:
return cachedClient;
case COLLECTION:
return new PreloadingNetworkStoreClient(cachedClient, false, executorService);
case ALL_COLLECTIONS_NEEDED_FOR_BUS_VIEW:
return new PreloadingNetworkStoreClient(cachedClient, true, executorService);
default:
throw new IllegalStateException("Unknown preloading strategy: " + preloadingStrategy);
}
return switch (preloadingStrategy) {
case NONE -> cachedClient;
case COLLECTION -> new PreloadingNetworkStoreClient(cachedClient, false, executorService);
case ALL_COLLECTIONS_NEEDED_FOR_BUS_VIEW ->
new PreloadingNetworkStoreClient(cachedClient, true, executorService);
};
}

public NetworkFactory getNetworkFactory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,62 +65,27 @@ public PreloadingNetworkStoreClient(CachedNetworkStoreClient delegate, boolean a

private void loadToCache(ResourceType resourceType, UUID networkUuid, int variantNum) {
switch (resourceType) {
case SUBSTATION:
delegate.getSubstations(networkUuid, variantNum);
break;
case VOLTAGE_LEVEL:
delegate.getVoltageLevels(networkUuid, variantNum);
break;
case LOAD:
delegate.getLoads(networkUuid, variantNum);
break;
case GENERATOR:
delegate.getGenerators(networkUuid, variantNum);
break;
case BATTERY:
delegate.getBatteries(networkUuid, variantNum);
break;
case SHUNT_COMPENSATOR:
delegate.getShuntCompensators(networkUuid, variantNum);
break;
case VSC_CONVERTER_STATION:
delegate.getVscConverterStations(networkUuid, variantNum);
break;
case LCC_CONVERTER_STATION:
delegate.getLccConverterStations(networkUuid, variantNum);
break;
case STATIC_VAR_COMPENSATOR:
delegate.getStaticVarCompensators(networkUuid, variantNum);
break;
case BUSBAR_SECTION:
delegate.getBusbarSections(networkUuid, variantNum);
break;
case SWITCH:
delegate.getSwitches(networkUuid, variantNum);
break;
case TWO_WINDINGS_TRANSFORMER:
delegate.getTwoWindingsTransformers(networkUuid, variantNum);
break;
case THREE_WINDINGS_TRANSFORMER:
delegate.getThreeWindingsTransformers(networkUuid, variantNum);
break;
case LINE:
delegate.getLines(networkUuid, variantNum);
break;
case HVDC_LINE:
delegate.getHvdcLines(networkUuid, variantNum);
break;
case DANGLING_LINE:
delegate.getDanglingLines(networkUuid, variantNum);
break;
case CONFIGURED_BUS:
delegate.getConfiguredBuses(networkUuid, variantNum);
break;
case TIE_LINE:
delegate.getTieLines(networkUuid, variantNum);
break;
default:
break;
case SUBSTATION -> delegate.getSubstations(networkUuid, variantNum);
case VOLTAGE_LEVEL -> delegate.getVoltageLevels(networkUuid, variantNum);
case LOAD -> delegate.getLoads(networkUuid, variantNum);
case GENERATOR -> delegate.getGenerators(networkUuid, variantNum);
case BATTERY -> delegate.getBatteries(networkUuid, variantNum);
case SHUNT_COMPENSATOR -> delegate.getShuntCompensators(networkUuid, variantNum);
case VSC_CONVERTER_STATION -> delegate.getVscConverterStations(networkUuid, variantNum);
case LCC_CONVERTER_STATION -> delegate.getLccConverterStations(networkUuid, variantNum);
case STATIC_VAR_COMPENSATOR -> delegate.getStaticVarCompensators(networkUuid, variantNum);
case BUSBAR_SECTION -> delegate.getBusbarSections(networkUuid, variantNum);
case SWITCH -> delegate.getSwitches(networkUuid, variantNum);
case TWO_WINDINGS_TRANSFORMER -> delegate.getTwoWindingsTransformers(networkUuid, variantNum);
case THREE_WINDINGS_TRANSFORMER -> delegate.getThreeWindingsTransformers(networkUuid, variantNum);
case LINE -> delegate.getLines(networkUuid, variantNum);
case HVDC_LINE -> delegate.getHvdcLines(networkUuid, variantNum);
case DANGLING_LINE -> delegate.getDanglingLines(networkUuid, variantNum);
case CONFIGURED_BUS -> delegate.getConfiguredBuses(networkUuid, variantNum);
case TIE_LINE -> delegate.getTieLines(networkUuid, variantNum);
default -> {
// Do nothing
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
*/
package com.powsybl.network.store.client;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.joda.JodaModule;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.powsybl.commons.PowsyblException;
import com.powsybl.network.store.model.*;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -46,7 +48,9 @@ public static RestTemplateBuilder createRestTemplateBuilder(String baseUri) {

private static ObjectMapper createObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JodaModule());
objectMapper.registerModule(new JavaTimeModule())
.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false);
return objectMapper;
}

Expand Down
Loading
Loading