Skip to content

Conversation

@dfcoffin
Copy link
Contributor

@dfcoffin dfcoffin commented Jan 8, 2026

Summary

Phase 5 of the ESPI 4.0 schema compliance project updates IntervalBlock entity, DTO, mapper, repository, and tests to match the espi.xsd element sequence and optimize for read-only operations.

Changes Made

IntervalBlockDto

  • ✅ Updated field order to match espi.xsd IntervalBlock element sequence
  • ✅ Removed Atom-level fields (published, updated, relatedLinks, selfLink, upLink, description)
  • ✅ Kept only ESPI schema fields: interval, intervalReadings
  • ✅ Updated all constructors to match new field order
  • ✅ Removed unused OffsetDateTime import
  • ✅ Added ESPI 4.0 schema compliance documentation

IntervalBlockMapper

  • ✅ Updated toDto mapping - removed mappings for deleted Atom fields
  • ✅ Updated toEntity mapping - marked Atom fields as ignore=true
  • ✅ Removed updateEntity method (read-only operations only)
  • ✅ Removed unused @MappingTarget import

IntervalBlockRepository

  • ✅ Optimized to keep only indexed queries:
    • findAllIds() - returns all interval block IDs
    • findAllByMeterReadingId() - indexed on meter_reading_id
    • findAllIdsByUsagePointId() - indexed through relationships
  • ✅ Removed non-indexed queries:
    • deleteByUuid() - redundant with inherited deleteById()
    • findAllIdsByXpath3() - complex join without index
    • findIdByXpath() - complex join without index
    • findByMeterReadingEntity() - duplicate of findAllByMeterReadingId()
    • findByUri() - non-indexed query on self_link_href

IntervalBlockServiceImpl

  • ✅ Updated findAllByMeterReading() to use findAllByMeterReadingId()
  • ✅ Deprecated findByURI() with warning (non-indexed query removed)

IntervalBlockRepositoryTest

  • ✅ Removed redundant shouldDeleteIntervalBlockByUuid test
  • ✅ Removed tests for deleted repository methods:
    • shouldFindAllIntervalBlockIdsByXpath3
    • shouldFindIntervalBlockIdByXpath
    • shouldFindIntervalBlocksByMeterReadingEntity
    • shouldFindIntervalBlockByUri
  • ✅ Updated shouldHandleEmptyResultsGracefully test
  • ✅ All 24 IntervalBlock tests passing

Validation

  • ✅ All 545 openespi-common tests passing
  • ✅ IntervalBlockRepositoryTest: 24/24 tests passing
  • ✅ DtoExportServiceImplTest validates XML output matches espi.xsd
  • ✅ Flyway migration scripts verified (MySQL, PostgreSQL, H2)

XML Output Validation

The DtoExportServiceImplTest confirms proper XML structure:

<espi:IntervalBlock>
  <interval>
    <start>1330578000</start>
    <duration>86400</duration>
  </interval>
  <IntervalReading>
    <cost>974</cost>
    <ReadingQuality>...</ReadingQuality>
    <timePeriod>...</timePeriod>
    <value>282</value>
  </IntervalReading>
  ...
</espi:IntervalBlock>

Related Issues

Testing Instructions

# Run IntervalBlock tests
mvn test -Dtest=IntervalBlockRepositoryTest

# Run all tests
mvn clean test

# Verify XML export
mvn test -Dtest=DtoExportServiceImplTest

🤖 Generated with Claude Code

Phase 5 of ESPI 4.0 schema compliance focuses on IntervalBlock entity
field order and repository query optimization for read-only operations.

Changes:
- IntervalBlockDto: Updated field order to match espi.xsd sequence
  - Removed Atom-level fields (published, updated, links, description)
  - Kept only ESPI schema fields: interval, intervalReadings
  - Updated constructors and removed unused imports
  - Added schema compliance documentation

- IntervalBlockMapper: Updated mappings for simplified DTO
  - Removed mappings for non-existent Atom fields
  - Removed updateEntity method (read-only operations only)
  - Removed @MappingTarget import

- IntervalBlockRepository: Optimized for indexed queries only
  - Kept: findAllIds, findAllByMeterReadingId, findAllIdsByUsagePointId
  - Removed: deleteByUuid, findAllIdsByXpath3, findIdByXpath,
    findByMeterReadingEntity, findByUri
  - Removed @Modifying, @transactional imports

- IntervalBlockServiceImpl: Updated for repository changes
  - Updated findAllByMeterReading to use findAllByMeterReadingId
  - Deprecated findByURI (non-indexed query removed)

- IntervalBlockRepositoryTest: Removed obsolete tests
  - Removed redundant deleteByUuid test
  - Removed tests for non-indexed queries (xpath, URI-based)
  - Updated empty results test
  - All 24 tests passing

Related Issues:
- Part of Issue #28 (ESPI 4.0 Schema Compliance)
- Created Issue #70 (Remove legacy Long id fields from DTOs)

All 545 openespi-common tests passing.
DtoExportServiceImplTest validates XML output matches espi.xsd.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@dfcoffin dfcoffin merged commit a82d10d into main Jan 8, 2026
5 checks passed
@dfcoffin dfcoffin deleted the feature/schema-compliance-phase-5-interval-block branch January 8, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants