Skip to content

Commit

Permalink
HIBERNATE removed
Browse files Browse the repository at this point in the history
  • Loading branch information
uwol committed Aug 29, 2023
1 parent 33f249f commit 78ab259
Show file tree
Hide file tree
Showing 53 changed files with 71 additions and 1,645 deletions.
10 changes: 0 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@
<artifactId>guava</artifactId>
<version>30.1.1-jre</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.10.Final</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,6 @@
import java.util.Map.Entry;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Index;

import io.github.uwol.compecon.economy.agent.Agent;
import io.github.uwol.compecon.economy.bookkeeping.impl.BalanceSheetDTO;
import io.github.uwol.compecon.economy.materia.GoodType;
Expand All @@ -53,7 +36,6 @@
import io.github.uwol.compecon.economy.sectors.financial.BankAccount.TermType;
import io.github.uwol.compecon.economy.sectors.financial.BankAccountDelegate;
import io.github.uwol.compecon.economy.sectors.financial.Currency;
import io.github.uwol.compecon.economy.sectors.financial.impl.BankAccountImpl;
import io.github.uwol.compecon.economy.security.debt.Bond;
import io.github.uwol.compecon.economy.security.equity.Share;
import io.github.uwol.compecon.engine.applicationcontext.ApplicationContext;
Expand All @@ -62,12 +44,6 @@
import io.github.uwol.compecon.engine.timesystem.impl.DayType;
import io.github.uwol.compecon.engine.timesystem.impl.MonthType;

