Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package be.mct.entities;
- import java.io.Serializable;
- import java.util.List;
- import javax.persistence.*;
- /**
- *
- * @author Tommy
- */
- @Entity
- public class BeerLover implements Serializable {
- @Id
- @GeneratedValue(strategy =GenerationType.AUTO)
- private Long id;
- @OneToMany(mappedBy = "owner")
- private List<Beer> beers;
- @ManyToMany
- private List<Beer> favorites;
- private String name;
- private String password;
- private String personalInformation;
- private String picture;
- public List<Beer> getBeers() {
- return beers;
- }
- public void setBeers(List<Beer> beers) {
- this.beers = beers;
- }
- public List<Beer> getFavorites() {
- return favorites;
- }
- public void setFavorites(List<Beer> favorites) {
- this.favorites = favorites;
- }
- 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 getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public String getPersonalInformation() {
- return personalInformation;
- }
- public void setPersonalInformation(String personalInformation) {
- this.personalInformation = personalInformation;
- }
- public String getPicture() {
- return picture;
- }
- public void setPicture(String picture) {
- this.picture = picture;
- }
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final BeerLover other = (BeerLover) obj;
- if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
- return false;
- }
- return true;
- }
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 71 * hash + (this.id != null ? this.id.hashCode() : 0);
- return hash;
- }
- }
- ---------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package be.mct.entities;
- import be.mct.actions.ImageAdjustment;
- import java.awt.image.BufferedImage;
- import java.io.Serializable;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.List;
- import javax.persistence.*;
- import javax.swing.ImageIcon;
- /**
- *
- * @author Tommy
- */
- @Entity
- public class Beer implements Serializable {
- @Id
- @GeneratedValue(strategy =GenerationType.AUTO)
- private Long id;
- @ManyToMany(mappedBy = "favorites")
- private List<BeerLover> lovers;
- @OneToMany(mappedBy ="beer")
- private List<BeerReview> reviews;
- @ManyToOne
- private BeerLover owner;
- private String name;
- private double alcoholicPercentage;
- private String brewery;
- private String picture;
- private String description;
- public double getAlcoholicPercentage() {
- return alcoholicPercentage;
- }
- public void setAlcoholicPercentage(double alcoholicPercentage) {
- this.alcoholicPercentage = alcoholicPercentage;
- }
- public String getBrewery() {
- return brewery;
- }
- public void setBrewery(String brewery) {
- this.brewery = brewery;
- }
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- public Long getId() {
- return id;
- }
- public void setId(Long id) {
- this.id = id;
- }
- public List<BeerLover> getLovers() {
- return lovers;
- }
- public void setLovers(List<BeerLover> lovers) {
- this.lovers = lovers;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public BeerLover getOwner() {
- return owner;
- }
- public void setOwner(BeerLover owner) {
- this.owner = owner;
- }
- public String getPicture() {
- return picture;
- }
- public void setPicture(String picture) {
- this.picture = picture;
- }
- public int getWidth() throws MalformedURLException {
- java.net.URL where = new URL(picture);
- ImageIcon anotherIcon = new ImageIcon(where);
- BufferedImage preview = ImageAdjustment.shrink(ImageAdjustment.toBufferedImage(anotherIcon),0.35);
- return preview.getWidth();
- }
- public int getHeight() throws MalformedURLException {
- java.net.URL where = new URL(picture);
- ImageIcon anotherIcon = new ImageIcon(where);
- BufferedImage preview = ImageAdjustment.shrink(ImageAdjustment.toBufferedImage(anotherIcon),0.35);
- return preview.getHeight();
- }
- public List<BeerReview> getReviews() {
- return reviews;
- }
- public void setReviews(List<BeerReview> reviews) {
- this.reviews = reviews;
- }
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Beer other = (Beer) obj;
- if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
- return false;
- }
- return true;
- }
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 97 * hash + (this.id != null ? this.id.hashCode() : 0);
- return hash;
- }
- }
- ---------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package be.mct.entities;
- import java.io.Serializable;
- import java.util.Date;
- import javax.persistence.*;
- /**
- *
- * @author Tommy
- */
- @Entity
- public class BeerReview implements Serializable {
- @ManyToOne
- private Beer beer;
- @Id
- @GeneratedValue(strategy =GenerationType.AUTO)
- private Long id;
- @ManyToOne
- private BeerLover reviewer;
- private String text;
- private int stars;
- @Temporal(javax.persistence.TemporalType.DATE)
- private Date postDate;
- public Beer getBeer() {
- return beer;
- }
- public void setBeer(Beer beer) {
- this.beer = beer;
- }
- public Long getId() {
- return id;
- }
- public void setId(Long id) {
- this.id = id;
- }
- public Date getPostDate() {
- return postDate;
- }
- public void setPostDate(Date postDate) {
- this.postDate = postDate;
- }
- public BeerLover getReviewer() {
- return reviewer;
- }
- public void setReviewer(BeerLover reviewer) {
- this.reviewer = reviewer;
- }
- public int getStars() {
- return stars;
- }
- public void setStars(int stars) {
- this.stars = stars;
- }
- public String getText() {
- return text;
- }
- public void setText(String text) {
- this.text = text;
- }
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final BeerReview other = (BeerReview) obj;
- if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
- return false;
- }
- return true;
- }
- @Override
- public int hashCode() {
- int hash = 5;
- hash = 53 * hash + (this.id != null ? this.id.hashCode() : 0);
- return hash;
- }
- }
Add Comment
Please, Sign In to add comment