FINERACT-1926: Fineract Asset Externalization models
- [x] JPA model changes
This commit is contained in:
committed by
Arnold Gálovics
parent
9fee79ecde
commit
debc8e94a4
-87
@@ -1,87 +0,0 @@
|
|||||||
/**
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you 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.apache.fineract.investor.domain;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.Optional;
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.MappedSuperclass;
|
|
||||||
import org.springframework.data.domain.Auditable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class is a copy paste from the fineract-provider module since EclipseLink not weaves the class properly if it's
|
|
||||||
* placed in the fineract-core module.
|
|
||||||
*/
|
|
||||||
@MappedSuperclass
|
|
||||||
public abstract class AbstractAuditableCustom extends AbstractPersistableCustom implements Auditable<Long, Long, LocalDateTime> {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 141481953116476081L;
|
|
||||||
|
|
||||||
@Column(name = "createdby_id")
|
|
||||||
private Long createdBy;
|
|
||||||
|
|
||||||
@Column(name = "created_date")
|
|
||||||
private LocalDateTime createdDate;
|
|
||||||
|
|
||||||
@Column(name = "lastmodifiedby_id")
|
|
||||||
private Long lastModifiedBy;
|
|
||||||
|
|
||||||
@Column(name = "lastmodified_date")
|
|
||||||
private LocalDateTime lastModifiedDate;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Long> getCreatedBy() {
|
|
||||||
return Optional.ofNullable(this.createdBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCreatedBy(final Long createdBy) {
|
|
||||||
this.createdBy = createdBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<LocalDateTime> getCreatedDate() {
|
|
||||||
return null == this.createdDate ? Optional.empty() : Optional.of(this.createdDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCreatedDate(final LocalDateTime createdDate) {
|
|
||||||
this.createdDate = createdDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Long> getLastModifiedBy() {
|
|
||||||
return Optional.ofNullable(this.lastModifiedBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLastModifiedBy(final Long lastModifiedBy) {
|
|
||||||
this.lastModifiedBy = lastModifiedBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<LocalDateTime> getLastModifiedDate() {
|
|
||||||
return null == this.lastModifiedDate ? Optional.empty() : Optional.of(this.lastModifiedDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLastModifiedDate(final LocalDateTime lastModifiedDate) {
|
|
||||||
this.lastModifiedDate = lastModifiedDate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+99
@@ -0,0 +1,99 @@
|
|||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.apache.fineract.investor.domain;
|
||||||
|
|
||||||
|
import static org.apache.fineract.infrastructure.core.domain.AuditableFieldsConstants.CREATED_BY_DB_FIELD;
|
||||||
|
import static org.apache.fineract.infrastructure.core.domain.AuditableFieldsConstants.CREATED_DATE_DB_FIELD;
|
||||||
|
import static org.apache.fineract.infrastructure.core.domain.AuditableFieldsConstants.LAST_MODIFIED_BY_DB_FIELD;
|
||||||
|
import static org.apache.fineract.infrastructure.core.domain.AuditableFieldsConstants.LAST_MODIFIED_DATE_DB_FIELD;
|
||||||
|
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import java.util.Optional;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.MappedSuperclass;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||||
|
import org.springframework.data.domain.Auditable;
|
||||||
|
import org.springframework.data.jpa.domain.AbstractAuditable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A custom copy of {@link AbstractAuditable} to override the column names used on database. It also uses OffsetDateTime
|
||||||
|
* for created and modified. The datetimes will be converted from tenant TZ to UTC before storing (automatically
|
||||||
|
* happens) and converted from System TZ to tenant TZ after fetching from DB
|
||||||
|
*
|
||||||
|
* Abstract base class for auditable entities. Stores the audit values in persistent fields.
|
||||||
|
*/
|
||||||
|
@MappedSuperclass
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
public abstract class AbstractAuditableWithUTCDateTimeCustom extends AbstractPersistableCustom
|
||||||
|
implements Auditable<Long, Long, OffsetDateTime> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 141481953116476081L;
|
||||||
|
|
||||||
|
@Column(name = CREATED_BY_DB_FIELD, nullable = false)
|
||||||
|
@Setter(onMethod = @__(@Override))
|
||||||
|
private Long createdBy;
|
||||||
|
|
||||||
|
@Column(name = CREATED_DATE_DB_FIELD, nullable = false)
|
||||||
|
@Setter(onMethod = @__(@Override))
|
||||||
|
private OffsetDateTime createdDate;
|
||||||
|
|
||||||
|
@Column(name = LAST_MODIFIED_BY_DB_FIELD, nullable = false)
|
||||||
|
@Setter(onMethod = @__(@Override))
|
||||||
|
private Long lastModifiedBy;
|
||||||
|
|
||||||
|
@Column(name = LAST_MODIFIED_DATE_DB_FIELD, nullable = false)
|
||||||
|
@Setter(onMethod = @__(@Override))
|
||||||
|
private OffsetDateTime lastModifiedDate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Long> getCreatedBy() {
|
||||||
|
return Optional.ofNullable(this.createdBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<OffsetDateTime> getCreatedDate() {
|
||||||
|
if (this.createdDate == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
return Optional.of(this.createdDate
|
||||||
|
.withOffsetSameInstant(DateUtils.getDateTimeZoneOfTenant().getRules().getOffset(this.createdDate.toInstant())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Long> getLastModifiedBy() {
|
||||||
|
return Optional.ofNullable(this.lastModifiedBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<OffsetDateTime> getLastModifiedDate() {
|
||||||
|
if (this.lastModifiedDate == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
return Optional.of(this.lastModifiedDate
|
||||||
|
.withOffsetSameInstant(DateUtils.getDateTimeZoneOfTenant().getRules().getOffset(this.lastModifiedDate.toInstant())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -31,7 +31,7 @@ import lombok.Setter;
|
|||||||
@Entity
|
@Entity
|
||||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||||
@Table(name = "m_external_asset_owner")
|
@Table(name = "m_external_asset_owner")
|
||||||
public class ExternalAssetOwner extends AbstractAuditableCustom {
|
public class ExternalAssetOwner extends AbstractAuditableWithUTCDateTimeCustom {
|
||||||
|
|
||||||
@Column(name = "external_id", nullable = false, length = 100, unique = true)
|
@Column(name = "external_id", nullable = false, length = 100, unique = true)
|
||||||
private String externalId;
|
private String externalId;
|
||||||
|
|||||||
+7
-1
@@ -22,6 +22,8 @@ import java.math.BigDecimal;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -33,11 +35,15 @@ import lombok.Setter;
|
|||||||
@Table(name = "m_external_asset_owner_transfer")
|
@Table(name = "m_external_asset_owner_transfer")
|
||||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||||
@Entity
|
@Entity
|
||||||
public class ExternalAssetOwnerTransfer extends AbstractAuditableCustom {
|
public class ExternalAssetOwnerTransfer extends AbstractAuditableWithUTCDateTimeCustom {
|
||||||
|
|
||||||
@Column(name = "owner_id")
|
@Column(name = "owner_id")
|
||||||
private Long ownerId;
|
private Long ownerId;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "owner_id", insertable = false, updatable = false)
|
||||||
|
private ExternalAssetOwner owner;
|
||||||
|
|
||||||
@Column(name = "external_id", length = 100)
|
@Column(name = "external_id", length = 100)
|
||||||
private String externalId;
|
private String externalId;
|
||||||
|
|
||||||
|
|||||||
+6
-3
@@ -20,6 +20,8 @@ package org.apache.fineract.investor.domain;
|
|||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -31,12 +33,13 @@ import lombok.Setter;
|
|||||||
@Table(name = "m_external_asset_owner_transfer_loan_mapping")
|
@Table(name = "m_external_asset_owner_transfer_loan_mapping")
|
||||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||||
@Entity
|
@Entity
|
||||||
public class ExternalAssetOwnerTransferLoanMapping extends AbstractAuditableCustom {
|
public class ExternalAssetOwnerTransferLoanMapping extends AbstractAuditableWithUTCDateTimeCustom {
|
||||||
|
|
||||||
@Column(name = "loan_id", nullable = false)
|
@Column(name = "loan_id", nullable = false)
|
||||||
private Long loanId;
|
private Long loanId;
|
||||||
|
|
||||||
@Column(name = "owner_transfer_id")
|
@ManyToOne
|
||||||
private Long ownerTransferId;
|
@JoinColumn(name = "owner_transfer_id", insertable = false, updatable = false)
|
||||||
|
private ExternalAssetOwnerTransfer ownerTransfer;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user