@Entity
@Table(name = "Agent")
@org.hibernate.annotations.Table(appliesTo = "Agent", indexes = {
@Index(name = "IDX_A_DTYPE", columnNames = { "DTYPE" }) })
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "DTYPE")
public abstract class AgentImpl implements Agent {

public class BalanceSheetPublicationEvent implements TimeSystemEvent {
Expand All @@ -90,12 +66,8 @@ public void onEvent() {
/**
* bank account for basic daily transactions
*/
@OneToOne(targetEntity = BankAccountImpl.class)
@JoinColumn(name = "bankAccountTransactions_id")
@Index(name = "IDX_A_BA_TRANSACTIONS")
protected BankAccount bankAccountTransactions;

@Transient
protected final BankAccountDelegate bankAccountTransactionsDelegate = new BankAccountDelegate() {
@Override
public BankAccount getBankAccount() {
Expand All @@ -108,32 +80,22 @@ public void onTransfer(final double amount) {
}
};

@Id
@GeneratedValue(strategy = GenerationType.TABLE)
protected int id;

@Column(name = "isDeconstructed")
protected boolean isDeconstructed = false;

@Transient
private boolean isInitialized = false;

@Column(name = "primaryCurrency")
@Enumerated(EnumType.STRING)
@Index(name = "IDX_A_PRIMARYCURRENCY")
protected Currency primaryCurrency;

/**
* maxCredit limits the demand for money when buying production input factors,
* thus limiting M1 in the monetary system
*/
@Column(name = "referenceCredit")
protected double referenceCredit;

@Transient
protected Set<TimeSystemEvent> timeSystemEvents = new HashSet<TimeSystemEvent>();

@Transient
protected void assureBankAccountTransactions() {
if (isDeconstructed) {
return;
Expand All @@ -152,7 +114,6 @@ protected void assureBankAccountTransactions() {
* deregisters the agent from all referencing objects
*/
@Override
@Transient
public void deconstruct() {
isDeconstructed = true;

Expand Down Expand Up @@ -193,7 +154,6 @@ public BankAccount getBankAccountTransactions() {
}

@Override
@Transient
public BankAccountDelegate getBankAccountTransactionsDelegate() {
return bankAccountTransactionsDelegate;
}
Expand All @@ -203,12 +163,10 @@ public int getId() {
return id;
}

@Transient
protected Log getLog() {
return ApplicationContext.getInstance().getLog();
}

@Transient
protected Bank getPrimaryBank() {
assureBankAccountTransactions();
return bankAccountTransactions.getManagingBank();
Expand Down Expand Up @@ -249,7 +207,6 @@ public boolean isDeconstructed() {
return isDeconstructed;
}

@Transient
protected BalanceSheetDTO issueBalanceSheet() {
assureBankAccountTransactions();

Expand Down Expand Up @@ -339,15 +296,13 @@ protected BalanceSheetDTO issueBalanceSheet() {
}

@Override
@Transient
public void onBankCloseBankAccount(final BankAccount bankAccount) {
if (bankAccountTransactions == bankAccount) {
bankAccountTransactions = null;
}
}

@Override
@Transient
public void onPropertyTransferred(final Property property, final PropertyOwner oldOwner,
final PropertyOwner newOwner) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,83 +19,41 @@

package io.github.uwol.compecon.economy.markets.impl;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Index;

import io.github.uwol.compecon.economy.agent.impl.AgentImpl;
import io.github.uwol.compecon.economy.markets.MarketOrder;
import io.github.uwol.compecon.economy.markets.MarketParticipant;
import io.github.uwol.compecon.economy.materia.GoodType;
import io.github.uwol.compecon.economy.property.Property;
import io.github.uwol.compecon.economy.property.impl.PropertyImpl;
import io.github.uwol.compecon.economy.sectors.financial.BankAccountDelegate;
import io.github.uwol.compecon.economy.sectors.financial.Currency;

/**
* http://en.wikipedia.org/wiki/Order_%28exchange%29
*/
@Entity
@Table(name = "MarketOrder")
@org.hibernate.annotations.Table(appliesTo = "MarketOrder", indexes = {
@Index(name = "IDX_MO_GP", columnNames = { "goodType", "pricePerUnit" }),
@Index(name = "IDX_MO_CP", columnNames = { "commodityCurrency", "pricePerUnit" }) })
public class MarketOrderImpl implements MarketOrder, Comparable<MarketOrder> {

@Column(name = "amount")
protected double amount;

@Column(name = "commodityCurrency")
@Enumerated(EnumType.STRING)
protected Currency commodityCurrency;

@Transient
protected BankAccountDelegate commodityCurrencyOfferorsBankAcountDelegate;

@Enumerated(EnumType.STRING)
@Column(name = "currency")
@Index(name = "IDX_MO_CURRENCY")
protected Currency currency;

@Column
@Enumerated(EnumType.STRING)
protected GoodType goodType;

@Id
@GeneratedValue(strategy = GenerationType.TABLE)
protected int id;

@ManyToOne(targetEntity = AgentImpl.class)
@JoinColumn(name = "offeror_id")
protected MarketParticipant offeror;

@Transient
protected BankAccountDelegate offerorsBankAcountDelegate;

@Column(name = "pricePerUnit")
protected double pricePerUnit;

@ManyToOne(targetEntity = PropertyImpl.class)
@Index(name = "IDX_MO_PROPERTY")
@JoinColumn(name = "property_id")
protected Property property;

@Column
@Enumerated(EnumType.STRING)
protected ValidityPeriod validityPeriod;

@Override
@Transient
public int compareTo(final MarketOrder marketOrder) {
if (this == marketOrder) {
return 0;
Expand All @@ -114,7 +72,6 @@ public int compareTo(final MarketOrder marketOrder) {
}

@Override
@Transient
public void decrementAmount(final double amount) {
this.amount -= amount;
}
Expand All @@ -125,7 +82,6 @@ public double getAmount() {
}

@Override
@Transient
public Object getCommodity() {
if (CommodityType.CURRENCY.equals(getCommodityType())) {
return commodityCurrency;
Expand All @@ -146,13 +102,11 @@ public Currency getCommodityCurrency() {
}

@Override
@Transient
public BankAccountDelegate getCommodityCurrencyOfferorsBankAccountDelegate() {
return commodityCurrencyOfferorsBankAcountDelegate;
}

@Override
@Transient
public CommodityType getCommodityType() {
if (commodityCurrency != null) {
return CommodityType.CURRENCY;
Expand Down Expand Up @@ -184,7 +138,6 @@ public MarketParticipant getOfferor() {
}

@Override
@Transient
public BankAccountDelegate getOfferorsBankAcountDelegate() {
return offerorsBankAcountDelegate;
}
Expand All @@ -194,7 +147,6 @@ public double getPricePerUnit() {
return pricePerUnit;
}

@Transient
public double getPriceTotal() {
return pricePerUnit * getAmount();
}
Expand All @@ -220,7 +172,6 @@ public void setCommodityCurrency(final Currency currency) {
commodityCurrency = currency;
}

@Transient
public void setCommodityCurrencyOfferorsBankAccountDelegate(final BankAccountDelegate bankAccountDelegate) {
commodityCurrencyOfferorsBankAcountDelegate = bankAccountDelegate;
}
Expand All @@ -241,7 +192,6 @@ public void setOfferor(final MarketParticipant offeror) {
this.offeror = offeror;
}

@Transient
public void setOfferorsBankAcountDelegate(final BankAccountDelegate offerorsBankAcountDelegate) {
this.offerorsBankAcountDelegate = offerorsBankAcountDelegate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,16 @@
import java.util.HashMap;
import java.util.Map;

import javax.persistence.CollectionTable;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.MapKeyEnumerated;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import io.github.uwol.compecon.economy.agent.impl.AgentImpl;
import io.github.uwol.compecon.economy.materia.GoodType;
import io.github.uwol.compecon.economy.property.GoodTypeOwnership;
import io.github.uwol.compecon.economy.property.PropertyOwner;

@Entity
@Table(name = "GoodTypeOwnership")
public class GoodTypeOwnershipImpl implements GoodTypeOwnership {

@Id
@GeneratedValue(strategy = GenerationType.TABLE)
protected int id;

@ElementCollection
@CollectionTable(name = "GoodTypeOwnership_OwnedGoodTypes", joinColumns = @JoinColumn(name = "goodtypeownership_id"))
@MapKeyEnumerated(EnumType.STRING)
private Map<GoodType, Double> ownedGoodTypes = new HashMap<GoodType, Double>();

@OneToOne(targetEntity = AgentImpl.class)
@JoinColumn(name = "propertyOwner_id", nullable = false)
protected PropertyOwner propertyOwner;

public GoodTypeOwnershipImpl() {
Expand Down
Loading

0 comments on commit 78ab259

Please sign in to comment.