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

Identifiable batch delete #490

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -43,4 +43,5 @@ public interface RestClient {

void post(String url, Object... uriVariables);

void deleteAll(String url, List<String> ids, Object... uriVariables);
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,13 @@ public void delete(String url, Object... uriVariables) {
throw createHttpException(url, "delete", response.getStatusCode());
}
}

@Override
public void deleteAll(String url, List<String> body, Object... uriVariables) {
HttpEntity<List<String>> requestEntity = new HttpEntity<>(body);
ResponseEntity<Void> response = restTemplate.exchange(url, HttpMethod.DELETE, requestEntity, Void.class, uriVariables);
if (response.getStatusCode() != HttpStatus.OK) {
throw createHttpException(url, "delete", response.getStatusCode());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ private <T extends IdentifiableAttributes> void updateAll(String target, String
}

private void removeAll(String url, UUID networkUuid, int variantNum, List<String> ids) {
for (String id : ids) {
restClient.delete(url, networkUuid, variantNum, id);
}
restClient.deleteAll(url, ids, networkUuid, variantNum);
}

@Override
Expand Down Expand Up @@ -305,7 +303,7 @@ public void updateSubstations(UUID networkUuid, List<Resource<SubstationAttribut
}

public void removeSubstations(UUID networkUuid, int variantNum, List<String> substationsId) {
removeAll("/networks/{networkUuid}/{variantNum}/substations/{substationId}", networkUuid, variantNum, substationsId);
removeAll("/networks/{networkUuid}/{variantNum}/substations", networkUuid, variantNum, substationsId);
}

// voltage level
Expand Down Expand Up @@ -337,7 +335,7 @@ public void updateVoltageLevels(UUID networkUuid, List<Resource<VoltageLevelAttr

@Override
public void removeVoltageLevels(UUID networkUuid, int variantNum, List<String> voltageLevelsId) {
removeAll("/networks/{networkUuid}/{variantNum}/voltage-levels/{voltageLevelId}", networkUuid, variantNum, voltageLevelsId);
removeAll("/networks/{networkUuid}/{variantNum}/voltage-levels", networkUuid, variantNum, voltageLevelsId);
}

@Override
Expand All @@ -347,7 +345,7 @@ public List<Resource<BusbarSectionAttributes>> getVoltageLevelBusbarSections(UUI

@Override
public void removeBusBarSections(UUID networkUuid, int variantNum, List<String> busBarSectionsId) {
removeAll("/networks/{networkUuid}/{variantNum}/busbar-sections/{busBarSectionId}", networkUuid, variantNum, busBarSectionsId);
removeAll("/networks/{networkUuid}/{variantNum}/busbar-sections", networkUuid, variantNum, busBarSectionsId);
}

@Override
Expand All @@ -362,7 +360,7 @@ public List<Resource<GeneratorAttributes>> getVoltageLevelGenerators(UUID networ

@Override
public void removeGenerators(UUID networkUuid, int variantNum, List<String> generatorsId) {
removeAll("/networks/{networkUuid}/{variantNum}/generators/{generatorId}", networkUuid, variantNum, generatorsId);
removeAll("/networks/{networkUuid}/{variantNum}/generators", networkUuid, variantNum, generatorsId);
}

@Override
Expand All @@ -372,7 +370,7 @@ public List<Resource<BatteryAttributes>> getVoltageLevelBatteries(UUID networkUu

@Override
public void removeBatteries(UUID networkUuid, int variantNum, List<String> batteriesId) {
removeAll("/networks/{networkUuid}/{variantNum}/batteries/{batteryId}", networkUuid, variantNum, batteriesId);
removeAll("/networks/{networkUuid}/{variantNum}/batteries", networkUuid, variantNum, batteriesId);
}

@Override
Expand All @@ -387,7 +385,7 @@ public List<Resource<ShuntCompensatorAttributes>> getVoltageLevelShuntCompensato

@Override
public void removeShuntCompensators(UUID networkUuid, int variantNum, List<String> shuntCompensatorsId) {
removeAll("/networks/{networkUuid}/{variantNum}/shunt-compensators/{shuntCompensatorId}", networkUuid, variantNum, shuntCompensatorsId);
removeAll("/networks/{networkUuid}/{variantNum}/shunt-compensators", networkUuid, variantNum, shuntCompensatorsId);
}

@Override
Expand All @@ -397,7 +395,7 @@ public List<Resource<VscConverterStationAttributes>> getVoltageLevelVscConverter

@Override
public void removeVscConverterStations(UUID networkUuid, int variantNum, List<String> vscConverterStationsId) {
removeAll("/networks/{networkUuid}/{variantNum}/vsc-converter-stations/{vscConverterStationId}", networkUuid, variantNum, vscConverterStationsId);
removeAll("/networks/{networkUuid}/{variantNum}/vsc-converter-stations", networkUuid, variantNum, vscConverterStationsId);
}

@Override
Expand All @@ -407,7 +405,7 @@ public List<Resource<StaticVarCompensatorAttributes>> getVoltageLevelStaticVarCo

@Override
public void removeStaticVarCompensators(UUID networkUuid, int variantNum, List<String> staticVarCompensatorsId) {
removeAll("/networks/{networkUuid}/{variantNum}/static-var-compensators/{staticVarCompensatorId}", networkUuid, variantNum, staticVarCompensatorsId);
removeAll("/networks/{networkUuid}/{variantNum}/static-var-compensators", networkUuid, variantNum, staticVarCompensatorsId);
}

@Override
Expand All @@ -417,7 +415,7 @@ public List<Resource<LccConverterStationAttributes>> getVoltageLevelLccConverter

@Override
public void removeLccConverterStations(UUID networkUuid, int variantNum, List<String> lccConverterStationsId) {
removeAll("/networks/{networkUuid}/{variantNum}/lcc-converter-stations/{lccConverterStationId}", networkUuid, variantNum, lccConverterStationsId);
removeAll("/networks/{networkUuid}/{variantNum}/lcc-converter-stations", networkUuid, variantNum, lccConverterStationsId);
}

@Override
Expand All @@ -427,7 +425,7 @@ public List<Resource<TwoWindingsTransformerAttributes>> getVoltageLevelTwoWindin

@Override
public void removeTwoWindingsTransformers(UUID networkUuid, int variantNum, List<String> twoWindingsTransformersId) {
removeAll("/networks/{networkUuid}/{variantNum}/2-windings-transformers/{twoWindingsTransformerId}", networkUuid, variantNum, twoWindingsTransformersId);
removeAll("/networks/{networkUuid}/{variantNum}/2-windings-transformers", networkUuid, variantNum, twoWindingsTransformersId);
}

@Override
Expand All @@ -437,7 +435,7 @@ public List<Resource<ThreeWindingsTransformerAttributes>> getVoltageLevelThreeWi

@Override
public void removeThreeWindingsTransformers(UUID networkUuid, int variantNum, List<String> threeWindingsTransformersId) {
removeAll("/networks/{networkUuid}/{variantNum}/3-windings-transformers/{threeWindingsTransformerId}", networkUuid, variantNum, threeWindingsTransformersId);
removeAll("/networks/{networkUuid}/{variantNum}/3-windings-transformers", networkUuid, variantNum, threeWindingsTransformersId);
}

@Override
Expand All @@ -447,7 +445,7 @@ public List<Resource<LineAttributes>> getVoltageLevelLines(UUID networkUuid, int

@Override
public void removeLines(UUID networkUuid, int variantNum, List<String> linesId) {
removeAll("/networks/{networkUuid}/{variantNum}/lines/{lineId}", networkUuid, variantNum, linesId);
removeAll("/networks/{networkUuid}/{variantNum}/lines", networkUuid, variantNum, linesId);
}

@Override
Expand Down Expand Up @@ -479,7 +477,7 @@ public void updateSwitches(UUID networkUuid, List<Resource<SwitchAttributes>> sw

@Override
public void removeSwitches(UUID networkUuid, int variantNum, List<String> switchesId) {
removeAll("/networks/{networkUuid}/{variantNum}/switches/{switchId}", networkUuid, variantNum, switchesId);
removeAll("/networks/{networkUuid}/{variantNum}/switches", networkUuid, variantNum, switchesId);
}

// busbar section
Expand Down Expand Up @@ -528,7 +526,7 @@ public void updateLoads(UUID networkUuid, List<Resource<LoadAttributes>> loadRes

@Override
public void removeLoads(UUID networkUuid, int variantNum, List<String> loadsId) {
removeAll("/networks/{networkUuid}/{variantNum}/loads/{loadId}", networkUuid, variantNum, loadsId);
removeAll("/networks/{networkUuid}/{variantNum}/loads", networkUuid, variantNum, loadsId);
}

// generator
Expand Down Expand Up @@ -748,7 +746,7 @@ public Optional<Resource<HvdcLineAttributes>> getHvdcLine(UUID networkUuid, int

@Override
public void removeHvdcLines(UUID networkUuid, int variantNum, List<String> hvdcLinesId) {
removeAll("/networks/{networkUuid}/{variantNum}/hvdc-lines/{hvdcLineId}", networkUuid, variantNum, hvdcLinesId);
removeAll("/networks/{networkUuid}/{variantNum}/hvdc-lines", networkUuid, variantNum, hvdcLinesId);
}

@Override
Expand All @@ -775,7 +773,7 @@ public Optional<Resource<DanglingLineAttributes>> getDanglingLine(UUID networkUu

@Override
public void removeDanglingLines(UUID networkUuid, int variantNum, List<String> danglingLinesId) {
removeAll("/networks/{networkUuid}/{variantNum}/dangling-lines/{danglingLineId}", networkUuid, variantNum, danglingLinesId);
removeAll("/networks/{networkUuid}/{variantNum}/dangling-lines", networkUuid, variantNum, danglingLinesId);
}

@Override
Expand Down Expand Up @@ -812,7 +810,7 @@ public void updateConfiguredBuses(UUID networkUuid, List<Resource<ConfiguredBusA

@Override
public void removeConfiguredBuses(UUID networkUuid, int variantNum, List<String> busesId) {
removeAll("/networks/{networkUuid}/{variantNum}/configured-buses/{busId}", networkUuid, variantNum, busesId);
removeAll("/networks/{networkUuid}/{variantNum}/configured-buses", networkUuid, variantNum, busesId);
}

@Override
Expand All @@ -832,7 +830,7 @@ public Optional<Resource<TieLineAttributes>> getTieLine(UUID networkUuid, int va

@Override
public void removeTieLines(UUID networkUuid, int variantNum, List<String> tieLinesId) {
removeAll("/networks/{networkUuid}/{variantNum}/tie-lines/{tieLineId}", networkUuid, variantNum, tieLinesId);
removeAll("/networks/{networkUuid}/{variantNum}/tie-lines", networkUuid, variantNum, tieLinesId);
}

@Override
Expand Down Expand Up @@ -883,7 +881,7 @@ public Optional<Resource<GroundAttributes>> getGround(UUID networkUuid, int vari

@Override
public void removeGrounds(UUID networkUuid, int variantNum, List<String> groundsId) {
removeAll("/networks/{networkUuid}/{variantNum}/grounds/{groundId}", networkUuid, variantNum, groundsId);
removeAll("/networks/{networkUuid}/{variantNum}/grounds", networkUuid, variantNum, groundsId);
}

@Override
Expand Down
Loading