Guest User

Untitled

a guest
Jun 24th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.76 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6. package be.mct.entities;
  7.  
  8. import java.io.Serializable;
  9. import java.util.List;
  10. import javax.persistence.*;
  11.  
  12.  
  13. /**
  14. *
  15. * @author Tommy
  16. */
  17. @Entity
  18. public class BeerLover implements Serializable {
  19. @Id
  20. @GeneratedValue(strategy =GenerationType.AUTO)
  21. private Long id;
  22. @OneToMany(mappedBy = "owner")
  23. private List<Beer> beers;
  24. @ManyToMany
  25. private List<Beer> favorites;
  26. private String name;
  27. private String password;
  28. private String personalInformation;
  29. private String picture;
  30.  
  31. public List<Beer> getBeers() {
  32. return beers;
  33. }
  34.  
  35. public void setBeers(List<Beer> beers) {
  36. this.beers = beers;
  37. }
  38.  
  39. public List<Beer> getFavorites() {
  40. return favorites;
  41. }
  42.  
  43. public void setFavorites(List<Beer> favorites) {
  44. this.favorites = favorites;
  45. }
  46.  
  47. public Long getId() {
  48. return id;
  49. }
  50.  
  51. public void setId(Long id) {
  52. this.id = id;
  53. }
  54.  
  55. public String getName() {
  56. return name;
  57. }
  58.  
  59. public void setName(String name) {
  60. this.name = name;
  61. }
  62.  
  63. public String getPassword() {
  64. return password;
  65. }
  66.  
  67. public void setPassword(String password) {
  68. this.password = password;
  69. }
  70.  
  71. public String getPersonalInformation() {
  72. return personalInformation;
  73. }
  74.  
  75. public void setPersonalInformation(String personalInformation) {
  76. this.personalInformation = personalInformation;
  77. }
  78.  
  79. public String getPicture() {
  80. return picture;
  81. }
  82.  
  83. public void setPicture(String picture) {
  84. this.picture = picture;
  85. }
  86.  
  87. @Override
  88. public boolean equals(Object obj) {
  89. if (obj == null) {
  90. return false;
  91. }
  92. if (getClass() != obj.getClass()) {
  93. return false;
  94. }
  95. final BeerLover other = (BeerLover) obj;
  96. if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
  97. return false;
  98. }
  99. return true;
  100. }
  101.  
  102. @Override
  103. public int hashCode() {
  104. int hash = 7;
  105. hash = 71 * hash + (this.id != null ? this.id.hashCode() : 0);
  106. return hash;
  107. }
  108.  
  109. }
  110.  
  111.  
  112. ---------
  113.  
  114.  
  115. /*
  116. * To change this template, choose Tools | Templates
  117. * and open the template in the editor.
  118. */
  119.  
  120. package be.mct.entities;
  121.  
  122. import be.mct.actions.ImageAdjustment;
  123. import java.awt.image.BufferedImage;
  124. import java.io.Serializable;
  125. import java.net.MalformedURLException;
  126. import java.net.URL;
  127. import java.util.List;
  128. import javax.persistence.*;
  129. import javax.swing.ImageIcon;
  130.  
  131. /**
  132. *
  133. * @author Tommy
  134. */
  135. @Entity
  136. public class Beer implements Serializable {
  137. @Id
  138. @GeneratedValue(strategy =GenerationType.AUTO)
  139.  
  140. private Long id;
  141. @ManyToMany(mappedBy = "favorites")
  142. private List<BeerLover> lovers;
  143. @OneToMany(mappedBy ="beer")
  144. private List<BeerReview> reviews;
  145. @ManyToOne
  146. private BeerLover owner;
  147. private String name;
  148. private double alcoholicPercentage;
  149. private String brewery;
  150. private String picture;
  151. private String description;
  152.  
  153. public double getAlcoholicPercentage() {
  154. return alcoholicPercentage;
  155. }
  156.  
  157. public void setAlcoholicPercentage(double alcoholicPercentage) {
  158. this.alcoholicPercentage = alcoholicPercentage;
  159. }
  160.  
  161. public String getBrewery() {
  162. return brewery;
  163. }
  164.  
  165. public void setBrewery(String brewery) {
  166. this.brewery = brewery;
  167. }
  168.  
  169. public String getDescription() {
  170. return description;
  171. }
  172.  
  173. public void setDescription(String description) {
  174. this.description = description;
  175. }
  176.  
  177. public Long getId() {
  178. return id;
  179. }
  180.  
  181. public void setId(Long id) {
  182. this.id = id;
  183. }
  184.  
  185. public List<BeerLover> getLovers() {
  186. return lovers;
  187. }
  188.  
  189. public void setLovers(List<BeerLover> lovers) {
  190. this.lovers = lovers;
  191. }
  192.  
  193. public String getName() {
  194. return name;
  195. }
  196.  
  197. public void setName(String name) {
  198. this.name = name;
  199. }
  200.  
  201. public BeerLover getOwner() {
  202. return owner;
  203. }
  204.  
  205. public void setOwner(BeerLover owner) {
  206. this.owner = owner;
  207. }
  208.  
  209. public String getPicture() {
  210. return picture;
  211. }
  212. public void setPicture(String picture) {
  213. this.picture = picture;
  214. }
  215. public int getWidth() throws MalformedURLException {
  216. java.net.URL where = new URL(picture);
  217. ImageIcon anotherIcon = new ImageIcon(where);
  218. BufferedImage preview = ImageAdjustment.shrink(ImageAdjustment.toBufferedImage(anotherIcon),0.35);
  219. return preview.getWidth();
  220. }
  221. public int getHeight() throws MalformedURLException {
  222. java.net.URL where = new URL(picture);
  223. ImageIcon anotherIcon = new ImageIcon(where);
  224. BufferedImage preview = ImageAdjustment.shrink(ImageAdjustment.toBufferedImage(anotherIcon),0.35);
  225. return preview.getHeight();
  226. }
  227.  
  228. public List<BeerReview> getReviews() {
  229. return reviews;
  230. }
  231.  
  232. public void setReviews(List<BeerReview> reviews) {
  233. this.reviews = reviews;
  234. }
  235.  
  236. @Override
  237. public boolean equals(Object obj) {
  238. if (obj == null) {
  239. return false;
  240. }
  241. if (getClass() != obj.getClass()) {
  242. return false;
  243. }
  244. final Beer other = (Beer) obj;
  245. if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
  246. return false;
  247. }
  248. return true;
  249. }
  250.  
  251. @Override
  252. public int hashCode() {
  253. int hash = 7;
  254. hash = 97 * hash + (this.id != null ? this.id.hashCode() : 0);
  255. return hash;
  256. }
  257.  
  258. }
  259.  
  260.  
  261. ---------
  262.  
  263.  
  264.  
  265. /*
  266. * To change this template, choose Tools | Templates
  267. * and open the template in the editor.
  268. */
  269.  
  270. package be.mct.entities;
  271.  
  272. import java.io.Serializable;
  273. import java.util.Date;
  274. import javax.persistence.*;
  275.  
  276. /**
  277. *
  278. * @author Tommy
  279. */
  280. @Entity
  281. public class BeerReview implements Serializable {
  282. @ManyToOne
  283. private Beer beer;
  284. @Id
  285. @GeneratedValue(strategy =GenerationType.AUTO)
  286. private Long id;
  287. @ManyToOne
  288. private BeerLover reviewer;
  289. private String text;
  290. private int stars;
  291. @Temporal(javax.persistence.TemporalType.DATE)
  292. private Date postDate;
  293.  
  294. public Beer getBeer() {
  295. return beer;
  296. }
  297.  
  298. public void setBeer(Beer beer) {
  299. this.beer = beer;
  300. }
  301.  
  302. public Long getId() {
  303. return id;
  304. }
  305.  
  306. public void setId(Long id) {
  307. this.id = id;
  308. }
  309.  
  310. public Date getPostDate() {
  311. return postDate;
  312. }
  313.  
  314. public void setPostDate(Date postDate) {
  315. this.postDate = postDate;
  316. }
  317.  
  318. public BeerLover getReviewer() {
  319. return reviewer;
  320. }
  321.  
  322. public void setReviewer(BeerLover reviewer) {
  323. this.reviewer = reviewer;
  324. }
  325.  
  326. public int getStars() {
  327. return stars;
  328. }
  329.  
  330. public void setStars(int stars) {
  331. this.stars = stars;
  332. }
  333.  
  334. public String getText() {
  335. return text;
  336. }
  337.  
  338. public void setText(String text) {
  339. this.text = text;
  340. }
  341.  
  342. @Override
  343. public boolean equals(Object obj) {
  344. if (obj == null) {
  345. return false;
  346. }
  347. if (getClass() != obj.getClass()) {
  348. return false;
  349. }
  350. final BeerReview other = (BeerReview) obj;
  351. if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
  352. return false;
  353. }
  354. return true;
  355. }
  356.  
  357. @Override
  358. public int hashCode() {
  359. int hash = 5;
  360. hash = 53 * hash + (this.id != null ? this.id.hashCode() : 0);
  361. return hash;
  362. }
  363.  
  364. }
Add Comment
Please, Sign In to add comment