Search in sources :

Example 1 with SeasonalValueBean

use of cwms.radar.data.dto.SeasonalValueBean in project cwms-radar-api by USACE.

the class LocationLevelsDaoImpl method getSeasonalValues.

private List<usace.cwms.db.dao.ifc.level.SeasonalValueBean> getSeasonalValues(LocationLevel locationLevel) {
    List<usace.cwms.db.dao.ifc.level.SeasonalValueBean> seasonalValues = null;
    if (locationLevel.getSeasonalValues() != null) {
        seasonalValues = new ArrayList<>();
        for (SeasonalValueBean bean : locationLevel.getSeasonalValues()) {
            usace.cwms.db.dao.ifc.level.SeasonalValueBean storeBean = new usace.cwms.db.dao.ifc.level.SeasonalValueBean();
            storeBean.setValue(bean.getValue());
            storeBean.setOffsetMonths(bean.getOffsetMonths().byteValue());
            storeBean.setOffsetMinutes(bean.getOffsetMinutes());
            seasonalValues.add(storeBean);
        }
    }
    return seasonalValues;
}
Also used : SeasonalValueBean(cwms.radar.data.dto.SeasonalValueBean)

Example 2 with SeasonalValueBean

use of cwms.radar.data.dto.SeasonalValueBean in project cwms-radar-api by USACE.

the class LocationLevelsDaoTest method buildExampleLevel.

LocationLevel buildExampleLevel(String locationName) throws Exception {
    String dateString = "1999-12-05T10:15:30+01:00[UTC]";
    List<SeasonalValueBean> seasonalValues = new ArrayList<>();
    SeasonalValueBean seasonalVal = new SeasonalValueBean.Builder(10.0).withOffsetMinutes(BigInteger.valueOf(0)).withOffsetMonths(0).build();
    seasonalValues.add(0, seasonalVal);
    ZonedDateTimeAdapter zonedDateTimeAdapter = new ZonedDateTimeAdapter();
    ZonedDateTime unmarshalledDateTime = zonedDateTimeAdapter.unmarshal(dateString);
    LocationLevel retval = new LocationLevel.Builder(locationName + ".Elev.Inst.0.Bottom of Inlet", unmarshalledDateTime).withOfficeId(OFFICE_ID).withLevelComment("For testing").withLevelUnitsId(Unit.FEET.getValue()).withSeasonalValues(seasonalValues).withIntervalMonths(1).build();
    return retval;
}
Also used : SeasonalValueBean(cwms.radar.data.dto.SeasonalValueBean) ZonedDateTime(java.time.ZonedDateTime) ArrayList(java.util.ArrayList) ZonedDateTimeAdapter(cwms.radar.formatters.xml.adapters.ZonedDateTimeAdapter) LocationLevel(cwms.radar.data.dto.LocationLevel)

Example 3 with SeasonalValueBean

use of cwms.radar.data.dto.SeasonalValueBean in project cwms-radar-api by USACE.

the class LevelsController method getUpdatedLocationLevel.

