Commit d1952cf48f21635ab07ddbfdeb60bca93ed797bc
1 parent
76fa2012
Exists in
master
Adicionando codigos
Showing
429 changed files
with
23136 additions
and
2152 deletions
Show diff stats
Too many changes.
To preserve performance only 100 of 429 files displayed.
... | ... | @@ -0,0 +1,9 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<module type="JAVA_MODULE" version="4"> | |
3 | + <component name="NewModuleRootManager" inherit-compiler-output="true"> | |
4 | + <exclude-output /> | |
5 | + <content url="file://$MODULE_DIR$" /> | |
6 | + <orderEntry type="inheritedJdk" /> | |
7 | + <orderEntry type="sourceFolder" forTests="false" /> | |
8 | + </component> | |
9 | +</module> | |
0 | 10 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,8 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<project version="4"> | |
3 | + <component name="ProjectModuleManager"> | |
4 | + <modules> | |
5 | + <module fileurl="file://$PROJECT_DIR$/.idea/2020-Herik-SRH.iml" filepath="$PROJECT_DIR$/.idea/2020-Herik-SRH.iml" /> | |
6 | + </modules> | |
7 | + </component> | |
8 | +</project> | |
0 | 9 | \ No newline at end of file | ... | ... |
.idea/sonarlint/issuestore/5/d/5d3445d1560f9fb50fd22131b2387e4661ecc6d7
0 → 100644
.idea/sonarlint/issuestore/8/e/8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d
0 → 100644
.idea/sonarlint/issuestore/9/6/962c419380565e1b39f0c2c642d055bb68106743
0 → 100644
.idea/sonarlint/issuestore/a/c/acd061af923379b136810cb92f99558057249ef9
0 → 100644
.idea/sonarlint/issuestore/b/d/bde5d5ddddf6982d30196f10e83c423802e01b75
0 → 100644
No preview for this file type
... | ... | @@ -0,0 +1,42 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<project version="4"> | |
3 | + <component name="ChangeListManager"> | |
4 | + <list default="true" id="d16a14de-0ce4-449c-88ef-95e346e97466" name="Default Changelist" comment="" /> | |
5 | + <option name="SHOW_DIALOG" value="false" /> | |
6 | + <option name="HIGHLIGHT_CONFLICTS" value="true" /> | |
7 | + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> | |
8 | + <option name="LAST_RESOLUTION" value="IGNORE" /> | |
9 | + </component> | |
10 | + <component name="Git.Settings"> | |
11 | + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> | |
12 | + </component> | |
13 | + <component name="ProjectId" id="1eEDyolyBaYceGht1XHEwSuoSEW" /> | |
14 | + <component name="ProjectViewState"> | |
15 | + <option name="hideEmptyMiddlePackages" value="true" /> | |
16 | + <option name="showLibraryContents" value="true" /> | |
17 | + </component> | |
18 | + <component name="PropertiesComponent"> | |
19 | + <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> | |
20 | + <property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> | |
21 | + <property name="last_opened_file_path" value="$PROJECT_DIR$/../srh-backend" /> | |
22 | + </component> | |
23 | + <component name="SvnConfiguration"> | |
24 | + <configuration /> | |
25 | + </component> | |
26 | + <component name="TaskManager"> | |
27 | + <task active="true" id="Default" summary="Default task"> | |
28 | + <changelist id="d16a14de-0ce4-449c-88ef-95e346e97466" name="Default Changelist" comment="" /> | |
29 | + <created>1593878115840</created> | |
30 | + <option name="number" value="Default" /> | |
31 | + <option name="presentableId" value="Default" /> | |
32 | + <updated>1593878115840</updated> | |
33 | + </task> | |
34 | + <servers /> | |
35 | + </component> | |
36 | + <component name="WindowStateProjectService"> | |
37 | + <state x="466" y="144" width="424" height="480" key="FileChooserDialogImpl" timestamp="1593954397371"> | |
38 | + <screen x="0" y="30" width="1366" height="738" /> | |
39 | + </state> | |
40 | + <state x="466" y="144" width="424" height="480" key="FileChooserDialogImpl/0.30.1366.738@0.30.1366.738" timestamp="1593954397371" /> | |
41 | + </component> | |
42 | +</project> | |
0 | 43 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,307 @@ |
1 | +root = true | |
2 | + | |
3 | +[*] | |
4 | +charset = utf-8 | |
5 | +end_of_line = lf | |
6 | +indent_size = 4 | |
7 | +indent_style = space | |
8 | +insert_final_newline = false | |
9 | +max_line_length = 120 | |
10 | +tab_width = 4 | |
11 | +ij_continuation_indent_size = 8 | |
12 | +ij_formatter_off_tag = @formatter:off | |
13 | +ij_formatter_on_tag = @formatter:on | |
14 | +ij_formatter_tags_enabled = false | |
15 | +ij_smart_tabs = false | |
16 | +ij_wrap_on_typing = false | |
17 | + | |
18 | +[*.java] | |
19 | +ij_java_align_consecutive_assignments = false | |
20 | +ij_java_align_consecutive_variable_declarations = false | |
21 | +ij_java_align_group_field_declarations = false | |
22 | +ij_java_align_multiline_annotation_parameters = false | |
23 | +ij_java_align_multiline_array_initializer_expression = false | |
24 | +ij_java_align_multiline_assignment = false | |
25 | +ij_java_align_multiline_binary_operation = false | |
26 | +ij_java_align_multiline_chained_methods = false | |
27 | +ij_java_align_multiline_extends_list = false | |
28 | +ij_java_align_multiline_for = true | |
29 | +ij_java_align_multiline_method_parentheses = false | |
30 | +ij_java_align_multiline_parameters = true | |
31 | +ij_java_align_multiline_parameters_in_calls = false | |
32 | +ij_java_align_multiline_parenthesized_expression = false | |
33 | +ij_java_align_multiline_records = true | |
34 | +ij_java_align_multiline_resources = true | |
35 | +ij_java_align_multiline_ternary_operation = false | |
36 | +ij_java_align_multiline_text_blocks = false | |
37 | +ij_java_align_multiline_throws_list = false | |
38 | +ij_java_align_subsequent_simple_methods = false | |
39 | +ij_java_align_throws_keyword = false | |
40 | +ij_java_annotation_parameter_wrap = off | |
41 | +ij_java_array_initializer_new_line_after_left_brace = false | |
42 | +ij_java_array_initializer_right_brace_on_new_line = false | |
43 | +ij_java_array_initializer_wrap = off | |
44 | +ij_java_assert_statement_colon_on_next_line = false | |
45 | +ij_java_assert_statement_wrap = off | |
46 | +ij_java_assignment_wrap = off | |
47 | +ij_java_binary_operation_sign_on_next_line = false | |
48 | +ij_java_binary_operation_wrap = off | |
49 | +ij_java_blank_lines_after_anonymous_class_header = 0 | |
50 | +ij_java_blank_lines_after_class_header = 0 | |
51 | +ij_java_blank_lines_after_imports = 1 | |
52 | +ij_java_blank_lines_after_package = 1 | |
53 | +ij_java_blank_lines_around_class = 1 | |
54 | +ij_java_blank_lines_around_field = 0 | |
55 | +ij_java_blank_lines_around_field_in_interface = 0 | |
56 | +ij_java_blank_lines_around_initializer = 1 | |
57 | +ij_java_blank_lines_around_method = 1 | |
58 | +ij_java_blank_lines_around_method_in_interface = 1 | |
59 | +ij_java_blank_lines_before_class_end = 0 | |
60 | +ij_java_blank_lines_before_imports = 1 | |
61 | +ij_java_blank_lines_before_method_body = 0 | |
62 | +ij_java_blank_lines_before_package = 0 | |
63 | +ij_java_block_brace_style = end_of_line | |
64 | +ij_java_block_comment_at_first_column = true | |
65 | +ij_java_call_parameters_new_line_after_left_paren = false | |
66 | +ij_java_call_parameters_right_paren_on_new_line = false | |
67 | +ij_java_call_parameters_wrap = off | |
68 | +ij_java_case_statement_on_separate_line = true | |
69 | +ij_java_catch_on_new_line = false | |
70 | +ij_java_class_annotation_wrap = split_into_lines | |
71 | +ij_java_class_brace_style = end_of_line | |
72 | +ij_java_class_count_to_use_import_on_demand = 5 | |
73 | +ij_java_class_names_in_javadoc = 1 | |
74 | +ij_java_do_not_indent_top_level_class_members = false | |
75 | +ij_java_do_not_wrap_after_single_annotation = false | |
76 | +ij_java_do_while_brace_force = never | |
77 | +ij_java_doc_add_blank_line_after_description = true | |
78 | +ij_java_doc_add_blank_line_after_param_comments = false | |
79 | +ij_java_doc_add_blank_line_after_return = false | |
80 | +ij_java_doc_add_p_tag_on_empty_lines = true | |
81 | +ij_java_doc_align_exception_comments = true | |
82 | +ij_java_doc_align_param_comments = true | |
83 | +ij_java_doc_do_not_wrap_if_one_line = false | |
84 | +ij_java_doc_enable_formatting = true | |
85 | +ij_java_doc_enable_leading_asterisks = true | |
86 | +ij_java_doc_indent_on_continuation = false | |
87 | +ij_java_doc_keep_empty_lines = true | |
88 | +ij_java_doc_keep_empty_parameter_tag = true | |
89 | +ij_java_doc_keep_empty_return_tag = true | |
90 | +ij_java_doc_keep_empty_throws_tag = true | |
91 | +ij_java_doc_keep_invalid_tags = true | |
92 | +ij_java_doc_param_description_on_new_line = false | |
93 | +ij_java_doc_preserve_line_breaks = false | |
94 | +ij_java_doc_use_throws_not_exception_tag = true | |
95 | +ij_java_else_on_new_line = false | |
96 | +ij_java_enum_constants_wrap = off | |
97 | +ij_java_extends_keyword_wrap = off | |
98 | +ij_java_extends_list_wrap = off | |
99 | +ij_java_field_annotation_wrap = split_into_lines | |
100 | +ij_java_finally_on_new_line = false | |
101 | +ij_java_for_brace_force = never | |
102 | +ij_java_for_statement_new_line_after_left_paren = false | |
103 | +ij_java_for_statement_right_paren_on_new_line = false | |
104 | +ij_java_for_statement_wrap = off | |
105 | +ij_java_generate_final_locals = false | |
106 | +ij_java_generate_final_parameters = false | |
107 | +ij_java_if_brace_force = never | |
108 | +ij_java_imports_layout = *,|,javax.**,java.**,|,$* | |
109 | +ij_java_indent_case_from_switch = true | |
110 | +ij_java_insert_inner_class_imports = false | |
111 | +ij_java_insert_override_annotation = true | |
112 | +ij_java_keep_blank_lines_before_right_brace = 2 | |
113 | +ij_java_keep_blank_lines_between_package_declaration_and_header = 2 | |
114 | +ij_java_keep_blank_lines_in_code = 2 | |
115 | +ij_java_keep_blank_lines_in_declarations = 2 | |
116 | +ij_java_keep_control_statement_in_one_line = true | |
117 | +ij_java_keep_first_column_comment = true | |
118 | +ij_java_keep_indents_on_empty_lines = false | |
119 | +ij_java_keep_line_breaks = true | |
120 | +ij_java_keep_multiple_expressions_in_one_line = false | |
121 | +ij_java_keep_simple_blocks_in_one_line = false | |
122 | +ij_java_keep_simple_classes_in_one_line = false | |
123 | +ij_java_keep_simple_lambdas_in_one_line = false | |
124 | +ij_java_keep_simple_methods_in_one_line = false | |
125 | +ij_java_label_indent_absolute = false | |
126 | +ij_java_label_indent_size = 0 | |
127 | +ij_java_lambda_brace_style = end_of_line | |
128 | +ij_java_layout_static_imports_separately = true | |
129 | +ij_java_line_comment_add_space = false | |
130 | +ij_java_line_comment_at_first_column = true | |
131 | +ij_java_method_annotation_wrap = split_into_lines | |
132 | +ij_java_method_brace_style = end_of_line | |
133 | +ij_java_method_call_chain_wrap = off | |
134 | +ij_java_method_parameters_new_line_after_left_paren = false | |
135 | +ij_java_method_parameters_right_paren_on_new_line = false | |
136 | +ij_java_method_parameters_wrap = off | |
137 | +ij_java_modifier_list_wrap = false | |
138 | +ij_java_names_count_to_use_import_on_demand = 3 | |
139 | +ij_java_new_line_after_lparen_in_record_header = false | |
140 | +ij_java_packages_to_use_import_on_demand = java.awt.*,javax.swing.* | |
141 | +ij_java_parameter_annotation_wrap = off | |
142 | +ij_java_parentheses_expression_new_line_after_left_paren = false | |
143 | +ij_java_parentheses_expression_right_paren_on_new_line = false | |
144 | +ij_java_place_assignment_sign_on_next_line = false | |
145 | +ij_java_prefer_longer_names = true | |
146 | +ij_java_prefer_parameters_wrap = false | |
147 | +ij_java_record_components_wrap = normal | |
148 | +ij_java_repeat_synchronized = true | |
149 | +ij_java_replace_instanceof_and_cast = false | |
150 | +ij_java_replace_null_check = true | |
151 | +ij_java_replace_sum_lambda_with_method_ref = true | |
152 | +ij_java_resource_list_new_line_after_left_paren = false | |
153 | +ij_java_resource_list_right_paren_on_new_line = false | |
154 | +ij_java_resource_list_wrap = off | |
155 | +ij_java_rparen_on_new_line_in_record_header = false | |
156 | +ij_java_space_after_closing_angle_bracket_in_type_argument = false | |
157 | +ij_java_space_after_colon = true | |
158 | +ij_java_space_after_comma = true | |
159 | +ij_java_space_after_comma_in_type_arguments = true | |
160 | +ij_java_space_after_for_semicolon = true | |
161 | +ij_java_space_after_quest = true | |
162 | +ij_java_space_after_type_cast = true | |
163 | +ij_java_space_before_annotation_array_initializer_left_brace = false | |
164 | +ij_java_space_before_annotation_parameter_list = false | |
165 | +ij_java_space_before_array_initializer_left_brace = false | |
166 | +ij_java_space_before_catch_keyword = true | |
167 | +ij_java_space_before_catch_left_brace = true | |
168 | +ij_java_space_before_catch_parentheses = true | |
169 | +ij_java_space_before_class_left_brace = true | |
170 | +ij_java_space_before_colon = true | |
171 | +ij_java_space_before_colon_in_foreach = true | |
172 | +ij_java_space_before_comma = false | |
173 | +ij_java_space_before_do_left_brace = true | |
174 | +ij_java_space_before_else_keyword = true | |
175 | +ij_java_space_before_else_left_brace = true | |
176 | +ij_java_space_before_finally_keyword = true | |
177 | +ij_java_space_before_finally_left_brace = true | |
178 | +ij_java_space_before_for_left_brace = true | |
179 | +ij_java_space_before_for_parentheses = true | |
180 | +ij_java_space_before_for_semicolon = false | |
181 | +ij_java_space_before_if_left_brace = true | |
182 | +ij_java_space_before_if_parentheses = true | |
183 | +ij_java_space_before_method_call_parentheses = false | |
184 | +ij_java_space_before_method_left_brace = true | |
185 | +ij_java_space_before_method_parentheses = false | |
186 | +ij_java_space_before_opening_angle_bracket_in_type_parameter = false | |
187 | +ij_java_space_before_quest = true | |
188 | +ij_java_space_before_switch_left_brace = true | |
189 | +ij_java_space_before_switch_parentheses = true | |
190 | +ij_java_space_before_synchronized_left_brace = true | |
191 | +ij_java_space_before_synchronized_parentheses = true | |
192 | +ij_java_space_before_try_left_brace = true | |
193 | +ij_java_space_before_try_parentheses = true | |
194 | +ij_java_space_before_type_parameter_list = false | |
195 | +ij_java_space_before_while_keyword = true | |
196 | +ij_java_space_before_while_left_brace = true | |
197 | +ij_java_space_before_while_parentheses = true | |
198 | +ij_java_space_inside_one_line_enum_braces = false | |
199 | +ij_java_space_within_empty_array_initializer_braces = false | |
200 | +ij_java_space_within_empty_method_call_parentheses = false | |
201 | +ij_java_space_within_empty_method_parentheses = false | |
202 | +ij_java_spaces_around_additive_operators = true | |
203 | +ij_java_spaces_around_assignment_operators = true | |
204 | +ij_java_spaces_around_bitwise_operators = true | |
205 | +ij_java_spaces_around_equality_operators = true | |
206 | +ij_java_spaces_around_lambda_arrow = true | |
207 | +ij_java_spaces_around_logical_operators = true | |
208 | +ij_java_spaces_around_method_ref_dbl_colon = false | |
209 | +ij_java_spaces_around_multiplicative_operators = true | |
210 | +ij_java_spaces_around_relational_operators = true | |
211 | +ij_java_spaces_around_shift_operators = true | |
212 | +ij_java_spaces_around_type_bounds_in_type_parameters = true | |
213 | +ij_java_spaces_around_unary_operator = false | |
214 | +ij_java_spaces_within_angle_brackets = false | |
215 | +ij_java_spaces_within_annotation_parentheses = false | |
216 | +ij_java_spaces_within_array_initializer_braces = false | |
217 | +ij_java_spaces_within_braces = false | |
218 | +ij_java_spaces_within_brackets = false | |
219 | +ij_java_spaces_within_cast_parentheses = false | |
220 | +ij_java_spaces_within_catch_parentheses = false | |
221 | +ij_java_spaces_within_for_parentheses = false | |
222 | +ij_java_spaces_within_if_parentheses = false | |
223 | +ij_java_spaces_within_method_call_parentheses = false | |
224 | +ij_java_spaces_within_method_parentheses = false | |
225 | +ij_java_spaces_within_parentheses = false | |
226 | +ij_java_spaces_within_switch_parentheses = false | |
227 | +ij_java_spaces_within_synchronized_parentheses = false | |
228 | +ij_java_spaces_within_try_parentheses = false | |
229 | +ij_java_spaces_within_while_parentheses = false | |
230 | +ij_java_special_else_if_treatment = true | |
231 | +ij_java_subclass_name_suffix = Impl | |
232 | +ij_java_ternary_operation_signs_on_next_line = false | |
233 | +ij_java_ternary_operation_wrap = off | |
234 | +ij_java_test_name_suffix = Test | |
235 | +ij_java_throws_keyword_wrap = off | |
236 | +ij_java_throws_list_wrap = off | |
237 | +ij_java_use_external_annotations = false | |
238 | +ij_java_use_fq_class_names = false | |
239 | +ij_java_use_relative_indents = false | |
240 | +ij_java_use_single_class_imports = true | |
241 | +ij_java_variable_annotation_wrap = off | |
242 | +ij_java_visibility = public | |
243 | +ij_java_while_brace_force = never | |
244 | +ij_java_while_on_new_line = false | |
245 | +ij_java_wrap_comments = false | |
246 | +ij_java_wrap_first_method_in_call_chain = false | |
247 | +ij_java_wrap_long_lines = false | |
248 | + | |
249 | +[*.properties] | |
250 | +ij_properties_align_group_field_declarations = false | |
251 | +ij_properties_keep_blank_lines = false | |
252 | +ij_properties_key_value_delimiter = equals | |
253 | +ij_properties_spaces_around_key_value_delimiter = false | |
254 | + | |
255 | +[.editorconfig] | |
256 | +ij_editorconfig_align_group_field_declarations = false | |
257 | +ij_editorconfig_space_after_colon = false | |
258 | +ij_editorconfig_space_after_comma = true | |
259 | +ij_editorconfig_space_before_colon = false | |
260 | +ij_editorconfig_space_before_comma = false | |
261 | +ij_editorconfig_spaces_around_assignment_operators = true | |
262 | + | |
263 | +[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.jspx,*.pom,*.rng,*.tagx,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}] | |
264 | +ij_xml_align_attributes = true | |
265 | +ij_xml_align_text = false | |
266 | +ij_xml_attribute_wrap = normal | |
267 | +ij_xml_block_comment_at_first_column = true | |
268 | +ij_xml_keep_blank_lines = 2 | |
269 | +ij_xml_keep_indents_on_empty_lines = false | |
270 | +ij_xml_keep_line_breaks = true | |
271 | +ij_xml_keep_line_breaks_in_text = true | |
272 | +ij_xml_keep_whitespaces = false | |
273 | +ij_xml_keep_whitespaces_around_cdata = preserve | |
274 | +ij_xml_keep_whitespaces_inside_cdata = false | |
275 | +ij_xml_line_comment_at_first_column = true | |
276 | +ij_xml_space_after_tag_name = false | |
277 | +ij_xml_space_around_equals_in_attribute = false | |
278 | +ij_xml_space_inside_empty_tag = false | |
279 | +ij_xml_text_wrap = normal | |
280 | +ij_xml_use_custom_settings = false | |
281 | + | |
282 | +[{*.bash,*.sh,*.zsh}] | |
283 | +indent_size = 2 | |
284 | +tab_width = 2 | |
285 | +ij_shell_binary_ops_start_line = false | |
286 | +ij_shell_keep_column_alignment_padding = false | |
287 | +ij_shell_minify_program = false | |
288 | +ij_shell_redirect_followed_by_space = false | |
289 | +ij_shell_switch_cases_indented = false | |
290 | + | |
291 | +[{*.har,*.json}] | |
292 | +indent_size = 2 | |
293 | +ij_json_keep_blank_lines_in_code = 0 | |
294 | +ij_json_keep_indents_on_empty_lines = false | |
295 | +ij_json_keep_line_breaks = true | |
296 | +ij_json_space_after_colon = true | |
297 | +ij_json_space_after_comma = true | |
298 | +ij_json_space_before_colon = true | |
299 | +ij_json_space_before_comma = false | |
300 | +ij_json_spaces_within_braces = false | |
301 | +ij_json_spaces_within_brackets = false | |
302 | +ij_json_wrap_long_lines = false | |
303 | + | |
304 | +[{*.yaml,*.yml}] | |
305 | +indent_size = 2 | |
306 | +ij_yaml_keep_indents_on_empty_lines = false | |
307 | +ij_yaml_keep_line_breaks = true | ... | ... |
codigos/backend/.gitignore
... | ... | @@ -0,0 +1,17 @@ |
1 | +# Hybrid Recommendation System | |
2 | + | |
3 | +## Install (Linux) | |
4 | + | |
5 | +```bash | |
6 | +> chmod +x startConfig.sh | |
7 | +> ./startConfig.sh | |
8 | +``` | |
9 | + | |
10 | +- Create a database in PostgreSQL with name **srh** | |
11 | +- Insert the content of data.sql on database: | |
12 | + | |
13 | +```sql | |
14 | +INSERT INTO api_user(id, name, login, password, profile) VALUES (1, 'api', 'api', '$2a$10$sFKmbxbG4ryhwPNx/l3pgOJSt.fW1z6YcUnuE2X8APA/Z3NI/oSpq', 'API'); | |
15 | +``` | |
16 | + | |
17 | +Use the user **api** with password **123456** to generate the token for api | |
0 | 18 | \ No newline at end of file | ... | ... |
No preview for this file type
182 KB
No preview for this file type
codigos/backend/mvnw
codigos/backend/mvnw.cmd
... | ... | @@ -108,10 +108,10 @@ cd "%EXEC_DIR%" |
108 | 108 | |
109 | 109 | :endDetectBaseDir |
110 | 110 | |
111 | -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.edu.ifes.ci.si.les.srh.config" goto endReadAdditionalConfig | |
111 | +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig | |
112 | 112 | |
113 | 113 | @setlocal EnableExtensions EnableDelayedExpansion |
114 | -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.edu.ifes.ci.si.les.srh.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a | |
114 | +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a | |
115 | 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% |
116 | 116 | |
117 | 117 | :endReadAdditionalConfig | ... | ... |
codigos/backend/pom.xml
... | ... | @@ -5,51 +5,58 @@ |
5 | 5 | <parent> |
6 | 6 | <groupId>org.springframework.boot</groupId> |
7 | 7 | <artifactId>spring-boot-starter-parent</artifactId> |
8 | - <version>2.3.1.RELEASE</version> | |
8 | + <version>2.2.6.RELEASE</version> | |
9 | 9 | <relativePath/> <!-- lookup parent from repository --> |
10 | 10 | </parent> |
11 | - <groupId>edu.ifes.ci.si.les.srh</groupId> | |
12 | - <artifactId>srh</artifactId> | |
11 | + <groupId>com.srh</groupId> | |
12 | + <artifactId>api</artifactId> | |
13 | 13 | <version>0.0.1-SNAPSHOT</version> |
14 | - <name>srh</name> | |
15 | - <description>A Hybrid Recommendation System build with RESTful API</description> | |
14 | + <name>Hybrid Recommendation System</name> | |
15 | + <description>Hybrid Recommendation System RESTfull API</description> | |
16 | 16 | |
17 | 17 | <properties> |
18 | 18 | <java.version>14</java.version> |
19 | + <spring-boot-admin.version>2.2.1</spring-boot-admin.version> | |
19 | 20 | </properties> |
20 | 21 | |
21 | 22 | <dependencies> |
22 | 23 | <dependency> |
23 | 24 | <groupId>org.springframework.boot</groupId> |
24 | - <artifactId>spring-boot-starter-web</artifactId> | |
25 | + <artifactId>spring-boot-starter-cache</artifactId> | |
25 | 26 | </dependency> |
26 | - | |
27 | 27 | <dependency> |
28 | 28 | <groupId>org.springframework.boot</groupId> |
29 | 29 | <artifactId>spring-boot-starter-data-jpa</artifactId> |
30 | 30 | </dependency> |
31 | - | |
32 | 31 | <dependency> |
33 | 32 | <groupId>org.springframework.boot</groupId> |
34 | - <artifactId>spring-boot-devtools</artifactId> | |
35 | - <scope>runtime</scope> | |
36 | - <optional>true</optional> | |
33 | + <artifactId>spring-boot-starter-hateoas</artifactId> | |
37 | 34 | </dependency> |
38 | 35 | <dependency> |
39 | - <groupId>javax.validation</groupId> | |
40 | - <artifactId>validation-api</artifactId> | |
36 | + <groupId>org.springframework.boot</groupId> | |
37 | + <artifactId>spring-boot-starter-security</artifactId> | |
41 | 38 | </dependency> |
39 | + <dependency> | |
40 | + <groupId>org.springframework.boot</groupId> | |
41 | + <artifactId>spring-boot-starter-mail</artifactId> | |
42 | + </dependency> | |
42 | 43 | <dependency> |
43 | - <groupId>com.h2database</groupId> | |
44 | - <artifactId>h2</artifactId> | |
45 | - <scope>runtime</scope> | |
44 | + <groupId>de.codecentric</groupId> | |
45 | + <artifactId>spring-boot-admin-starter-client</artifactId> | |
46 | 46 | </dependency> |
47 | + | |
47 | 48 | <dependency> |
48 | - <groupId>org.projectlombok</groupId> | |
49 | - <artifactId>lombok</artifactId> | |
49 | + <groupId>org.springframework.boot</groupId> | |
50 | + <artifactId>spring-boot-devtools</artifactId> | |
51 | + <scope>runtime</scope> | |
50 | 52 | <optional>true</optional> |
51 | 53 | </dependency> |
52 | 54 | <dependency> |
55 | + <groupId>org.postgresql</groupId> | |
56 | + <artifactId>postgresql</artifactId> | |
57 | + <scope>runtime</scope> | |
58 | + </dependency> | |
59 | + <dependency> | |
53 | 60 | <groupId>org.springframework.boot</groupId> |
54 | 61 | <artifactId>spring-boot-starter-test</artifactId> |
55 | 62 | <scope>test</scope> |
... | ... | @@ -61,16 +68,37 @@ |
61 | 68 | </exclusions> |
62 | 69 | </dependency> |
63 | 70 | <dependency> |
64 | - <groupId>org.postgresql</groupId> | |
65 | - <artifactId>postgresql</artifactId> | |
66 | - <scope>runtime</scope> | |
71 | + <groupId>org.springframework.security</groupId> | |
72 | + <artifactId>spring-security-test</artifactId> | |
73 | + <scope>test</scope> | |
67 | 74 | </dependency> |
75 | + <dependency> | |
76 | + <groupId>io.jsonwebtoken</groupId> | |
77 | + <artifactId>jjwt</artifactId> | |
78 | + <version>0.9.1</version> | |
79 | + </dependency> | |
80 | + <dependency> | |
81 | + <groupId>org.projectlombok</groupId> | |
82 | + <artifactId>lombok</artifactId> | |
83 | + <optional>true</optional> | |
84 | + </dependency> | |
68 | 85 | <dependency> |
69 | - <groupId>org.hibernate.validator</groupId> | |
70 | - <artifactId>hibernate-validator</artifactId> | |
71 | - <version>6.0.18.Final</version> | |
86 | + <groupId>com.h2database</groupId> | |
87 | + <artifactId>h2</artifactId> | |
72 | 88 | </dependency> |
73 | - </dependencies> | |
89 | + </dependencies> | |
90 | + | |
91 | + <dependencyManagement> | |
92 | + <dependencies> | |
93 | + <dependency> | |
94 | + <groupId>de.codecentric</groupId> | |
95 | + <artifactId>spring-boot-admin-dependencies</artifactId> | |
96 | + <version>${spring-boot-admin.version}</version> | |
97 | + <type>pom</type> | |
98 | + <scope>import</scope> | |
99 | + </dependency> | |
100 | + </dependencies> | |
101 | + </dependencyManagement> | |
74 | 102 | |
75 | 103 | <build> |
76 | 104 | <plugins> |
... | ... | @@ -78,6 +106,14 @@ |
78 | 106 | <groupId>org.springframework.boot</groupId> |
79 | 107 | <artifactId>spring-boot-maven-plugin</artifactId> |
80 | 108 | </plugin> |
109 | + <plugin> | |
110 | + <groupId>org.apache.maven.plugins</groupId> | |
111 | + <artifactId>maven-compiler-plugin</artifactId> | |
112 | + <configuration> | |
113 | + <source>13</source> | |
114 | + <target>13</target> | |
115 | + </configuration> | |
116 | + </plugin> | |
81 | 117 | </plugins> |
82 | 118 | </build> |
83 | 119 | ... | ... |
codigos/backend/src/main/java/com/srh/api/Application.java
0 → 100644
... | ... | @@ -0,0 +1,13 @@ |
1 | +package com.srh.api; | |
2 | + | |
3 | +import org.springframework.boot.SpringApplication; | |
4 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | |
5 | + | |
6 | +@SpringBootApplication | |
7 | +public class Application { | |
8 | + | |
9 | + public static void main(String[] args) { | |
10 | + SpringApplication.run(Application.class, args); | |
11 | + } | |
12 | + | |
13 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/algorithms/AlgorithmCalc.java
0 → 100644
... | ... | @@ -0,0 +1,10 @@ |
1 | +package com.srh.api.algorithms; | |
2 | + | |
3 | +import com.srh.api.algorithms.structure.RecommendationsByUser; | |
4 | +import com.srh.api.dto.resource.RecommendationForm; | |
5 | + | |
6 | +import java.util.List; | |
7 | + | |
8 | +public interface AlgorithmCalc { | |
9 | + public List<RecommendationsByUser> calc(RecommendationForm recommendationInfo); | |
10 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/algorithms/AlgorithmStrategy.java
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +package com.srh.api.algorithms; | |
2 | + | |
3 | +import com.srh.api.algorithms.strategies.*; | |
4 | +import com.srh.api.error.exception.InvalidAlgorithmRecommendationException; | |
5 | +import lombok.SneakyThrows; | |
6 | + | |
7 | +public class AlgorithmStrategy { | |
8 | + @SneakyThrows | |
9 | + public static AlgorithmCalc findInstance(Integer algorithmId) { | |
10 | + String idValue = String.valueOf(algorithmId); | |
11 | + | |
12 | + switch (idValue) { | |
13 | + case "1": | |
14 | + return new Collaborative(); | |
15 | + case "2": | |
16 | + return new BasedContent(); | |
17 | + case "3": | |
18 | + return new WeightedHybrid(); | |
19 | + case "4": | |
20 | + return new WeightedHybridWithThreads(); | |
21 | + case "5": | |
22 | + return new MixedHybrid(); | |
23 | + case "6": | |
24 | + return new MixedHybridWithThreads(); | |
25 | + default: | |
26 | + throw new InvalidAlgorithmRecommendationException("Algoritmo inválido"); | |
27 | + } | |
28 | + } | |
29 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/algorithms/strategies/BasedContent.java
0 → 100644
... | ... | @@ -0,0 +1,15 @@ |
1 | +package com.srh.api.algorithms.strategies; | |
2 | + | |
3 | +import com.srh.api.algorithms.AlgorithmCalc; | |
4 | +import com.srh.api.algorithms.structure.RecommendationsByUser; | |
5 | +import com.srh.api.dto.resource.RecommendationForm; | |
6 | +import com.srh.api.model.Evaluator; | |
7 | + | |
8 | +import java.util.List; | |
9 | + | |
10 | +public class BasedContent implements AlgorithmCalc { | |
11 | + @Override | |
12 | + public List<RecommendationsByUser> calc(RecommendationForm recommendationForm) { | |
13 | + return null; | |
14 | + } | |
15 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/algorithms/strategies/Collaborative.java
0 → 100644
... | ... | @@ -0,0 +1,111 @@ |
1 | +package com.srh.api.algorithms.strategies; | |
2 | + | |
3 | +import com.srh.api.algorithms.AlgorithmCalc; | |
4 | +import com.srh.api.algorithms.structure.RecommendationsByUser; | |
5 | +import com.srh.api.builder.RecommendationBuilder; | |
6 | +import com.srh.api.dto.resource.RecommendationForm; | |
7 | +import com.srh.api.model.*; | |
8 | +import com.srh.api.repository.EvaluatorRepository; | |
9 | +import com.srh.api.repository.ItemRepository; | |
10 | +import com.srh.api.repository.ProjectRepository; | |
11 | +import com.srh.api.repository.RecommendationRepository; | |
12 | +import com.srh.api.service.AlgorithmService; | |
13 | +import com.srh.api.service.EvaluatorService; | |
14 | +import com.srh.api.service.ProjectService; | |
15 | +import org.springframework.beans.factory.annotation.Autowired; | |
16 | +import org.springframework.data.domain.Page; | |
17 | +import org.springframework.data.domain.Pageable; | |
18 | + | |
19 | +import java.time.LocalDateTime; | |
20 | +import java.util.ArrayList; | |
21 | +import java.util.List; | |
22 | +import java.util.Random; | |
23 | + | |
24 | +public class Collaborative implements AlgorithmCalc { | |
25 | + @Autowired | |
26 | + private EvaluatorService evaluatorService; | |
27 | + | |
28 | + @Autowired | |
29 | + private ItemRepository itemRepository; | |
30 | + | |
31 | + @Autowired | |
32 | + private RecommendationRepository recommendationRepository; | |
33 | + | |
34 | + @Autowired | |
35 | + private ProjectRepository projectRepository; | |
36 | + | |
37 | + @Autowired | |
38 | + private ProjectService projectService; | |
39 | + | |
40 | + @Autowired | |
41 | + private AlgorithmService algorithmService; | |
42 | + | |
43 | + @Override | |
44 | + public List<RecommendationsByUser> calc(RecommendationForm recommendationForm) { | |
45 | + Iterable<Evaluator> evaluators = evaluatorService.listAll(); | |
46 | + List<RecommendationsByUser> recommendations = new ArrayList<>(); | |
47 | + | |
48 | + for (Evaluator evaluator : evaluators) { | |
49 | + RecommendationsByUser recommendationsByUser = generateRecommendationByEvaluator( | |
50 | + evaluator, recommendationForm | |
51 | + ); | |
52 | + | |
53 | + if (recommendationsByUser == null) { | |
54 | + recommendations.add(recommendationsByUser); | |
55 | + } | |
56 | + } | |
57 | + | |
58 | + return recommendations; | |
59 | + } | |
60 | + | |
61 | + private RecommendationsByUser generateRecommendationByEvaluator(Evaluator evaluator, | |
62 | + RecommendationForm recommendationForm) { | |
63 | + Random random = new Random(); | |
64 | + | |
65 | + if (random.nextInt(2) == 1) { | |
66 | + RecommendationsByUser recommendationsByUser = new RecommendationsByUser(); | |
67 | + | |
68 | + recommendationsByUser.setEvaluator(evaluator); | |
69 | + recommendationsByUser.setRecommendations(calculateRecommendations(evaluator, | |
70 | + recommendationForm)); | |
71 | + | |
72 | + return recommendationsByUser; | |
73 | + } | |
74 | + | |
75 | + return null; | |
76 | + } | |
77 | + | |
78 | + private List<Recommendation> calculateRecommendations(Evaluator evaluator, | |
79 | + RecommendationForm recommendationForm) { | |
80 | + Random random = new Random(); | |
81 | + List<Recommendation> recommendations = new ArrayList<>(); | |
82 | + | |
83 | + Project project = projectService.find(recommendationForm.getProjectId()); | |
84 | + Integer matrixId = project.getLastMatrixId() + 1; | |
85 | + Algorithm algorithm = algorithmService.find(recommendationForm.getAlgorithmId()); | |
86 | + | |
87 | + for(Item item: itemRepository.findByProject(project)) { | |
88 | + Double score = random.nextDouble() * 5; | |
89 | + | |
90 | + if (score > recommendationForm.getPassingScore()) { | |
91 | + Recommendation recommendation = RecommendationBuilder.aRecommendation() | |
92 | + .withAlgorithm(algorithm) | |
93 | + .withItem(item) | |
94 | + .withDate(LocalDateTime.now()) | |
95 | + .withEvaluator(evaluator) | |
96 | + .withRuntimeInSeconds(1) | |
97 | + .withWeight(score) | |
98 | + .withMatrixId(matrixId) | |
99 | + .build(); | |
100 | + | |
101 | + recommendationRepository.save(recommendation); | |
102 | + recommendations.add(recommendation); | |
103 | + } | |
104 | + } | |
105 | + | |
106 | + project.setLastMatrixId(matrixId); | |
107 | + projectService.save(project); | |
108 | + | |
109 | + return recommendations; | |
110 | + } | |
111 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/algorithms/strategies/MixedHybrid.java
0 → 100644
... | ... | @@ -0,0 +1,15 @@ |
1 | +package com.srh.api.algorithms.strategies; | |
2 | + | |
3 | +import com.srh.api.algorithms.AlgorithmCalc; | |
4 | +import com.srh.api.algorithms.structure.RecommendationsByUser; | |
5 | +import com.srh.api.dto.resource.RecommendationForm; | |
6 | +import com.srh.api.model.Evaluator; | |
7 | + | |
8 | +import java.util.List; | |
9 | + | |
10 | +public class MixedHybrid implements AlgorithmCalc { | |
11 | + @Override | |
12 | + public List<RecommendationsByUser> calc(RecommendationForm recommendationForm) { | |
13 | + return null; | |
14 | + } | |
15 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/algorithms/strategies/MixedHybridWithThreads.java
0 → 100644
... | ... | @@ -0,0 +1,15 @@ |
1 | +package com.srh.api.algorithms.strategies; | |
2 | + | |
3 | +import com.srh.api.algorithms.AlgorithmCalc; | |
4 | +import com.srh.api.algorithms.structure.RecommendationsByUser; | |
5 | +import com.srh.api.dto.resource.RecommendationForm; | |
6 | +import com.srh.api.model.Evaluator; | |
7 | + | |
8 | +import java.util.List; | |
9 | + | |
10 | +public class MixedHybridWithThreads implements AlgorithmCalc { | |
11 | + @Override | |
12 | + public List<RecommendationsByUser> calc(RecommendationForm recommendationForm) { | |
13 | + return null; | |
14 | + } | |
15 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/algorithms/strategies/WeightedHybrid.java
0 → 100644
... | ... | @@ -0,0 +1,14 @@ |
1 | +package com.srh.api.algorithms.strategies; | |
2 | + | |
3 | +import com.srh.api.algorithms.AlgorithmCalc; | |
4 | +import com.srh.api.algorithms.structure.RecommendationsByUser; | |
5 | +import com.srh.api.dto.resource.RecommendationForm; | |
6 | +import com.srh.api.model.Evaluator; | |
7 | + | |
8 | +import java.util.List; | |
9 | + | |
10 | +public class WeightedHybrid implements AlgorithmCalc { | |
11 | + public List<RecommendationsByUser> calc(RecommendationForm recommendationForm) { | |
12 | + return null; | |
13 | + } | |
14 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/algorithms/strategies/WeightedHybridWithThreads.java
0 → 100644
... | ... | @@ -0,0 +1,14 @@ |
1 | +package com.srh.api.algorithms.strategies; | |
2 | + | |
3 | +import com.srh.api.algorithms.AlgorithmCalc; | |
4 | +import com.srh.api.algorithms.structure.RecommendationsByUser; | |
5 | +import com.srh.api.dto.resource.RecommendationForm; | |
6 | + | |
7 | +import java.util.List; | |
8 | + | |
9 | +public class WeightedHybridWithThreads implements AlgorithmCalc { | |
10 | + @Override | |
11 | + public List<RecommendationsByUser> calc(RecommendationForm recommendationForm) { | |
12 | + return null; | |
13 | + } | |
14 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/algorithms/structure/RecommendationsByUser.java
0 → 100644
... | ... | @@ -0,0 +1,13 @@ |
1 | +package com.srh.api.algorithms.structure; | |
2 | + | |
3 | +import com.srh.api.model.Evaluator; | |
4 | +import com.srh.api.model.Recommendation; | |
5 | +import lombok.Data; | |
6 | + | |
7 | +import java.util.List; | |
8 | + | |
9 | +@Data | |
10 | +public class RecommendationsByUser { | |
11 | + private Evaluator evaluator; | |
12 | + private List<Recommendation> recommendations; | |
13 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/algorithms/utils/EuclideanDistance.java
0 → 100644
codigos/backend/src/main/java/com/srh/api/builder/AdminBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,70 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.model.Admin; | |
4 | +import com.srh.api.model.Project; | |
5 | + | |
6 | +import java.util.List; | |
7 | + | |
8 | +public final class AdminBuilder { | |
9 | + protected String login; | |
10 | + protected String password; | |
11 | + private List<Project> projects; | |
12 | + private Integer id; | |
13 | + private String oldPassword; | |
14 | + private String name; | |
15 | + private String email; | |
16 | + | |
17 | + private AdminBuilder() { | |
18 | + } | |
19 | + | |
20 | + public static AdminBuilder anAdmin() { | |
21 | + return new AdminBuilder(); | |
22 | + } | |
23 | + | |
24 | + public AdminBuilder withProjects(List<Project> projects) { | |
25 | + this.projects = projects; | |
26 | + return this; | |
27 | + } | |
28 | + | |
29 | + public AdminBuilder withId(Integer id) { | |
30 | + this.id = id; | |
31 | + return this; | |
32 | + } | |
33 | + | |
34 | + public AdminBuilder withLogin(String login) { | |
35 | + this.login = login; | |
36 | + return this; | |
37 | + } | |
38 | + | |
39 | + public AdminBuilder withOldPassword(String oldPassword) { | |
40 | + this.oldPassword = oldPassword; | |
41 | + return this; | |
42 | + } | |
43 | + | |
44 | + public AdminBuilder withName(String name) { | |
45 | + this.name = name; | |
46 | + return this; | |
47 | + } | |
48 | + | |
49 | + public AdminBuilder withEmail(String email) { | |
50 | + this.email = email; | |
51 | + return this; | |
52 | + } | |
53 | + | |
54 | + public AdminBuilder withPassword(String password) { | |
55 | + this.password = password; | |
56 | + return this; | |
57 | + } | |
58 | + | |
59 | + public Admin build() { | |
60 | + Admin admin = new Admin(); | |
61 | + admin.setProjects(projects); | |
62 | + admin.setId(id); | |
63 | + admin.setLogin(login); | |
64 | + admin.setOldPassword(oldPassword); | |
65 | + admin.setName(name); | |
66 | + admin.setEmail(email); | |
67 | + admin.setPassword(password); | |
68 | + return admin; | |
69 | + } | |
70 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/builder/AlgorithmBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,50 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.model.Algorithm; | |
4 | +import com.srh.api.model.Recommendation; | |
5 | +import com.srh.api.model.TypeRecommendation; | |
6 | + | |
7 | +import java.util.List; | |
8 | + | |
9 | +public final class AlgorithmBuilder { | |
10 | + private Integer id; | |
11 | + private String name; | |
12 | + private TypeRecommendation typeRecommendation; | |
13 | + private List<Recommendation> recommendations; | |
14 | + | |
15 | + private AlgorithmBuilder() { | |
16 | + } | |
17 | + | |
18 | + public static AlgorithmBuilder anAlgorithm() { | |
19 | + return new AlgorithmBuilder(); | |
20 | + } | |
21 | + | |
22 | + public AlgorithmBuilder withId(Integer id) { | |
23 | + this.id = id; | |
24 | + return this; | |
25 | + } | |
26 | + | |
27 | + public AlgorithmBuilder withName(String name) { | |
28 | + this.name = name; | |
29 | + return this; | |
30 | + } | |
31 | + | |
32 | + public AlgorithmBuilder withTypeRecommendation(TypeRecommendation typeRecommendation) { | |
33 | + this.typeRecommendation = typeRecommendation; | |
34 | + return this; | |
35 | + } | |
36 | + | |
37 | + public AlgorithmBuilder withRecommendations(List<Recommendation> recommendations) { | |
38 | + this.recommendations = recommendations; | |
39 | + return this; | |
40 | + } | |
41 | + | |
42 | + public Algorithm build() { | |
43 | + Algorithm algorithm = new Algorithm(); | |
44 | + algorithm.setId(id); | |
45 | + algorithm.setName(name); | |
46 | + algorithm.setTypeRecommendation(typeRecommendation); | |
47 | + algorithm.setRecommendations(recommendations); | |
48 | + return algorithm; | |
49 | + } | |
50 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/builder/ApiUserBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,70 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.model.ApiUser; | |
4 | +import com.srh.api.model.Profile; | |
5 | + | |
6 | +import java.util.List; | |
7 | + | |
8 | +public final class ApiUserBuilder { | |
9 | + protected String login; | |
10 | + protected String password; | |
11 | + private List<Profile> profiles; | |
12 | + private Integer id; | |
13 | + private String oldPassword; | |
14 | + private String name; | |
15 | + private String email; | |
16 | + | |
17 | + private ApiUserBuilder() { | |
18 | + } | |
19 | + | |
20 | + public static ApiUserBuilder anApiUser() { | |
21 | + return new ApiUserBuilder(); | |
22 | + } | |
23 | + | |
24 | + public ApiUserBuilder withProfiles(List<Profile> profiles) { | |
25 | + this.profiles = profiles; | |
26 | + return this; | |
27 | + } | |
28 | + | |
29 | + public ApiUserBuilder withId(Integer id) { | |
30 | + this.id = id; | |
31 | + return this; | |
32 | + } | |
33 | + | |
34 | + public ApiUserBuilder withLogin(String login) { | |
35 | + this.login = login; | |
36 | + return this; | |
37 | + } | |
38 | + | |
39 | + public ApiUserBuilder withOldPassword(String oldPassword) { | |
40 | + this.oldPassword = oldPassword; | |
41 | + return this; | |
42 | + } | |
43 | + | |
44 | + public ApiUserBuilder withName(String name) { | |
45 | + this.name = name; | |
46 | + return this; | |
47 | + } | |
48 | + | |
49 | + public ApiUserBuilder withEmail(String email) { | |
50 | + this.email = email; | |
51 | + return this; | |
52 | + } | |
53 | + | |
54 | + public ApiUserBuilder withPassword(String password) { | |
55 | + this.password = password; | |
56 | + return this; | |
57 | + } | |
58 | + | |
59 | + public ApiUser build() { | |
60 | + ApiUser apiUser = new ApiUser(); | |
61 | + apiUser.setProfiles(profiles); | |
62 | + apiUser.setId(id); | |
63 | + apiUser.setLogin(login); | |
64 | + apiUser.setOldPassword(oldPassword); | |
65 | + apiUser.setName(name); | |
66 | + apiUser.setEmail(email); | |
67 | + apiUser.setPassword(password); | |
68 | + return apiUser; | |
69 | + } | |
70 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/builder/AttributeBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,65 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.model.Attribute; | |
4 | +import com.srh.api.model.Item; | |
5 | +import com.srh.api.model.TypeAttribute; | |
6 | +import com.srh.api.model.TypeItem; | |
7 | + | |
8 | +import java.util.List; | |
9 | + | |
10 | +public final class AttributeBuilder { | |
11 | + private Integer id; | |
12 | + private String name; | |
13 | + private String value; | |
14 | + private TypeAttribute type; | |
15 | + private List<Item> itens; | |
16 | + private List<TypeItem> typeItens; | |
17 | + | |
18 | + private AttributeBuilder() { | |
19 | + } | |
20 | + | |
21 | + public static AttributeBuilder anAttribute() { | |
22 | + return new AttributeBuilder(); | |
23 | + } | |
24 | + | |
25 | + public AttributeBuilder withId(Integer id) { | |
26 | + this.id = id; | |
27 | + return this; | |
28 | + } | |
29 | + | |
30 | + public AttributeBuilder withName(String name) { | |
31 | + this.name = name; | |
32 | + return this; | |
33 | + } | |
34 | + | |
35 | + public AttributeBuilder withValue(String value) { | |
36 | + this.value = value; | |
37 | + return this; | |
38 | + } | |
39 | + | |
40 | + public AttributeBuilder withType(TypeAttribute type) { | |
41 | + this.type = type; | |
42 | + return this; | |
43 | + } | |
44 | + | |
45 | + public AttributeBuilder withItens(List<Item> itens) { | |
46 | + this.itens = itens; | |
47 | + return this; | |
48 | + } | |
49 | + | |
50 | + public AttributeBuilder withTypeItens(List<TypeItem> typeItens) { | |
51 | + this.typeItens = typeItens; | |
52 | + return this; | |
53 | + } | |
54 | + | |
55 | + public Attribute build() { | |
56 | + Attribute attribute = new Attribute(); | |
57 | + attribute.setId(id); | |
58 | + attribute.setName(name); | |
59 | + attribute.setValue(value); | |
60 | + attribute.setType(type); | |
61 | + attribute.setItens(itens); | |
62 | + attribute.setTypeItens(typeItens); | |
63 | + return attribute; | |
64 | + } | |
65 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/builder/EvaluatorBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,90 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.model.*; | |
4 | + | |
5 | +import java.util.List; | |
6 | + | |
7 | +public final class EvaluatorBuilder { | |
8 | + protected String login; | |
9 | + protected String password; | |
10 | + private List<Project> projects; | |
11 | + private List<Recommendation> recommendations; | |
12 | + private List<ItemRating> itemRatings; | |
13 | + private List<RecommendationRating> recommendationRatings; | |
14 | + private Integer id; | |
15 | + private String oldPassword; | |
16 | + private String name; | |
17 | + private String email; | |
18 | + | |
19 | + private EvaluatorBuilder() { | |
20 | + } | |
21 | + | |
22 | + public static EvaluatorBuilder anEvaluator() { | |
23 | + return new EvaluatorBuilder(); | |
24 | + } | |
25 | + | |
26 | + public EvaluatorBuilder withProjects(List<Project> projects) { | |
27 | + this.projects = projects; | |
28 | + return this; | |
29 | + } | |
30 | + | |
31 | + public EvaluatorBuilder withRecommendations(List<Recommendation> recommendations) { | |
32 | + this.recommendations = recommendations; | |
33 | + return this; | |
34 | + } | |
35 | + | |
36 | + public EvaluatorBuilder withItemRatings(List<ItemRating> itemRatings) { | |
37 | + this.itemRatings = itemRatings; | |
38 | + return this; | |
39 | + } | |
40 | + | |
41 | + public EvaluatorBuilder withRecommendationRatings(List<RecommendationRating> recommendationRatings) { | |
42 | + this.recommendationRatings = recommendationRatings; | |
43 | + return this; | |
44 | + } | |
45 | + | |
46 | + public EvaluatorBuilder withId(Integer id) { | |
47 | + this.id = id; | |
48 | + return this; | |
49 | + } | |
50 | + | |
51 | + public EvaluatorBuilder withLogin(String login) { | |
52 | + this.login = login; | |
53 | + return this; | |
54 | + } | |
55 | + | |
56 | + public EvaluatorBuilder withOldPassword(String oldPassword) { | |
57 | + this.oldPassword = oldPassword; | |
58 | + return this; | |
59 | + } | |
60 | + | |
61 | + public EvaluatorBuilder withName(String name) { | |
62 | + this.name = name; | |
63 | + return this; | |
64 | + } | |
65 | + | |
66 | + public EvaluatorBuilder withEmail(String email) { | |
67 | + this.email = email; | |
68 | + return this; | |
69 | + } | |
70 | + | |
71 | + public EvaluatorBuilder withPassword(String password) { | |
72 | + this.password = password; | |
73 | + return this; | |
74 | + } | |
75 | + | |
76 | + public Evaluator build() { | |
77 | + Evaluator evaluator = new Evaluator(); | |
78 | + evaluator.setProjects(projects); | |
79 | + evaluator.setRecommendations(recommendations); | |
80 | + evaluator.setItemRatings(itemRatings); | |
81 | + evaluator.setRecommendationRatings(recommendationRatings); | |
82 | + evaluator.setId(id); | |
83 | + evaluator.setLogin(login); | |
84 | + evaluator.setOldPassword(oldPassword); | |
85 | + evaluator.setName(name); | |
86 | + evaluator.setEmail(email); | |
87 | + evaluator.setPassword(password); | |
88 | + return evaluator; | |
89 | + } | |
90 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/builder/ItemBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,83 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.model.*; | |
4 | + | |
5 | +import java.util.List; | |
6 | + | |
7 | +public final class ItemBuilder { | |
8 | + private Integer id; | |
9 | + private String name; | |
10 | + private String description; | |
11 | + private List<ItemRating> itemRatings; | |
12 | + private List<Recommendation> recommendations; | |
13 | + private Project project; | |
14 | + private TypeItem typeItem; | |
15 | + private List<Tag> tags; | |
16 | + private List<Attribute> attributes; | |
17 | + | |
18 | + private ItemBuilder() { | |
19 | + } | |
20 | + | |
21 | + public static ItemBuilder anItem() { | |
22 | + return new ItemBuilder(); | |
23 | + } | |
24 | + | |
25 | + public ItemBuilder withId(Integer id) { | |
26 | + this.id = id; | |
27 | + return this; | |
28 | + } | |
29 | + | |
30 | + public ItemBuilder withName(String name) { | |
31 | + this.name = name; | |
32 | + return this; | |
33 | + } | |
34 | + | |
35 | + public ItemBuilder withDescription(String description) { | |
36 | + this.description = description; | |
37 | + return this; | |
38 | + } | |
39 | + | |
40 | + public ItemBuilder withItemRatings(List<ItemRating> itemRatings) { | |
41 | + this.itemRatings = itemRatings; | |
42 | + return this; | |
43 | + } | |
44 | + | |
45 | + public ItemBuilder withRecommendations(List<Recommendation> recommendations) { | |
46 | + this.recommendations = recommendations; | |
47 | + return this; | |
48 | + } | |
49 | + | |
50 | + public ItemBuilder withProject(Project project) { | |
51 | + this.project = project; | |
52 | + return this; | |
53 | + } | |
54 | + | |
55 | + public ItemBuilder withTypeItem(TypeItem typeItem) { | |
56 | + this.typeItem = typeItem; | |
57 | + return this; | |
58 | + } | |
59 | + | |
60 | + public ItemBuilder withTags(List<Tag> tags) { | |
61 | + this.tags = tags; | |
62 | + return this; | |
63 | + } | |
64 | + | |
65 | + public ItemBuilder withAttributes(List<Attribute> attributes) { | |
66 | + this.attributes = attributes; | |
67 | + return this; | |
68 | + } | |
69 | + | |
70 | + public Item build() { | |
71 | + Item item = new Item(); | |
72 | + item.setId(id); | |
73 | + item.setName(name); | |
74 | + item.setDescription(description); | |
75 | + item.setItemRatings(itemRatings); | |
76 | + item.setRecommendations(recommendations); | |
77 | + item.setProject(project); | |
78 | + item.setTypeItem(typeItem); | |
79 | + item.setTags(tags); | |
80 | + item.setAttributes(attributes); | |
81 | + return item; | |
82 | + } | |
83 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/builder/ItemRatingBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,57 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.model.Evaluator; | |
4 | +import com.srh.api.model.Item; | |
5 | +import com.srh.api.model.ItemRating; | |
6 | + | |
7 | +import java.time.LocalDateTime; | |
8 | + | |
9 | +public final class ItemRatingBuilder { | |
10 | + private Evaluator evaluator; | |
11 | + private Item item; | |
12 | + private Integer id; | |
13 | + private Double score; | |
14 | + private LocalDateTime date; | |
15 | + | |
16 | + private ItemRatingBuilder() { | |
17 | + } | |
18 | + | |
19 | + public static ItemRatingBuilder anItemRating() { | |
20 | + return new ItemRatingBuilder(); | |
21 | + } | |
22 | + | |
23 | + public ItemRatingBuilder withEvaluator(Evaluator evaluator) { | |
24 | + this.evaluator = evaluator; | |
25 | + return this; | |
26 | + } | |
27 | + | |
28 | + public ItemRatingBuilder withItem(Item item) { | |
29 | + this.item = item; | |
30 | + return this; | |
31 | + } | |
32 | + | |
33 | + public ItemRatingBuilder withId(Integer id) { | |
34 | + this.id = id; | |
35 | + return this; | |
36 | + } | |
37 | + | |
38 | + public ItemRatingBuilder withScore(Double score) { | |
39 | + this.score = score; | |
40 | + return this; | |
41 | + } | |
42 | + | |
43 | + public ItemRatingBuilder withDate(LocalDateTime date) { | |
44 | + this.date = date; | |
45 | + return this; | |
46 | + } | |
47 | + | |
48 | + public ItemRating build() { | |
49 | + ItemRating itemRating = new ItemRating(); | |
50 | + itemRating.setEvaluator(evaluator); | |
51 | + itemRating.setItem(item); | |
52 | + itemRating.setId(id); | |
53 | + itemRating.setScore(score); | |
54 | + itemRating.setDate(date); | |
55 | + return itemRating; | |
56 | + } | |
57 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/builder/ItemTagBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,31 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.model.Item; | |
4 | +import com.srh.api.model.ItemTag; | |
5 | +import com.srh.api.model.Tag; | |
6 | + | |
7 | +public final class ItemTagBuilder { | |
8 | + private Item item; | |
9 | + private Tag tag; | |
10 | + | |
11 | + private ItemTagBuilder() { | |
12 | + } | |
13 | + | |
14 | + public static ItemTagBuilder anItemTag() { | |
15 | + return new ItemTagBuilder(); | |
16 | + } | |
17 | + | |
18 | + public ItemTagBuilder withItem(Item item) { | |
19 | + this.item = item; | |
20 | + return this; | |
21 | + } | |
22 | + | |
23 | + public ItemTagBuilder withTag(Tag tag) { | |
24 | + this.tag = tag; | |
25 | + return this; | |
26 | + } | |
27 | + | |
28 | + public ItemTag build() { | |
29 | + return new ItemTag(item, tag); | |
30 | + } | |
31 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/builder/LoginFormBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,32 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.dto.auth.LoginForm; | |
4 | + | |
5 | +public final class LoginFormBuilder { | |
6 | + private String login; | |
7 | + private String password; | |
8 | + | |
9 | + private LoginFormBuilder() { | |
10 | + } | |
11 | + | |
12 | + public static LoginFormBuilder aLoginForm() { | |
13 | + return new LoginFormBuilder(); | |
14 | + } | |
15 | + | |
16 | + public LoginFormBuilder withLogin(String login) { | |
17 | + this.login = login; | |
18 | + return this; | |
19 | + } | |
20 | + | |
21 | + public LoginFormBuilder withPassword(String password) { | |
22 | + this.password = password; | |
23 | + return this; | |
24 | + } | |
25 | + | |
26 | + public LoginForm build() { | |
27 | + LoginForm loginForm = new LoginForm(); | |
28 | + loginForm.setLogin(login); | |
29 | + loginForm.setPassword(password); | |
30 | + return loginForm; | |
31 | + } | |
32 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/builder/ProfileBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,42 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.model.ApiUser; | |
4 | +import com.srh.api.model.Profile; | |
5 | + | |
6 | +import java.util.List; | |
7 | + | |
8 | +public final class ProfileBuilder { | |
9 | + private Integer id; | |
10 | + private String name; | |
11 | + private List<ApiUser> apiUsers; | |
12 | + | |
13 | + private ProfileBuilder() { | |
14 | + } | |
15 | + | |
16 | + public static ProfileBuilder aProfile() { | |
17 | + return new ProfileBuilder(); | |
18 | + } | |
19 | + | |
20 | + public ProfileBuilder withId(Integer id) { | |
21 | + this.id = id; | |
22 | + return this; | |
23 | + } | |
24 | + | |
25 | + public ProfileBuilder withName(String name) { | |
26 | + this.name = name; | |
27 | + return this; | |
28 | + } | |
29 | + | |
30 | + public ProfileBuilder withApiUsers(List<ApiUser> apiUsers) { | |
31 | + this.apiUsers = apiUsers; | |
32 | + return this; | |
33 | + } | |
34 | + | |
35 | + public Profile build() { | |
36 | + Profile profile = new Profile(); | |
37 | + profile.setId(id); | |
38 | + profile.setName(name); | |
39 | + profile.setApiUsers(apiUsers); | |
40 | + return profile; | |
41 | + } | |
42 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/builder/ProjectBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,91 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.model.*; | |
4 | + | |
5 | +import java.time.LocalDate; | |
6 | +import java.util.List; | |
7 | + | |
8 | +public final class ProjectBuilder { | |
9 | + private Integer id; | |
10 | + private String name; | |
11 | + private String description; | |
12 | + private LocalDate date; | |
13 | + private Boolean visible; | |
14 | + private Integer lastMatrixId; | |
15 | + private Situations situation; | |
16 | + private Admin admin; | |
17 | + private List<Evaluator> evaluators; | |
18 | + private List<Item> itens; | |
19 | + | |
20 | + private ProjectBuilder() { | |
21 | + } | |
22 | + | |
23 | + public static ProjectBuilder aProject() { | |
24 | + return new ProjectBuilder(); | |
25 | + } | |
26 | + | |
27 | + public ProjectBuilder withId(Integer id) { | |
28 | + this.id = id; | |
29 | + return this; | |
30 | + } | |
31 | + | |
32 | + public ProjectBuilder withName(String name) { | |
33 | + this.name = name; | |
34 | + return this; | |
35 | + } | |
36 | + | |
37 | + public ProjectBuilder withDescription(String description) { | |
38 | + this.description = description; | |
39 | + return this; | |
40 | + } | |
41 | + | |
42 | + public ProjectBuilder withDate(LocalDate date) { | |
43 | + this.date = date; | |
44 | + return this; | |
45 | + } | |
46 | + | |
47 | + public ProjectBuilder withVisible(Boolean visible) { | |
48 | + this.visible = visible; | |
49 | + return this; | |
50 | + } | |
51 | + | |
52 | + public ProjectBuilder withLastMatrixId(Integer lastMatrixId) { | |
53 | + this.lastMatrixId = lastMatrixId; | |
54 | + return this; | |
55 | + } | |
56 | + | |
57 | + public ProjectBuilder withSituation(Situations situation) { | |
58 | + this.situation = situation; | |
59 | + return this; | |
60 | + } | |
61 | + | |
62 | + public ProjectBuilder withAdmin(Admin admin) { | |
63 | + this.admin = admin; | |
64 | + return this; | |
65 | + } | |
66 | + | |
67 | + public ProjectBuilder withEvaluators(List<Evaluator> evaluators) { | |
68 | + this.evaluators = evaluators; | |
69 | + return this; | |
70 | + } | |
71 | + | |
72 | + public ProjectBuilder withItens(List<Item> itens) { | |
73 | + this.itens = itens; | |
74 | + return this; | |
75 | + } | |
76 | + | |
77 | + public Project build() { | |
78 | + Project project = new Project(); | |
79 | + project.setId(id); | |
80 | + project.setName(name); | |
81 | + project.setDescription(description); | |
82 | + project.setDate(date); | |
83 | + project.setVisible(visible); | |
84 | + project.setLastMatrixId(lastMatrixId); | |
85 | + project.setSituation(situation); | |
86 | + project.setAdmin(admin); | |
87 | + project.setEvaluators(evaluators); | |
88 | + project.setItens(itens); | |
89 | + return project; | |
90 | + } | |
91 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/builder/RecommendationBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,84 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.model.*; | |
4 | + | |
5 | +import java.time.LocalDateTime; | |
6 | +import java.util.List; | |
7 | + | |
8 | +public final class RecommendationBuilder { | |
9 | + private Integer id; | |
10 | + private Double weight; | |
11 | + private LocalDateTime date; | |
12 | + private Integer runtimeInSeconds; | |
13 | + private Integer matrixId; | |
14 | + private Algorithm algorithm; | |
15 | + private Evaluator evaluator; | |
16 | + private Item item; | |
17 | + private List<RecommendationRating> recommendationRatings; | |
18 | + | |
19 | + private RecommendationBuilder() { | |
20 | + } | |
21 | + | |
22 | + public static RecommendationBuilder aRecommendation() { | |
23 | + return new RecommendationBuilder(); | |
24 | + } | |
25 | + | |
26 | + public RecommendationBuilder withId(Integer id) { | |
27 | + this.id = id; | |
28 | + return this; | |
29 | + } | |
30 | + | |
31 | + public RecommendationBuilder withWeight(Double weight) { | |
32 | + this.weight = weight; | |
33 | + return this; | |
34 | + } | |
35 | + | |
36 | + public RecommendationBuilder withDate(LocalDateTime date) { | |
37 | + this.date = date; | |
38 | + return this; | |
39 | + } | |
40 | + | |
41 | + public RecommendationBuilder withRuntimeInSeconds(Integer runtimeInSeconds) { | |
42 | + this.runtimeInSeconds = runtimeInSeconds; | |
43 | + return this; | |
44 | + } | |
45 | + | |
46 | + public RecommendationBuilder withMatrixId(Integer matrixId) { | |
47 | + this.matrixId = matrixId; | |
48 | + return this; | |
49 | + } | |
50 | + | |
51 | + public RecommendationBuilder withAlgorithm(Algorithm algorithm) { | |
52 | + this.algorithm = algorithm; | |
53 | + return this; | |
54 | + } | |
55 | + | |
56 | + public RecommendationBuilder withEvaluator(Evaluator evaluator) { | |
57 | + this.evaluator = evaluator; | |
58 | + return this; | |
59 | + } | |
60 | + | |
61 | + public RecommendationBuilder withItem(Item item) { | |
62 | + this.item = item; | |
63 | + return this; | |
64 | + } | |
65 | + | |
66 | + public RecommendationBuilder withRecommendationRatings(List<RecommendationRating> recommendationRatings) { | |
67 | + this.recommendationRatings = recommendationRatings; | |
68 | + return this; | |
69 | + } | |
70 | + | |
71 | + public Recommendation build() { | |
72 | + Recommendation recommendation = new Recommendation(); | |
73 | + recommendation.setId(id); | |
74 | + recommendation.setWeight(weight); | |
75 | + recommendation.setDate(date); | |
76 | + recommendation.setRuntimeInSeconds(runtimeInSeconds); | |
77 | + recommendation.setMatrixId(matrixId); | |
78 | + recommendation.setAlgorithm(algorithm); | |
79 | + recommendation.setEvaluator(evaluator); | |
80 | + recommendation.setItem(item); | |
81 | + recommendation.setRecommendationRatings(recommendationRatings); | |
82 | + return recommendation; | |
83 | + } | |
84 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/builder/RecommendationRatingBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,57 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.model.Evaluator; | |
4 | +import com.srh.api.model.Recommendation; | |
5 | +import com.srh.api.model.RecommendationRating; | |
6 | + | |
7 | +import java.time.LocalDateTime; | |
8 | + | |
9 | +public final class RecommendationRatingBuilder { | |
10 | + private Recommendation recommendation; | |
11 | + private Evaluator evaluator; | |
12 | + private Integer id; | |
13 | + private Double score; | |
14 | + private LocalDateTime date; | |
15 | + | |
16 | + private RecommendationRatingBuilder() { | |
17 | + } | |
18 | + | |
19 | + public static RecommendationRatingBuilder aRecommendationRating() { | |
20 | + return new RecommendationRatingBuilder(); | |
21 | + } | |
22 | + | |
23 | + public RecommendationRatingBuilder withRecommendation(Recommendation recommendation) { | |
24 | + this.recommendation = recommendation; | |
25 | + return this; | |
26 | + } | |
27 | + | |
28 | + public RecommendationRatingBuilder withEvaluator(Evaluator evaluator) { | |
29 | + this.evaluator = evaluator; | |
30 | + return this; | |
31 | + } | |
32 | + | |
33 | + public RecommendationRatingBuilder withId(Integer id) { | |
34 | + this.id = id; | |
35 | + return this; | |
36 | + } | |
37 | + | |
38 | + public RecommendationRatingBuilder withScore(Double score) { | |
39 | + this.score = score; | |
40 | + return this; | |
41 | + } | |
42 | + | |
43 | + public RecommendationRatingBuilder withDate(LocalDateTime date) { | |
44 | + this.date = date; | |
45 | + return this; | |
46 | + } | |
47 | + | |
48 | + public RecommendationRating build() { | |
49 | + RecommendationRating recommendationRating = new RecommendationRating(); | |
50 | + recommendationRating.setRecommendation(recommendation); | |
51 | + recommendationRating.setEvaluator(evaluator); | |
52 | + recommendationRating.setId(id); | |
53 | + recommendationRating.setScore(score); | |
54 | + recommendationRating.setDate(date); | |
55 | + return recommendationRating; | |
56 | + } | |
57 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/builder/TagBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,42 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.model.Item; | |
4 | +import com.srh.api.model.Tag; | |
5 | + | |
6 | +import java.util.List; | |
7 | + | |
8 | +public final class TagBuilder { | |
9 | + private Integer id; | |
10 | + private String name; | |
11 | + private List<Item> itens; | |
12 | + | |
13 | + private TagBuilder() { | |
14 | + } | |
15 | + | |
16 | + public static TagBuilder aTag() { | |
17 | + return new TagBuilder(); | |
18 | + } | |
19 | + | |
20 | + public TagBuilder withId(Integer id) { | |
21 | + this.id = id; | |
22 | + return this; | |
23 | + } | |
24 | + | |
25 | + public TagBuilder withName(String name) { | |
26 | + this.name = name; | |
27 | + return this; | |
28 | + } | |
29 | + | |
30 | + public TagBuilder withItens(List<Item> itens) { | |
31 | + this.itens = itens; | |
32 | + return this; | |
33 | + } | |
34 | + | |
35 | + public Tag build() { | |
36 | + Tag tag = new Tag(); | |
37 | + tag.setId(id); | |
38 | + tag.setName(name); | |
39 | + tag.setItens(itens); | |
40 | + return tag; | |
41 | + } | |
42 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/builder/TypeItemBuilder.java
0 → 100644
... | ... | @@ -0,0 +1,50 @@ |
1 | +package com.srh.api.builder; | |
2 | + | |
3 | +import com.srh.api.model.Attribute; | |
4 | +import com.srh.api.model.Item; | |
5 | +import com.srh.api.model.TypeItem; | |
6 | + | |
7 | +import java.util.List; | |
8 | + | |
9 | +public final class TypeItemBuilder { | |
10 | + private Integer id; | |
11 | + private String name; | |
12 | + private List<Item> itens; | |
13 | + private List<Attribute> attributes; | |
14 | + | |
15 | + private TypeItemBuilder() { | |
16 | + } | |
17 | + | |
18 | + public static TypeItemBuilder aTypeItem() { | |
19 | + return new TypeItemBuilder(); | |
20 | + } | |
21 | + | |
22 | + public TypeItemBuilder withId(Integer id) { | |
23 | + this.id = id; | |
24 | + return this; | |
25 | + } | |
26 | + | |
27 | + public TypeItemBuilder withName(String name) { | |
28 | + this.name = name; | |
29 | + return this; | |
30 | + } | |
31 | + | |
32 | + public TypeItemBuilder withItens(List<Item> itens) { | |
33 | + this.itens = itens; | |
34 | + return this; | |
35 | + } | |
36 | + | |
37 | + public TypeItemBuilder withAttributes(List<Attribute> attributes) { | |
38 | + this.attributes = attributes; | |
39 | + return this; | |
40 | + } | |
41 | + | |
42 | + public TypeItem build() { | |
43 | + TypeItem typeItem = new TypeItem(); | |
44 | + typeItem.setId(id); | |
45 | + typeItem.setName(name); | |
46 | + typeItem.setItens(itens); | |
47 | + typeItem.setAttributes(attributes); | |
48 | + return typeItem; | |
49 | + } | |
50 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/config/DbSeeder.java
0 → 100644
... | ... | @@ -0,0 +1,141 @@ |
1 | +package com.srh.api.config; | |
2 | + | |
3 | +import com.srh.api.builder.AlgorithmBuilder; | |
4 | +import com.srh.api.builder.ApiUserBuilder; | |
5 | +import com.srh.api.builder.ProfileBuilder; | |
6 | +import com.srh.api.model.Algorithm; | |
7 | +import com.srh.api.model.ApiUser; | |
8 | +import com.srh.api.model.Profile; | |
9 | +import com.srh.api.model.TypeRecommendation; | |
10 | +import com.srh.api.repository.AlgorithmRepository; | |
11 | +import com.srh.api.repository.ApiUserRepository; | |
12 | +import com.srh.api.repository.ProfileRepository; | |
13 | +import org.springframework.beans.factory.annotation.Autowired; | |
14 | +import org.springframework.stereotype.Service; | |
15 | + | |
16 | +import java.util.ArrayList; | |
17 | +import java.util.Arrays; | |
18 | +import java.util.List; | |
19 | + | |
20 | +@Service | |
21 | +public class DbSeeder { | |
22 | + @Autowired | |
23 | + private ApiUserRepository apiUserRepository; | |
24 | + | |
25 | + @Autowired | |
26 | + private ProfileRepository profileRepository; | |
27 | + | |
28 | + @Autowired | |
29 | + private AlgorithmRepository algorithmRepository; | |
30 | + | |
31 | + private Profile adminProfile; | |
32 | + private Profile userProfile; | |
33 | + | |
34 | + public boolean seed() { | |
35 | + createProfileAdmin(); | |
36 | + createProfileUser(); | |
37 | + | |
38 | + createApiUserAdmin(); | |
39 | + createApiUserClient(); | |
40 | + | |
41 | + createAlgorithms(); | |
42 | + | |
43 | + return true; | |
44 | + } | |
45 | + | |
46 | + private void createApiUserAdmin() { | |
47 | + List<Profile> profiles = new ArrayList<>(); | |
48 | + profiles.add(adminProfile); | |
49 | + profiles.add(userProfile); | |
50 | + | |
51 | + ApiUser apiUser = ApiUserBuilder.anApiUser() | |
52 | + .withId(1) | |
53 | + .withEmail("admin@email.com") | |
54 | + .withName("admin") | |
55 | + .withLogin("admin") | |
56 | + .withPassword("$2a$10$sFKmbxbG4ryhwPNx/l3pgOJSt.fW1z6YcUnuE2X8APA/Z3NI/oSpq") | |
57 | + .withProfiles(profiles) | |
58 | + .build(); | |
59 | + | |
60 | + apiUserRepository.save(apiUser); | |
61 | + } | |
62 | + | |
63 | + private void createApiUserClient() { | |
64 | + List<Profile> profiles = new ArrayList<>(); | |
65 | + profiles.add(userProfile); | |
66 | + | |
67 | + ApiUser apiUser = ApiUserBuilder.anApiUser() | |
68 | + .withId(2) | |
69 | + .withEmail("admin@email.com") | |
70 | + .withName("client") | |
71 | + .withLogin("client") | |
72 | + .withPassword("$2a$10$sFKmbxbG4ryhwPNx/l3pgOJSt.fW1z6YcUnuE2X8APA/Z3NI/oSpq") | |
73 | + .withProfiles(profiles) | |
74 | + .build(); | |
75 | + | |
76 | + apiUserRepository.save(apiUser); | |
77 | + } | |
78 | + | |
79 | + private void createProfileAdmin() { | |
80 | + Profile profile = ProfileBuilder.aProfile() | |
81 | + .withId(1) | |
82 | + .withName("ROLE_ADMIN") | |
83 | + .build(); | |
84 | + | |
85 | + adminProfile = profile; | |
86 | + profileRepository.save(profile); | |
87 | + } | |
88 | + | |
89 | + private void createProfileUser() { | |
90 | + Profile profile = ProfileBuilder.aProfile() | |
91 | + .withId(2) | |
92 | + .withName("ROLE_USER") | |
93 | + .build(); | |
94 | + | |
95 | + userProfile = profile; | |
96 | + profileRepository.save(profile); | |
97 | + } | |
98 | + | |
99 | + private void createAlgorithms() { | |
100 | + Algorithm algorithm1 = AlgorithmBuilder.anAlgorithm() | |
101 | + .withId(1) | |
102 | + .withName("Filtragem Colaborativa") | |
103 | + .withTypeRecommendation(TypeRecommendation.COLLABORATIVE) | |
104 | + .build(); | |
105 | + | |
106 | + Algorithm algorithm2 = AlgorithmBuilder.anAlgorithm() | |
107 | + .withId(1) | |
108 | + .withName("Filtragem Baseada em Conteúdo") | |
109 | + .withTypeRecommendation(TypeRecommendation.COLLABORATIVE) | |
110 | + .build(); | |
111 | + | |
112 | + Algorithm algorithm3 = AlgorithmBuilder.anAlgorithm() | |
113 | + .withId(1) | |
114 | + .withName("Filtragem Híbrida ponderada - Single Thread") | |
115 | + .withTypeRecommendation(TypeRecommendation.COLLABORATIVE) | |
116 | + .build(); | |
117 | + | |
118 | + Algorithm algorithm4 = AlgorithmBuilder.anAlgorithm() | |
119 | + .withId(1) | |
120 | + .withName("Filtragem Híbrida ponderada - Multi Thread") | |
121 | + .withTypeRecommendation(TypeRecommendation.COLLABORATIVE) | |
122 | + .build(); | |
123 | + | |
124 | + Algorithm algorithm5 = AlgorithmBuilder.anAlgorithm() | |
125 | + .withId(1) | |
126 | + .withName("Filtragem Híbrida Mista - Single Thread") | |
127 | + .withTypeRecommendation(TypeRecommendation.COLLABORATIVE) | |
128 | + .build(); | |
129 | + | |
130 | + Algorithm algorithm6 = AlgorithmBuilder.anAlgorithm() | |
131 | + .withId(1) | |
132 | + .withName("Filtragem Híbrida Mista - Multi Thread") | |
133 | + .withTypeRecommendation(TypeRecommendation.COLLABORATIVE) | |
134 | + .build(); | |
135 | + | |
136 | + algorithmRepository.saveAll(Arrays.asList( | |
137 | + algorithm1, algorithm2, algorithm3, | |
138 | + algorithm4, algorithm5, algorithm6 | |
139 | + )); | |
140 | + } | |
141 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/config/DevProfile.java
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +package com.srh.api.config; | |
2 | + | |
3 | +import org.springframework.beans.factory.annotation.Autowired; | |
4 | +import org.springframework.beans.factory.annotation.Value; | |
5 | +import org.springframework.context.annotation.Bean; | |
6 | +import org.springframework.context.annotation.Configuration; | |
7 | +import org.springframework.context.annotation.Profile; | |
8 | + | |
9 | +@Configuration | |
10 | +@Profile("dev") | |
11 | +public class DevProfile { | |
12 | + @Autowired | |
13 | + private DbSeeder dbSeeder; | |
14 | + | |
15 | + @Value("${spring.jpa.hibernate.ddl-auto}") | |
16 | + private String strategy; | |
17 | + | |
18 | + @Bean | |
19 | + public boolean initializeDatabase() { | |
20 | + if (strategy.equals("create")) { | |
21 | + return dbSeeder.seed(); | |
22 | + } | |
23 | + | |
24 | + return false; | |
25 | + } | |
26 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/config/EmailConfig.java
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +package com.srh.api.config; | |
2 | + | |
3 | +import org.springframework.context.annotation.Bean; | |
4 | +import org.springframework.mail.javamail.JavaMailSender; | |
5 | +import org.springframework.mail.javamail.JavaMailSenderImpl; | |
6 | +import org.springframework.stereotype.Component; | |
7 | + | |
8 | +import java.util.Properties; | |
9 | + | |
10 | +@Component | |
11 | +public class EmailConfig { | |
12 | + @Bean | |
13 | + public JavaMailSender getJavaMailSender() { | |
14 | + JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); | |
15 | + mailSender.setHost("smtp.gmail.com"); | |
16 | + mailSender.setPort(587); | |
17 | + | |
18 | + mailSender.setUsername("my.gmail@gmail.com"); | |
19 | + mailSender.setPassword("password"); | |
20 | + | |
21 | + Properties props = mailSender.getJavaMailProperties(); | |
22 | + props.put("mail.transport.protocol", "smtp"); | |
23 | + props.put("mail.smtp.auth", "true"); | |
24 | + props.put("mail.smtp.starttls.enable", "true"); | |
25 | + props.put("mail.debug", "true"); | |
26 | + | |
27 | + return mailSender; | |
28 | + } | |
29 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/config/TestProfile.java
0 → 100644
... | ... | @@ -0,0 +1,18 @@ |
1 | +package com.srh.api.config; | |
2 | + | |
3 | +import org.springframework.beans.factory.annotation.Autowired; | |
4 | +import org.springframework.context.annotation.Bean; | |
5 | +import org.springframework.context.annotation.Configuration; | |
6 | +import org.springframework.context.annotation.Profile; | |
7 | + | |
8 | +@Configuration | |
9 | +@Profile("test") | |
10 | +public class TestProfile { | |
11 | + @Autowired | |
12 | + private DbSeeder dbSeeder; | |
13 | + | |
14 | + @Bean | |
15 | + public boolean initializeDatabase() { | |
16 | + return dbSeeder.seed(); | |
17 | + } | |
18 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/AdminController.java
0 → 100644
... | ... | @@ -0,0 +1,97 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.AdminDto; | |
4 | +import com.srh.api.dto.resource.AdminForm; | |
5 | +import com.srh.api.dto.resource.ProjectDto; | |
6 | +import com.srh.api.dto.resource.TypeItemDto; | |
7 | +import com.srh.api.hypermedia.AdminModelAssembler; | |
8 | +import com.srh.api.model.Admin; | |
9 | +import com.srh.api.model.Project; | |
10 | +import com.srh.api.model.TypeItem; | |
11 | +import com.srh.api.service.AdminService; | |
12 | +import com.srh.api.utils.PageUtil; | |
13 | +import lombok.SneakyThrows; | |
14 | +import org.springframework.beans.factory.annotation.Autowired; | |
15 | +import org.springframework.data.domain.Page; | |
16 | +import org.springframework.data.domain.Pageable; | |
17 | +import org.springframework.data.web.PageableDefault; | |
18 | +import org.springframework.data.web.PagedResourcesAssembler; | |
19 | +import org.springframework.hateoas.EntityModel; | |
20 | +import org.springframework.hateoas.PagedModel; | |
21 | +import org.springframework.http.ResponseEntity; | |
22 | +import org.springframework.web.bind.annotation.*; | |
23 | +import org.springframework.web.util.UriComponentsBuilder; | |
24 | + | |
25 | +import javax.transaction.Transactional; | |
26 | +import javax.validation.Valid; | |
27 | +import java.net.URI; | |
28 | + | |
29 | +import static com.srh.api.dto.resource.AdminDto.convert; | |
30 | + | |
31 | +@RestController | |
32 | +@RequestMapping("/users/admins") | |
33 | +public class AdminController { | |
34 | + @Autowired | |
35 | + private AdminService adminService; | |
36 | + | |
37 | + @Autowired | |
38 | + private AdminModelAssembler adminModelAssembler; | |
39 | + | |
40 | + @Autowired | |
41 | + private PagedResourcesAssembler<AdminDto> pagedResourcesAssembler; | |
42 | + | |
43 | + @Autowired | |
44 | + private PagedResourcesAssembler<ProjectDto> projectDtoPagedResourcesAssembler; | |
45 | + | |
46 | + @GetMapping | |
47 | + public PagedModel<EntityModel<AdminDto>> listAll(@PageableDefault(page = 0, size = 5) Pageable pageInfo) { | |
48 | + Page<Admin> admins = adminService.findAll(pageInfo); | |
49 | + return pagedResourcesAssembler.toModel(convert(admins)); | |
50 | + } | |
51 | + | |
52 | + @GetMapping("/{id}") | |
53 | + public EntityModel<AdminDto> find(@PathVariable Integer id) { | |
54 | + Admin admin = adminService.find(id); | |
55 | + return adminModelAssembler.toModel(new AdminDto(admin)); | |
56 | + } | |
57 | + | |
58 | + @PostMapping | |
59 | + public ResponseEntity<EntityModel<AdminDto>> create(@RequestBody @Valid AdminForm adminForm, | |
60 | + UriComponentsBuilder uriBuilder) { | |
61 | + Admin admin = adminForm.build(); | |
62 | + adminService.save(admin); | |
63 | + URI uri = uriBuilder.path("/users/admins/{id}").buildAndExpand(admin.getId()).toUri(); | |
64 | + return ResponseEntity.created(uri) | |
65 | + .body(adminModelAssembler.toModel(new AdminDto(admin))); | |
66 | + } | |
67 | + | |
68 | + @PutMapping("/{id}") | |
69 | + @SneakyThrows | |
70 | + @Transactional | |
71 | + public EntityModel<AdminDto> update(@RequestBody @Valid AdminForm adminForm, @PathVariable Integer id) { | |
72 | + Admin admin = adminForm.build(); | |
73 | + admin.setId(id); | |
74 | + admin = adminService.update(admin, adminForm.getOldPassword()); | |
75 | + return adminModelAssembler.toModel(new AdminDto(admin)); | |
76 | + } | |
77 | + | |
78 | + @DeleteMapping("/{id}") | |
79 | + @Transactional | |
80 | + public ResponseEntity<Void> delete(@PathVariable Integer id) { | |
81 | + adminService.delete(id); | |
82 | + return ResponseEntity.noContent().build(); | |
83 | + } | |
84 | + | |
85 | + @GetMapping("{adminId}/projects") | |
86 | + public PagedModel<EntityModel<ProjectDto>> findProjectsByAdmin( | |
87 | + @PathVariable Integer adminId, | |
88 | + @PageableDefault(page = 0, size = 5) Pageable pageInfo | |
89 | + ) { | |
90 | + PageUtil<Project> pageUtil = new PageUtil<>(pageInfo, adminService. | |
91 | + listProjectsByAdmin(adminId)); | |
92 | + | |
93 | + return projectDtoPagedResourcesAssembler.toModel(ProjectDto.convert( | |
94 | + pageUtil.getPage() | |
95 | + )); | |
96 | + } | |
97 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/AlgorithmController.java
0 → 100644
... | ... | @@ -0,0 +1,76 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.AlgorithmDto; | |
4 | +import com.srh.api.dto.resource.AlgorithmForm; | |
5 | +import com.srh.api.hypermedia.AlgorithmModelAssembler; | |
6 | +import com.srh.api.model.Algorithm; | |
7 | +import com.srh.api.service.AlgorithmService; | |
8 | +import org.springframework.beans.factory.annotation.Autowired; | |
9 | +import org.springframework.data.domain.Page; | |
10 | +import org.springframework.data.domain.Pageable; | |
11 | +import org.springframework.data.web.PageableDefault; | |
12 | +import org.springframework.data.web.PagedResourcesAssembler; | |
13 | +import org.springframework.hateoas.EntityModel; | |
14 | +import org.springframework.hateoas.PagedModel; | |
15 | +import org.springframework.http.ResponseEntity; | |
16 | +import org.springframework.web.bind.annotation.*; | |
17 | +import org.springframework.web.util.UriComponentsBuilder; | |
18 | + | |
19 | +import javax.transaction.Transactional; | |
20 | +import javax.validation.Valid; | |
21 | + | |
22 | +import java.net.URI; | |
23 | + | |
24 | +import static com.srh.api.dto.resource.AlgorithmDto.convert; | |
25 | + | |
26 | +@RestController | |
27 | +@RequestMapping("/algorithms") | |
28 | +public class AlgorithmController { | |
29 | + @Autowired | |
30 | + private AlgorithmService algorithmService; | |
31 | + | |
32 | + @Autowired | |
33 | + private AlgorithmModelAssembler algorithmModelAssembler; | |
34 | + | |
35 | + @Autowired | |
36 | + private PagedResourcesAssembler<AlgorithmDto> pagedResourcesAssembler; | |
37 | + | |
38 | + @GetMapping | |
39 | + public PagedModel<EntityModel<AlgorithmDto>> listAll(@PageableDefault(page = 0, size = 5) | |
40 | + Pageable pageInfo) { | |
41 | + Page<Algorithm> algorithms = algorithmService.findAll(pageInfo); | |
42 | + return pagedResourcesAssembler.toModel(convert(algorithms)); | |
43 | + } | |
44 | + | |
45 | + @GetMapping("/{id}") | |
46 | + public EntityModel<AlgorithmDto> find(@PathVariable Integer id) { | |
47 | + Algorithm algorithm = algorithmService.find(id); | |
48 | + return algorithmModelAssembler.toModel(new AlgorithmDto(algorithm)); | |
49 | + } | |
50 | + | |
51 | + @PostMapping | |
52 | + public ResponseEntity<EntityModel<AlgorithmDto>> create(@RequestBody @Valid AlgorithmForm algorithmForm, | |
53 | + UriComponentsBuilder uriBuilder) { | |
54 | + Algorithm algorithm = algorithmForm.build(); | |
55 | + algorithmService.save(algorithm); | |
56 | + URI uri = uriBuilder.path("/algorithms/{id}").buildAndExpand(algorithm.getId()).toUri(); | |
57 | + return ResponseEntity.created(uri) | |
58 | + .body(algorithmModelAssembler.toModel(new AlgorithmDto(algorithm))); | |
59 | + } | |
60 | + | |
61 | + @PutMapping("/{id}") | |
62 | + @Transactional | |
63 | + public EntityModel<AlgorithmDto> update(@RequestBody @Valid AlgorithmForm algorithmForm, | |
64 | + @PathVariable Integer id) { | |
65 | + Algorithm algorithm = algorithmForm.build(); | |
66 | + algorithm.setId(id); | |
67 | + algorithm = algorithmService.update(algorithm); | |
68 | + return algorithmModelAssembler.toModel(new AlgorithmDto(algorithm)); | |
69 | + } | |
70 | + | |
71 | + @DeleteMapping("/{id}") | |
72 | + public ResponseEntity<Void> delete(@PathVariable Integer id) { | |
73 | + algorithmService.delete(id); | |
74 | + return ResponseEntity.noContent().build(); | |
75 | + } | |
76 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/ApiUsersController.java
0 → 100644
... | ... | @@ -0,0 +1,87 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.ApiUserForm; | |
4 | +import com.srh.api.dto.resource.ApiUsersDto; | |
5 | +import com.srh.api.hypermedia.ApiUserModelAssembler; | |
6 | +import com.srh.api.model.ApiUser; | |
7 | +import com.srh.api.model.Profile; | |
8 | +import com.srh.api.service.ApiUserService; | |
9 | +import com.srh.api.service.ProfileService; | |
10 | +import org.springframework.beans.factory.annotation.Autowired; | |
11 | +import org.springframework.data.domain.Page; | |
12 | +import org.springframework.data.domain.Pageable; | |
13 | +import org.springframework.data.web.PageableDefault; | |
14 | +import org.springframework.data.web.PagedResourcesAssembler; | |
15 | +import org.springframework.hateoas.EntityModel; | |
16 | +import org.springframework.hateoas.PagedModel; | |
17 | +import org.springframework.http.ResponseEntity; | |
18 | +import org.springframework.web.bind.annotation.*; | |
19 | +import org.springframework.web.util.UriComponentsBuilder; | |
20 | + | |
21 | +import javax.transaction.Transactional; | |
22 | +import javax.validation.Valid; | |
23 | +import java.net.URI; | |
24 | +import java.util.List; | |
25 | + | |
26 | +@RestController | |
27 | +@RequestMapping("/users/apis") | |
28 | +public class ApiUsersController { | |
29 | + @Autowired | |
30 | + private ApiUserService apiUserService; | |
31 | + | |
32 | + @Autowired | |
33 | + private ProfileService profileService; | |
34 | + | |
35 | + @Autowired | |
36 | + private ApiUserModelAssembler apiUserModelAssembler; | |
37 | + | |
38 | + @Autowired | |
39 | + private PagedResourcesAssembler<ApiUsersDto> pagedResourcesAssembler; | |
40 | + | |
41 | + @GetMapping | |
42 | + public PagedModel<EntityModel<ApiUsersDto>> listAll(@PageableDefault(page = 0, size = 5) | |
43 | + Pageable pageInfo) { | |
44 | + Page<ApiUser> users = apiUserService.findAll(pageInfo); | |
45 | + return pagedResourcesAssembler.toModel(ApiUsersDto.convert(users)); | |
46 | + } | |
47 | + | |
48 | + @GetMapping("/{id}") | |
49 | + public EntityModel<ApiUsersDto> find(@PathVariable Integer id) { | |
50 | + ApiUser apiUser = apiUserService.find(id); | |
51 | + return apiUserModelAssembler.toModel(new ApiUsersDto(apiUser)); | |
52 | + } | |
53 | + | |
54 | + @PostMapping | |
55 | + public ResponseEntity<EntityModel<ApiUsersDto>> create(@RequestBody @Valid ApiUserForm apiUserForm, | |
56 | + UriComponentsBuilder uriBuilder) { | |
57 | + ApiUser apiUser = apiUserForm.build(); | |
58 | + List<Profile> profiles = profileService.getProfilesByAuthority(apiUserForm.getIsAdmin()); | |
59 | + | |
60 | + apiUser.setProfiles(profiles); | |
61 | + apiUserService.save(apiUser); | |
62 | + | |
63 | + URI uri = uriBuilder.path("/users/apis/{id}").buildAndExpand(apiUser.getId()).toUri(); | |
64 | + return ResponseEntity.created(uri) | |
65 | + .body(apiUserModelAssembler.toModel(new ApiUsersDto(apiUser))); | |
66 | + } | |
67 | + | |
68 | + @PutMapping("/{id}") | |
69 | + @Transactional | |
70 | + public EntityModel<ApiUsersDto> update(@RequestBody @Valid ApiUserForm apiUserForm, | |
71 | + @PathVariable Integer id) { | |
72 | + ApiUser apiUser = apiUserForm.build(); | |
73 | + List<Profile> profiles = profileService.getProfilesByAuthority(apiUserForm.getIsAdmin()); | |
74 | + | |
75 | + apiUser.setId(id); | |
76 | + apiUser.setProfiles(profiles); | |
77 | + apiUser = apiUserService.update(apiUser, apiUserForm.getOldPassword()); | |
78 | + return apiUserModelAssembler.toModel(new ApiUsersDto(apiUser)); | |
79 | + } | |
80 | + | |
81 | + @DeleteMapping("/{id}") | |
82 | + @Transactional | |
83 | + public ResponseEntity<Void> delete(@PathVariable Integer id) { | |
84 | + apiUserService.delete(id); | |
85 | + return ResponseEntity.noContent().build(); | |
86 | + } | |
87 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/AttributeController.java
0 → 100644
... | ... | @@ -0,0 +1,76 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.AttributeDto; | |
4 | +import com.srh.api.dto.resource.AttributeForm; | |
5 | +import com.srh.api.hypermedia.AttributeModelAssembler; | |
6 | +import com.srh.api.model.Attribute; | |
7 | +import com.srh.api.service.AttributeService; | |
8 | +import org.springframework.beans.factory.annotation.Autowired; | |
9 | +import org.springframework.data.domain.Page; | |
10 | +import org.springframework.data.domain.Pageable; | |
11 | +import org.springframework.data.web.PageableDefault; | |
12 | +import org.springframework.data.web.PagedResourcesAssembler; | |
13 | +import org.springframework.hateoas.EntityModel; | |
14 | +import org.springframework.hateoas.PagedModel; | |
15 | +import org.springframework.http.ResponseEntity; | |
16 | +import org.springframework.web.bind.annotation.*; | |
17 | +import org.springframework.web.util.UriComponentsBuilder; | |
18 | + | |
19 | +import javax.transaction.Transactional; | |
20 | +import javax.validation.Valid; | |
21 | + | |
22 | +import java.net.URI; | |
23 | + | |
24 | +import static com.srh.api.dto.resource.AttributeDto.convert; | |
25 | + | |
26 | +@RestController | |
27 | +@RequestMapping("/attributes") | |
28 | +public class AttributeController { | |
29 | + @Autowired | |
30 | + private AttributeService attributeService; | |
31 | + | |
32 | + @Autowired | |
33 | + private AttributeModelAssembler attributeModelAssembler; | |
34 | + | |
35 | + @Autowired | |
36 | + private PagedResourcesAssembler<AttributeDto> pagedResourcesAssembler; | |
37 | + | |
38 | + @GetMapping | |
39 | + public PagedModel<EntityModel<AttributeDto>> listAll(@PageableDefault(page = 0, size = 5) | |
40 | + Pageable pageInfo) { | |
41 | + Page<Attribute> attributes = attributeService.findAll(pageInfo); | |
42 | + return pagedResourcesAssembler.toModel(convert(attributes)); | |
43 | + } | |
44 | + | |
45 | + @GetMapping("/{id}") | |
46 | + public EntityModel<AttributeDto> find(@PathVariable Integer id) { | |
47 | + Attribute attribute = attributeService.find(id); | |
48 | + return attributeModelAssembler.toModel(new AttributeDto(attribute)); | |
49 | + } | |
50 | + | |
51 | + @PostMapping | |
52 | + public ResponseEntity<EntityModel<AttributeDto>> create(@RequestBody @Valid AttributeForm attributeForm, | |
53 | + UriComponentsBuilder uriBuilder) { | |
54 | + Attribute attribute = attributeForm.build(); | |
55 | + attributeService.save(attribute); | |
56 | + URI uri = uriBuilder.path("/attributes").buildAndExpand(attribute.getId()).toUri(); | |
57 | + return ResponseEntity.created(uri) | |
58 | + .body(attributeModelAssembler.toModel(new AttributeDto(attribute))); | |
59 | + } | |
60 | + | |
61 | + @PutMapping("/{id}") | |
62 | + @Transactional | |
63 | + public EntityModel<AttributeDto> update(@RequestBody @Valid AttributeForm attributeForm, | |
64 | + @PathVariable Integer id) { | |
65 | + Attribute attribute = attributeForm.build(); | |
66 | + attribute.setId(id); | |
67 | + attribute = attributeService.update(attribute); | |
68 | + return attributeModelAssembler.toModel(new AttributeDto(attribute)); | |
69 | + } | |
70 | + | |
71 | + @DeleteMapping("/{id}") | |
72 | + public ResponseEntity<Void> delete(@PathVariable Integer id) { | |
73 | + attributeService.delete(id); | |
74 | + return ResponseEntity.noContent().build(); | |
75 | + } | |
76 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/AuthController.java
0 → 100644
... | ... | @@ -0,0 +1,55 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.auth.AuthDto; | |
4 | +import com.srh.api.dto.auth.LoginForm; | |
5 | +import com.srh.api.error.exception.InvalidUserInTokenException; | |
6 | +import com.srh.api.service.JWTService; | |
7 | +import org.springframework.beans.factory.annotation.Autowired; | |
8 | +import org.springframework.http.HttpHeaders; | |
9 | +import org.springframework.http.ResponseEntity; | |
10 | +import org.springframework.security.authentication.AuthenticationManager; | |
11 | +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; | |
12 | +import org.springframework.security.core.Authentication; | |
13 | +import org.springframework.security.core.AuthenticationException; | |
14 | +import org.springframework.web.bind.annotation.PostMapping; | |
15 | +import org.springframework.web.bind.annotation.RequestBody; | |
16 | +import org.springframework.web.bind.annotation.RequestMapping; | |
17 | +import org.springframework.web.bind.annotation.RestController; | |
18 | + | |
19 | +import javax.validation.Valid; | |
20 | + | |
21 | +import static com.srh.api.security.SecurityConstants.*; | |
22 | + | |
23 | +@RestController | |
24 | +@RequestMapping("/auth") | |
25 | +public class AuthController { | |
26 | + @Autowired | |
27 | + private AuthenticationManager authManager; | |
28 | + | |
29 | + @Autowired | |
30 | + private JWTService jwtService; | |
31 | + | |
32 | + @PostMapping | |
33 | + public ResponseEntity<AuthDto> auth(@RequestBody @Valid LoginForm form) { | |
34 | + UsernamePasswordAuthenticationToken loginUser = form.convert(); | |
35 | + String token = generatedTokenForAuthenticatedUser(loginUser); | |
36 | + return ResponseEntity.ok() | |
37 | + .headers(generateAuthorizationHeader(token)) | |
38 | + .body(new AuthDto(token, "Bearer")); | |
39 | + } | |
40 | + | |
41 | + public String generatedTokenForAuthenticatedUser(UsernamePasswordAuthenticationToken userToken) { | |
42 | + try { | |
43 | + Authentication authentication = authManager.authenticate(userToken); | |
44 | + return jwtService.buildToken(authentication); | |
45 | + } catch (AuthenticationException e) { | |
46 | + throw new InvalidUserInTokenException(e); | |
47 | + } | |
48 | + } | |
49 | + | |
50 | + private HttpHeaders generateAuthorizationHeader(String token) { | |
51 | + HttpHeaders responseHeaders = new HttpHeaders(); | |
52 | + responseHeaders.set(HEADER, TOKEN_PREFIX + token); | |
53 | + return responseHeaders; | |
54 | + } | |
55 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/EvaluatorController.java
0 → 100644
... | ... | @@ -0,0 +1,75 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.EvaluatorDto; | |
4 | +import com.srh.api.dto.resource.EvaluatorForm; | |
5 | +import com.srh.api.hypermedia.EvaluatorModelAssembler; | |
6 | +import com.srh.api.model.Evaluator; | |
7 | +import com.srh.api.service.EvaluatorService; | |
8 | +import org.springframework.beans.factory.annotation.Autowired; | |
9 | +import org.springframework.data.domain.Page; | |
10 | +import org.springframework.data.domain.Pageable; | |
11 | +import org.springframework.data.web.PageableDefault; | |
12 | +import org.springframework.data.web.PagedResourcesAssembler; | |
13 | +import org.springframework.hateoas.EntityModel; | |
14 | +import org.springframework.hateoas.PagedModel; | |
15 | +import org.springframework.http.ResponseEntity; | |
16 | +import org.springframework.web.bind.annotation.*; | |
17 | +import org.springframework.web.util.UriComponentsBuilder; | |
18 | + | |
19 | +import javax.transaction.Transactional; | |
20 | +import javax.validation.Valid; | |
21 | +import java.net.URI; | |
22 | + | |
23 | +import static com.srh.api.dto.resource.EvaluatorDto.convert; | |
24 | + | |
25 | +@RestController | |
26 | +@RequestMapping("/users/evaluators") | |
27 | +public class EvaluatorController { | |
28 | + @Autowired | |
29 | + private EvaluatorService evaluatorService; | |
30 | + | |
31 | + @Autowired | |
32 | + private EvaluatorModelAssembler evaluatorModelAssembler; | |
33 | + | |
34 | + @Autowired | |
35 | + private PagedResourcesAssembler<EvaluatorDto> pagedResourcesAssembler; | |
36 | + | |
37 | + @GetMapping | |
38 | + public PagedModel<EntityModel<EvaluatorDto>> listAll(@PageableDefault(page = 0, size = 5) | |
39 | + Pageable pageInfo) { | |
40 | + Page<Evaluator> users = evaluatorService.findAll(pageInfo); | |
41 | + return pagedResourcesAssembler.toModel(convert(users)); | |
42 | + } | |
43 | + | |
44 | + @GetMapping("/{id}") | |
45 | + public EntityModel<EvaluatorDto> find(@PathVariable Integer id) { | |
46 | + Evaluator evaluator = evaluatorService.find(id); | |
47 | + return evaluatorModelAssembler.toModel(new EvaluatorDto(evaluator)); | |
48 | + } | |
49 | + | |
50 | + @PostMapping | |
51 | + public ResponseEntity<EntityModel<EvaluatorDto>> create(@RequestBody @Valid EvaluatorForm evaluatorForm, | |
52 | + UriComponentsBuilder uriBuilder) { | |
53 | + Evaluator evaluator = evaluatorForm.build(); | |
54 | + evaluatorService.save(evaluator); | |
55 | + URI uri = uriBuilder.path("/users/evaluators/{id}").buildAndExpand(evaluator.getId()).toUri(); | |
56 | + return ResponseEntity.created(uri) | |
57 | + .body(evaluatorModelAssembler.toModel(new EvaluatorDto(evaluator))); | |
58 | + } | |
59 | + | |
60 | + @PutMapping("/{id}") | |
61 | + @Transactional | |
62 | + public EntityModel<EvaluatorDto> update(@RequestBody @Valid EvaluatorForm evaluatorForm, | |
63 | + @PathVariable Integer id) { | |
64 | + Evaluator evaluator = evaluatorForm.build(); | |
65 | + evaluator.setId(id); | |
66 | + evaluator = evaluatorService.update(evaluator, evaluatorForm.getOldPassword()); | |
67 | + return evaluatorModelAssembler.toModel(new EvaluatorDto(evaluator)); | |
68 | + } | |
69 | + | |
70 | + @DeleteMapping("/{id}") | |
71 | + public ResponseEntity<Void> delete(@PathVariable Integer id) { | |
72 | + evaluatorService.delete(id); | |
73 | + return ResponseEntity.noContent().build(); | |
74 | + } | |
75 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/ForgetPasswordController.java
0 → 100644
codigos/backend/src/main/java/com/srh/api/controller/ItemAttributeController.java
0 → 100644
... | ... | @@ -0,0 +1,85 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.AttributeDto; | |
4 | +import com.srh.api.dto.resource.ItemAttributeDto; | |
5 | +import com.srh.api.dto.resource.ItemAttributeForm; | |
6 | +import com.srh.api.hypermedia.AttributeModelAssembler; | |
7 | +import com.srh.api.hypermedia.ItemAttributeModelAssembler; | |
8 | +import com.srh.api.model.Attribute; | |
9 | +import com.srh.api.model.ItemAttribute; | |
10 | +import com.srh.api.service.ItemAttributeService; | |
11 | +import lombok.SneakyThrows; | |
12 | +import org.springframework.beans.factory.annotation.Autowired; | |
13 | +import org.springframework.data.domain.Page; | |
14 | +import org.springframework.data.domain.Pageable; | |
15 | +import org.springframework.data.web.PageableDefault; | |
16 | +import org.springframework.data.web.PagedResourcesAssembler; | |
17 | +import org.springframework.hateoas.EntityModel; | |
18 | +import org.springframework.hateoas.PagedModel; | |
19 | +import org.springframework.http.ResponseEntity; | |
20 | +import org.springframework.web.bind.annotation.*; | |
21 | +import org.springframework.web.util.UriComponentsBuilder; | |
22 | + | |
23 | +import javax.validation.Valid; | |
24 | +import java.net.URI; | |
25 | + | |
26 | +@RestController | |
27 | +@RequestMapping("/itens/{itemId}/attributes") | |
28 | +public class ItemAttributeController { | |
29 | + @Autowired | |
30 | + private ItemAttributeService itemAttributeService; | |
31 | + | |
32 | + @Autowired | |
33 | + private ItemAttributeModelAssembler itemAttributeModelAssembler; | |
34 | + | |
35 | + @Autowired | |
36 | + private AttributeModelAssembler attributeModelAssembler; | |
37 | + | |
38 | + @Autowired | |
39 | + PagedResourcesAssembler<AttributeDto> pagedResourcesAssembler; | |
40 | + | |
41 | + @GetMapping | |
42 | + public PagedModel<EntityModel<AttributeDto>> listAttributesByItem( | |
43 | + @PathVariable Integer itemId, @PageableDefault(page = 0, size = 5) Pageable pageInfo | |
44 | + ) { | |
45 | + Page<Attribute> attributes = itemAttributeService.listAttributesByItem(itemId, pageInfo); | |
46 | + return pagedResourcesAssembler.toModel(AttributeDto.convert(attributes)); | |
47 | + } | |
48 | + | |
49 | + @GetMapping("/{attributeId}") | |
50 | + public EntityModel<AttributeDto> findAttributeInItem(@PathVariable Integer itemId, | |
51 | + @PathVariable Integer attributeId) { | |
52 | + Attribute attribute = itemAttributeService.findAttributeByItem(itemId, attributeId); | |
53 | + return attributeModelAssembler.toModel(new AttributeDto(attribute)); | |
54 | + } | |
55 | + | |
56 | + @PostMapping | |
57 | + @SneakyThrows | |
58 | + public ResponseEntity<EntityModel<ItemAttributeDto>> linksAttributesItem( | |
59 | + @PathVariable Integer itemId, | |
60 | + @RequestBody @Valid ItemAttributeForm itemAttributeForm, | |
61 | + UriComponentsBuilder uriBuilder | |
62 | + ) { | |
63 | + ItemAttribute itemAttribute = itemAttributeService.save( | |
64 | + itemAttributeForm.getItemId(), | |
65 | + itemAttributeForm.getAttributeId() | |
66 | + ); | |
67 | + | |
68 | + URI uri = uriBuilder.path("/itens/{itemId}/attributes/{attributeId}") | |
69 | + .buildAndExpand(itemId, itemAttributeForm.getAttributeId()) | |
70 | + .toUri(); | |
71 | + | |
72 | + return ResponseEntity.created(uri) | |
73 | + .body(itemAttributeModelAssembler.toModel( | |
74 | + new ItemAttributeDto(itemAttribute) | |
75 | + )); | |
76 | + } | |
77 | + | |
78 | + @DeleteMapping("/{attributeId}") | |
79 | + @SneakyThrows | |
80 | + public ResponseEntity<Void> delete(@PathVariable Integer itemId, | |
81 | + @PathVariable Integer attributeId) { | |
82 | + itemAttributeService.delete(itemId, attributeId); | |
83 | + return ResponseEntity.noContent().build(); | |
84 | + } | |
85 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/ItemController.java
0 → 100644
... | ... | @@ -0,0 +1,91 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.ItemDto; | |
4 | +import com.srh.api.dto.resource.ItemForm; | |
5 | +import com.srh.api.dto.resource.RecommendationDto; | |
6 | +import com.srh.api.hypermedia.ItemModelAssembler; | |
7 | +import com.srh.api.model.Item; | |
8 | +import com.srh.api.model.Recommendation; | |
9 | +import com.srh.api.service.ItemService; | |
10 | +import com.srh.api.utils.PageUtil; | |
11 | +import org.springframework.beans.factory.annotation.Autowired; | |
12 | +import org.springframework.data.domain.Page; | |
13 | +import org.springframework.data.domain.Pageable; | |
14 | +import org.springframework.data.web.PageableDefault; | |
15 | +import org.springframework.data.web.PagedResourcesAssembler; | |
16 | +import org.springframework.hateoas.EntityModel; | |
17 | +import org.springframework.hateoas.PagedModel; | |
18 | +import org.springframework.http.ResponseEntity; | |
19 | +import org.springframework.web.bind.annotation.*; | |
20 | +import org.springframework.web.util.UriComponentsBuilder; | |
21 | + | |
22 | +import javax.transaction.Transactional; | |
23 | +import javax.validation.Valid; | |
24 | +import java.net.URI; | |
25 | + | |
26 | +import static com.srh.api.dto.resource.ItemDto.convert; | |
27 | + | |
28 | +@RestController | |
29 | +@RequestMapping("/itens") | |
30 | +public class ItemController { | |
31 | + @Autowired | |
32 | + private ItemService itemService; | |
33 | + | |
34 | + @Autowired | |
35 | + private ItemModelAssembler itemModelAssembler; | |
36 | + | |
37 | + @Autowired | |
38 | + private PagedResourcesAssembler<ItemDto> pagedResourcesAssembler; | |
39 | + | |
40 | + @Autowired | |
41 | + private PagedResourcesAssembler<RecommendationDto> recommendationsPagedResourcesAssembler; | |
42 | + | |
43 | + @GetMapping | |
44 | + public PagedModel<EntityModel<ItemDto>> listAll(@PageableDefault(page = 0, size = 5) | |
45 | + Pageable pageInfo) { | |
46 | + Page<Item> itens = itemService.findAll(pageInfo); | |
47 | + return pagedResourcesAssembler.toModel(convert(itens)); | |
48 | + } | |
49 | + | |
50 | + @GetMapping("/{id}") | |
51 | + public EntityModel<ItemDto> find(@PathVariable Integer id) { | |
52 | + Item item = itemService.find(id); | |
53 | + return itemModelAssembler.toModel(new ItemDto(item)); | |
54 | + } | |
55 | + | |
56 | + @PostMapping | |
57 | + public ResponseEntity<EntityModel<ItemDto>> create(@RequestBody @Valid ItemForm itemForm, | |
58 | + UriComponentsBuilder uriBuilder) { | |
59 | + Item item = itemForm.build(); | |
60 | + itemService.save(item); | |
61 | + URI uri = uriBuilder.path("/itens/{id}").buildAndExpand(item.getId()).toUri(); | |
62 | + return ResponseEntity.created(uri) | |
63 | + .body(itemModelAssembler.toModel(new ItemDto(item))); | |
64 | + } | |
65 | + | |
66 | + @PutMapping("/{id}") | |
67 | + @Transactional | |
68 | + public EntityModel<ItemDto> update(@RequestBody @Valid ItemForm itemForm, @PathVariable Integer id) { | |
69 | + Item item = itemForm.build(); | |
70 | + item.setId(id); | |
71 | + item = itemService.update(item); | |
72 | + return itemModelAssembler.toModel(new ItemDto(item)); | |
73 | + } | |
74 | + | |
75 | + @DeleteMapping("/{id}") | |
76 | + @Transactional | |
77 | + public ResponseEntity<Void> delete(@PathVariable Integer id) { | |
78 | + itemService.delete(id); | |
79 | + return ResponseEntity.noContent().build(); | |
80 | + } | |
81 | + | |
82 | + @GetMapping("/{itemId}/recommendations") | |
83 | + public PagedModel<EntityModel<RecommendationDto>> listRecommendationsByItem( | |
84 | + @PathVariable Integer itemId, | |
85 | + @PageableDefault(page = 0, size = 5) Pageable pageInfo | |
86 | + ) { | |
87 | + Item item = itemService.find(itemId); | |
88 | + PageUtil<Recommendation> pageUtil = new PageUtil<>(pageInfo, item.getRecommendations()); | |
89 | + return recommendationsPagedResourcesAssembler.toModel(RecommendationDto.convert(pageUtil.getPage())); | |
90 | + } | |
91 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/ItemRatingController.java
0 → 100644
... | ... | @@ -0,0 +1,76 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.ItemRatingDto; | |
4 | +import com.srh.api.dto.resource.ItemRatingForm; | |
5 | +import com.srh.api.hypermedia.ItemRatingModelAssembler; | |
6 | +import com.srh.api.model.ItemRating; | |
7 | +import com.srh.api.service.ItemRatingService; | |
8 | +import org.springframework.beans.factory.annotation.Autowired; | |
9 | +import org.springframework.data.domain.Page; | |
10 | +import org.springframework.data.domain.Pageable; | |
11 | +import org.springframework.data.web.PageableDefault; | |
12 | +import org.springframework.data.web.PagedResourcesAssembler; | |
13 | +import org.springframework.hateoas.EntityModel; | |
14 | +import org.springframework.hateoas.PagedModel; | |
15 | +import org.springframework.http.ResponseEntity; | |
16 | +import org.springframework.web.bind.annotation.*; | |
17 | +import org.springframework.web.util.UriComponentsBuilder; | |
18 | + | |
19 | +import javax.transaction.Transactional; | |
20 | +import javax.validation.Valid; | |
21 | + | |
22 | +import java.net.URI; | |
23 | + | |
24 | +import static com.srh.api.dto.resource.ItemRatingDto.convert; | |
25 | + | |
26 | +@RestController | |
27 | +@RequestMapping("/itemratings") | |
28 | +public class ItemRatingController { | |
29 | + @Autowired | |
30 | + private ItemRatingService itemRatingService; | |
31 | + | |
32 | + @Autowired | |
33 | + private ItemRatingModelAssembler itemRatingModelAssembler; | |
34 | + | |
35 | + @Autowired | |
36 | + PagedResourcesAssembler<ItemRatingDto> pagedResourcesAssembler; | |
37 | + | |
38 | + @GetMapping | |
39 | + public PagedModel<EntityModel<ItemRatingDto>> listAll(@PageableDefault(page = 0, size = 5) | |
40 | + Pageable pageInfo) { | |
41 | + Page<ItemRating> itemRatings = itemRatingService.findAll(pageInfo); | |
42 | + return pagedResourcesAssembler.toModel(convert(itemRatings)); | |
43 | + } | |
44 | + | |
45 | + @GetMapping("/{id}") | |
46 | + public EntityModel<ItemRatingDto> find(@PathVariable Integer id) { | |
47 | + ItemRating itemRating = itemRatingService.find(id); | |
48 | + return itemRatingModelAssembler.toModel(new ItemRatingDto(itemRating)); | |
49 | + } | |
50 | + | |
51 | + @PostMapping | |
52 | + public ResponseEntity<EntityModel<ItemRatingDto>> create(@RequestBody @Valid ItemRatingForm itemRatingForm, | |
53 | + UriComponentsBuilder uriBuilder) { | |
54 | + ItemRating itemRating = itemRatingForm.build(); | |
55 | + itemRatingService.save(itemRating); | |
56 | + URI uri = uriBuilder.path("/itemratings/{id}").buildAndExpand(itemRating.getId()).toUri(); | |
57 | + return ResponseEntity.created(uri) | |
58 | + .body(itemRatingModelAssembler.toModel(new ItemRatingDto(itemRating))); | |
59 | + } | |
60 | + | |
61 | + @PutMapping("/{id}") | |
62 | + @Transactional | |
63 | + public EntityModel<ItemRatingDto> update(@RequestBody @Valid ItemRatingForm itemRatingForm, | |
64 | + @PathVariable Integer id) { | |
65 | + ItemRating itemRating = itemRatingForm.build(); | |
66 | + itemRating.setId(id); | |
67 | + itemRating = itemRatingService.update(itemRating); | |
68 | + return itemRatingModelAssembler.toModel(new ItemRatingDto(itemRating)); | |
69 | + } | |
70 | + | |
71 | + @DeleteMapping("/{id}") | |
72 | + public ResponseEntity<Void> delete(@PathVariable Integer id) { | |
73 | + itemRatingService.delete(id); | |
74 | + return ResponseEntity.noContent().build(); | |
75 | + } | |
76 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/ItemTagController.java
0 → 100644
... | ... | @@ -0,0 +1,85 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.ItemTagDto; | |
4 | +import com.srh.api.dto.resource.ItemTagForm; | |
5 | +import com.srh.api.dto.resource.TagDto; | |
6 | +import com.srh.api.hypermedia.ItemTagModelAssembler; | |
7 | +import com.srh.api.hypermedia.TagModelAssembler; | |
8 | +import com.srh.api.model.ItemTag; | |
9 | +import com.srh.api.model.Tag; | |
10 | +import com.srh.api.service.ItemTagService; | |
11 | +import lombok.SneakyThrows; | |
12 | +import org.springframework.beans.factory.annotation.Autowired; | |
13 | +import org.springframework.data.domain.Page; | |
14 | +import org.springframework.data.domain.Pageable; | |
15 | +import org.springframework.data.web.PageableDefault; | |
16 | +import org.springframework.data.web.PagedResourcesAssembler; | |
17 | +import org.springframework.hateoas.EntityModel; | |
18 | +import org.springframework.hateoas.PagedModel; | |
19 | +import org.springframework.http.ResponseEntity; | |
20 | +import org.springframework.web.bind.annotation.*; | |
21 | +import org.springframework.web.util.UriComponentsBuilder; | |
22 | + | |
23 | +import javax.validation.Valid; | |
24 | +import java.net.URI; | |
25 | + | |
26 | +@RestController | |
27 | +@RequestMapping("/itens/{itemId}/tags") | |
28 | +public class ItemTagController { | |
29 | + @Autowired | |
30 | + private ItemTagService itemTagService; | |
31 | + | |
32 | + @Autowired | |
33 | + private ItemTagModelAssembler itemTagModelAssembler; | |
34 | + | |
35 | + @Autowired | |
36 | + private TagModelAssembler tagModelAssembler; | |
37 | + | |
38 | + @Autowired | |
39 | + PagedResourcesAssembler<TagDto> pagedResourcesAssembler; | |
40 | + | |
41 | + @GetMapping | |
42 | + public PagedModel<EntityModel<TagDto>> listTagsByItem( | |
43 | + @PathVariable Integer itemId, @PageableDefault(page = 0, size = 5) Pageable pageInfo | |
44 | + ) { | |
45 | + Page<Tag> tags = itemTagService.listTagsByItem(itemId, pageInfo); | |
46 | + return pagedResourcesAssembler.toModel(TagDto.convert(tags)); | |
47 | + } | |
48 | + | |
49 | + @GetMapping("/{tagId}") | |
50 | + public EntityModel<TagDto> findTagByItem(@PathVariable Integer itemId, | |
51 | + @PathVariable Integer tagId) { | |
52 | + Tag tag = itemTagService.findTagByItem(itemId, tagId); | |
53 | + return tagModelAssembler.toModel(new TagDto(tag)); | |
54 | + } | |
55 | + | |
56 | + @PostMapping | |
57 | + @SneakyThrows | |
58 | + public ResponseEntity<EntityModel<ItemTagDto>> linksTagsItem( | |
59 | + @PathVariable Integer itemId, | |
60 | + @RequestBody @Valid ItemTagForm itemTagForm, | |
61 | + UriComponentsBuilder uriBuilder | |
62 | + ) { | |
63 | + ItemTag itemTag = itemTagService.save( | |
64 | + itemTagForm.getItemId(), | |
65 | + itemTagForm.getTagId() | |
66 | + ); | |
67 | + | |
68 | + URI uri = uriBuilder.path("/itens/{itemId}/tags/{tagId}") | |
69 | + .buildAndExpand(itemTag.getItem().getId(), itemTag.getTag().getId()) | |
70 | + .toUri(); | |
71 | + | |
72 | + return ResponseEntity.created(uri) | |
73 | + .body(itemTagModelAssembler.toModel( | |
74 | + new ItemTagDto(itemTag) | |
75 | + )); | |
76 | + } | |
77 | + | |
78 | + @DeleteMapping("/{tagId}") | |
79 | + @SneakyThrows | |
80 | + public ResponseEntity<Void> delete(@PathVariable Integer itemId, | |
81 | + @PathVariable Integer tagId) { | |
82 | + itemTagService.delete(itemId, tagId); | |
83 | + return ResponseEntity.noContent().build(); | |
84 | + } | |
85 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/LoginAdminController.java
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.LoginClientForm; | |
4 | +import com.srh.api.service.LoginClientDto; | |
5 | +import com.srh.api.service.LoginClientService; | |
6 | +import org.springframework.beans.factory.annotation.Autowired; | |
7 | +import org.springframework.http.ResponseEntity; | |
8 | +import org.springframework.web.bind.annotation.PostMapping; | |
9 | +import org.springframework.web.bind.annotation.RequestBody; | |
10 | +import org.springframework.web.bind.annotation.RequestMapping; | |
11 | +import org.springframework.web.bind.annotation.RestController; | |
12 | + | |
13 | +import javax.validation.Valid; | |
14 | + | |
15 | +@RestController | |
16 | +@RequestMapping("/admins/login") | |
17 | +public class LoginAdminController { | |
18 | + @Autowired | |
19 | + private LoginClientService loginClientService; | |
20 | + | |
21 | + @PostMapping | |
22 | + public ResponseEntity<LoginClientDto> loginUser(@RequestBody @Valid LoginClientForm loginForm) { | |
23 | + Boolean validUser = loginClientService.generateLoginTokenByAdmins( | |
24 | + loginForm.getLogin(), loginForm.getPassword() | |
25 | + ); | |
26 | + Integer adminId = loginClientService.getAdminId(loginForm.getLogin()); | |
27 | + return ResponseEntity.ok(new LoginClientDto(validUser, adminId)); | |
28 | + } | |
29 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/LoginEvaluatorController.java
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.LoginClientForm; | |
4 | +import com.srh.api.service.LoginClientDto; | |
5 | +import com.srh.api.service.LoginClientService; | |
6 | +import org.springframework.beans.factory.annotation.Autowired; | |
7 | +import org.springframework.http.ResponseEntity; | |
8 | +import org.springframework.web.bind.annotation.PostMapping; | |
9 | +import org.springframework.web.bind.annotation.RequestBody; | |
10 | +import org.springframework.web.bind.annotation.RequestMapping; | |
11 | +import org.springframework.web.bind.annotation.RestController; | |
12 | + | |
13 | +import javax.validation.Valid; | |
14 | + | |
15 | +@RestController | |
16 | +@RequestMapping("/evaluators/login") | |
17 | +public class LoginEvaluatorController { | |
18 | + @Autowired | |
19 | + private LoginClientService loginClientService; | |
20 | + | |
21 | + @PostMapping | |
22 | + public ResponseEntity<LoginClientDto> loginUser(@RequestBody @Valid LoginClientForm loginForm) { | |
23 | + Boolean validUser = loginClientService.verifyEvaluators( | |
24 | + loginForm.getLogin(), loginForm.getPassword() | |
25 | + ); | |
26 | + Integer evaluatorId = loginClientService.getEvaluatorId(loginForm.getLogin()); | |
27 | + return ResponseEntity.ok(new LoginClientDto(validUser, evaluatorId)); | |
28 | + } | |
29 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/ProjectController.java
0 → 100644
... | ... | @@ -0,0 +1,157 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.*; | |
4 | +import com.srh.api.hypermedia.ProjectModelAssembler; | |
5 | +import com.srh.api.model.*; | |
6 | +import com.srh.api.service.ProjectService; | |
7 | +import com.srh.api.utils.PageUtil; | |
8 | +import lombok.SneakyThrows; | |
9 | +import org.springframework.beans.factory.annotation.Autowired; | |
10 | +import org.springframework.data.domain.Page; | |
11 | +import org.springframework.data.domain.Pageable; | |
12 | +import org.springframework.data.web.PageableDefault; | |
13 | +import org.springframework.data.web.PagedResourcesAssembler; | |
14 | +import org.springframework.hateoas.EntityModel; | |
15 | +import org.springframework.hateoas.PagedModel; | |
16 | +import org.springframework.http.ResponseEntity; | |
17 | +import org.springframework.web.bind.annotation.*; | |
18 | +import org.springframework.web.util.UriComponentsBuilder; | |
19 | + | |
20 | +import javax.transaction.Transactional; | |
21 | +import javax.validation.Valid; | |
22 | +import java.net.URI; | |
23 | + | |
24 | +import static com.srh.api.dto.resource.ProjectDto.convert; | |
25 | + | |
26 | +@RestController | |
27 | +@RequestMapping("/projects") | |
28 | +public class ProjectController { | |
29 | + @Autowired | |
30 | + private ProjectService projectService; | |
31 | + | |
32 | + @Autowired | |
33 | + private ProjectModelAssembler projectModelAssembler; | |
34 | + | |
35 | + @Autowired | |
36 | + private PagedResourcesAssembler<ProjectDto> pagedResourcesAssembler; | |
37 | + | |
38 | + @Autowired | |
39 | + private PagedResourcesAssembler<ItemDto> itemDtoPagedResourcesAssembler; | |
40 | + | |
41 | + @Autowired | |
42 | + private PagedResourcesAssembler<RecommendationDto> recommendationDtoPagedResourcesAssembler; | |
43 | + | |
44 | + @Autowired | |
45 | + private PagedResourcesAssembler<ItemRatingDto> itemRatingDtoPagedResourcesAssembler; | |
46 | + | |
47 | + @Autowired | |
48 | + private PagedResourcesAssembler<TagDto> tagDtoPagedResourcesAssembler; | |
49 | + | |
50 | + @Autowired | |
51 | + private PagedResourcesAssembler<TypeItemDto> typeItemDtoPagedResourcesAssembler; | |
52 | + | |
53 | + @GetMapping | |
54 | + public PagedModel<EntityModel<ProjectDto>> listAll(@PageableDefault(page = 0, size = 5) | |
55 | + Pageable pageInfo) { | |
56 | + Page<Project> projects = projectService.findAll(pageInfo); | |
57 | + return pagedResourcesAssembler.toModel(convert(projects)); | |
58 | + } | |
59 | + | |
60 | + @GetMapping("/{id}") | |
61 | + public EntityModel<ProjectDto> find(@PathVariable Integer id) { | |
62 | + Project project = projectService.find(id); | |
63 | + return projectModelAssembler.toModel(new ProjectDto(project)); | |
64 | + } | |
65 | + | |
66 | + @PostMapping | |
67 | + @SneakyThrows | |
68 | + public ResponseEntity<EntityModel<ProjectDto>> create(@RequestBody @Valid ProjectForm projectForm, | |
69 | + UriComponentsBuilder uriBuilder) { | |
70 | + Project project = projectForm.build(); | |
71 | + Project projectPersist = projectService.save(project); | |
72 | + URI uri = uriBuilder.path("/projects/{id}").buildAndExpand(project.getId()).toUri(); | |
73 | + return ResponseEntity.created(uri) | |
74 | + .body(projectModelAssembler.toModel(new ProjectDto(projectPersist))); | |
75 | + } | |
76 | + | |
77 | + @PutMapping("/{id}") | |
78 | + @Transactional | |
79 | + @SneakyThrows | |
80 | + public EntityModel<ProjectDto> update(@RequestBody @Valid ProjectForm projectForm, | |
81 | + @PathVariable Integer id) { | |
82 | + Project project = projectForm.build(); | |
83 | + project.setId(id); | |
84 | + project = projectService.update(project); | |
85 | + return projectModelAssembler.toModel(new ProjectDto(project)); | |
86 | + } | |
87 | + | |
88 | + @DeleteMapping("/{id}") | |
89 | + @Transactional | |
90 | + public ResponseEntity<Void> delete(@PathVariable Integer id) { | |
91 | + projectService.delete(id); | |
92 | + return ResponseEntity.noContent().build(); | |
93 | + } | |
94 | + | |
95 | + @GetMapping("/{projectId}/itens") | |
96 | + public PagedModel<EntityModel<ItemDto>> findItensByProject( | |
97 | + @PathVariable Integer projectId, | |
98 | + @PageableDefault(page = 0, size = 5) Pageable pageInfo | |
99 | + ) { | |
100 | + PageUtil<Item> pageUtil = new PageUtil<>(pageInfo, projectService. | |
101 | + listItensByProject(projectId)); | |
102 | + | |
103 | + return itemDtoPagedResourcesAssembler.toModel(ItemDto.convert(pageUtil.getPage())); | |
104 | + } | |
105 | + | |
106 | + @GetMapping("{projectId}/recommendations") | |
107 | + public PagedModel<EntityModel<RecommendationDto>> findRecommendationsByProject( | |
108 | + @PathVariable Integer projectId, | |
109 | + @PageableDefault(page = 0, size = 5) Pageable pageInfo | |
110 | + ) { | |
111 | + PageUtil<Recommendation> pageUtil = new PageUtil<>(pageInfo, projectService. | |
112 | + listRecommendationsByProject(projectId)); | |
113 | + | |
114 | + return recommendationDtoPagedResourcesAssembler.toModel(RecommendationDto.convert( | |
115 | + pageUtil.getPage() | |
116 | + )); | |
117 | + } | |
118 | + | |
119 | + @GetMapping("{projectId}/itemratings") | |
120 | + public PagedModel<EntityModel<ItemRatingDto>> findItemRatingsByProject( | |
121 | + @PathVariable Integer projectId, | |
122 | + @PageableDefault(page = 0, size = 5) Pageable pageInfo | |
123 | + ) { | |
124 | + PageUtil<ItemRating> pageUtil = new PageUtil<>(pageInfo, projectService. | |
125 | + listItemRatingsByProject(projectId)); | |
126 | + | |
127 | + return itemRatingDtoPagedResourcesAssembler.toModel(ItemRatingDto.convert( | |
128 | + pageUtil.getPage() | |
129 | + )); | |
130 | + } | |
131 | + | |
132 | + @GetMapping("{projectId}/tags") | |
133 | + public PagedModel<EntityModel<TagDto>> findTagsByProject( | |
134 | + @PathVariable Integer projectId, | |
135 | + @PageableDefault(page = 0, size = 5) Pageable pageInfo | |
136 | + ) { | |
137 | + PageUtil<Tag> pageUtil = new PageUtil<>(pageInfo, projectService. | |
138 | + listTagsByProject(projectId)); | |
139 | + | |
140 | + return tagDtoPagedResourcesAssembler.toModel(TagDto.convert( | |
141 | + pageUtil.getPage() | |
142 | + )); | |
143 | + } | |
144 | + | |
145 | + @GetMapping("{projectId}/typeitens") | |
146 | + public PagedModel<EntityModel<TypeItemDto>> findTypeItensByProject( | |
147 | + @PathVariable Integer projectId, | |
148 | + @PageableDefault(page = 0, size = 5) Pageable pageInfo | |
149 | + ) { | |
150 | + PageUtil<TypeItem> pageUtil = new PageUtil<>(pageInfo, projectService. | |
151 | + listTypeItensByProject(projectId)); | |
152 | + | |
153 | + return typeItemDtoPagedResourcesAssembler.toModel(TypeItemDto.convert( | |
154 | + pageUtil.getPage() | |
155 | + )); | |
156 | + } | |
157 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/ProjectEvaluatorController.java
0 → 100644
... | ... | @@ -0,0 +1,85 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.ProjectEvaluatorDto; | |
4 | +import com.srh.api.dto.resource.ProjectEvaluatorForm; | |
5 | +import com.srh.api.dto.resource.EvaluatorDto; | |
6 | +import com.srh.api.hypermedia.ProjectEvaluatorModelAssembler; | |
7 | +import com.srh.api.hypermedia.EvaluatorModelAssembler; | |
8 | +import com.srh.api.model.ProjectEvaluator; | |
9 | +import com.srh.api.model.Evaluator; | |
10 | +import com.srh.api.service.ProjectEvaluatorService; | |
11 | +import lombok.SneakyThrows; | |
12 | +import org.springframework.beans.factory.annotation.Autowired; | |
13 | +import org.springframework.data.domain.Page; | |
14 | +import org.springframework.data.domain.Pageable; | |
15 | +import org.springframework.data.web.PageableDefault; | |
16 | +import org.springframework.data.web.PagedResourcesAssembler; | |
17 | +import org.springframework.hateoas.EntityModel; | |
18 | +import org.springframework.hateoas.PagedModel; | |
19 | +import org.springframework.http.ResponseEntity; | |
20 | +import org.springframework.web.bind.annotation.*; | |
21 | +import org.springframework.web.util.UriComponentsBuilder; | |
22 | + | |
23 | +import javax.validation.Valid; | |
24 | +import java.net.URI; | |
25 | + | |
26 | +@RestController | |
27 | +@RequestMapping("/projects/{projectId}/evaluators") | |
28 | +public class ProjectEvaluatorController { | |
29 | + @Autowired | |
30 | + private ProjectEvaluatorService projectEvaluatorService; | |
31 | + | |
32 | + @Autowired | |
33 | + private ProjectEvaluatorModelAssembler projectEvaluatorModelAssembler; | |
34 | + | |
35 | + @Autowired | |
36 | + private EvaluatorModelAssembler evaluatorModelAssembler; | |
37 | + | |
38 | + @Autowired | |
39 | + private PagedResourcesAssembler<EvaluatorDto> evaluatorDtoPagedResourcesAssembler; | |
40 | + | |
41 | + @GetMapping | |
42 | + public PagedModel<EntityModel<EvaluatorDto>> listRecommendersByProject( | |
43 | + @PathVariable Integer projectId, @PageableDefault(page = 0, size = 5) Pageable pageInfo) { | |
44 | + Page<Evaluator> recommendersPage = projectEvaluatorService. | |
45 | + listEvaluatorsByProject(projectId, pageInfo); | |
46 | + return evaluatorDtoPagedResourcesAssembler.toModel(EvaluatorDto | |
47 | + .convert(recommendersPage)); | |
48 | + } | |
49 | + | |
50 | + @GetMapping("/{evaluatorId}") | |
51 | + public EntityModel<EvaluatorDto> findEvaluatorInProject(@PathVariable Integer projectId, | |
52 | + @PathVariable Integer evaluatorId) { | |
53 | + Evaluator evaluator = projectEvaluatorService.findEvaluatorByProject(projectId, | |
54 | + evaluatorId); | |
55 | + return evaluatorModelAssembler.toModel(new EvaluatorDto(evaluator)); | |
56 | + } | |
57 | + | |
58 | + @PostMapping | |
59 | + @SneakyThrows | |
60 | + public ResponseEntity<EntityModel<ProjectEvaluatorDto>> linkEvaluatorsProject( | |
61 | + @PathVariable Integer projectId, @RequestBody @Valid ProjectEvaluatorForm | |
62 | + projectRecommenderForm, UriComponentsBuilder uriBuilder) { | |
63 | + | |
64 | + ProjectEvaluator projectEvaluator = projectEvaluatorService.save( | |
65 | + projectRecommenderForm.getProjectId(), | |
66 | + projectRecommenderForm.getEvaluatorId()); | |
67 | + | |
68 | + URI uri = uriBuilder.path("/projects/{projectId}/recommenders/{evaluatorId}") | |
69 | + .buildAndExpand(projectId, projectEvaluator.getEvaluator().getId()) | |
70 | + .toUri(); | |
71 | + | |
72 | + return ResponseEntity.created(uri) | |
73 | + .body(projectEvaluatorModelAssembler.toModel( | |
74 | + new ProjectEvaluatorDto(projectEvaluator) | |
75 | + )); | |
76 | + } | |
77 | + | |
78 | + @DeleteMapping("/{evaluatorId}") | |
79 | + @SneakyThrows | |
80 | + public ResponseEntity<Void> delete(@PathVariable Integer projectId, | |
81 | + @PathVariable Integer evaluatorId) { | |
82 | + projectEvaluatorService.delete(projectId, evaluatorId); | |
83 | + return ResponseEntity.noContent().build(); | |
84 | + } | |
85 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/RecommendationController.java
0 → 100644
... | ... | @@ -0,0 +1,73 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.algorithms.structure.RecommendationsByUser; | |
4 | +import com.srh.api.dto.resource.RecommendationDto; | |
5 | +import com.srh.api.dto.resource.RecommendationForm; | |
6 | +import com.srh.api.dto.resource.RecommendationUserDto; | |
7 | +import com.srh.api.hypermedia.RecommendationModelAssembler; | |
8 | +import com.srh.api.model.Recommendation; | |
9 | +import com.srh.api.service.RecommendationService; | |
10 | +import org.springframework.beans.factory.annotation.Autowired; | |
11 | +import org.springframework.data.domain.Page; | |
12 | +import org.springframework.data.domain.Pageable; | |
13 | +import org.springframework.data.web.PageableDefault; | |
14 | +import org.springframework.data.web.PagedResourcesAssembler; | |
15 | +import org.springframework.hateoas.EntityModel; | |
16 | +import org.springframework.hateoas.PagedModel; | |
17 | +import org.springframework.http.ResponseEntity; | |
18 | +import org.springframework.web.bind.annotation.*; | |
19 | + | |
20 | +import javax.transaction.Transactional; | |
21 | +import javax.validation.Valid; | |
22 | + | |
23 | +import java.util.ArrayList; | |
24 | +import java.util.List; | |
25 | + | |
26 | +import static com.srh.api.dto.resource.RecommendationDto.convert; | |
27 | + | |
28 | +@RestController | |
29 | +@RequestMapping("/recommendations") | |
30 | +public class RecommendationController { | |
31 | + @Autowired | |
32 | + private RecommendationService recommendationService; | |
33 | + | |
34 | + @Autowired | |
35 | + private RecommendationModelAssembler recommendationModelAssembler; | |
36 | + | |
37 | + @Autowired | |
38 | + private PagedResourcesAssembler<RecommendationDto> pagedResourcesAssembler; | |
39 | + | |
40 | + @GetMapping | |
41 | + public PagedModel<EntityModel<RecommendationDto>> listAll(@PageableDefault(page = 0, size = 5) | |
42 | + Pageable pageInfo) { | |
43 | + Page<Recommendation> recommendations = recommendationService.findAll(pageInfo); | |
44 | + return pagedResourcesAssembler.toModel(convert(recommendations)); | |
45 | + } | |
46 | + | |
47 | + @GetMapping("/{id}") | |
48 | + public EntityModel<RecommendationDto> find(@PathVariable Integer id) { | |
49 | + Recommendation recommendation = recommendationService.find(id); | |
50 | + return recommendationModelAssembler.toModel(new RecommendationDto(recommendation)); | |
51 | + } | |
52 | + | |
53 | + @PostMapping | |
54 | + public ResponseEntity<List<RecommendationUserDto>> generateRecommendations( | |
55 | + @RequestBody @Valid RecommendationForm form) { | |
56 | + List<RecommendationsByUser> recommendations = recommendationService.generateRecommendation(form); | |
57 | + List<RecommendationUserDto> recommendationUserDtos = new ArrayList<>(); | |
58 | + | |
59 | + for (RecommendationsByUser recommendationByUser : recommendations) { | |
60 | + recommendationUserDtos.add(new RecommendationUserDto(recommendationByUser)); | |
61 | + } | |
62 | + | |
63 | + return ResponseEntity.ok(recommendationUserDtos); | |
64 | + } | |
65 | + | |
66 | + @DeleteMapping("/{id}") | |
67 | + @Transactional | |
68 | + public ResponseEntity<Void> delete(@PathVariable Integer id) { | |
69 | + recommendationService.delete(id); | |
70 | + return ResponseEntity.noContent().build(); | |
71 | + } | |
72 | + | |
73 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/RecommendationRatingController.java
0 → 100644
... | ... | @@ -0,0 +1,77 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.RecommendationRatingDto; | |
4 | +import com.srh.api.dto.resource.RecommendationRatingForm; | |
5 | +import com.srh.api.hypermedia.RecommendationRatingModelAssembler; | |
6 | +import com.srh.api.model.RecommendationRating; | |
7 | +import com.srh.api.service.RecommmendationRatingService; | |
8 | +import org.springframework.beans.factory.annotation.Autowired; | |
9 | +import org.springframework.data.domain.Page; | |
10 | +import org.springframework.data.domain.Pageable; | |
11 | +import org.springframework.data.web.PageableDefault; | |
12 | +import org.springframework.data.web.PagedResourcesAssembler; | |
13 | +import org.springframework.hateoas.EntityModel; | |
14 | +import org.springframework.hateoas.PagedModel; | |
15 | +import org.springframework.http.ResponseEntity; | |
16 | +import org.springframework.web.bind.annotation.*; | |
17 | +import org.springframework.web.util.UriComponentsBuilder; | |
18 | + | |
19 | +import javax.transaction.Transactional; | |
20 | +import javax.validation.Valid; | |
21 | + | |
22 | +import java.net.URI; | |
23 | + | |
24 | +import static com.srh.api.dto.resource.RecommendationRatingDto.convert; | |
25 | + | |
26 | +@RestController | |
27 | +@RequestMapping("/recommendationratings") | |
28 | +public class RecommendationRatingController { | |
29 | + @Autowired | |
30 | + private RecommmendationRatingService recommmendationRatingService; | |
31 | + | |
32 | + @Autowired | |
33 | + private RecommendationRatingModelAssembler recommendationRatingModelAssembler; | |
34 | + | |
35 | + @Autowired | |
36 | + private PagedResourcesAssembler<RecommendationRatingDto> pagedResourcesAssembler; | |
37 | + | |
38 | + @GetMapping | |
39 | + public PagedModel<EntityModel<RecommendationRatingDto>> listAll(@PageableDefault(page = 0, size = 5) | |
40 | + Pageable pageInfo) { | |
41 | + Page<RecommendationRating> recommendationRatingDtos = recommmendationRatingService.findAll(pageInfo); | |
42 | + return pagedResourcesAssembler.toModel(convert(recommendationRatingDtos)); | |
43 | + } | |
44 | + | |
45 | + @GetMapping("/{id}") | |
46 | + public EntityModel<RecommendationRatingDto> find(@PathVariable Integer id) { | |
47 | + RecommendationRating recommendationRating = recommmendationRatingService.find(id); | |
48 | + return recommendationRatingModelAssembler.toModel(new RecommendationRatingDto(recommendationRating)); | |
49 | + } | |
50 | + | |
51 | + @PostMapping | |
52 | + public ResponseEntity<EntityModel<RecommendationRatingDto>> create(@RequestBody @Valid | |
53 | + RecommendationRatingForm recommendationRatingForm, | |
54 | + UriComponentsBuilder uriBuilder) { | |
55 | + RecommendationRating recommendationRating = recommendationRatingForm.build(); | |
56 | + recommmendationRatingService.save(recommendationRating); | |
57 | + URI uri = uriBuilder.path("/recommendationratings/{id}").buildAndExpand(recommendationRating.getId()).toUri(); | |
58 | + return ResponseEntity.created(uri) | |
59 | + .body(recommendationRatingModelAssembler.toModel(new RecommendationRatingDto(recommendationRating))); | |
60 | + } | |
61 | + | |
62 | + @PutMapping("/{id}") | |
63 | + @Transactional | |
64 | + public EntityModel<RecommendationRatingDto> update(@RequestBody @Valid RecommendationRatingForm recommendationRatingForm, | |
65 | + @PathVariable Integer id) { | |
66 | + RecommendationRating recommendationRating = recommendationRatingForm.build(); | |
67 | + recommendationRating.setId(id); | |
68 | + recommendationRating = recommmendationRatingService.update(recommendationRating); | |
69 | + return recommendationRatingModelAssembler.toModel(new RecommendationRatingDto(recommendationRating)); | |
70 | + } | |
71 | + | |
72 | + @DeleteMapping("/{id}") | |
73 | + public ResponseEntity<Void> delete(@PathVariable Integer id) { | |
74 | + recommmendationRatingService.delete(id); | |
75 | + return ResponseEntity.noContent().build(); | |
76 | + } | |
77 | +} | |
0 | 78 | \ No newline at end of file | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/TagController.java
0 → 100644
... | ... | @@ -0,0 +1,74 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.TagDto; | |
4 | +import com.srh.api.dto.resource.TagForm; | |
5 | +import com.srh.api.hypermedia.TagModelAssembler; | |
6 | +import com.srh.api.model.Tag; | |
7 | +import com.srh.api.service.TagService; | |
8 | +import org.springframework.beans.factory.annotation.Autowired; | |
9 | +import org.springframework.data.domain.Page; | |
10 | +import org.springframework.data.domain.Pageable; | |
11 | +import org.springframework.data.web.PageableDefault; | |
12 | +import org.springframework.data.web.PagedResourcesAssembler; | |
13 | +import org.springframework.hateoas.EntityModel; | |
14 | +import org.springframework.hateoas.PagedModel; | |
15 | +import org.springframework.http.ResponseEntity; | |
16 | +import org.springframework.web.bind.annotation.*; | |
17 | +import org.springframework.web.util.UriComponentsBuilder; | |
18 | + | |
19 | +import javax.transaction.Transactional; | |
20 | +import javax.validation.Valid; | |
21 | +import java.net.URI; | |
22 | + | |
23 | +import static com.srh.api.dto.resource.TagDto.*; | |
24 | + | |
25 | +@RestController | |
26 | +@RequestMapping("/tags") | |
27 | +public class TagController { | |
28 | + @Autowired | |
29 | + private TagService tagService; | |
30 | + | |
31 | + @Autowired | |
32 | + private TagModelAssembler tagModelAssembler; | |
33 | + | |
34 | + @Autowired | |
35 | + private PagedResourcesAssembler<TagDto> pagedResourcesAssembler; | |
36 | + | |
37 | + @GetMapping | |
38 | + public PagedModel<EntityModel<TagDto>> listAll(@PageableDefault(page = 0, size = 5) Pageable pageInfo) { | |
39 | + Page<Tag> tags = tagService.findAll(pageInfo); | |
40 | + return pagedResourcesAssembler.toModel(convert(tags)); | |
41 | + } | |
42 | + | |
43 | + @GetMapping("/{id}") | |
44 | + public EntityModel<TagDto> find(@PathVariable Integer id) { | |
45 | + Tag tag = tagService.find(id); | |
46 | + return tagModelAssembler.toModel(new TagDto(tag)); | |
47 | + } | |
48 | + | |
49 | + @PostMapping | |
50 | + public ResponseEntity<EntityModel<TagDto>> create(@RequestBody @Valid TagForm tagForm, | |
51 | + UriComponentsBuilder uriBuilder) { | |
52 | + Tag tag = tagForm.build(); | |
53 | + tagService.save(tag); | |
54 | + URI uri = uriBuilder.path("/tags/{id}").buildAndExpand(tag.getId()).toUri(); | |
55 | + return ResponseEntity.created(uri) | |
56 | + .body(tagModelAssembler.toModel(new TagDto(tag))); | |
57 | + } | |
58 | + | |
59 | + @PutMapping("/{id}") | |
60 | + @Transactional | |
61 | + public EntityModel<TagDto> update(@RequestBody @Valid TagForm tagForm, @PathVariable Integer id) { | |
62 | + Tag tag = tagForm.build(); | |
63 | + tag.setId(id); | |
64 | + tag = tagService.update(tag); | |
65 | + return tagModelAssembler.toModel(new TagDto(tag)); | |
66 | + } | |
67 | + | |
68 | + @DeleteMapping("/{id}") | |
69 | + @Transactional | |
70 | + public ResponseEntity<Void> delete(@PathVariable Integer id) { | |
71 | + tagService.delete(id); | |
72 | + return ResponseEntity.noContent().build(); | |
73 | + } | |
74 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/TypeItemAttributeController.java
0 → 100644
... | ... | @@ -0,0 +1,86 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.AttributeDto; | |
4 | +import com.srh.api.dto.resource.TypeItemAttributeDto; | |
5 | +import com.srh.api.dto.resource.TypeItemAttributeForm; | |
6 | +import com.srh.api.hypermedia.AttributeModelAssembler; | |
7 | +import com.srh.api.hypermedia.TypeItemAttributeModelAssembler; | |
8 | +import com.srh.api.model.Attribute; | |
9 | +import com.srh.api.model.TypeItemAttribute; | |
10 | +import com.srh.api.service.TypeItemAttributeService; | |
11 | +import lombok.SneakyThrows; | |
12 | +import org.springframework.beans.factory.annotation.Autowired; | |
13 | +import org.springframework.data.domain.Page; | |
14 | +import org.springframework.data.domain.Pageable; | |
15 | +import org.springframework.data.web.PageableDefault; | |
16 | +import org.springframework.data.web.PagedResourcesAssembler; | |
17 | +import org.springframework.hateoas.EntityModel; | |
18 | +import org.springframework.hateoas.PagedModel; | |
19 | +import org.springframework.http.ResponseEntity; | |
20 | +import org.springframework.web.bind.annotation.*; | |
21 | +import org.springframework.web.util.UriComponentsBuilder; | |
22 | + | |
23 | +import javax.validation.Valid; | |
24 | +import java.net.URI; | |
25 | + | |
26 | +@RestController | |
27 | +@RequestMapping("/typeitens/{typeItemId}/attributes") | |
28 | +public class TypeItemAttributeController { | |
29 | + @Autowired | |
30 | + private TypeItemAttributeService typeItemAttributeService; | |
31 | + | |
32 | + @Autowired | |
33 | + private TypeItemAttributeModelAssembler typeItemAttributeModelAssembler; | |
34 | + | |
35 | + @Autowired | |
36 | + private AttributeModelAssembler attributeModelAssembler; | |
37 | + | |
38 | + @Autowired | |
39 | + private PagedResourcesAssembler<AttributeDto> pagedResourcesAssembler; | |
40 | + | |
41 | + @GetMapping | |
42 | + public PagedModel<EntityModel<AttributeDto>> listAttributesByTypeItem( | |
43 | + @PathVariable Integer typeItemId, @PageableDefault(page = 0, size = 5) Pageable pageInfo | |
44 | + ) { | |
45 | + Page<Attribute> attributes = typeItemAttributeService.listAttributesByTypeItem(typeItemId, pageInfo); | |
46 | + return pagedResourcesAssembler.toModel(AttributeDto.convert(attributes)); | |
47 | + } | |
48 | + | |
49 | + @GetMapping("/{attributeId}") | |
50 | + public EntityModel<AttributeDto> findAttributeInTypeItem(@PathVariable Integer typeItemId, | |
51 | + @PathVariable Integer attributeId) { | |
52 | + Attribute attribute = typeItemAttributeService.findAttributeByTypeItem(typeItemId, attributeId); | |
53 | + return attributeModelAssembler.toModel(new AttributeDto(attribute)); | |
54 | + } | |
55 | + | |
56 | + @PostMapping | |
57 | + @SneakyThrows | |
58 | + public ResponseEntity<EntityModel<TypeItemAttributeDto>> linksAttributesTypeItem( | |
59 | + @PathVariable Integer typeItemId, | |
60 | + @RequestBody @Valid TypeItemAttributeForm typeItemAttributeForm, | |
61 | + UriComponentsBuilder uriBuilder | |
62 | + ) { | |
63 | + | |
64 | + TypeItemAttribute typeItemAttribute = typeItemAttributeService.save( | |
65 | + typeItemAttributeForm.getTypeItemId(), | |
66 | + typeItemAttributeForm.getAttributeId() | |
67 | + ); | |
68 | + | |
69 | + URI uri = uriBuilder.path("/projects/{projectId}/recommenders/{evaluatorId}") | |
70 | + .buildAndExpand(typeItemId, typeItemAttributeForm.getAttributeId()) | |
71 | + .toUri(); | |
72 | + | |
73 | + return ResponseEntity.created(uri) | |
74 | + .body(typeItemAttributeModelAssembler.toModel( | |
75 | + new TypeItemAttributeDto(typeItemAttribute) | |
76 | + )); | |
77 | + } | |
78 | + | |
79 | + @DeleteMapping("/{attributeId}") | |
80 | + @SneakyThrows | |
81 | + public ResponseEntity<Void> delete(@PathVariable Integer typeItemId, | |
82 | + @PathVariable Integer attributeId) { | |
83 | + typeItemAttributeService.delete(typeItemId, attributeId); | |
84 | + return ResponseEntity.noContent().build(); | |
85 | + } | |
86 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/controller/TypeItemController.java
0 → 100644
... | ... | @@ -0,0 +1,91 @@ |
1 | +package com.srh.api.controller; | |
2 | + | |
3 | +import com.srh.api.dto.resource.ItemDto; | |
4 | +import com.srh.api.dto.resource.TypeItemDto; | |
5 | +import com.srh.api.dto.resource.TypeItemForm; | |
6 | +import com.srh.api.hypermedia.TypeItemModelAssembler; | |
7 | +import com.srh.api.model.Item; | |
8 | +import com.srh.api.model.TypeItem; | |
9 | +import com.srh.api.service.TypeItemService; | |
10 | +import com.srh.api.utils.PageUtil; | |
11 | +import org.springframework.beans.factory.annotation.Autowired; | |
12 | +import org.springframework.data.domain.Page; | |
13 | +import org.springframework.data.domain.Pageable; | |
14 | +import org.springframework.data.web.PageableDefault; | |
15 | +import org.springframework.data.web.PagedResourcesAssembler; | |
16 | +import org.springframework.hateoas.EntityModel; | |
17 | +import org.springframework.hateoas.PagedModel; | |
18 | +import org.springframework.http.ResponseEntity; | |
19 | +import org.springframework.web.bind.annotation.*; | |
20 | +import org.springframework.web.util.UriComponentsBuilder; | |
21 | + | |
22 | +import javax.transaction.Transactional; | |
23 | +import javax.validation.Valid; | |
24 | + | |
25 | +import java.net.URI; | |
26 | + | |
27 | +import static com.srh.api.dto.resource.TypeItemDto.*; | |
28 | + | |
29 | +@RestController | |
30 | +@RequestMapping("/typeitens") | |
31 | +public class TypeItemController { | |
32 | + @Autowired | |
33 | + private TypeItemService typeItemService; | |
34 | + | |
35 | + @Autowired | |
36 | + private TypeItemModelAssembler typeItemModelAssembler; | |
37 | + | |
38 | + @Autowired | |
39 | + PagedResourcesAssembler<TypeItemDto> pagedResourcesAssembler; | |
40 | + | |
41 | + @Autowired | |
42 | + PagedResourcesAssembler<ItemDto> itemDtoPagedResourcesAssembler; | |
43 | + | |
44 | + @GetMapping | |
45 | + public PagedModel<EntityModel<TypeItemDto>> listAll(@PageableDefault(page = 0, size = 5) Pageable pageInfo) { | |
46 | + Page<TypeItem> typeItems = typeItemService.findAll(pageInfo); | |
47 | + return pagedResourcesAssembler.toModel(convert(typeItems)); | |
48 | + } | |
49 | + | |
50 | + @GetMapping("/{id}") | |
51 | + public EntityModel<TypeItemDto> find(@PathVariable Integer id) { | |
52 | + TypeItem typeItem = typeItemService.find(id); | |
53 | + return typeItemModelAssembler.toModel(new TypeItemDto(typeItem)); | |
54 | + } | |
55 | + | |
56 | + @PostMapping | |
57 | + public ResponseEntity<EntityModel<TypeItemDto>> create(@RequestBody @Valid TypeItemForm typeItemForm, | |
58 | + UriComponentsBuilder uriBuilder) { | |
59 | + TypeItem typeItem = typeItemForm.build(); | |
60 | + typeItemService.save(typeItem); | |
61 | + URI uri = uriBuilder.path("/typeitems/{id}").buildAndExpand(typeItem.getId()).toUri(); | |
62 | + return ResponseEntity.created(uri) | |
63 | + .body(typeItemModelAssembler.toModel(new TypeItemDto(typeItem))); | |
64 | + } | |
65 | + | |
66 | + @PutMapping("/{id}") | |
67 | + @Transactional | |
68 | + public EntityModel<TypeItemDto> update(@RequestBody @Valid TypeItemForm typeItemForm, @PathVariable Integer id) { | |
69 | + TypeItem typeItem = typeItemForm.build(); | |
70 | + typeItem.setId(id); | |
71 | + typeItem = typeItemService.update(typeItem); | |
72 | + return typeItemModelAssembler.toModel(new TypeItemDto(typeItem)); | |
73 | + } | |
74 | + | |
75 | + @DeleteMapping("/{id}") | |
76 | + public ResponseEntity<Void> delete(@PathVariable Integer id) { | |
77 | + typeItemService.delete(id); | |
78 | + return ResponseEntity.noContent().build(); | |
79 | + } | |
80 | + | |
81 | + @GetMapping("/{typeItemId}/itens") | |
82 | + public PagedModel<EntityModel<ItemDto>> findItensByTypeItem( | |
83 | + @PathVariable Integer typeItemId, | |
84 | + @PageableDefault(page = 0, size = 5) Pageable pageInfo | |
85 | + ) { | |
86 | + TypeItem typeItem = typeItemService.find(typeItemId); | |
87 | + PageUtil<Item> pageUtil = new PageUtil<>(pageInfo, typeItem.getItens()); | |
88 | + return itemDtoPagedResourcesAssembler.toModel(ItemDto.convert(pageUtil.getPage())); | |
89 | + } | |
90 | + | |
91 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/auth/AuthDto.java
0 → 100644
codigos/backend/src/main/java/com/srh/api/dto/auth/LoginForm.java
0 → 100644
... | ... | @@ -0,0 +1,24 @@ |
1 | +package com.srh.api.dto.auth; | |
2 | + | |
3 | +import lombok.Data; | |
4 | +import org.hibernate.validator.constraints.Length; | |
5 | +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; | |
6 | + | |
7 | +import javax.validation.constraints.NotEmpty; | |
8 | +import javax.validation.constraints.NotNull; | |
9 | + | |
10 | +@Data | |
11 | +public class LoginForm { | |
12 | + @NotNull | |
13 | + @NotEmpty | |
14 | + private String login; | |
15 | + | |
16 | + @NotNull | |
17 | + @NotEmpty | |
18 | + @Length(min = 6) | |
19 | + private String password; | |
20 | + | |
21 | + public UsernamePasswordAuthenticationToken convert() { | |
22 | + return new UsernamePasswordAuthenticationToken(login, password); | |
23 | + } | |
24 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/error/DefaultErrorDto.java
0 → 100644
codigos/backend/src/main/java/com/srh/api/dto/error/FormErrorDto.java
0 → 100644
codigos/backend/src/main/java/com/srh/api/dto/resource/AdminDto.java
0 → 100644
... | ... | @@ -0,0 +1,33 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | |
4 | +import com.srh.api.model.Admin; | |
5 | +import com.srh.api.model.Project; | |
6 | +import lombok.Getter; | |
7 | +import org.springframework.data.domain.Page; | |
8 | +import org.springframework.hateoas.server.core.Relation; | |
9 | + | |
10 | +import java.util.List; | |
11 | + | |
12 | +@Getter | |
13 | +@Relation(collectionRelation = "admins") | |
14 | +public class AdminDto { | |
15 | + private final Integer id; | |
16 | + private final String name; | |
17 | + private final String login; | |
18 | + private final String email; | |
19 | + @JsonIgnore | |
20 | + private final List<Project> projects; | |
21 | + | |
22 | + public AdminDto(Admin admin) { | |
23 | + this.id = admin.getId(); | |
24 | + this.name = admin.getName(); | |
25 | + this.login = admin.getLogin(); | |
26 | + this.email = admin.getEmail(); | |
27 | + this.projects = admin.getProjects(); | |
28 | + } | |
29 | + | |
30 | + public static Page<AdminDto> convert(Page<Admin> admins) { | |
31 | + return admins.map(AdminDto::new); | |
32 | + } | |
33 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/AdminForm.java
0 → 100644
... | ... | @@ -0,0 +1,49 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.builder.AdminBuilder; | |
4 | +import com.srh.api.model.Admin; | |
5 | +import lombok.AllArgsConstructor; | |
6 | +import lombok.Getter; | |
7 | +import lombok.NoArgsConstructor; | |
8 | +import org.hibernate.validator.constraints.Length; | |
9 | + | |
10 | +import javax.validation.constraints.Email; | |
11 | +import javax.validation.constraints.NotEmpty; | |
12 | +import javax.validation.constraints.NotNull; | |
13 | + | |
14 | +@Getter | |
15 | +@AllArgsConstructor | |
16 | +@NoArgsConstructor | |
17 | +public class AdminForm { | |
18 | + @NotNull | |
19 | + @NotEmpty | |
20 | + @Length(min = 3) | |
21 | + private String name; | |
22 | + | |
23 | + @NotNull | |
24 | + @NotEmpty | |
25 | + @Length(min = 3) | |
26 | + private String login; | |
27 | + | |
28 | + @NotNull | |
29 | + @NotEmpty | |
30 | + @Length(min = 6) | |
31 | + private String password; | |
32 | + | |
33 | + @NotNull | |
34 | + @NotEmpty | |
35 | ||
36 | + private String email; | |
37 | + | |
38 | + private String oldPassword; | |
39 | + | |
40 | + public Admin build() { | |
41 | + return AdminBuilder.anAdmin() | |
42 | + .withName(name) | |
43 | + .withLogin(login) | |
44 | + .withEmail(email) | |
45 | + .withPassword(password) | |
46 | + .withOldPassword(password) | |
47 | + .build(); | |
48 | + } | |
49 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/AlgorithmDto.java
0 → 100644
... | ... | @@ -0,0 +1,24 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.model.Algorithm; | |
4 | +import lombok.Getter; | |
5 | +import org.springframework.data.domain.Page; | |
6 | +import org.springframework.hateoas.server.core.Relation; | |
7 | + | |
8 | +@Getter | |
9 | +@Relation(collectionRelation = "algorithms") | |
10 | +public class AlgorithmDto { | |
11 | + private final Integer id; | |
12 | + private final String name; | |
13 | + private final String typeRecommendation; | |
14 | + | |
15 | + public AlgorithmDto(Algorithm algorithm) { | |
16 | + this.id = algorithm.getId(); | |
17 | + this.name = algorithm.getName(); | |
18 | + this.typeRecommendation = algorithm.getTypeRecommendation().toString(); | |
19 | + } | |
20 | + | |
21 | + public static Page<AlgorithmDto> convert(Page<Algorithm> algorithms) { | |
22 | + return algorithms.map(AlgorithmDto::new); | |
23 | + } | |
24 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/AlgorithmForm.java
0 → 100644
... | ... | @@ -0,0 +1,31 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.builder.AlgorithmBuilder; | |
4 | +import com.srh.api.model.Algorithm; | |
5 | +import com.srh.api.model.TypeRecommendation; | |
6 | +import lombok.AllArgsConstructor; | |
7 | +import lombok.Getter; | |
8 | +import lombok.NoArgsConstructor; | |
9 | + | |
10 | +import javax.validation.constraints.NotEmpty; | |
11 | +import javax.validation.constraints.NotNull; | |
12 | + | |
13 | +@Getter | |
14 | +@AllArgsConstructor | |
15 | +@NoArgsConstructor | |
16 | +public class AlgorithmForm { | |
17 | + @NotNull | |
18 | + @NotEmpty | |
19 | + private String name; | |
20 | + | |
21 | + @NotNull | |
22 | + @NotEmpty | |
23 | + private String typeRecommendation; | |
24 | + | |
25 | + public Algorithm build() { | |
26 | + return AlgorithmBuilder.anAlgorithm() | |
27 | + .withName(name) | |
28 | + .withTypeRecommendation(TypeRecommendation.valueOf(typeRecommendation)) | |
29 | + .build(); | |
30 | + } | |
31 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/ApiUserForm.java
0 → 100644
... | ... | @@ -0,0 +1,52 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.builder.ApiUserBuilder; | |
4 | +import com.srh.api.model.ApiUser; | |
5 | +import lombok.AllArgsConstructor; | |
6 | +import lombok.Getter; | |
7 | +import lombok.NoArgsConstructor; | |
8 | +import org.hibernate.validator.constraints.Length; | |
9 | + | |
10 | +import javax.validation.constraints.Email; | |
11 | +import javax.validation.constraints.NotEmpty; | |
12 | +import javax.validation.constraints.NotNull; | |
13 | + | |
14 | +@Getter | |
15 | +@AllArgsConstructor | |
16 | +@NoArgsConstructor | |
17 | +public class ApiUserForm { | |
18 | + @NotEmpty | |
19 | + @NotNull | |
20 | + @Length(min = 3) | |
21 | + private String name; | |
22 | + | |
23 | + @NotEmpty | |
24 | + @NotNull | |
25 | + @Length(min = 3) | |
26 | + private String login; | |
27 | + | |
28 | + @NotEmpty | |
29 | + @NotNull | |
30 | + @Length(min = 6) | |
31 | + private String password; | |
32 | + | |
33 | + @NotNull | |
34 | + @NotEmpty | |
35 | ||
36 | + private String email; | |
37 | + | |
38 | + private String oldPassword; | |
39 | + | |
40 | + @NotNull | |
41 | + private Boolean isAdmin; | |
42 | + | |
43 | + public ApiUser build() { | |
44 | + return ApiUserBuilder.anApiUser() | |
45 | + .withLogin(login) | |
46 | + .withName(name) | |
47 | + .withEmail(email) | |
48 | + .withPassword(password) | |
49 | + .withOldPassword(oldPassword) | |
50 | + .build(); | |
51 | + } | |
52 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/ApiUsersDto.java
0 → 100644
... | ... | @@ -0,0 +1,34 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | |
4 | +import com.srh.api.model.ApiUser; | |
5 | +import com.srh.api.model.Profile; | |
6 | +import lombok.Getter; | |
7 | +import org.springframework.data.domain.Page; | |
8 | +import org.springframework.hateoas.server.core.Relation; | |
9 | + | |
10 | +import java.util.List; | |
11 | + | |
12 | +@Getter | |
13 | +@Relation(collectionRelation = "apiUsers") | |
14 | +public class ApiUsersDto { | |
15 | + private final Integer id; | |
16 | + private final String name; | |
17 | + private final String login; | |
18 | + private final String email; | |
19 | + | |
20 | + @JsonIgnore | |
21 | + private final List<Profile> profiles; | |
22 | + | |
23 | + public ApiUsersDto(ApiUser apiUser) { | |
24 | + this.id = apiUser.getId(); | |
25 | + this.name = apiUser.getName(); | |
26 | + this.login = apiUser.getLogin(); | |
27 | + this.profiles = apiUser.getProfiles(); | |
28 | + this.email = apiUser.getEmail(); | |
29 | + } | |
30 | + | |
31 | + public static Page<ApiUsersDto> convert(Page<ApiUser> users) { | |
32 | + return users.map(ApiUsersDto::new); | |
33 | + } | |
34 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/AttributeDto.java
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.model.Attribute; | |
4 | +import lombok.Getter; | |
5 | +import org.springframework.data.domain.Page; | |
6 | +import org.springframework.hateoas.server.core.Relation; | |
7 | + | |
8 | +@Getter | |
9 | +@Relation(collectionRelation = "attributes") | |
10 | +public class AttributeDto { | |
11 | + private final Integer id; | |
12 | + private final String name; | |
13 | + private final String value; | |
14 | + private final String type; | |
15 | + | |
16 | + public AttributeDto(Attribute attribute) { | |
17 | + this.id = attribute.getId(); | |
18 | + this.name = attribute.getName(); | |
19 | + this.value = attribute.getValue(); | |
20 | + this.type = attribute.getType().toString(); | |
21 | + } | |
22 | + | |
23 | + public static Page<AttributeDto> convert(Page<Attribute> attributes) { | |
24 | + return attributes.map(AttributeDto::new); | |
25 | + } | |
26 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/AttributeForm.java
0 → 100644
... | ... | @@ -0,0 +1,36 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.builder.AttributeBuilder; | |
4 | +import com.srh.api.model.Attribute; | |
5 | +import com.srh.api.model.TypeAttribute; | |
6 | +import lombok.AllArgsConstructor; | |
7 | +import lombok.Getter; | |
8 | +import lombok.NoArgsConstructor; | |
9 | + | |
10 | +import javax.validation.constraints.NotEmpty; | |
11 | +import javax.validation.constraints.NotNull; | |
12 | + | |
13 | +@Getter | |
14 | +@AllArgsConstructor | |
15 | +@NoArgsConstructor | |
16 | +public class AttributeForm { | |
17 | + @NotNull | |
18 | + @NotEmpty | |
19 | + private String name; | |
20 | + | |
21 | + @NotNull | |
22 | + @NotEmpty | |
23 | + private String value; | |
24 | + | |
25 | + @NotNull | |
26 | + @NotEmpty | |
27 | + private String type; | |
28 | + | |
29 | + public Attribute build() { | |
30 | + return AttributeBuilder.anAttribute() | |
31 | + .withName(name) | |
32 | + .withValue(value) | |
33 | + .withType(TypeAttribute.valueOf(type)) | |
34 | + .build(); | |
35 | + } | |
36 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/EvaluatorDto.java
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.model.Evaluator; | |
4 | +import lombok.Getter; | |
5 | +import org.springframework.data.domain.Page; | |
6 | +import org.springframework.hateoas.server.core.Relation; | |
7 | + | |
8 | +@Getter | |
9 | +@Relation(collectionRelation = "evaluators") | |
10 | +public class EvaluatorDto { | |
11 | + private final Integer id; | |
12 | + private final String name; | |
13 | + private final String login; | |
14 | + private final String email; | |
15 | + | |
16 | + public EvaluatorDto(Evaluator evaluator) { | |
17 | + this.id = evaluator.getId(); | |
18 | + this.name = evaluator.getName(); | |
19 | + this.login = evaluator.getLogin(); | |
20 | + this.email = evaluator.getEmail(); | |
21 | + } | |
22 | + | |
23 | + public static Page<EvaluatorDto> convert(Page<Evaluator> users) { | |
24 | + return users.map(EvaluatorDto::new); | |
25 | + } | |
26 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/EvaluatorForm.java
0 → 100644
... | ... | @@ -0,0 +1,49 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.builder.EvaluatorBuilder; | |
4 | +import com.srh.api.model.Evaluator; | |
5 | +import lombok.AllArgsConstructor; | |
6 | +import lombok.Getter; | |
7 | +import lombok.NoArgsConstructor; | |
8 | +import org.hibernate.validator.constraints.Length; | |
9 | + | |
10 | +import javax.validation.constraints.Email; | |
11 | +import javax.validation.constraints.NotEmpty; | |
12 | +import javax.validation.constraints.NotNull; | |
13 | + | |
14 | +@Getter | |
15 | +@AllArgsConstructor | |
16 | +@NoArgsConstructor | |
17 | +public class EvaluatorForm { | |
18 | + @NotNull | |
19 | + @NotEmpty | |
20 | + @Length(min = 3) | |
21 | + private String name; | |
22 | + | |
23 | + @NotNull | |
24 | + @NotEmpty | |
25 | + @Length(min = 3) | |
26 | + private String login; | |
27 | + | |
28 | + @NotNull | |
29 | + @NotEmpty | |
30 | + @Length(min = 6) | |
31 | + private String password; | |
32 | + | |
33 | + @NotNull | |
34 | + @NotEmpty | |
35 | ||
36 | + private String email; | |
37 | + | |
38 | + private String oldPassword; | |
39 | + | |
40 | + public Evaluator build() { | |
41 | + return EvaluatorBuilder.anEvaluator() | |
42 | + .withName(name) | |
43 | + .withLogin(login) | |
44 | + .withPassword(password) | |
45 | + .withOldPassword(oldPassword) | |
46 | + .withEmail(email) | |
47 | + .build(); | |
48 | + } | |
49 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/ItemAttributeDto.java
0 → 100644
... | ... | @@ -0,0 +1,17 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.model.ItemAttribute; | |
4 | +import lombok.Getter; | |
5 | +import org.springframework.hateoas.server.core.Relation; | |
6 | + | |
7 | +@Getter | |
8 | +@Relation(collectionRelation = "relationship") | |
9 | +public class ItemAttributeDto { | |
10 | + private final Integer itemId; | |
11 | + private final Integer attributeId; | |
12 | + | |
13 | + public ItemAttributeDto(ItemAttribute itemAttribute) { | |
14 | + this.itemId = itemAttribute.getItem().getId(); | |
15 | + this.attributeId = itemAttribute.getAttribute().getId(); | |
16 | + } | |
17 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/ItemAttributeForm.java
0 → 100644
... | ... | @@ -0,0 +1,18 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Getter; | |
5 | +import lombok.NoArgsConstructor; | |
6 | + | |
7 | +import javax.validation.constraints.NotNull; | |
8 | + | |
9 | +@Getter | |
10 | +@AllArgsConstructor | |
11 | +@NoArgsConstructor | |
12 | +public class ItemAttributeForm { | |
13 | + @NotNull | |
14 | + private Integer itemId; | |
15 | + | |
16 | + @NotNull | |
17 | + private Integer attributeId; | |
18 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/ItemDto.java
0 → 100644
... | ... | @@ -0,0 +1,33 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | |
4 | +import com.srh.api.model.Item; | |
5 | +import com.srh.api.model.Project; | |
6 | +import com.srh.api.model.TypeItem; | |
7 | +import lombok.Getter; | |
8 | +import org.springframework.data.domain.Page; | |
9 | +import org.springframework.hateoas.server.core.Relation; | |
10 | + | |
11 | +@Getter | |
12 | +@Relation(collectionRelation = "itens") | |
13 | +public class ItemDto { | |
14 | + private final Integer id; | |
15 | + private final String name; | |
16 | + private final String description; | |
17 | + @JsonIgnore | |
18 | + private final Project project; | |
19 | + @JsonIgnore | |
20 | + private final TypeItem typeItem; | |
21 | + | |
22 | + public ItemDto(Item item) { | |
23 | + this.id = item.getId(); | |
24 | + this.name = item.getName(); | |
25 | + this.description = item.getDescription(); | |
26 | + this.project = item.getProject(); | |
27 | + this.typeItem = item.getTypeItem(); | |
28 | + } | |
29 | + | |
30 | + public static Page<ItemDto> convert(Page<Item> items) { | |
31 | + return items.map(ItemDto::new); | |
32 | + } | |
33 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/ItemForm.java
0 → 100644
... | ... | @@ -0,0 +1,60 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.builder.ItemBuilder; | |
4 | +import com.srh.api.builder.ProjectBuilder; | |
5 | +import com.srh.api.builder.TypeItemBuilder; | |
6 | +import com.srh.api.model.Item; | |
7 | +import com.srh.api.model.Project; | |
8 | +import com.srh.api.model.TypeItem; | |
9 | +import lombok.AllArgsConstructor; | |
10 | +import lombok.Getter; | |
11 | +import lombok.NoArgsConstructor; | |
12 | +import org.hibernate.validator.constraints.Length; | |
13 | + | |
14 | +import javax.validation.constraints.NotEmpty; | |
15 | +import javax.validation.constraints.NotNull; | |
16 | + | |
17 | +@Getter | |
18 | +@AllArgsConstructor | |
19 | +@NoArgsConstructor | |
20 | +public class ItemForm { | |
21 | + @NotNull | |
22 | + @NotEmpty | |
23 | + @Length(min = 3) | |
24 | + private String name; | |
25 | + | |
26 | + @NotNull | |
27 | + @NotEmpty | |
28 | + @Length(min = 3) | |
29 | + private String description; | |
30 | + | |
31 | + @NotNull | |
32 | + private Integer projectId; | |
33 | + | |
34 | + private Integer typeItemId; | |
35 | + | |
36 | + public Item build() { | |
37 | + Project project = ProjectBuilder.aProject() | |
38 | + .withId(projectId) | |
39 | + .build(); | |
40 | + | |
41 | + if (typeItemId != null) { | |
42 | + TypeItem typeItem = TypeItemBuilder.aTypeItem() | |
43 | + .withId(typeItemId) | |
44 | + .build(); | |
45 | + | |
46 | + return ItemBuilder.anItem() | |
47 | + .withName(name) | |
48 | + .withDescription(description) | |
49 | + .withProject(project) | |
50 | + .withTypeItem(typeItem) | |
51 | + .build(); | |
52 | + } | |
53 | + | |
54 | + return ItemBuilder.anItem() | |
55 | + .withName(name) | |
56 | + .withDescription(description) | |
57 | + .withProject(project) | |
58 | + .build(); | |
59 | + } | |
60 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/ItemRatingDto.java
0 → 100644
... | ... | @@ -0,0 +1,28 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | |
4 | +import com.srh.api.model.Evaluator; | |
5 | +import com.srh.api.model.Item; | |
6 | +import com.srh.api.model.ItemRating; | |
7 | +import lombok.Getter; | |
8 | +import org.springframework.data.domain.Page; | |
9 | +import org.springframework.hateoas.server.core.Relation; | |
10 | + | |
11 | +@Getter | |
12 | +@Relation(collectionRelation = "itemRatings") | |
13 | +public class ItemRatingDto extends RatingDto { | |
14 | + @JsonIgnore | |
15 | + private final Item item; | |
16 | + @JsonIgnore | |
17 | + private final Evaluator evaluator; | |
18 | + | |
19 | + public ItemRatingDto(ItemRating itemRating) { | |
20 | + super(itemRating); | |
21 | + this.item = itemRating.getItem(); | |
22 | + this.evaluator = itemRating.getEvaluator(); | |
23 | + } | |
24 | + | |
25 | + public static Page<ItemRatingDto> convert(Page<ItemRating> itemRatings) { | |
26 | + return itemRatings.map(ItemRatingDto::new); | |
27 | + } | |
28 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/ItemRatingForm.java
0 → 100644
... | ... | @@ -0,0 +1,43 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.builder.EvaluatorBuilder; | |
4 | +import com.srh.api.builder.ItemBuilder; | |
5 | +import com.srh.api.builder.ItemRatingBuilder; | |
6 | +import com.srh.api.model.Evaluator; | |
7 | +import com.srh.api.model.Item; | |
8 | +import com.srh.api.model.ItemRating; | |
9 | +import lombok.AllArgsConstructor; | |
10 | +import lombok.Getter; | |
11 | +import lombok.NoArgsConstructor; | |
12 | + | |
13 | +import javax.validation.constraints.NotNull; | |
14 | +import java.time.LocalDateTime; | |
15 | + | |
16 | +@Getter | |
17 | +@AllArgsConstructor | |
18 | +@NoArgsConstructor | |
19 | +public class ItemRatingForm { | |
20 | + @NotNull | |
21 | + private Double score; | |
22 | + @NotNull | |
23 | + private Integer evaluatorId; | |
24 | + @NotNull | |
25 | + private Integer itemId; | |
26 | + | |
27 | + public ItemRating build() { | |
28 | + Evaluator evaluator = EvaluatorBuilder.anEvaluator() | |
29 | + .withId(evaluatorId) | |
30 | + .build(); | |
31 | + | |
32 | + Item item = ItemBuilder.anItem() | |
33 | + .withId(itemId) | |
34 | + .build(); | |
35 | + | |
36 | + return ItemRatingBuilder.anItemRating() | |
37 | + .withScore(score) | |
38 | + .withEvaluator(evaluator) | |
39 | + .withItem(item) | |
40 | + .withDate(LocalDateTime.now()) | |
41 | + .build(); | |
42 | + } | |
43 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/ItemTagDto.java
0 → 100644
... | ... | @@ -0,0 +1,17 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.model.ItemTag; | |
4 | +import lombok.Getter; | |
5 | +import org.springframework.hateoas.server.core.Relation; | |
6 | + | |
7 | +@Getter | |
8 | +@Relation(collectionRelation = "relationship") | |
9 | +public class ItemTagDto { | |
10 | + private final Integer itemId; | |
11 | + private final Integer tagId; | |
12 | + | |
13 | + public ItemTagDto(ItemTag itemTag) { | |
14 | + this.itemId = itemTag.getItem().getId(); | |
15 | + this.tagId = itemTag.getTag().getId(); | |
16 | + } | |
17 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/ItemTagForm.java
0 → 100644
... | ... | @@ -0,0 +1,17 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Getter; | |
5 | +import lombok.NoArgsConstructor; | |
6 | + | |
7 | +import javax.validation.constraints.NotNull; | |
8 | + | |
9 | +@Getter | |
10 | +@AllArgsConstructor | |
11 | +@NoArgsConstructor | |
12 | +public class ItemTagForm { | |
13 | + @NotNull | |
14 | + private Integer itemId; | |
15 | + @NotNull | |
16 | + private Integer tagId; | |
17 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/LoginClientForm.java
0 → 100644
... | ... | @@ -0,0 +1,24 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Getter; | |
5 | +import lombok.NoArgsConstructor; | |
6 | +import org.hibernate.validator.constraints.Length; | |
7 | + | |
8 | +import javax.validation.constraints.NotEmpty; | |
9 | +import javax.validation.constraints.NotNull; | |
10 | + | |
11 | +@Getter | |
12 | +@AllArgsConstructor | |
13 | +@NoArgsConstructor | |
14 | +public class LoginClientForm { | |
15 | + @NotNull | |
16 | + @NotEmpty | |
17 | + @Length(min = 3) | |
18 | + private String login; | |
19 | + | |
20 | + @NotNull | |
21 | + @NotEmpty | |
22 | + @Length(min = 6) | |
23 | + private String password; | |
24 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/ProjectDto.java
0 → 100644
... | ... | @@ -0,0 +1,38 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | |
4 | +import com.srh.api.model.Admin; | |
5 | +import com.srh.api.model.Project; | |
6 | +import com.srh.api.model.Situations; | |
7 | +import lombok.Getter; | |
8 | +import org.springframework.data.domain.Page; | |
9 | +import org.springframework.hateoas.server.core.Relation; | |
10 | + | |
11 | +import java.time.LocalDate; | |
12 | + | |
13 | +@Getter | |
14 | +@Relation(collectionRelation = "projects") | |
15 | +public class ProjectDto { | |
16 | + private final Integer id; | |
17 | + private final String name; | |
18 | + private final String description; | |
19 | + private final Situations situation; | |
20 | + private final LocalDate date; | |
21 | + private final Boolean visible; | |
22 | + @JsonIgnore | |
23 | + private final Admin admin; | |
24 | + | |
25 | + public ProjectDto(Project project) { | |
26 | + this.id = project.getId(); | |
27 | + this.name = project.getName(); | |
28 | + this.description = project.getDescription(); | |
29 | + this.date = project.getDate(); | |
30 | + this.situation = project.getSituation(); | |
31 | + this.visible = project.getVisible(); | |
32 | + this.admin = project.getAdmin(); | |
33 | + } | |
34 | + | |
35 | + public static Page<ProjectDto> convert(Page<Project> projects) { | |
36 | + return projects.map(ProjectDto::new); | |
37 | + } | |
38 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/ProjectEvaluatorDto.java
0 → 100644
... | ... | @@ -0,0 +1,17 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.model.ProjectEvaluator; | |
4 | +import lombok.Getter; | |
5 | +import org.springframework.hateoas.server.core.Relation; | |
6 | + | |
7 | +@Getter | |
8 | +@Relation(collectionRelation = "relationship") | |
9 | +public class ProjectEvaluatorDto { | |
10 | + private final Integer projectId; | |
11 | + private final Integer evaluatorId; | |
12 | + | |
13 | + public ProjectEvaluatorDto(ProjectEvaluator projectEvaluator) { | |
14 | + this.projectId = projectEvaluator.getProject().getId(); | |
15 | + this.evaluatorId = projectEvaluator.getEvaluator().getId(); | |
16 | + } | |
17 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/ProjectEvaluatorForm.java
0 → 100644
... | ... | @@ -0,0 +1,17 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Getter; | |
5 | +import lombok.NoArgsConstructor; | |
6 | + | |
7 | +import javax.validation.constraints.NotNull; | |
8 | + | |
9 | +@Getter | |
10 | +@AllArgsConstructor | |
11 | +@NoArgsConstructor | |
12 | +public class ProjectEvaluatorForm { | |
13 | + @NotNull | |
14 | + private Integer projectId; | |
15 | + @NotNull | |
16 | + private Integer evaluatorId; | |
17 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/ProjectForm.java
0 → 100644
... | ... | @@ -0,0 +1,57 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.builder.AdminBuilder; | |
4 | +import com.srh.api.builder.ProjectBuilder; | |
5 | +import com.srh.api.model.Admin; | |
6 | +import com.srh.api.model.Project; | |
7 | +import com.srh.api.model.Situations; | |
8 | +import lombok.AllArgsConstructor; | |
9 | +import lombok.Getter; | |
10 | +import lombok.NoArgsConstructor; | |
11 | +import org.hibernate.validator.constraints.Length; | |
12 | + | |
13 | +import javax.validation.constraints.NotEmpty; | |
14 | +import javax.validation.constraints.NotNull; | |
15 | +import java.time.LocalDate; | |
16 | + | |
17 | +@Getter | |
18 | +@AllArgsConstructor | |
19 | +@NoArgsConstructor | |
20 | +public class ProjectForm { | |
21 | + | |
22 | + @NotEmpty | |
23 | + @NotNull | |
24 | + @Length(min = 3) | |
25 | + private String name; | |
26 | + | |
27 | + @NotEmpty | |
28 | + @NotNull | |
29 | + @Length(min = 3) | |
30 | + private String description; | |
31 | + | |
32 | + @NotNull | |
33 | + private Integer adminId; | |
34 | + | |
35 | + @NotNull | |
36 | + @NotEmpty | |
37 | + private String situation; | |
38 | + | |
39 | + @NotNull | |
40 | + private Boolean visible; | |
41 | + | |
42 | + public Project build() { | |
43 | + Admin admin = AdminBuilder.anAdmin() | |
44 | + .withId(adminId) | |
45 | + .build(); | |
46 | + | |
47 | + return ProjectBuilder.aProject() | |
48 | + .withName(name) | |
49 | + .withDescription(description) | |
50 | + .withAdmin(admin) | |
51 | + .withSituation(Situations.valueOf(situation)) | |
52 | + .withDate(LocalDate.now()) | |
53 | + .withVisible(visible) | |
54 | + .withLastMatrixId(0) | |
55 | + .build(); | |
56 | + } | |
57 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/RatingDto.java
0 → 100644
... | ... | @@ -0,0 +1,21 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.model.ItemRating; | |
4 | +import com.srh.api.model.Rating; | |
5 | +import lombok.Getter; | |
6 | +import org.springframework.data.domain.Page; | |
7 | + | |
8 | +import java.time.LocalDateTime; | |
9 | + | |
10 | +@Getter | |
11 | +public class RatingDto { | |
12 | + private final Integer id; | |
13 | + private final Double score; | |
14 | + private final LocalDateTime date; | |
15 | + | |
16 | + public RatingDto(Rating rating) { | |
17 | + this.id = rating.getId(); | |
18 | + this.score = rating.getScore(); | |
19 | + this.date = rating.getDate(); | |
20 | + } | |
21 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/RecommendationDto.java
0 → 100644
... | ... | @@ -0,0 +1,28 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.srh.api.model.Recommendation; | |
4 | +import lombok.Getter; | |
5 | +import org.springframework.data.domain.Page; | |
6 | +import org.springframework.hateoas.server.core.Relation; | |
7 | + | |
8 | +import java.time.LocalDateTime; | |
9 | + | |
10 | +@Getter | |
11 | +@Relation(collectionRelation = "recommendations") | |
12 | +public class RecommendationDto { | |
13 | + private final Integer id; | |
14 | + private final Double weight; | |
15 | + private final LocalDateTime date; | |
16 | + private final Integer runtimeInSeconds; | |
17 | + | |
18 | + public RecommendationDto(Recommendation recommendation) { | |
19 | + this.id = recommendation.getId(); | |
20 | + this.weight = recommendation.getWeight(); | |
21 | + this.date = recommendation.getDate(); | |
22 | + this.runtimeInSeconds = recommendation.getRuntimeInSeconds(); | |
23 | + } | |
24 | + | |
25 | + public static Page<RecommendationDto> convert(Page<Recommendation> recommendations) { | |
26 | + return recommendations.map(RecommendationDto::new); | |
27 | + } | |
28 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/RecommendationForm.java
0 → 100644
... | ... | @@ -0,0 +1,28 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Getter; | |
5 | +import lombok.NoArgsConstructor; | |
6 | + | |
7 | +import javax.validation.constraints.Max; | |
8 | +import javax.validation.constraints.Min; | |
9 | +import javax.validation.constraints.NotNull; | |
10 | + | |
11 | +@Getter | |
12 | +@AllArgsConstructor | |
13 | +@NoArgsConstructor | |
14 | +public class RecommendationForm { | |
15 | + @Min(value = 0) | |
16 | + @Max(value = 5) | |
17 | + @NotNull | |
18 | + private Double passingScore; | |
19 | + | |
20 | + @NotNull | |
21 | + private Integer algorithmId; | |
22 | + | |
23 | + @NotNull | |
24 | + private Boolean offline; | |
25 | + | |
26 | + @NotNull | |
27 | + private Integer projectId; | |
28 | +} | ... | ... |
codigos/backend/src/main/java/com/srh/api/dto/resource/RecommendationRatingDto.java
0 → 100644
... | ... | @@ -0,0 +1,28 @@ |
1 | +package com.srh.api.dto.resource; | |
2 | + | |
3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | |
4 | +import com.srh.api.model.Evaluator; | |
5 | +import com.srh.api.model.Recommendation; | |
6 | +import com.srh.api.model.RecommendationRating; | |
7 | +import lombok.Getter; | |
8 | +import org.springframework.data.domain.Page; | |
9 | +import org.springframework.hateoas.server.core.Relation; | |
10 | + | |
11 | +@Getter | |
12 | +@Relation(collectionRelation = "recommendationRatings") | |
13 | +public class RecommendationRatingDto extends RatingDto { | |
14 | + @JsonIgnore | |
15 | + private final Recommendation recommendation; | |
16 | + @JsonIgnore | |
17 | + private final Evaluator evaluator; | |
18 | + | |
19 | + public RecommendationRatingDto(RecommendationRating recommedationRating) { | |
20 | + super(recommedationRating); | |
21 | + this.recommendation = recommedationRating.getRecommendation(); | |
22 | + this.evaluator = recommedationRating.getEvaluator(); | |
23 | + } | |
24 | + | |
25 | + public static Page<RecommendationRatingDto> convert(Page<RecommendationRating> recommendationRatings) { | |
26 | + return recommendationRatings.map(RecommendationRatingDto::new); | |
27 | + } | |
28 | +} | ... | ... |