formatting and refactoring

REL-BRANCH-ClubhelperModel-0.0.1
Markus Kreth 5 years ago
parent b020eb3a62
commit 4cf2ac1d88
  1. 10
      src/main/java/de/kreth/clubhelper/model/controller/AttendanceController.java
  2. 170
      src/main/java/de/kreth/clubhelper/model/data/CompetitionType.java

@ -17,9 +17,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.kreth.clubhelper.model.dao.AttendanceDao; import de.kreth.clubhelper.model.dao.AttendanceDao;
import de.kreth.clubhelper.model.dao.PersonDao; import de.kreth.clubhelper.model.dao.PersonDao;
import de.kreth.clubhelper.model.data.Attendance; import de.kreth.clubhelper.model.data.Attendance;
@ -40,13 +37,6 @@ public class AttendanceController {
@ResponseBody @ResponseBody
public List<Attendance> getAttendencesOn(@PathVariable("date") @DateTimeFormat(iso = ISO.DATE) LocalDate date) { public List<Attendance> getAttendencesOn(@PathVariable("date") @DateTimeFormat(iso = ISO.DATE) LocalDate date) {
List<Attendance> findByOnDate = attendanceDao.findByOnDate(date); List<Attendance> findByOnDate = attendanceDao.findByOnDate(date);
ObjectMapper mapper = new ObjectMapper();
try {
String one = mapper.writeValueAsString(findByOnDate.get(0));
System.out.println(one);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return findByOnDate; return findByOnDate;
} }

@ -14,95 +14,95 @@ import javax.persistence.Table;
@Table(name = "clubevent_addon") @Table(name = "clubevent_addon")
public class CompetitionType implements Serializable { public class CompetitionType implements Serializable {
@Id private static final long serialVersionUID = 1L;
private String id;
@Id
@Column(name = "competition_type", nullable = false, length = 45) private String id;
private String type;
@Column(name = "competition_type", nullable = false, length = 45)
@OneToOne(mappedBy = "competitionType") private String type;
@JoinColumn(name = "id")
@MapsId @OneToOne(mappedBy = "competitionType")
private ClubEvent clubEvent; @JoinColumn(name = "id")
@MapsId
public Type getType() { private ClubEvent clubEvent;
return Type.valueOf(type);
} public Type getType() {
return Type.valueOf(type);
public void setType(Type type) { }
this.type = type.name();
} public void setType(Type type) {
this.type = type.name();
public void setClubEvent(ClubEvent clubEvent) { }
this.clubEvent = clubEvent;
} public void setClubEvent(ClubEvent clubEvent) {
this.clubEvent = clubEvent;
public String getId() { }
return id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public ClubEvent getClubEvent() {
return clubEvent;
}
public void setType(String type) {
this.type = type;
}
public static enum Type {
EINZEL,
SYNCHRON,
DOPPELMINI,
MANNSCHAFT,
LIGA
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
} }
if (obj == null) {
public void setId(String id) { return false;
this.id = id;
} }
if (getClass() != obj.getClass()) {
public ClubEvent getClubEvent() { return false;
return clubEvent;
} }
CompetitionType other = (CompetitionType) obj;
public void setType(String type) { if (id == null) {
this.type = type; if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
} }
if (type == null) {
public static enum Type { if (other.type != null) {
EINZEL, return false;
SYNCHRON, }
DOPPELMINI, } else if (!type.equals(other.type)) {
MANNSCHAFT, return false;
LIGA
} }
return true;
}
@Override @Override
public int hashCode() { public String toString() {
final int prime = 31; return type;
int result = 1; }
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
CompetitionType other = (CompetitionType) obj;
if (id == null) {
if (other.id != null) {
return false;
}
}
else if (!id.equals(other.id)) {
return false;
}
if (type == null) {
if (other.type != null) {
return false;
}
}
else if (!type.equals(other.type)) {
return false;
}
return true;
}
@Override
public String toString() {
return type;
}
} }

Loading…
Cancel
Save