Changes in / [7bc8942:7fafead] in Git


Ignore:
Files:
180 added
1 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • README.md

    r7bc8942 r7fafead  
    33<div style="float: left; width: 60%;">
    44
    5 <img src="/img/logo.png" style="display: block; float:left; height: auto; width: 30%;" align="right">
    6 <h4 style="display: block; font-weight: normal; text-align: justify; float: right">Предмет: Бази на податоци 2021/2022/Зимски</h2><br>
     5<img src="/img/logo.png" style="display: block; float:left; height: auto; width: 30%;" align="right" alt="q">
     6<h4 style="display: block; font-weight: normal; text-align: justify; float: right">Предмет: Бази на податоци 2021/2022/Зимски</h4><br>
    77<h4 style="display: block; font-weight: normal; text-align: justify; float: right">Под менторство на вонр. проф. д-р Вангел Ајановски и демонстр. м-р Ненад Анчев</h4><br>
    88<h4 style="display: block; font-weight: normal; text-align: justify; float: right">Започнат: Ноември 2021</h4><br><br>
     
    2323        <li>Мартин Николов (193113)</li>
    2424</ol>
     25</div>
  • pom.xml

    r7bc8942 r7fafead  
    4242            <groupId>org.postgresql</groupId>
    4343            <artifactId>postgresql</artifactId>
    44             <scope>runtime</scope>
    4544        </dependency>
    4645        <dependency>
     
    5958            <scope>test</scope>
    6059        </dependency>
     60
    6161        <dependency>
    6262            <groupId>org.springframework.boot</groupId>
    6363            <artifactId>spring-boot-starter-data-jpa</artifactId>
    64             <version>RELEASE</version>
    65             <scope>compile</scope>
    6664        </dependency>
     65        <dependency>
     66        <groupId>org.springframework.boot</groupId>
     67        <artifactId>spring-boot-actuator</artifactId>
     68        </dependency>
     69        <dependency>
     70            <groupId>com.h2database</groupId>
     71            <artifactId>h2</artifactId>
     72        </dependency>
     73
     74
     75
    6776    </dependencies>
    6877
  • src/main/java/com/wediscussmovies/project/model/Discussion.java

    r7bc8942 r7fafead  
    11package com.wediscussmovies.project.model;
    22
     3import com.wediscussmovies.project.model.enumerations.DiscussionType;
    34import lombok.Data;
    45
    56import javax.persistence.*;
    67import java.sql.Date;
     8import java.util.Collection;
    79import java.util.List;
     10import java.util.Objects;
    811
    912@Data
    1013@Entity
    11 @Table (name="discussions")
     14@Table(name = "discussions", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
    1215public class Discussion {
     16
     17    @GeneratedValue(strategy = GenerationType.IDENTITY)
    1318    @Id
    14     @GeneratedValue
    15     private int discussion_id;
     19    @Column(name = "discussion_id")
     20    private Long id;
     21
     22    @Enumerated
     23    private DiscussionType type;
     24
     25    private String text;
     26
     27    private String title;
     28
     29    private Date date;
     30
     31
     32
     33
    1634
    1735    @ManyToOne
    18     @Column(name = "movie_id")
     36    @JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false)
     37    private User user;
     38
     39    @ManyToOne
     40    @JoinColumn(name = "movie_id", referencedColumnName = "movie_id")
    1941    private Movie movie;
    2042
    21     @ManyToOne()
    22     @Column(name = "person_id")
     43    @ManyToOne
     44    @JoinColumn(name = "person_id", referencedColumnName = "person_id")
    2345    private Person person;
    2446
    25     @ManyToOne
    26     @Column(name = "user_id")
    27     private User user;
    2847
    29     @Column(name = "text", length = 1000, nullable = false)
    30     private String text;
    3148
    32     @Column(name = "title", length = 1000, nullable = false)
    33     private String title;
    3449
    35     @Column(name = "date", nullable = false)
    36     private Date date;
    3750
    38     @Column(name = "type", nullable = false)
    39     private DiscussionType type;
    40     @OneToMany
    41     private List<Reply> replies;
     51
     52    public Discussion(DiscussionType type, String text, String title, Date date, User user, Movie movie, Person person, List<Reply> replies) {
     53        this.type = type;
     54        this.text = text;
     55        this.title = title;
     56        this.date = date;
     57        this.user = user;
     58        this.movie = movie;
     59        this.person = person;
     60    }
    4261
    4362    public Discussion() {
    4463    }
    4564
    46     public Discussion(String title, String text, User user, Movie movie, Date valueOf) {
    47         this.title = title;
    48         this.text = text;
    49         this.user = user;
    50         this.date = valueOf;
    51         this.movie = movie;
    52         this.type = DiscussionType.M;
    53     }
    54 
    55     public Discussion(String title, String text, User user, Person person, Date valueOf) {
    56         this.title = title;
    57         this.text = text;
    58         this.user = user;
    59         this.date = valueOf;
    60         this.person = person;
    61         this.type = DiscussionType.P;
    62     }
    63 
    6465
    6566}
    66 
    67 
    68 /*
    69     create table discussions(
    70         discussion_id serial primary key,
    71         type char(1) not null,
    72         text varchar(1000) not null,
    73         title varchar(250) not null,
    74         date date not null,
    75         user_id integer not null,
    76         movie_id integer,
    77         person_id integer,
    78         constraint fk_user_created foreign key (user_id) references users(user_id)
    79         on delete cascade on update cascade,
    80         constraint ck_type_discussion check( (type = 'M' and movie_id notnull and person_id isnull)
    81         or (type='P' and person_id  notnull and movie_id isnull)),
    82         constraint fk_discussion_movie foreign key (movie_id) references movies(movie_id)
    83         on delete cascade on update cascade,
    84         constraint fk_discussion_person foreign key (person_id) references persons(person_id)
    85         on delete cascade on update cascade
    86     );
    87 
    88  */
  • src/main/java/com/wediscussmovies/project/model/Genre.java

    r7bc8942 r7fafead  
    11package com.wediscussmovies.project.model;
    22
     3
     4import javax.persistence.*;
     5import java.util.Collection;
    36import lombok.Data;
    47
    5 import javax.persistence.*;
    68
     9@Entity
     10@Table(name = "genres", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
    711@Data
    8 @Entity
    9 @Table(name="genres")
    1012public class Genre {
     13
     14    @GeneratedValue(strategy = GenerationType.IDENTITY)
    1115    @Id
    12     @GeneratedValue
    13     @Column(name="genre_id", nullable = false, unique = true)
    14     private int genre_id;
     16    @Column(name = "genre_id")
     17    private Long id;
    1518
    16     @Column(name="genre_type", length = 100, nullable = false, unique = true)
    17     private String genre_type;
     19    @Column(name = "genre_type")
     20    private String genre;
    1821
    19     public Genre(String genreName) {
    20         this.genre_type = genreName;
     22    public Genre(String genre) {
     23        this.genre = genre;
    2124    }
    2225
    2326    public Genre() {
    2427    }
     28
    2529}
    26 
    27 /*
    28 
    29 create table genres(
    30     genre_id serial primary key,
    31     genre_type varchar(100) not null unique
    32 );
    33 
    34  */
  • src/main/java/com/wediscussmovies/project/model/Movie.java

    r7bc8942 r7fafead  
    55import javax.persistence.*;
    66import java.sql.Date;
     7import java.util.Collection;
    78import java.util.Comparator;
    89import java.util.List;
     10import java.util.Objects;
     11
     12
     13@Entity
     14@Table(name = "movies", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
    915@Data
    10 @Entity
    11 @Table (name="movies")
    1216public class Movie {
     17
     18    @GeneratedValue(strategy = GenerationType.IDENTITY)
    1319    @Id
    14     @GeneratedValue
    15     @Column(name="movie_id", nullable = false)
    16     private int movie_id;
     20    @Column(name = "movie_id")
     21    private Long id;
    1722
    18     @Column(name="title", length = 150, unique = true, nullable = false)
    19     private String Title;
     23    private String title;
    2024
    21     @Column(name="description", nullable = false, length = 1000)
    2225    private String description;
    2326
    24     @Column(name="image_url", length = 300, nullable = false)
    25     private String image_url;
     27    @Column(name = "image_url")
     28    private String imageUrl;
    2629
    27     @Column(name="airing_date")
    28     private Date airing_date;
    2930
    30     @Column(name="imdb_rating")
    31     private float imdb_rating;
     31    @Column(name = "airing_date")
     32    private Date aringDate;
    3233
    33     @Column(name="director_id")
     34    @Column(name = "imdb_rating")
     35    private Double imbdRating;
     36
     37    @ManyToMany
     38    private List<Genre> genres;
     39
     40    @ManyToMany
     41    private List<Person> likes;
     42
     43    @ManyToMany
     44    private List<Person> actors;
     45
     46
     47
     48
    3449    @ManyToOne
     50    @JoinColumn(name = "director_id")
    3551    private Person director;
    3652
    37     @ManyToMany(mappedBy = "movie_actors")
    38     private List<Person> actors;
    3953
    40     @ManyToMany(mappedBy = "movie_genres")
    41     private List<Genre> genres;
     54
     55
     56
    4257
    4358    public boolean isFromGenre(Genre genre){
    44         for(Genre g: genres){
    45             if(g.getGenre_id() == genre.getGenre_id())
    46                 return true;
    47         }
    48         return false;
     59
     60     return    genres
     61                .stream()
     62                .anyMatch(g -> Objects.equals(g.getId(), genre.getId()));
     63
    4964    }
    5065    public boolean hasActor(Person p){
    51         for(Person person: actors){
    52             if(person.getPerson_id() == p.getPerson_id())
    53                 return true;
    54         }
    55         return false;
     66        return
     67                actors
     68                        .stream()
     69                        .anyMatch(a -> Objects.equals(a.getPersonId(), p.getPersonId()));
     70
     71
    5672    }
    5773
    5874    public boolean isDirectedBy(Person p){
    59         return director.getPerson_id() == p.getPerson_id();
     75        return Objects.equals(director.getPersonId(), p.getPersonId());
    6076    }
    6177
    6278    public static Comparator<Movie> comparatorTitle = Comparator.comparing(Movie::getTitle);
    6379
     80
     81    public Movie( String title, String description, String imageUrl, Date aringDate, Double imbdRating,Person director, List<Person> actors, List<Genre> genres) {
     82
     83        this.title = title;
     84        this.description = description;
     85        this.imageUrl = imageUrl;
     86        this.aringDate = aringDate;
     87        this.imbdRating = imbdRating;
     88        this.genres = genres;
     89        this.likes = likes;
     90        this.actors = actors;
     91        this.director = director;
     92    }
     93
    6494    public Movie() {
    6595    }
    6696
    67     public Movie(String title, String description, String image_url, Date airing_date, float imdb_rating, Person director, List<Person> actors, List<Genre> genres) {
    68         Title = title;
    69         this.description = description;
    70         this.image_url = image_url;
    71         this.airing_date = airing_date;
    72         this.imdb_rating = imdb_rating;
    73         this.director = director;
    74         this.actors = actors;
    75         this.genres = genres;
    76     }
     97
    7798}
    78 
    79 
    80 /*
    81 
    82     create table movies(
    83         movie_id serial primary key,
    84         title varchar(150) not null unique,
    85         description varchar(1000) not null,
    86         image_url varchar(300) not null,
    87         airing_date date not null,
    88         imdb_rating float,
    89         director_id integer,
    90         constraint fk_movie_director foreign key (director_id) references persons(person_id)
    91         on delete cascade on update cascade,
    92         constraint ck_person_is_director check( check_constraint_person(director_id) = 'D')
    93     );
    94  */
  • src/main/java/com/wediscussmovies/project/model/Person.java

    r7bc8942 r7fafead  
    11package com.wediscussmovies.project.model;
    22
     3import com.wediscussmovies.project.model.enumerations.PersonType;
    34import lombok.Data;
    45
    56import javax.persistence.*;
    67import java.sql.Date;
    7 import java.util.Comparator;
     8import java.util.Collection;
    89import java.util.List;
    910
     11@Entity
     12@Table(name = "persons", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
    1013@Data
    11 @Entity
    12 @Table(name="persons")
    1314public class Person {
     15    @GeneratedValue(strategy = GenerationType.IDENTITY)
    1416    @Id
    15     @GeneratedValue
    16     private int person_id;
     17    @Column(name = "person_id")
     18    private Long personId;
    1719
    18     @Column(name="name", length=100, nullable=false, unique=false)
    1920    private String name;
    2021
    21     @Column(name="surname", length=100, nullable=false, unique=false)
    2222    private String surname;
    2323
    24     @Column(name="type", nullable = false)
    25     private PersonType personType;
     24    @Enumerated
     25    private PersonType type;
    2626
    27     @Column(name="date_of_birth", nullable=false)
    28     private Date date_of_birth;
     27    @Column(name = "date_of_birth")
     28    private Date birthDate;
    2929
    30     @Column(name="image_url", length=300, nullable=false, unique=false)
    31     private String image_url;
     30    @Column(name = "image_url")
     31    private String imageUrl;
    3232
    33     @Column(name="description", length=300, nullable=false, unique=false)
    3433    private String description;
    3534
    36     @ManyToMany
    37     private List<Movie> acts_in;
    3835
    39     public Person(String name, String surname, PersonType personType, Date date_of_birth, String image_url, String description) {
    40         this.name = name;
    41         this.surname = surname;
    42         this.personType = personType;
    43         this.date_of_birth = date_of_birth;
    44         this.image_url = image_url;
    45         this.description = description;
    46     }
    4736
    4837    public Person() {
    4938    }
    5039
    51     public static Comparator<Person> personComparatorByNameSurname = Comparator.comparing(Person::getName).thenComparing(Person::getSurname);
     40    public Person(String name, String surname, PersonType type, Date date_of_birth, String image_url, String description) {
     41        this.name = name;
     42        this.surname = surname;
     43        this.type = type;
     44        this.birthDate = date_of_birth;
     45        this.imageUrl = image_url;
     46        this.description = description;
     47    }
    5248}
    53 
    54 
    55 /*
    56         create table persons(
    57         person_id serial primary key,
    58         name varchar(100) not null,
    59         surname varchar(100) not null,
    60         type char(1) not null,
    61         date_of_birth date not null,
    62         image_url varchar(300) not null,
    63         description varchar(300) not null,
    64         constraint ck_type check (type ='A' or type='D')
    65     );
    66  */
  • src/main/java/com/wediscussmovies/project/model/Reply.java

    r7bc8942 r7fafead  
    77import java.util.Optional;
    88
     9@Entity
     10@Table(name = "replies", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
     11@IdClass(RepliesEntityPK.class)
    912@Data
    10 @Entity
    11 @Table(name="replies")
    1213public class Reply {
    1314    @Id
    14     @GeneratedValue
     15    @Column(name = "discussion_id")
     16    private Long discussionId;
     17
     18    @GeneratedValue(strategy = GenerationType.IDENTITY)
     19    @Id
    1520    @Column(name = "reply_id")
    16     private int reply_id;
     21    private Long replyId;
     22
     23    private String text;
     24
     25    private Date date;
    1726
    1827    @ManyToOne
    19     @Column(name = "discussion_id")
     28    @JoinColumn(name = "discussion_id", referencedColumnName = "discussion_id", nullable = false,insertable = false, updatable = false)
    2029    private Discussion discussion;
    2130
    2231    @ManyToOne
    23     @Column(name = "user_id")
     32    @JoinColumn(name = "user_id")
    2433    private User user;
    2534
    26     @Column(name = "date", nullable = false)
    27     private Date date;
    2835
    29     @Column(name= "text", length = 1000, nullable = false)
    30     private String text;
     36
    3137
    3238    public Reply(Discussion discussion, User user, Date date, String text) {
     
    3541        this.date = date;
    3642        this.text = text;
     43
    3744    }
    38 }
     45
     46    public Reply() {
     47
     48    }
    3949
    4050
    41 /*
    42 
    43     create table replies(
    44         discussion_id integer,
    45         reply_id serial,
    46         text varchar(1000) not null,
    47         date date not null,
    48         user_id integer not null,
    49         constraint pk_replies primary key(discussion_id,reply_id),
    50         constraint fk_user_create_reply foreign key (user_id) references users(user_id)
    51         on delete cascade on update cascade,
    52         constraint fk_reply_discussion foreign key (discussion_id) references discussions(discussion_id)
    53         on delete cascade on update cascade
    54 
    55 
    56     );
    57  */
     51}
  • src/main/java/com/wediscussmovies/project/model/User.java

    r7bc8942 r7fafead  
    11package com.wediscussmovies.project.model;
    22
    3 import lombok.Data;
    4 
    53import javax.persistence.*;
     4import java.util.Collection;
    65import java.util.List;
    76
    8 @Data
    97@Entity
    10 @Table(name="users")
     8@Table(name = "users", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
    119public class User {
     10    @GeneratedValue(strategy = GenerationType.IDENTITY)
    1211    @Id
    13     @GeneratedValue
    14     @Column(name="user_id", nullable = false)
    15     private int user_id;
     12    @Column(name = "user_id")
     13    private Long userId;
    1614
    17     @Column(name="username", length=50, nullable=false, unique=false)
    1815    private String username;
    1916
    20     @Column(name="name", length=50, nullable=false, unique=false)
    2117    private String name;
    2218
    23     @Column(name="surname", length=50, nullable=false, unique=false)
    2419    private String surname;
    2520
    26     @Column(name="email", length=50, nullable=false, unique=false)
    2721    private String email;
    2822
    29     @Column(name="password", length=100, nullable=false, unique=true)
    3023    private String password;
    3124
    32     //TODO("RATES_MOVIE")
    33     @ManyToMany(mappedBy = "movie_likes")
    34     private List<Movie> likes_movie;
     25    @ManyToMany
     26    private List<Movie> movies;
    3527
    36     @ManyToMany(mappedBy = "user_genres")
    37     private List<Genre> likes_genres;
     28
     29
    3830
    3931    public User(String username, String name, String surname, String email, String password) {
     
    4840    }
    4941}
    50 
    51 
    52 /*
    53     create table users(
    54       user_id serial primary key,
    55       username varchar(50) not null unique,
    56       name varchar(50) not null,
    57       surname varchar(50) not null,
    58       email varchar(100) not null unique,
    59       password varchar(30) not null,
    60       constraint ck_password check(length(password) >= 9)
    61     );
    62  */
  • src/main/java/com/wediscussmovies/project/repository/GenreRepository.java

    r7bc8942 r7fafead  
    99@Repository
    1010public interface GenreRepository extends JpaRepository<Genre, Integer> {
    11     public List<Genre> findAllByGenre_typeLike(String genre_type);
     11    public List<Genre> findAllByGenre(String genre_type);
    1212}
  • src/main/java/com/wediscussmovies/project/repository/PersonRepository.java

    r7bc8942 r7fafead  
    22
    33import com.wediscussmovies.project.model.Person;
    4 import com.wediscussmovies.project.model.PersonType;
     4import com.wediscussmovies.project.model.enumerations.PersonType;
    55import org.springframework.data.jpa.repository.JpaRepository;
    66import org.springframework.data.jpa.repository.Query;
  • src/main/java/com/wediscussmovies/project/service/GenreService.java

    r7bc8942 r7fafead  
    22
    33import com.wediscussmovies.project.model.Genre;
     4import org.springframework.stereotype.Service;
    45
    56import java.util.List;
    67import java.util.Optional;
    78
     9@Service
    810public interface GenreService {
    911    public List<Genre> findAll();
  • src/main/java/com/wediscussmovies/project/service/MovieService.java

    r7bc8942 r7fafead  
    99    public List<Movie> listAll();
    1010    public List<Movie> searchByTitle(String title);
    11     public Optional<Movie> findById(Integer id);
     11    public Optional<Movie> findById(Long id);
    1212    public Movie save(Movie movie);
    13     public void deleteById(int id);
     13    public void deleteById(Long id);
    1414}
  • src/main/java/com/wediscussmovies/project/service/PersonService.java

    r7bc8942 r7fafead  
    77
    88public interface PersonService {
    9     public List<Person> findAllDirectors();
    10     public List<Person> findAllActors();
     9    List<Person> findAllDirectors();
     10    List<Person> findAllActors();
    1111    Optional<Person> findById(Integer person_id);
    1212    Optional<Person> findActorById(Integer id);
  • src/main/java/com/wediscussmovies/project/service/ReplyService.java

    r7bc8942 r7fafead  
    88    public Reply save(Reply r);
    99    public void delete(Reply r);
    10     Optional<Reply> findById(Integer id);
     10    Optional<Reply> findById(Long id);
     11
    1112}
  • src/main/java/com/wediscussmovies/project/service/impl/GenreServiceImpl.java

    r7bc8942 r7fafead  
    2424    @Override
    2525    public List<Genre> findAllByType(String genre) {
    26         return genreRepository.findAllByGenre_typeLike(genre);
     26        return genreRepository.findAllByGenre(genre);
    2727    }
    2828
  • src/main/java/com/wediscussmovies/project/service/impl/MovieServiceImpl.java

    r7bc8942 r7fafead  
    2323
    2424    @Override
    25     public Optional<Movie> findById(Integer id) {
    26         return movieRepository.findById(id);
     25    public Optional<Movie> findById(Long id) {
     26        return movieRepository.findById(1);
    2727    }
    2828
     
    3333
    3434    @Override
    35     public void deleteById(int id) {
    36         movieRepository.deleteById(id);
     35    public void deleteById(Long id) {
     36        movieRepository.deleteById(0);
    3737    }
    3838
  • src/main/java/com/wediscussmovies/project/service/impl/PersonServiceImpl.java

    r7bc8942 r7fafead  
    22
    33import com.wediscussmovies.project.model.Person;
    4 import com.wediscussmovies.project.model.PersonType;
     4import com.wediscussmovies.project.model.enumerations.PersonType;
    55import com.wediscussmovies.project.repository.PersonRepository;
    66import com.wediscussmovies.project.service.PersonService;
     
    1313public class PersonServiceImpl implements PersonService {
    1414    private final PersonRepository personRepository;
     15
    1516
    1617    public PersonServiceImpl(PersonRepository personRepository) {
  • src/main/java/com/wediscussmovies/project/service/impl/ReplyServiceImpl.java

    r7bc8942 r7fafead  
    1717
    1818    @Override
    19     public Optional<Reply> findById(Integer id) {
    20         return replyRepository.findById(id);
     19    public Optional<Reply> findById(Long id) {
     20        return replyRepository.findById(1);
    2121    }
    2222
  • src/main/java/com/wediscussmovies/project/web/controller/DiscussionsController.java

    r7bc8942 r7fafead  
    22
    33import com.wediscussmovies.project.model.*;
     4import com.wediscussmovies.project.model.enumerations.DiscussionType;
    45import com.wediscussmovies.project.service.DiscussionService;
    56import com.wediscussmovies.project.service.MovieService;
     
    1314import java.sql.Date;
    1415import java.time.LocalDate;
     16import java.util.ArrayList;
    1517import java.util.List;
    1618import java.util.Optional;
     
    101103            return "redirect:/login";
    102104        }
    103         Integer movie_id = (Integer) request.getSession().getAttribute("movieId");
     105        Long movie_id = (Long) request.getSession().getAttribute("movieId");
    104106        request.getSession().setAttribute("movieId", null);
    105107        Optional<Movie> movieOp = movieService.findById(movie_id);
    106108        if(movieOp.isEmpty())
    107109            return "redirect:/movies";
    108         Discussion discussion = new Discussion(title, text, user, movieOp.get(), Date.valueOf(LocalDate.now()));
     110        Discussion discussion = new Discussion(DiscussionType.M,text, title, Date.valueOf(LocalDate.now()),user,movieOp.get(),null,new ArrayList<>());
    109111        discussionService.save(discussion);
    110112        return "redirect:/discussions";
     
    135137        if(personOp.isEmpty())
    136138            return "redirect:/discussions";
    137         Discussion discussion = new Discussion(title, text, user, personOp.get(), Date.valueOf(LocalDate.now()));
     139        Discussion discussion = new Discussion(DiscussionType.P,title, text,Date.valueOf(LocalDate.now()),user,null,personOp.get(),new ArrayList<>());
    138140        discussionService.save(discussion);
    139141        return "redirect:/discussions";
  • src/main/java/com/wediscussmovies/project/web/controller/MovieController.java

    r7bc8942 r7fafead  
    11package com.wediscussmovies.project.web.controller;
    22
     3import com.wediscussmovies.project.exception.MovieIdNotFoundException;
    34import com.wediscussmovies.project.model.Genre;
    45import com.wediscussmovies.project.model.Movie;
    56import com.wediscussmovies.project.model.Person;
    6 import com.wediscussmovies.project.model.exception.MovieIdNotFoundException;
    77import com.wediscussmovies.project.service.GenreService;
    88import com.wediscussmovies.project.service.MovieService;
     
    5959
    6060    @PostMapping("/{id}/delete")
    61     public String addMovie(@PathVariable int id){
     61    public String addMovie(@PathVariable Long id){
    6262        Optional<Movie> movie = movieService.findById(id);
    6363        if(movie.isPresent()){
    64             movieService.deleteById(movie.get().getMovie_id());
     64            movieService.deleteById(movie.get().getId());
    6565        }
    6666        return "redirect:/movies";
     
    7272                               @RequestParam String image_url,
    7373                               @RequestParam Date airing_date,
    74                                @RequestParam Float rating,
     74                               @RequestParam Double rating,
    7575                               @RequestParam Integer director_id,
    7676                               @RequestParam List<Integer> actors,
     
    131131    @PostMapping("/edit/confirm")
    132132    public String editMoviePost(
    133                                 @RequestParam Integer movie_id,
     133                                @RequestParam Long movie_id,
    134134                                @RequestParam String title,
    135135                               @RequestParam String description,
    136136                               @RequestParam String image_url,
    137137                               @RequestParam Date airing_date,
    138                                @RequestParam Float rating,
     138                               @RequestParam Double rating,
    139139                               @RequestParam Integer director_id,
    140140                               @RequestParam List<Integer> actors,
     
    203203        movie.setTitle(title);
    204204        movie.setDescription(description);
    205         movie.setAiring_date(airing_date);
    206         movie.setImage_url(image_url);
    207         movie.setImdb_rating(rating);
     205        movie.setAringDate(airing_date);
     206        movie.setImageUrl(image_url);
     207        movie.setImbdRating(rating);
    208208
    209209        movieService.save(movie);
     
    213213
    214214    @GetMapping("/{id}/edit")
    215     public String editMovie(@PathVariable Integer id, Model model){
     215    public String editMovie(@PathVariable Long id, Model model){
    216216        Movie movie = movieService.findById(id).orElseThrow(() -> new MovieIdNotFoundException(id));
    217217        model.addAttribute("directors", personService.findAllDirectors());
  • src/main/java/com/wediscussmovies/project/web/controller/PersonsController.java

    r7bc8942 r7fafead  
    22
    33import com.wediscussmovies.project.model.Person;
    4 import com.wediscussmovies.project.model.PersonType;
     4import com.wediscussmovies.project.model.enumerations.PersonType;
    55import com.wediscussmovies.project.service.PersonService;
    66import org.springframework.stereotype.Controller;
     
    3838                    boolean add = true;
    3939                    for(Person a: actorsByName){
    40                         if(a.getPerson_id() == p.getPerson_id()){
     40                        if(a.getPersonId() == p.getPersonId()){
    4141                            add=false;
    4242                            break;
     
    5050            actors = actorsByName;
    5151        }
    52         actors.sort(Person.personComparatorByNameSurname);
     52       // actors.sort(Person.personComparatorByNameSurname);
    5353        model.addAttribute("actors", actors);
    5454        model.addAttribute("contentTemplate", "actorsList");
     
    7171                    boolean add = true;
    7272                    for(Person a: directorsByName){
    73                         if(a.getPerson_id() == p.getPerson_id()){
     73                        if(a.getPersonId() == p.getPersonId()){
    7474                            add=false;
    7575                            break;
     
    8383            directors = directorsByName;
    8484        }
    85         directors.sort(Person.personComparatorByNameSurname);
     85     //   directors.sort(Person.personComparatorByNameSurname);
    8686        model.addAttribute("directors", directors);
    8787        model.addAttribute("contentTemplate", "directorsList");
  • src/main/java/com/wediscussmovies/project/web/controller/ReplyController.java

    r7bc8942 r7fafead  
    1919
    2020    @GetMapping("/edit/{id}")
    21     public String getReplyEdit(@PathVariable Integer id, Model model){
     21    public String getReplyEdit(@PathVariable Long id, Model model){
    2222        Optional<Reply> reply = replyService.findById(id);
    2323        if(reply.isEmpty())
     
    2929
    3030    @PostMapping("/edit/confirm/{id}")
    31     public String getReplyEdit(@PathVariable Integer id, @RequestParam String text){
     31    public String getReplyEdit(@PathVariable Long id, @RequestParam String text){
    3232        Optional<Reply> replyOp = replyService.findById(id);
    3333        if(replyOp.isEmpty())
     
    3737        reply.setText(text);
    3838        replyService.save(reply);
    39         return "redirect:/discussions/"+reply.getDiscussion().getDiscussion_id();
     39        return "redirect:/discussions/"+reply.getDiscussion().getId();
    4040    }
    4141}
  • src/main/resources/application.properties

    r7bc8942 r7fafead  
    1 
     1spring.profiles.active=prod
Note: See TracChangeset for help on using the changeset viewer.