package at.ac.tuwien.inso.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

import at.ac.tuwien.inso.dto.SemesterDto;

@Entity
public class Semester {

    @Id
    @GeneratedValue
    private Long id;

    @Column
    private String label;

    protected Semester() {

    }

    public Semester(String label) {
        this.label = label;
    }

    public Long getId() {
        return id;
    }
    
    public void setId(Long id){
    	this.id = id;
    }

    public String getLabel() {
        return label;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Semester semester = (Semester) o;

        if (id != null ? !id.equals(semester.id) : semester.id != null) return false;
        return label != null ? label.equals(semester.label) : semester.label == null;

    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (label != null ? label.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Semester{" +
                "id=" + id +
                ", label='" + label + '\'' +
                '}';
    }
    
    public SemesterDto toDto(){
    	SemesterDto dto = new SemesterDto(label);
    	if(id!=null){dto.setId(id);}
		return dto;
    }
}

@@ -123,51 +123,168 @@
 nce.
-GeneratedValue;%0Aimport javax.persistence.Id
+EnumType;%0Aimport javax.persistence.Enumerated;%0Aimport javax.persistence.GeneratedValue;%0Aimport javax.persistence.Id;%0Aimport javax.validation.constraints.NotNull
 ;%0A%0Ai
@@ -436,36 +436,151 @@
 ate 
-String label;%0A%0A    protected
+int year;%0A%0A    /**%0A     * WS or SS%0A     */%0A    @Column%0A    @NotNull%0A    @Enumerated(EnumType.STRING)%0A    private SemesterType type;%0A%0A    public
  Sem
@@ -589,17 +589,16 @@
 ter() %7B%0A
-%0A
     %7D%0A%0A 
@@ -620,50 +620,89 @@
 ter(
-String label) %7B%0A        this.label = label
+int year, SemesterType type) %7B%0A        this.year = year;%0A        this.type = type
 ;%0A  
@@ -835,23 +835,19 @@
 lic 
-Str
 in
-g
+t
  get
-Label
+Year
 () %7B
@@ -862,21 +862,20 @@
  return 
-label
+year
 ;%0A    %7D%0A
@@ -883,746 +883,367 @@
     
-@Override%0A    public boolean equals(Object o) %7B%0A        if (this == o) return true
+public void setYear(int year) %7B%0A        this.year = year
 ;%0A    
+%7D%0A%0A
     
-if (o == null %7C%7C getClass() != o.getClass()) return false;%0A%0A        Semester semester = (Semester) o;%0A
+public SemesterType getType() %7B%0A        return type;
 %0A    
+%7D%0A%0A
     
-if (id != null ? !id.equals(semester.id) : semester.id != null) return false;%0A        return label != null ? label.equals(semester.label) : semester.label == null;%0A%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        int result = id != null ? id.hashCode() : 0;%0A        result = 31 * result + (label != null ? label.hashCode() : 0);%0A        return result;%0A    %7D%0A%0A    @Override%0A    public String toString() %7B%0A        return %22Semester%7B%22 +%0A                %22id=%22 + id +%0A                %22, label='%22 + label + '%5C'' +%0A                '%7D'
+public void setType(SemesterType type) %7B%0A        this.type = type;%0A    %7D%0A%0A    public String getLabel() %7B%0A        return getType() + %22 %22 + getYear();%0A    %7D%0A%0A    @Override%0A    public String toString() %7B%0A        return getLabel()
 ;%0A  
@@ -1326,23 +1326,30 @@
 Dto(
-label
+year, type
 );%0A
+%0A
     %09if
+ 
 (id!
@@ -1354,17 +1354,28 @@
 d!=null)
-%7B
+ %7B%0A    %09    
 dto.setI
@@ -1380,17 +1380,24 @@
 tId(id);
-%7D
+%0A    %09%7D%0A
 %0A%09%09retur

Refactor Semester