Ignore:
Timestamp:
01/16/22 03:40:31 (3 years ago)
Author:
Petar Partaloski <ppartaloski@…>
Branches:
main
Children:
2a5d6a3
Parents:
839f96a
Message:

Early implementations, MovieController CRUD implementation included

Location:
src/main/java/com/wediscussmovies/project/model
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/wediscussmovies/project/model/Discussion.java

    r839f96a r7a0bf79  
    11package com.wediscussmovies.project.model;
     2
     3import lombok.Data;
    24
    35import javax.persistence.*;
     
    57import java.util.List;
    68
     9@Data
    710@Entity
    811public class Discussion {
  • src/main/java/com/wediscussmovies/project/model/Genre.java

    r839f96a r7a0bf79  
    11package com.wediscussmovies.project.model;
     2
     3import lombok.Data;
    24
    35import javax.persistence.Column;
     
    68import javax.persistence.Id;
    79
     10@Data
    811@Entity(name="genres")
    912public class Genre {
     
    1518    @Column(name="genre_type", length = 100, nullable = false, unique = true)
    1619    private String genre_type;
     20
     21    public Genre(String genreName) {
     22        this.genre_type = genreName;
     23    }
     24
     25    public Genre() {
     26    }
    1727}
    1828
  • src/main/java/com/wediscussmovies/project/model/Movie.java

    r839f96a r7a0bf79  
    11package com.wediscussmovies.project.model;
     2
     3import lombok.Data;
    24
    35import javax.persistence.*;
    46import java.sql.Date;
     7import java.util.Comparator;
    58import java.util.List;
    6 
     9@Data
    710@Entity(name="movies")
    811public class Movie {
     
    3639    @ManyToMany(mappedBy = "movie_genres")
    3740    private List<Genre> genres;
     41
     42    public boolean isFromGenre(Genre genre){
     43        for(Genre g: genres){
     44            if(g.getGenre_id() == genre.getGenre_id())
     45                return true;
     46        }
     47        return false;
     48    }
     49    public boolean hasActor(Person p){
     50        for(Person person: actors){
     51            if(person.getPerson_id() == p.getPerson_id())
     52                return true;
     53        }
     54        return false;
     55    }
     56
     57    public boolean isDirectedBy(Person p){
     58        return director.getPerson_id() == p.getPerson_id();
     59    }
     60
     61    public static Comparator<Movie> comparatorTitle = Comparator.comparing(Movie::getTitle);
     62
     63    public Movie(String title, String description, String image_url, Date airing_date, float imdb_rating, Person director, List<Person> actors, List<Genre> genres) {
     64        Title = title;
     65        this.description = description;
     66        this.image_url = image_url;
     67        this.airing_date = airing_date;
     68        this.imdb_rating = imdb_rating;
     69        this.director = director;
     70        this.actors = actors;
     71        this.genres = genres;
     72    }
    3873}
    3974
  • src/main/java/com/wediscussmovies/project/model/Person.java

    r839f96a r7a0bf79  
    11package com.wediscussmovies.project.model;
     2
     3import lombok.Data;
    24
    35import javax.persistence.*;
     
    57import java.util.List;
    68
     9@Data
    710@Entity(name="persons")
    811public class Person {
  • src/main/java/com/wediscussmovies/project/model/Reply.java

    r839f96a r7a0bf79  
    11package com.wediscussmovies.project.model;
     2
     3import lombok.Data;
    24
    35import javax.persistence.*;
    46import java.sql.Date;
    57
     8@Data
    69@Entity(name="replies")
    710public class Reply {
  • src/main/java/com/wediscussmovies/project/model/User.java

    r839f96a r7a0bf79  
    11package com.wediscussmovies.project.model;
     2
     3import lombok.Data;
    24
    35import javax.persistence.*;
    46import java.util.List;
    57
     8@Data
    69@Entity(name="users")
    710public class User {
Note: See TracChangeset for help on using the changeset viewer.