Create ResourceManagerController, create Modify interface in dataschema,
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / controller / ResourceManagerController.java
1 /*
2 * Copyright (c) 2015 Berner Fachhochschule, Switzerland.
3 *
4 * Project Smart Reservation System.
5 *
6 * Distributable under GPL license. See terms of license at gnu.org.
7 */
8 package ch.bfh.ti.srs.controller;
9
10 import ch.bfh.ti.srs.datahandler.DataHandler;
11 import ch.bfh.ti.srs.dataschema.Resource;
12
13
14 public class ResourceManagerController extends Controller {
15
16 public ResourceManagerController(DataHandler dh, SessionController sc) {
17 super(dh, sc);
18 }
19
20 public boolean addResource(Resource resource) throws Exception {
21 if (dh == null)
22 throw new Exception("No DataHandler set");
23 if (resource == null)
24 throw new IllegalArgumentException("Resource must be defined");
25 return dh.addResource(resource);
26 }
27
28 public boolean changeResource(Resource resource) throws Exception{
29 if (dh == null)
30 throw new Exception("No DataHandler set");
31 if (resource == null)
32 throw new IllegalArgumentException("Resource must be defined");
33 return dh.editResource(resource);
34 }
35
36 public boolean deleteResource(Resource resource) throws Exception {
37 if (dh == null)
38 throw new Exception("No DataHandler set");
39 if (resource == null)
40 throw new IllegalArgumentException("Resource must be defined");
41 return dh.deleteResource(resource);
42 }
43 }