Skip to content

Commit

Permalink
fixes for java and drools part .. ugh
Browse files Browse the repository at this point in the history
  • Loading branch information
Dado555 committed Sep 4, 2022
1 parent 583cb2c commit db5fc3d
Show file tree
Hide file tree
Showing 70 changed files with 1,030 additions and 1,090 deletions.
11 changes: 11 additions & 0 deletions gleficu-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions gleficu-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@fortawesome/free-regular-svg-icons": "^6.1.2",
"@fortawesome/free-solid-svg-icons": "^6.1.2",
"@fortawesome/vue-fontawesome": "^2.0.8",
"@voerro/vue-tagsinput": "^2.7.1",
"autoprefixer": "^9.8.6",
"awesome-vue-star-rating": "^1.0.9",
"axios": "^0.21.4",
Expand Down
1 change: 1 addition & 0 deletions gleficu-frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@voerro/vue-tagsinput@2.7.0/dist/style.css">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body class="bg-gray-900 text-white">
Expand Down
90 changes: 67 additions & 23 deletions gleficu-frontend/src/components/users/RecommendMeMovie.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<template>
<div class="container mx-auto px-4 py-16">
<button id="recommendMovieBtn" class="rounded bg-yellow-500 text-white cursor-auto">Recommend Me A Movie!</button>
<voerro-tags-input id="recommendMovieSearch" element-id="tags" v-model="selectedTags" :existing-tags="existingTags"
:typeahead="true" style="margin-bottom: 30px" @change="onChange($event)"/>

<button id="recommendMovieBtn" class="rounded bg-yellow-500 text-white cursor-auto" @click="recommendMovie()">Recommend Me A Movie!</button>
<br/> <br/>

<div class="container mx-auto border-b border-gray-600 px-4 py-4">
Expand Down Expand Up @@ -33,59 +36,100 @@
<script>
// import MovieItem from "../items/MovieItem";
import PopularMovies from "@/components/front/PopularMovies";
import {movieService} from "@/services/movieService";
import VoerroTagsInput from "@voerro/vue-tagsinput";
import {authService} from "@/services/authService";
import {javaMovieRecommend} from "@/services/javaMovieRecommend";
let currentPage = 1;
export default {
name: "RecommendMeMovie",
components: {
PopularMovies,
VoerroTagsInput
// MovieItem,
},
data: function() {
return {
movies: [],
// genres: [],
searchResult: [],
searchTerm: "",
showSearchResult: false,
searchResultType: "none",
selectedTags: [],
existingTags: [
{ key: 'web-development', value: 'Web Development' },
{ key: 'php', value: 'PHP' },
{ key: 'javascript', value: 'JavaScript' },
],
};
},
// async mounted() {
// await this.fetchGenres();
// try {
// const response = await this.$http.get("/movie/popular");
// this.movies = response.data.results;
// } catch (error) {
// console.log(error);
// }
// },
mounted() {
this.keyboardEvents();
},
methods: {
// async fetchGenres() {
// try {
// const response = await this.$http.get("/genre/movie/list");
// this.genres = response.data.genres;
// console.log("Genres: " + this.genres.toString());
// } catch (error) {
// console.log(error);
// }
// },
recommendMovie() {
let userId = authService.getJwtField("userId");
if(this.selectedTags.length < 1 || userId === null) {
alert("Input some tags!")
} else {
let tempTags = [];
for(let t of this.selectedTags) {
tempTags.push(t.key);
}
let payload = {
tags: tempTags,
userId: userId
};
console.log(payload);
javaMovieRecommend.getMovieRecommends(payload).then((response) => {
console.log(response.data);
});
}
},
onChange(value) {
if(value.length > 2) {
clearTimeout(this.debounce);
this.debounce = setTimeout(() => {
this.fetchSearch(value);
}, 600);
}
},
async fetchSearch(name) {
try {
movieService.searchTags(name).then((response) => {
this.existingTags = [];
for(let str of response.data) {
let temp = {key: str, value: str};
this.existingTags.push(temp);
}
});
} catch (error) {
console.log(error);
}
},
next() {
currentPage += 1;
console.log(currentPage);
// this.fetchMovies(currentPage);
},
previous() {
currentPage -= 1;
console.log(currentPage);
// this.fetchMovies(currentPage);
},
},
}
</script>

<style scoped>
#recommendMovieBtn {
#recommendMovieBtn, #recommendMovieSearch{
margin-left: 10%;
width: 1200px;
height: 80px;
Expand Down
8 changes: 4 additions & 4 deletions gleficu-frontend/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ let router = new VueRouter({
path: "/recommend-movie",
name: "recommendMovie",
component: RecommendMeMovie,
meta: {
authenticated: true,
authorities: ["USER"],
}
// meta: {
// authenticated: true,
// authorities: ["USER"],
// }
},
{
path: '/login',
Expand Down
17 changes: 17 additions & 0 deletions gleficu-frontend/src/services/javaMovieRecommend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import axios from "axios";

const API_URL = 'http://localhost:3004/api/recommend/'
const GET_GENRES = API_URL + "genre-by-tags"

class JavaMovieRecommend {
getMovieRecommends(payload) {
return axios.get(GET_GENRES + `?user_id=${payload.userId}&tags=${payload.tags}`,
{
headers: {
Authorization: "Bearer " + localStorage.getItem("id_token"),
}
}
);
}
}
export const javaMovieRecommend = new JavaMovieRecommend();
9 changes: 9 additions & 0 deletions gleficu-frontend/src/services/movieService.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const GET_MOVIE_BY_IMDB_ID = API_URL + "getByImdbId"
const WATCH_MAGNET = API_URL + "watchMagnet"
const SEARCH_MOVIES = API_URL + "searchMovies"
const UPDATE_MOVIE = API_URL + "updateMovie"
const SEARCH_TAGS = API_URL + "searchTags"

class MovieService {
getByTitle(movie) {
Expand Down Expand Up @@ -80,6 +81,14 @@ class MovieService {
},
});
}

searchTags(tagName) {
return axios.get(SEARCH_TAGS + `/${tagName}`, {
headers: {
Authorization: "Bearer " + localStorage.getItem("id_token"),
},
})
}
}

