--- /dev/null
+package businessLogic;
+
+import gui.StartWindow;
+
+import java.rmi.RemoteException;
+import java.util.Vector;
+
+import dataAccess.DB4oManager;
+import domain.Owner;
+
+public class LoginManager implements LoginManagerInterface {
+ //owners to be separated to accounts later on
+ DB4oManager dbMngr;
+
+
+ public LoginManager() {
+
+ try {
+ dbMngr = DB4oManager.getInstance();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+
+ @Override
+ public Owner checkCredentials(String usr, String pwd) {
+ try {
+ Vector<Owner> owner = dbMngr.getSingleOwner(usr, pwd);
+ if(owner.isEmpty()) return null;
+ else return owner.get(0);
+
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+
+
+}
//db.close();
}
}
+
+ public Vector<Owner> getSingleOwner(String usr, String pwd) throws RemoteException,
+ Exception {
+ ObjectContainer db=DB4oManager.getContainer();
+ try {
+ Owner proto = new Owner(null,usr,pwd,null);
+ ObjectSet result = db.queryByExample(proto);
+ Vector<Owner> owners=new Vector<Owner>();
+ while(result.hasNext())
+ owners.add((Owner)result.next());
+ return owners;
+ } finally {
+ //db.close();
+ }
+ }
+
public Vector<RuralHouse> getAllRuralHouses() throws RemoteException,
Exception {
ObjectContainer db=DB4oManager.getContainer();