Git Repository Public Repository

RRRRHHHH_Code

URLs

Copy to Clipboard
 
ccac9974c8183f7f0d30e8cabd84ee0386e8cd97
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package businessLogic;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.sql.Date;
import java.util.Vector;

import common.OfferInterface;

import dataAccess.DB4oManager;
import domain.Offer;
import domain.RuralHouse;
import exceptions.BadDates;
import exceptions.OverlappingOfferExists;

public final class OfferManager extends UnicastRemoteObject implements OfferInterface{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private int offerNumber = 0;
	dataAccess.DB4oManager dbMngr;

	public OfferManager() throws RemoteException {
		super();
		try {
			this.dbMngr = DB4oManager.getInstance();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


	
	/**
	 * This method creates an offer with a house number, first day, last day and price
	 * 
	 * @param House
	 *            number, start day, last day and price
	 * @return the created offer, or null, or an exception
	 */
	public Offer createOffer(RuralHouse ruralHouse, Date firstDay, Date lastDay,
			float price) throws OverlappingOfferExists, BadDates, RemoteException, Exception {
		if (firstDay.after(lastDay)||firstDay==null||lastDay==null)
			throw new BadDates();

		boolean b = dbMngr.existsOverlappingOffer(ruralHouse,firstDay,lastDay); // The ruralHouse object in the client may not be updated
		if (!b) {
			dbMngr.createOffer(ruralHouse,firstDay,lastDay,price);
			return ruralHouse.createOffer(offerNumber, firstDay, lastDay, price);			
		}
		return null;
	}

	
	public void deleteOffer(RuralHouse rh, Offer o) throws RemoteException, Exception{
		rh.getAllOffers().removeElement(o);
		dbMngr.deleteOffer( o);
	}



	@Override
	public Vector<Offer> getRuralHouseOffers(RuralHouse rh)
			throws RemoteException {
		// TODO Auto-generated method stub
		return dbMngr.getRHsOffer(rh.getHouseName());
	}

}

Commits for RRRRHHHH_CoderuralHouses/src/businessLogic/OfferManager.java

Diff revisions: vs.
Revision Author Commited Message
4bc36b ... Diff Diff camjan Tue 19 May, 2015 23:23:13 +0000

Merge branch ‘master’ of https://xp-dev.com/git/RRRRHHHH_Code

Conflicts:
ruralHouses client/src/gui/HouseFeaturesGUI.java
ruralHouses client/src/gui/ModifyOfferGUI.java
ruralHouses/src/domain/RuralHouse.java

ad3773 ... Diff Diff pinene picture pinene Tue 19 May, 2015 18:01:40 +0000

data now is gotten using queries

fca164 ... Diff Diff camjan Tue 19 May, 2015 14:51:35 +0000

Some improvements done, owner deletion started, some bugs remain there

25898b ... Diff Diff camjan Mon 18 May, 2015 15:26:01 +0000

Account adding and deleting fixed

799949 ... Diff Diff epinzolas001 Mon 18 May, 2015 11:12:36 +0000

debugging

4f8bcc ... Diff Diff epinzolas001 Mon 18 May, 2015 09:49:54 +0000

Merge conflicts solutioned

42679b ... Diff Diff pinene picture pinene Sun 19 Apr, 2015 14:18:02 +0000

Merge branch ‘master’ of https://xp-dev.com/git/RRRRHHHH_Code

Conflicts:
ruralHouses/src/businessLogic/OfferManager.java
ruralHouses/src/gui/HouseFeaturesGUI.java
ruralHouses/src/gui/ModifyHouseGUI.java
ruralHouses/src/gui/StartWindow.java

520867 ... Diff Diff pinene picture pinene Sun 19 Apr, 2015 14:09:12 +0000

tmp

837fab ... Diff Diff Eneko Pinzolas Murua Sat 18 Apr, 2015 14:09:49 +0000

no warnings

5761bc ... camjan Wed 15 Apr, 2015 15:27:07 +0000

Bugs when deleting houses and offers fixed and GUI’s adapated for empty cases