export const movieService = new MovieService();
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import java.util.Set;
import java.util.HashSet;

import com.sbnz.gleficu.model.facts.*;
import com.sbnz.gleficu.model.lists.*;
import com.sbnz.gleficu.model.movie.*;
import com.sbnz.gleficu.model.user.*;
import com.sbnz.gleficu.model.phases.*;
import com.sbnz.gleficu.model.*;
import com.sbnz.gleficu.model.enums.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import java.util.List;
import java.util.Set;

import com.sbnz.gleficu.model.facts.*;
import com.sbnz.gleficu.model.lists.*;
import com.sbnz.gleficu.model.movie.*;
import com.sbnz.gleficu.model.user.*;
import com.sbnz.gleficu.model.phases.*;
import com.sbnz.gleficu.model.*;
import com.sbnz.gleficu.model.enums.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import java.util.List;
import java.util.Set;

import com.sbnz.gleficu.model.facts.*;
import com.sbnz.gleficu.model.lists.*;
import com.sbnz.gleficu.model.movie.*;
import com.sbnz.gleficu.model.user.*;
import com.sbnz.gleficu.model.phases.*;
import com.sbnz.gleficu.model.*;
import com.sbnz.gleficu.model.enums.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import java.util.List;
import java.util.Set;

import com.sbnz.gleficu.model.facts.*;
import com.sbnz.gleficu.model.lists.*;
import com.sbnz.gleficu.model.movie.*;
import com.sbnz.gleficu.model.user.*;
import com.sbnz.gleficu.model.phases.*;
import com.sbnz.gleficu.model.*;
import com.sbnz.gleficu.model.enums.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import java.util.List;
import java.util.Set;

import com.sbnz.gleficu.model.facts.*;
import com.sbnz.gleficu.model.lists.*;
import com.sbnz.gleficu.model.movie.*;
import com.sbnz.gleficu.model.user.*;
import com.sbnz.gleficu.model.phases.*;
import com.sbnz.gleficu.model.*;
import com.sbnz.gleficu.model.enums.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.sbnz.templates;
import java.util.Set;
import com.sbnz.gleficu.model.facts.*;
import com.sbnz.gleficu.model.lists.*;
import com.sbnz.gleficu.model.movie.*;
import com.sbnz.gleficu.model.user.*;
import com.sbnz.gleficu.model.phases.*;
import com.sbnz.gleficu.model.*;
import com.sbnz.gleficu.model.enums.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,30 @@ import java.util.List;
import java.util.Set;

import com.sbnz.gleficu.model.facts.*;
import com.sbnz.gleficu.model.lists.*;
import com.sbnz.gleficu.model.movie.*;
import com.sbnz.gleficu.model.user.*;
import com.sbnz.gleficu.model.phases.*;
import com.sbnz.gleficu.model.*;
import com.sbnz.gleficu.model.enums.*;

rule "Filter filmova po glavnim glumcima"
agenda-group "Filter filmova po filmskoj ekipi"
no-loop true
when
$phase: MovieFilterByFilmCrewPhase($actors: actors, $movies: movies)
// rule "Filter filmova po glavnim glumcima"
// agenda-group "Filter filmova po filmskoj ekipi"
// no-loop true
// when
// $phase: MovieFilterByFilmCrewPhase($actors: actors, $movies: movies)

accumulate (
FilmCrew($id: id) from $actors;
$actorsIn: collectSet($id)
)
// accumulate (
// FilmCrew($id: id) from $actors;
// $actorsIn: collectSet($id)
// )

accumulate (
$retMovie: Movie($movieId: id, $movieActors: actors) from $movies
and FilmCrew($id: id, id memberOf $actorsIn) from $movieActors;
$retMovies: collectSet($retMovie)
)
then
System.out.println("(glumci) Filtriranje filmova..");
insert(new MoviesFilterFilmCrewFact($retMovies));
end
// accumulate (
// $retMovie: Movie($movieId: id, $movieActors: actors) from $movies
// and FilmCrew($id: id, id memberOf $actorsIn) from $movieActors;
// $retMovies: collectSet($retMovie)
// )
// then
// System.out.println("(glumci) Filtriranje filmova..");
// insert(new MoviesFilterFilmCrewFact($retMovies));
// end
Loading

0 comments on commit db5fc3d

Please sign in to comment.