Skip to content

Conversation

@dfcoffin
Copy link
Contributor

Summary

Implements Phase 1 of 26 in the NAESB ESPI 4.0 schema compliance plan. This phase establishes TimeConfiguration DTO with JAXB XML marshalling/unmarshalling on Spring Boot 4.0.1 + Java 25.

Implementation Details

DTO Layer (JAXB)

  • TimeConfigurationDto with @XmlRootElement and XSD propOrder compliance
  • ✅ Byte array defensive copying for DST rules
  • ✅ Utility methods: getTzOffsetInHours(), getEffectiveOffset(), hasDstRules()
  • ✅ 11 comprehensive XML marshalling/unmarshalling tests

Mapper Layer

  • TimeConfigurationMapper using MapStruct 1.6.3
  • ✅ Bidirectional Entity ↔ DTO conversion
  • ✅ UUID mapping: Entity.idDTO.uuid

Repository

  • ✅ Removed 3 XPath-based query methods (non-index)
  • ✅ Retained 2 index-based methods: findAllIds(), findAllIdsByUsagePointId()

Database Migration

  • V4__Create_Time_Configurations.sql with XSD propOrder column sequence
  • ✅ Indexes on created, updated, tz_offset

Code Quality

SonarQube Fixes

  • ✅ Replaced generic throws Exception with specific throws JAXBException
  • ✅ Fixed variable naming (camelCase: utcMinusEight, utcPlusFivePointFive)
  • ✅ Chained assertions for better readability
  • ✅ Removed unused variables
  • ✅ Used hasSameHashCodeAs() for hashCode assertions

SonarQube Configuration

  • ✅ Created sonar-project.properties to exclude Oracle-specific SQL rules
  • ✅ Configured multicriteria exclusions: sql:S6397, sql:Oracle*
  • Note: Project uses MySQL, PostgreSQL, H2 (not Oracle)

Testing

Test Results

✅ All 11 TimeConfigurationDtoTest tests PASS
✅ XML marshalling/unmarshalling validated
✅ JAXB functionality verified with realistic timezone data
✅ Round-trip marshalling integrity confirmed

Test Environment

  • Java 25 (LTS - Zulu 25.28+85-CA)
  • Spring Boot 4.0.1
  • Jakarta EE 11
  • JAXB (jakarta.xml.bind-api 4.x)
  • MapStruct 1.6.3

Documentation

Analysis Documents

  • DTO_APPROACH_COMPARISON.md - JAXB vs Jackson XML evaluation
  • PR50_MULTI_PHASE_IMPACT.md - Spring Boot 4.0 impact on all 26 phases
  • PR50_TEST_FAILURE_FIX.md - Timestamp precision test fix
  • JUNIE_VS_CLAUDE_GUIDELINES_COMPARISON.md - Test pattern migration guide

Plan Updates

  • MULTI_PHASE_SCHEMA_COMPLIANCE_PLAN.md updated with Spring Boot 4.0 stack
  • Added comprehensive Spring Boot 4.0 test patterns for remaining 25 phases

Team Decisions

JAXB selected for all 26 phases

  • Rationale: Jackson 3.0 XML support is immature in Spring Boot 4.0
  • JAXB provides stable, proven XML binding for ESPI 4.0 compliance

Test Plan

  • Review JAXB DTO implementation
  • Verify XSD propOrder compliance
  • Validate XML marshalling output
  • Check MapStruct mapper generation
  • Review Flyway migration script
  • Confirm SonarQube exclusions work in CI
  • Verify all 11 tests pass in CI

Next Steps

After this PR merges:

  • Phase 2: ReadingType DTO (13 fields)
  • Phase 3: IntervalReading DTO (9 fields)
  • Continue through remaining 23 phases

🤖 Generated with Claude Code

dfcoffin and others added 2 commits December 30, 2025 00:11
Implements Phase 1 of 26-phase NAESB ESPI 4.0 schema compliance plan using
JAXB (Jakarta XML Binding) for XML marshalling/unmarshalling on Spring Boot 4.0.1
and Java 25.

