Skip to content

Commit 08ffcc4

Browse files
committed
Cleaned up where condition for level retrieval
1 parent 3539144 commit 08ffcc4

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDaoImpl.java

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -165,29 +165,21 @@ public LocationLevels getLocationLevels(String cursor, int pageSize,
165165
}
166166

167167
Condition whereCondition = ref.LOCATION_LEVEL_ID.isNotNull();
168-
Condition standardWhereCondition = ref.LOCATION_LEVEL_ID.isNotNull();
169168

170169
if (office != null && !office.isEmpty()) {
171170
whereCondition = whereCondition.and(ref.OFFICE_ID.eq(office.toUpperCase()));
172-
standardWhereCondition = standardWhereCondition.and(DSL.upper(ref.OFFICE_ID).eq(office.toUpperCase()));
173171
}
174172

175173
if (levelIdMask != null && !levelIdMask.isEmpty()) {
176174
whereCondition = whereCondition.and(
177175
JooqDao.caseInsensitiveLikeRegex(ref.LOCATION_LEVEL_ID, levelIdMask));
178-
standardWhereCondition = standardWhereCondition.and(
179-
JooqDao.caseInsensitiveLikeRegex(ref.LOCATION_LEVEL_ID, levelIdMask));
180176
}
181177

182178
if (beginZdt != null) {
183179
whereCondition = whereCondition.and(ref.LOCATION_LEVEL_DATE.greaterOrEqual(Timestamp.from(beginZdt.toInstant())));
184-
standardWhereCondition = standardWhereCondition.and(
185-
ref.LOCATION_LEVEL_DATE.greaterOrEqual(Timestamp.from(beginZdt.toInstant())));
186180
}
187181
if (endZdt != null) {
188182
whereCondition = whereCondition.and(ref.LOCATION_LEVEL_DATE.lessThan(Timestamp.from(endZdt.toInstant())));
189-
standardWhereCondition = standardWhereCondition.and(
190-
ref.LOCATION_LEVEL_DATE.lessThan(Timestamp.from(endZdt.toInstant())));
191183
}
192184

193185
Map<LevelLookup, LocationLevel.Builder> builderMap = new LinkedHashMap<>();
@@ -228,7 +220,7 @@ public LocationLevels getLocationLevels(String cursor, int pageSize,
228220
.from(ref)
229221
.fullOuterJoin(values)
230222
.on(ref.LOCATION_LEVEL_CODE.eq(values.LOCATION_LEVEL_CODE.cast(Long.class)))
231-
.where(standardWhereCondition)
223+
.where(whereCondition)
232224
);
233225
}
234226

@@ -394,19 +386,18 @@ private void storeNormalLocationLevel(LocationLevel locationLevel) {
394386
}
395387

396388
private void storeVirtualLocationLevel(VirtualLocationLevel locationLevel) {
397-
VirtualLocationLevel virtualLocationLevel = locationLevel;
398389
Timestamp date = Timestamp.from(locationLevel.getLevelDate().toInstant());
399-
Timestamp expirationDate = Timestamp.from(virtualLocationLevel.getExpirationDate().toInstant());
390+
Timestamp expirationDate = Timestamp.from(locationLevel.getExpirationDate().toInstant());
400391
STR_TAB_TAB_T constituentTab = new STR_TAB_TAB_T();
401-
for (VirtualLocationLevel.RatingConstituent constituent : virtualLocationLevel.getConstituents()) {
392+
for (VirtualLocationLevel.RatingConstituent constituent : locationLevel.getConstituents()) {
402393
constituentTab.add(new STR_TAB_T(constituent.getConstituentList()));
403394
}
404395
connection(dsl, c -> {
405396
String officeId = locationLevel.getOfficeId();
406397
setOffice(c, officeId);
407398
CWMS_LEVEL_PACKAGE.call_STORE_VIRTUAL_LOCATION_LEVEL(DSL.using(c).configuration(),
408399
locationLevel.getLocationLevelId(), constituentTab,
409-
virtualLocationLevel.getConstituentConnections(),
400+
locationLevel.getConstituentConnections(),
410401
locationLevel.getLevelComment(), locationLevel.getAttributeDurationId(),
411402
locationLevel.getAttributeValue(), locationLevel.getAttributeUnitsId(),
412403
locationLevel.getAttributeComment(), date, expirationDate,
@@ -445,9 +436,9 @@ public static SeasonalValueBean buildSeasonalValue(SEASONAL_VALUE_T fromBean) {
445436
@NotNull
446437
private List<SeasonalValueBean> buildSeasonalValues(LOCATION_LEVEL_T level) {
447438
List<SeasonalValueBean> seasonalValues = Collections.emptyList();
448-
SEASONAL_VALUE_TAB_T values = level.getSEASONAL_VALUES();
449-
if (values != null) {
450-
seasonalValues = values.stream()
439+
SEASONAL_VALUE_TAB_T seasonalValueTabT = level.getSEASONAL_VALUES();
440+
if (seasonalValueTabT != null) {
441+
seasonalValues = seasonalValueTabT.stream()
451442
.filter(Objects::nonNull)
452443
.map(LocationLevelsDaoImpl::buildSeasonalValue)
453444
.collect(toList());
@@ -676,13 +667,13 @@ private void parseLevels(Record r, Map<LevelLookup, LocationLevel.Builder> build
676667
if (unit.equalsIgnoreCase(UnitSystem.EN.value())) {
677668
attrUnit = r.get(values.ATTRIBUTE_UNIT_EN);
678669
if (attrUnit != null) {
679-
oattrVal = r.get(values.ATTRIBUTE_VALUE_EN).doubleValue();
670+
oattrVal = r.get(values.ATTRIBUTE_VALUE_EN);
680671
}
681672

682673
} else {
683674
attrUnit = r.get(values.ATTRIBUTE_UNIT_SI);
684675
if (attrUnit != null) {
685-
oattrVal = r.get(values.ATTRIBUTE_VALUE_SI).doubleValue();
676+
oattrVal = r.get(values.ATTRIBUTE_VALUE_SI);
686677
}
687678
}
688679
}

0 commit comments

Comments
 (0)