signIn madness

PlaygroundDevelopment
Nils Gerstner 7 years ago
parent f6b2adce48
commit 173489a29a

@ -15,7 +15,9 @@
<configuration>
<setting name="validation-enabled" value="true" />
<setting name="provider-name" value="" />
<datasource-mapping />
<datasource-mapping>
<factory-entry name="school" />
</datasource-mapping>
<deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml" />
</configuration>
</facet>
@ -33,7 +35,6 @@
<orderEntry type="library" name="Maven: javax:javaee-api:7.0" level="project" />
<orderEntry type="library" name="Maven: com.sun.mail:javax.mail:1.5.0" level="project" />
<orderEntry type="library" name="Maven: javax.activation:activation:1.1" level="project" />
<orderEntry type="library" name="Maven: org.primefaces:primefaces:6.1" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.persistence:org.eclipse.persistence.jpa:2.6.4" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.persistence:javax.persistence:2.1.1" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.persistence:org.eclipse.persistence.asm:2.6.4" level="project" />
@ -41,5 +42,7 @@
<orderEntry type="library" name="Maven: org.glassfish:javax.json:1.0.4" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:2.6.4" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.persistence:org.eclipse.persistence.core:2.6.4" level="project" />
<orderEntry type="library" name="Maven: postgresql:postgresql:8.1-404.jdbc3" level="project" />
<orderEntry type="library" name="Maven: org.primefaces:primefaces:6.0" level="project" />
</component>
</module>

Binary file not shown.

@ -0,0 +1,16 @@
F<EFBFBD>r att skapa connection poolen och resursen jdbc/school,
k<EFBFBD>r f<>ljande kommando i asadmin
(OBS: ni m<>ste eventuellt anpassa l<>senordet...)
-------------------------------------------------------
(Om DB inte igång, skriv: "start-domain" kommando tolken)
create-jdbc-connection-pool --datasourceclassname org.postgresql.ds.PGSimpleDataSource --restype javax.sql.XADataSource --property portNumber=5432:password=LexiconJava:user=postgres:serverName=localhost:databaseName=school jpa_school_postgresql_pool
create-jdbc-resource --connectionpoolid jpa_school_postgresql_pool jdbc/school
stop-domain

@ -36,18 +36,25 @@
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.persistence/org.eclipse.persistence.jpa -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.6.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/postgresql/postgresql -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.1-404.jdbc3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.primefaces/primefaces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.0</version>
</dependency>
</dependencies>

@ -0,0 +1,73 @@
package com.rotanareg.skolan.AssociatedPersist;
import com.rotanareg.skolan.coursePersist.CourseEntity;
import com.rotanareg.skolan.userPersist.UserEntity;
import javax.persistence.*;
/**
* Created by Nils Gerstner on 2017-08-31.
*/
@Entity
@Table(name="COURSE_USER")
@IdClass(CourseUserAssociationId.class)
public class CourseUserAssociation {
@Id
private long courseId;
@Id
private long personId;
@Column(name="IS_TEACHER")
private boolean isTeacher;
@ManyToOne
@PrimaryKeyJoinColumn(name="COURSEID", referencedColumnName = "ID")
private CourseEntity course;
@ManyToOne
@PrimaryKeyJoinColumn(name="PERSONID", referencedColumnName = "ID")
private UserEntity person;
public long getCourseId() {
return courseId;
}
public void setCourseId(Long courseId) {
this.courseId = courseId;
}
public long getPersonId() {
return personId;
}
public void setPersonId(Long personId) {
this.personId = personId;
}
public boolean isTeacher() {
return isTeacher;
}
public void setTeacher(boolean teacher) {
isTeacher = teacher;
}
public CourseEntity getCourse() {
return course;
}
public void setCourse(CourseEntity course) {
this.course = course;
}
public UserEntity getPerson() {
return person;
}
public void setPerson(UserEntity person) {
this.person = person;
}
}

@ -0,0 +1,25 @@
package com.rotanareg.skolan.AssociatedPersist;
import java.io.Serializable;
/**
* Created by Nils Gerstner on 2017-08-31.
*/
public class CourseUserAssociationId implements Serializable {
private long personId;
private long courseId;
@Override
public int hashCode() {
return (int) (personId + courseId);
}
@Override
public boolean equals(Object o) {
if (o instanceof CourseUserAssociationId) {
CourseUserAssociationId otherId = (CourseUserAssociationId) o;
return (otherId.personId == this.personId) && (otherId.courseId == this.courseId);
}
return false;
}
}

