Add most XML annotations
Some things aren't working yet...
This commit is contained in:
parent
a870c28d21
commit
b7a21d4be2
6
.idea/compiler.xml
generated
6
.idea/compiler.xml
generated
@ -13,9 +13,9 @@
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="MoviesApp" target="11" />
|
||||
<module name="MoviesClient" target="9" />
|
||||
<module name="MoviesCommon" target="9" />
|
||||
<module name="MoviesWebApp" target="9" />
|
||||
<module name="MoviesClient" target="11" />
|
||||
<module name="MoviesCommon" target="11" />
|
||||
<module name="MoviesWebApp" target="11" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
</project>
|
@ -23,21 +23,24 @@ import java.time.LocalDate;
|
||||
)
|
||||
@XmlRootElement
|
||||
public class Actors {
|
||||
@XmlAttribute(name = "id")
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(length = 100, nullable = false)
|
||||
@XmlAttribute
|
||||
private String firstname;
|
||||
|
||||
@Column(length = 100, nullable = false)
|
||||
@XmlAttribute
|
||||
private String lastname;
|
||||
|
||||
@Column(nullable = false)
|
||||
@XmlAttribute
|
||||
private Sex sex;
|
||||
|
||||
@Column(nullable = false)
|
||||
@XmlAttribute
|
||||
private LocalDate birthdate;
|
||||
|
||||
public Actors(String firstname, String lastname, Sex sex, LocalDate birthdate) {
|
||||
|
@ -4,6 +4,8 @@ import lombok.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
@ -24,11 +26,8 @@ import java.util.List;
|
||||
)
|
||||
@XmlRootElement
|
||||
public class Movies {
|
||||
// TODO: XmlAttributes may need different names
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@XmlAttribute
|
||||
private Long id;
|
||||
|
||||
@Column(length = 100, nullable = false)
|
||||
@ -56,10 +55,13 @@ public class Movies {
|
||||
name = "t_movies_actors",
|
||||
joinColumns = @JoinColumn(name = "fk_movies_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "fk_actors_id"))
|
||||
@XmlElementWrapper(name = "actors")
|
||||
@XmlElement(name = "actor")
|
||||
private List<Actors> actors;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "fk_studios_id")
|
||||
@XmlElement
|
||||
private Studios studio;
|
||||
|
||||
public Movies(String title, String description, Genre genre, int length, int releaseyear) {
|
||||
|
@ -3,6 +3,8 @@ package at.technikumwien.movies;
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@ -10,22 +12,23 @@ import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "t_studios")
|
||||
@XmlRootElement
|
||||
public class Studios {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(length = 100, nullable = false)
|
||||
@XmlAttribute
|
||||
private String name;
|
||||
|
||||
@XmlAttribute
|
||||
private String countrycode;
|
||||
|
||||
@XmlAttribute
|
||||
private String postcode;
|
||||
|
||||
public Studios(String name, String countrycode, String postcode) {
|
||||
this(null, name, countrycode, postcode);
|
||||
}
|
||||
|
||||
//TODO consider using
|
||||
//@ManyToMany(mappedBy = 'at.technikumwien.movies.Studios')
|
||||
//private List<at.technikumwien.movies.Movies> movies
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package at.technikumwien.movies;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class LocalDateAdapter extends XmlAdapter<String, LocalDate> {
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
||||
|
||||
@Override
|
||||
public LocalDate unmarshal(String s) throws Exception {
|
||||
return LocalDate.parse(s, FORMATTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String marshal(LocalDate localDate) throws Exception {
|
||||
return FORMATTER.format(localDate);
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlJavaTypeAdapter(LocalDateAdapter.class)
|
||||
|
||||
package at.technikumwien.movies;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
Loading…
x
Reference in New Issue
Block a user