diff --git a/.gitignore b/.gitignore
index 8f51a4a..a6c44cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,4 @@
.idea/*
target/*
-<<<<<<< HEAD
-=======
*.war
->>>>>>> 21f7771889fbd331d8067aeaacba276c2ab841e7
-target/RotanaReg.war
-com.rotanareg.skolan.iml
+target/RotanaReg.war
\ No newline at end of file
diff --git a/com.rotanareg.skolan.iml b/com.rotanareg.skolan.iml
new file mode 100644
index 0000000..46af354
--- /dev/null
+++ b/com.rotanareg.skolan.iml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/Java/ejb/CourseService.java b/src/main/java/Java/ejb/CourseService.java
deleted file mode 100644
index 428627b..0000000
--- a/src/main/java/Java/ejb/CourseService.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package ejb;
-
-import domain.CourseDomain;
-
-import javax.ejb.Local;
-import java.util.List;
-
-/**
- * Created by Solidbeans on 2017-03-20.
- */
-@Local
-public interface CourseService {
-
- void addCourse(CourseDomain course);
- void updateCourse(CourseDomain course);
- void removeCourse(Long id);
- CourseDomain getCourse(Long id);
- List getCourses();
- public List getCoursesContaining(String filter);
-}
diff --git a/src/main/java/Java/ejb/CourseServiceImpl.java b/src/main/java/Java/ejb/CourseServiceImpl.java
deleted file mode 100644
index c642901..0000000
--- a/src/main/java/Java/ejb/CourseServiceImpl.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package ejb;
-
-import domain.CourseDomain;
-import jpa.Course;
-
-import javax.ejb.Stateless;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * Created by Solidbeans on 2017-03-20.
- */
-
-@Stateless
-public class CourseServiceImpl implements CourseService{
- @PersistenceContext
- EntityManager em;
-
- @Override
- public void addCourse(CourseDomain course) {
- Course c = new Course(course.getName(),course.getDescription(),course.getCourseNr());
- em.persist(c);
-
- }
-
- @Override
- public void updateCourse(CourseDomain course) {
- Course c = em.find(Course.class,course.getId());
- c.setName(course.getName());
- c.setDescription(course.getDescription());
- c.setCourseNr(course.getCourseNr());
- em.merge(c);
- }
-
- @Override
- public void removeCourse(Long id) {
- Course c = em.find(Course.class, id);
- em.remove(c);
- }
-
- @Override
- public CourseDomain getCourse(Long id) {
- Course c = em.find(Course.class,id);
- CourseDomain cd = new CourseDomain(c.getId(),c.getName(),c.getDescription(),c.getCourseNr());
-
- return cd;
- }
-
- @Override
- public List getCourses() {
- List courseList = em.createNamedQuery("selectAll").getResultList();
-
- return courseList.stream().
- map(c->new CourseDomain(c.getId(),c.getName(),c.getDescription(),c.getCourseNr())).
- collect(Collectors.toList());
- }
-
- @Override
- public List getCoursesContaining(String filter) {
- List courseList = em.createNamedQuery("selectSome").setParameter("filt",filter).getResultList();
-
- return courseList.stream().
- map(c->new CourseDomain(c.getId(),c.getName(),c.getDescription(),c.getCourseNr())).
- collect(Collectors.toList());
- }
-
-}
diff --git a/src/main/java/com/rotanareg/skolan/Role.java b/src/main/java/com/rotanareg/skolan/Role.java
index 070e1ae..2601485 100644
--- a/src/main/java/com/rotanareg/skolan/Role.java
+++ b/src/main/java/com/rotanareg/skolan/Role.java
@@ -10,9 +10,9 @@ public enum Role {
public String toString() {
switch (this) {
case STUDENT:
- return "Student";
+ return "StudentJAS";
case TEACHER:
- return "Teacher";
+ return "TeacherJAS";
case ADMIN:
return "Admin";
}
diff --git a/src/main/java/com/rotanareg/skolan/course/Course.java b/src/main/java/com/rotanareg/skolan/course/Course.java
deleted file mode 100644
index 8b1f8f9..0000000
--- a/src/main/java/com/rotanareg/skolan/course/Course.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.rotanareg.skolan.course;
-import java.io.Serializable;
-
-public final class Course implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private final long id;
- private final String name;
- private final String description;
-
-public Course (long id, String name, String description){
- this.id = id;
- this.name = name;
- this.description = description;
-}
- public long getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-}
diff --git a/src/main/java/com/rotanareg/skolan/course/CourseDetails.java b/src/main/java/com/rotanareg/skolan/course/CourseDetails.java
deleted file mode 100644
index 17b1146..0000000
--- a/src/main/java/com/rotanareg/skolan/course/CourseDetails.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.rotanareg.skolan.course;
-
-import javax.faces.view.ViewScoped;
-import javax.inject.Inject;
-import javax.inject.Named;
-import java.io.Serializable;
-
-@Named
-@ViewScoped
-public class CourseDetails implements Serializable{
- private static final long serialVersionUID = 1L;
-
- @Inject
- private CourseService courseService;
-
- private long courseId;
-
- private Course course;
-
- public long getCourseId() {
- return courseId;
- }
-
- public void setCourseId(long courseId) {
- this.courseId = courseId;
- }
-
- public void onload() {
- course = courseService.getCourse(courseId);
- }
-
- //public course getCourse() {
- // return course;
- //}
-}
\ No newline at end of file
diff --git a/src/main/java/com/rotanareg/skolan/course/CourseService.java b/src/main/java/com/rotanareg/skolan/course/CourseService.java
deleted file mode 100644
index 7e0ed37..0000000
--- a/src/main/java/com/rotanareg/skolan/course/CourseService.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.rotanareg.skolan.course;
-import java.util.List;
-
-public interface CourseService {
- List getMostStudiedCourses ();
- Course getCourse (long id);
-}
diff --git a/src/main/java/com/rotanareg/skolan/course/CourseServiceImpl.java b/src/main/java/com/rotanareg/skolan/course/CourseServiceImpl.java
deleted file mode 100644
index 15f2595..0000000
--- a/src/main/java/com/rotanareg/skolan/course/CourseServiceImpl.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.rotanareg.skolan.course;
-
-import javax.enterprise.context.ApplicationScoped;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@ApplicationScoped
-public class CourseServiceImpl implements CourseService {
-
- private final Map courses;
-
- private final List mostStudiedCourses;
-
- public CourseServiceImpl (){
- Map map = new HashMap<>();
- map.put(1L, new Course(1L,"Design och konstruktion av grafiska gränssnitt","Kursen innehåller en genomgång av standardklasserna i ett välutvecklat grafiskt bibliotek, en översikt över vilka riktlinjer som krävs för att skapa lättanvända gränssnitt samt metoder för att iterativt utveckla och förbättra ett gränssnitt. Kursen ger praktisk erfarenhet i implementering samt användbarhet genom ett grupprojekt som ger en fördjupning av delmomentet kring grafiska komponenter från kursen Objektorienterad programvaruutveckling. Projektets mål är att utveckla en applikation för en specifik användargrupp och att genom att låta dessa testa programmet iterativt förbättra det."));
- map.put(2L, new Course(2L," Objektorienterad programmering","Grundläggande begrepp i objektorienterad programutveckling. Vad som skiljer det objektorienterade synsättet från andra synsätt.I kursen används programspråket Java. Momenten så som objekt och klass, datainkapsling,konstruktorer, metoder, instansvariabler, klassvariabler behandals men även modularisering av program, användning av dokumentation för standardbibliotek, användning av standardklasser för datasamlingar samt kodningsstandard, namnsättning och kommentering. Testning av program också ingår i kursen och det behandlas även arv, dynamisk bindning och polymorfism, abstrakta klasser och gränssnitt, grafiska användargränssnitt, händelser och lyssnare."));
- map.put(3L, new Course(3L,"Datastrukturer","Abstrakta datatyper. Enkel komplexitetsanalys. Vanliga datastrukturer som fält, listor, träd och hashtabeller samt hur dessa kan användas för att implementera abstrakta datatyper som köer, prioritetsköer, lexika och grafer. Standardalgoritmer för dessa datastrukturer och deras resurskrav. Iteratorer. Sorteringsalgoritmer. Standardbibliotek för datastrukturer och algoritmer."));
-
- courses =Collections.unmodifiableMap(map);
- mostStudiedCourses = Collections.unmodifiableList(new ArrayList<>(courses.values()));
-
-}
- @Override
- public List getMostStudiedCourses() {
- return mostStudiedCourses;
- }
- @Override
- public Course getCourse (long id) {
- return courses.get(id);
-
- }
-}
diff --git a/src/main/java/com/rotanareg/skolan/course/MostStudiedCourses.java b/src/main/java/com/rotanareg/skolan/course/MostStudiedCourses.java
deleted file mode 100644
index be78cec..0000000
--- a/src/main/java/com/rotanareg/skolan/course/MostStudiedCourses.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.rotanareg.skolan.course;
-
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.inject.Named;
-import java.util.List;
-
-@Named
-@RequestScoped
-public class MostStudiedCourses {
-
- @Inject
- private com.rotanareg.skolan.course.CourseService courseService;
-
- private List courses;
-
- @PostConstruct
- public void initialize() {
- courses = courseService.getMostStudiedCourses ();
- }
-
- public List getCourses() {
- return courses;
- }
-}
diff --git a/src/main/java/Java/jpa/Course.java b/src/main/java/com/rotanareg/skolan/coursePersist/CourseEntity.java
similarity index 81%
rename from src/main/java/Java/jpa/Course.java
rename to src/main/java/com/rotanareg/skolan/coursePersist/CourseEntity.java
index a703208..0c23c04 100644
--- a/src/main/java/Java/jpa/Course.java
+++ b/src/main/java/com/rotanareg/skolan/coursePersist/CourseEntity.java
@@ -1,4 +1,4 @@
-package jpa;
+package com.rotanareg.skolan.coursePersist;
import javax.persistence.*;
@@ -6,11 +6,12 @@ import javax.persistence.*;
* Created by Solidbeans on 2017-03-20.
*/
@Entity
+@Table(name = "Course")
@NamedQueries({
- @NamedQuery(name="selectAll",query="SELECT c FROM Course c"),
- @NamedQuery(name="selectSome",query="SELECT t FROM Course t WHERE LOCATE(:filt,t.name) OR LOCATE(:filt,t.courseNr) >0 ")
+ @NamedQuery(name="selectAll",query="SELECT c FROM CourseEntity c"),
+ @NamedQuery(name="selectSome",query="SELECT t FROM CourseEntity t WHERE LOCATE(:filt,t.name) >0 ")
})
-public class Course {
+public class CourseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@@ -20,10 +21,10 @@ public class Course {
private String description;
private String courseNr;
- public Course() {
+ public CourseEntity() {
}
- public Course(String name, String description, String courseNr) {
+ public CourseEntity(String name, String description, String courseNr) {
this.name = name;
this.description = description;
this.courseNr = courseNr;
diff --git a/src/main/java/com/rotanareg/skolan/coursePersist/CourseService.java b/src/main/java/com/rotanareg/skolan/coursePersist/CourseService.java
new file mode 100644
index 0000000..6769a80
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/coursePersist/CourseService.java
@@ -0,0 +1,20 @@
+package com.rotanareg.skolan.coursePersist;
+
+import com.rotanareg.skolan.domains.Course;
+
+import javax.ejb.Local;
+import java.util.List;
+
+/**
+ * Created by Solidbeans on 2017-03-20.
+ */
+@Local
+public interface CourseService {
+
+ void addCourse(Course course);
+ void updateCourse(Course course);
+ void removeCourse(Long id);
+ Course getCourse(Long id);
+ List getCourses();
+ public List getCoursesContaining(String filter);
+}
diff --git a/src/main/java/com/rotanareg/skolan/coursePersist/CourseServiceImpl.java b/src/main/java/com/rotanareg/skolan/coursePersist/CourseServiceImpl.java
new file mode 100644
index 0000000..2cbf259
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/coursePersist/CourseServiceImpl.java
@@ -0,0 +1,81 @@
+package com.rotanareg.skolan.coursePersist;
+
+import com.rotanareg.skolan.domains.Course;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * Created by Solidbeans on 2017-03-20.
+ */
+
+@Stateless
+public class CourseServiceImpl implements CourseService{
+ @PersistenceContext
+ EntityManager em;
+
+ @Override
+ public void addCourse(Course course) {
+ CourseEntity c = new CourseEntity(course.getName(),course.getDescription(),course.getCourseNr());
+ em.persist(c);
+
+ }
+
+ @Override
+ public void updateCourse(Course course) {
+ CourseEntity c = em.find(CourseEntity.class,course.getId());
+ c.setName(course.getName());
+ c.setDescription(course.getDescription());
+ c.setCourseNr(course.getCourseNr());
+ em.merge(c);
+ }
+
+ @Override
+ public void removeCourse(Long id) {
+ CourseEntity c = em.find(CourseEntity.class, id);
+ em.remove(c);
+ }
+
+ @Override
+ public Course getCourse(Long id) {
+ CourseEntity c = em.find(CourseEntity.class,id);
+ Course cd = new Course(c.getId(),c.getName(),c.getDescription(),c.getCourseNr());
+
+ return cd;
+ }
+
+ @Override
+ public List getCourses() {
+ List courseEntityList = em.createNamedQuery("selectAll").getResultList();
+ if (courseEntityList.isEmpty()){
+ CourseEntity a = new CourseEntity("Engelska",
+ "Du som behärskar engelska kommer långt. Engelska är ett världsspråk och antalet engelsktalande människor i världen ökar ständigt. Men engelska är inte bara samtal. Det är också litteratur att läsa och texter att skriva. Välkommen till oss när du vill förbättra din engelska!",
+ "E1234A");
+ em.persist(a);
+ CourseEntity b = new CourseEntity("Svenska",
+ "Utbildningen är individualiserad och innan antagning sker en intestning. Du kan delta i utbildningen även om du inte har avslutat din Svenska för invandrare, SFI. Korta vägen pågår i 25 veckor och därutöver ingår 5 veckors praktik. Utbildningen utförs av Folkuniversitetet i Umeå i samarbete med Umeå universitet. Det finns möjlighet till individuell förlängning.",
+ "Sv234B");
+ em.persist(b);
+ CourseEntity c = new CourseEntity("allmän datakunskap",
+ "Kom igång och lär dig data från början. Folkuniversitetet är en erfaren data- och IT-utbildare. Vi har kurser för både nybörjare och erfarna dataanvändare, för juniorer såväl som seniorer och inom både allmän datakunskap och enskilda datorprogram.",
+ "DK234C");
+ em.persist(c);
+ }
+ return courseEntityList.stream().
+ map(c->new Course(c.getId(),c.getName(),c.getDescription(),c.getCourseNr())).
+ collect(Collectors.toList());
+ }
+
+ @Override
+ public List getCoursesContaining(String filter) {
+ List courseEntityList = em.createNamedQuery("selectSome").setParameter("filt",filter).getResultList();
+
+ return courseEntityList.stream().
+ map(c->new Course(c.getId(),c.getName(),c.getDescription(),c.getCourseNr())).
+ collect(Collectors.toList());
+ }
+
+}
diff --git a/src/main/java/Java/domain/CourseDomain.java b/src/main/java/com/rotanareg/skolan/domains/Course.java
similarity index 62%
rename from src/main/java/Java/domain/CourseDomain.java
rename to src/main/java/com/rotanareg/skolan/domains/Course.java
index e55da57..98ba738 100644
--- a/src/main/java/Java/domain/CourseDomain.java
+++ b/src/main/java/com/rotanareg/skolan/domains/Course.java
@@ -1,21 +1,21 @@
-package domain;
+package com.rotanareg.skolan.domains;
/**
* Created by Nils Gerstner on 8/20/17.
*/
-public class CourseDomain {
+public class Course {
private long id;
private String name;
private String description;
private String courseNr;
- public CourseDomain(String name, String description, String courseNr){
+ public Course(){
this.name = name;
this.description = description;
this.courseNr = courseNr;
}
- public CourseDomain(long id, String name, String description, String courseNr){
+ public Course(long id, String name, String description, String courseNr){
this.id = id;
this.name = name;
this.description = description;
@@ -53,4 +53,15 @@ public class CourseDomain {
public void setCourseNr(String courseNr) {
this.courseNr = courseNr;
}
+
+ @Override
+ public String toString(){
+ final StringBuilder sbc = new StringBuilder("CourseEntity{");
+ sbc.append("id=").append(id);
+ sbc.append(", courseCode='").append(courseNr).append('\'');
+ sbc.append(", courseTitle='").append(name).append('\'');
+ sbc.append(", description='").append(description).append('\'');
+ sbc.append('}');
+ return sbc.toString();
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/rotanareg/skolan/user/DateB.java b/src/main/java/com/rotanareg/skolan/user/DateB.java
new file mode 100644
index 0000000..81628bf
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/DateB.java
@@ -0,0 +1,21 @@
+package com.rotanareg.skolan.user;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+
+
+public class DateB {
+
+ public static Date date(String s) {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ try {
+ return dateFormat.parse(s);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
+
diff --git a/src/main/java/com/rotanareg/skolan/user/admin/admindomain/AdminDomain.java b/src/main/java/com/rotanareg/skolan/user/admin/admindomain/AdminDomain.java
new file mode 100644
index 0000000..ef27539
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/admin/admindomain/AdminDomain.java
@@ -0,0 +1,4 @@
+package com.rotanareg.skolan.user.admin.admindomain;
+
+public class AdminDomain {
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/admin/adminejb/AdminService.java b/src/main/java/com/rotanareg/skolan/user/admin/adminejb/AdminService.java
new file mode 100644
index 0000000..9c01b9d
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/admin/adminejb/AdminService.java
@@ -0,0 +1,4 @@
+package com.rotanareg.skolan.user.admin.adminejb;
+
+public class AdminService {
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/admin/adminejb/AdminServiceImpl.java b/src/main/java/com/rotanareg/skolan/user/admin/adminejb/AdminServiceImpl.java
new file mode 100644
index 0000000..5ff00e7
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/admin/adminejb/AdminServiceImpl.java
@@ -0,0 +1,4 @@
+package com.rotanareg.skolan.user.admin.adminejb;
+
+public class AdminServiceImpl {
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/admin/adminjpa/Admin.java b/src/main/java/com/rotanareg/skolan/user/admin/adminjpa/Admin.java
new file mode 100644
index 0000000..ada60f2
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/admin/adminjpa/Admin.java
@@ -0,0 +1,4 @@
+package com.rotanareg.skolan.user.admin.adminjpa;
+
+public class Admin {
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/admin/adminjsf/AdminBean.java b/src/main/java/com/rotanareg/skolan/user/admin/adminjsf/AdminBean.java
new file mode 100644
index 0000000..78b5556
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/admin/adminjsf/AdminBean.java
@@ -0,0 +1,4 @@
+package com.rotanareg.skolan.user.admin.adminjsf;
+
+public class AdminBean {
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/student/studentdomain/StudentDomain.java b/src/main/java/com/rotanareg/skolan/user/student/studentdomain/StudentDomain.java
new file mode 100644
index 0000000..b769e07
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/student/studentdomain/StudentDomain.java
@@ -0,0 +1,4 @@
+package com.rotanareg.skolan.user.student.studentdomain;
+
+public class StudentDomain {
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/student/studentejb/StudentService.java b/src/main/java/com/rotanareg/skolan/user/student/studentejb/StudentService.java
new file mode 100644
index 0000000..95a5ea1
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/student/studentejb/StudentService.java
@@ -0,0 +1,4 @@
+package com.rotanareg.skolan.user.student.studentejb;
+
+public class StudentService {
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/student/studentejb/StudentServiceImpl.java b/src/main/java/com/rotanareg/skolan/user/student/studentejb/StudentServiceImpl.java
new file mode 100644
index 0000000..7849f7c
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/student/studentejb/StudentServiceImpl.java
@@ -0,0 +1,4 @@
+package com.rotanareg.skolan.user.student.studentejb;
+
+public class StudentServiceImpl {
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/student/studentjpa/Student.java b/src/main/java/com/rotanareg/skolan/user/student/studentjpa/Student.java
new file mode 100644
index 0000000..6f17e71
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/student/studentjpa/Student.java
@@ -0,0 +1,4 @@
+package com.rotanareg.skolan.user.student.studentjpa;
+
+public class Student {
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/student/studentjsf/StudentBean.java b/src/main/java/com/rotanareg/skolan/user/student/studentjsf/StudentBean.java
new file mode 100644
index 0000000..35747ec
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/student/studentjsf/StudentBean.java
@@ -0,0 +1,5 @@
+package com.rotanareg.skolan.user.student.studentjsf;
+
+public class StudentBean {
+
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/teacher/teacherdomain/TeacherDomain.java b/src/main/java/com/rotanareg/skolan/user/teacher/teacherdomain/TeacherDomain.java
new file mode 100644
index 0000000..f5b9a3f
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/teacher/teacherdomain/TeacherDomain.java
@@ -0,0 +1,4 @@
+package com.rotanareg.skolan.user.teacher.teacherdomain;
+
+public class TeacherDomain {
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/teacher/teacherejb/TeacherServiceImpl.java b/src/main/java/com/rotanareg/skolan/user/teacher/teacherejb/TeacherServiceImpl.java
new file mode 100644
index 0000000..50dac17
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/teacher/teacherejb/TeacherServiceImpl.java
@@ -0,0 +1,4 @@
+package com.rotanareg.skolan.user.teacher.teacherejb;
+
+public class TeacherServiceImpl {
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/teacher/teacherejb/TeaherService.java b/src/main/java/com/rotanareg/skolan/user/teacher/teacherejb/TeaherService.java
new file mode 100644
index 0000000..dff970c
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/teacher/teacherejb/TeaherService.java
@@ -0,0 +1,4 @@
+package com.rotanareg.skolan.user.teacher.teacherejb;
+
+public class TeaherService {
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/teacher/teacherjpa/Teacher.java b/src/main/java/com/rotanareg/skolan/user/teacher/teacherjpa/Teacher.java
new file mode 100644
index 0000000..e1121ac
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/teacher/teacherjpa/Teacher.java
@@ -0,0 +1,4 @@
+package com.rotanareg.skolan.user.teacher.teacherjpa;
+
+public class Teacher {
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/teacher/teacherjsf/TeacherBean.java b/src/main/java/com/rotanareg/skolan/user/teacher/teacherjsf/TeacherBean.java
new file mode 100644
index 0000000..b01aa0a
--- /dev/null
+++ b/src/main/java/com/rotanareg/skolan/user/teacher/teacherjsf/TeacherBean.java
@@ -0,0 +1,4 @@
+package com.rotanareg.skolan.user.teacher.teacherjsf;
+
+public class TeacherBean {
+}
diff --git a/src/main/java/com/rotanareg/skolan/user/EmailAddressValidator.java b/src/main/java/com/rotanareg/skolan/userManager/EmailAddressValidator.java
similarity index 91%
rename from src/main/java/com/rotanareg/skolan/user/EmailAddressValidator.java
rename to src/main/java/com/rotanareg/skolan/userManager/EmailAddressValidator.java
index 755e6d8..4b001b1 100644
--- a/src/main/java/com/rotanareg/skolan/user/EmailAddressValidator.java
+++ b/src/main/java/com/rotanareg/skolan/userManager/EmailAddressValidator.java
@@ -1,4 +1,4 @@
-package com.rotanareg.skolan.user;
+package com.rotanareg.skolan.userManager;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
diff --git a/src/main/java/com/rotanareg/skolan/user/PhoneNumber.java b/src/main/java/com/rotanareg/skolan/userManager/PhoneNumber.java
similarity index 93%
rename from src/main/java/com/rotanareg/skolan/user/PhoneNumber.java
rename to src/main/java/com/rotanareg/skolan/userManager/PhoneNumber.java
index b709b99..1276f3e 100644
--- a/src/main/java/com/rotanareg/skolan/user/PhoneNumber.java
+++ b/src/main/java/com/rotanareg/skolan/userManager/PhoneNumber.java
@@ -1,4 +1,4 @@
-package com.rotanareg.skolan.user;
+package com.rotanareg.skolan.userManager;
import java.io.Serializable;
diff --git a/src/main/java/com/rotanareg/skolan/user/PhoneNumberConverter.java b/src/main/java/com/rotanareg/skolan/userManager/PhoneNumberConverter.java
similarity index 97%
rename from src/main/java/com/rotanareg/skolan/user/PhoneNumberConverter.java
rename to src/main/java/com/rotanareg/skolan/userManager/PhoneNumberConverter.java
index 2e43326..577c0ab 100644
--- a/src/main/java/com/rotanareg/skolan/user/PhoneNumberConverter.java
+++ b/src/main/java/com/rotanareg/skolan/userManager/PhoneNumberConverter.java
@@ -1,4 +1,4 @@
-package com.rotanareg.skolan.user;
+package com.rotanareg.skolan.userManager;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
diff --git a/src/main/java/com/rotanareg/skolan/user/PhoneNumberValidator.java b/src/main/java/com/rotanareg/skolan/userManager/PhoneNumberValidator.java
similarity index 95%
rename from src/main/java/com/rotanareg/skolan/user/PhoneNumberValidator.java
rename to src/main/java/com/rotanareg/skolan/userManager/PhoneNumberValidator.java
index 691d22e..2120eaf 100644
--- a/src/main/java/com/rotanareg/skolan/user/PhoneNumberValidator.java
+++ b/src/main/java/com/rotanareg/skolan/userManager/PhoneNumberValidator.java
@@ -1,4 +1,4 @@
-package com.rotanareg.skolan.user;
+package com.rotanareg.skolan.userManager;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
diff --git a/src/main/java/com/rotanareg/skolan/user/SignIn.java b/src/main/java/com/rotanareg/skolan/userManager/SignIn.java
similarity index 80%
rename from src/main/java/com/rotanareg/skolan/user/SignIn.java
rename to src/main/java/com/rotanareg/skolan/userManager/SignIn.java
index ec31961..3fccb61 100644
--- a/src/main/java/com/rotanareg/skolan/user/SignIn.java
+++ b/src/main/java/com/rotanareg/skolan/userManager/SignIn.java
@@ -1,5 +1,4 @@
-package com.rotanareg.skolan.user;
-
+package com.rotanareg.skolan.userManager;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
@@ -13,13 +12,12 @@ public class SignIn {
@Inject
private UserManager userManager;
- @Pattern(regexp = "[A-Za-z0-9]{2,20}", message = "Användarnamnet skall innehålla bara bokstäver och siffror samt vara långt mellan 2 och 20 tecken.")
+ @Pattern(regexp = "[A-Za-z0-9]{2,20}", message = "Användarnamnet skall innehålla bara bokstäver och siffror samt vara långt mellan 2 och 20 tecken.")
private String username;
@Size(min = 8, message = "Ditt password måste innehålla minst 8 tecken.")
private String password;
-
public String getUsername() {
return username;
}
diff --git a/src/main/java/com/rotanareg/skolan/user/User.java b/src/main/java/com/rotanareg/skolan/userManager/User.java
similarity index 69%
rename from src/main/java/com/rotanareg/skolan/user/User.java
rename to src/main/java/com/rotanareg/skolan/userManager/User.java
index be0094a..3d87108 100644
--- a/src/main/java/com/rotanareg/skolan/user/User.java
+++ b/src/main/java/com/rotanareg/skolan/userManager/User.java
@@ -1,27 +1,24 @@
-package com.rotanareg.skolan.user;
+package com.rotanareg.skolan.userManager;
import com.rotanareg.skolan.Role;
+import javax.validation.constraints.Past;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
-import java.io.Serializable;
import java.util.List;
+
public class User implements Serializable {
private static final long serialVersionUID = 1L;
- private String username;
- private String password;
- private String firstName;
- private String lastName;
- private String emailAddress;
- private String phoneNumber;
- private Date birthDate;
private Role role;
private List rolesList;
- public User(){
+ public User() {
rolesList = new ArrayList();
rolesList.add(Role.STUDENT);
rolesList.add(Role.TEACHER);
@@ -29,6 +26,27 @@ public class User implements Serializable {
role = Role.STUDENT; // set the first role as default
}
+ @Pattern(regexp = "[A-Za-z0-9]{2,20}", message = "Skriv in ditt användarnamn mellan 2 och 20 tecken långt, innehållande bokstäver och siffror")
+ private String username;
+
+ @Size(min = 8, message = "Ditt pasword måste innehålla minst 8 tecken")
+ private String password;
+
+ @Size(min = 1, max = 30, message = "Skriv in ditt Förnamn mellan 1 och 30 tecken långt.")
+ private String firstName;
+
+ @Size(min = 1, max = 30, message = "Skriv in ditt Efternamn mellan 1 och 30 tecken långt.")
+ private String lastName;
+
+ @ValidEmailAddress
+ private String emailAddress;
+
+ private PhoneNumber phoneNumber;
+
+ @Past(message = "Ditt födelsedatum måste vara i dåtid .")
+ private Date birthDate;
+
+
public String getUsername() {
return username;
}
@@ -45,6 +63,7 @@ public class User implements Serializable {
this.password = password;
}
+
public String getFirstName() {
return firstName;
}
@@ -58,9 +77,11 @@ public class User implements Serializable {
}
public void setLastName(String lastName) {
+
this.lastName = lastName;
}
+
public String getEmailAddress() {
return emailAddress;
}
@@ -69,11 +90,11 @@ public class User implements Serializable {
this.emailAddress = emailAddress;
}
- public String getPhoneNumber() {
+ public PhoneNumber getPhoneNumber() {
return phoneNumber;
}
- public void setPhoneNumber(String phoneNumber) {
+ public void setPhoneNumber(PhoneNumber phoneNumber) {
this.phoneNumber = phoneNumber;
}
@@ -97,6 +118,6 @@ public class User implements Serializable {
return rolesList;
}
-
}
+
diff --git a/src/main/java/com/rotanareg/skolan/user/UserDetail.java b/src/main/java/com/rotanareg/skolan/userManager/UserDetail.java
similarity index 93%
rename from src/main/java/com/rotanareg/skolan/user/UserDetail.java
rename to src/main/java/com/rotanareg/skolan/userManager/UserDetail.java
index 5a3fa93..807f288 100644
--- a/src/main/java/com/rotanareg/skolan/user/UserDetail.java
+++ b/src/main/java/com/rotanareg/skolan/userManager/UserDetail.java
@@ -1,4 +1,4 @@
-package com.rotanareg.skolan.user;
+package com.rotanareg.skolan.userManager;
import javax.faces.view.ViewScoped;
diff --git a/src/main/java/com/rotanareg/skolan/user/UserManager.java b/src/main/java/com/rotanareg/skolan/userManager/UserManager.java
similarity index 63%
rename from src/main/java/com/rotanareg/skolan/user/UserManager.java
rename to src/main/java/com/rotanareg/skolan/userManager/UserManager.java
index fd0d5c5..b2ad538 100644
--- a/src/main/java/com/rotanareg/skolan/user/UserManager.java
+++ b/src/main/java/com/rotanareg/skolan/userManager/UserManager.java
@@ -1,14 +1,15 @@
-package com.rotanareg.skolan.user;
+package com.rotanareg.skolan.userManager;
+
+import com.rotanareg.skolan.Role;
import javax.enterprise.context.SessionScoped;
-import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
@Named
-@SessionScoped // Marko jobbar på
+@SessionScoped
public class UserManager implements Serializable {
private static final long serialVersionUID = 1L;
@@ -29,24 +30,29 @@ public class UserManager implements Serializable {
public String signIn(String username, String password) {
User user = userService.getUser(username);
if (user == null || !password.equals(user.getPassword())) {
- FacesContext.getCurrentInstance().addMessage(null,
- new FacesMessage("Skriv in ditt användarnamn och password"));
- return "failure";
+ return "signIn";
}
-
currentUser = user;
- return "success";
+
+ switch (user.getRole()) {
+ case STUDENT:
+ return "student"; // xhtml-page to redirect to when signed in
+ case TEACHER:
+ return "teacher"; // xhtml-page to redirect to when signed in
+ case ADMIN:
+ return "admin"; // xhtml-page to redirect to when signed in
+ }
+ return ""; // should never happen, but redirects to the default xhtml-page
}
public void signOut() {
-
FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
- //return "index?faces-redirect =true";
}
public String save(User user) {
userService.saveUser(user);
currentUser = user;
+
return "index";
}
}
diff --git a/src/main/java/com/rotanareg/skolan/user/UserService.java b/src/main/java/com/rotanareg/skolan/userManager/UserService.java
similarity index 80%
rename from src/main/java/com/rotanareg/skolan/user/UserService.java
rename to src/main/java/com/rotanareg/skolan/userManager/UserService.java
index 721cdf3..f07deea 100644
--- a/src/main/java/com/rotanareg/skolan/user/UserService.java
+++ b/src/main/java/com/rotanareg/skolan/userManager/UserService.java
@@ -1,4 +1,4 @@
-package com.rotanareg.skolan.user;
+package com.rotanareg.skolan.userManager;
public interface UserService {
// get information om användare
diff --git a/src/main/java/com/rotanareg/skolan/user/UserServiceImpl.java b/src/main/java/com/rotanareg/skolan/userManager/UserServiceImpl.java
similarity index 92%
rename from src/main/java/com/rotanareg/skolan/user/UserServiceImpl.java
rename to src/main/java/com/rotanareg/skolan/userManager/UserServiceImpl.java
index 5df98d8..27840ff 100644
--- a/src/main/java/com/rotanareg/skolan/user/UserServiceImpl.java
+++ b/src/main/java/com/rotanareg/skolan/userManager/UserServiceImpl.java
@@ -1,4 +1,4 @@
-package com.rotanareg.skolan.user;
+package com.rotanareg.skolan.userManager;
import javax.enterprise.context.ApplicationScoped;
import java.util.Map;
diff --git a/src/main/java/com/rotanareg/skolan/user/ValidEmailAddress.java b/src/main/java/com/rotanareg/skolan/userManager/ValidEmailAddress.java
similarity index 92%
rename from src/main/java/com/rotanareg/skolan/user/ValidEmailAddress.java
rename to src/main/java/com/rotanareg/skolan/userManager/ValidEmailAddress.java
index 4cb0ed5..994871c 100644
--- a/src/main/java/com/rotanareg/skolan/user/ValidEmailAddress.java
+++ b/src/main/java/com/rotanareg/skolan/userManager/ValidEmailAddress.java
@@ -1,4 +1,4 @@
-package com.rotanareg.skolan.user;
+package com.rotanareg.skolan.userManager;
import javax.validation.Constraint;
import javax.validation.Payload;
diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml
index d67439c..9808c80 100644
--- a/src/main/resources/META-INF/persistence.xml
+++ b/src/main/resources/META-INF/persistence.xml
@@ -9,7 +9,7 @@
false
-
+
-
+
\ No newline at end of file
diff --git a/src/main/webapp/admin.xhtml b/src/main/webapp/admin.xhtml
index 06c7be8..7754f1f 100644
--- a/src/main/webapp/admin.xhtml
+++ b/src/main/webapp/admin.xhtml
@@ -1,32 +1,24 @@
-
+
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
-
-
-
+
+
+
- Registrera nya användare
-
- Registrera nya kurser
+
+
+
+
-
-
-
-
+