@ -0,0 +1,109 @@
/******************************
* JSF - Managed-Bean, hämta info till/från xhtml filen. (Mellan Back och Front -end.)
******************************/
//TODO: inkludera logik
package com.rotanareg.skolan;
import com.rotanareg.skolan.attendancePersist.*;
import com.rotanareg.skolan.domains.*;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import java.sql.Date;
import java.util.List;
/**
* Created by Marko K. Seppänen.
*/
@ManagedBean
@RequestScoped
public class AttendanceBean {
private Long id;
// private Course course;
// private User user;
private Date sqlDate; //yyyy-mm-dd
private boolean hasAttended;
@EJB
AttendanceService aService;
public String addCourse() {
if (getId() == null) {
aService.addAttendance(new AttendanceDomain(getDate(), isHasAttended()));
}else {
// Update
// aService.updateCourse(new AttendanceDomain(getId(), getDate(), isHasAttended()));
}
setId(null);
setDate(null);
setHasAttended(false);
return "stats_test";
}
/*
public String editCourse(Long id) {
CourseDomain courseDomain = courseService.getCourse(id);
setId(courseDomain.getId());
setName(courseDomain.getName());
setCode(courseDomain.getCode());
return "course";
}
public String removeCourse(Long id) {
courseService.removeCourse(id);
return "course";
}
*/
public List<AttendanceDomain> getAttendances() {
return aService.getAttendances();
}
/*
public List<CourseDomain> getCoursesFilter() {
if (myFilter == null || myFilter.equals(""))
return courseService.getCourses();
else
return courseService.getCoursesNameContain(myFilter);
}
*/
public String getSubmitButton() {
if (id == null)
return "Add";
else
return "Update";
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Date getDate() {
return sqlDate;
}
public void setDate(Date date) {
this.sqlDate = date;
}
public boolean isHasAttended() {
return hasAttended;
}
public void setHasAttended(boolean hasAttended) {
this.hasAttended = hasAttended;
}
public AttendanceService getCourseService() {
return aService;
}
public void setCourseService(AttendanceService courseService) {
this.aService = courseService;
}
}

@ -10,9 +10,9 @@ public enum Role {
public String toString() {
switch (this) {
case STUDENT:
return "StudentJAS";
return "Student";
case TEACHER:
return "TeacherJAS";
return "Teacher";
case ADMIN:
return "Admin";
}

@ -0,0 +1,87 @@
package com.rotanareg.skolan;
import java.util.List;
import com.rotanareg.skolan.domains.User;
import com.rotanareg.skolan.userPersist.*;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class UserBean {
private Long id;
private String name;
private String lastName;
private Role role;
private String passWord;
@EJB
UserService userService;
public String addUser(){
if (getId()==null)
userService.addUser(new User(name,lastName,role));
else
userService.addUser(new User(getId(),getName(),getLastName(),getRole(),getPassWord()));
setId(null);
setName("");
setLastName("");
setRole(null);
setPassWord("");
return "user";
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Role getRole() {
return role;
}
public void setRole(Role role) {
this.role = role;
}
public String getPassWord() {
return passWord;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
public UserService getUserService() {
return userService;
}
public void setUserService(UserService userService) {
this.userService = userService;
}
public UserService getUsers(){
return userService;
}
}

@ -0,0 +1,98 @@
/******************************
* JPA Entity class defines whose instances can be stored in the database.
* The Entity represents your Data Object Model.
******************************/
package com.rotanareg.skolan.attendancePersist;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
//import java.util.*;
import java.sql.Date;
import java.text.DateFormat.*;
import java.text.*;
/**
* Created by Marko K. Seppänen.
*/
/*@NamedQueries({
@NamedQuery(name = "selectAll", query = "SELECT p FROM Course p"),
@NamedQuery(name = "selectSome", query = "SELECT t FROM Course t WHERE LOCATE(:filt,t.name) >0 ")
})*/
@Entity
@Table(name = "Attendance")
@NamedQueries({
@NamedQuery(name = "selectAll", query = "SELECT p FROM AttendanceEntity p"),
//@NamedQuery(name = "selectSome", query = "SELECT t FROM AttendanceEntity t WHERE LOCATE(:filt,t.name) >0 ")
})
public class AttendanceEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
//@NotNull
//private Long courseId;
/* private CourseEntity course;
//@NotNull
//private Long userId;
private UserEntity user;
*/
////@Temporal(TemporalType.DATE)
////@DateFormat(format = "yyyy-MM-dd")
//@NotNull
private Date sqlDate; //yyyy-mm-dd
private boolean hasAttended;
public AttendanceEntity() {
}
public AttendanceEntity(Date date, boolean hasAttended) {
this.sqlDate = date;
this.hasAttended = hasAttended;
}
/* public AttendanceEntity(CourseEntity course, UserEntity user, Date sqlDate, boolean hasAttended) {
this.course = course;
this.user = user;
this.sqlDate = sqlDate;
this.hasAttended = hasAttended;
}
*/
public Long getId() {
return id;
}
/* public CourseEntity getCourse() {
return course;
}
public void setCourse(CourseEntity course) {
this.course = course;
}
public UserEntity getUser() {
return user;
}
public void setUser(UserEntity user) {
this.user = user;
}
*/
public Date getDate() {
return sqlDate;
}
public void setDate(Date date) {
this.sqlDate = date;
}
public boolean isHasAttended() {
return hasAttended;
}
public void setHasAttended(boolean hasAttended) {
this.hasAttended = hasAttended;
}
}

@ -0,0 +1,35 @@
/******************************
* EJB - Interface för våran tjänst ("kontrakt" för varje EJB att följa om den vill stödja tjänsten för Attendance)
******************************/
package com.rotanareg.skolan.attendancePersist;
import com.rotanareg.skolan.domains.*;
import javax.ejb.Local;
import java.util.List;
/**
* Created by Marko K. Seppänen.
*/
@Local
public interface AttendanceService {
// (C)reate / add.
void addAttendance(AttendanceDomain attendance);
/*
// (R)ead / get.
AttendanceDomain getAttendance(Long id);
// (U)pdate.
void updateAttendance(AttendanceDomain attendance);
// (D)elete.
void deleteAttendance(Long id);
*/
List<AttendanceDomain> getAttendances();
/*
public List<CourseDomain> getCoursesNameContain(String filter);
*/
}

@ -0,0 +1,92 @@
/******************************
* EJB - Enterprise bean (EJB), som stödjer tjänsten AttendanceService.
******************************/
package com.rotanareg.skolan.attendancePersist;
import com.rotanareg.skolan.domains.*;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.sql.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* Created by Marko K. Seppänen.
*/
@Stateless
public class AttendanceServiceImpl implements AttendanceService {
@PersistenceContext
EntityManager em;
// (C)reate / add.
@Override
public void addAttendance(AttendanceDomain ad){
AttendanceEntity dom = new AttendanceEntity(ad.getDate(), ad.isHasAttended()); // Create the Data Object Model
em.persist(dom);
}
// (R)ead / get.
/* @Override
public AttendanceDomain getAttendance(Long id){
Course c = em.find(Course.class, id);
return new CourseDomain(c.getId(), c.getName(), c.getCode());
}
// (U)pdate.
@Override
public void updateAttendance(AttendanceDomain attendance){
Course c = em.find(Course.class, course.getId());
c.setName(course.getName());
c.setCode(course.getCode());
em.merge(c);
}
// (D)elete.
@Override
public void deleteAttendance(Long id){
Course c = em.find(Course.class, id);
em.remove(c);
}
*/
@Override
public List<AttendanceDomain> getAttendances() {
/*Query query = em.createQuery("select a from Course a where a.code = :lname and a.name = :fname", Course.class);
query.setParameter("lname", "Karlsson");
query.setParameter("fname", "Kalle");
*/
/*Query query = em.createQuery("select a from Attendance a where a.code = :lname and a.name = :fname", AttendanceEntity.class);
query.setParameter("lname", "Karlsson");
query.setParameter("fname", "Kalle");
*/
//List<CourseEntity> courseEntityList = em.createNamedQuery("selectAllCourses").getResultList();
/*
List<AttendanceEntity> courseRecords = query.getResultList();
System.out.println("course Size " + courseRecords.size());
*/
List<AttendanceEntity> l = em.createNamedQuery("selectAll").getResultList();
return l.stream().
map(a -> new AttendanceDomain(a.getId(), a.getDate(), a.isHasAttended())).
collect(Collectors.toList());
}
/*
@Override
public List<CourseDomain> getCoursesNameContain(String filter) {
List<Course> l = em.createNamedQuery("selectSome").setParameter("filt", filter).getResultList();
return l.stream().
map(p -> new CourseDomain(p.getId(), p.getName(), p.getCode())).
collect(Collectors.toList());
}
*/
}

@ -1,23 +1,21 @@
package com.rotanareg.skolan.coursePersist;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
/**
* Created by Solidbeans on 2017-03-20.
*/
import com.rotanareg.skolan.AssociatedPersist.CourseUserAssociation;
import com.rotanareg.skolan.Role;
import com.rotanareg.skolan.userPersist.UserEntity;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "Course")
@NamedQueries({
@NamedQuery(name="selectAll",query="SELECT c FROM CourseEntity c"),
@NamedQuery(name="selectSome",query="SELECT t FROM CourseEntity t WHERE LOCATE(:filt,t.name) >0 ")
@NamedQuery(name="selectAllCourses",query="SELECT c FROM CourseEntity c"),
@NamedQuery(name="selectSomeCourses",query="SELECT t FROM CourseEntity t WHERE LOCATE(:filt,t.name) >0 ")
})
public class CourseEntity {
@ -30,6 +28,9 @@ public class CourseEntity {
private String description;
private String courseNr;
@OneToMany(mappedBy="course")
private List<CourseUserAssociation> persons;
public CourseEntity() {
}
@ -70,4 +71,27 @@ public class CourseEntity {
public void setCourseNr(String courseNr) {
this.courseNr = courseNr;
}
public List<CourseUserAssociation> getPersons() {
return persons;
}
public void addPerson (UserEntity person, boolean isTeacher) {
CourseUserAssociation courseUserAssociation = new CourseUserAssociation();
if (person.getRole() == Role.ADMIN) {
System.out.println("Nor TEACHER or STUDENT; not added!");
} else {
if (isTeacher && person.getRole() == Role.TEACHER)
courseUserAssociation.setTeacher(true);
else if (!isTeacher && person.getRole() != Role.STUDENT)
courseUserAssociation.setTeacher(false);
courseUserAssociation.setPerson(person);
courseUserAssociation.setCourse(this);
courseUserAssociation.setPersonId(person.getId());
courseUserAssociation.setCourseId(this.getId());
if (this.persons == null)
this.persons = new ArrayList<>();
this.persons.add(courseUserAssociation);
}
}
}

@ -1,12 +1,11 @@
package com.rotanareg.skolan.coursePersist;
import java.util.List;
import javax.ejb.Local;
import com.rotanareg.skolan.domains.Course;
/**
* Created by Solidbeans on 2017-03-20.
*/
import javax.ejb.Local;
import java.util.List;
@Local
public interface CourseService {

@ -8,9 +8,6 @@ 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{
@ -49,7 +46,7 @@ public class CourseServiceImpl implements CourseService{
@Override
public List<Course> getCourses() {
List<CourseEntity> courseEntityList = em.createNamedQuery("selectAll").getResultList();
List<CourseEntity> courseEntityList = em.createNamedQuery("selectAllCourses").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!",
@ -71,7 +68,7 @@ public class CourseServiceImpl implements CourseService{
@Override
public List<Course> getCoursesContaining(String filter) {
List<CourseEntity> courseEntityList = em.createNamedQuery("selectSome").setParameter("filt",filter).getResultList();
List<CourseEntity> courseEntityList = em.createNamedQuery("selectSomeCourses").setParameter("filt",filter).getResultList();
return courseEntityList.stream().
map(c->new Course(c.getId(),c.getName(),c.getDescription(),c.getCourseNr())).

@ -0,0 +1,80 @@
/******************************
* POJO - Mellanskikt mellan AttendanceBean (vanlig böna) och EJB (Enterprise-böna), samt JPA (transformerings-klass).
* Inkapslings-klass (hjälp-klass) för att underlätta transporten av data mellan objekt.
******************************/
package com.rotanareg.skolan.domains;
import java.sql.Date;
/**
* Created by Marko K. Seppänen.
*/
public class AttendanceDomain {
private Long id;
// private Course course;
// private User user;
private Date sqlDate; //yyyy-mm-dd
private boolean hasAttended;
public AttendanceDomain(Date date, boolean hasAttended) {
this.sqlDate = date;
this.hasAttended = hasAttended;
}
public AttendanceDomain(Long id, Date date, boolean hasAttended) {
this.id = id;
this.sqlDate = date;
this.hasAttended = hasAttended;
}
/* public AttendanceDomain(Long id, Course course, User user, Date date, boolean hasAttended) {
this.id = id;
this.courseId = courseId;
this.userId = userId;
this.sqlDate = date;
this.hasAttended = hasAttended;
}
*/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/* public Course getCourse() {
return course;
}
public void setCourse(Course course) {
this.course = course;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
*/
public Date getDate() {
return sqlDate;
}
public void setDate(Date date) {
this.sqlDate = sqlDate;
}
public boolean isHasAttended() {
return hasAttended;
}
public void setHasAttended(boolean hasAttended) {
this.hasAttended = hasAttended;
}
}

@ -1,5 +1,11 @@
package com.rotanareg.skolan.domains;
import com.rotanareg.skolan.AssociatedPersist.CourseUserAssociation;
import com.rotanareg.skolan.userPersist.UserEntity;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Nils Gerstner on 8/20/17.
*/
@ -9,6 +15,7 @@ public class Course {
private String name;
private String description;
private String courseNr;
private List<CourseUserAssociation> persons;
public Course(String name, String description, String courseNr){
this.name = name;
@ -55,6 +62,14 @@ public class Course {
this.courseNr = courseNr;
}
public List<CourseUserAssociation> getPersons() {
return persons;
}
public void setPersons(List<CourseUserAssociation> persons) {
this.persons = persons;
}
@Override
public String toString(){
final StringBuilder sbc = new StringBuilder("CourseEntity{");

@ -0,0 +1,26 @@
package com.rotanareg.skolan.signIn;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
import java.io.Serializable;
/**
* Created by Nils Gerstner on 2017-09-01.
*/
@Named
@SessionScoped
public class LoggedIn implements Serializable {
private Long id = null;
public LoggedIn() {
}
public LoggedIn(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
}

@ -0,0 +1,49 @@
package com.rotanareg.skolan.signIn;
import javax.ejb.EJB;
import javax.enterprise.context.*;
import javax.inject.*;
import com.rotanareg.skolan.userPersist.UserService;
@Named
@RequestScoped
public class SignIn {
@Inject
private LoggedIn loggedIn;
@EJB
private UserService us;
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public void setPassword(String password) {
this.password = password;
}
public void submit() {
if (us.getUserContaining(username).get(0).getPassWord().equals(password)){
this.loggedIn = new LoggedIn(us.getUserContaining(username).get(0).getId());
}
}
public boolean loggedIn(){
if (loggedIn != null)
return true;
return false;
}
public void logout(){
this.loggedIn = null;
}
}

@ -1,21 +0,0 @@
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;
}
}

@ -1,4 +0,0 @@
package com.rotanareg.skolan.user.admin.admindomain;
public class AdminDomain {
}

@ -1,4 +0,0 @@
package com.rotanareg.skolan.user.admin.adminejb;
public class AdminService {
}

@ -1,4 +0,0 @@
package com.rotanareg.skolan.user.admin.adminejb;
public class AdminServiceImpl {
}

@ -1,4 +0,0 @@
package com.rotanareg.skolan.user.admin.adminjpa;
public class Admin {
}

@ -1,4 +0,0 @@
package com.rotanareg.skolan.user.admin.adminjsf;
public class AdminBean {
}

@ -1,4 +0,0 @@
package com.rotanareg.skolan.user.student.studentdomain;
public class StudentDomain {
}

@ -1,4 +0,0 @@
package com.rotanareg.skolan.user.student.studentejb;
public class StudentService {
}

@ -1,4 +0,0 @@
package com.rotanareg.skolan.user.student.studentejb;
public class StudentServiceImpl {
}

@ -1,4 +0,0 @@
package com.rotanareg.skolan.user.student.studentjpa;
public class Student {
}

@ -1,5 +0,0 @@
package com.rotanareg.skolan.user.student.studentjsf;
public class StudentBean {
}

@ -1,4 +0,0 @@
package com.rotanareg.skolan.user.teacher.teacherdomain;
public class TeacherDomain {
}

@ -1,4 +0,0 @@
package com.rotanareg.skolan.user.teacher.teacherejb;
public class TeacherServiceImpl {
}

@ -1,4 +0,0 @@
package com.rotanareg.skolan.user.teacher.teacherejb;
public class TeaherService {
}

@ -1,4 +0,0 @@
package com.rotanareg.skolan.user.teacher.teacherjpa;
public class Teacher {
}

@ -1,4 +0,0 @@
package com.rotanareg.skolan.user.teacher.teacherjsf;
public class TeacherBean {
}

@ -1,20 +0,0 @@
package com.rotanareg.skolan.userManager;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class EmailAddressValidator implements ConstraintValidator<ValidEmailAddress, String> {
@Override
public void initialize(ValidEmailAddress constraintAnnotation) {
}
@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
return value == null || value.equals("") || value.contains("@");
}
}

@ -1,28 +0,0 @@
package com.rotanareg.skolan.userManager;
import java.io.Serializable;
public class PhoneNumber implements Serializable {
private static final long serialVersionUID = 1L;
private String countryCode;
private String subscriberNumber;
public String getCountryCode() {
return countryCode;
}
public void setCountryCode(String countryCode) {
this.countryCode = countryCode;
}
public String getSubscriberNumber() {
return subscriberNumber;
}
public void setSubscriberNumber(String subscriberNumber) {
this.subscriberNumber = subscriberNumber;
}
}

@ -1,45 +0,0 @@
package com.rotanareg.skolan.userManager;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
import java.util.regex.Pattern;
@FacesConverter(forClass = PhoneNumber.class)
public class PhoneNumberConverter implements Converter {
private static final Pattern PHONE_NUMBER_PATTERN = Pattern.compile("[0-8]{2}-[0-8]{3}-[0-8]{3}");
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
if (value == null || value.equals("")) {
return null;
}
if (!PHONE_NUMBER_PATTERN.matcher(value).matches()) {
throw new ConverterException(
new FacesMessage("Fyll i det rätta formen på telefonummer: 00-000-000."));
}
PhoneNumber phoneNumber = new PhoneNumber();
phoneNumber.setCountryCode(value.substring(0, 2));
phoneNumber.setSubscriberNumber(value.substring(3));
return phoneNumber;
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if (value == null) {
return null;
}
PhoneNumber phoneNumber = (PhoneNumber) value;
return phoneNumber.getCountryCode() + "-" + phoneNumber.getSubscriberNumber();
}
}

@ -1,33 +0,0 @@
package com.rotanareg.skolan.userManager;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
@FacesValidator("com.rotanareg.skolan.user.PhoneNumber")
public class PhoneNumberValidator implements Validator {
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
PhoneNumber phoneNumber = (PhoneNumber) value;
if (phoneNumber != null) {
checkCountryCode(phoneNumber.getCountryCode());
}
}
private void checkCountryCode(String countryCode) {
int firstDigit = Character.digit(countryCode.charAt(0), 10);
if (firstDigit == 0 || firstDigit == 1) {
throw new ValidatorException(
new FacesMessage("Första siffran i ditt tfn får inte vara 0 or 1."));
}
}
}

@ -1,40 +0,0 @@
package com.rotanareg.skolan.userManager;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
@Named
@RequestScoped
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.")
private String username;
@Size(min = 8, message = "Ditt password måste innehålla minst 8 tecken.")
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String submit() {
return userManager.signIn(username, password);
}
}

@ -1,123 +0,0 @@
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.util.List;
public class User implements Serializable {
private static final long serialVersionUID = 1L;
private Role role;
private List<Role> rolesList;
public User() {
rolesList = new ArrayList();
rolesList.add(Role.STUDENT);
rolesList.add(Role.TEACHER);
rolesList.add(Role.ADMIN);
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;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmailAddress() {
return emailAddress;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
public PhoneNumber getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(PhoneNumber phoneNumber) {
this.phoneNumber = phoneNumber;
}
public Date getBirthDate() {
return birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
public Role getRole() {
return role;
}
public void setRole(Role role) {
this.role = role;
}
public List<Role> getRolesList() {
return rolesList;
}
}

@ -1,30 +0,0 @@
package com.rotanareg.skolan.userManager;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
@Named
@ViewScoped
public class UserDetail implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private UserManager userManager;
private User user;
public User getUser() {
return user;
}
public void onload() {
user = userManager.isSignedIn() ? userManager.getCurrentUser() : new User();
}
public String submit() {
return userManager.save(user);
}
}

@ -1,60 +0,0 @@
package com.rotanareg.skolan.userManager;
import com.rotanareg.skolan.Role;
import javax.enterprise.context.SessionScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
@Named
@SessionScoped
public class UserManager implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private UserService userService;
private User currentUser;
public boolean isSignedIn() {
return currentUser != null;
}
public User getCurrentUser() {
return currentUser;
}
public String signIn(String username, String password) {
User user = userService.getUser(username);
if (user == null || !password.equals(user.getPassword())) {
return "signIn";
}
currentUser = user;
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();
}
public String save(User user) {
userService.saveUser(user);
currentUser = user;
return "index";
}
}

@ -1,9 +0,0 @@
package com.rotanareg.skolan.userManager;
public interface UserService {
// get information om användare
User getUser(String username);
// spara information om användare
void saveUser(User user);
}

@ -1,23 +0,0 @@
package com.rotanareg.skolan.userManager;
import javax.enterprise.context.ApplicationScoped;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ApplicationScoped // skall stored i databas
public class UserServiceImpl implements UserService {
private final Map<String, User> users = new ConcurrentHashMap<>();
@Override
public User getUser(String username) {
return users.get(username);
}
@Override
public void saveUser(User user) {
users.put(user.getUsername(), user);
}
}

@ -1,20 +0,0 @@
package com.rotanareg.skolan.userManager;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Constraint(validatedBy = EmailAddressValidator.class)
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ValidEmailAddress {
String message() default "Skriv din rätta e-mail adressen.";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}

@ -1,16 +1,19 @@
package com.rotanareg.skolan.userPersist;
import javax.persistence.*;
import com.rotanareg.skolan.AssociatedPersist.CourseUserAssociation;
import com.rotanareg.skolan.Role;
import com.rotanareg.skolan.coursePersist.CourseEntity;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Solidbeans on 2017-03-20.
*/
@Entity
@Table(name = "Person")
@NamedQueries({
@NamedQuery(name="selectAll",query="SELECT u FROM UserEntity u"),
@NamedQuery(name="selectSome",query="SELECT t FROM UserEntity t WHERE LOCATE(:filt,t.name) >0 ")
@NamedQuery(name="selectAllUsers",query="SELECT u FROM UserEntity u"),
@NamedQuery(name="selectSomeUsers",query="SELECT t FROM UserEntity t WHERE LOCATE(:filt,t.name) >0 ")
})
public class UserEntity {
@ -23,6 +26,9 @@ public class UserEntity {
private String lastName;
private String passWord;
@OneToMany(mappedBy = "person")
private List<CourseUserAssociation> courses;
public UserEntity() {
}
@ -72,4 +78,27 @@ public class UserEntity {
public String getPassWord() {
return passWord;
}
public List<CourseUserAssociation> getCourses() {
return courses;
}
public void addCourse (CourseEntity course, boolean isTeacher) {
CourseUserAssociation courseUserAssociation = new CourseUserAssociation();
if (this.getRole() == Role.ADMIN) {
System.out.println("Nor TEACHER or STUDENT; not added!");
} else {
if (isTeacher && this.getRole() == Role.TEACHER)
courseUserAssociation.setTeacher(true);
else if (!isTeacher && this.getRole() != Role.STUDENT)
courseUserAssociation.setTeacher(false);
courseUserAssociation.setPerson(this);
courseUserAssociation.setCourse(course);
courseUserAssociation.setPersonId(this.getId());
courseUserAssociation.setCourseId(course.getId());
if (this.courses == null)
this.courses = new ArrayList<>();
this.courses.add(courseUserAssociation);
}
}
}

@ -5,9 +5,7 @@ import com.rotanareg.skolan.domains.User;
import javax.ejb.Local;
import java.util.List;
/**
* Created by Solidbeans on 2017-03-20.
*/
@Local
public interface UserService {
@ -15,6 +13,6 @@ public interface UserService {
void updateUser(User user);
void removeUser(Long id);
User getUser(Long id);
List<User> getUser();
List<User> getUsers();
public List<User> getUserContaining(String filter);
}

@ -9,9 +9,7 @@ import javax.persistence.PersistenceContext;
import java.util.List;
import java.util.stream.Collectors;
/**
* Created by Solidbeans on 2017-03-20.
*/
@Stateless
public class UserServiceImpl implements UserService{
@ -47,8 +45,8 @@ public class UserServiceImpl implements UserService{
return ud;
}
@Override
public List<User> getUser() {
List<UserEntity> userEntityList = em.createNamedQuery("selectAll").getResultList();
public List<User> getUsers() {
List<UserEntity> userEntityList = em.createNamedQuery("selectAllUsers").getResultList();
if (userEntityList.isEmpty()){
UserEntity a = new UserEntity("Nils","Gerstner",Role.STUDENT,"1234");
em.persist(a);
@ -65,7 +63,7 @@ public class UserServiceImpl implements UserService{
@Override
public List<User> getUserContaining(String filter) {
List<UserEntity> userEntityList = em.createNamedQuery("selectSome").setParameter("filt",filter).getResultList();
List<UserEntity> userEntityList = em.createNamedQuery("selectSomeUsers").setParameter("filt",filter).getResultList();
return userEntityList.stream().
map(c->new User(c.getId(),c.getName(),c.getLastName(),c.getRole(),c.getPassWord())).

@ -4,12 +4,16 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="Persistence-unit" transaction-type="JTA">
<jta-data-source>jdbc/school</jta-data-source>
<persistence-unit name="school" transaction-type="JTA"> <!--same name as in emf definition-->
<jta-data-source>jdbc/school</jta-data-source> <!--This resource has to be added to GlassFish-->
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<!-- <property name="javax.persistence.schema-generation.database.action" value="create"/> -->
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
</persistence-unit>
</persistence>

@ -3,5 +3,20 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
<navigation-rule>
<display-name>index.xhtml</display-name>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/pupil1.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<display-name>index.xhtml</display-name>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/index.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>

@ -1,24 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="templates/template_page.xhtml">
<ui:param name="pageTitle" value="Admin sidan"/>
<ui:composition template="/templates/page_template.xhtml">
<ui:param name="pageTitle" value="Admin"/>
<ui:define name = "panel-top">
<ui:define name="panel-top">
<section>
<h:commandButton value="Registrera nya kurser" action="#{course.addCourse()}"/> <!--lägg in inom parantes parameter-->
<h:commandButton value="Registrera nya användare" action="#{user.addUser()}"/> <!--lägg in inom parantes parameter-->
<h:outputLink value="index.xhtml">Logga ut</h:outputLink>
</section>
</ui:define>
<ui:define name="panel-main">
<section>
<h1>Admin</h1>
<h:outputLink value="user_detail.xhtml">Registrera nya användare</h:outputLink>
</section>
</ui:define>
</ui:composition>
</html>

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<h:outputLabel value="Hello, world"/>
</f:view>
</html>

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="templates/page_template.xhtml">
<f:metadata>
<f:viewParam name ="courseId" value="#{courseDetail.courseId}"/>
<f:viewAction action="#{courseDetail.onload}"/>
</f:metadata>
<ui:param name="pageTitle" value="Course Details"/>
<ui:define name="panel-main">
<section class="course_detail">
<h:form>
<h1>#{course.name}</h1>
<p> </p>
</h:form>
</section>
</ui:define>
</ui:composition>
</html>

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
@ -8,16 +8,16 @@
<ui:composition template="templates/template_page.xhtml">
<f:metadata>
<f:viewParam name ="courseId" value="#{course.Id}"/>
<f:viewAction action="#{course.onload}"/>
<f:viewParam name="courseId" value="#{courseDetails.courseId}"/>
<f:viewAction action="#{courseDetails.onload}"/>
</f:metadata>
<ui:param name="pageTitle" value="Course Details"/>
<ui:define name="panel-main">
<section class="course_details">
<h:form>
<h1>#{course.name}</h1>
<p>#{course.description}</p>
<h1>#{courseDetails.course.name}</h1>
<p>#{courseDetails.course.description}</p>
</h:form>
</section>
</ui:define>

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="/templates/page_template.xhtml">
<ui:param name="pageTitle" value="Kurs"/>
<ui:define name="panel-top">
<section>
<p>Ny kurs panel top</p>
</section>
</ui:define>
<ui:define name="panel-main">
<section class="create_course">
<h:form>
<p> Kurs kod</p>
<p>Kurs namn</p>
<p>Kurs deskription</p>
<p>Ansvarig lärare</p>
</h:form>
</section>
</ui:define>
</ui:composition>
</html>

@ -0,0 +1,28 @@
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:composite="http://xmlns.jcp.org/jsf/composite">
<h:form>
<p id="login_form">
<label class="text_grey">Login:</label><br/>
<br/>
<h:outputLabel>Användarnamn123:</h:outputLabel><br/>
<h:inputText id="username" value="#{contactInformation.foreName}"/><br/>
<br/>
<h:outputLabel>Lösenord:</h:outputLabel><br/>
<h:inputText id="password" value="#{contactInformation.city}"/><br/>
<br/>
<h:commandButton action="#{contactInformation.save}" value="Login"/>
</p>
</h:form>
</ui:composition>

@ -1,27 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="/templates/page_template.xhtml">
<ui:param name="pageTitle" value="Index"/>
<ui:define name="panel-top">
<section>
<p><h:outputLink value="signIn.xhtml">Logga in</h:outputLink></p>
</section>
</ui:define>
<ui:composition template="/templates/template_page.xhtml">
<ui:param name="pageTitle" value="Första sidan"/>
<ui:define name="panel-main">
<section class="bild">
<h:graphicImage library="skolan" name="/images/testBild2.jpg"/>
<h:graphicImage library="skola" name="/images/testBild2.jpg"/>
</section>
</ui:define>
</ui:composition>
</html>

@ -1,83 +0,0 @@
html {
margin: 0;
padding: 0;
font-family: Tahoma, sans-serif;
}
body {
margin: 0;
padding: 0;
}
h1, h2, h3, h4, h5, h6 {
margin: 0 0 8px 0;
padding: 0;
}
p {
margin: 8px 0 0 0;
padding: 0;
}
input, button,select {
font-family: Tahoma, sans-serif;
font-size: 100%;
}
body > header {
padding: 16px;
clear: both;
text-align: center;
font-size: 200%;
}
body > header > h1 {
margin: 0;
}
body > section , body > form > section{
margin: 8px 20%;
padding: 18px;
overflow: hidden;
.bild
background-image: url("testBild2.jpg");
background-repeat: no-repeat;
background-size: cover;
background-position: 100%;
}
body > footer {
padding: 8px;
clear: both;
font-size: 13px;
text-align: center;
}
body > footer > p {
margin: 0;
}
.student-table {
width: 100%;
}
.student-header {
padding: 4px;
text-align: left;
font-weight: bold;
}
.student-col-name {
padding: 4px;
text-align: left;
}
.student-col-courseCode, .student-col-courseName, .student-col-teacherName {
padding: 4px;
text-align: right;
}
.student-footer {
padding: 4px;
font-weight: bold;
text-align: right;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

@ -1,62 +0,0 @@
body {
background-color: rgba(118, 203, 224, 0.1);
}
a:link, a:visited {
color: #8d52a0;
}
a:hover, a:active {
color: #76cbe0;
}
input, select {
background-color: #ffffff;
color: #000000;
border: 1px solid #396280;
padding: 4px;
}
option {
background-color: white;
color: black;
}
input[readonly] {
color: #808080;
}
input[type="submit"], input[type="button"] {
border-radius: 4px;
padding: 4px 12px;
}
body > header {
background-color: #2badca;
color: white;
}
body > section, body > form > section {
background-color: rgba(114, 207, 179, 0.38);
color: black;
}
body > footer {
background-color: #2badca;
color: #e5e5e5;
}
.student-header {
background-color: #2a17f1;
color: white;
}
.student-row-odd {
background-color: #e0e0e0;
}
.student-row-even {
background-color: #f0f0f0;
}
.student-footer {
background-color: #2a17f1;
color: white;
}

@ -1,33 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="/templates/page_template.xhtml">
<ui:param name="pageTitle" value="Logga in"/>
<ui:composition template="/templates/template_page.xhtml">
<ui:param name="pageTitle" value="Sign In"/>
<ui:define name="panel-top">
<section>
<ui:fragment rendered="#{loggedIn.id == null}">
<h1>Logga in</h1>
<p>Skriv ditt användarnamn</p>
</ui:fragment>
<h:outputText value="Välkommen till Rotana Reg skolan!"/>
<p> </p>
<h:outputText value="Vänligen logga in"/>
<ui:fragment rendered="#{loggedIn.id != null}">
<h:form>
<h1>Välkommen, #{userBean.users.getUser(loggedIn.id).name}!</h1>
<p>Du är redan inloggad.
Vill du<h:commandLink action="#{signIn.logout}">logga ut</h:commandLink>?</p>
</h:form>
</ui:fragment>
</section>
</ui:define>
<ui:define name="panel-main">
<ui:fragment rendered="#{not userManager.signedIn}">
<ui:fragment rendered="#{loggedIn.id == null}">
<section>
<h:form>
<h:panelGrid columns="2" styleClass="form-grid" columnClasses="form-column-label,form-column-input">
<h:outputLabel for="username">Användarnamn</h:outputLabel>
<h:inputText id="username" value="#{signIn.username}" size="20"/>
<h:inputText id="username" value="#{signIn.username}"/>
<h:outputLabel for="password">Password</h:outputLabel>
<h:inputSecret id="password" value="#{signIn.password}" size="20"/>
<h:inputSecret id="password" value="#{signIn.password}"/> <!--anroppar user bean-->
<h:outputText value=""/>
<h:commandButton value="Submit" action="#{signIn.submit}"/> <!--anroppar usermanager-->

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="templates/template_page.xhtml">
<ui:param name="pageTitle" value="Admin sidan"/>
<ui:define name="panel-top">
<section>
<h:outputLink value="index.xhtml">Logga ut</h:outputLink>
</section>
</ui:define>
<ui:define name="panel-main">
<section>
<h1>Statistik</h1>
--marko jobbar på statistik-biten...---
<br/>
<h:link styleClass="menuItem" value="stats_test.xhtml" outcome="stats_test"/>
</section>
</ui:define>
</ui:composition>
</html>

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<h:form id="form1">
<h:panelGrid columns="3">
<h:panelGrid columns="2" style="vertical-align: top">
<h:outputText value='Enter name'/>
<h:inputText value='#{attendanceBean.date}'/>
<h:outputText value='Enter code'/>
<h:inputText value='#{attendanceBean.hasAttended}'/>
<h:commandButton action="#{attendanceBean.addAttendance}" value="#{attendanceBean.submitButton}"/>
<h:inputHidden value="#{attendanceBean.id}"/>
</h:panelGrid>
<h:panelGrid columns="1" style="vertical-align: top">
<h:outputText value="Unfilterd List"/>
<h:dataTable id="tbl1" value="#{attendanceBean.attendances}" var="aBean">
<h:column >
<f:facet name="header">Id</f:facet>
<h:outputText id="id" value="#{aBean.id}"/>
</h:column>
<h:column >
<f:facet name="header">Datum</f:facet>
<h:outputText value="#{aBean.date}"/>
</h:column>
<h:column >
<f:facet name="header">Närvaro</f:facet>
<h:outputText value="#{aBean.hasAttended}"/>
</h:column>
</h:dataTable>
</h:panelGrid>
<h:panelGrid columns="1" style="vertical-align:text-top">
</h:panelGrid>
</h:panelGrid>
</h:form>
</f:view>
</html>

@ -1,87 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<ui:composition template="/templates/page_template.xhtml">
<ui:param name="pageTitle" value="Student"/>
<ui:define name = "panel-top">
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="templates/template_page.xhtml">
<ui:param name="pageTitle" value="Student sidan"/>
<ui:define name="panel-top">
<section>
<h:dataTable value="#{coursesBean.courses.courses}" var="myCourse">
<h:column>
<h1>#{myCourse.name}</h1>
#{myCourse.description}
</h:column>
</h:dataTable>
<h:form>
<h:dataTable value="#{student.lines}" var="line"
styleClass="student-table"
headerClass="student-header"
rowClasses="student-row-odd,student-row-even"
columnClasses="student-col-courseCode,student-col-courseName,student-col-teacherName"
footerClass="student-footer">
<h:column>
<f:facet name="header">Kurs kod</f:facet>
<h:outputLink value="course_detail.xhtml">
<f:param name="courseId" value="#{line.course.id}"/>
#{line.courseCode.name}
</h:outputLink>
</h:column>
<h:column>
<f:facet name="header">Kurs namn</f:facet>
#{line.courseName.name}
</h:column>
<h:column>
<f:facet name="header">Ansvarig lärare</f:facet>
#{line.teacherName}
</h:column>
<f:facet name="footer">
<h:commandButton value="Avregistrera" action="#{course.removeCourse(line.course)}"/>
</f:facet>
</h:dataTable>
</h:form>
<h:outputLink value="index.xhtml">Logga ut</h:outputLink>
</section>
</ui:define>
<ui:define name="panel-main">
<section>
<h:form>
<h:dataTable value="#{student.lines}" var="line"
styleClass="student-table"
headerClass="student-header"
rowClasses="student-row-odd,student-row-even"
columnClasses="student-col-courseCode,student-col-courseName,student-col-teacherName"
footerClass="student-footer">
<h:column>
<f:facet name="header">Kurs kod</f:facet>
<h:outputLink value="course_detail.xhtml">
<f:param name="courseId" value="#{line.course.id}"/>
#{line.courseCode.name}
</h:outputLink>
</h:column>
<h:dataTable value="#{userBean.users.users}" var="myUser">
<h:column>
<f:facet name="header">Kurs namn</f:facet>
#{line.courseName.name}
#{myUser.name} #{myUser.role}
</h:column>
</h:dataTable>
<section>
<h:dataTable value="#{coursesBean.courses.courses}" var="myCourse">
<h:column>
<f:facet name="header">Ansvarig lärare</f:facet>
#{line.teacherName}
<h1>#{myCourse.name}</h1>
#{myCourse.description}
</h:column>
<f:facet name="footer">
<h:commandButton value="Sök" action="course_detail"/>
<h:commandButton value="Registrera" action="#{course.addCourse(line.course)}"/>
</f:facet>
</h:dataTable>
</h:form>
</section>
</ui:define>
</ui:composition>
</f:view>
</ui:composition>
</html>

@ -1,24 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="/templates/page_template.xhtml">
<ui:param name="pageTitel" value="Lärare"/>
<ui:define name = "panel-top">
<ui:composition template="templates/template_page.xhtml">
<ui:param name="pageTitle" value="Lärare sidan"/>
<ui:define name="panel-top">
<section>
<p> lärare sidan panel top</p>
<!--TODO vet ej -->
<h:outputLink value="index.xhtml">Logga ut</h:outputLink>
</section>
</ui:define>
<ui:define name="panel-main">
<section>
<p> lärare sidan panel main</p>
<h1>Lärare</h1>
<h2>Bla bla bla</h2>
</section>
</ui:define>
</ui:composition>
</html>

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition>
<footer>
<h1>Skolan 2017</h1>
</footer>
</ui:composition>
</html>

@ -0,0 +1,28 @@
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:composite="http://xmlns.jcp.org/jsf/composite">
<h:form id="loginForm">
<label class="text_grey" value="Login"/>
<h:outputLabel value="Användarnamn: "/>
<h:inputText id="username"
value="#{loginBean.username}"
required="true"
requiredMessage="du måste ange ditt namn!!!"/>
<br/>
<h:outputLabel value="Lösenord: "/>
<h:inputSecret id="password"
value="#{loginBean.password}"
required="true"
requiredMessage="mata in ditt lösenord"/>
<br/>
<br/>
<h:commandButton action="#{loginBean.login}" value="Login"/>
</h:form>
</ui:composition>

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition>
<header>
<h1>Rotana Reg skola</h1>
</header>
</ui:composition>
</html>

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view contentType="text/html">
<h:head>
<meta charset="UTF-8"/>
<title>RotanaReg Skolan #{pageTitel} </title>
<h:outputStylesheet library="skolan" name="/css/style.css"/>
<h:outputStylesheet library="skolan" name="/theme/blueheven.css"/>
</h:head>
<h:body>
<ui:include src="header_template.xhtml"/>
<nav>
<h:link styleClass="menuItem" value="Home" outcome="index"/>
<span class="text_grey"> | </span>
<h:link styleClass="menuItem" value="Admin" outcome="admin"/>
<span class="text_grey"> | </span>
<h:link styleClass="menuItem" value="Student" outcome="student"/>
<span class="text_grey"> | </span>
<h:link styleClass="menuItem" value="Teacher" outcome="teacher"/>
</nav>
<ui:insert name="panel-top">
<section>
<p>Hej<h:outputLink value="signIn.xhtml"></h:outputLink></p>
</section>
</ui:insert>
<ui:insert name="panel-main">
<section>
<h1>Main Panel</h1>
<p>Placeholder text.</p> <!--används bara en content för panel main inte är specifierad i relevant page-->
</section>
</ui:insert>
<ui:include src="footer_template.xhtml"/>
</h:body>
</f:view>
</html>

@ -9,7 +9,7 @@
<ui:composition>
<footer>
<h:form>
<h:outputText value="Skolan 2017"/>
<h:outputText value="2017 Rotana Reg Skolan"/>
</h:form>
</footer>
</ui:composition>

@ -26,6 +26,8 @@
<h:link styleClass="menuItem" value="Student" outcome="student"/>
<span class="text_grey"> | </span>
<h:link styleClass="menuItem" value="Teacher" outcome="teacher"/>
<span class="text_grey"> | </span>
<h:link styleClass="menuItem" value="Stats" outcome="stats"/>
</nav>
<ui:insert name = "panel-top">

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<h:outputLabel value="Hello, world"/>
</f:view>
</html>

@ -1,17 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://xmlns.jcp.org/jsf/passthrough"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="/templates/page_template.xhtml">
<ui:composition template="templates/template_page.xhtml">
<f:metadata>
<f:viewAction action="#{userDetail.onload}"/>
</f:metadata>
<ui:param name="pageTitle" value="Användar detaljer"/>
<ui:define name="panel-top">
@ -19,7 +17,6 @@
<h:outputLink value="admin.xhtml">Tillbaka</h:outputLink>
</section>
</ui:define>
<ui:define name="panel-main">
<section>
<h:form>
@ -41,9 +38,8 @@
<h:inputText id="emailAddress" value="#{userDetail.user.emailAddress}" size="20"/>
<h:outputLabel for="phoneNumber">Telefon nummer</h:outputLabel>
<h:inputText id="phoneNumber" value="#{userDetail.user.phoneNumber}" size="20">
<f:validator validatorId="com.rotanareg.skolan.user.PhoneNumber"/>
</h:inputText>
<h:inputText id="phoneNumber" value="#{userDetail.user.phoneNumber}" size="20"/>
<h:outputLabel for="birthDate">Födelsedatum</h:outputLabel>
<h:inputText id="birthDate" p:type="date" value="#{userDetail.user.birthDate}">
<f:convertDateTime pattern="yyyy-MM-dd"/>
@ -58,9 +54,9 @@
<h:outputText value=""/>
<h:commandButton value="Submit" action="#{userDetail.submit}"/>
</h:panelGrid>
</h:form>
</section>
</ui:define>
</ui:composition>
</html>
Loading…
Cancel
Save