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
Expand Up @@ -34,11 +34,10 @@
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
import org.apache.fineract.organisation.office.domain.Office;
import org.apache.fineract.useradministration.domain.AppUser;

@Entity
@Table(name = "acc_gl_closure", uniqueConstraints = { @UniqueConstraint(columnNames = { "office_id", "closing_date" }, name = "office_id_closing_date") })
public class GLClosure extends AbstractAuditableCustom<AppUser, Long> {
public class GLClosure extends AbstractAuditableCustom {

@ManyToOne
@JoinColumn(name = "office_id", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

@Entity
@Table(name = "acc_gl_financial_activity_account")
public class FinancialActivityAccount extends AbstractPersistableCustom<Long> {
public class FinancialActivityAccount extends AbstractPersistableCustom {

@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "gl_account_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

@Entity
@Table(name = "acc_gl_account", uniqueConstraints = { @UniqueConstraint(columnNames = { "gl_code" }, name = "acc_gl_code") })
public class GLAccount extends AbstractPersistableCustom<Long> {
public class GLAccount extends AbstractPersistableCustom {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parent_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

@Entity
@Table(name = "m_trial_balance")
public class TrialBalance extends AbstractPersistableCustom<Long> {
public class TrialBalance extends AbstractPersistableCustom {

@Column(name = "office_id", nullable = false)
private Long officeId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountTransaction;
import org.apache.fineract.useradministration.domain.AppUser;

@Entity
@Table(name = "acc_gl_journal_entry")
public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
public class JournalEntry extends AbstractAuditableCustom {

@ManyToOne
@JoinColumn(name = "office_id", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@Entity
@Table(name = "acc_product_mapping", uniqueConstraints = { @UniqueConstraint(columnNames = { "product_id", "product_type",
"financial_account_type", "payment_type" }, name = "financial_action") })
public class ProductToGLAccountMapping extends AbstractPersistableCustom<Long> {
public class ProductToGLAccountMapping extends AbstractPersistableCustom {

@ManyToOne(optional=true)
@JoinColumn(name = "gl_account_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

@Entity
@Table(name = "m_loanproduct_provisioning_entry")
public class LoanProductProvisioningEntry extends AbstractPersistableCustom<Long> {
public class LoanProductProvisioningEntry extends AbstractPersistableCustom {

@ManyToOne(optional = false)
@JoinColumn(name = "history_id", referencedColumnName = "id", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

@Entity
@Table(name = "m_provisioning_history")
public class ProvisioningEntry extends AbstractPersistableCustom<Long> {
public class ProvisioningEntry extends AbstractPersistableCustom {

@Column(name = "journal_entry_created")
private Boolean isJournalEntryCreated;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

@Entity
@Table(name = "acc_accounting_rule", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }, name = "accounting_rule_name_unique") })
public class AccountingRule extends AbstractPersistableCustom<Long> {
public class AccountingRule extends AbstractPersistableCustom {

@Column(name = "name", nullable = false, length = 500)
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

@Entity
@Table(name = "acc_rule_tags", uniqueConstraints = { @UniqueConstraint(columnNames = { "acc_rule_id", "tag_id", "acc_type_enum" }, name = "UNIQUE_ACCOUNT_RULE_TAGS") })
public class AccountingTagRule extends AbstractPersistableCustom<Long> {
public class AccountingTagRule extends AbstractPersistableCustom {

@ManyToOne
@JoinColumn(name = "acc_rule_id", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
import org.apache.fineract.infrastructure.security.utils.SQLInjectionValidator;
import org.apache.fineract.useradministration.domain.AppUser;


@Entity
@Table(name = "m_adhoc")
public class AdHoc extends AbstractAuditableCustom<AppUser, Long> {
public class AdHoc extends AbstractAuditableCustom {

@Column(name = "name", length = 100)
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

@Entity
@Table(name = "m_portfolio_command_source")
public class CommandSource extends AbstractPersistableCustom<Long> {
public class CommandSource extends AbstractPersistableCustom {

@Column(name = "action_name", nullable = true, length = 100)
private String actionName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

@Entity
@Table(name = AccountNumberFormatConstants.ACCOUNT_NUMBER_FORMAT_TABLE_NAME, uniqueConstraints = { @UniqueConstraint(columnNames = { AccountNumberFormatConstants.ACCOUNT_TYPE_ENUM_COLUMN_NAME }, name = AccountNumberFormatConstants.ACCOUNT_TYPE_UNIQUE_CONSTRAINT_NAME) })
public class AccountNumberFormat extends AbstractPersistableCustom<Long> {
public class AccountNumberFormat extends AbstractPersistableCustom {

@Column(name = AccountNumberFormatConstants.ACCOUNT_TYPE_ENUM_COLUMN_NAME, nullable = false)
private Integer accountTypeEnum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

@Entity
@Table(name = "m_import_document")
public class ImportDocument extends AbstractPersistableCustom<Long>{
public class ImportDocument extends AbstractPersistableCustom{

@OneToOne
@JoinColumn(name = "document_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

@Entity
@Table(name = "c_cache")
public class PlatformCache extends AbstractPersistableCustom<Long> {
public class PlatformCache extends AbstractPersistableCustom {

@Column(name = "cache_type_enum")
private Integer cacheType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

@Entity
@Table(name = "scheduled_email_campaign")
public class EmailCampaign extends AbstractPersistableCustom<Long> {
public class EmailCampaign extends AbstractPersistableCustom {

@Column(name = "campaign_name", nullable = false)
private String campaignName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

@Entity
@Table(name = "scheduled_email_configuration")
public class EmailConfiguration extends AbstractPersistableCustom<Long> {
public class EmailConfiguration extends AbstractPersistableCustom {
@Column(name = "name", nullable = false)
private String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

@Entity
@Table(name = "scheduled_email_messages_outbound")
public class EmailMessage extends AbstractPersistableCustom<Long> {
public class EmailMessage extends AbstractPersistableCustom {

@ManyToOne
@JoinColumn(name = "group_id", nullable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

@Entity
@Table(name = "sms_campaign", uniqueConstraints = {@UniqueConstraint(columnNames = { "campaign_name" }, name = "campaign_name_UNIQUE")})
public class SmsCampaign extends AbstractPersistableCustom<Long> {
public class SmsCampaign extends AbstractPersistableCustom {

@Column(name = "campaign_name", nullable = false)
private String campaignName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

@Entity
@Table(name = "m_code", uniqueConstraints = { @UniqueConstraint(columnNames = { "code_name" }, name = "code_name") })
public class Code extends AbstractPersistableCustom<Long> {
public class Code extends AbstractPersistableCustom {

@Column(name = "code_name", length = 100)
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

@Entity
@Table(name = "m_code_value", uniqueConstraints = { @UniqueConstraint(columnNames = { "code_id", "code_value" }, name = "code_value_duplicate") })
public class CodeValue extends AbstractPersistableCustom<Long> {
public class CodeValue extends AbstractPersistableCustom {

@Column(name = "code_value", length = 100)
private String label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

@Entity
@Table(name = "c_external_service", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }, name = "name_UNIQUE") })
public class ExternalService extends AbstractPersistableCustom<Long> {
public class ExternalService extends AbstractPersistableCustom {

@Column(name = "name", length = 50)
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

@Entity
@Table(name = "c_configuration")
public class GlobalConfigurationProperty extends AbstractPersistableCustom<Long> {
public class GlobalConfigurationProperty extends AbstractPersistableCustom {

@Column(name = "name", nullable = false)
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.fineract.infrastructure.core.domain;

import java.io.Serializable;
import java.time.Instant;
import java.util.Date;
import java.util.Optional;
Expand All @@ -35,9 +34,9 @@

/**
* A custom copy of {@link AbstractAuditable} to override the column names used
* on database.
* on database. It also uses Instant instead of LocalDateTime for created and modified.
*
* Abstract base class for auditable entities. Stores the audition values in
* Abstract base class for auditable entities. Stores the audit values in
* persistent fields.
*
* @param <U>
Expand All @@ -46,7 +45,7 @@
* the type of the auditing type's identifier
*/
@MappedSuperclass
public abstract class AbstractAuditableCustom<U, PK extends Serializable> extends AbstractPersistableCustom<PK> implements Auditable<AppUser, Long, Instant> {
public abstract class AbstractAuditableCustom extends AbstractPersistableCustom implements Auditable<AppUser, Long, Instant> {

private static final long serialVersionUID = 141481953116476081L;

Expand All @@ -66,88 +65,41 @@ public abstract class AbstractAuditableCustom<U, PK extends Serializable> extend
@Temporal(TemporalType.TIMESTAMP)
private Date lastModifiedDate;

/*
* (non-Javadoc)
*
* @see org.springframework.data.domain.Auditable#getCreatedBy()
*/
@Override
public Optional<AppUser> getCreatedBy() {
return Optional.ofNullable(this.createdBy);
}

/*
* (non-Javadoc)
*
* @see
* org.springframework.data.domain.Auditable#setCreatedBy(java.lang.Object)
*/
@Override
public void setCreatedBy(final AppUser createdBy) {

this.createdBy = createdBy;
}

/*
* (non-Javadoc)
*
* @see org.springframework.data.domain.Auditable#getCreatedDate()
*/
@Override
public Optional<Instant> getCreatedDate() {
return null == this.createdDate ? Optional.empty() : Optional.of(this.createdDate.toInstant());
}

/*
* (non-Javadoc)
*
* @see
* org.springframework.data.domain.Auditable#setCreatedDate(T)
*/
@Override
public void setCreatedDate(final Instant createdDate) {
this.createdDate = null == createdDate ? null : Date.from(createdDate);
}

/*
* (non-Javadoc)
*
* @see org.springframework.data.domain.Auditable#getLastModifiedBy()
*/
@Override
public Optional<AppUser> getLastModifiedBy() {
return Optional.ofNullable(this.lastModifiedBy);
}

/*
* (non-Javadoc)
*
* @see
* org.springframework.data.domain.Auditable#setLastModifiedBy(java.lang
* .Object)
*/
@Override
public void setLastModifiedBy(final AppUser lastModifiedBy) {

this.lastModifiedBy = lastModifiedBy;
}

/*
* (non-Javadoc)
*
* @see org.springframework.data.domain.Auditable#getLastModifiedDate()
*/
@Override
public Optional<Instant> getLastModifiedDate() {
return null == this.lastModifiedDate ? Optional.empty() : Optional.of(this.lastModifiedDate.toInstant());
}

/*
* (non-Javadoc)
*
* @see
* org.springframework.data.domain.Auditable#setLastModifiedDate(T)
*/
@Override
public void setLastModifiedDate(final Instant lastModifiedDate) {
this.lastModifiedDate = null == lastModifiedDate ? null : Date.from(lastModifiedDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,41 @@
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import org.springframework.data.domain.Persistable;


/**
* Abstract base class for entities.
*
* Inspired by {@link org.springframework.data.jpa.domain.AbstractPersistable}, but
* Id is always Long (and this class thus does not require generic parameterization),
* and auto-generation is of strategy {@link javax.persistence.GenerationType#IDENTITY}.
*
* The {@link #equals(Object)} and {@link #hashCode()} methods are NOT implemented here,
* which is untypical for JPA (it's usually implemented based on the Id), because
* "we end up with issues on OpenJPA" (TODO clarify this).
*/
@MappedSuperclass
public abstract class AbstractPersistableCustom<PK extends Serializable> implements Persistable<Long>, Serializable {

private static final long serialVersionUID = 9181640245194392646L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
public abstract class AbstractPersistableCustom implements Persistable<Long>, Serializable {

@Override
public Long getId() {
return id;
}
private static final long serialVersionUID = 9181640245194392646L;

protected void setId(final Long id) {
this.id = id;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Override
public boolean isNew() {
@Override
public Long getId() {
return id;
}

return null == this.id;
}
protected void setId(final Long id) {
this.id = id;
}

// We have removed toString(), hashCode() and equals() methods here, because by adding them here, we end up with issues on OpenJPA.
@Override
@Transient // DATAJPA-622
public boolean isNew() {
return null == this.id;
}
}
Loading