Skip to content

Commit

Permalink
results: add locationId to entity and dto (#150)
Browse files Browse the repository at this point in the history
* add locationId to entity


---------

Signed-off-by: jamal-khey <myjamal89@gmail.com>
jamal-khey authored Jan 3, 2025
1 parent cf9e837 commit c733838
Showing 8 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -25,6 +25,8 @@
public class LimitViolationInfos {
private String subjectId;

private String locationId;

private Double limit;

private String limitName;
@@ -44,6 +46,7 @@ public class LimitViolationInfos {
public static LimitViolationInfos toLimitViolationInfos(LimitViolationEntity limitViolationEntity) {
return LimitViolationInfos.builder()
.subjectId(limitViolationEntity.getSubjectId())
.locationId(limitViolationEntity.getLocationId())
.limit(limitViolationEntity.getLimit())
.limitName(limitViolationEntity.getLimitName())
.actualOverloadDuration(limitViolationEntity.getActualOverload())
Original file line number Diff line number Diff line change
@@ -40,6 +40,9 @@ public class LimitViolationEntity {
@Column
private String subjectId;

@Column
private String locationId;

@Column(name = "limit_")
private Double limit;

Original file line number Diff line number Diff line change
@@ -94,6 +94,7 @@ private static LimitViolationEntity toLimitViolationsEntity(UUID resultUuid, Lim
return LimitViolationEntity.builder()
.loadFlowResult(LoadFlowResultEntity.builder().resultUuid(resultUuid).build())
.subjectId(limitViolationInfos.getSubjectId())
.locationId(limitViolationInfos.getLocationId())
.limitType(limitViolationInfos.getLimitType())
.limit(limitViolationInfos.getLimit())
.limitName(limitViolationInfos.getLimitName())
Original file line number Diff line number Diff line change
@@ -178,7 +178,6 @@ public List<LimitViolationInfos> getLimitViolationsInfos(UUID resultUuid, String
// get resource filters and global filters
List<ResourceFilter> resourceFilters = FilterUtils.fromStringFiltersToDTO(stringFilters, objectMapper);
GlobalFilter globalFilter = FilterUtils.fromStringGlobalFiltersToDTO(stringGlobalFilters, objectMapper);

if (globalFilter != null) {
List<ResourceFilter> resourceGlobalFilters = filterService.getResourceFilters(networkUuid, variantId, globalFilter);
if (!resourceGlobalFilters.isEmpty()) {
Original file line number Diff line number Diff line change
@@ -193,7 +193,8 @@ protected List<LimitViolationInfos> calculateOverloadLimitViolations(List<LimitV

public static LimitViolationInfos toLimitViolationInfos(LimitViolation violation, Network network) {
return LimitViolationInfos.builder()
.subjectId(getViolationLocationId(violation, network))
.subjectId(violation.getSubjectId())
.locationId(getViolationLocationId(violation, network))
.actualOverloadDuration(violation.getAcceptableDuration())
.upComingOverloadDuration(violation.getAcceptableDuration())
.limit(violation.getLimit())
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet author="jamalk (generated)" id="1734365506039-1">
<addColumn tableName="limit_violation">
<column name="location_id" type="varchar(255)"/>
</addColumn>
</changeSet>
</databaseChangeLog>
5 changes: 3 additions & 2 deletions src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
@@ -30,5 +30,6 @@ databaseChangeLog:
- include:
file: changesets/changelog_20241212T190828Z.xml
relativeToChangelogFile: true


- include:
file: changesets/changelog_20241216T161132Z.xml
relativeToChangelogFile: true
Original file line number Diff line number Diff line change
@@ -832,8 +832,8 @@ public void testGetLimitViolationsVoltage() throws Exception {
});
assertEquals(2, limitViolations.size());
// check that the subject id is equal to the Bus Id
assertEquals("VLHV1_0", limitViolations.get(0).getSubjectId());
assertEquals("VLHV2_0", limitViolations.get(1).getSubjectId());
assertEquals("VLHV1_0", limitViolations.get(0).getLocationId());
assertEquals("VLHV2_0", limitViolations.get(1).getLocationId());
}
}

0 comments on commit c733838

Please sign in to comment.