private LocationLevel getUpdatedLocationLevel(LocationLevel existingLevel, LocationLevel updatedLevel) {
    String seasonalTimeSeriesId = (updatedLevel.getSeasonalTimeSeriesId() == null ? existingLevel.getSeasonalTimeSeriesId() : updatedLevel.getSeasonalTimeSeriesId());
    List<SeasonalValueBean> seasonalValues = (updatedLevel.getSeasonalValues() == null ? existingLevel.getSeasonalValues() : updatedLevel.getSeasonalValues());
    String specifiedLevelId = (updatedLevel.getSpecifiedLevelId() == null ? existingLevel.getSpecifiedLevelId() : updatedLevel.getSpecifiedLevelId());
    String parameterTypeId = (updatedLevel.getParameterTypeId() == null ? existingLevel.getParameterTypeId() : updatedLevel.getParameterTypeId());
    String parameterId = (updatedLevel.getParameterId() == null ? existingLevel.getParameterId() : updatedLevel.getParameterId());
    Double siParameterUnitsConstantValue = (updatedLevel.getConstantValue() == null ? existingLevel.getConstantValue() : updatedLevel.getConstantValue());
    String levelUnitsId = (updatedLevel.getLevelUnitsId() == null ? existingLevel.getLevelUnitsId() : updatedLevel.getLevelUnitsId());
    ZonedDateTime levelDate = (updatedLevel.getLevelDate() == null ? existingLevel.getLevelDate() : updatedLevel.getLevelDate());
    String levelComment = (updatedLevel.getLevelComment() == null ? existingLevel.getLevelComment() : updatedLevel.getLevelComment());
    ZonedDateTime intervalOrigin = (updatedLevel.getIntervalOrigin() == null ? existingLevel.getIntervalOrigin() : updatedLevel.getIntervalOrigin());
    Integer intervalMinutes = (updatedLevel.getIntervalMinutes() == null ? existingLevel.getIntervalMinutes() : updatedLevel.getIntervalMinutes());
    Integer intervalMonths = (updatedLevel.getIntervalMonths() == null ? existingLevel.getIntervalMonths() : updatedLevel.getIntervalMonths());
    String interpolateString = (updatedLevel.getInterpolateString() == null ? existingLevel.getInterpolateString() : updatedLevel.getInterpolateString());
    String durationId = (updatedLevel.getDurationId() == null ? existingLevel.getDurationId() : updatedLevel.getDurationId());
    BigDecimal attributeValue = (updatedLevel.getAttributeValue() == null ? existingLevel.getAttributeValue() : updatedLevel.getAttributeValue());
    String attributeUnitsId = (updatedLevel.getAttributeUnitsId() == null ? existingLevel.getAttributeUnitsId() : updatedLevel.getAttributeUnitsId());
    String attributeParameterTypeId = (updatedLevel.getAttributeParameterTypeId() == null ? existingLevel.getAttributeParameterTypeId() : updatedLevel.getAttributeParameterTypeId());
    String attributeParameterId = (updatedLevel.getAttributeParameterId() == null ? existingLevel.getAttributeParameterId() : updatedLevel.getAttributeParameterId());
    String attributeDurationId = (updatedLevel.getAttributeDurationId() == null ? existingLevel.getAttributeDurationId() : updatedLevel.getAttributeDurationId());
    String attributeComment = (updatedLevel.getAttributeComment() == null ? existingLevel.getAttributeComment() : updatedLevel.getAttributeComment());
    String locationId = (updatedLevel.getLocationLevelId() == null ? existingLevel.getLocationLevelId() : updatedLevel.getLocationLevelId());
    String officeId = (updatedLevel.getOfficeId() == null ? existingLevel.getOfficeId() : updatedLevel.getOfficeId());
    if (existingLevel.getIntervalMonths() != null && existingLevel.getIntervalMonths() > 0) {
        intervalMinutes = null;
    } else if (existingLevel.getIntervalMinutes() != null && existingLevel.getIntervalMinutes() > 0) {
        intervalMonths = null;
    }
    if (existingLevel.getAttributeValue() == null) {
        attributeUnitsId = null;
    }
    if (!existingLevel.getSeasonalValues().isEmpty()) {
        siParameterUnitsConstantValue = null;
        seasonalTimeSeriesId = null;
    } else if (existingLevel.getSeasonalTimeSeriesId() != null && !existingLevel.getSeasonalTimeSeriesId().isEmpty()) {
        siParameterUnitsConstantValue = null;
        seasonalValues = null;
    }
    return new LocationLevel.Builder(locationId, levelDate).withSeasonalValues(seasonalValues).withSeasonalTimeSeriesId(seasonalTimeSeriesId).withSpecifiedLevelId(specifiedLevelId).withParameterTypeId(parameterTypeId).withParameterId(parameterId).withConstantValue(siParameterUnitsConstantValue).withLevelUnitsId(levelUnitsId).withLevelComment(levelComment).withIntervalOrigin(intervalOrigin).withIntervalMinutes(intervalMinutes).withIntervalMonths(intervalMonths).withInterpolateString(interpolateString).withDurationId(durationId).withAttributeValue(attributeValue).withAttributeUnitsId(attributeUnitsId).withAttributeParameterTypeId(attributeParameterTypeId).withAttributeParameterId(attributeParameterId).withAttributeDurationId(attributeDurationId).withAttributeComment(attributeComment).withOfficeId(officeId).build();
}
Also used : SeasonalValueBean(cwms.radar.data.dto.SeasonalValueBean) ZonedDateTime(java.time.ZonedDateTime) LocationLevel(cwms.radar.data.dto.LocationLevel) BigDecimal(java.math.BigDecimal)

Example 4 with SeasonalValueBean

use of cwms.radar.data.dto.SeasonalValueBean in project cwms-radar-api by USACE.

the class LocationLevelsDaoTest method getUpdatedLocationLevel.

