From: pinene Date: Fri, 27 Feb 2015 11:59:29 +0000 (+0100) Subject: Introduced Login Manager logic by creating the LoginManager and the LoginManagerInterface X-Git-Url: https://xp-dev.com/git/RRRRHHHH_Code/commitdiff_plain/1a30aec4aa0112eeed6bcac4a42880613a124a7b Introduced Login Manager logic by creating the LoginManager and the LoginManagerInterface --- diff --git a/ruralHouses/db/DBjcampos004.yap b/ruralHouses/db/DBjcampos004.yap index 672ef19..7af26dd 100644 Binary files a/ruralHouses/db/DBjcampos004.yap and b/ruralHouses/db/DBjcampos004.yap differ diff --git a/ruralHouses/src/businessLogic/ApplicationFacadeInterface.java b/ruralHouses/src/businessLogic/ApplicationFacadeInterface.java index a438bee..215e60b 100644 --- a/ruralHouses/src/businessLogic/ApplicationFacadeInterface.java +++ b/ruralHouses/src/businessLogic/ApplicationFacadeInterface.java @@ -63,6 +63,8 @@ public interface ApplicationFacadeInterface extends Remote { public Vector getOwners() throws RemoteException, Exception; + + public Vector getAllRuralHouses()throws RemoteException, Exception; diff --git a/ruralHouses/src/businessLogic/LoginManager.java b/ruralHouses/src/businessLogic/LoginManager.java new file mode 100644 index 0000000..9710fec --- /dev/null +++ b/ruralHouses/src/businessLogic/LoginManager.java @@ -0,0 +1,43 @@ +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 = 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; + } + + + +} diff --git a/ruralHouses/src/businessLogic/LoginManagerInterface.java b/ruralHouses/src/businessLogic/LoginManagerInterface.java new file mode 100644 index 0000000..57b070a --- /dev/null +++ b/ruralHouses/src/businessLogic/LoginManagerInterface.java @@ -0,0 +1,11 @@ +package businessLogic; + +import domain.*; + +public interface LoginManagerInterface { + + public Owner checkCredentials(String usr, String pwd); + + + +} diff --git a/ruralHouses/src/dataAccess/DB4oManager.java b/ruralHouses/src/dataAccess/DB4oManager.java index 0049a4e..8388435 100644 --- a/ruralHouses/src/dataAccess/DB4oManager.java +++ b/ruralHouses/src/dataAccess/DB4oManager.java @@ -85,7 +85,23 @@ public class DB4oManager { //db.close(); } } + + public Vector 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 owners=new Vector(); + while(result.hasNext()) + owners.add((Owner)result.next()); + return owners; + } finally { + //db.close(); + } + } + public Vector getAllRuralHouses() throws RemoteException, Exception { ObjectContainer db=DB4oManager.getContainer(); diff --git a/ruralHouses/src/gui/IntroduceOfferGUI.java b/ruralHouses/src/gui/IntroduceOfferGUI.java index 5d768e8..502f598 100644 --- a/ruralHouses/src/gui/IntroduceOfferGUI.java +++ b/ruralHouses/src/gui/IntroduceOfferGUI.java @@ -86,5 +86,7 @@ public class IntroduceOfferGUI extends JFrame { } return jButton; } + + } // @jve:decl-index=0:visual-constraint="222,33"