Merge branch 'master' of github.com:frmwrk123/dis
This commit is contained in:
@ -1 +1 @@
|
|||||||
java -cp "out\production\DIS sheet 2:lib\db2jcc.jar:lib\db2jcc_license_cu.jar" de.dis2017.Main
|
java -cp "bin/;lib/*" de.dis2017.Main
|
||||||
@ -148,7 +148,7 @@ public class Main {
|
|||||||
estate.setSquareArea(FormUtil.readInt("Square Area"));
|
estate.setSquareArea(FormUtil.readInt("Square Area"));
|
||||||
estate.setAgent(FormUtil.readInt("EstateAgent ID"));
|
estate.setAgent(FormUtil.readInt("EstateAgent ID"));
|
||||||
if (isApartment) {
|
if (isApartment) {
|
||||||
Apartment apartment = (Apartment) estate;
|
Apartment apartment = new Apartment(estate);
|
||||||
apartment.setFloor(FormUtil.readInt("Floor"));
|
apartment.setFloor(FormUtil.readInt("Floor"));
|
||||||
apartment.setRooms(FormUtil.readInt("Rooms"));
|
apartment.setRooms(FormUtil.readInt("Rooms"));
|
||||||
apartment.setRent(FormUtil.readInt("Rent"));
|
apartment.setRent(FormUtil.readInt("Rent"));
|
||||||
@ -158,7 +158,7 @@ public class Main {
|
|||||||
apartment.setBuiltinKitchen(input.equals("Y") || input.equals("y"));
|
apartment.setBuiltinKitchen(input.equals("Y") || input.equals("y"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
House house = (House) estate;
|
House house = new House(estate);
|
||||||
house.setPrice(FormUtil.readInt("Price"));
|
house.setPrice(FormUtil.readInt("Price"));
|
||||||
house.setFloors(FormUtil.readInt("Floors"));
|
house.setFloors(FormUtil.readInt("Floors"));
|
||||||
input = FormUtil.readString("Garden(Y/N)");
|
input = FormUtil.readString("Garden(Y/N)");
|
||||||
@ -562,7 +562,7 @@ public class Main {
|
|||||||
contract = tenancyContract;
|
contract = tenancyContract;
|
||||||
tenancyContract.setApartment(FormUtil.readInt("Apartment ID"));
|
tenancyContract.setApartment(FormUtil.readInt("Apartment ID"));
|
||||||
tenancyContract.setPlace(place);
|
tenancyContract.setPlace(place);
|
||||||
tenancyContract.setDate(date);
|
tenancyContract.setDate(Date.valueOf(date));
|
||||||
tenancyContract.setPerson(person);
|
tenancyContract.setPerson(person);
|
||||||
tenancyContract.setStartDate(Date.valueOf(FormUtil.readString("Start Date")));
|
tenancyContract.setStartDate(Date.valueOf(FormUtil.readString("Start Date")));
|
||||||
Date endDate = Date.valueOf(FormUtil.readString("End Date"));
|
Date endDate = Date.valueOf(FormUtil.readString("End Date"));
|
||||||
@ -580,7 +580,7 @@ public class Main {
|
|||||||
PurchaseContract purchaseContract = new PurchaseContract();
|
PurchaseContract purchaseContract = new PurchaseContract();
|
||||||
contract = purchaseContract;
|
contract = purchaseContract;
|
||||||
purchaseContract.setPlace(place);
|
purchaseContract.setPlace(place);
|
||||||
purchaseContract.setDate(date);
|
purchaseContract.setDate(Date.valueOf(date));
|
||||||
purchaseContract.setPerson(person);
|
purchaseContract.setPerson(person);
|
||||||
purchaseContract.setHouse(FormUtil.readInt("House ID"));
|
purchaseContract.setHouse(FormUtil.readInt("House ID"));
|
||||||
purchaseContract.setNoOfInstallments(FormUtil.readInt("No of Installments"));
|
purchaseContract.setNoOfInstallments(FormUtil.readInt("No of Installments"));
|
||||||
@ -599,7 +599,8 @@ public class Main {
|
|||||||
|
|
||||||
for (Object o : persons) {
|
for (Object o : persons) {
|
||||||
Person person = (Person) o;
|
Person person = (Person) o;
|
||||||
System.out.println("ID: " + person.getId() + ", Name: " + person.getFirstName() + " " + person.getName());
|
System.out.println("ID: " + person.getId() + ", Name: " + person.getFirstName() + " " + person.getName()
|
||||||
|
+ " , Address: " + person.getAddress());
|
||||||
}
|
}
|
||||||
System.out.println("------------------");
|
System.out.println("------------------");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,20 @@ public class Apartment extends Estate{
|
|||||||
private boolean balcony;
|
private boolean balcony;
|
||||||
private boolean builtinKitchen;
|
private boolean builtinKitchen;
|
||||||
|
|
||||||
|
public Apartment(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Apartment(Estate estate){
|
||||||
|
this.setId(estate.getId());
|
||||||
|
this.setCity(estate.getCity());
|
||||||
|
this.setPostalCode(estate.getPostalCode());
|
||||||
|
this.setStreet(estate.getStreet());
|
||||||
|
this.setStreetNumber(estate.getStreetNumber());
|
||||||
|
this.setSquareArea(estate.getSquareArea());
|
||||||
|
this.setAgent(estate.getAgent());
|
||||||
|
}
|
||||||
|
|
||||||
public int getFloor() {
|
public int getFloor() {
|
||||||
return floor;
|
return floor;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,24 +1,33 @@
|
|||||||
package de.dis2017.data;
|
package de.dis2017.data;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contract data class
|
* Contract data class
|
||||||
*/
|
*/
|
||||||
public class Contract {
|
public class Contract {
|
||||||
private int contractNo = -1;
|
private int contractNo = -1;
|
||||||
private String date;
|
private Date date;
|
||||||
private String place;
|
private String place;
|
||||||
private int person;
|
private int person;
|
||||||
|
private int estate;
|
||||||
|
|
||||||
|
public int getEstate() {
|
||||||
|
return estate;
|
||||||
|
}
|
||||||
|
public void setEstate(int estate) {
|
||||||
|
this.estate = estate;
|
||||||
|
}
|
||||||
public int getContractNo() {
|
public int getContractNo() {
|
||||||
return contractNo;
|
return contractNo;
|
||||||
}
|
}
|
||||||
public void setContractNo(int contractNo) {
|
public void setContractNo(int contractNo) {
|
||||||
this.contractNo = contractNo;
|
this.contractNo = contractNo;
|
||||||
}
|
}
|
||||||
public String getDate() {
|
public Date getDate() {
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
public void setDate(String date) {
|
public void setDate(Date date) {
|
||||||
this.date = date;
|
this.date = date;
|
||||||
}
|
}
|
||||||
public String getPlace() {
|
public String getPlace() {
|
||||||
|
|||||||
@ -5,6 +5,20 @@ public class House extends Estate {
|
|||||||
private int price;
|
private int price;
|
||||||
private boolean garden;
|
private boolean garden;
|
||||||
|
|
||||||
|
public House(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public House(Estate estate){
|
||||||
|
this.setId(estate.getId());
|
||||||
|
this.setCity(estate.getCity());
|
||||||
|
this.setPostalCode(estate.getPostalCode());
|
||||||
|
this.setStreet(estate.getStreet());
|
||||||
|
this.setStreetNumber(estate.getStreetNumber());
|
||||||
|
this.setSquareArea(estate.getSquareArea());
|
||||||
|
this.setAgent(estate.getAgent());
|
||||||
|
}
|
||||||
|
|
||||||
public int getFloors() {
|
public int getFloors() {
|
||||||
return floors;
|
return floors;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,15 @@ public class PurchaseContract extends Contract {
|
|||||||
private int noOfInstallments;
|
private int noOfInstallments;
|
||||||
private int interestRate;
|
private int interestRate;
|
||||||
|
|
||||||
private int house;
|
public PurchaseContract(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
public PurchaseContract(Contract contract){
|
||||||
|
this.setContractNo(contract.getContractNo());
|
||||||
|
this.setDate(contract.getDate());
|
||||||
|
this.setPlace(contract.getPlace());
|
||||||
|
this.setPerson(contract.getPerson());
|
||||||
|
}
|
||||||
|
|
||||||
public int getNoOfInstallments() {
|
public int getNoOfInstallments() {
|
||||||
return noOfInstallments;
|
return noOfInstallments;
|
||||||
@ -23,10 +31,10 @@ public class PurchaseContract extends Contract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getHouse() {
|
public int getHouse() {
|
||||||
return house;
|
return super.getEstate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHouse(int house) {
|
public void setHouse(int house) {
|
||||||
this.house = house;
|
super.setEstate(house);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,16 @@ public class TenancyContract extends Contract {
|
|||||||
private Duration duration;
|
private Duration duration;
|
||||||
private int additionalCost;
|
private int additionalCost;
|
||||||
|
|
||||||
private int apartment;
|
public TenancyContract(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TenancyContract(Contract contract){
|
||||||
|
this.setContractNo(contract.getContractNo());
|
||||||
|
this.setDate(contract.getDate());
|
||||||
|
this.setPlace(contract.getPlace());
|
||||||
|
this.setPerson(contract.getPerson());
|
||||||
|
}
|
||||||
|
|
||||||
public Timestamp getStartDate() {
|
public Timestamp getStartDate() {
|
||||||
return startDate;
|
return startDate;
|
||||||
@ -40,10 +49,10 @@ public class TenancyContract extends Contract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getApartment() {
|
public int getApartment() {
|
||||||
return apartment;
|
return super.getEstate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setApartment(int apartment) {
|
public void setApartment(int apartment) {
|
||||||
this.apartment = apartment;
|
super.setEstate(apartment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,13 @@
|
|||||||
package de.dis2017.data.db;
|
package de.dis2017.data.db;
|
||||||
|
|
||||||
import de.dis2017.data.*;
|
import de.dis2017.data.Apartment;
|
||||||
|
import de.dis2017.data.Contract;
|
||||||
|
import de.dis2017.data.Estate;
|
||||||
|
import de.dis2017.data.EstateAgent;
|
||||||
|
import de.dis2017.data.House;
|
||||||
|
import de.dis2017.data.Person;
|
||||||
|
import de.dis2017.data.PurchaseContract;
|
||||||
|
import de.dis2017.data.TenancyContract;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
@ -21,6 +28,7 @@ public class ORM {
|
|||||||
private Map<Integer, Contract> _contracts;
|
private Map<Integer, Contract> _contracts;
|
||||||
private Map<Integer, Person> _persons;
|
private Map<Integer, Person> _persons;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the ORM.
|
* Initializes the ORM.
|
||||||
*/
|
*/
|
||||||
@ -275,7 +283,7 @@ public class ORM {
|
|||||||
Contract contract = new Contract();
|
Contract contract = new Contract();
|
||||||
contract.setContractNo(rs.getInt("contractNumber"));
|
contract.setContractNo(rs.getInt("contractNumber"));
|
||||||
contract.setPlace(rs.getString("place"));
|
contract.setPlace(rs.getString("place"));
|
||||||
contract.setDate(rs.getString("date"));
|
contract.setDate(rs.getDate("date"));
|
||||||
|
|
||||||
contracts.add(contract);
|
contracts.add(contract);
|
||||||
}
|
}
|
||||||
@ -375,7 +383,7 @@ public class ORM {
|
|||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
contract.setContractNo(ID);
|
contract.setContractNo(ID);
|
||||||
contract.setPlace(rs.getString("place"));
|
contract.setPlace(rs.getString("place"));
|
||||||
contract.setDate(rs.getString("date"));
|
contract.setDate(rs.getDate("date"));
|
||||||
contract.setPerson(rs.getInt("person"));
|
contract.setPerson(rs.getInt("person"));
|
||||||
|
|
||||||
if (contract instanceof PurchaseContract) {
|
if (contract instanceof PurchaseContract) {
|
||||||
@ -876,7 +884,7 @@ public class ORM {
|
|||||||
String insertSQL = "INSERT INTO CONTRACT (date, place) " +
|
String insertSQL = "INSERT INTO CONTRACT (date, place) " +
|
||||||
"VALUES (?, ?)";
|
"VALUES (?, ?)";
|
||||||
PreparedStatement pstmt = _connection.prepareStatement(insertSQL, Statement.RETURN_GENERATED_KEYS);
|
PreparedStatement pstmt = _connection.prepareStatement(insertSQL, Statement.RETURN_GENERATED_KEYS);
|
||||||
pstmt.setString(1, contract.getDate());
|
pstmt.setDate(1, contract.getDate());
|
||||||
pstmt.setString(2, contract.getPlace());
|
pstmt.setString(2, contract.getPlace());
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user