private LocationLevel getUpdatedLocationLevel(LocationLevel existinglocation, LocationLevel updatedLevel) {
    String seasonalTimeSeriesId = (updatedLevel.getSeasonalTimeSeriesId() == null ? existinglocation.getSeasonalTimeSeriesId() : updatedLevel.getSeasonalTimeSeriesId());
    List<SeasonalValueBean> seasonalValues = (updatedLevel.getSeasonalValues() == null ? existinglocation.getSeasonalValues() : updatedLevel.getSeasonalValues());
    String specifiedLevelId = (updatedLevel.getSpecifiedLevelId() == null ? existinglocation.getSpecifiedLevelId() : updatedLevel.getSpecifiedLevelId());
    String parameterTypeId = (updatedLevel.getParameterTypeId() == null ? existinglocation.getParameterTypeId() : updatedLevel.getParameterTypeId());
    String parameterId = (updatedLevel.getParameterId() == null ? existinglocation.getParameterId() : updatedLevel.getParameterId());
    Double siParameterUnitsConstantValue = (updatedLevel.getConstantValue() == null ? existinglocation.getConstantValue() : updatedLevel.getConstantValue());
    String levelUnitsId = (updatedLevel.getLevelUnitsId() == null ? existinglocation.getLevelUnitsId() : updatedLevel.getLevelUnitsId());
    ZonedDateTime levelDate = (updatedLevel.getLevelDate() == null ? existinglocation.getLevelDate() : updatedLevel.getLevelDate());
    String levelComment = (updatedLevel.getLevelComment() == null ? existinglocation.getLevelComment() : updatedLevel.getLevelComment());
    ZonedDateTime intervalOrigin = (updatedLevel.getIntervalOrigin() == null ? existinglocation.getIntervalOrigin() : updatedLevel.getIntervalOrigin());
    Integer intervalMinutes = (updatedLevel.getIntervalMinutes() == null ? existinglocation.getIntervalMinutes() : updatedLevel.getIntervalMinutes());
    Integer intervalMonths = (updatedLevel.getIntervalMonths() == null ? existinglocation.getIntervalMonths() : updatedLevel.getIntervalMonths());
    String interpolateString = (updatedLevel.getInterpolateString() == null ? existinglocation.getInterpolateString() : updatedLevel.getInterpolateString());
    String durationId = (updatedLevel.getDurationId() == null ? existinglocation.getDurationId() : updatedLevel.getDurationId());
    BigDecimal attributeValue = (updatedLevel.getAttributeValue() == null ? existinglocation.getAttributeValue() : updatedLevel.getAttributeValue());
    String attributeUnitsId = (updatedLevel.getAttributeUnitsId() == null ? existinglocation.getAttributeUnitsId() : updatedLevel.getAttributeUnitsId());
    String attributeParameterTypeId = (updatedLevel.getAttributeParameterTypeId() == null ? existinglocation.getAttributeParameterTypeId() : updatedLevel.getAttributeParameterTypeId());
    String attributeParameterId = (updatedLevel.getAttributeParameterId() == null ? existinglocation.getAttributeParameterId() : updatedLevel.getAttributeParameterId());
    String attributeDurationId = (updatedLevel.getAttributeDurationId() == null ? existinglocation.getAttributeDurationId() : updatedLevel.getAttributeDurationId());
    String attributeComment = (updatedLevel.getAttributeComment() == null ? existinglocation.getAttributeComment() : updatedLevel.getAttributeComment());
    String locationId = (updatedLevel.getLocationLevelId() == null ? existinglocation.getLocationLevelId() : updatedLevel.getLocationLevelId());
    String officeId = (updatedLevel.getOfficeId() == null ? existinglocation.getOfficeId() : updatedLevel.getOfficeId());
    if (existinglocation.getIntervalMonths() != null && existinglocation.getIntervalMonths() > 0) {
        intervalMinutes = null;
    } else if (existinglocation.getIntervalMinutes() != null && existinglocation.getIntervalMinutes() > 0) {
        intervalMonths = null;
    }
    if (existinglocation.getAttributeValue() == null) {
        attributeUnitsId = null;
    }
    if (!existinglocation.getSeasonalValues().isEmpty()) {
        siParameterUnitsConstantValue = null;
        seasonalTimeSeriesId = null;
    } else if (existinglocation.getSeasonalTimeSeriesId() != null && !existinglocation.getSeasonalTimeSeriesId().isEmpty()) {
        siParameterUnitsConstantValue = null;
        seasonalValues = null;
    }
    return new LocationLevel.Builder(locationId, levelDate).withSeasonalValues(seasonalValues).withSeasonalTimeSeriesId(seasonalTimeSeriesId).withSpecifiedLevelId(specifiedLevelId).withParameterTypeId(parameterTypeId).withParameterId(parameterId).withConstantValue(siParameterUnitsConstantValue).withLevelUnitsId(levelUnitsId).withLevelComment(levelComment).withIntervalOrigin(intervalOrigin).withIntervalMinutes(intervalMinutes).withIntervalMonths(intervalMonths).withInterpolateString(interpolateString).withDurationId(durationId).withAttributeValue(attributeValue).withAttributeUnitsId(attributeUnitsId).withAttributeParameterTypeId(attributeParameterTypeId).withAttributeParameterId(attributeParameterId).withAttributeDurationId(attributeDurationId).withAttributeComment(attributeComment).withOfficeId(officeId).build();
}
Also used : BigInteger(java.math.BigInteger) SeasonalValueBean(cwms.radar.data.dto.SeasonalValueBean) ZonedDateTime(java.time.ZonedDateTime) LocationLevel(cwms.radar.data.dto.LocationLevel) BigDecimal(java.math.BigDecimal)

Aggregations

SeasonalValueBean (cwms.radar.data.dto.SeasonalValueBean)4 LocationLevel (cwms.radar.data.dto.LocationLevel)3 ZonedDateTime (java.time.ZonedDateTime)3 BigDecimal (java.math.BigDecimal)2 ZonedDateTimeAdapter (cwms.radar.formatters.xml.adapters.ZonedDateTimeAdapter)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1