Skip to content
Browse files

controllers and some minor refactoring

  • Loading branch information...
1 parent 2360aa8 commit a8e38433eecb5bee7afc84eb533ab52de2f4b207 @mbir0654 committed May 26, 2011
View
1 .gitignore
@@ -11,3 +11,4 @@ sems_server/bin/*
*.iws
*/out/*
*META*
+sems_server/src/data/dbutil/*
View
4 sems_client/src/business/model/Group.java
@@ -35,8 +35,8 @@ public Group(String gr) {
/**
* @param student the student to set
*/
- public void addStudent(Student s) {
- this.students.add(s);
+ public void addStudent(Student student) {
+ this.students.add(student);
}
/**
View
71 sems_client/src/client/RMIUtil.java
@@ -0,0 +1,71 @@
+package client;
+
+import business.serviceinterface.InterfaceAppService;
+
+import business.serviceinterface.*;
+import controller.Controller;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import ui.frameLogin;
+
+import javax.swing.*;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: myh
+ * Date: 5/23/11
+ * Time: 11:24 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class RMIUtil {
+ public static void init() {
+ ApplicationContext factory = new ClassPathXmlApplicationContext(
+ "classpath:client/clientContext.xml");
+ RMIUtil app = (RMIUtil) factory.getBean("semsClient");
+ app.test();
+ }
+
+ public void test() {
+ System.out.println(appService.hello());
+ System.out.println(studentService.hello());
+ System.out.println(adminService.hello());
+ System.out.println(profService.hello());
+ }
+
+ public static InterfaceAppService getAppService(){
+ return appService;
+ }
+
+ public static InterfaceAdministratorService getAdminService() {
+ return adminService;
+ }
+
+ public static InterfaceProfessorService getProfService() {
+ return profService;
+ }
+
+ public static InterfaceStudentService getStudentService() {
+ return studentService;
+ }
+
+ public void setAppService(InterfaceAppService service) {
+ appService = service;
+ }
+
+ public void setAdminService(InterfaceAdministratorService service) {
+ adminService = service;
+ }
+
+ public void setProfService(InterfaceProfessorService service) {
+ profService = service;
+ }
+
+ public void setStudentService(InterfaceStudentService service) {
+ studentService = service;
+ }
+
+ private static InterfaceAppService appService;
+ private static InterfaceAdministratorService adminService;
+ private static InterfaceProfessorService profService;
+ private static InterfaceStudentService studentService;
+}
View
46 sems_client/src/client/SemsClient.java
@@ -1,52 +1,22 @@
package client;
-import business.serviceinterface.InterfaceAppService;
+import controller.Controller;
+import ui.frameLogin;
-import business.serviceinterface.*;
-import com.sun.org.apache.bcel.internal.util.ClassPath;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
+import javax.swing.*;
/**
* Created by IntelliJ IDEA.
* User: myh
- * Date: 5/23/11
- * Time: 11:24 PM
+ * Date: 5/26/11
+ * Time: 5:40 PM
* To change this template use File | Settings | File Templates.
*/
public class SemsClient {
public static void main(String[] args) {
- ApplicationContext factory = new ClassPathXmlApplicationContext(
- "classpath:client/clientContext.xml");
- SemsClient app = (SemsClient) factory.getBean("semsClient");
- app.run();
- }
-
- public void run() {
- System.out.println(appService.hello());
- System.out.println(studentService.hello());
- System.out.println(adminService.hello());
- System.out.println(profService.hello());
- }
-
- public void setAppService(InterfaceAppService service) {
- this.appService = service;
- }
+ RMIUtil.init();
- public void setAdminService(InterfaceAdministratorService service) {
- this.adminService = service;
+ Controller loginController = new Controller(RMIUtil.getAppService());
+ loginController.openLoginFrame();
}
-
- public void setProfService(InterfaceProfessorService service) {
- this.profService = service;
- }
-
- public void setStudentService(InterfaceStudentService service) {
- this.studentService = service;
- }
-
- private InterfaceAppService appService;
- private InterfaceAdministratorService adminService;
- private InterfaceProfessorService profService;
- private InterfaceStudentService studentService;
}
View
2 sems_client/src/client/clientContext.xml
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="semsClient" class="client.SemsClient">
+ <bean id="semsClient" class="client.RMIUtil">
<property name="appService" ref="appService" />
<property name="studentService" ref="studentService" />
<property name="adminService" ref="administratorService" />
View
83 sems_client/src/controller/Controller.java
@@ -13,6 +13,8 @@
import java.nio.charset.Charset;
import java.security.*;
+import business.serviceinterface.InterfaceAppService;
+import client.RMIUtil;
import ui.*;
//import business.service.AppService;
@@ -23,21 +25,31 @@
*
*/
public class Controller {
-
- private User u;
-
@SuppressWarnings("unused")
-// private AppService apps;
+
+ private User u;
+ private frameLogin loginFrame;
+ private InterfaceAppService apps;
/**
* Constructorul implicit.
* <p>atributul privat este referinta
* spre clasa cu serviciile aplicatiei</p>
- * @see AppService#getInstance()
*/
- public Controller(){
-// apps = AppService.getInstance();
+
+ /**
+ *
+ * @param service - serviciul utilizat de controller
+ */
+
+ public Controller(InterfaceAppService service){
+ apps = service;
}
+
+ public void openLoginFrame() {
+ loginFrame = new frameLogin(this);
+ loginFrame.setVisible(true);
+ }
public User ValidateUser(String u, String p){
return null;
@@ -46,52 +58,57 @@ public User ValidateUser(String u, String p){
/*
* Checking the login username and password to know what to open
*/
- public void checkLogin(frameLogin f) {
- String inputUser = f.getInputUser().getText();
+ public void checkLogin() {
+ String inputUser = loginFrame.getInputUser().getText();
/*
* Trimite username-ul si parola in format MD5
* spre verificare la server
*/
- User U=new Student();
- System.out.println(U.getClass().toString());
- if(U.getClass().toString().contains("Administrator"))
- this.loginAdmin(f, (Administrator) U);
- else if(U.getClass().toString().contains("Professor"))
- this.loginProf(f,(Professor) U);
- else if(U.getClass().toString().contains("Student"))
- this.loginStudent(f,(Student) U);
-
+ User user = new Professor();
+ if(user instanceof Administrator) {
+ this.loginAdmin(loginFrame, (Administrator) user);
+ loginFrame.setVisible(false);
+ }
+ else if(user instanceof Professor) {
+ this.loginProf(loginFrame,(Professor) user);
+ loginFrame.setVisible(false);
+ }
+ else if(user instanceof Student) {
+ this.loginStudent(loginFrame,(Student) user);
+ loginFrame.setVisible(false);
+ }
}
public void loginAdmin(JFrame f,Administrator adm){
- u = new Administrator(adm);
- ControllerAdmin ca = new ControllerAdmin((Administrator) u);
- JFrame admin = new frameAdminMain(ca);
- admin.setVisible(true);
- admin.setTitle("SEMS :: Administrator");
- admin.setResizable(false);
+ u = new Administrator(adm);
+ ControllerAdmin ca = new ControllerAdmin((Administrator) u, RMIUtil.getAdminService());
+ JFrame adminFrame = new frameAdminMain(ca);
+ adminFrame.setTitle("SEMS :: Administrator");
+ adminFrame.setResizable(false);
+ adminFrame.setVisible(true);
//f.setVisible(false); //lasa linia asta comentata!!!
}
/**
* @param f este referinta spre fereastra afectata de metoda
*/
public void loginStudent(JFrame f,Student stud){
- u = new Student(stud);
- ControllerStudent cs = new ControllerStudent((Student)u);
- cs.openMainFrame();
+ u = new Student(stud);
+ ControllerStudent cs = new ControllerStudent((Student) u, RMIUtil.getStudentService());
+ cs.openMainFrame();
+
}
/**
* @param f este referinta spre fereastra afectata de metoda
*/
public void loginProf(JFrame f, Professor P){
- u = new Professor(P);
- ControllerProfesor cp = new ControllerProfesor((Professor) u);
- JFrame prof = new frameProfMain(cp);
- prof.setVisible(true);
- prof.setTitle("SEMS :: Profesor");
- prof.setResizable(false);
+ u = new Professor(P);
+ ControllerProfesor cp = new ControllerProfesor((Professor) u, RMIUtil.getProfService());
+ JFrame profFrame = new frameProfMain(cp);
+ profFrame.setVisible(true);
+ profFrame.setResizable(false);
+ profFrame.setTitle("SEMS :: Profesor");
//f.setVisible(false); //lasa linia asta comentata!!!
}
View
6 sems_client/src/controller/ControllerAdmin.java
@@ -6,15 +6,19 @@
package controller;
import business.model.Administrator;
import javax.swing.DefaultListModel;
+
+import business.serviceinterface.InterfaceAdministratorService;
import ui.*;
/**
*
* @author snoopy
*/
public class ControllerAdmin {
private final Administrator a;
- public ControllerAdmin(Administrator adm) {
+ private final InterfaceAdministratorService administratorService;
+ public ControllerAdmin(Administrator adm, InterfaceAdministratorService service) {
this.a=adm;
+ administratorService = service;
}
}
View
15 sems_client/src/controller/ControllerProfesor.java
@@ -14,16 +14,19 @@
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
+
+import business.serviceinterface.InterfaceProfessorService;
import ui.*;
/**
*
* @author snoopy
*/
public class ControllerProfesor {
private final Professor p;
-
- public ControllerProfesor(Professor pr) {
- this.p=pr;
+ private final InterfaceProfessorService professorService;
+ public ControllerProfesor(Professor pr, InterfaceProfessorService service) {
+ this.p = pr;
+ professorService = service;
}
@@ -214,13 +217,13 @@ public void loadCatalogGroups(frameProfCatalog f) {
DefaultListModel dlm = new DefaultListModel();
for(Group g : p.getGroups()){
if(g.getSpecialty().getCourses().equals(c)){
- dlm.addElement("Grupa "+g.getGroup()+" ("+g.getStudentNr()+")");
+ dlm.addElement("Grupa "+g.getGroupName()+" ("+g.getStudentNr()+")");
}
}
// DE STERS
Group t = new Group();
- t.setGroup("221");
- dlm.addElement("Grupa "+t.getGroup()+" ("+t.getStudentNr()+")");
+ t.setGroupName("221");
+ dlm.addElement("Grupa "+t.getGroupName()+" ("+t.getStudentNr()+")");
/////////////////
f.getListGrupe().setModel(dlm);
f.getListGrupe().setEnabled(true);
View
8 sems_client/src/controller/ControllerStudent.java
@@ -13,16 +13,20 @@
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.table.*;
+
+import business.serviceinterface.InterfaceStudentService;
import ui.*;
/**
*
* @author snoopy
*/
public class ControllerStudent {
- private final Student s;
+ private final Student s;
+ private final InterfaceStudentService studentService;
- public ControllerStudent(Student s) {
+ public ControllerStudent(Student s, InterfaceStudentService service) {
this.s = s;
+ studentService = service;
}
/*
View
BIN sems_client/src/icons/appico.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN sems_client/src/icons/appico1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN sems_client/src/icons/appico2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN sems_client/src/icons/appico3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
7 sems_client/src/test/GuiTester.java
@@ -6,6 +6,7 @@
import javax.swing.*;
/*import java.awt.*;
import java.awt.event.*;*/
+import controller.Controller;
import ui.*;
/**
@@ -37,12 +38,14 @@ public static void main(String[] args) {
catch (IllegalAccessException e) {
// handle exception
}
-
+
+/* Controller controlerLogin = new Controller()
JFrame loginFrame = new frameLogin();
loginFrame.setVisible(true);
loginFrame.setTitle("SEMS:: Login");
loginFrame.setName("Login");
- loginFrame.setResizable(false);
+ loginFrame.pack();
+ loginFrame.setResizable(false);*/
}
}
View
11 sems_client/src/ui/frameLogin.java
@@ -13,6 +13,9 @@
import javax.swing.*;
import controller.Controller;
+import sun.awt.image.SurfaceManager;
+
+import java.awt.*;
/**
*
@@ -21,12 +24,13 @@
*/
public class frameLogin extends javax.swing.JFrame {
- private Controller c = new Controller();
+ private final Controller c;
/** Creates new form frameLogin */
- public frameLogin() {
+ public frameLogin(Controller controller) {
initComponents();
infoText.setVisible(false);
+ c = controller;
}
/** This method is called from within the constructor to
@@ -47,6 +51,7 @@ private void initComponents() {
butLogin = new javax.swing.JButton();
infoText = new javax.swing.JLabel();
+ setTitle("SEMS:: Login");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setName("Login"); // NOI18N
@@ -134,7 +139,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
private void butLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butLoginActionPerformed
- c.checkLogin(this);
+ c.checkLogin();
}//GEN-LAST:event_butLoginActionPerformed
View
95 sems_server/src/business/service/AdministratorService.java
@@ -16,65 +16,74 @@ public String hello() {
@SuppressWarnings("unused")
private Administrator a;
-
+
+ /**
+ * TODO
+ * logout and save data
+ */
public void exitSystem() {
- /**
- * TODO
- * logout and save data
- */
}
+
+ /**
+ * TODO
+ * inmatricularea unui student nou
+ */
public void registerStudent() {
- /**
- * TODO
- * inmatricularea student nou
- */
}
- public void manageResources() {
- /**
- * TODO
- * administreaza resurse (facultati, profesori, cursuri, specializari)
- */
+
+ /**
+ * TODO
+ * administreaza resurse (facultati, profesori, cursuri, specializari)
+ */
+ public void manageResources() {
}
+
+ /**
+ * TODO
+ * gestionare de facultati
+ */
public void manageFaculties() {
- /**
- * TODO
- * gestionare de facultati
- */
}
- public void manageSpecializations() {
- /**
- * TODO
- * gestionare de specializari
- */
+
+ /**
+ * TODO
+ * gestionare de specializari
+ */
+ public void manageSpecializations() {
}
+
+ /**
+ * TODO
+ * gestionare de cursuri
+ */
public void manageCourses() {
- /**
- * TODO
- * gestionare de cursuri
- */
}
+
+ /**
+ * TODO
+ * gestionare de profesori
+ */
public void manageProfessors() {
- /**
- * TODO
- * gestionare de profesori
- */
}
+
+ /**
+ * TODO
+ * gestionare de administratori
+ */
public void manageAdministrators() {
- /**
- * TODO
- * gestionare de administratori
- */
}
+
+ /**
+ * TODO
+ * aprobare si salvare contract de stdiu
+ */
public void approveContracts() {
- /**
- * TODO
- * aprobare si salvare contract de stdiu
- */
}
+
+ /**
+ * TODO
+ * generare de rapoarte
+ */
public void generateReports() {
- /**
- * TODO
- * generare de rapoarte
- */
}
}
View
18 sems_server/src/data/dbutil/stored_procedures.sql
@@ -1,4 +1,4 @@
---anunturi pt un curs
+-- anunturi pt un curs
DELIMITER $$
DROP PROCEDURE IF EXISTS `pc221`.`announce_for_course`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pc221`.`announce_for_course`(IN param6 INT)
@@ -8,7 +8,7 @@ BEGIN
END$$
DELIMITER ;
---cursurile unei specializari
+-- cursurile unei specializari
DELIMITER $$
DROP PROCEDURE IF EXISTS `pc221`.`courses_for_specialty`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pc221`.`courses_for_specialty`(IN param4 INT)
@@ -19,7 +19,7 @@ BEGIN
END$$
DELIMITER ;
---notele la un examen
+-- notele la un examen
DELIMITER $$
DROP PROCEDURE IF EXISTS `pc221`.`grades_for_exam`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pc221`.`grades_for_exam`(IN param3 INT)
@@ -30,7 +30,7 @@ BEGIN
END$$
DELIMITER ;
---rezolvarile unei teme
+-- rezolvarile unei teme
DELIMITER $$
DROP PROCEDURE IF EXISTS `pc221`.`solutions_for_assign`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pc221`.`solutions_for_assign`(IN param2 INT)
@@ -41,7 +41,7 @@ BEGIN
END$$
DELIMITER ;
---specializarile unei facultati
+-- specializarile unei facultati
DELIMITER $$
DROP PROCEDURE IF EXISTS `pc221`.`specialties_for_faculty`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pc221`.`specialties_for_faculty`(IN param5 INT)
@@ -51,7 +51,7 @@ BEGIN
END$$
DELIMITER ;
---tprofesorii unui curs
+-- tprofesorii unui curs
DELIMITER $$
DROP PROCEDURE IF EXISTS `pc221`.`teachers_for_course`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pc221`.`teachers_for_course`(IN param1 INT)
@@ -62,7 +62,7 @@ BEGIN
END$$
DELIMITER ;
---grupele unui profesor
+-- grupele unui profesor
DELIMITER $$
DROP PROCEDURE IF EXISTS `pc221`.`groups_for_teacher`$$
CREATE PROCEDURE `pc221`.`groups_for_teacher` (IN param7 VARCHAR(255))
@@ -73,7 +73,7 @@ BEGIN
END$$
DELIMITER ;
---cursurile dintr-un contract
+-- cursurile dintr-un contract
DELIMITER $$
DROP PROCEDURE IF EXISTS `pc221`.`courses_for_contract`$$
CREATE PROCEDURE `pc221`.`courses_for_contract` (IN param9 INT)
@@ -83,7 +83,7 @@ BEGIN
END$$
DELIMITER ;
---studentii unei grupe
+-- studentii unei grupe
DELIMITER $$
DROP PROCEDURE IF EXISTS `pc221`.`students_for_group`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `students_for_group`(IN param8 INT)

0 comments on commit a8e3843

Please sign in to comment.
Something went wrong with that request. Please try again.