-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor line and transformer filter entities to avoid code duplicati…
…on (#77) * Refactor line and transformer filter entities In order to be able to organize files by filter type. Signed-off-by: BOUHOURS Antoine <[email protected]>
- Loading branch information
1 parent
a80cb59
commit 52629db
Showing
7 changed files
with
197 additions
and
154 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
src/main/java/org/gridsuite/filter/server/dto/AbstractLineFilter.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,74 @@ | ||
/** | ||
* 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 org.gridsuite.filter.server.dto; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import lombok.experimental.SuperBuilder; | ||
import org.springframework.util.CollectionUtils; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.SortedSet; | ||
|
||
/** | ||
* @author Antoine Bouhours <antoine.bouhours at rte-france.com> | ||
*/ | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@SuperBuilder | ||
@ToString(callSuper = true) | ||
@Schema(description = "Line Filters", allOf = CriteriaFilter.class) | ||
public abstract class AbstractLineFilter extends AbstractEquipmentFilterForm { | ||
|
||
@Schema(description = "SubstationName1") | ||
String substationName1; | ||
|
||
@Schema(description = "SubstationName2") | ||
String substationName2; | ||
|
||
@Schema(description = "Countries1") | ||
private SortedSet<String> countries1; | ||
|
||
@Schema(description = "Countries2") | ||
private SortedSet<String> countries2; | ||
|
||
@Schema(description = "Free properties 1") | ||
// LinkedHashMap to keep order too | ||
@JsonDeserialize(as = LinkedHashMap.class) | ||
private Map<String, List<String>> freeProperties1; | ||
|
||
@Schema(description = "Free properties 2") | ||
// LinkedHashMap to keep order too | ||
@JsonDeserialize(as = LinkedHashMap.class) | ||
private Map<String, List<String>> freeProperties2; | ||
|
||
AbstractLineFilter(String equipmentID, String equipmentName, String substationName1, String substationName2, SortedSet<String> countries1, SortedSet<String> countries2) { | ||
super(equipmentID, equipmentName); | ||
this.substationName1 = substationName1; | ||
this.substationName2 = substationName2; | ||
this.countries1 = countries1; | ||
this.countries2 = countries2; | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return super.isEmpty() | ||
&& substationName1 == null | ||
&& substationName2 == null | ||
&& CollectionUtils.isEmpty(countries1) | ||
&& CollectionUtils.isEmpty(countries2) | ||
&& CollectionUtils.isEmpty(freeProperties1) | ||
&& CollectionUtils.isEmpty(freeProperties2); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/org/gridsuite/filter/server/dto/AbstractTransformerFilter.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,59 @@ | ||
/** | ||
* 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 org.gridsuite.filter.server.dto; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import lombok.experimental.SuperBuilder; | ||
import org.springframework.util.CollectionUtils; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.SortedSet; | ||
|
||
/** | ||
* @author Antoine Bouhours <antoine.bouhours at rte-france.com> | ||
*/ | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@SuperBuilder | ||
@ToString(callSuper = true) | ||
@Schema(description = "Transformer Filters", allOf = CriteriaFilter.class) | ||
public abstract class AbstractTransformerFilter extends AbstractEquipmentFilterForm { | ||
|
||
@Schema(description = "SubstationName") | ||
private String substationName; | ||
|
||
@Schema(description = "Countries") | ||
private SortedSet<String> countries; | ||
|
||
@Schema(description = "Free properties") | ||
// LinkedHashMap to keep order too | ||
@JsonDeserialize(as = LinkedHashMap.class) | ||
private Map<String, List<String>> freeProperties; | ||
|
||
AbstractTransformerFilter(String equipmentID, String equipmentName, String substationName, SortedSet<String> countries, Map<String, List<String>> freeProperties) { | ||
super(equipmentID, equipmentName); | ||
this.substationName = substationName; | ||
this.countries = countries; | ||
this.freeProperties = freeProperties; | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return super.isEmpty() | ||
&& substationName == null | ||
&& CollectionUtils.isEmpty(countries) | ||
&& CollectionUtils.isEmpty(freeProperties); | ||
} | ||
} |
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
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.