jpa course + diverse ändringar

PlaygroundDevelopment
Nils Gerstner 7 years ago
parent e0cd6f12fc
commit ad6d3083de

6
.gitignore vendored

@ -1,8 +1,4 @@
.idea/*
target/*
<<<<<<< HEAD
=======
*.war
>>>>>>> 21f7771889fbd331d8067aeaacba276c2ab841e7
target/RotanaReg.war
com.rotanareg.skolan.iml
target/RotanaReg.war

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
</webroots>
</configuration>
</facet>
<facet type="jpa" name="JPA">
<configuration>
<setting name="validation-enabled" value="true" />
<setting name="provider-name" value="" />
<datasource-mapping>
<factory-entry name="Persistence-unit" />
</datasource-mapping>
<deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<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" />
<orderEntry type="library" name="Maven: org.eclipse.persistence:org.eclipse.persistence.antlr:2.6.4" level="project" />
<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" />
</component>
</module>

@ -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<CourseDomain> getCourses();
public List<CourseDomain> getCoursesContaining(String filter);
}

@ -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<CourseDomain> getCourses() {
List<Course> 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<CourseDomain> getCoursesContaining(String filter) {
List<Course> 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());
}
}

@ -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";
}

@ -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;
}
}

@ -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;
//}
}

@ -1,7 +0,0 @@
package com.rotanareg.skolan.course;
import java.util.List;
public interface CourseService {
List<Course> getMostStudiedCourses ();
Course getCourse (long id);
}

@ -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<Long, Course> courses;
private final List<Course> mostStudiedCourses;
public CourseServiceImpl (){
Map<Long, Course> 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<Course> getMostStudiedCourses() {
return mostStudiedCourses;
}
@Override
public Course getCourse (long id) {
return courses.get(id);
}
}

@ -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<Course> courses;
@PostConstruct
public void initialize() {
courses = courseService.getMostStudiedCourses ();
}
public List<Course> getCourses() {
return courses;
}
}

@ -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;

@ -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<Course> getCourses();
public List<Course> getCoursesContaining(String filter);
}

@ -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<Course> getCourses() {
List<CourseEntity> 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<Course> getCoursesContaining(String filter) {
List<CourseEntity> 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());
}
}

@ -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();
}
}

@ -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;
}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,4 +1,4 @@
package com.rotanareg.skolan.user;
package com.rotanareg.skolan.userManager;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

@ -1,4 +1,4 @@
package com.rotanareg.skolan.user;
package com.rotanareg.skolan.userManager;
import java.io.Serializable;

@ -1,4 +1,4 @@
package com.rotanareg.skolan.user;
package com.rotanareg.skolan.userManager;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;

@ -1,4 +1,4 @@
package com.rotanareg.skolan.user;
package com.rotanareg.skolan.userManager;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;

@ -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;
}

@ -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<Role> 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;
}
}

@ -1,4 +1,4 @@
package com.rotanareg.skolan.user;
package com.rotanareg.skolan.userManager;
import javax.faces.view.ViewScoped;

@ -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";
}
}

@ -1,4 +1,4 @@
package com.rotanareg.skolan.user;
package com.rotanareg.skolan.userManager;
public interface UserService {
// get information om användare

@ -1,4 +1,4 @@
package com.rotanareg.skolan.user;
package com.rotanareg.skolan.userManager;
import javax.enterprise.context.ApplicationScoped;
import java.util.Map;

@ -1,4 +1,4 @@
package com.rotanareg.skolan.user;
package com.rotanareg.skolan.userManager;
import javax.validation.Constraint;
import javax.validation.Payload;

@ -9,7 +9,7 @@
<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"/>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
</persistence-unit>
</persistence>
</persistence>

@ -1,32 +1,24 @@
<?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">
<!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">
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="templates/template_page.xhtml">
<ui:param name="pageTitle" value="Admin sidan"/>
<ui:define name="panel-top">
<ui:composition template="/templates/page_template.xhtml">
<ui:param name="pageTitle" value="Admin"/>
<ui:define name = "panel-top">
<section>
<h:outputLink value="user_detail.xhtml">Registrera nya användare</h:outputLink>
<p> </p>
<h:outputLink value="create_course.xhtml">Registrera nya kurser</h:outputLink>
<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-->
</section>
</ui:define>
<ui:define name="panel-main">
<section>
<ui:define name="panel-main">
<section>
<h1>här kommer mer</h1>
</section>
</ui:define>
</section>
</ui:define>
</ui:composition>
</html>
</html>

@ -0,0 +1,24 @@
<?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>

@ -8,16 +8,16 @@
<ui:composition template="templates/template_page.xhtml">
<f:metadata>
<f:viewParam name ="courseId" value="#{courseDetails.courseId}"/>
<f:viewAction action="#{courseDetails.onload}"/>
<f:viewParam name ="courseId" value="#{course.Id}"/>
<f:viewAction action="#{course.onload}"/>
</f:metadata>
<ui:param name="pageTitle" value="Course Details"/>
<ui:define name="panel-main">
<section class="course_details">
<h:form>
<h1>#{courseDetails.course.name}</h1>
<p>#{courseDetails.course.description}</p>
<h1>#{course.name}</h1>
<p>#{course.description}</p>
</h:form>
</section>
</ui:define>

@ -1,11 +1,29 @@
<?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">
<!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>
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>

@ -1,19 +1,27 @@
<?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">
<!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">
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/templates/template_page.xhtml">
<ui:param name="pageTitle" value="Index sidan"/>
<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:define name="panel-main">
<section class = "bild">
<h:graphicImage library="skola" name="/images/testBild2.jpg"/>
<section class="bild">
<h:graphicImage library="skolan" name="/images/testBild2.jpg"/>
</section>
</ui:define>
</ui:composition>
</html>

@ -0,0 +1,83 @@
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.

After

Width:  |  Height:  |  Size: 91 KiB

@ -0,0 +1,62 @@
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,53 +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">
<!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/template_page.xhtml">
<ui:param name="pageTitle" value="Sign In"/>
<ui:composition template="/templates/page_template.xhtml">
<ui:param name="pageTitle" value="Logga in"/>
<ui:define name="panel-top">
<section>
<ui:fragment rendered="#{not userManager.signedIn}">
<h1>Logga in</h1>
<p>Skriv ditt användarnamn</p>
</ui:fragment>
<ui:fragment rendered="#{userManager.signedIn}">
<h:form>
<h1>Välkommen, #{userManager.currentUser.firstName}!</h1>
<p>Du är redan inloggad.
Vill du<h:commandLink action="#{userManager.signOut}">logga ut</h:commandLink>?</p>
</h:form>
</ui:fragment>
<h:outputText value="Välkommen till Rotana Reg skolan!"/>
<p> </p>
<h:outputText value="Vänligen logga in"/>
</section>
</ui:define>
<ui:define name="panel-main">
<ui:fragment rendered="#{not userManager.signedIn}">
<section>
<h:messages styleClass="validation-messages"/>
<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:outputLabel for="password">Password</h:outputLabel>
<h:inputSecret id="password" value="#{signIn.password}" size="20"/>
<h:outputText value=""/>
<h:commandButton value="Submit" action="#{signIn.submit}"/> <!--anroppar usermanager-->
</h:panelGrid>
</h:form>
</section>
<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:outputLabel for="password">Password</h:outputLabel>
<h:inputSecret id="password" value="#{signIn.password}" size="20"/>
<h:outputText value=""/>
<h:commandButton value="Submit" action="#{signIn.submit}"/> <!--anroppar usermanager-->
</h:panelGrid>
</h:form>
</section>
</ui:fragment>
</ui:define>
</ui:composition>
</html>
</html>

@ -1,34 +1,81 @@
<?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">
<!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">
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">
<ui:composition template="templates/template_page.xhtml">
<ui:param name="pageTitle" value="Student sidan"/>
<ui:define name="panel-top">
<section>
<!-- <h:outputLink value="index.xhtml">Logga ut</h:outputLink> måste redict på rätt sätt-->
<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: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>
</section>
</ui:define>
<ui:define name="panel-main">
<section>
<h1>Mest lästa kurser</h1>
<h:form>
<ui:repeat value="#{mostStudiedCourses.courses}" var="course">
<ui:param name="course" value="#{course}"/>
<ui:define name="course-description">
<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="Sök" action="course_detail"/>
<h:commandButton value="Registrera" action="#{course.addCourse(line.course)}"/>
</f:facet>
</ui:define>
</ui:repeat>
</h:dataTable>
</h:form>
</section>
</ui:define>
</ui:composition>
</html>
</f:view>
</html>

@ -1,21 +1,24 @@
<?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">
<!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">
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="templates/template_page.xhtml">
<ui:param name="pageTitle" value="Lärare sidan"/>
<ui:define name="panel-top">
<ui:composition template="/templates/page_template.xhtml">
<ui:param name="pageTitel" value="Lärare"/>
<ui:define name = "panel-top">
<section>
<p> lärare sidan panel top</p>
<!--TODO vet ej -->
</section>
</ui:define>
</ui:composition>
<ui:define name="panel-main">
<section>
<p> lärare sidan panel main</p>
</html>
</section>
</ui:define>
</ui:composition>
</html>

@ -0,0 +1,12 @@
<?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,12 @@
<?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>

@ -0,0 +1,41 @@
<?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>

@ -0,0 +1,11 @@
<?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,15 +1,17 @@
<?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">
<!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:p="http://xmlns.jcp.org/jsf/passthrough"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="templates/template_page.xhtml">
<ui:composition template="/templates/page_template.xhtml">
<f:metadata>
<f:viewAction action="#{userDetail.onload}"/>
</f:metadata>
<ui:param name="pageTitle" value="Användar detaljer"/>
<ui:define name="panel-top">
@ -17,46 +19,48 @@
<h:outputLink value="admin.xhtml">Tillbaka</h:outputLink>
</section>
</ui:define>
<ui:define name="panel-main">
<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="#{userDetail.user.username}" size="20"
readonly="#{userManager.signedIn}"/>
<h:outputLabel for="password">Password</h:outputLabel>
<h:inputSecret id="password" value="#{userDetail.user.password}" size="20"/>
<h:outputLabel for="firstName">Förnamn</h:outputLabel>
<h:inputText id="firstName" value="#{userDetail.user.firstName}" size="30"/>
<ui:define name="panel-main">
<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="#{userDetail.user.username}" size="20"
readonly="#{userManager.signedIn}"/>
<h:outputLabel for="lastName">Efternamn</h:outputLabel>
<h:inputText id="lastName" value="#{userDetail.user.lastName}" size="30"/>
<h:outputLabel for="password">Password</h:outputLabel>
<h:inputSecret id="password" value="#{userDetail.user.password}" size="20"/>
<h:outputLabel for="emailAddress">E-mail address</h:outputLabel>
<h:inputText id="emailAddress" value="#{userDetail.user.emailAddress}" size="20"/>
<h:outputLabel for="firstName">Förnamn</h:outputLabel>
<h:inputText id="firstName" value="#{userDetail.user.firstName}" size="30"/>
<h:outputLabel for="phoneNumber">Telefon nummer</h:outputLabel>
<h:inputText id="phoneNumber" value="#{userDetail.user.phoneNumber}" size="20"/>
<h:outputLabel for="lastName">Efternamn</h:outputLabel>
<h:inputText id="lastName" value="#{userDetail.user.lastName}" size="30"/>
<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"/>
</h:inputText>
<h:outputLabel for="emailAddress">E-mail address</h:outputLabel>
<h:inputText id="emailAddress" value="#{userDetail.user.emailAddress}" size="20"/>
<h:outputLabel for="role" value="Roll:"/>
<h:selectOneRadio rendered="true" id="role" value="#{userDetail.user.role}" label="role"
filter="true" panelStyle="width:250px">
<f:selectItems value="#{userDetail.user.rolesList}"/>
</h:selectOneRadio>
<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:outputLabel for="birthDate">Födelsedatum</h:outputLabel>
<h:inputText id="birthDate" p:type="date" value="#{userDetail.user.birthDate}">
<f:convertDateTime pattern="yyyy-MM-dd"/>
</h:inputText>
<h:outputText value=""/>
<h:commandButton value="Submit" action="#{userDetail.submit}"/>
</h:panelGrid>
<h:outputLabel for="role" value="Roll:"/>
<h:selectOneRadio rendered="true" id="role" value="#{userDetail.user.role}" label="role"
filter="true" panelStyle="width:250px">
<f:selectItems value="#{userDetail.user.rolesList}"/>
</h:selectOneRadio>
</h:form>
</section>
<h:outputText value=""/>
<h:commandButton value="Submit" action="#{userDetail.submit}"/>
</h:panelGrid>
</h:form>
</section>
</ui:define>
</ui:composition>
</html>
</html>
Loading…
Cancel
Save