## Implementation

**DTO Layer (JAXB):**
- TimeConfigurationDto: JAXB DTO with @XmlRootElement and XSD propOrder compliance
- Byte array cloning for DST rules (defensive copying)
- Utility methods: getTzOffsetInHours(), getEffectiveOffset(), hasDstRules()
- All 11 XML marshalling/unmarshalling tests passing

**Mapper Layer:**
- TimeConfigurationMapper: MapStruct bidirectional Entity-DTO conversion
- UUID handling: Entity.id → DTO.uuid mapping
- Ignores transient and managed fields

**Repository:**
- Removed 3 XPath-based query methods (non-index queries)
- Retained 2 index-based query methods: findAllIds(), findAllIdsByUsagePointId()

**Database Migration:**
- V4__Create_Time_Configurations.sql: XSD propOrder column sequence
- Indexes on created, updated, tz_offset

## Code Quality (SonarQube Fixes)

**TimeConfigurationDtoTest:**
- Replaced generic "throws Exception" with specific "throws JAXBException" (3 methods)
- Fixed variable naming to match camelCase convention (utcMinusEight, utcPlusFivePointFive)
- Methods that call marshaller/unmarshaller now declare JAXBException

**TimeConfigurationRepositoryTest:**
- Chained assertions for better readability (3 locations)
- Removed unused variables (2 occurrences)
- Used hasSameHashCodeAs() for hashCode assertion

**SonarQube Configuration:**
- Created sonar-project.properties to exclude Oracle-specific SQL rules
- Project uses MySQL, PostgreSQL, H2 - VARCHAR2 rule doesn't apply
- Configured multicriteria exclusions for sql:S6397 and sql:Oracle* rules

## Testing

- ✅ All 11 TimeConfigurationDtoTest tests pass (Spring Boot 4.0 + Java 25)
- ✅ XML marshalling/unmarshalling validated
- ✅ JAXB functionality verified with realistic timezone data
- ✅ Round-trip marshalling integrity confirmed

## Documentation

**Analysis Documents:**
- DTO_APPROACH_COMPARISON.md: JAXB vs Jackson XML evaluation
- PR50_MULTI_PHASE_IMPACT.md: Spring Boot 4.0 upgrade impact on all 26 phases
- PR50_TEST_FAILURE_FIX.md: Timestamp precision test fix
- JUNIE_VS_CLAUDE_GUIDELINES_COMPARISON.md: Test pattern migration guide

**Plan Updates:**
- MULTI_PHASE_SCHEMA_COMPLIANCE_PLAN.md: Updated with Spring Boot 4.0 stack
- Added comprehensive Spring Boot 4.0 test patterns for remaining 25 phases

## Technology Stack

- Java 25 (LTS - Zulu 25.28+85-CA)
- Spring Boot 4.0.1
- Jakarta EE 11
- JAXB (jakarta.xml.bind-api 4.x)
- MapStruct 1.6.3

Team Decision: JAXB selected for all 26 phases due to Jackson 3.0 XML immaturity
in Spring Boot 4.0.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The time_configurations table was already created in V2__MySQL_Specific_Tables.sql
because it contains BLOB columns requiring vendor-specific handling. The V4 migration
was attempting to create the same table, causing CI/CD failures with error:
  SQL State: 42S01
  Error Code: 1050
  Message: Table 'time_configurations' already exists

Changes:
- Deleted openespi-common/src/main/resources/db/migration/V4__Create_Time_Configurations.sql
- Fixed openespi-thirdparty/pom.xml artifactId capitalization for consistency

Related to #51 (Phase 1: TimeConfiguration DTO implementation)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@dfcoffin dfcoffin merged commit a0d113c into main Dec 30, 2025
5 checks passed
@dfcoffin dfcoffin deleted the feature/phase1-time-configuration-dto branch December 30, 2025 06:05
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