Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
*
* Copyright (c) 2025 Green Button Alliance, Inc.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.greenbuttonalliance.espi.common.domain.customer.common;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.greenbuttonalliance.espi.common.domain.customer.enums.ProgramDateKind;

import java.io.Serializable;

/**
* Embeddable class for single customer energy efficiency program date mapping.
*
* Per customer.xsd lines 1223-1251, ProgramDateIdMapping extends Object (NOT IdentifiedObject).
* This is an embedded component, not a standalone entity.
*/
@Embeddable
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProgramDateIdMapping implements Serializable {

/**
* Type of customer energy efficiency program date.
*/
@Enumerated(EnumType.STRING)
@Column(name = "program_date_type", length = 64)
private ProgramDateKind programDateType;

/**
* Code value (may be alphanumeric).
*/
@Column(name = "code", length = 64)
private String code;

/**
* Name associated with code.
*/
@Column(name = "name", length = 256)
private String name;

/**
* Optional description of code.
*/
@Column(name = "note", length = 256)
private String note;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@

import lombok.*;
import org.greenbuttonalliance.espi.common.domain.common.IdentifiedObject;
import org.greenbuttonalliance.espi.common.domain.customer.common.ProgramDateIdMapping;
import org.hibernate.proxy.HibernateProxy;

import jakarta.persistence.*;
import java.util.Objects;

/**
* Pure JPA/Hibernate entity for ProgramDateIdMappings without JAXB concerns.
*
* [extension] Collection of all customer Energy Efficiency programs
*
* [extension] Collection of all customer Energy Efficiency programs.
* Per customer.xsd lines 269-283, ProgramDateIdMappings extends IdentifiedObject
* and contains a single embedded ProgramDateIdMapping object.
*/
@Entity
@Table(name = "program_date_id_mappings")
Expand All @@ -46,10 +49,39 @@
public class ProgramDateIdMappingsEntity extends IdentifiedObject {

/**
* [extension] Program date description
* TODO: Create ProgramDateIdMappingEntity and enable this relationship
* Single customer energy efficiency program date mapping.
* Per customer.xsd, this is the only field in ProgramDateIdMappings beyond IdentifiedObject fields.
*/
// @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
// @JoinColumn(name = "program_date_id_mapping_id")
// private ProgramDateIdMappingEntity programDateIdMapping;
@Embedded
private ProgramDateIdMapping programDateIdMapping;

@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null) return false;
Class<?> oEffectiveClass = o instanceof HibernateProxy hibernateProxy ? hibernateProxy.getHibernateLazyInitializer().getPersistentClass() : o.getClass();
Class<?> thisEffectiveClass = this instanceof HibernateProxy hibernateProxy ? hibernateProxy.getHibernateLazyInitializer().getPersistentClass() : this.getClass();
if (thisEffectiveClass != oEffectiveClass) return false;
ProgramDateIdMappingsEntity that = (ProgramDateIdMappingsEntity) o;
return getId() != null && Objects.equals(getId(), that.getId());
}

@Override
public final int hashCode() {
return this instanceof HibernateProxy hibernateProxy ? hibernateProxy.getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
}

@Override
public String toString() {
return getClass().getSimpleName() + "(" +
"id = " + getId() + ", " +
"description = " + getDescription() + ", " +
"created = " + getCreated() + ", " +
"updated = " + getUpdated() + ", " +
"published = " + getPublished() + ", " +
"upLink = " + getUpLink() + ", " +
"selfLink = " + getSelfLink() + ", " +
"programDateIdMapping = " + programDateIdMapping + ", " +
"relatedLinks = " + getRelatedLinks() + ")";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
*
* Copyright (c) 2025 Green Button Alliance, Inc.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.greenbuttonalliance.espi.common.domain.customer.enums;

/**
* Type of Demand Response program date based on ESPI 4.0 customer.xsd specification.
*
* Per customer.xsd lines 1997-2030.
* Note: XSD uses union type, allowing both enumerated values and custom String64 values.
*
* Ordinal mapping:
* 0 = CUST_DR_PROGRAM_ENROLLMENT_DATE
* 1 = CUST_DR_PROGRAM_DE_ENROLLMENT_DATE
* 2 = CUST_DR_PROGRAM_TERM_DATE_REGARDLESS_FINANCIAL
* 3 = CUST_DR_PROGRAM_TERM_DATE_WITHOUT_FINANCIAL
*/
public enum ProgramDateKind {
/**
* Date customer enrolled in Demand Response program.
* Ordinal: 0
*/
CUST_DR_PROGRAM_ENROLLMENT_DATE,

/**
* Date customer terminated enrollment in Demand Response program.
* Ordinal: 1
*/
CUST_DR_PROGRAM_DE_ENROLLMENT_DATE,

/**
* Earliest date customer can terminate Demand Response enrollment, regardless of financial impact.
* Ordinal: 2
*/
CUST_DR_PROGRAM_TERM_DATE_REGARDLESS_FINANCIAL,

/**
* Earliest date customer can terminate Demand Response enrollment, without financial impact.
* Ordinal: 3
*/
CUST_DR_PROGRAM_TERM_DATE_WITHOUT_FINANCIAL
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
*
* Copyright (c) 2025 Green Button Alliance, Inc.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.greenbuttonalliance.espi.common.dto.customer;

import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.greenbuttonalliance.espi.common.domain.customer.enums.ProgramDateKind;

import java.io.Serializable;

/**
* ProgramDateIdMapping DTO for embedded complex type.
* Per ESPI 4.0 customer.xsd lines 1223-1251.
*
* Single customer energy efficiency program date mapping with 4 fields:
* - programDateType: Type of customer energy efficiency program date
* - code: Code value (may be alphanumeric)
* - name: Name associated with code
* - note: Optional description of code
*
* This is an embedded component (extends Object in XSD, not IdentifiedObject).
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ProgramDateIdMapping", namespace = "http://naesb.org/espi/customer", propOrder = {
"programDateType", "code", "name", "note"
})
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ProgramDateIdMappingDto implements Serializable {

private static final long serialVersionUID = 1L;

/**
* Type of customer energy efficiency program date.
* Maps to customer.xsd programDateType element (lines 1224-1238).
*/
@XmlElement(name = "programDateType", namespace = "http://naesb.org/espi/customer")
private ProgramDateKind programDateType;

/**
* Code value (may be alphanumeric).
* Maps to customer.xsd code element (lines 1239-1242).
*/
@XmlElement(name = "code", namespace = "http://naesb.org/espi/customer")
private String code;

/**
* Name associated with code.
* Maps to customer.xsd name element (lines 1243-1246).
*/
@XmlElement(name = "name", namespace = "http://naesb.org/espi/customer")
private String name;

/**
* Optional description of code.
* Maps to customer.xsd note element (lines 1247-1250).
*/
@XmlElement(name = "note", namespace = "http://naesb.org/espi/customer")
private String note;
}
Loading
Loading