├── .classpath
├── .gitattributes
├── .gitignore
├── .project
├── .settings
├── org.eclipse.core.resources.prefs
├── org.eclipse.jdt.core.prefs
├── org.eclipse.m2e.core.prefs
└── org.eclipse.wst.common.project.facet.core.xml
├── .travis.yml
├── Diagrama
├── class-diagram.asta
└── class-diagram.png
├── README.md
├── bin
└── application
│ └── application.css
├── build.fxbuild
├── db
└── adminDb.db
├── pom.xml
├── screens
├── apresentation.png
├── inventory-search.png
├── new-employee.png
├── new-product.png
├── painel.png
├── report-pdf.png
└── reports.png
└── src
└── main
├── java
└── com
│ └── tiagohs
│ ├── MainApplication.java
│ ├── SplashScreen.java
│ ├── controller
│ ├── AboutController.java
│ ├── BaseController.java
│ ├── BrandNewController.java
│ ├── ClientNewController.java
│ ├── ClientsController.java
│ ├── DashboardController.java
│ ├── EmployeeNewController.java
│ ├── IItemBaseController.java
│ ├── InventoryController.java
│ ├── ItemBaseController.java
│ ├── LoginController.java
│ ├── LoginDialogController.java
│ ├── ProductNewController.java
│ ├── ReportViewerController.java
│ ├── ReportsController.java
│ ├── RootController.java
│ ├── SaleTableController.java
│ ├── SalesController.java
│ ├── SalesNewController.java
│ ├── SettingsController.java
│ └── SupplierNewController.java
│ ├── dialect
│ ├── SQLiteDialect.java
│ └── SQLiteDialectIdentityColumnSupport.java
│ ├── model
│ ├── Address.java
│ ├── Brand.java
│ ├── Client.java
│ ├── ClientType.java
│ ├── Employee.java
│ ├── Fone.java
│ ├── Image.java
│ ├── Item.java
│ ├── Language.java
│ ├── Product.java
│ ├── ProductType.java
│ ├── Role.java
│ ├── Sale.java
│ ├── Supplier.java
│ ├── Tag.java
│ ├── User.java
│ └── dto
│ │ ├── BrandTableDTO.java
│ │ ├── ClientTableDTO.java
│ │ ├── EmployeeReportDTO.java
│ │ ├── EmployeeTableDTO.java
│ │ ├── ProductReportDTO.java
│ │ ├── ProductTableDTO.java
│ │ ├── SalesReportDTO.java
│ │ ├── SalesTableDTO.java
│ │ ├── SupplierReportDTO.java
│ │ └── SupplierTableDTO.java
│ ├── repository
│ ├── BrandRepository.java
│ ├── ClientRepository.java
│ ├── EmployeeRepository.java
│ ├── LanguageRepository.java
│ ├── ProductRepository.java
│ ├── ProductTypeRepository.java
│ ├── RoleRepository.java
│ ├── SaleRepository.java
│ ├── SupplierRepository.java
│ └── UserRepository.java
│ ├── service
│ ├── BaseCrudService.java
│ ├── BaseService.java
│ ├── BrandService.java
│ ├── BrandServiceImpl.java
│ ├── ClientService.java
│ ├── ClientServiceImpl.java
│ ├── EmployeeService.java
│ ├── EmployeeServiceImpl.java
│ ├── IBaseService.java
│ ├── LanguageService.java
│ ├── LanguageServiceImpl.java
│ ├── ProductService.java
│ ├── ProductServiceImpl.java
│ ├── ProductTypeService.java
│ ├── ProductTypeServiceImpl.java
│ ├── ReportsService.java
│ ├── ReportsServiceImpl.java
│ ├── RoleService.java
│ ├── RoleServiceImpl.java
│ ├── SaleService.java
│ ├── SaleServiceImpl.java
│ ├── SupplierService.java
│ ├── SupplierServiceImpl.java
│ ├── TableService.java
│ ├── UserService.java
│ └── UserServiceImpl.java
│ ├── util
│ ├── ComboBoxSelectListener.java
│ ├── DialogAction.java
│ ├── EntityFactory.java
│ ├── EntityReportFactory.java
│ ├── I18N.java
│ ├── ITableDataCreator.java
│ ├── ITableSearchTest.java
│ ├── ITableServiceCreator.java
│ ├── JRPrintPreview.java
│ ├── TableUtils.java
│ ├── ValidatorUtils.java
│ ├── WatchListener.java
│ └── WindowsUtils.java
│ └── validators
│ ├── DecimalValidator.java
│ ├── DuplicateUserValidator.java
│ ├── EmailValidator.java
│ ├── MaxLengthValidator.java
│ ├── MoneyValidator.java
│ ├── NumberValidator.java
│ └── PasswordAndConfirmPasswordValidator.java
└── resources
├── application.properties
├── css
├── application.css
└── jfoenix.css
├── data.sql
├── fonts
└── Roboto-Regular.ttf
├── fxml
├── about.fxml
├── clients.fxml
├── dashboard.fxml
├── dialog.fxml
├── inventory.fxml
├── item_base.fxml
├── login.fxml
├── login_dialog.fxml
├── new_brand.fxml
├── new_client.fxml
├── new_employee.fxml
├── new_product.fxml
├── new_sale_order.fxml
├── new_supplier.fxml
├── report_viewer.fxml
├── reports.fxml
├── root.fxml
├── sale_table.fxml
├── sales.fxml
├── settings.fxml
└── test.fxml
├── i18n
├── i18n.properties
├── i18n_en_US.properties
└── i18n_pt_BR.properties
├── images
├── calendar.png
├── dashboard.png
├── edit.png
├── employee.png
├── exit.png
├── facebook.png
├── file.png
├── github.png
├── gmail.png
├── google.png
├── help.png
├── home.png
├── icon.ico
├── icon.png
├── image.png
├── inventory.png
├── linkedin.png
├── minus-clean.png
├── next-first.png
├── next-last.png
├── next-left.png
├── next-right.png
├── pass.png
├── person-plus.png
├── person.png
├── persons.png
├── plus-clean.png
├── plus.png
├── printer.png
├── reload.png
├── remove.png
├── report.png
├── sale.png
├── save.png
├── settings.png
├── supplier.png
├── tag-plus.png
├── twitter.png
└── user-profile.png
└── reports
├── employees_template.jrxml
├── products_template.jrxml
├── sales_template.jrxml
└── suppliers_template.jrxml
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.rb linguist-language=Java
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.ear
17 | *.zip
18 | *.tar.gz
19 | *.rar
20 | target/
21 | bin/
22 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ControleEstoque
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.common.project.facet.core.builder
10 |
11 |
12 |
13 |
14 | org.eclipse.jdt.core.javabuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.xtext.ui.shared.xtextBuilder
20 |
21 |
22 |
23 |
24 | org.springframework.ide.eclipse.core.springbuilder
25 |
26 |
27 |
28 |
29 | org.eclipse.m2e.core.maven2Builder
30 |
31 |
32 |
33 |
34 |
35 | org.springframework.ide.eclipse.core.springnature
36 | org.eclipse.m2e.core.maven2Nature
37 | org.eclipse.xtext.ui.shared.xtextNature
38 | org.eclipse.jdt.core.javanature
39 | org.eclipse.wst.common.project.facet.core.nature
40 |
41 |
42 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/main/resources=UTF-8
4 | encoding/=UTF-8
5 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.8
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
12 | org.eclipse.jdt.core.compiler.source=1.8
13 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.wst.common.project.facet.core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 |
3 | jdk:
4 | - oraclejdk8
5 |
6 | # git strips the wrapper jar file so we have to force its download during the build
7 | install:
8 | - mvn -N io.takari:maven:wrapper
9 |
10 | branches:
11 | only:
12 | - admin-javafx
13 |
--------------------------------------------------------------------------------
/Diagrama/class-diagram.asta:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tiagohs/spring-javafx-material-design-admin/248e8e5e01ba1092e16d4e102e6268ec8f2b3912/Diagrama/class-diagram.asta
--------------------------------------------------------------------------------
/Diagrama/class-diagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tiagohs/spring-javafx-material-design-admin/248e8e5e01ba1092e16d4e102e6268ec8f2b3912/Diagrama/class-diagram.png
--------------------------------------------------------------------------------
/bin/application/application.css:
--------------------------------------------------------------------------------
1 | /* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
--------------------------------------------------------------------------------
/build.fxbuild:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/db/adminDb.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tiagohs/spring-javafx-material-design-admin/248e8e5e01ba1092e16d4e102e6268ec8f2b3912/db/adminDb.db
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | ControleEstoque
4 | ControleEstoque
5 | 0.0.1-SNAPSHOT
6 | Controle de Estoque
7 |
8 |
9 | org.springframework.boot
10 | spring-boot-starter-parent
11 | 1.5.4.RELEASE
12 |
13 |
14 |
15 |
16 | UTF-8
17 | UTF-8
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-data-jpa
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-starter-validation
29 |
30 |
31 | com.h2database
32 | h2
33 | runtime
34 |
35 |
36 | org.hibernate
37 | hibernate-jpamodelgen
38 |
39 |
40 | com.enigmabridge
41 | hibernate4-sqlite-dialect
42 | 0.1.2
43 |
44 |
45 | io.datafx
46 | injection
47 | 8.0
48 |
49 |
50 | org.xerial
51 | sqlite-jdbc
52 | 3.19.3
53 |
54 |
55 | com.jfoenix
56 | jfoenix
57 | 1.6.0
58 |
59 |
60 | de.jensd
61 | fontawesomefx
62 | 8.9
63 |
64 |
65 | io.datafx
66 | flow
67 | 8.0.7
68 |
69 |
70 | io.datafx
71 | datafx
72 | 8.0.7
73 |
74 |
75 | org.apache.derby
76 | derbyclient
77 | 10.13.1.1
78 |
79 |
80 |
81 | com.lowagie
82 | itext
83 | 4.2.2
84 | pom
85 |
86 |
87 |
88 | net.sf.jasperreports
89 | jasperreports
90 | 6.4.0
91 |
92 |
93 | com.lowagie
94 | itext
95 |
96 |
97 | org.olap4j
98 | olap4j
99 |
100 |
101 |
102 |
103 | org.springframework.boot
104 |
105 | spring-boot-starter-cloud-connectors
106 |
107 |
108 |
109 | javax.inject
110 | javax.inject
111 | 1
112 |
113 |
114 | com.google.firebase
115 | firebase-admin
116 | 5.9.0
117 |
118 |
119 |
120 |
121 |
122 |
123 | org.springframework.boot
124 | spring-boot-maven-plugin
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/screens/apresentation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tiagohs/spring-javafx-material-design-admin/248e8e5e01ba1092e16d4e102e6268ec8f2b3912/screens/apresentation.png
--------------------------------------------------------------------------------
/screens/inventory-search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tiagohs/spring-javafx-material-design-admin/248e8e5e01ba1092e16d4e102e6268ec8f2b3912/screens/inventory-search.png
--------------------------------------------------------------------------------
/screens/new-employee.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tiagohs/spring-javafx-material-design-admin/248e8e5e01ba1092e16d4e102e6268ec8f2b3912/screens/new-employee.png
--------------------------------------------------------------------------------
/screens/new-product.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tiagohs/spring-javafx-material-design-admin/248e8e5e01ba1092e16d4e102e6268ec8f2b3912/screens/new-product.png
--------------------------------------------------------------------------------
/screens/painel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tiagohs/spring-javafx-material-design-admin/248e8e5e01ba1092e16d4e102e6268ec8f2b3912/screens/painel.png
--------------------------------------------------------------------------------
/screens/report-pdf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tiagohs/spring-javafx-material-design-admin/248e8e5e01ba1092e16d4e102e6268ec8f2b3912/screens/report-pdf.png
--------------------------------------------------------------------------------
/screens/reports.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tiagohs/spring-javafx-material-design-admin/248e8e5e01ba1092e16d4e102e6268ec8f2b3912/screens/reports.png
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs;
2 |
3 | import java.util.Locale;
4 |
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 | import org.springframework.context.ConfigurableApplicationContext;
8 |
9 | import com.tiagohs.controller.LoginController;
10 | import com.tiagohs.controller.RootController;
11 | import com.tiagohs.model.Language;
12 | import com.tiagohs.model.User;
13 | import com.tiagohs.service.LanguageService;
14 | import com.tiagohs.service.UserService;
15 | import com.tiagohs.util.I18N;
16 | import com.tiagohs.util.WindowsUtils;
17 |
18 | import javafx.application.Application;
19 | import javafx.application.HostServices;
20 | import javafx.stage.Stage;
21 |
22 | @SpringBootApplication
23 | public class MainApplication extends Application {
24 |
25 |
26 |
27 | public static ConfigurableApplicationContext springContext;
28 | public static I18N i18n;
29 | public static HostServices hostServices;
30 |
31 | private UserService userService;
32 | private LanguageService languageService;
33 |
34 | @Override
35 | public void init() throws Exception {
36 | springContext = SpringApplication.run(MainApplication.class);
37 | userService = springContext.getBean(UserService.class);
38 | languageService = springContext.getBean(LanguageService.class);
39 |
40 | initI18N();
41 | }
42 |
43 | private void initI18N() {
44 | Language languageDefault = languageService.findDefaultLanguage();
45 |
46 | if (languageDefault != null) {
47 | i18n = new I18N(new Locale(languageDefault.getLanguageCode(), languageDefault.getCountryCode()));
48 | } else {
49 | i18n = new I18N(I18N.PORTUGUESE_BRAZILLIAN);
50 | }
51 |
52 |
53 | }
54 |
55 | @Override
56 | public void start(Stage primaryStage) throws Exception {
57 | hostServices = this.getHostServices();
58 |
59 | userService.finUserSignIn(e -> {
60 | try {
61 | User user = (User) e.getSource().getValue();
62 |
63 | if (user == null) {
64 | WindowsUtils.openNewWindow(primaryStage, LoginController.PATH_FXML, i18n.getString(LoginController.LOGIN_TITLE_KEY), LoginController.PATH_ICON, null);
65 | } else {
66 | WindowsUtils.openNewWindow(primaryStage, RootController.PATH_FXML, i18n.getString(RootController.ROOT_TITLE_KEY), RootController.PATH_ICON, null);
67 | }
68 | } catch(Exception ex) {
69 | ex.printStackTrace();
70 | }
71 |
72 | }, null);
73 |
74 | }
75 |
76 | public static void main(String[] args) {
77 | launch(args);
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/SplashScreen.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs;
2 |
3 | import javafx.application.Preloader;
4 | import javafx.scene.Scene;
5 | import javafx.scene.layout.StackPane;
6 | import javafx.stage.Stage;
7 |
8 | public class SplashScreen extends Preloader {
9 |
10 | private Stage stage;
11 |
12 | @Override
13 | public void start(Stage stage) throws Exception {
14 | this.stage = stage;
15 |
16 | this.stage.setScene(createScene());
17 | this.stage.show();
18 | }
19 |
20 | private Scene createScene() {
21 | StackPane root = new StackPane();
22 | Scene scene = new Scene(root, 300, 200);
23 | return scene;
24 | }
25 |
26 | @Override
27 | public void handleApplicationNotification(PreloaderNotification notification) {
28 | if (notification instanceof StateChangeNotification) {
29 | stage.hide();
30 | }
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/controller/AboutController.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.controller;
2 |
3 | import java.util.HashMap;
4 |
5 | import org.springframework.stereotype.Controller;
6 |
7 | import com.tiagohs.MainApplication;
8 | import com.tiagohs.util.WindowsUtils;
9 |
10 | import javafx.fxml.FXML;
11 | import javafx.stage.Stage;
12 |
13 | @Controller
14 | public class AboutController extends BaseController {
15 |
16 | public static final String PATH_FXML = "/fxml/about.fxml";
17 | public static final String ABOUT_TITLE_KEY = "about.title";
18 | public static final String PATH_ICON = WindowsUtils.ICON_APP_PATH;
19 |
20 | public static final String FACCEBOOK_URL = "https://www.facebook.com/tiago.henrique.16";
21 | public static final String GITHUB_URL = "https://github.com/tiagohs";
22 | public static final String LINKEDIN_URL = "https://br.linkedin.com/in/tiago-henrique-395868b7";
23 | public static final String EMAIL_URL = "mailto:tiago.hsilva@al.infnet.edu.br";
24 |
25 | @Override
26 | public void init(Stage stage, HashMap parameters) {
27 | super.init(stage, parameters);
28 | }
29 |
30 | @Override
31 | protected void onClose() {
32 |
33 | }
34 |
35 | @FXML
36 | public void onFacebook() {
37 | MainApplication.hostServices.showDocument(FACCEBOOK_URL);
38 | }
39 |
40 | @FXML
41 | public void onGithub() {
42 | MainApplication.hostServices.showDocument(GITHUB_URL);
43 | }
44 |
45 | @FXML
46 | public void onEmail() {
47 | MainApplication.hostServices.showDocument(EMAIL_URL);
48 | }
49 |
50 | @FXML
51 | public void onLinkedin() {
52 | MainApplication.hostServices.showDocument(LINKEDIN_URL);
53 | }
54 |
55 | public void onOk() {
56 | stage.close();
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/controller/BaseController.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.controller;
2 |
3 | import java.util.HashMap;
4 |
5 | import com.tiagohs.MainApplication;
6 | import com.tiagohs.util.I18N;
7 |
8 | import javafx.stage.Stage;
9 |
10 | public abstract class BaseController {
11 |
12 | protected Stage stage;
13 | protected I18N i18N;
14 |
15 | public void init(Stage stage, HashMap parameters) {
16 | this.stage = stage;
17 | this.i18N = MainApplication.i18n;
18 |
19 | this.stage.setOnHiding(e -> { onClose(); });
20 | this.stage.setOnHidden(e -> { onClose(); });
21 | }
22 |
23 | public Stage getStage() {
24 | return stage;
25 | }
26 |
27 | public I18N getI18N() {
28 | return i18N;
29 | }
30 |
31 | public String getWindowTitle(String titleKey) {
32 | return MainApplication.i18n.getString(titleKey);
33 | }
34 |
35 | protected abstract void onClose();
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/controller/BrandNewController.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.controller;
2 |
3 | import java.util.HashMap;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Controller;
7 |
8 | import com.jfoenix.controls.JFXButton;
9 | import com.jfoenix.controls.JFXTextArea;
10 | import com.jfoenix.controls.JFXTextField;
11 | import com.tiagohs.model.Brand;
12 | import com.tiagohs.service.BrandService;
13 | import com.tiagohs.util.EntityFactory;
14 | import com.tiagohs.util.ValidatorUtils;
15 | import com.tiagohs.util.WindowsUtils;
16 |
17 | import javafx.fxml.FXML;
18 | import javafx.scene.layout.StackPane;
19 | import javafx.stage.Stage;
20 |
21 | @Controller
22 | public class BrandNewController extends BaseController {
23 |
24 | public static final String BRAND_KEY = "brand_key";
25 |
26 | public static final String PATH_FXML = "/fxml/new_brand.fxml";
27 | public static final String NEW_BRAND_TITLE_KEY = "new_brand.title";
28 | public static final String PATH_ICON = WindowsUtils.ICON_APP_PATH;
29 |
30 | @FXML
31 | private StackPane container;
32 |
33 | @FXML
34 | private JFXTextField nameTextField;
35 |
36 | @FXML
37 | private JFXTextField emailTextField;
38 |
39 | @FXML
40 | private JFXTextArea additionalInfoTextArea;
41 |
42 | @FXML
43 | private JFXButton saveButton;
44 |
45 | @Autowired
46 | private BrandService brandService;
47 |
48 | private Brand brand;
49 |
50 | @Override
51 | public void init(Stage stage, HashMap parameters) {
52 | super.init(stage, parameters);
53 |
54 | checkParameters(parameters);
55 | validateTextFields();
56 | watchEvents();
57 | }
58 |
59 | @Override
60 | protected void onClose() {
61 | brandService.onClose();
62 | }
63 |
64 | private void checkParameters( HashMap parameters) {
65 | if (parameters != null) {
66 | this.brand = (Brand) parameters.get(BRAND_KEY);
67 | updateTextFields();
68 | }
69 | }
70 |
71 | private void updateTextFields() {
72 |
73 | WindowsUtils.setTextInTextField(nameTextField, brand.getName());
74 | WindowsUtils.setTextInTextField(emailTextField, brand.getEmail());
75 | WindowsUtils.setTextInTextArea(additionalInfoTextArea, brand.getAdditionalInformation());
76 | }
77 |
78 | private void watchEvents() {
79 | WindowsUtils.watchEvents(nameTextField, v -> watch());
80 | WindowsUtils.watchEvents(emailTextField, v -> watch());
81 | }
82 |
83 | private void validateTextFields() {
84 | ValidatorUtils.addRequiredValidator(nameTextField, "Brand Name is Required!");
85 | ValidatorUtils.addRequiredValidator(emailTextField, "Email is Required!");
86 |
87 | ValidatorUtils.addEmailValidator(emailTextField, "Email does not match");
88 |
89 | WindowsUtils.validateTextField(nameTextField);
90 | WindowsUtils.validateTextField(emailTextField);
91 | }
92 |
93 | private void watch() {
94 | if (isRequiredTextFieldsFilled() && (emailTextField.validate())) {
95 | saveButton.setDisable(false);
96 | } else {
97 | saveButton.setDisable(true);
98 | }
99 |
100 | }
101 |
102 | private boolean isRequiredTextFieldsFilled() {
103 | return !WindowsUtils.isTextFieldEmpty(nameTextField) ||
104 | !WindowsUtils.isTextFieldEmpty(emailTextField);
105 | }
106 |
107 | @FXML
108 | public void onSave() {
109 |
110 | try {
111 | brandService.save(EntityFactory.createBrand(brand, WindowsUtils.getTextFromTextField(nameTextField),
112 | WindowsUtils.getTextFromTextField(emailTextField),
113 | WindowsUtils.getTextFromTextArea(additionalInfoTextArea)), e -> {
114 | WindowsUtils.createDefaultDialog(container, "Sucess", "Brand save with sucess.", () -> { stage.close(); });
115 | }, null);
116 | } catch (Exception e) {
117 | e.printStackTrace();
118 | WindowsUtils.createDefaultDialog(container, "Error", "Error saving brand, try again.", () -> {});
119 | }
120 | }
121 |
122 | @FXML
123 | public void onCancel() {
124 | stage.close();
125 | }
126 |
127 | @FXML
128 | public void onHelp() {
129 |
130 | }
131 |
132 | }
133 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/controller/DashboardController.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.controller;
2 |
3 | import java.text.ParseException;
4 | import java.text.SimpleDateFormat;
5 | import java.util.ArrayList;
6 | import java.util.Calendar;
7 | import java.util.HashMap;
8 | import java.util.List;
9 |
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.stereotype.Controller;
12 |
13 | import com.tiagohs.service.EmployeeService;
14 | import com.tiagohs.service.SaleService;
15 | import com.tiagohs.service.UserService;
16 | import com.tiagohs.util.WindowsUtils;
17 |
18 | import javafx.fxml.FXML;
19 | import javafx.scene.chart.LineChart;
20 | import javafx.scene.chart.XYChart;
21 | import javafx.scene.control.Label;
22 | import javafx.stage.Stage;
23 |
24 | @Controller
25 | public class DashboardController extends BaseController {
26 |
27 | public static final String PATH_FXML = "/fxml/dashboard.fxml";
28 | public static final String DASHBOARD_TITLE_KEY = "dashboard.title";
29 | public static final String PATH_ICON = WindowsUtils.ICON_APP_PATH;
30 |
31 | @FXML
32 | private LineChart salesChart;
33 |
34 | @FXML
35 | private Label usersLabel;
36 |
37 | @FXML
38 | private Label salesLabel;
39 |
40 | @FXML
41 | private Label employeesLabel;
42 |
43 | @Autowired
44 | private UserService userService;
45 |
46 | @Autowired
47 | private SaleService saleService;
48 |
49 | @Autowired
50 | private EmployeeService employeeService;
51 |
52 | @Override
53 | public void init(Stage stage, HashMap parameters) {
54 | super.init(stage, parameters);
55 |
56 | configureSalesChart();
57 | configureLabels();
58 | }
59 |
60 | @Override
61 | protected void onClose() {
62 | userService.onClose();
63 | saleService.onClose();
64 | employeeService.onClose();
65 | }
66 |
67 | @SuppressWarnings({ "unchecked", "rawtypes" })
68 | private void configureSalesChart() {
69 | SimpleDateFormat month = new SimpleDateFormat("MMM-yyyy");
70 |
71 | salesChart.getXAxis().setLabel(getI18N().getString("date.month"));
72 |
73 | XYChart.Series series = new XYChart.Series();
74 | series.setName(getI18N().getString("sales.pathTitle"));
75 |
76 | List allMonths = new ArrayList<>();
77 |
78 | try {
79 | allMonths = getLast12Months();
80 | } catch (ParseException e1) {
81 | }
82 |
83 |
84 |
85 | for (Calendar calendar : allMonths) {
86 | System.out.println(calendar.getTime().toString());
87 | System.out.println(saleService.getTotalSalesByMonth(calendar));
88 | series.getData().add(new XYChart.Data(month.format(calendar.getTime()), saleService.getTotalSalesByMonth(calendar)));
89 | }
90 |
91 | salesChart.getData().add(series);
92 | }
93 |
94 | private List getLast12Months() throws ParseException {
95 | List allDates = new ArrayList<>();
96 |
97 | Calendar cal = Calendar.getInstance();
98 | allDates.add(Calendar.getInstance());
99 |
100 | for (int i = 1; i <= 12; i++) {
101 | Calendar c = Calendar.getInstance();
102 | cal.add(Calendar.MONTH, -1);
103 | c.setTime(cal.getTime());
104 | allDates.add(c);
105 | }
106 |
107 | return reverse(allDates);
108 | }
109 |
110 | public List reverse(List list) {
111 | for(int i = 0, j = list.size() - 1; i < j; i++) {
112 | list.add(i, list.remove(j));
113 | }
114 |
115 | return list;
116 | }
117 |
118 | private void configureLabels() {
119 |
120 | userService.getTotalUsers(e -> {
121 | configureLabel(usersLabel, (Long) e.getSource().getValue());
122 | }, null);
123 |
124 | saleService.getTotalSales(e -> {
125 | configureLabel(salesLabel, (Long) e.getSource().getValue());
126 | }, null);
127 |
128 | employeeService.getTotalEmployees(e -> {
129 | configureLabel(employeesLabel, (Long) e.getSource().getValue());
130 | }, null);
131 | }
132 |
133 | private void configureLabel(Label label, long value) {
134 | WindowsUtils.setTextInLabel(label, String.valueOf(value));
135 | }
136 |
137 | }
138 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/controller/IItemBaseController.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.controller;
2 |
3 | public interface IItemBaseController {
4 |
5 | double getTotal();
6 | double getQuantity();
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/controller/LoginController.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.controller;
2 |
3 | import java.util.HashMap;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Controller;
7 |
8 | import com.jfoenix.controls.JFXButton;
9 | import com.jfoenix.controls.JFXCheckBox;
10 | import com.jfoenix.controls.JFXTextField;
11 | import com.tiagohs.model.User;
12 | import com.tiagohs.service.UserService;
13 | import com.tiagohs.util.ValidatorUtils;
14 | import com.tiagohs.util.WindowsUtils;
15 |
16 | import javafx.fxml.FXML;
17 | import javafx.scene.control.Label;
18 | import javafx.stage.Modality;
19 | import javafx.stage.Stage;
20 |
21 | @Controller
22 | public class LoginController extends BaseController {
23 |
24 | public static final String PATH_FXML = "/fxml/login.fxml";
25 | public static final String LOGIN_TITLE_KEY = "login.title";
26 | public static final String PATH_ICON = WindowsUtils.ICON_APP_PATH;
27 |
28 | @FXML
29 | private JFXTextField emailTextField;
30 |
31 | @FXML
32 | private JFXTextField passwordTextField;
33 |
34 | @FXML
35 | private JFXCheckBox rememberMeCheckBox;
36 |
37 | @FXML
38 | private JFXButton loginButton;
39 |
40 | @FXML
41 | private Label errorLabel;
42 |
43 | @Autowired
44 | private UserService userService;
45 |
46 | public void init(Stage stage, HashMap parameters) {
47 | super.init(stage, parameters);
48 |
49 | validateTextFields();
50 | watchEvents();
51 | }
52 |
53 | private void validateTextFields() {
54 |
55 | ValidatorUtils.addRequiredValidator(emailTextField, "E-mail is Required!");
56 | ValidatorUtils.addRequiredValidator(passwordTextField, "Password is Required!");
57 |
58 | ValidatorUtils.addEmailValidator(emailTextField, "Email does not match");
59 |
60 | WindowsUtils.validateTextField(emailTextField);
61 | WindowsUtils.validateTextField(passwordTextField);
62 | }
63 |
64 | private void watchEvents() {
65 | WindowsUtils.watchEvents(emailTextField, v -> watch());
66 | WindowsUtils.watchEvents(passwordTextField, v -> watch());
67 | }
68 |
69 | private void watch() {
70 | if (isRequiredTextFieldsFilled() && (passwordTextField.validate() && emailTextField.validate())) {
71 | loginButton.setDisable(false);
72 | } else {
73 | loginButton.setDisable(true);
74 | }
75 |
76 | }
77 |
78 | private boolean isRequiredTextFieldsFilled() {
79 | return !(WindowsUtils.isTextFieldEmpty(emailTextField)) &&
80 | !(WindowsUtils.isTextFieldEmpty(passwordTextField));
81 | }
82 |
83 | @Override
84 | protected void onClose() {
85 | userService.onClose();
86 | }
87 |
88 | @FXML
89 | public void onLogin() {
90 |
91 | userService.findByEmailAndPassword(WindowsUtils.getTextFromTextField(emailTextField),
92 | WindowsUtils.getTextFromTextField(passwordTextField),
93 | e -> {
94 | User user = (User) e.getSource().getValue();
95 |
96 | if (user != null) {
97 | onSucessLogin(user);
98 | } else {
99 | onErrorLogin();
100 | }
101 | }, null);
102 |
103 | }
104 |
105 | private void onSucessLogin(User user) {
106 | errorLabel.setVisible(false);
107 |
108 | userService.setUserAsSignin(user.getEmail(),
109 | user.getPassword(),
110 | e -> {
111 | try {
112 | WindowsUtils.openNewWindow(RootController.PATH_FXML, getWindowTitle(RootController.ROOT_TITLE_KEY), RootController.PATH_ICON, null, Modality.WINDOW_MODAL);
113 | stage.close();
114 | } catch (Exception e1) {
115 | e1.printStackTrace();
116 | }
117 |
118 | }, null);
119 |
120 | }
121 |
122 | private void onErrorLogin() {
123 | errorLabel.setVisible(true);
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/controller/LoginDialogController.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.controller;
2 |
3 | import org.springframework.stereotype.Controller;
4 |
5 | import com.tiagohs.util.WindowsUtils;
6 |
7 | import javafx.beans.value.ChangeListener;
8 | import javafx.beans.value.ObservableValue;
9 | import javafx.concurrent.Worker;
10 | import javafx.fxml.FXML;
11 | import javafx.scene.layout.AnchorPane;
12 | import javafx.scene.web.WebEngine;
13 | import javafx.scene.web.WebView;
14 |
15 | @Controller
16 | public class LoginDialogController extends BaseController {
17 |
18 | public static final String PATH_FXML = "/fxml/login_dialog.fxml";
19 | public static final String LOGIN_DIALOG_TITLE_KEY = "login_dialog.title";
20 | public static final String PATH_ICON = WindowsUtils.ICON_APP_PATH;
21 |
22 | private static String HTML_STRING = //
23 | ""//
24 | + " " //
25 | + " "//
31 | + " "//
32 | + " "//
33 | + " This is Html content
"//
34 | + " Enter Color: "//
35 | + " "//
36 | + " "//
37 | + " "//
38 | + " "//
39 | ;
40 |
41 | @FXML
42 | private WebView webView;
43 |
44 | @FXML
45 | private AnchorPane container;
46 |
47 | public void init(javafx.stage.Stage stage, java.util.HashMap parameters) {
48 | super.init(stage, parameters);
49 |
50 | System.out.println("indo");
51 | // Get WebEngine via WebView
52 |
53 | WebEngine webEngine = webView.getEngine();
54 |
55 | System.setProperty("http.proxyHost","proxy.inf.bndes.net");
56 | System.setProperty("http.proxyPort","8080");
57 | System.setProperty("https.proxyHost","proxy.inf.bndes.net");
58 | System.setProperty("https.proxyPort","8080");
59 |
60 | webEngine.load("https://google.com");
61 |
62 | webEngine.getLoadWorker().stateProperty().addListener(
63 | new ChangeListener() {
64 | public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) {
65 | System.out.println("webEngine result "+ newState.toString());
66 | }
67 | });
68 | };
69 |
70 | @Override
71 | protected void onClose() {
72 |
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/controller/RootController.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.controller;
2 |
3 | import java.util.HashMap;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Controller;
7 |
8 | import com.tiagohs.service.UserService;
9 | import com.tiagohs.util.WindowsUtils;
10 |
11 | import javafx.fxml.FXML;
12 | import javafx.scene.layout.AnchorPane;
13 | import javafx.stage.Modality;
14 | import javafx.stage.Stage;
15 |
16 |
17 | @Controller
18 | public class RootController extends BaseController {
19 |
20 | public static final String PATH_FXML = "/fxml/root.fxml";
21 | public static final String ROOT_TITLE_KEY = "root.title";
22 | public static final String PATH_ICON = WindowsUtils.ICON_APP_PATH;
23 |
24 | @FXML
25 | private AnchorPane rootPane;
26 |
27 | @Autowired
28 | private UserService userService;
29 |
30 | public void init(Stage stage, HashMap parameters) {
31 | super.init(stage, parameters);
32 |
33 | try {
34 | WindowsUtils.replaceFxmlOnWindow(rootPane, DashboardController.PATH_FXML, stage, null);
35 | } catch (Exception e) {
36 | e.printStackTrace();
37 | }
38 | }
39 |
40 | @Override
41 | protected void onClose() {
42 |
43 | }
44 |
45 | @FXML
46 | private void onInvetoryAction() throws Exception {
47 | WindowsUtils.replaceFxmlOnWindow(rootPane, InventoryController.PATH_FXML, stage, null);
48 | }
49 |
50 | @FXML
51 | private void onDashboardAction() throws Exception {
52 | WindowsUtils.replaceFxmlOnWindow(rootPane, DashboardController.PATH_FXML, stage, null);
53 | }
54 |
55 | @FXML
56 | private void onSalesAction() throws Exception {
57 | WindowsUtils.replaceFxmlOnWindow(rootPane, SalesController.PATH_FXML, stage, null);
58 | }
59 |
60 | @FXML
61 | private void onClientsAction() throws Exception {
62 | WindowsUtils.replaceFxmlOnWindow(rootPane, ClientsController.PATH_FXML, stage, null);
63 | }
64 |
65 | @FXML
66 | private void onReportsAction() throws Exception {
67 | WindowsUtils.replaceFxmlOnWindow(rootPane, ReportsController.PATH_FXML, stage, null);
68 | }
69 |
70 | @FXML
71 | private void onAbout() throws Exception {
72 | WindowsUtils.openNewWindow(AboutController.PATH_FXML, getWindowTitle(AboutController.ABOUT_TITLE_KEY), AboutController.PATH_ICON, null, Modality.APPLICATION_MODAL);
73 | }
74 |
75 | @FXML
76 | private void onSettings() throws Exception {
77 | WindowsUtils.openNewWindow(SettingsController.PATH_FXML, getWindowTitle(SettingsController.SETTINGS_TITLE_KEY), SettingsController.PATH_ICON, null, Modality.WINDOW_MODAL);
78 | stage.close();
79 | }
80 |
81 | @FXML
82 | private void onLogout() throws Exception {
83 |
84 | userService.setUserAsSignOut(e -> {
85 | try {
86 | WindowsUtils.openNewWindow(LoginController.PATH_FXML, getWindowTitle(LoginController.LOGIN_TITLE_KEY), LoginController.PATH_ICON, null, Modality.WINDOW_MODAL);
87 | onClose();
88 | } catch (Exception e1) {
89 | e1.printStackTrace();
90 | }
91 | }, null);
92 |
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/controller/SalesController.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.controller;
2 |
3 | import java.io.IOException;
4 | import java.util.HashMap;
5 | import java.util.List;
6 |
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.stereotype.Controller;
9 |
10 | import com.tiagohs.controller.SaleTableController.TypeSaleTable;
11 | import com.tiagohs.model.Sale;
12 | import com.tiagohs.service.SaleService;
13 | import com.tiagohs.util.WindowsUtils;
14 |
15 | import javafx.concurrent.Service;
16 | import javafx.concurrent.WorkerStateEvent;
17 | import javafx.event.EventHandler;
18 | import javafx.fxml.FXML;
19 | import javafx.fxml.FXMLLoader;
20 | import javafx.scene.Scene;
21 | import javafx.scene.layout.AnchorPane;
22 | import javafx.scene.layout.StackPane;
23 | import javafx.stage.Modality;
24 | import javafx.stage.Stage;
25 |
26 | @Controller
27 | public class SalesController extends BaseController {
28 |
29 | public static final String PATH_FXML = "/fxml/sales.fxml";
30 | public static final String SALES_TITLE_KEY = "sales.title";
31 | public static final String PATH_ICON = WindowsUtils.ICON_APP_PATH;
32 |
33 | @FXML
34 | private AnchorPane allContainer;
35 |
36 | @FXML
37 | private AnchorPane openContainer;
38 |
39 | @FXML
40 | private AnchorPane finalizedContainer;
41 |
42 | @Autowired
43 | private SaleService saleService;
44 |
45 | @Override
46 | public void init(Stage stage, HashMap parameters) {
47 | super.init(stage, parameters);
48 |
49 | allContainer.getChildren().add(createAllTable(TypeSaleTable.ALL));
50 | openContainer.getChildren().add(createAllTable(TypeSaleTable.OPEN));
51 | finalizedContainer.getChildren().add(createAllTable(TypeSaleTable.FINALIZED));
52 | }
53 |
54 | @Override
55 | protected void onClose() {
56 | saleService.onClose();
57 | }
58 |
59 | private StackPane createAllTable(TypeSaleTable type) {
60 | Scene scene = null;
61 |
62 | try {
63 | FXMLLoader loader = WindowsUtils.loadFxml("/fxml/sale_table.fxml");
64 | scene = new Scene(loader.load());
65 |
66 | SaleTableController controller = loader.getController();
67 | controller.init(type, this);
68 | } catch (IOException e) {
69 | e.printStackTrace();
70 | }
71 |
72 | return (StackPane) scene.lookup("#container");
73 | }
74 |
75 | public Service> getSales(TypeSaleTable type, EventHandler onSucess, EventHandler beforeStart) {
76 |
77 | switch(type) {
78 | case ALL:
79 | return saleService.findAll(onSucess, beforeStart);
80 | case FINALIZED:
81 | return saleService.findAllFinalizedSales(onSucess, beforeStart);
82 | case OPEN:
83 | return saleService.findAllOpenSales(onSucess, beforeStart);
84 | }
85 |
86 | return null;
87 | }
88 |
89 | @FXML
90 | public void onNewSale() throws Exception {
91 | WindowsUtils.openNewWindow(SalesNewController.PATH_FXML, getWindowTitle(SalesNewController.NEW_SALE_TITLE_KEY), SalesNewController.PATH_ICON, null, Modality.APPLICATION_MODAL);
92 | }
93 |
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/controller/SettingsController.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.controller;
2 |
3 | import java.util.HashMap;
4 | import java.util.Locale;
5 |
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Controller;
8 |
9 | import com.jfoenix.controls.JFXComboBox;
10 | import com.tiagohs.model.Language;
11 | import com.tiagohs.service.LanguageService;
12 | import com.tiagohs.util.WindowsUtils;
13 |
14 | import javafx.fxml.FXML;
15 | import javafx.scene.control.Button;
16 | import javafx.stage.Stage;
17 |
18 | @Controller
19 | public class SettingsController extends BaseController {
20 |
21 | public static final String PATH_FXML = "/fxml/settings.fxml";
22 | public static final String SETTINGS_TITLE_KEY = "settings.title";
23 | public static final String PATH_ICON = WindowsUtils.ICON_APP_PATH;
24 |
25 | @FXML
26 | private JFXComboBox languageComboBox;
27 |
28 | @FXML
29 | private Button saveButton;
30 |
31 | @Autowired
32 | private LanguageService languageService;
33 |
34 | private Language defaultLanguage;
35 |
36 | @Override
37 | public void init(Stage stage, HashMap parameters) {
38 | super.init(stage, parameters);
39 |
40 | fillComboBoxes();
41 | addDefaultLanguage();
42 | watchEvents();
43 | }
44 |
45 | private void addDefaultLanguage() {
46 | this.defaultLanguage = languageService.findDefaultLanguage();
47 |
48 | WindowsUtils.setSelectedComboBoxItem(languageComboBox, defaultLanguage);
49 | }
50 |
51 | private void fillComboBoxes() {
52 | WindowsUtils.addComboBoxItens(languageComboBox, languageService);
53 | }
54 |
55 | private void watchEvents() {
56 | WindowsUtils.onComboBoxItemSelected(languageComboBox, v -> watch(v));
57 | }
58 |
59 | private void watch(Language languageSelected) {
60 | if (languageSelected.equals(defaultLanguage)) {
61 | saveButton.setDisable(true);
62 | } else {
63 | saveButton.setDisable(false);
64 | }
65 |
66 | }
67 |
68 | @Override
69 | protected void onClose() {
70 | languageService.onClose();
71 |
72 | }
73 |
74 | @FXML
75 | public void onSave() {
76 |
77 | Language newLanguage = WindowsUtils.getSelectedComboBoxItem(languageComboBox);
78 |
79 | languageService.changeDefaultLanguage(newLanguage, e -> {
80 |
81 | getI18N().updateDefaultLocale(new Locale(newLanguage.getLanguageCode(), newLanguage.getCountryCode()));
82 | onOpenRootWindow();
83 |
84 | stage.close();
85 | }, null);
86 | }
87 |
88 | @FXML
89 | public void onCancel() {
90 | stage.close();
91 | onOpenRootWindow();
92 | }
93 |
94 | @FXML
95 | public void onHelp() {
96 |
97 | }
98 |
99 | private void onOpenRootWindow() {
100 | try {
101 | WindowsUtils.openNewWindow(RootController.PATH_FXML, getWindowTitle(RootController.ROOT_TITLE_KEY), RootController.PATH_ICON, null, null);
102 | } catch (Exception e1) {
103 | e1.printStackTrace();
104 | }
105 | }
106 |
107 |
108 | }
109 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/dialect/SQLiteDialectIdentityColumnSupport.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.dialect;
2 |
3 | import org.hibernate.dialect.Dialect;
4 | import org.hibernate.dialect.identity.IdentityColumnSupportImpl;
5 |
6 | public class SQLiteDialectIdentityColumnSupport extends IdentityColumnSupportImpl {
7 |
8 | public SQLiteDialectIdentityColumnSupport(Dialect dialect) {
9 | super(dialect);
10 | }
11 |
12 | @Override
13 | public boolean supportsIdentityColumns() {
14 | return true;
15 | }
16 |
17 | /*
18 | public boolean supportsInsertSelectIdentity() {
19 | return true; // As specified in NHibernate dialect
20 | }
21 | */
22 |
23 | @Override
24 | public boolean hasDataTypeInIdentityColumn() {
25 | // As specified in NHibernate dialect
26 | // FIXME true
27 | return false;
28 | }
29 |
30 | /*
31 | public String appendIdentitySelectToInsert(String insertString) {
32 | return new StringBuffer(insertString.length()+30). // As specified in NHibernate dialect
33 | append(insertString).
34 | append("; ").append(getIdentitySelectString()).
35 | toString();
36 | }
37 | */
38 |
39 | @Override
40 | public String getIdentitySelectString(String table, String column, int type) {
41 | return "select last_insert_rowid()";
42 | }
43 |
44 | @Override
45 | public String getIdentityColumnString(int type) {
46 | // return "integer primary key autoincrement";
47 | // FIXME "autoincrement"
48 | return "integer";
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/Address.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model;
2 |
3 | import javax.persistence.Column;
4 | import javax.persistence.Entity;
5 | import javax.persistence.GeneratedValue;
6 | import javax.persistence.GenerationType;
7 | import javax.persistence.Id;
8 | import javax.persistence.Table;
9 |
10 | @Entity
11 | @Table(name = "address")
12 | public class Address {
13 |
14 | @Id
15 | @GeneratedValue(strategy = GenerationType.AUTO)
16 | @Column(name = "address_id")
17 | private long id;
18 |
19 | @Column(name = "rua")
20 | private String street;
21 |
22 | @Column(name = "number")
23 | private int number;
24 |
25 | @Column(name = "complement")
26 | private String complement;
27 |
28 | @Column(name = "suburb")
29 | private String suburb;
30 |
31 | @Column(name = "city")
32 | private String city;
33 |
34 | @Column(name = "state")
35 | private String state;
36 |
37 | @Column(name = "country")
38 | private String country;
39 |
40 | @Column(name = "cep")
41 | private String cep;
42 |
43 | public long getId() {
44 | return id;
45 | }
46 |
47 | public void setId(long id) {
48 | this.id = id;
49 | }
50 |
51 | public String getStreet() {
52 | return street;
53 | }
54 |
55 | public void setStreet(String street) {
56 | this.street = street;
57 | }
58 |
59 | public int getNumber() {
60 | return number;
61 | }
62 |
63 | public void setNumber(int number) {
64 | this.number = number;
65 | }
66 |
67 | public String getComplement() {
68 | return complement;
69 | }
70 |
71 | public void setComplement(String complement) {
72 | this.complement = complement;
73 | }
74 |
75 | public String getSuburb() {
76 | return suburb;
77 | }
78 |
79 | public void setSuburb(String suburb) {
80 | this.suburb = suburb;
81 | }
82 |
83 | public String getCity() {
84 | return city;
85 | }
86 |
87 | public void setCity(String city) {
88 | this.city = city;
89 | }
90 |
91 | public String getState() {
92 | return state;
93 | }
94 |
95 | public void setState(String state) {
96 | this.state = state;
97 | }
98 |
99 | public String getCountry() {
100 | return country;
101 | }
102 |
103 | public void setCountry(String country) {
104 | this.country = country;
105 | }
106 |
107 | public String getCep() {
108 | return cep;
109 | }
110 |
111 | public void setCep(String cep) {
112 | this.cep = cep;
113 | }
114 |
115 |
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/Brand.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model;
2 |
3 | import java.util.List;
4 |
5 | import javax.persistence.CascadeType;
6 | import javax.persistence.Column;
7 | import javax.persistence.Entity;
8 | import javax.persistence.FetchType;
9 | import javax.persistence.GeneratedValue;
10 | import javax.persistence.GenerationType;
11 | import javax.persistence.Id;
12 | import javax.persistence.OneToMany;
13 | import javax.persistence.Table;
14 |
15 | @Entity
16 | @Table(name = "brand")
17 | public class Brand {
18 |
19 | @Id
20 | @GeneratedValue(strategy = GenerationType.AUTO)
21 | @Column(name = "brand_id")
22 | private long id;
23 |
24 | @Column(name = "name")
25 | private String name;
26 |
27 | @Column(name = "email")
28 | private String email;
29 |
30 | @Column(name = "additional_information")
31 | private String additionalInformation;
32 |
33 | @OneToMany(mappedBy = "brand", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
34 | private List products;
35 |
36 | public long getId() {
37 | return id;
38 | }
39 |
40 | public void setId(long id) {
41 | this.id = id;
42 | }
43 |
44 | public String getName() {
45 | return name;
46 | }
47 |
48 | public void setName(String name) {
49 | this.name = name;
50 | }
51 |
52 | public List getProducts() {
53 | return products;
54 | }
55 |
56 | public void setProducts(List products) {
57 | this.products = products;
58 | }
59 |
60 | public String getEmail() {
61 | return email;
62 | }
63 |
64 | public void setEmail(String email) {
65 | this.email = email;
66 | }
67 |
68 | public String getAdditionalInformation() {
69 | return additionalInformation;
70 | }
71 |
72 | public void setAdditionalInformation(String additionalInformation) {
73 | this.additionalInformation = additionalInformation;
74 | }
75 |
76 | @Override
77 | public String toString() {
78 | return getName();
79 | }
80 |
81 | @Override
82 | public boolean equals(Object obj) {
83 |
84 | if (obj instanceof Brand) {
85 | if (obj != null) {
86 | Brand brand = (Brand) obj;
87 | return brand.getId() == getId();
88 | }
89 | }
90 |
91 | return false;
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/Client.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model;
2 |
3 | import java.util.List;
4 |
5 | import javax.persistence.CascadeType;
6 | import javax.persistence.Column;
7 | import javax.persistence.Entity;
8 | import javax.persistence.FetchType;
9 | import javax.persistence.GeneratedValue;
10 | import javax.persistence.GenerationType;
11 | import javax.persistence.Id;
12 | import javax.persistence.ManyToOne;
13 | import javax.persistence.OneToMany;
14 | import javax.persistence.OneToOne;
15 | import javax.persistence.Table;
16 |
17 | @Entity
18 | @Table(name = "client")
19 | public class Client {
20 |
21 | @Id
22 | @GeneratedValue(strategy = GenerationType.AUTO)
23 | @Column(name = "client_id")
24 | private long id;
25 |
26 | @Column(name = "cpf")
27 | private String cpf;
28 |
29 | @ManyToOne(fetch = FetchType.LAZY)
30 | private ClientType clientType;
31 |
32 | @OneToOne(optional = true, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
33 | private Address address;
34 |
35 | @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
36 | private List phones;
37 |
38 | @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
39 | private User user;
40 |
41 | public long getId() {
42 | return id;
43 | }
44 |
45 | public void setId(long id) {
46 | this.id = id;
47 | }
48 |
49 | public ClientType getClientType() {
50 | return clientType;
51 | }
52 |
53 | public void setClientType(ClientType clientType) {
54 | this.clientType = clientType;
55 | }
56 |
57 |
58 | public Address getAddress() {
59 | return address;
60 | }
61 |
62 | public void setAddress(Address address) {
63 | this.address = address;
64 | }
65 |
66 | public List getPhones() {
67 | return phones;
68 | }
69 |
70 | public void setPhones(List phones) {
71 | this.phones = phones;
72 | }
73 |
74 | public String getCpf() {
75 | return cpf;
76 | }
77 |
78 | public void setCpf(String cpf) {
79 | this.cpf = cpf;
80 | }
81 |
82 | public User getUser() {
83 | return user;
84 | }
85 |
86 | public void setUser(User user) {
87 | this.user = user;
88 | }
89 |
90 | @Override
91 | public String toString() {
92 | return getUser() != null ? getUser().getName() : getCpf();
93 | }
94 |
95 | @Override
96 | public boolean equals(Object obj) {
97 |
98 | if (obj instanceof Client) {
99 | if (obj != null) {
100 | Client client = (Client) obj;
101 | return client.getId() == getId();
102 | }
103 | }
104 |
105 | return false;
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/ClientType.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model;
2 |
3 | import java.util.List;
4 |
5 | import javax.persistence.Column;
6 | import javax.persistence.Entity;
7 | import javax.persistence.FetchType;
8 | import javax.persistence.GeneratedValue;
9 | import javax.persistence.GenerationType;
10 | import javax.persistence.Id;
11 | import javax.persistence.OneToMany;
12 | import javax.persistence.Table;
13 |
14 | @Entity
15 | @Table(name = "client_type")
16 | public class ClientType {
17 | @Id
18 | @GeneratedValue(strategy = GenerationType.AUTO)
19 | @Column(name = "client_type_id")
20 | private long id;
21 |
22 | @Column(name = "name")
23 | private String name;
24 |
25 | @OneToMany(mappedBy = "clientType", fetch = FetchType.LAZY)
26 | private List clients;
27 |
28 | public ClientType() {
29 | }
30 |
31 | public ClientType(long id, String name) {
32 | super();
33 | this.id = id;
34 | this.name = name;
35 | }
36 |
37 | public long getId() {
38 | return id;
39 | }
40 |
41 | public void setId(long id) {
42 | this.id = id;
43 | }
44 |
45 | public String getName() {
46 | return name;
47 | }
48 |
49 | public void setName(String name) {
50 | this.name = name;
51 | }
52 |
53 | public List getClients() {
54 | return clients;
55 | }
56 |
57 | public void setClients(List clients) {
58 | this.clients = clients;
59 | }
60 |
61 | @Override
62 | public String toString() {
63 | return getName();
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/Employee.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model;
2 |
3 | import java.util.List;
4 |
5 | import javax.persistence.CascadeType;
6 | import javax.persistence.Column;
7 | import javax.persistence.Entity;
8 | import javax.persistence.FetchType;
9 | import javax.persistence.GeneratedValue;
10 | import javax.persistence.GenerationType;
11 | import javax.persistence.Id;
12 | import javax.persistence.OneToMany;
13 | import javax.persistence.OneToOne;
14 | import javax.persistence.Table;
15 |
16 | @Entity
17 | @Table(name = "employee")
18 | public class Employee {
19 |
20 | @Id
21 | @GeneratedValue(strategy = GenerationType.AUTO)
22 | @Column(name = "employee_id")
23 | private long id;
24 |
25 | @Column(name = "cpf")
26 | private String cpf;
27 |
28 | @OneToOne(optional = true, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
29 | private Address address;
30 |
31 | @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
32 | private List phones;
33 |
34 | @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
35 | private User user;
36 |
37 | public long getId() {
38 | return id;
39 | }
40 |
41 | public void setId(long id) {
42 | this.id = id;
43 | }
44 |
45 | public String getCpf() {
46 | return cpf;
47 | }
48 |
49 | public void setCpf(String cpf) {
50 | this.cpf = cpf;
51 | }
52 |
53 | public Address getAddres() {
54 | return address;
55 | }
56 |
57 | public void setAddres(Address addres) {
58 | this.address = addres;
59 | }
60 |
61 | public List getFones() {
62 | return phones;
63 | }
64 |
65 | public void setFones(List fones) {
66 | this.phones = fones;
67 | }
68 |
69 | public User getUser() {
70 | return user;
71 | }
72 |
73 | public void setUser(User user) {
74 | this.user = user;
75 | }
76 |
77 | @Override
78 | public String toString() {
79 | if (getUser() != null) {
80 | return getUser().getName();
81 | } else {
82 | return getCpf();
83 | }
84 | }
85 |
86 | @Override
87 | public boolean equals(Object obj) {
88 |
89 | if (obj instanceof Employee) {
90 | if (obj != null) {
91 | Employee employee = (Employee) obj;
92 | return employee.getId() == getId();
93 | }
94 | }
95 |
96 | return false;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/Fone.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model;
2 |
3 | import javax.persistence.Column;
4 | import javax.persistence.Entity;
5 | import javax.persistence.GeneratedValue;
6 | import javax.persistence.GenerationType;
7 | import javax.persistence.Id;
8 | import javax.persistence.ManyToOne;
9 | import javax.persistence.Table;
10 |
11 | @Entity
12 | @Table(name = "fone")
13 | public class Fone {
14 |
15 | @Id
16 | @GeneratedValue(strategy = GenerationType.AUTO)
17 | @Column(name = "fone_id")
18 | private long id;
19 |
20 | @Column(name = "code")
21 | private int code;
22 |
23 | @Column(name = "number")
24 | private long number;
25 |
26 | @ManyToOne
27 | private Employee employee;
28 |
29 | @ManyToOne
30 | private Client client;
31 |
32 | public long getId() {
33 | return id;
34 | }
35 |
36 | public void setId(long id) {
37 | this.id = id;
38 | }
39 |
40 | public int getCode() {
41 | return code;
42 | }
43 |
44 | public void setCode(int code) {
45 | this.code = code;
46 | }
47 |
48 | public long getNumber() {
49 | return number;
50 | }
51 |
52 | public void setNumber(long number) {
53 | this.number = number;
54 | }
55 |
56 | public Employee getEmployee() {
57 | return employee;
58 | }
59 |
60 | public void setEmployee(Employee employee) {
61 | this.employee = employee;
62 | }
63 |
64 |
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/Image.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model;
2 |
3 | import javax.persistence.Column;
4 | import javax.persistence.Entity;
5 | import javax.persistence.GeneratedValue;
6 | import javax.persistence.GenerationType;
7 | import javax.persistence.Id;
8 | import javax.persistence.ManyToOne;
9 | import javax.persistence.Table;
10 |
11 | @Entity
12 | @Table(name = "image")
13 | public class Image {
14 |
15 | @Id
16 | @GeneratedValue(strategy = GenerationType.AUTO)
17 | @Column(name = "image_id")
18 | private long id;
19 |
20 | @Column(name = "path")
21 | private String path;
22 |
23 | @ManyToOne
24 | private Product product;
25 |
26 | public long getId() {
27 | return id;
28 | }
29 |
30 | public void setId(long id) {
31 | this.id = id;
32 | }
33 |
34 | public String getPath() {
35 | return path;
36 | }
37 |
38 | public void setPath(String path) {
39 | this.path = path;
40 | }
41 |
42 | public Product getProduct() {
43 | return product;
44 | }
45 |
46 | public void setProduct(Product product) {
47 | this.product = product;
48 | }
49 |
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/Item.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model;
2 |
3 | import javax.persistence.CascadeType;
4 | import javax.persistence.Column;
5 | import javax.persistence.Entity;
6 | import javax.persistence.FetchType;
7 | import javax.persistence.GeneratedValue;
8 | import javax.persistence.GenerationType;
9 | import javax.persistence.Id;
10 | import javax.persistence.OneToOne;
11 | import javax.persistence.Table;
12 |
13 | @Entity
14 | @Table(name = "item")
15 | public class Item {
16 |
17 | @Id
18 | @GeneratedValue(strategy = GenerationType.AUTO)
19 | @Column(name = "item_id")
20 | private long id;
21 |
22 | @Column(name = "total_price")
23 | private double totalPrice;
24 |
25 | @Column(name = "quantity")
26 | private int quantity;
27 |
28 | @Column(name = "discount")
29 | private double discount;
30 |
31 | @Column(name = "tax")
32 | private double tax;
33 |
34 | @OneToOne(optional = true, fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
35 | private Product product;
36 |
37 | public long getId() {
38 | return id;
39 | }
40 |
41 | public void setId(long id) {
42 | this.id = id;
43 | }
44 |
45 | public double getTotalPrice() {
46 | return totalPrice;
47 | }
48 |
49 | public void setTotalPrice(double totalPrice) {
50 | this.totalPrice = totalPrice;
51 | }
52 |
53 | public double getDiscount() {
54 | return discount;
55 | }
56 |
57 | public void setDiscount(double discount) {
58 | this.discount = discount;
59 | }
60 |
61 | public double getTax() {
62 | return tax;
63 | }
64 |
65 | public void setTax(double tax) {
66 | this.tax = tax;
67 | }
68 |
69 | public Product getProduct() {
70 | return product;
71 | }
72 |
73 | public void setProduct(Product product) {
74 | this.product = product;
75 | }
76 |
77 | public int getQuantity() {
78 | return quantity;
79 | }
80 |
81 | public void setQuantity(int quantity) {
82 | this.quantity = quantity;
83 | }
84 |
85 |
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/Language.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model;
2 |
3 | import javax.persistence.Column;
4 | import javax.persistence.Entity;
5 | import javax.persistence.GeneratedValue;
6 | import javax.persistence.GenerationType;
7 | import javax.persistence.Id;
8 | import javax.persistence.Table;
9 |
10 | import org.hibernate.annotations.Type;
11 |
12 | @Entity
13 | @Table(name = "language")
14 | public class Language {
15 |
16 | @Id
17 | @GeneratedValue(strategy = GenerationType.AUTO)
18 | @Column(name = "language_id")
19 | private long id;
20 |
21 | @Column(name = "language_name")
22 | private String languageName;
23 |
24 | @Column(name = "language_code")
25 | private String languageCode;
26 |
27 | @Column(name = "country_code")
28 | private String countryCode;
29 |
30 | @Column(name = "is_default")
31 | @Type(type="true_false")
32 | private boolean isDefault;
33 |
34 | public long getId() {
35 | return id;
36 | }
37 |
38 | public void setId(long id) {
39 | this.id = id;
40 | }
41 |
42 | public String getLanguageName() {
43 | return languageName;
44 | }
45 |
46 | public void setLanguageName(String languageName) {
47 | this.languageName = languageName;
48 | }
49 |
50 | public String getLanguageCode() {
51 | return languageCode;
52 | }
53 |
54 | public void setLanguageCode(String languageCode) {
55 | this.languageCode = languageCode;
56 | }
57 |
58 | public boolean isDefault() {
59 | return isDefault;
60 | }
61 |
62 | public void setDefault(boolean isDefault) {
63 | this.isDefault = isDefault;
64 | }
65 |
66 | public String getCountryCode() {
67 | return countryCode;
68 | }
69 |
70 | public void setCountryCode(String countryCode) {
71 | this.countryCode = countryCode;
72 | }
73 |
74 | @Override
75 | public boolean equals(Object obj) {
76 |
77 | if (obj instanceof Language) {
78 | if (obj != null) {
79 | Language language = (Language) obj;
80 | return language.getId() == getId();
81 | }
82 | }
83 |
84 | return false;
85 | }
86 |
87 | @Override
88 | public String toString() {
89 | return getLanguageName();
90 | }
91 |
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/ProductType.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model;
2 |
3 | import java.util.List;
4 |
5 | import javax.persistence.Column;
6 | import javax.persistence.Entity;
7 | import javax.persistence.FetchType;
8 | import javax.persistence.GeneratedValue;
9 | import javax.persistence.GenerationType;
10 | import javax.persistence.Id;
11 | import javax.persistence.OneToMany;
12 | import javax.persistence.Table;
13 |
14 | @Entity
15 | @Table(name = "product_type")
16 | public class ProductType {
17 |
18 | @Id
19 | @GeneratedValue(strategy = GenerationType.AUTO)
20 | @Column(name = "addres_id")
21 | private long id;
22 |
23 | @Column(name = "name")
24 | private String name;
25 |
26 | @OneToMany(mappedBy = "productType", fetch = FetchType.LAZY)
27 | private List product;
28 |
29 | public long getId() {
30 | return id;
31 | }
32 |
33 | public void setId(long id) {
34 | this.id = id;
35 | }
36 |
37 | public String getName() {
38 | return name;
39 | }
40 |
41 | public void setName(String name) {
42 | this.name = name;
43 | }
44 |
45 | public List getProduct() {
46 | return product;
47 | }
48 |
49 | public void setProduct(List product) {
50 | this.product = product;
51 | }
52 |
53 | @Override
54 | public String toString() {
55 | return getName();
56 | }
57 |
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/Role.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model;
2 |
3 | import javax.persistence.Column;
4 | import javax.persistence.Entity;
5 | import javax.persistence.GeneratedValue;
6 | import javax.persistence.GenerationType;
7 | import javax.persistence.Id;
8 | import javax.persistence.Table;
9 |
10 | @Entity
11 | @Table(name = "role")
12 | public class Role {
13 |
14 | @Id
15 | @GeneratedValue(strategy = GenerationType.AUTO)
16 | @Column(name="role_id")
17 | private long id;
18 |
19 | @Column(name="role", unique = true)
20 | private String role;
21 |
22 | @Column(name="name")
23 | private String name;
24 |
25 | public long getId() {
26 | return id;
27 | }
28 | public void setId(long id) {
29 | this.id = id;
30 | }
31 | public String getRole() {
32 | return role;
33 | }
34 | public void setRole(String role) {
35 | this.role = role;
36 | }
37 | public String getName() {
38 | return name;
39 | }
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 |
44 | @Override
45 | public String toString() {
46 | return getName();
47 | }
48 |
49 | @Override
50 | public boolean equals(Object obj) {
51 |
52 | if (obj instanceof Role) {
53 | if (obj != null) {
54 | Role role = (Role) obj;
55 | return role.getId() == getId();
56 | }
57 | }
58 |
59 | return false;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/Supplier.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model;
2 |
3 | import java.util.List;
4 |
5 | import javax.persistence.CascadeType;
6 | import javax.persistence.Column;
7 | import javax.persistence.Entity;
8 | import javax.persistence.FetchType;
9 | import javax.persistence.GeneratedValue;
10 | import javax.persistence.GenerationType;
11 | import javax.persistence.Id;
12 | import javax.persistence.OneToMany;
13 | import javax.persistence.OneToOne;
14 | import javax.persistence.Table;
15 |
16 | @Entity
17 | @Table(name = "supplier")
18 | public class Supplier {
19 |
20 | @Id
21 | @GeneratedValue(strategy = GenerationType.AUTO)
22 | @Column(name = "supplier_id")
23 | private long id;
24 |
25 | @Column(name = "company_name")
26 | private String companyName;
27 |
28 | @Column(name = "email")
29 | private String email;
30 |
31 | @OneToOne(optional = true, fetch = FetchType.LAZY, cascade=CascadeType.ALL)
32 | private Address addres;
33 |
34 | @OneToMany(mappedBy = "supplier", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
35 | private List products;
36 |
37 |
38 | public long getId() {
39 | return id;
40 | }
41 |
42 | public void setId(long id) {
43 | this.id = id;
44 | }
45 |
46 | public String getCompanyName() {
47 | return companyName;
48 | }
49 |
50 | public void setCompanyName(String companyName) {
51 | this.companyName = companyName;
52 | }
53 |
54 | public String getEmail() {
55 | return email;
56 | }
57 |
58 | public void setEmail(String email) {
59 | this.email = email;
60 | }
61 |
62 | public Address getAddres() {
63 | return addres;
64 | }
65 |
66 | public void setAddres(Address addres) {
67 | this.addres = addres;
68 | }
69 |
70 | public List getProducts() {
71 | return products;
72 | }
73 |
74 | public void setProducts(List products) {
75 | this.products = products;
76 | }
77 |
78 | @Override
79 | public String toString() {
80 | return getCompanyName();
81 | }
82 |
83 | @Override
84 | public boolean equals(Object obj) {
85 |
86 | if (obj instanceof Supplier) {
87 | if (obj != null) {
88 | Supplier supplier = (Supplier) obj;
89 | return supplier.getId() == getId();
90 | }
91 | }
92 |
93 | return false;
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/Tag.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model;
2 |
3 | import java.util.List;
4 |
5 | import javax.persistence.Column;
6 | import javax.persistence.Entity;
7 | import javax.persistence.GeneratedValue;
8 | import javax.persistence.GenerationType;
9 | import javax.persistence.Id;
10 | import javax.persistence.ManyToMany;
11 | import javax.persistence.Table;
12 |
13 | @Entity
14 | @Table(name = "tag")
15 | public class Tag {
16 |
17 | @Id
18 | @GeneratedValue(strategy = GenerationType.AUTO)
19 | @Column(name = "tag_id")
20 | private long id;
21 |
22 | @Column(name = "name")
23 | private String name;
24 |
25 | @ManyToMany(mappedBy = "tags")
26 | private List products;
27 |
28 | @ManyToMany(mappedBy = "tags")
29 | private List sales;
30 |
31 | public long getId() {
32 | return id;
33 | }
34 |
35 | public void setId(long id) {
36 | this.id = id;
37 | }
38 |
39 | public String getName() {
40 | return name;
41 | }
42 |
43 | public void setName(String name) {
44 | this.name = name;
45 | }
46 |
47 | public List getProducts() {
48 | return products;
49 | }
50 |
51 | public void setProducts(List products) {
52 | this.products = products;
53 | }
54 |
55 | public List getSales() {
56 | return sales;
57 | }
58 |
59 | public void setSales(List sales) {
60 | this.sales = sales;
61 | }
62 |
63 | @Override
64 | public boolean equals(Object obj) {
65 |
66 | if (obj instanceof Tag) {
67 | if (obj != null) {
68 | Tag tag = (Tag) obj;
69 | return tag.getId() == getId();
70 | }
71 | }
72 |
73 | return false;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/User.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model;
2 |
3 | import java.util.List;
4 |
5 | import javax.persistence.CascadeType;
6 | import javax.persistence.Column;
7 | import javax.persistence.Entity;
8 | import javax.persistence.GeneratedValue;
9 | import javax.persistence.GenerationType;
10 | import javax.persistence.Id;
11 | import javax.persistence.JoinColumn;
12 | import javax.persistence.JoinTable;
13 | import javax.persistence.ManyToMany;
14 | import javax.persistence.Table;
15 |
16 | @Entity
17 | @Table(name = "user")
18 | public class User {
19 |
20 | @Id
21 | @GeneratedValue(strategy = GenerationType.AUTO)
22 | @Column(name = "user_id")
23 | private int id;
24 |
25 | @Column(name = "email", unique = true)
26 | private String email;
27 |
28 | @Column(name = "name")
29 | private String name;
30 |
31 | @Column(name = "photo_path")
32 | private String photoPath;
33 |
34 | @Column(name = "password")
35 | private String password;
36 |
37 | @Column(name = "is_login")
38 | private int isLogin;
39 |
40 | @ManyToMany(cascade = CascadeType.MERGE)
41 | @JoinTable(name = "user_role",
42 | joinColumns = @JoinColumn(name = "user_id"),
43 | inverseJoinColumns = @JoinColumn(name = "role_id"))
44 | private List roles;
45 |
46 | public int getId() {
47 | return id;
48 | }
49 |
50 | public void setId(int id) {
51 | this.id = id;
52 | }
53 |
54 | public String getEmail() {
55 | return email;
56 | }
57 |
58 | public void setEmail(String email) {
59 | this.email = email;
60 | }
61 |
62 | public String getPassword() {
63 | return password;
64 | }
65 |
66 | public void setPassword(String password) {
67 | this.password = password;
68 | }
69 |
70 | public List getRoles() {
71 | return roles;
72 | }
73 |
74 | public void setRoles(List roles) {
75 | this.roles = roles;
76 | }
77 |
78 | public String getName() {
79 | return name;
80 | }
81 |
82 | public void setName(String name) {
83 | this.name = name;
84 | }
85 |
86 | public String getPhotoPath() {
87 | return photoPath;
88 | }
89 |
90 | public void setPhotoPath(String photoPath) {
91 | this.photoPath = photoPath;
92 | }
93 |
94 | public int getIsLogin() {
95 | return isLogin;
96 | }
97 |
98 | public void setIsLogin(int isLogin) {
99 | this.isLogin = isLogin;
100 | }
101 |
102 | @Override
103 | public String toString() {
104 | return getName();
105 | }
106 |
107 | @Override
108 | public boolean equals(Object obj) {
109 |
110 | if (obj instanceof User) {
111 | if (obj != null) {
112 | User user = (User) obj;
113 | return user.getId() == getId();
114 | }
115 | }
116 |
117 | return false;
118 | }
119 |
120 | }
121 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/dto/BrandTableDTO.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model.dto;
2 |
3 | import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject;
4 | import com.tiagohs.model.Brand;
5 |
6 | import javafx.beans.property.SimpleStringProperty;
7 | import javafx.beans.property.StringProperty;
8 |
9 | public class BrandTableDTO extends RecursiveTreeObject {
10 |
11 | private StringProperty name;
12 | private StringProperty email;
13 | private StringProperty additionalInformation;
14 | private Brand originalBrand;
15 |
16 | public StringProperty getName() {
17 | return name;
18 | }
19 | public void setName(StringProperty name) {
20 | this.name = name;
21 | }
22 | public void setName(String name) {
23 | this.name = new SimpleStringProperty(name);
24 | }
25 | public StringProperty getEmail() {
26 | return email;
27 | }
28 | public void setEmail(StringProperty email) {
29 | this.email = email;
30 | }
31 | public void setEmail(String email) {
32 | this.email = new SimpleStringProperty(email);
33 | }
34 | public StringProperty getAdditionalInformation() {
35 | return additionalInformation;
36 | }
37 | public void setAdditionalInformation(StringProperty additionalInformation) {
38 | this.additionalInformation = additionalInformation;
39 | }
40 | public void setAdditionalInformation(String additionalInformation) {
41 | this.additionalInformation = new SimpleStringProperty(additionalInformation);
42 | }
43 | public Brand getOriginalBrand() {
44 | return originalBrand;
45 | }
46 | public void setOriginalBrand(Brand originalBrand) {
47 | this.originalBrand = originalBrand;
48 | }
49 |
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/dto/ClientTableDTO.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model.dto;
2 |
3 | import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject;
4 | import com.tiagohs.model.Address;
5 | import com.tiagohs.model.Client;
6 |
7 | import javafx.beans.property.SimpleStringProperty;
8 | import javafx.beans.property.StringProperty;
9 |
10 | public class ClientTableDTO extends RecursiveTreeObject{
11 |
12 | private StringProperty name;
13 | private StringProperty email;
14 | private StringProperty address;
15 | private StringProperty fone;
16 | private StringProperty numOrders;
17 | private StringProperty type;
18 | private Client originalClient;
19 |
20 | public StringProperty getName() {
21 | return name;
22 | }
23 | public void setName(StringProperty name) {
24 | this.name = name;
25 | }
26 | public void setName(String name) {
27 | this.name = new SimpleStringProperty(name);
28 | }
29 | public StringProperty getEmail() {
30 | return email;
31 | }
32 | public void setEmail(StringProperty email) {
33 | this.email = email;
34 | }
35 | public void setEmail(String email) {
36 | this.email = new SimpleStringProperty(email);
37 | }
38 | public StringProperty getAddress() {
39 | return address;
40 | }
41 | public void setAddress(StringProperty address) {
42 | this.address = address;
43 | }
44 | public void setAddress(String address) {
45 | this.address = new SimpleStringProperty(address);
46 | }
47 | public void setAddress(Address address) {
48 | this.address = new SimpleStringProperty(address.getStreet() + " - " + address.getNumber());
49 | }
50 | public StringProperty getFone() {
51 | return fone;
52 | }
53 | public void setFone(StringProperty fone) {
54 | this.fone = fone;
55 | }
56 | public void setFone(String fone) {
57 | this.fone = new SimpleStringProperty(fone);
58 | }
59 | public StringProperty getNumOrders() {
60 | return numOrders;
61 | }
62 | public void setNumOrders(StringProperty numOrders) {
63 | this.numOrders = numOrders;
64 | }
65 | public void setNumOrders(String numOrders) {
66 | this.numOrders = new SimpleStringProperty(numOrders);
67 | }
68 | public StringProperty getType() {
69 | return type;
70 | }
71 | public void setType(StringProperty type) {
72 | this.type = type;
73 | }
74 | public void setType(String type) {
75 | this.type = new SimpleStringProperty(type);
76 | }
77 | public Client getOriginalClient() {
78 | return originalClient;
79 | }
80 | public void setOriginalClient(Client originalClient) {
81 | this.originalClient = originalClient;
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/dto/EmployeeReportDTO.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model.dto;
2 |
3 | public class EmployeeReportDTO {
4 |
5 | private String name;
6 | private String email;
7 | private String cpf;
8 | private String adress;
9 |
10 | public String getName() {
11 | return name;
12 | }
13 | public void setName(String name) {
14 | this.name = name;
15 | }
16 | public String getEmail() {
17 | return email;
18 | }
19 | public void setEmail(String email) {
20 | this.email = email;
21 | }
22 | public String getCpf() {
23 | return cpf;
24 | }
25 | public void setCpf(String cpf) {
26 | this.cpf = cpf;
27 | }
28 | public String getAdress() {
29 | return adress;
30 | }
31 | public void setAdress(String adress) {
32 | this.adress = adress;
33 | }
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/dto/EmployeeTableDTO.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model.dto;
2 |
3 | import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject;
4 | import com.tiagohs.model.Address;
5 | import com.tiagohs.model.Employee;
6 | import com.tiagohs.util.WindowsUtils;
7 |
8 | import javafx.beans.property.SimpleStringProperty;
9 | import javafx.beans.property.StringProperty;
10 |
11 | public class EmployeeTableDTO extends RecursiveTreeObject {
12 |
13 | private StringProperty name;
14 | private StringProperty email;
15 | private StringProperty cpf;
16 | private StringProperty adress;
17 | private Employee originalEmployee;
18 |
19 | public StringProperty getName() {
20 | return name;
21 | }
22 |
23 | public void setName(StringProperty name) {
24 | this.name = name;
25 | }
26 |
27 | public void setName(String name) {
28 | this.name = new SimpleStringProperty(name);
29 | }
30 |
31 | public StringProperty getEmail() {
32 | return email;
33 | }
34 |
35 | public void setEmail(StringProperty email) {
36 | this.email = email;
37 | }
38 |
39 | public void setEmail(String email) {
40 | this.email = new SimpleStringProperty(email);
41 | }
42 |
43 | public StringProperty getCpf() {
44 | return cpf;
45 | }
46 |
47 | public void setCpf(StringProperty cpf) {
48 | this.cpf = cpf;
49 | }
50 |
51 | public void setCpf(String cpf) {
52 | this.cpf = new SimpleStringProperty(WindowsUtils.formatCPF(cpf));
53 | }
54 |
55 | public StringProperty getAdress() {
56 | return adress;
57 | }
58 |
59 | public void setAdress(StringProperty adress) {
60 | this.adress = adress;
61 | }
62 |
63 | public void setAdress(String adress) {
64 | this.adress = new SimpleStringProperty(adress);
65 | }
66 |
67 | public void setAdress(Address adress) {
68 | this.adress = new SimpleStringProperty(adress.getStreet() + " " + adress.getNumber());
69 | }
70 |
71 | public Employee getOriginalEmployee() {
72 | return originalEmployee;
73 | }
74 |
75 | public void setOriginalEmployee(Employee originalEmployee) {
76 | this.originalEmployee = originalEmployee;
77 | }
78 |
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/dto/ProductReportDTO.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model.dto;
2 |
3 | public class ProductReportDTO {
4 |
5 | private String sku;
6 | private String supplier;
7 | private String buyPrice;
8 | private String productType;
9 | private String description;
10 |
11 | public String getSku() {
12 | return sku;
13 | }
14 | public void setSku(String sku) {
15 | this.sku = sku;
16 | }
17 | public String getSupplier() {
18 | return supplier;
19 | }
20 | public void setSupplier(String supplier) {
21 | this.supplier = supplier;
22 | }
23 | public String getBuyPrice() {
24 | return buyPrice;
25 | }
26 | public void setBuyPrice(String buyPrice) {
27 | this.buyPrice = buyPrice;
28 | }
29 | public String getProductType() {
30 | return productType;
31 | }
32 | public void setProductType(String productType) {
33 | this.productType = productType;
34 | }
35 | public String getDescription() {
36 | return description;
37 | }
38 | public void setDescription(String description) {
39 | this.description = description;
40 | }
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/dto/ProductTableDTO.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model.dto;
2 |
3 | import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject;
4 | import com.tiagohs.model.Product;
5 |
6 | import javafx.beans.property.SimpleStringProperty;
7 | import javafx.beans.property.StringProperty;
8 |
9 | public class ProductTableDTO extends RecursiveTreeObject {
10 |
11 | private StringProperty sku;
12 | private StringProperty supplier;
13 | private StringProperty buyPrice;
14 | private StringProperty productType;
15 | private StringProperty description;
16 | private Product originalProduct;
17 |
18 | public ProductTableDTO(String sku, String supplier, double buyPrice,
19 | String productType, String description, Product originalProduct) {
20 | this.sku = new SimpleStringProperty(sku);
21 | this.supplier = new SimpleStringProperty(supplier);
22 | this.buyPrice = new SimpleStringProperty(Double.toString(buyPrice));
23 | this.productType = new SimpleStringProperty(productType);
24 | this.description = new SimpleStringProperty(description);
25 | this.originalProduct = originalProduct;
26 | }
27 |
28 | public ProductTableDTO() {
29 |
30 | }
31 |
32 | public StringProperty getSku() {
33 | return sku;
34 | }
35 |
36 | public void setSku(StringProperty sku) {
37 | this.sku = sku;
38 | }
39 |
40 | public void setSku(String sku) {
41 | this.sku = new SimpleStringProperty(sku);
42 | }
43 |
44 | public StringProperty getSupplier() {
45 | return supplier;
46 | }
47 |
48 | public void setSupplier(StringProperty supplier) {
49 | this.supplier = supplier;
50 | }
51 |
52 | public void setSupplier(String supplier) {
53 | this.supplier = new SimpleStringProperty(supplier);
54 | }
55 |
56 | public StringProperty getBuyPrice() {
57 | return buyPrice;
58 | }
59 |
60 | public void setBuyPrice(StringProperty buyPrice) {
61 | this.buyPrice = buyPrice;
62 | }
63 |
64 | public void setBuyPrice(double buyPrice) {
65 | this.buyPrice = new SimpleStringProperty(Double.toString(buyPrice));
66 | }
67 |
68 | public StringProperty getProductType() {
69 | return productType;
70 | }
71 |
72 | public void setProductType(StringProperty productType) {
73 | this.productType = productType;
74 | }
75 |
76 | public void setProductType(String productType) {
77 | this.productType = new SimpleStringProperty(productType);
78 | }
79 |
80 | public StringProperty getDescription() {
81 | return description;
82 | }
83 |
84 | public void setDescription(StringProperty description) {
85 | this.description = description;
86 | }
87 |
88 | public void setDescription(String description) {
89 | this.description = new SimpleStringProperty(description);
90 | }
91 |
92 | public Product getOriginalProduct() {
93 | return originalProduct;
94 | }
95 |
96 | public void setOriginalProduct(Product originalProduct) {
97 | this.originalProduct = originalProduct;
98 | }
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/dto/SalesReportDTO.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model.dto;
2 |
3 | public class SalesReportDTO {
4 |
5 | private String code;
6 | private String shipmentDate;
7 | private String issueDate;
8 | private String client;
9 | private String totalUnits;
10 | private String total;
11 |
12 | public String getCode() {
13 | return code;
14 | }
15 | public void setCode(String code) {
16 | this.code = code;
17 | }
18 | public String getShipmentDate() {
19 | return shipmentDate;
20 | }
21 | public void setShipmentDate(String shipmentDate) {
22 | this.shipmentDate = shipmentDate;
23 | }
24 | public String getIssueDate() {
25 | return issueDate;
26 | }
27 | public void setIssueDate(String issueDate) {
28 | this.issueDate = issueDate;
29 | }
30 | public String getClient() {
31 | return client;
32 | }
33 | public void setClient(String client) {
34 | this.client = client;
35 | }
36 | public String getTotalUnits() {
37 | return totalUnits;
38 | }
39 | public void setTotalUnits(String totalUnits) {
40 | this.totalUnits = totalUnits;
41 | }
42 | public String getTotal() {
43 | return total;
44 | }
45 | public void setTotal(String total) {
46 | this.total = total;
47 | }
48 |
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/dto/SalesTableDTO.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model.dto;
2 |
3 | import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject;
4 | import com.tiagohs.model.Sale;
5 |
6 | import javafx.beans.property.SimpleStringProperty;
7 | import javafx.beans.property.StringProperty;
8 |
9 | public class SalesTableDTO extends RecursiveTreeObject {
10 |
11 | private StringProperty code;
12 | private StringProperty shipmentDate;
13 | private StringProperty issueDate;
14 | private StringProperty client;
15 | private StringProperty totalUnits;
16 | private StringProperty total;
17 | private Sale originalObject;
18 |
19 | public StringProperty getCode() {
20 | return code;
21 | }
22 | public void setCode(StringProperty code) {
23 | this.code = code;
24 | }
25 | public void setCode(String code) {
26 | this.code = new SimpleStringProperty(code);
27 | }
28 | public StringProperty getShipmentDate() {
29 | return shipmentDate;
30 | }
31 | public void setShipmentDate(StringProperty shipmentDate) {
32 | this.shipmentDate = shipmentDate;
33 | }
34 | public void setShipmentDate(String shipmentDate) {
35 | this.shipmentDate = new SimpleStringProperty(shipmentDate);
36 | }
37 | public StringProperty getIssueDate() {
38 | return issueDate;
39 | }
40 | public void setIssueDate(StringProperty issueDate) {
41 | this.issueDate = issueDate;
42 | }
43 | public void setIssueDate(String issueDate) {
44 | this.issueDate = new SimpleStringProperty(issueDate);
45 | }
46 | public StringProperty getClient() {
47 | return client;
48 | }
49 | public void setClient(StringProperty client) {
50 | this.client = client;
51 | }
52 | public void setClient(String client) {
53 | this.client = new SimpleStringProperty(client);
54 | }
55 | public StringProperty getTotalUnits() {
56 | return totalUnits;
57 | }
58 | public void setTotalUnits(StringProperty totalUnits) {
59 | this.totalUnits = totalUnits;
60 | }
61 | public void setTotalUnits(double totalUnits) {
62 | this.totalUnits = new SimpleStringProperty(String.valueOf(totalUnits));;
63 | }
64 | public void setTotalUnits(String totalUnits) {
65 | this.totalUnits = new SimpleStringProperty(totalUnits);
66 | }
67 | public StringProperty getTotal() {
68 | return total;
69 | }
70 | public void setTotal(StringProperty total) {
71 | this.total = total;
72 | }
73 | public void setTotal(String total) {
74 | this.total = new SimpleStringProperty(total);
75 | }
76 | public void setTotal(double total) {
77 | this.total = new SimpleStringProperty(String.valueOf(total));
78 | }
79 | public void setFormattedTotal(double total) {
80 | this.total = new SimpleStringProperty(String.format("R$ %.2f", total));
81 | }
82 | public Sale getOriginalObject() {
83 | return originalObject;
84 | }
85 | public void setOriginalObject(Sale originalObject) {
86 | this.originalObject = originalObject;
87 | }
88 |
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/dto/SupplierReportDTO.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model.dto;
2 |
3 | public class SupplierReportDTO {
4 |
5 | private String companyName;
6 | private String email;
7 | private String adress;
8 |
9 | public String getCompanyName() {
10 | return companyName;
11 | }
12 | public void setCompanyName(String companyName) {
13 | this.companyName = companyName;
14 | }
15 | public String getEmail() {
16 | return email;
17 | }
18 | public void setEmail(String email) {
19 | this.email = email;
20 | }
21 | public String getAdress() {
22 | return adress;
23 | }
24 | public void setAdress(String adress) {
25 | this.adress = adress;
26 | }
27 |
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/model/dto/SupplierTableDTO.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.model.dto;
2 |
3 | import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject;
4 | import com.tiagohs.model.Address;
5 | import com.tiagohs.model.Supplier;
6 |
7 | import javafx.beans.property.SimpleStringProperty;
8 | import javafx.beans.property.StringProperty;
9 |
10 | public class SupplierTableDTO extends RecursiveTreeObject {
11 |
12 | private StringProperty companyName;
13 | private StringProperty email;
14 | private StringProperty adress;
15 | private Supplier originalSupplier;
16 |
17 | public SupplierTableDTO(String companyName, String email, Address adress, Supplier originalSupplier) {
18 | this.companyName = new SimpleStringProperty(companyName);
19 | this.email = new SimpleStringProperty(email);
20 | this.adress = new SimpleStringProperty(adress.getStreet() + " " + adress.getNumber());
21 | this.originalSupplier = originalSupplier;
22 | }
23 |
24 | public SupplierTableDTO() {
25 | }
26 |
27 | public StringProperty getCompanyName() {
28 | return companyName;
29 | }
30 | public void setCompanyName(StringProperty companyName) {
31 | this.companyName = companyName;
32 | }
33 | public void setCompanyName(String companyName) {
34 | this.companyName = new SimpleStringProperty(companyName);
35 | }
36 | public StringProperty getEmail() {
37 | return email;
38 | }
39 | public void setEmail(StringProperty email) {
40 | this.email = email;
41 | }
42 | public void setEmail(String email) {
43 | this.email = new SimpleStringProperty(email);
44 | }
45 | public StringProperty getAdress() {
46 | return adress;
47 | }
48 | public void setAdress(StringProperty adress) {
49 | this.adress = adress;
50 | }
51 | public void setAdress(String adress) {
52 | this.adress = new SimpleStringProperty(adress);
53 | }
54 | public void setAdress(Address adress) {
55 | this.adress = new SimpleStringProperty(adress.getStreet() + " " + adress.getNumber());
56 | }
57 |
58 | public Supplier getOriginalSupplier() {
59 | return originalSupplier;
60 | }
61 |
62 | public void setOriginalSupplier(Supplier originalSupplier) {
63 | this.originalSupplier = originalSupplier;
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/repository/BrandRepository.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 | import org.springframework.stereotype.Repository;
5 |
6 | import com.tiagohs.model.Brand;
7 |
8 | @Repository("brandRepository")
9 | public interface BrandRepository extends JpaRepository {
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/repository/ClientRepository.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 | import org.springframework.data.jpa.repository.Query;
5 | import org.springframework.stereotype.Repository;
6 |
7 | import com.tiagohs.model.Client;
8 |
9 | @Repository("clientRepository")
10 | public interface ClientRepository extends JpaRepository {
11 |
12 | @Query("SELECT COUNT(c) FROM Client c")
13 | Long getTotalClients();
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/repository/EmployeeRepository.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 | import org.springframework.data.jpa.repository.Query;
5 | import org.springframework.stereotype.Repository;
6 |
7 | import com.tiagohs.model.Employee;
8 |
9 | @Repository("employeeRepository")
10 | public interface EmployeeRepository extends JpaRepository {
11 |
12 | @Query("SELECT COUNT(e) FROM Employee e")
13 | Long getTotalEmployees();
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/repository/LanguageRepository.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 | import org.springframework.data.jpa.repository.Modifying;
5 | import org.springframework.data.jpa.repository.Query;
6 | import org.springframework.data.repository.query.Param;
7 | import org.springframework.stereotype.Repository;
8 | import org.springframework.transaction.annotation.Transactional;
9 |
10 | import com.tiagohs.model.Language;
11 |
12 | @Repository("languageRepository")
13 | public interface LanguageRepository extends JpaRepository {
14 |
15 | @Query("SELECT l FROM Language l WHERE l.isDefault = 'true'")
16 | Language findDefaultLanguage();
17 |
18 | @Modifying(clearAutomatically = true)
19 | @Transactional
20 | @Query("UPDATE Language SET isDefault = 'false' WHERE isDefault = 'true'")
21 | void cleanLanguageDefault();
22 |
23 | @Modifying(clearAutomatically = true)
24 | @Transactional
25 | @Query("UPDATE Language SET isDefault = 'true' WHERE language_code = :language_code AND country_code = :country_code")
26 | void setLanguageAsDefault(@Param("language_code") String language, @Param("country_code") String country);
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/repository/ProductRepository.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 | import org.springframework.stereotype.Repository;
5 |
6 | import com.tiagohs.model.Product;
7 |
8 | @Repository("productRepository")
9 | public interface ProductRepository extends JpaRepository {
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/repository/ProductTypeRepository.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 | import org.springframework.stereotype.Repository;
5 |
6 | import com.tiagohs.model.ProductType;
7 |
8 | @Repository("productTypeRepository")
9 | public interface ProductTypeRepository extends JpaRepository{
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/repository/RoleRepository.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.repository;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.data.jpa.repository.JpaRepository;
6 | import org.springframework.stereotype.Repository;
7 |
8 | import com.tiagohs.model.Role;
9 |
10 | @Repository("roleRepository")
11 | public interface RoleRepository extends JpaRepository {
12 |
13 | List findByRole(String role);
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/repository/SaleRepository.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.repository;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.data.jpa.repository.JpaRepository;
6 | import org.springframework.data.jpa.repository.Query;
7 | import org.springframework.data.repository.query.Param;
8 |
9 | import com.tiagohs.model.Sale;
10 |
11 | public interface SaleRepository extends JpaRepository {
12 |
13 | @Query("SELECT s FROM Sale s WHERE LOWER(s.state) = LOWER('open')")
14 | List findAllOpenSales();
15 |
16 | @Query("SELECT s FROM Sale s WHERE LOWER(s.state) = LOWER('finalized')")
17 | List findAllFinalizedSales();
18 |
19 | @Query("SELECT COUNT(s) FROM Sale s")
20 | Long getTotalSales();
21 |
22 | @Query("SELECT s FROM Sale s WHERE strftime('%m-%Y', s.issueDate) = :month")
23 | List findSalesByMonth(@Param("month") String month);
24 |
25 | @Query("SELECT COUNT(s) FROM Sale s WHERE strftime('%m-%Y', s.issueDate) = :month")
26 | Long getTotalSalesByMonth(@Param("month") String month);
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/repository/SupplierRepository.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 | import org.springframework.data.jpa.repository.Query;
5 | import org.springframework.stereotype.Repository;
6 |
7 | import com.tiagohs.model.Supplier;
8 |
9 | @Repository("supplierRepository")
10 | public interface SupplierRepository extends JpaRepository {
11 |
12 | @Query("SELECT COUNT(s) FROM Supplier s")
13 | Long getTotalSuppliers();
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/repository/UserRepository.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 | import org.springframework.data.jpa.repository.Modifying;
5 | import org.springframework.data.jpa.repository.Query;
6 | import org.springframework.data.repository.query.Param;
7 | import org.springframework.stereotype.Repository;
8 | import org.springframework.transaction.annotation.Transactional;
9 |
10 | import com.tiagohs.model.User;
11 |
12 | @Repository("userRepository")
13 | public interface UserRepository extends JpaRepository {
14 |
15 | @Query("SELECT COUNT(u) FROM User u")
16 | Long getTotalUsers();
17 |
18 | @Query("SELECT u FROM User u where u.isLogin = 'True'")
19 | User finUserSignIn();
20 |
21 | @Modifying(clearAutomatically = true)
22 | @Transactional
23 | @Query("UPDATE User SET isLogin = 'True' where email =:email and password = :password")
24 | void setUserAsSignIn(@Param("email") String email, @Param("password") String password);
25 |
26 | @Modifying(clearAutomatically = true)
27 | @Transactional
28 | @Query("UPDATE User SET isLogin = 'False' where isLogin = 'True'")
29 | void setUserAsSignOut();
30 |
31 | User findByEmail(String email);
32 | User findByEmailAndPassword(String email, String password);
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/BaseCrudService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.data.jpa.repository.JpaRepository;
6 |
7 | import javafx.concurrent.Service;
8 | import javafx.concurrent.Task;
9 | import javafx.concurrent.WorkerStateEvent;
10 | import javafx.event.EventHandler;
11 |
12 | public abstract class BaseCrudService> extends BaseService {
13 |
14 | private R repository;
15 |
16 | public BaseCrudService(R repository) {
17 | this.repository = repository;
18 |
19 | }
20 |
21 | public Service save(T obj, EventHandler onSucess, EventHandler beforeStart) throws Exception {
22 |
23 | if (obj == null) {
24 | throw new Exception();
25 | }
26 |
27 | return createService(new Task() {
28 | protected T call() throws Exception {
29 | return repository.save(obj);
30 | };
31 | }, onSucess, beforeStart);
32 |
33 | }
34 |
35 | public Service> findAll(EventHandler onSucess, EventHandler beforeStart) {
36 | return createService(new Task>() {
37 | protected List call() throws Exception {
38 | return repository.findAll();
39 | };
40 | }, onSucess, beforeStart);
41 | }
42 |
43 |
44 | public Service delete(long id, EventHandler onSucess, EventHandler beforeStart) throws Exception {
45 | return createService(new Task() {
46 | protected Void call() throws Exception {
47 | repository.delete(id);
48 | return null;
49 | };
50 | }, onSucess, beforeStart);
51 |
52 | }
53 |
54 |
55 | public Service find(long id, EventHandler onSucess, EventHandler beforeStart) throws Exception {
56 | return createService(new Task() {
57 | protected T call() throws Exception {
58 | return repository.findOne(id);
59 | };
60 | }, onSucess, beforeStart);
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/BaseService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import javafx.concurrent.Service;
7 | import javafx.concurrent.Task;
8 | import javafx.concurrent.WorkerStateEvent;
9 | import javafx.event.EventHandler;
10 |
11 | public abstract class BaseService {
12 |
13 | private List> services;
14 |
15 | public BaseService() {
16 | this.services = new ArrayList>();
17 | }
18 |
19 | protected Service createService(Task task, EventHandler onSucess, EventHandler beforeStart) {
20 | Service service = new Service() {
21 | protected Task createTask() {
22 | return task;
23 | }
24 | };
25 |
26 | if (onSucess != null)
27 | service.setOnSucceeded(onSucess);
28 |
29 | if (beforeStart != null)
30 | service.setOnScheduled(beforeStart);
31 |
32 | service.setOnFailed(e -> {
33 | System.out.println("Failed: " + e.getSource().getException());
34 | });
35 |
36 | service.start();
37 |
38 | services.add(service);
39 |
40 | return service;
41 | }
42 |
43 | public void onClose() {
44 |
45 | for (Service> service : services) {
46 | service.cancel();
47 | }
48 |
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/BrandService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import org.springframework.stereotype.Repository;
4 |
5 | import com.tiagohs.model.Brand;
6 |
7 | @Repository("brandService")
8 | public interface BrandService extends IBaseService {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/BrandServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.stereotype.Service;
6 |
7 | import com.tiagohs.model.Brand;
8 | import com.tiagohs.repository.BrandRepository;
9 |
10 | @Service("brandService")
11 | public class BrandServiceImpl extends BaseCrudService> implements BrandService {
12 |
13 | private BrandRepository brandRepository;
14 |
15 | @Autowired
16 | public BrandServiceImpl(BrandRepository brandRepository) {
17 | super(brandRepository);
18 |
19 | this.brandRepository = brandRepository;
20 | }
21 |
22 | public BrandRepository getBrandRepository() {
23 | return brandRepository;
24 | }
25 |
26 | public void setBrandRepository(BrandRepository brandRepository) {
27 | this.brandRepository = brandRepository;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/ClientService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import com.tiagohs.model.Client;
4 |
5 | import javafx.concurrent.WorkerStateEvent;
6 | import javafx.event.EventHandler;
7 |
8 | public interface ClientService extends IBaseService {
9 |
10 | javafx.concurrent.Service getTotalClients(EventHandler onSucess, EventHandler beforeStart);
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/ClientServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 | import org.springframework.stereotype.Service;
5 |
6 | import com.tiagohs.model.Client;
7 | import com.tiagohs.repository.ClientRepository;
8 |
9 | import javafx.concurrent.Task;
10 | import javafx.concurrent.WorkerStateEvent;
11 | import javafx.event.EventHandler;
12 |
13 | @Service("clientService")
14 | public class ClientServiceImpl extends BaseCrudService> implements ClientService {
15 |
16 | private ClientRepository clientReporitory;
17 |
18 | public ClientServiceImpl(ClientRepository repository) {
19 | super(repository);
20 |
21 | this.clientReporitory = repository;
22 | }
23 |
24 | public ClientRepository getClientReporitory() {
25 | return clientReporitory;
26 | }
27 |
28 | public void setClientReporitory(ClientRepository clientReporitory) {
29 | this.clientReporitory = clientReporitory;
30 | }
31 |
32 | @Override
33 | public javafx.concurrent.Service getTotalClients(EventHandler onSucess, EventHandler beforeStart) {
34 | return createService(new Task() {
35 | protected Long call() throws Exception {
36 | return clientReporitory.getTotalClients();
37 | };
38 | }, onSucess, beforeStart);
39 | }
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/EmployeeService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import com.tiagohs.model.Employee;
4 |
5 | import javafx.concurrent.WorkerStateEvent;
6 | import javafx.event.EventHandler;
7 |
8 | public interface EmployeeService extends IBaseService {
9 |
10 | javafx.concurrent.Service getTotalEmployees(EventHandler onSucess, EventHandler beforeStart);
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/EmployeeServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.stereotype.Service;
6 |
7 | import com.tiagohs.model.Employee;
8 | import com.tiagohs.repository.EmployeeRepository;
9 |
10 | import javafx.concurrent.Task;
11 | import javafx.concurrent.WorkerStateEvent;
12 | import javafx.event.EventHandler;
13 |
14 | @Service("employeeService")
15 | public class EmployeeServiceImpl extends BaseCrudService> implements EmployeeService {
16 |
17 | private EmployeeRepository employeeRepository;
18 |
19 | @Autowired
20 | public EmployeeServiceImpl(EmployeeRepository repository) {
21 | super(repository);
22 |
23 | this.employeeRepository = repository;
24 | }
25 |
26 | public EmployeeRepository getEmployeeRepository() {
27 | return employeeRepository;
28 | }
29 |
30 | public void setEmployeeRepository(EmployeeRepository employeeRepository) {
31 | this.employeeRepository = employeeRepository;
32 | }
33 |
34 | @Override
35 | public javafx.concurrent.Service getTotalEmployees(EventHandler onSucess, EventHandler beforeStart) {
36 | return createService(new Task() {
37 | protected Long call() throws Exception {
38 | return employeeRepository.getTotalEmployees();
39 | };
40 | }, onSucess, beforeStart);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/IBaseService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import java.util.List;
4 |
5 | import javafx.concurrent.Service;
6 | import javafx.concurrent.WorkerStateEvent;
7 | import javafx.event.EventHandler;
8 |
9 | public interface IBaseService {
10 | public Service save(T obj, EventHandler onSucess, EventHandler beforeStart) throws Exception;
11 | public Service> findAll(EventHandler onSucess, EventHandler beforeStart);
12 | public Service delete(long id, EventHandler onSucess, EventHandler beforeStart) throws Exception;
13 | public Service find(long id, EventHandler onSucess, EventHandler beforeStart) throws Exception;
14 |
15 | public void onClose();
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/LanguageService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import com.tiagohs.model.Language;
4 |
5 | import javafx.concurrent.Service;
6 | import javafx.concurrent.WorkerStateEvent;
7 | import javafx.event.EventHandler;
8 |
9 | public interface LanguageService extends IBaseService {
10 |
11 | Service changeDefaultLanguage(Language newDafaultLanguage, EventHandler onSucess, EventHandler beforeStart);
12 |
13 | Service findDefaultLanguage(EventHandler onSucess, EventHandler beforeStart);
14 | Language findDefaultLanguage();
15 |
16 | Service cleanLanguageDefault(EventHandler onSucess, EventHandler beforeStart);
17 |
18 | Service setLanguageAsDefault(String language, String country, EventHandler onSucess, EventHandler beforeStart);
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/LanguageServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 | import org.springframework.stereotype.Service;
5 |
6 | import com.tiagohs.model.Language;
7 | import com.tiagohs.repository.LanguageRepository;
8 |
9 | import javafx.concurrent.Task;
10 | import javafx.concurrent.WorkerStateEvent;
11 | import javafx.event.EventHandler;
12 |
13 | @Service("languageService")
14 | public class LanguageServiceImpl extends BaseCrudService> implements LanguageService {
15 |
16 | private LanguageRepository languageRepository;
17 |
18 | public LanguageServiceImpl(LanguageRepository repository) {
19 | super(repository);
20 |
21 | this.languageRepository = repository;
22 | }
23 |
24 | public LanguageRepository getLanguageRepository() {
25 | return languageRepository;
26 | }
27 |
28 | public void setLanguageRepository(LanguageRepository languageRepository) {
29 | this.languageRepository = languageRepository;
30 | }
31 |
32 | @Override
33 | public javafx.concurrent.Service findDefaultLanguage(EventHandler onSucess,
34 | EventHandler beforeStart) {
35 | return createService(new Task() {
36 | protected Language call() throws Exception {
37 | return findDefaultLanguage();
38 | };
39 | }, onSucess, beforeStart);
40 | }
41 |
42 | @Override
43 | public Language findDefaultLanguage() {
44 | return languageRepository.findDefaultLanguage();
45 | }
46 |
47 | @Override
48 | public javafx.concurrent.Service cleanLanguageDefault(EventHandler onSucess,
49 | EventHandler beforeStart) {
50 | return createService(new Task() {
51 | protected Void call() throws Exception {
52 | languageRepository.cleanLanguageDefault();
53 |
54 | return null;
55 | };
56 | }, onSucess, beforeStart);
57 | }
58 |
59 | @Override
60 | public javafx.concurrent.Service setLanguageAsDefault(String language, String country,
61 | EventHandler onSucess, EventHandler beforeStart) {
62 | return createService(new Task() {
63 | protected Void call() throws Exception {
64 | languageRepository.setLanguageAsDefault(language, country);
65 |
66 | return null;
67 | };
68 | }, onSucess, beforeStart);
69 | }
70 |
71 | @Override
72 | public javafx.concurrent.Service changeDefaultLanguage(Language newDafaultLanguage, EventHandler onSucess,
73 | EventHandler beforeStart) {
74 | return createService(new Task() {
75 | protected Language call() throws Exception {
76 |
77 | languageRepository.cleanLanguageDefault();
78 | languageRepository.setLanguageAsDefault(newDafaultLanguage.getLanguageCode(), newDafaultLanguage.getCountryCode());
79 |
80 | return null;
81 | };
82 | }, onSucess, beforeStart);
83 | }
84 |
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/ProductService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import com.tiagohs.model.Product;
4 |
5 | public interface ProductService extends IBaseService {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/ProductServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.stereotype.Service;
6 |
7 | import com.tiagohs.model.Product;
8 | import com.tiagohs.repository.ProductRepository;
9 |
10 | @Service("productService")
11 | public class ProductServiceImpl extends BaseCrudService> implements ProductService {
12 |
13 | private ProductRepository productRepository;
14 |
15 | @Autowired
16 | public ProductServiceImpl(ProductRepository productRepository) {
17 | super(productRepository);
18 |
19 | this.productRepository = productRepository;
20 | }
21 |
22 | public ProductRepository getProductRepository() {
23 | return productRepository;
24 | }
25 |
26 | public void setProductRepository(ProductRepository productRepository) {
27 | this.productRepository = productRepository;
28 | }
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/ProductTypeService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import com.tiagohs.model.ProductType;
4 |
5 | public interface ProductTypeService extends IBaseService {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/ProductTypeServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.stereotype.Service;
6 |
7 | import com.tiagohs.model.ProductType;
8 | import com.tiagohs.repository.ProductTypeRepository;
9 |
10 | @Service("productTypeService")
11 | public class ProductTypeServiceImpl extends BaseCrudService> implements ProductTypeService {
12 |
13 | private ProductTypeRepository productTypeRepository;
14 |
15 | @Autowired
16 | public ProductTypeServiceImpl(ProductTypeRepository repository) {
17 | super(repository);
18 |
19 | this.productTypeRepository = repository;
20 | }
21 |
22 | public ProductTypeRepository getProductTypeRepository() {
23 | return productTypeRepository;
24 | }
25 |
26 | public void setProductTypeRepository(ProductTypeRepository productTypeRepository) {
27 | this.productTypeRepository = productTypeRepository;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/ReportsService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import java.util.List;
4 |
5 | import javafx.concurrent.Service;
6 | import javafx.concurrent.WorkerStateEvent;
7 | import javafx.event.EventHandler;
8 | import net.sf.jasperreports.engine.JasperPrint;
9 |
10 | public interface ReportsService {
11 |
12 | Service createJasperPrint(String reportTemplatePath, List data, EventHandler onSucess, EventHandler beforeStart);
13 |
14 | void onClose();
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/ReportsServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import java.util.HashMap;
4 | import java.util.List;
5 |
6 | import javafx.concurrent.Service;
7 | import javafx.concurrent.Task;
8 | import javafx.concurrent.WorkerStateEvent;
9 | import javafx.event.EventHandler;
10 | import net.sf.jasperreports.engine.JasperCompileManager;
11 | import net.sf.jasperreports.engine.JasperFillManager;
12 | import net.sf.jasperreports.engine.JasperPrint;
13 | import net.sf.jasperreports.engine.JasperReport;
14 | import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
15 |
16 | @org.springframework.stereotype.Service("reportsService")
17 | public class ReportsServiceImpl extends BaseService implements ReportsService {
18 |
19 | public Service createJasperPrint(String reportTemplatePath, List data, EventHandler onSucess, EventHandler beforeStart) {
20 |
21 | return createService(new Task() {
22 | protected JasperPrint call() throws Exception {
23 | JasperPrint jasperPrint = null;
24 |
25 | try {
26 | System.out.println(data.size());
27 | JasperReport jasperReport = JasperCompileManager.compileReport(this.getClass().getResourceAsStream(reportTemplatePath));
28 | jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap<>(), new JRBeanCollectionDataSource(data));
29 | } catch (Exception e) {
30 | e.printStackTrace();
31 | }
32 |
33 | return jasperPrint;
34 | };
35 | }, onSucess, beforeStart);
36 |
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/RoleService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import java.util.List;
4 |
5 | import com.tiagohs.model.Role;
6 |
7 | import javafx.concurrent.Service;
8 | import javafx.concurrent.WorkerStateEvent;
9 | import javafx.event.EventHandler;
10 |
11 | public interface RoleService extends IBaseService {
12 |
13 | Service> findByRole(String role, EventHandler onSucess, EventHandler beforeStart);
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/RoleServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.data.jpa.repository.JpaRepository;
7 | import org.springframework.stereotype.Service;
8 |
9 | import com.tiagohs.model.Role;
10 | import com.tiagohs.repository.RoleRepository;
11 |
12 | import javafx.concurrent.Task;
13 | import javafx.concurrent.WorkerStateEvent;
14 | import javafx.event.EventHandler;
15 |
16 | @Service("roleService")
17 | public class RoleServiceImpl extends BaseCrudService> implements RoleService {
18 |
19 | private RoleRepository roleRepository;
20 |
21 | @Autowired
22 | public RoleServiceImpl(RoleRepository repository) {
23 | super(repository);
24 |
25 | this.roleRepository = repository;
26 | }
27 |
28 | public RoleRepository getRoleRepository() {
29 | return roleRepository;
30 | }
31 |
32 | public void setRoleRepository(RoleRepository roleRepository) {
33 | this.roleRepository = roleRepository;
34 | }
35 |
36 | @Override
37 | public javafx.concurrent.Service> findByRole(String role, EventHandler onSucess, EventHandler beforeStart) {
38 | return createService(new Task>() {
39 | protected List call() throws Exception {
40 | return roleRepository.findByRole(role);
41 | };
42 | }, onSucess, beforeStart);
43 |
44 | }
45 |
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/SaleService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import java.util.Calendar;
4 | import java.util.List;
5 |
6 | import com.tiagohs.model.Sale;
7 |
8 | import javafx.concurrent.Service;
9 | import javafx.concurrent.WorkerStateEvent;
10 | import javafx.event.EventHandler;
11 |
12 | public interface SaleService extends IBaseService {
13 |
14 | Service> findAllOpenSales(EventHandler onSucess, EventHandler beforeStart);
15 | Service> findAllFinalizedSales(EventHandler onSucess, EventHandler beforeStart);
16 | Service getTotalSales(EventHandler onSucess, EventHandler beforeStart);
17 | Service> findSaleByMonth(Calendar date, EventHandler onSucess, EventHandler beforeStart);
18 | Service getTotalSalesByMonthService(Calendar date, EventHandler onSucess, EventHandler beforeStart);
19 | Long getTotalSalesByMonth(Calendar date);
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/SaleServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import java.text.SimpleDateFormat;
4 | import java.util.Calendar;
5 | import java.util.List;
6 |
7 | import org.springframework.data.jpa.repository.JpaRepository;
8 | import org.springframework.stereotype.Service;
9 |
10 | import com.tiagohs.model.Sale;
11 | import com.tiagohs.repository.SaleRepository;
12 |
13 | import javafx.concurrent.Task;
14 | import javafx.concurrent.WorkerStateEvent;
15 | import javafx.event.EventHandler;
16 |
17 | @Service("saleService")
18 | public class SaleServiceImpl extends BaseCrudService> implements SaleService {
19 |
20 | private SaleRepository saleRepository;
21 | private SimpleDateFormat patternMonth;
22 |
23 | public SaleServiceImpl(SaleRepository repository) {
24 | super(repository);
25 |
26 | this.saleRepository = repository;
27 | this.patternMonth = new SimpleDateFormat("MM-yyyy");
28 | }
29 |
30 | public SaleRepository getSaleRepository() {
31 | return saleRepository;
32 | }
33 |
34 | @Override
35 | public javafx.concurrent.Service> findAllOpenSales(EventHandler onSucess, EventHandler beforeStart) {
36 | return createService(new Task>() {
37 | protected List call() throws Exception {
38 | return saleRepository.findAllOpenSales();
39 | };
40 | }, onSucess, beforeStart);
41 | }
42 |
43 | @Override
44 | public javafx.concurrent.Service> findAllFinalizedSales(EventHandler onSucess, EventHandler beforeStart) {
45 | return createService(new Task>() {
46 | protected List call() throws Exception {
47 | return saleRepository.findAllFinalizedSales();
48 | };
49 | }, onSucess, beforeStart);
50 | }
51 |
52 | @Override
53 | public javafx.concurrent.Service getTotalSales(EventHandler onSucess, EventHandler beforeStart) {
54 | return createService(new Task() {
55 | protected Long call() throws Exception {
56 | return saleRepository.getTotalSales();
57 | };
58 | }, onSucess, beforeStart);
59 | }
60 |
61 | @Override
62 | public javafx.concurrent.Service> findSaleByMonth(Calendar date, EventHandler onSucess, EventHandler beforeStart) {
63 | return createService(new Task>() {
64 | protected List call() throws Exception {
65 | if (date != null) {
66 | return saleRepository.findSalesByMonth(patternMonth.format(date.getTime()));
67 | }
68 |
69 | return null;
70 | };
71 | }, onSucess, beforeStart);
72 |
73 | }
74 |
75 | @Override
76 | public javafx.concurrent.Service getTotalSalesByMonthService(Calendar date, EventHandler onSucess, EventHandler beforeStart) {
77 | return createService(new Task() {
78 | protected Long call() throws Exception {
79 | if (date != null) {
80 | return getTotalSalesByMonth(date);
81 | }
82 |
83 | return 0L;
84 | };
85 | }, onSucess, beforeStart);
86 | }
87 |
88 | @Override
89 | public Long getTotalSalesByMonth(Calendar date) {
90 | return saleRepository.getTotalSalesByMonth(patternMonth.format(date.getTime()));
91 | }
92 |
93 |
94 |
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/SupplierService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import com.tiagohs.model.Supplier;
4 |
5 | import javafx.concurrent.Service;
6 | import javafx.concurrent.WorkerStateEvent;
7 | import javafx.event.EventHandler;
8 |
9 | public interface SupplierService extends IBaseService {
10 |
11 | Service getTotalSuppliers(EventHandler onSucess, EventHandler beforeStart);
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/SupplierServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.stereotype.Service;
6 |
7 | import com.tiagohs.model.Supplier;
8 | import com.tiagohs.repository.SupplierRepository;
9 |
10 | import javafx.concurrent.Task;
11 | import javafx.concurrent.WorkerStateEvent;
12 | import javafx.event.EventHandler;
13 |
14 | @Service("supplierService")
15 | public class SupplierServiceImpl extends BaseCrudService> implements SupplierService {
16 |
17 | private SupplierRepository supplierRepository;
18 |
19 | @Autowired
20 | public SupplierServiceImpl(SupplierRepository supplierRepository) {
21 | super(supplierRepository);
22 |
23 | this.supplierRepository = supplierRepository;
24 | }
25 |
26 | public SupplierRepository getSupplierRepository() {
27 | return supplierRepository;
28 | }
29 |
30 | public void setSupplierRepository(SupplierRepository supplierRepository) {
31 | this.supplierRepository = supplierRepository;
32 | }
33 |
34 | @Override
35 | public javafx.concurrent.Service getTotalSuppliers(EventHandler onSucess, EventHandler beforeStart) {
36 | return createService(new Task() {
37 | protected Long call() throws Exception {
38 | return supplierRepository.getTotalSuppliers();
39 | };
40 | }, onSucess, beforeStart);
41 | }
42 |
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/TableService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import com.tiagohs.util.ITableServiceCreator;
4 |
5 | import javafx.application.Platform;
6 | import javafx.concurrent.Service;
7 | import javafx.concurrent.Task;
8 |
9 | public class TableService extends Service {
10 |
11 | private ITableServiceCreator creator;
12 |
13 | public TableService(ITableServiceCreator creator) {
14 | this.creator = creator;
15 | }
16 |
17 | @Override
18 | protected Task createTask() {
19 | return new Task() {
20 | @Override
21 | protected Void call() throws Exception {
22 | Platform.runLater(() -> creator.onCreate());
23 |
24 | return null;
25 | }
26 | };
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/tiagohs/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.tiagohs.service;
2 |
3 | import com.tiagohs.model.User;
4 |
5 | import javafx.concurrent.Service;
6 | import javafx.concurrent.WorkerStateEvent;
7 | import javafx.event.EventHandler;
8 |
9 | public interface UserService extends IBaseService {
10 |
11 | Service getTotalUsers(EventHandler onSucess, EventHandler beforeStart);
12 |
13 | Service findUserByEmail(String email, EventHandler