* A munkalapok lista szűrhető projektre és résztvevőre. Ezt használjuk ki, amikor a projekt összevont nézetből a munkalap bontást szeretnénk látni
* A projektben a munkalap összesitve jelenjen meg személyenként, de navigáljon el bontott nézetbe kattintásra
* Projekt szerkesztő: ergonómikusabb elrendezés
-- A projekt szerkesztés/részletezés tetején az adatok legyenek bal oldalon bekeretezve.
+* A projekt szerkesztés/részletezés tetején az adatok legyenek bal oldalon bekeretezve.
A jobb oldalon pedig legyen látható a projekt árrése.
Az árrés annyi sorból áll ahány devizanem van a projekt számláiban. Egy adott devizanem esetén a számolás:
Kimenő - Bejövő - Treasury eladás + Treasury vétel
+
+db persist
+- servicerecord:
+ project generalas
+ generalas
+ project szuro
+
+auth/ldap
+autorizacio
+nav
+szamla erkeztetes camunda: egy felasznalohoz jon be, projekthez lehessen csatolni, projektszanot ellenorizze
+
+
- Számla kiegyenlítés
- Autentikáció: AD és helyi
- legyen felhasználó specifikus beállításokra lehetőség
- Plugin: lehet egyedi testreszabási igény, de ennek valahogy el kell teljesen különülnie a "core" forráskódtól. Pl. javascript motort be lehetne építeni, a szkriptek pedig meghatározott pontokon lehetnének becsatolva a logikába. Számla részletezés volt a példa (10000EUR számla 3 részletben forintban, kérdés mennyi pl. az utsó számla összege); 10 custom mező, javascripttel futna a custom mezők módosítására.
+fds.in.useribm.hu
+389
+
+ldaps
+fds.useribm.hu
+636
+
+
* By elGekko
*/
-package hu.user.lis.app;
+package hu.user.lis;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* By elGekko
*/
-package hu.user.lis.app;
+package hu.user.lis;
import hu.user.lis.ui.config.WebSecurityConfig;
import org.apache.logging.log4j.LogManager;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.SpringVersion;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
//@SpringBootApplication(scanBasePackages = {"hu.user.lis"})
@ComponentScan(basePackages = {"hu.user.lis"}, excludeFilters = {
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = WebSecurityConfig.class)})
@EnableWebMvc
+//@EnableMongoRepositories(basePackages = "hu.user.lis.db.repository")
+@EnableJpaRepositories(basePackages = "hu.user.lis.db.repository")
public class Main extends SpringBootServletInitializer implements ApplicationListener<ContextRefreshedEvent> {
private static final Logger logger = LogManager.getLogger();
* By elGekko
*/
-package hu.user.lis.app;
+package hu.user.lis;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
--- /dev/null
+server:
+ port: 8080
+ servlet:
+ context-path: /
+zk:
+ homepage: index
+ zul-view-resolver-enabled: true
+spring:
+ output:
+ ansi:
+ enabled: always
+ # data:
+ # mongodb:
+ # host: localhost
+ # port: 27017
+ # database: lis
+ datasource:
+ # driver-class-name: com.mysql.jdbc.Driver
+ type: com.zaxxer.hikari.HikariDataSource
+ url: jdbc:db2://localhost:50000/lis
+ username: db2admin
+ password: password
+# hikari:
+# pool-name: testmc
+# maximum-pool-size: 50
+# minimum-idle: 10
# pool-name: pool-maszkaweb
# maximum-pool-size: 50
# minimum-idle: 10
- datasource:
- # driver-class-name: com.mysql.jdbc.Driver
- type: com.zaxxer.hikari.HikariDataSource
- url: jdbc:db2://localvm:50000/testmc
- username: db2admin
- password: password
- hikari:
- pool-name: testmc
- maximum-pool-size: 50
- minimum-idle: 10
+ # data:
+ # mongodb:
+ # # host: dvdev.in.useribm.hu
+ # host: localvm
+ # port: 27017
+ # database: lis
+
+ # username: db2admin
+ # password: password
+# datasource:
+# # driver-class-name: com.mysql.jdbc.Driver
+# type: com.zaxxer.hikari.HikariDataSource
+# url: jdbc:db2://localvm:50000/testmc
+# username: db2admin
+# password: password
+# hikari:
+# pool-name: testmc
+# maximum-pool-size: 50
+# minimum-idle: 10
service:
message: Hello, World
* By elGekko
*/
-package hu.user.lis.app;
+package hu.user.lis;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
--- /dev/null
+Welcome!
+
+This is an MyBatis Migration repository. You can specify the repository
+directory when running migrations using the --path=<repos-directory>
+option. The default path is the current working directory ("./").
+
+The repository base directory contains three subdirectories as follows:
+
+./drivers
+
+Place your JDBC driver .jar or .zip files in this directory. Upon running a
+migration, the drivers will be dynamically loaded.
+
+Download driver:
+<dependency>
+ <groupId>com.ibm.db2</groupId>
+ <artifactId>jcc</artifactId>
+ <version>11.5.8.0</version>
+</dependency>
+
+
+./environments
+
+In the environments folder you will find .properties files that represent
+your database instances. By default a development.properties file is
+created for you to configure your development time database properties.
+You can also create test.properties and production.properties files.
+The environment can be specified when running a migration by using
+the --env=<environment> option (without the path or ".properties" part).
+
+The default environment is "development".
+
+./scripts
+
+This directory contains your migration SQL files. These are the files
+that contain your DDL to both upgrade and downgrade your database
+structure. By default, the directory will contain the script to
+create the changelog table, plus one empty "first" migration script.
+To create a new migration script, use the "new" command. To run
+all pending migrations, use the "up" command. To undo the last
+migration applied, use the "down" command etc.
+
+For more information about commands and options, run the MyBatis
+Migration script with the --help option.
+
+Enjoy.
--- /dev/null
+-- // Bootstrap.sql
+DROP DATABASE IF EXISTS LIS;
+CREATE DATABASE LIS AUTOMATIC STORAGE YES USING CODESET UTF-8 TERRITORY hu COLLATE USING UCA500R1_S2 PAGESIZE 32 K;
--- /dev/null
+## Base time zone to ensure times are consistent across machines
+time_zone=GMT+0:00
+
+## The character set that scripts are encoded with
+script_char_set=UTF-8
+
+## JDBC connection properties.
+driver=com.ibm.db2.jcc.DB2Driver
+url=jdbc:db2://localhost:50000/lis
+username=db2admin
+password=password
+
+#
+# A NOTE ON STORED PROCEDURES AND DELIMITERS
+#
+# Stored procedures and functions commonly have nested delimiters
+# that conflict with the schema migration parsing. If you tend
+# to use procs, functions, triggers or anything that could create
+# this situation, then you may want to experiment with
+# send_full_script=true (preferred), or if you can't use
+# send_full_script, then you may have to resort to a full
+# line delimiter such as "GO" or "/" or "!RUN!".
+#
+# Also play with the autocommit settings, as some drivers
+# or databases don't support creating procs, functions or
+# even tables in a transaction, and others require it.
+#
+
+# This ignores the line delimiters and
+# simply sends the entire script at once.
+# Use with JDBC drivers that can accept large
+# blocks of delimited text at once.
+send_full_script=false
+
+# This controls how statements are delimited.
+# By default statements are delimited by an
+# end of line semicolon. Some databases may
+# (e.g. MS SQL Server) may require a full line
+# delimiter such as GO.
+# These are ignored if send_full_script is true.
+delimiter=;
+full_line_delimiter=false
+
+# If set to true, each statement is isolated
+# in its own transaction. Otherwise the entire
+# script is executed in one transaction.
+# Few databases should need this set to true,
+# but some do.
+auto_commit=false
+
+# If set to false, warnings from the database will interrupt migrations.
+ignore_warnings=false
+
+# Custom driver path to allow you to centralize your driver files
+# Default requires the drivers to be in the drivers directory of your
+# initialized migration directory (created with "migrate init")
+# driver_path=
+
+# Name of the table that tracks changes to the database
+changelog=CHANGELOG
+
+# Migrations support variable substitutions in the form of ${variable}
+# in the migration scripts. All of the above properties will be ignored though,
+# with the exception of changelog.
+# Example: The following would be referenced in a migration file as ${ip_address}
+# ip_address=192.168.0.1
+
--- /dev/null
+-- // Create Changelog
+
+-- Default DDL for changelog table that will keep
+-- a record of the migrations that have been run.
+
+-- You can modify this to suit your database before
+-- running your first migration.
+
+-- Be sure that ID and DESCRIPTION fields exist in
+-- BigInteger and String compatible fields respectively.
+
+CREATE TABLE ${changelog} (
+ID NUMERIC(20,0) NOT NULL,
+APPLIED_AT VARCHAR(25) NOT NULL,
+DESCRIPTION VARCHAR(255) NOT NULL
+);
+
+ALTER TABLE ${changelog}
+ADD CONSTRAINT PK_${changelog}
+PRIMARY KEY (id);
+
+-- //@UNDO
+
+DROP TABLE ${changelog};
--- /dev/null
+-- // create_initial_schema
+-- Migration SQL that makes the change goes here.
+CREATE TABLE associate (
+ id BIGINT NOT NULL,
+ name VARCHAR(255),
+ login VARCHAR(255),
+ password VARCHAR(255),
+ monthly_cost DOUBLE NOT NULL,
+ active SMALLINT NOT NULL,
+ CONSTRAINT pk_associate PRIMARY KEY (id)
+);
+
+CREATE TABLE edocument (
+ id BIGINT NOT NULL,
+ created TIMESTAMP,
+ name VARCHAR(255),
+ description VARCHAR(255),
+ size INTEGER NOT NULL,
+ file BLOB,
+ CONSTRAINT pk_edocument PRIMARY KEY (id)
+);
+
+CREATE TABLE project_status (
+ id BIGINT NOT NULL,
+ name VARCHAR(255),
+ active SMALLINT NOT NULL,
+ order INTEGER NOT NULL,
+ CONSTRAINT pk_projectstatus PRIMARY KEY (id)
+);
+
+CREATE TABLE partner (
+ id BIGINT NOT NULL,
+ name VARCHAR(255),
+ vat_nr VARCHAR(255),
+ address VARCHAR(255),
+ active SMALLINT NOT NULL,
+ CONSTRAINT pk_partner PRIMARY KEY (id)
+);
+
+CREATE TABLE project (
+ id BIGINT NOT NULL,
+ project_status_id BIGINT,
+ name VARCHAR(255),
+ human_id VARCHAR(255),
+ contact_name VARCHAR(255),
+ partner_id BIGINT,
+ active SMALLINT NOT NULL,
+ CONSTRAINT pk_project PRIMARY KEY (id)
+);
+ALTER TABLE project ADD CONSTRAINT FK_PROJECT_ON_PARTNER FOREIGN KEY (partner_id) REFERENCES partner (id);
+ALTER TABLE project ADD CONSTRAINT FK_PROJECT_ON_PROJECT_STATUS FOREIGN KEY (project_status_id) REFERENCES project_status (id);
+
+CREATE TABLE invoice (
+ id BIGINT NOT NULL,
+ human_id VARCHAR(255),
+ title VARCHAR(255),
+ partner_id BIGINT,
+ project_id BIGINT,
+ income SMALLINT NOT NULL,
+ currency INTEGER,
+ net_amount DOUBLE NOT NULL,
+ gross_amount DOUBLE NOT NULL,
+ vat_amount DOUBLE NOT NULL,
+ completion_date TIMESTAMP,
+ create_date TIMESTAMP,
+ payment_deadline TIMESTAMP,
+ planned SMALLINT NOT NULL,
+ file BLOB,
+ CONSTRAINT pk_invoice PRIMARY KEY (id)
+);
+ALTER TABLE invoice ADD CONSTRAINT FK_INVOICE_ON_PARTNER FOREIGN KEY (partner_id) REFERENCES partner (id);
+ALTER TABLE invoice ADD CONSTRAINT FK_INVOICE_ON_PROJECT FOREIGN KEY (project_id) REFERENCES project (id);
+
+CREATE TABLE treasury (
+ id BIGINT NOT NULL,
+ project_id BIGINT,
+ human_id VARCHAR(255),
+ buy_amount DOUBLE NOT NULL,
+ buy_currency INTEGER,
+ sell_amount DOUBLE NOT NULL,
+ sell_currency INTEGER,
+ transaction_date TIMESTAMP,
+ value_date TIMESTAMP,
+ file BLOB,
+ CONSTRAINT pk_treasury PRIMARY KEY (id)
+);
+ALTER TABLE treasury ADD CONSTRAINT FK_TREASURY_ON_PROJECT FOREIGN KEY (project_id) REFERENCES project (id);
+
+CREATE TABLE project_associate (
+ id BIGINT NOT NULL,
+ project_id BIGINT,
+ associate_id BIGINT,
+ CONSTRAINT pk_projectassociate PRIMARY KEY (id)
+);
+ALTER TABLE project_associate ADD CONSTRAINT FK_PROJECTASSOCIATE_ON_ASSOCIATE FOREIGN KEY (associate_id) REFERENCES associate (id);
+ALTER TABLE project_associate ADD CONSTRAINT FK_PROJECTASSOCIATE_ON_PROJECT FOREIGN KEY (project_id) REFERENCES project (id);
+
+CREATE TABLE service_record (
+ id BIGINT NOT NULL,
+ project_id BIGINT,
+ associate_id BIGINT,
+ work_day TIMESTAMP,
+ description VARCHAR(255),
+ details VARCHAR(255),
+ work_hours INTEGER NOT NULL,
+ cost DOUBLE NOT NULL,
+ file BLOB,
+ CONSTRAINT pk_servicerecord PRIMARY KEY (id)
+);
+ALTER TABLE service_record ADD CONSTRAINT FK_SERVICERECORD_ON_ASSOCIATE FOREIGN KEY (associate_id) REFERENCES associate (id);
+ALTER TABLE service_record ADD CONSTRAINT FK_SERVICERECORD_ON_PROJECT FOREIGN KEY (project_id) REFERENCES project (id);
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+DROP TABLE service_record;
+DROP TABLE project_associate;
+DROP TABLE treasury;
+DROP TABLE invoice;
+DROP TABLE project;
+DROP TABLE partner;
+DROP TABLE project_status;
+DROP TABLE edocument;
+DROP TABLE associate;
<?xml version="1.0" encoding="UTF-8"?>
<project
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>hu.user</groupId>
<artifactId>lis-db</artifactId>
<artifactId>lis</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.data</groupId>
+ <artifactId>spring-data-mongodb</artifactId>
+ <version>3.4.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mongodb</groupId>
+ <artifactId>mongodb-driver-sync</artifactId>
+ <version>4.9.1</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ <version>3.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>com.ibm.db2</groupId>
+ <artifactId>jcc</artifactId>
+ <version>11.5.8.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </dependency>
+ </dependencies>
</project>
\ No newline at end of file
package hu.user.lis.db;
import lombok.*;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
@Getter
@Setter
+@Entity
@Builder
+@Document
@AllArgsConstructor
@NoArgsConstructor
public class Associate {
- String id;
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE)
+ Long id;
String name;
String login;
String password;
--- /dev/null
+package hu.user.lis.db;
+
+import lombok.*;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import java.util.Date;
+
+@Getter
+@Setter
+@Entity
+@Builder
+@Document
+@AllArgsConstructor
+@NoArgsConstructor
+public class EDocument {
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE)
+ Long id;
+ Date created;
+ String name;
+ String description;
+ int size;
+ byte[] file;
+}
package hu.user.lis.db;
import lombok.*;
+import org.springframework.data.mongodb.core.mapping.Document;
+import javax.persistence.*;
import java.util.Date;
@Getter
@Setter
+@Entity
@Builder
+@Document
@AllArgsConstructor
@NoArgsConstructor
public class Invoice {
- String id;
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE)
+ Long id;
String humanId;
- String projectId;
String title;
+ @OneToOne
+ @JoinColumn(name = "partner_id")
Partner partner;
+ @ManyToOne
+ @JoinColumn(name = "project_id")
+ Project project;
boolean income;
Currency currency;
double netAmount;
package hu.user.lis.db;
import lombok.*;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
@Getter
@Setter
+@Entity
@Builder
+@Document
@AllArgsConstructor
@NoArgsConstructor
public class Partner {
- String id;
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE)
+ Long id;
String name;
String vatNr;
String address;
package hu.user.lis.db;
import lombok.*;
+import org.springframework.data.mongodb.core.mapping.Document;
+import javax.persistence.*;
import java.util.List;
@Getter
@Setter
+@Entity
@Builder
+@Document
@AllArgsConstructor
@NoArgsConstructor
public class Project {
- String id;
- String projectStatusId;
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE)
+ Long id;
+ @ManyToOne
+ @JoinColumn(name = "project_status_id")
+ ProjectStatus projectStatus;
String name;
String humanId;
String contactName;
+ @ManyToOne
+ @JoinColumn(name = "partner_id")
Partner partner;
boolean active;
+ @OneToMany(mappedBy = "project")
List<Invoice> incomingInvoices;
+ @OneToMany(mappedBy = "project")
List<Invoice> outgoingInvoices;
+ @OneToMany(mappedBy = "project")
List<Treasury> treasuries;
}
package hu.user.lis.db;
import lombok.*;
+import org.springframework.data.mongodb.core.mapping.Document;
+import org.springframework.data.mongodb.core.mapping.DocumentReference;
+
+import javax.persistence.*;
@Getter
@Setter
+@Entity
@Builder
+@Document
@AllArgsConstructor
@NoArgsConstructor
public class ProjectAssociate {
- String projectId;
- String associateId;
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE)
+ Long id;
+ @ManyToOne
+ @JoinColumn(name = "project_id")
+ @DocumentReference
+ Project project;
+ @ManyToOne
+ @JoinColumn(name = "associate_id")
+ @DocumentReference
+ Associate associate;
}
import lombok.*;
+import javax.persistence.*;
+
@Getter
@Setter
@Builder
+@Entity
+//@Document
@AllArgsConstructor
@NoArgsConstructor
+@Table(name = "project_status")
public class ProjectStatus {
- String id;
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE)
+ Long id;
String name;
boolean active;
int order;
package hu.user.lis.db;
import lombok.*;
+import org.springframework.data.mongodb.core.mapping.Document;
+import org.springframework.data.mongodb.core.mapping.DocumentReference;
+import javax.persistence.*;
import java.util.Date;
@Getter
@Setter
+@Entity
@Builder
+@Document
@AllArgsConstructor
@NoArgsConstructor
public class ServiceRecord {
- String id;
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE)
+ Long id;
+ @ManyToOne
+ @JoinColumn(name = "project_id")
+ @DocumentReference(lazy = true)
Project project;
+ @ManyToOne
+ @JoinColumn(name = "associate_id")
+ @DocumentReference(lazy = true)
Associate associate;
Date workDay;
String description;
package hu.user.lis.db;
import lombok.*;
+import org.springframework.data.mongodb.core.mapping.Document;
+import javax.persistence.*;
import java.util.Date;
@Getter
@Setter
@Builder
+@Entity
+@Document
@AllArgsConstructor
@NoArgsConstructor
public class Treasury {
- String id;
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE)
+ Long id;
+ @ManyToOne
+ @JoinColumn(name = "project_id")
+ Project project;
String humanId;
double buyAmount;
Currency buyCurrency;
--- /dev/null
+package hu.user.lis.db.repository;
+
+import hu.user.lis.db.ProjectStatus;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.transaction.annotation.Transactional;
+
+public interface ProjectStatusRepository extends JpaRepository<ProjectStatus, Long> {
+ @Modifying
+ @Transactional
+ @Query(value = "TRUNCATE TABLE project_status IMMEDIATE", nativeQuery = true)
+ void truncate();
+}
--- /dev/null
+package hu.user.lis.services.api;
+
+import hu.user.lis.db.Associate;
+import hu.user.lis.services.nosql.AssociateDbService;
+import hu.user.lis.services.nosql.DbService;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Log4j2
+@RestController
+@RequestMapping("/api/associate")
+public class AssociateApi extends DbApi<Associate> {
+ @Autowired
+ AssociateDbService associateDbService;
+
+ @Override
+ protected DbService<Associate> getDbService() {
+ return associateDbService;
+ }
+}
--- /dev/null
+package hu.user.lis.services.api;
+
+import hu.user.lis.services.nosql.DbService;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+public abstract class DbApi<T> {
+
+ protected abstract DbService<T> getDbService();
+
+ @GetMapping("/list")
+ public List<T> list() {
+ return getDbService().list();
+ }
+
+ @GetMapping("/get/{id}")
+ public T get(@PathVariable String id) {
+ return getDbService().get(id);
+ }
+
+ @PostMapping("/create")
+ public T create(@RequestBody T entity) {
+ return getDbService().insert(entity);
+ }
+
+ @PutMapping("/update")
+ public void update(@RequestBody T entity) {
+ getDbService().save(entity);
+ }
+
+ @GetMapping("/reset")
+ public void reset() {
+ getDbService().reset();
+ }
+
+ @GetMapping("/generate")
+ public List<T> generate() {
+ return getDbService().generate();
+ }
+}
--- /dev/null
+package hu.user.lis.services.api;
+
+import hu.user.lis.services.nosql.*;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Log4j2
+@RestController
+@RequestMapping("/api/generate")
+public class GenerateApi {
+ @Autowired
+ ProjectStatusDbService projectStatusDbService;
+ @Autowired
+ PartnerDbService partnerDbService;
+ @Autowired
+ AssociateDbService associateDbService;
+ @Autowired
+ InvoiceDbService invoiceDbService;
+ @Autowired
+ TreasuryDbService treasuryDbService;
+ @Autowired
+ ProjectDbService projectDbService;
+ @Autowired
+ ProjectAssociateDbService projectAssociateDbService;
+ @Autowired
+ ServiceRecordDbService serviceRecordDbService;
+
+ @GetMapping("/all")
+ public String list() {
+ log.info("projectStatusDbService");
+ projectStatusDbService.generate();
+ log.info("partnerDbService");
+ partnerDbService.generate();
+ log.info("associateDbService");
+ associateDbService.generate();
+ log.info("invoiceDbService");
+ invoiceDbService.generate();
+ log.info("treasuryDbService");
+ treasuryDbService.generate();
+ log.info("projectDbService");
+ projectDbService.generate();
+ log.info("projectAssociateDbService");
+ projectAssociateDbService.generate();
+ log.info("serviceRecordDbService");
+ serviceRecordDbService.generate();
+ return "DONE";
+ }
+
+}
--- /dev/null
+package hu.user.lis.services.api;
+
+import hu.user.lis.db.Invoice;
+import hu.user.lis.services.nosql.DbService;
+import hu.user.lis.services.nosql.InvoiceDbService;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Log4j2
+@RestController
+@RequestMapping("/api/invoice")
+public class InvoiceApi extends DbApi<Invoice> {
+ @Autowired
+ InvoiceDbService invoiceDbService;
+
+ @Override
+ protected DbService<Invoice> getDbService() {
+ return invoiceDbService;
+ }
+}
--- /dev/null
+package hu.user.lis.services.api;
+
+import hu.user.lis.db.Partner;
+import hu.user.lis.services.nosql.DbService;
+import hu.user.lis.services.nosql.PartnerDbService;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Log4j2
+@RestController
+@RequestMapping("/api/partner")
+public class PartnerApi extends DbApi<Partner> {
+ @Autowired
+ PartnerDbService partnerDbService;
+
+ @Override
+ protected DbService<Partner> getDbService() {
+ return partnerDbService;
+ }
+}
--- /dev/null
+package hu.user.lis.services.api;
+
+import hu.user.lis.db.Project;
+import hu.user.lis.services.nosql.DbService;
+import hu.user.lis.services.nosql.ProjectDbService;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Log4j2
+@RestController
+@RequestMapping("/api/project")
+public class ProjectApi extends DbApi<Project> {
+ @Autowired
+ ProjectDbService projectDbService;
+
+ @Override
+ protected DbService<Project> getDbService() {
+ return projectDbService;
+ }
+}
--- /dev/null
+package hu.user.lis.services.api;
+
+import hu.user.lis.db.ProjectAssociate;
+import hu.user.lis.services.nosql.DbService;
+import hu.user.lis.services.nosql.ProjectAssociateDbService;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Log4j2
+@RestController
+@RequestMapping("/api/project-associate")
+public class ProjectAssociateApi extends DbApi<ProjectAssociate> {
+ @Autowired
+ ProjectAssociateDbService projectAssociateDbService;
+
+ @Override
+ protected DbService<ProjectAssociate> getDbService() {
+ return projectAssociateDbService;
+ }
+}
--- /dev/null
+package hu.user.lis.services.api;
+
+import hu.user.lis.db.ProjectStatus;
+import hu.user.lis.db.repository.ProjectStatusRepository;
+import hu.user.lis.services.data.ProjectStatusService;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Log4j2
+@RestController
+@RequestMapping("/api/project-status")
+public class ProjectStatusApi {
+ @Autowired
+ ProjectStatusRepository projectStatusRepository;
+ @Autowired
+ ProjectStatusService projectStatusService;
+
+ @GetMapping("/list")
+ public List<ProjectStatus> list() {
+ return projectStatusRepository.findAll();
+ }
+
+ @GetMapping("/get/{id}")
+ public ProjectStatus get(@PathVariable Long id) {
+ return projectStatusRepository.findById(id).orElse(null);
+ }
+
+ @PostMapping("/create")
+ public ProjectStatus create(@RequestBody ProjectStatus entity) {
+ return projectStatusRepository.save(entity);
+ }
+
+ @PutMapping("/update")
+ public void update(@RequestBody ProjectStatus entity) {
+ projectStatusRepository.truncate();
+ }
+
+ @GetMapping("/reset")
+ public void reset() {
+ projectStatusRepository.truncate();
+ }
+
+ @GetMapping("/generate")
+ public List<ProjectStatus> generate() {
+ reset();
+ List<ProjectStatus> result = projectStatusService.getAll();
+ projectStatusRepository.saveAll(result);
+ return result;
+ }
+}
--- /dev/null
+package hu.user.lis.services.api;
+
+import hu.user.lis.db.ServiceRecord;
+import hu.user.lis.services.nosql.DbService;
+import hu.user.lis.services.nosql.ServiceRecordDbService;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Log4j2
+@RestController
+@RequestMapping("/api/service-record")
+public class ServiceRecordApi extends DbApi<ServiceRecord> {
+ @Autowired
+ ServiceRecordDbService serviceRecordDbService;
+
+ @Override
+ protected DbService<ServiceRecord> getDbService() {
+ return serviceRecordDbService;
+ }
+}
--- /dev/null
+package hu.user.lis.services.api;
+
+import hu.user.lis.db.Treasury;
+import hu.user.lis.services.nosql.DbService;
+import hu.user.lis.services.nosql.TreasuryDbService;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Log4j2
+@RestController
+@RequestMapping("/api/treasury")
+public class TreasuryApi extends DbApi<Treasury> {
+ @Autowired
+ TreasuryDbService treasuryDbService;
+
+ @Override
+ protected DbService<Treasury> getDbService() {
+ return treasuryDbService;
+ }
+}
public interface AssociateService extends DataService<Associate> {
List<Associate> getAll();
+ void setAll(List<Associate> entities);
+
Associate createNew();
void add(Associate entity);
Associate getRandom();
void replace(Associate targetEntity, Associate replacementEntity);
+
+ Associate getById(String id);
}
import hu.user.lis.db.Associate;
import lombok.extern.log4j.Log4j2;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
return entities;
}
+ @Override
+ public void setAll(List<Associate> entities) {
+ this.entities = entities;
+ }
+
@Override
public Associate createNew() {
- String id = RandomStringUtils.random(8, "0123456789abcdef");
- return Associate.builder().id(id).active(true).build();
+ return Associate.builder().active(true).build();
}
@Override
entities.add(replacementEntity);
}
+ @Override
+ public Associate getById(String id) {
+ return getAll().stream().filter(p -> p.getId().equals(id)).findFirst().get();
+ }
+
@Override
public Associate getRandom() {
return getAll().get(RandomUtils.nextInt(0, entities.size()));
private List<Associate> generate() {
List<Associate> result = new ArrayList<>();
for (int i = 0; i < 10; i++) {
- String id = RandomStringUtils.random(8, "0123456789abcdef");
String name = dataGeneratorService.faker().name().fullName();
String login = "user" + (i + 1);
String password = "password";
Associate entity = Associate.builder()
.active(true)
- .id(id)
.name(name)
.login(login)
.password(password)
private List<Associate> generate2() {
List<Associate> result = new ArrayList<>();
double monthlyCost = 0;
- String id = RandomStringUtils.random(8, "0123456789abcdef");
String name = "Kosztolányi Árpád";
String login = "user1";
String password = "password";
monthlyCost = BigDecimal.valueOf(RandomUtils.nextDouble(300000, 1500000))
.setScale(2, RoundingMode.CEILING).doubleValue();
Associate entity = Associate.builder().monthlyCost(monthlyCost)
- .active(true).id(id).name(name).login(login).password(password).build();
+ .active(true).name(name).login(login).password(password).build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
name = "Lévai Tibor";
login = "user2";
password = "password";
monthlyCost = BigDecimal.valueOf(RandomUtils.nextDouble(300000, 1500000))
.setScale(2, RoundingMode.CEILING).doubleValue();
entity = Associate.builder().monthlyCost(monthlyCost)
- .active(true).id(id).name(name).login(login).password(password).build();
+ .active(true).name(name).login(login).password(password).build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
name = "Szabó Marcell";
login = "user3";
password = "password";
monthlyCost = BigDecimal.valueOf(RandomUtils.nextDouble(300000, 1500000))
.setScale(2, RoundingMode.CEILING).doubleValue();
entity = Associate.builder().monthlyCost(monthlyCost)
- .active(true).id(id).name(name).login(login).password(password).build();
+ .active(true).name(name).login(login).password(password).build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
name = "Gulyás Csaba";
login = "user4";
password = "password";
monthlyCost = BigDecimal.valueOf(RandomUtils.nextDouble(300000, 1500000))
.setScale(2, RoundingMode.CEILING).doubleValue();
entity = Associate.builder().monthlyCost(monthlyCost)
- .active(true).id(id).name(name).login(login).password(password).build();
+ .active(true).name(name).login(login).password(password).build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
name = "Lévai Csilla";
login = "user5";
password = "password";
monthlyCost = BigDecimal.valueOf(RandomUtils.nextDouble(300000, 1500000))
.setScale(2, RoundingMode.CEILING).doubleValue();
entity = Associate.builder().monthlyCost(monthlyCost)
- .active(true).id(id).name(name).login(login).password(password).build();
+ .active(true).name(name).login(login).password(password).build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
name = "Vajda Krisztina";
login = "user6";
password = "password";
monthlyCost = BigDecimal.valueOf(RandomUtils.nextDouble(300000, 1500000))
.setScale(2, RoundingMode.CEILING).doubleValue();
entity = Associate.builder().monthlyCost(monthlyCost)
- .active(true).id(id).name(name).login(login).password(password).build();
+ .active(true).name(name).login(login).password(password).build();
result.add(entity);
return result;
--- /dev/null
+package hu.user.lis.services.data;
+
+import hu.user.lis.db.EDocument;
+
+import java.util.List;
+
+public interface EDocumentService extends DataService<EDocument> {
+ List<EDocument> getAll();
+
+ EDocument createNew();
+
+ void add(EDocument entity);
+}
--- /dev/null
+package hu.user.lis.services.data;
+
+import hu.user.lis.db.EDocument;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+@Log4j2
+public class EDocumentServiceImpl extends DataServiceImpl<EDocument> implements EDocumentService {
+ @Autowired
+ DataGeneratorService dataGeneratorService;
+ private List<EDocument> entities;
+
+ @Override
+ public List<EDocument> getAll() {
+ if (entities == null) {
+ entities = new ArrayList<>();
+ }
+ return entities;
+ }
+
+ @Override
+ public EDocument createNew() {
+ return EDocument.builder().build();
+ }
+
+ @Override
+ public void add(EDocument entity) {
+ entities.add(entity);
+ }
+
+}
import java.util.List;
-public interface InvoiceService {
+public interface InvoiceService extends DataService<Invoice> {
List<Invoice> getAll();
+ void setAll(List<Invoice> entities);
+
Invoice createNew();
void add(Invoice entity);
- Invoice copy(Invoice sourceEntity);
-
- String toString(Invoice sourceEntity);
-
- Invoice copy(Invoice sourceEntity, String property, Object value);
-
void replace(Invoice targetEntity, Invoice replacementEntity);
List<Invoice> getRandom(boolean income);
Invoice getByHumanId(String id);
List<Invoice> getByHumanIds(String[] ids);
-
-
}
import hu.user.lis.db.Currency;
import hu.user.lis.db.Invoice;
import hu.user.lis.db.Partner;
-import hu.user.lis.db.Project;
import lombok.extern.log4j.Log4j2;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
@Service
@Log4j2
return result;
}
+ @Override
+ public void setAll(List<Invoice> entities) {
+ this.incomingEntities = new ArrayList<>();
+ this.outgoingEntities = new ArrayList<>();
+ entities.forEach(e -> {
+ if (e.isIncome()) {
+ incomingEntities.add(e);
+ } else {
+ outgoingEntities.add(e);
+ }
+ });
+ }
+
@Override
public Invoice createNew() {
- String id = RandomStringUtils.random(8, "0123456789abcdef");
- return Invoice.builder().id(id).planned(true).build();
+ return Invoice.builder().planned(true).build();
}
@Override
DateFormat humanIdDateFormat = new SimpleDateFormat("yyyy");
for (int i = 0; i < GENERATE_COUNT; i++) {
- String id = RandomStringUtils.random(8, "0123456789abcdef");
String title = dataGeneratorService.faker().commerce().productName();
Partner partner = partnerService.getRandom();
Date completionDate = dataGeneratorService.faker().date().between(formatter.parse("2010-01-01"), new Date());
double grossAmount = netAmount * 1.27;
double vatAmount = grossAmount - netAmount;
Invoice entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
if (income) { // csak a bejovo szamlak generalasa
- String id = RandomStringUtils.random(8, "0123456789abcdef");
String humanId = "VSz-2023/00070-"; // szamla sorszam
String title = dataGeneratorService.faker().commerce().productName(); // 2022-0027
- Partner partner = partnerService.getById("001"); // 001
+ Partner partner = partnerService.getByName("ServerUnite Kft."); // 001
Date completionDate = formatter.parse("2023-02-22");
Date createDate = formatter.parse("2023-02-22");
Date paymentDeadline = formatter.parse("2023-03-24");
double grossAmount = netAmount * 1.27;
double vatAmount = grossAmount - netAmount;
Invoice entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "582-SPI1003006-3021"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2020-0109
- partner = partnerService.getById("004"); // 004
+ partner = partnerService.getByName("Arrow ECS Kft."); // 004
completionDate = formatter.parse("2020-12-22");
createDate = formatter.parse("2020-12-22");
paymentDeadline = formatter.parse("2021-02-10");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "582-SPI003118"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2020-0109
- partner = partnerService.getById("004"); // 004
+ partner = partnerService.getByName("Arrow ECS Kft."); // 004
completionDate = formatter.parse("2020-12-31");
createDate = formatter.parse("2020-12-31");
paymentDeadline = formatter.parse("2021-03-31");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "582-SPI003680"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2020-0109
- partner = partnerService.getById("004"); // 004
+ partner = partnerService.getByName("Arrow ECS Kft."); // 004
completionDate = formatter.parse("2021-03-08");
createDate = formatter.parse("2021-03-08");
paymentDeadline = formatter.parse("2021-04-27");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "582-SPI003681"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2020-0109
- partner = partnerService.getById("004"); // 004
+ partner = partnerService.getByName("Arrow ECS Kft."); // 004
completionDate = formatter.parse("2021-03-08");
createDate = formatter.parse("2021-03-08");
paymentDeadline = formatter.parse("2021-04-27");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "582-SPI004090"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2020-0109
- partner = partnerService.getById("004"); // 004
+ partner = partnerService.getByName("Arrow ECS Kft."); // 004
completionDate = formatter.parse("2021-04-19");
createDate = formatter.parse("2021-04-19");
paymentDeadline = formatter.parse("2021-06-08");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "9090010764"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2020-0109
- partner = partnerService.getById("005"); // 005
+ partner = partnerService.getByName("Tech Data - TD Synnex Kft."); // 005
completionDate = formatter.parse("2020-12-31");
createDate = formatter.parse("2020-12-31");
paymentDeadline = formatter.parse("2021-03-01");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "VSz-2021/00091"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2020-0109
- partner = partnerService.getById("006"); // 006
+ partner = partnerService.getByName("The IT Solutions Kft."); // 006
completionDate = formatter.parse("2021-02-10");
createDate = formatter.parse("2021-02-18");
paymentDeadline = formatter.parse("2021-03-20");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "EURSZLA0177/2022"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2022-0227
- partner = partnerService.getById("008"); // 008
+ partner = partnerService.getByName("Clico Hungary Kft."); // 008
completionDate = formatter.parse("2022-12-30");
createDate = formatter.parse("2022-12-30");
paymentDeadline = formatter.parse("2023-01-31");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "19044"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2022-0227
- partner = partnerService.getById("009"); // 009
+ partner = partnerService.getByName("JamoDat"); // 009
completionDate = formatter.parse("2022-12-22");
createDate = formatter.parse("2022-12-22");
paymentDeadline = formatter.parse("2023-01-26");
grossAmount = netAmount * 1.27; // Ez a számla ÁFA-mentes !!!!
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "9171058452"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2022-0227
- partner = partnerService.getById("010"); // 010
+ partner = partnerService.getByName("S&T Consulting Kft."); // 010
completionDate = formatter.parse("2022-12-30");
createDate = formatter.parse("2023-01-13");
paymentDeadline = formatter.parse("2023-02-12");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "9171058628"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2022-0227
- partner = partnerService.getById("010"); // 010
+ partner = partnerService.getByName("S&T Consulting Kft."); // 010
completionDate = formatter.parse("2023-01-12");
createDate = formatter.parse("2023-01-19");
paymentDeadline = formatter.parse("2023-02-18");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "9171058628"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2022-0227
- partner = partnerService.getById("011"); // 011
+ partner = partnerService.getByName("SHT Kft."); // 011
completionDate = formatter.parse("2022-12-23");
createDate = formatter.parse("2022-12-23");
paymentDeadline = formatter.parse("2023-01-07");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "2022-SOV/000495"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2022-0227
- partner = partnerService.getById("012"); // 012
+ partner = partnerService.getByName("SoftOne Kft."); // 012
completionDate = formatter.parse("2022-12-31");
createDate = formatter.parse("2022-12-31");
paymentDeadline = formatter.parse("2023-01-30");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "2022-SOV/000496"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2022-0227
- partner = partnerService.getById("012"); // 012
+ partner = partnerService.getByName("SoftOne Kft."); // 012
completionDate = formatter.parse("2022-12-31");
createDate = formatter.parse("2022-12-31");
paymentDeadline = formatter.parse("2023-01-30");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "E-SYMPR-2022-105"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2022-0227
- partner = partnerService.getById("013"); // 013
+ partner = partnerService.getByName("Symport Holding Zrt."); // 013
completionDate = formatter.parse("2022-12-28");
createDate = formatter.parse("2022-12-28");
paymentDeadline = formatter.parse("2023-01-27");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "17356/23"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2023-0018
- partner = partnerService.getById("014"); // 014
+ partner = partnerService.getByName("Blue Store Kft."); // 014
completionDate = formatter.parse("2023-02-06");
createDate = formatter.parse("2023-02-06");
paymentDeadline = formatter.parse("2023-03-08");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "2023-SOV/000123"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2023-0054
- partner = partnerService.getById("012"); // 012
+ partner = partnerService.getByName("SoftOne Kft."); // 012
completionDate = formatter.parse("2023-04-14");
createDate = formatter.parse("2023-04-17");
paymentDeadline = formatter.parse("2023-05-17");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
result.add(entity);
} else {
- String id = RandomStringUtils.random(8, "0123456789abcdef");
String humanId = "USER-2023-7"; // szamla sorszam
String title = dataGeneratorService.faker().commerce().productName(); // 2022-0027
- Partner partner = partnerService.getById("002"); // 002
+ Partner partner = partnerService.getByName("Agrárminisztérium"); // 002
Date completionDate = formatter.parse("2023-02-23");
Date createDate = formatter.parse("2023-02-23");
Date paymentDeadline = formatter.parse("2023-03-25");
double grossAmount = netAmount * 1.27;
double vatAmount = grossAmount - netAmount;
Invoice entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "2021/0001"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2020-0109
- partner = partnerService.getById("007"); // 007
+ partner = partnerService.getByName("The IT Solutions Kft."); // 007
completionDate = formatter.parse("2020-12-31");
createDate = formatter.parse("2021-01-04");
paymentDeadline = formatter.parse("2021-04-04");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- // csak a kimeno szamlak generalasa
- id = RandomStringUtils.random(8, "0123456789abcdef");
+ // csak a kimeno szamlak generalasa
humanId = "2021/0069"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2020-0109
- partner = partnerService.getById("007"); // 007
+ partner = partnerService.getByName("The IT Solutions Kft."); // 007
completionDate = formatter.parse("2021-03-09");
createDate = formatter.parse("2021-03-10");
paymentDeadline = formatter.parse("2021-06-08.");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "E-USER-2023-12"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2022-0227
- partner = partnerService.getById("017"); // 017
+ partner = partnerService.getByName("MKB Bank Zrt."); // 017
completionDate = formatter.parse("2022-12-31");
createDate = formatter.parse("2023-01-06");
paymentDeadline = formatter.parse("2023-03-07");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "E-USER-2023-13"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2022-0227
- partner = partnerService.getById("017"); // 017
+ partner = partnerService.getByName("MKB Bank Zrt."); // 017
completionDate = formatter.parse("2022-12-31");
createDate = formatter.parse("2023-01-06");
paymentDeadline = formatter.parse("2023-03-07");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "E-USER-2023-53"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2023-0018
- partner = partnerService.getById("015"); // 015
+ partner = partnerService.getByName("HírTV Zrt."); // 015
completionDate = formatter.parse("2023-02-08");
createDate = formatter.parse("2023-02-09.");
paymentDeadline = formatter.parse("2023-03-08");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "E-USER-2023-95"; // szamla sorszam
title = dataGeneratorService.faker().commerce().productName(); // 2023-0054
- partner = partnerService.getById("016"); // 016
+ partner = partnerService.getByName("Groupama Biztosító Zrt."); // 016
completionDate = formatter.parse("2023-04-14");
createDate = formatter.parse("2023-04-17");
paymentDeadline = formatter.parse("2023-05-17");
grossAmount = netAmount * 1.27;
vatAmount = grossAmount - netAmount;
entity = Invoice.builder()
- .id(id)
.humanId(humanId)
.title(title)
.currency(currency)
}
-
@Override
public List<Invoice> getRandom(boolean income) {
getAll();
public interface PartnerService {
List<Partner> getAll();
+ void setAll(List<Partner> entities);
+
Partner createNew();
void add(Partner entity);
String toString(Partner sourceEntity) throws JsonProcessingException;
Partner copy(Partner sourceEntity, String property, Object value) throws JsonProcessingException, NoSuchFieldException, IllegalAccessException;
+
+ Partner getByName(String name);
}
return entities;
}
+ @Override
+ public void setAll(List<Partner> entities) {
+ this.entities = entities;
+ }
+
@Override
public Partner createNew() {
- String id = RandomStringUtils.random(8, "0123456789abcdef");
- return Partner.builder().id(id).active(true).build();
+ return Partner.builder().active(true).build();
}
@Override
address.city(),
address.streetName(),
address.buildingNumber());
- Partner partner = Partner.builder().active(true).id(id).name(name).vatNr(vatNr).address(fullAddress).build();
+ Partner partner = Partner.builder().active(true).name(name).vatNr(vatNr).address(fullAddress).build();
result.add(partner);
}
return result;
private List<Partner> generate2() {
List<Partner> result = new ArrayList<>();
- String id = "001";
String name = "ServerUnite Kft.";
- Partner partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1151 Budapest, Mogyoród útja 42.").build();
+ Partner partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1151 Budapest, Mogyoród útja 42.").build();
result.add(partner);
- id = "002";
name = "Agrárminisztérium";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1055 Budapest, Kossuth Lajos tér 11.").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1055 Budapest, Kossuth Lajos tér 11.").build();
result.add(partner);
- id = "003";
name = "DNS Hungária Kft.";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1027 Budapest, Kapás u. 11.").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1027 Budapest, Kapás u. 11.").build();
result.add(partner);
- id = "004";
+
name = "Arrow ECS Kft.";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1117 Budapest, Infopark stny. 3. B-épület, V. emelet").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1117 Budapest, Infopark stny. 3. B-épület, V. emelet").build();
result.add(partner);
- id = "005";
name = "Tech Data - TD Synnex Kft.";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1117 Budapest, Budafoki út 91-93.").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1117 Budapest, Budafoki út 91-93.").build();
result.add(partner);
- id = "006";
name = "The IT Solutions Kft.";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1141 Budapest, Vezér u. 106-108.").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1141 Budapest, Vezér u. 106-108.").build();
result.add(partner);
- id = "007";
name = "Techwave Hungary Zrt.";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1138 Budapest, Dunavirág u. 2-6.").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1138 Budapest, Dunavirág u. 2-6.").build();
result.add(partner);
- id = "008";
name = "Clico Hungary Kft.";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1134 Budapest, Dévai u. 26-28.").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1134 Budapest, Dévai u. 26-28.").build();
result.add(partner);
- id = "009";
name = "JamoDat";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("4700 Naestved, Salto Skovvange 36, Denmark").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("4700 Naestved, Salto Skovvange 36, Denmark").build();
result.add(partner);
- id = "010";
name = "S&T Consulting Kft.";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("2040 Budaörs, Puskás Tivadar út 14.").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("2040 Budaörs, Puskás Tivadar út 14.").build();
result.add(partner);
- id = "011";
name = "SHT Kft.";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1047 Budapest, Baross u. 79.").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1047 Budapest, Baross u. 79.").build();
result.add(partner);
- id = "012";
name = "SoftOne Kft.";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1052 Budapest, Deák Ferenc tér 3.").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1052 Budapest, Deák Ferenc tér 3.").build();
result.add(partner);
- id = "013";
name = "Symport Holding Zrt.";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1031 Budapest, Záhony u. 7.").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1031 Budapest, Záhony u. 7.").build();
result.add(partner);
- id = "014";
name = "Blue Store Kft.";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1118 Budapest, Budaörsi út 46.").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1118 Budapest, Budaörsi út 46.").build();
result.add(partner);
- id = "015";
name = "HírTV Zrt.";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1149 Budapest, Angol utca 65-69.").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1149 Budapest, Angol utca 65-69.").build();
result.add(partner);
- id = "016";
name = "Groupama Biztosító Zrt.";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1146 Budapest, Erzsébet királyné útja 1. C-épület").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1146 Budapest, Erzsébet királyné útja 1. C-épület").build();
result.add(partner);
- id = "017";
name = "MKB Bank Zrt.";
- partner = Partner.builder().active(true).id(id).name(name).vatNr(generateVatNumber()).address("1056 Budapest, Váci u. 38.").build();
+ partner = Partner.builder().active(true).name(name).vatNr(generateVatNumber()).address("1056 Budapest, Váci u. 38.").build();
result.add(partner);
return result;
return result;
}
+ @Override
+ public Partner getByName(String name) {
+ return getAll().stream().filter(p -> p.getName().equals(name)).findFirst().get();
+ }
+
}
package hu.user.lis.services.data;
+import hu.user.lis.db.Associate;
+import hu.user.lis.db.Project;
import hu.user.lis.db.ProjectAssociate;
-import java.util.Collection;
+import java.util.List;
import java.util.Map;
public interface ProjectAssociateService {
- ProjectAssociate createNew(String projectId, String associateId);
+ ProjectAssociate createNew(Project project, Associate associate);
void add(ProjectAssociate entity);
void remove(ProjectAssociate entity);
- void update(String projectId, Map<String, Boolean> associates);
+ void update(Project project, Map<Associate, Boolean> associates);
String toString(ProjectAssociate sourceEntity);
- Collection<ProjectAssociate> getAll();
+ List<ProjectAssociate> getAll();
}
package hu.user.lis.services.data;
-import com.fasterxml.jackson.databind.ObjectMapper;
import hu.user.lis.db.Associate;
import hu.user.lis.db.Project;
import hu.user.lis.db.ProjectAssociate;
@Service
@Log4j2
public class ProjectAssociateServiceImpl extends DataServiceImpl<ProjectAssociate> implements ProjectAssociateService {
- @Autowired
- ObjectMapper mapper;
@Autowired
ProjectService projectService;
@Autowired
}
@Override
- public ProjectAssociate createNew(String projectId, String associateId) {
- return ProjectAssociate.builder().projectId(projectId).associateId(associateId).build();
+ public ProjectAssociate createNew(Project project, Associate associate) {
+ return ProjectAssociate.builder().project(project).associate(associate).build();
}
@Override
}
@Override
- public void update(String projectId, Map<String, Boolean> associates) {
- List<ProjectAssociate> deleteEntities = entities.stream().filter(pa -> pa.getProjectId().equals(projectId)).collect(Collectors.toList());
+ public void update(Project project, Map<Associate, Boolean> associates) {
+ List<ProjectAssociate> deleteEntities = entities.stream().filter(pa -> pa.getProject().getId().equals(project.getId())).collect(Collectors.toList());
entities.removeAll(deleteEntities);
- associates.forEach((associateId, isAssociate) -> {
+ associates.forEach((associate, isAssociate) -> {
if (isAssociate) {
- ProjectAssociate projectAssociate = ProjectAssociate.builder().projectId(projectId).associateId(associateId).build();
+ ProjectAssociate projectAssociate = ProjectAssociate.builder().project(project).associate(associate).build();
entities.add(projectAssociate);
}
});
int associatesCount = RandomUtils.nextInt(1, 5);
for (int i = 0; i < associatesCount; i++) {
Associate associate = associateService.getRandom();
- ProjectAssociate entity = ProjectAssociate.builder().projectId(project.getId()).associateId(associate.getId()).build();
+ ProjectAssociate entity = ProjectAssociate.builder().project(project).associate(associate).build();
result.add(entity);
}
}
public interface ProjectService {
List<Project> getAll();
+ void setAll(List<Project> entities);
+
Project getById(String id);
List<Project> getByPartner(String id);
import hu.user.lis.db.Partner;
import hu.user.lis.db.Project;
+import hu.user.lis.db.ProjectStatus;
import lombok.extern.log4j.Log4j2;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
TreasuryService treasuryService;
@Autowired
ProjectStatusService projectStatusService;
+
private List<Project> entities;
@Override
return entities;
}
+ @Override
+ public void setAll(List<Project> entities) {
+ this.entities = entities;
+ }
+
@Override
public Project getById(String id) {
return getAll().stream().filter(p -> p.getId().equals(id)).findFirst().get();
@Override
public Project createNew() {
- String id = RandomStringUtils.random(8, "0123456789abcdef");
String humanId = dataGeneratorService.faker().code().isbn13(true);
- String projectStatusId = projectStatusService.getAll().get(0).getId();
+ ProjectStatus projectStatus = projectStatusService.getAll().get(0);
return Project.builder()
- .projectStatusId(projectStatusId)
- .id(id)
+ .projectStatus(projectStatus)
.humanId(humanId)
.incomingInvoices(new ArrayList<>())
.outgoingInvoices(new ArrayList<>())
List<Project> result = new ArrayList<>();
DateFormat dateFormat = new SimpleDateFormat("yyyy");
for (int i = 0; i < 20; i++) {
- String id = RandomStringUtils.random(8, "0123456789abcdef");
- String projectStatusId = projectStatusService.getAll().get(0).getId();
+ ProjectStatus projectStatus = projectStatusService.getAll().get(0);
String name = dataGeneratorService.faker().commerce().productName();
Date dt = dataGeneratorService.faker().date().past(i + 1, TimeUnit.DAYS);
String humanId = String.format("%s-%s", dateFormat.format(dt), String.format("%04d", i));
String contactName = dataGeneratorService.faker().name().fullName();
Partner partner = partnerService.getRandom();
Project entity = Project.builder()
- .id(id)
- .projectStatusId(projectStatusId)
+ .projectStatus(projectStatus)
.active(true)
.humanId(humanId)
.name(name)
.partner(partner)
.incomingInvoices(invoiceService.getRandom(true))
.outgoingInvoices(invoiceService.getRandom(false))
- //.treasuries(treasuryService.getRandom())
+ .treasuries(new ArrayList<>())
.build();
result.add(entity);
}
private List<Project> generate2() {
List<Project> result = new ArrayList<>();
- String id = dataGeneratorService.faker().code().isbn10(true);
- String projectStatusId = projectStatusService.getAll().get(0).getId();
+ ProjectStatus projectStatus = projectStatusService.getAll().get(0);
String name = "IBM és HP diszkek szállítása régi szerverbe";
String humanId = "2022-0027";
String contactName = dataGeneratorService.faker().name().fullName();
- Partner partner = partnerService.getById("002"); // 002
+
+ Partner partner = partnerService.getByName("Agrárminisztérium"); // 002
Project entity = Project.builder()
- .id(id)
- .projectStatusId(projectStatusId)
+ .projectStatus(projectStatus)
.active(true)
.humanId(humanId)
.name(name)
.partner(partner)
.incomingInvoices(invoiceService.getByHumanIds(new String[]{"VSz-2023/00070-"})) // VSz-2023/00070-
.outgoingInvoices(invoiceService.getByHumanIds(new String[]{"USER-2023-7"})) // USER-2023-7
- //.treasuries(treasuryService.getRandom())
+ .treasuries(new ArrayList<>())
.build();
result.add(entity);
- id = dataGeneratorService.faker().code().isbn10(true);
name = "IBM Power szerver garanciakiterjesztése";
humanId = "2022-0109";
contactName = dataGeneratorService.faker().name().fullName();
- partner = partnerService.getById("007"); // 007
+ partner = partnerService.getByName("Techwave Hungary Zrt."); // 007
entity = Project.builder()
- .id(id)
- .projectStatusId(projectStatusId)
+ .projectStatus(projectStatus)
.active(true)
.humanId(humanId)
.name(name)
.partner(partner)
.incomingInvoices(invoiceService.getByHumanIds(new String[]{"582-SPI1003006-3021", "582-SPI003118", "582-SPI003680", "582-SPI003681", "582-SPI004090", "9090010764", "VSz-2021/00091"})) // 582-SPI1003006-3021, 582-SPI003118, 582-SPI003680, 582-SPI003681, 582-SPI004090, 9090010764, VSz-2021/00091
.outgoingInvoices(invoiceService.getByHumanIds(new String[]{"2021/0001", "2021/0069"})) // 2021/0001, 2021/0069
- .treasuries(treasuryService.getByHumanIds(new String[]{"014","015"}))
+ .treasuries(treasuryService.getByHumanIds(new String[]{"014", "015"}))
.build();
result.add(entity);
- id = dataGeneratorService.faker().code().isbn10(true);
name = "Multivendor 2023 évre";
humanId = "2022-0227";
contactName = dataGeneratorService.faker().name().fullName();
- partner = partnerService.getById("017"); // 017
+ partner = partnerService.getByName("MKB Bank Zrt."); // 017
entity = Project.builder()
- .id(id)
- .projectStatusId(projectStatusId)
+ .projectStatus(projectStatus)
.active(true)
.humanId(humanId)
.name(name)
.build();
result.add(entity);
- id = dataGeneratorService.faker().code().isbn10(true);
name = "LTO8 szalagok szállítása";
humanId = "2023-0018";
contactName = dataGeneratorService.faker().name().fullName();
- partner = partnerService.getById("015"); // 015
+ partner = partnerService.getByName("HírTV Zrt."); // 015
entity = Project.builder()
- .id(id)
- .projectStatusId(projectStatusId)
+ .projectStatus(projectStatus)
.active(true)
.humanId(humanId)
.name(name)
.partner(partner)
.incomingInvoices(invoiceService.getByHumanIds(new String[]{"17356/23"})) // 17356/23
.outgoingInvoices(invoiceService.getByHumanIds(new String[]{"E-USER-2023-53"})) // E-USER-2023-53
- //.treasuries(treasuryService.getRandom())
+ .treasuries(new ArrayList<>())
.build();
result.add(entity);
- id = dataGeneratorService.faker().code().isbn10(true);
name = "PowerBuilder Professional licencek szállítása";
humanId = "2023-0054";
contactName = dataGeneratorService.faker().name().fullName();
- partner = partnerService.getById("016"); // 016
+ partner = partnerService.getByName("Groupama Biztosító Zrt."); // 016
entity = Project.builder()
- .id(id)
- .projectStatusId(projectStatusId)
+ .projectStatus(projectStatus)
.active(true)
.humanId(humanId)
.name(name)
public interface ProjectStatusService extends DataService<ProjectStatus> {
List<ProjectStatus> getAll();
- ProjectStatus getById(String id);
+ ProjectStatus getById(Object id);
ProjectStatus createNew();
import hu.user.lis.db.ProjectStatus;
import lombok.extern.log4j.Log4j2;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
import java.util.Comparator;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.stream.Collectors;
@Service
@Log4j2
public class ProjectStatusServiceImpl extends DataServiceImpl<ProjectStatus> implements ProjectStatusService {
- private Map<String, ProjectStatus> entities;
+ private List<ProjectStatus> entities;
@Override
public List<ProjectStatus> getAll() {
if (entities == null) {
+
+ //projectStatusRepository.findAll()
entities = generate();
}
- return entities.values().stream().sorted(Comparator.comparing(ProjectStatus::getOrder)).collect(Collectors.toList());
+ return entities.stream().sorted(Comparator.comparing(ProjectStatus::getOrder)).collect(Collectors.toList());
}
@Override
- public ProjectStatus getById(String id) {
- return entities.get(id);
+ public ProjectStatus getById(Object id) {
+ return entities.stream().filter(e -> e.getId().equals(id)).findFirst().get();
}
@Override
public ProjectStatus createNew() {
- String id = RandomStringUtils.random(8, "0123456789abcdef");
- ProjectStatus result = ProjectStatus.builder().id(id).active(true).order(entities.size() + 1).build();
- entities.put(result.getId(), result);
+ ProjectStatus result = ProjectStatus.builder().active(true).order(entities.size() + 1).build();
+ entities.add(result);
return result;
}
@Override
public void add(ProjectStatus entity) {
- entities.put(entity.getId(), entity);
+ entities.add(entity);
}
@Override
public void replace(ProjectStatus targetEntity, ProjectStatus replacementEntity) {
- entities.put(replacementEntity.getId(), replacementEntity);
+ ProjectStatus entity = getById(targetEntity.getId());
+ int i = entities.indexOf(entity);
+ entities.remove(i);
+ entities.add(i, replacementEntity);
}
@Override
return getAll().get(RandomUtils.nextInt(0, entities.size()));
}
- private void createStatus(String name, Map<String, ProjectStatus> entities) {
+ private void createStatus(String name, List<ProjectStatus> entities) {
ProjectStatus entity = ProjectStatus.builder()
.active(true)
- .id(RandomStringUtils.random(8, "0123456789abcdef"))
.name(name)
.order(entities.size() + 1)
.build();
- entities.put(entity.getId(), entity);
+ entities.add(entity);
}
- private Map<String, ProjectStatus> generate() {
- Map<String, ProjectStatus> result = new HashMap<>();
+ private List<ProjectStatus> generate() {
+ List<ProjectStatus> result = new ArrayList<>();
createStatus("Új", result);
createStatus("Terv", result);
createStatus("Készül az ajánlat", result);
import java.util.List;
-public interface ServiceRecordService {
+public interface ServiceRecordService extends DataService<ServiceRecord> {
List<ServiceRecord> getAll();
ServiceRecord getById(String id);
void add(ServiceRecord entity);
- ServiceRecord copy(ServiceRecord sourceEntity);
-
void calculateCost(ServiceRecord entity);
void replace(ServiceRecord targetEntity, ServiceRecord replacementEntity);
-
- String toString(ServiceRecord sourceEntity);
-
- ServiceRecord copy(ServiceRecord sourceEntity, String property, Object value);
}
package hu.user.lis.services.data;
-import hu.user.lis.db.Associate;
import hu.user.lis.db.Project;
import hu.user.lis.db.ServiceRecord;
import lombok.extern.log4j.Log4j2;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
@Service
@Log4j2
@Autowired
ProjectService projectService;
@Autowired
+ ProjectAssociateService projectAssociateService;
+ @Autowired
AssociateService associateService;
private List<ServiceRecord> entities;
@Override
public List<ServiceRecord> getByProject(String id) {
- return getAll().stream().filter(p -> p.getProject().getId().equals(id)).collect(Collectors.toList());
+// return getAll().stream().filter(p -> p.getProject().getId().equals(id)).collect(Collectors.toList());
+ return null;
}
@Override
public ServiceRecord createNew() {
- String id = RandomStringUtils.random(8, "0123456789abcdef");
- return ServiceRecord.builder()
- .id(id)
- .build();
+ return ServiceRecord.builder().build();
}
@Override
public void calculateCost(ServiceRecord entity) {
double cost = 0;
try {
- cost = (entity.getAssociate().getMonthlyCost() * entity.getWorkHours()) / (21 * 8);
- entity.setCost(cost);
+ if (Objects.nonNull(entity.getAssociate()) && entity.getWorkHours() > 0) {
+ cost = (entity.getAssociate().getMonthlyCost() * entity.getWorkHours()) / (21 * 8);
+ entity.setCost(cost);
+ }
} catch (Exception e) {
log.catching(e);
}
private List<ServiceRecord> generate() {
List<ServiceRecord> result = new ArrayList<>();
-
- projectService.getAll().forEach(p -> {
- int serviceRecordCount = RandomUtils.nextInt(3, 10);
- for (int i = 0; i < serviceRecordCount; i++) {
- String id = RandomStringUtils.random(8, "0123456789abcdef");
- Date workDay = dataGeneratorService.faker().date().past(i * 10 + 1, TimeUnit.DAYS);
- Associate associate = associateService.getRandom();
- String description = dataGeneratorService.faker().lorem().sentence(10);
- int workHours = RandomUtils.nextInt(1, 9);
- ServiceRecord entity = ServiceRecord.builder()
- .associate(associate)
- .project(p)
- .workDay(workDay)
- .workHours(workHours)
- .description(description)
- .id(id)
- .build();
- calculateCost(entity);
- result.add(entity);
-
- id = RandomStringUtils.random(8, "0123456789abcdef");
- entity = ServiceRecord.builder()
- .associate(associate)
- .project(p)
- .workDay(workDay)
- .workHours(workHours)
- .description(description)
- .id(id)
- .build();
- calculateCost(entity);
- result.add(entity);
-
-
- }
-
- });
+ Date workDay = dataGeneratorService.faker().date().past(10 + 1, TimeUnit.DAYS);
+ String description = dataGeneratorService.faker().lorem().sentence(10);
+ int workHours = RandomUtils.nextInt(1, 9);
+ ServiceRecord entity = ServiceRecord.builder()
+ .associate(associateService.getRandom())
+ .project(projectService.getRandom())
+ .workDay(workDay)
+ .workHours(workHours)
+ .description(description)
+ .build();
+ calculateCost(entity);
+ result.add(entity);
+
+// projectService.getAll().forEach(p -> {
+// int serviceRecordCount = RandomUtils.nextInt(3, 10);
+//
+// List<ProjectAssociate> projectAssociates = projectAssociateService.getAll().stream().filter(e -> e.getProject().getId().equals(p.getId())).collect(Collectors.toList());
+// projectAssociates.forEach(pa -> {
+// for (int i = 0; i < serviceRecordCount; i++) {
+// Date workDay = dataGeneratorService.faker().date().past(i * 10 + 1, TimeUnit.DAYS);
+// String description = dataGeneratorService.faker().lorem().sentence(10);
+// int workHours = RandomUtils.nextInt(1, 9);
+// ServiceRecord entity = ServiceRecord.builder()
+// .associate(pa.getAssociate())
+// .project(pa.getProject())
+// .workDay(workDay)
+// .workHours(workHours)
+// .description(description)
+// .build();
+// calculateCost(entity);
+// result.add(entity);
+//
+// entity = ServiceRecord.builder()
+// .associate(pa.getAssociate())
+// .project(pa.getProject())
+// .workDay(workDay)
+// .workHours(workHours)
+// .description(description)
+// .build();
+// calculateCost(entity);
+// result.add(entity);
+// }
+// });
+// });
return result;
}
private List<Supplier> generate() {
List<Supplier> result = new ArrayList<>();
for (int i = 0; i < 100; i++) {
- String id = RandomStringUtils.random(8, "0123456789abcdef");
String name = dataGeneratorService.faker().name().fullName();
String zipCode = RandomStringUtils.random(4, "0123456789");
- Supplier supplier = Supplier.builder().id(id).name(name).zipCode(zipCode).build();
+ Supplier supplier = Supplier.builder().name(name).zipCode(zipCode).build();
result.add(supplier);
}
return result;
@Override
public Treasury createNew() {
- String id = RandomStringUtils.random(8, "0123456789abcdef");
- return Treasury.builder().id(id).build();
+ return Treasury.builder().build();
}
private List<Treasury> generate() throws ParseException {
double buyAmount = RandomUtils.nextFloat(500, 100000);
double sellAmount = RandomUtils.nextFloat(500, 100000);
Treasury entity = Treasury.builder()
- .id(id)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.transactionDate(transactionDate)
List<Treasury> result = new ArrayList<>();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
- String id = RandomStringUtils.random(8, "0123456789abcdef");
String humanId = "001";
Date transactionDate = formatter.parse("2023-01-09");
Date valueDate = formatter.parse("2023-01-09");
double buyAmount = 12065.0;
double sellAmount = 0.0;
Treasury entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "002";
transactionDate = formatter.parse("2023-01-25");
valueDate = formatter.parse("2023-01-25");
buyAmount = 390.0;
sellAmount = 0.0;
entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "003";
transactionDate = formatter.parse("2023-01-27");
valueDate = formatter.parse("2023-01-27");
buyAmount = 66686.33;
sellAmount = 0.0;
entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "004";
transactionDate = formatter.parse("2023-01-27");
valueDate = formatter.parse("2023-01-27");
buyAmount = 3016.38;
sellAmount = 0.0;
entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "005";
transactionDate = formatter.parse("2023-01-30");
valueDate = formatter.parse("2023-01-30");
buyAmount = 20204.75;
sellAmount = 0.0;
entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "006";
transactionDate = formatter.parse("2023-01-30");
valueDate = formatter.parse("2023-01-30");
buyAmount = 56502.34;
sellAmount = 0.0;
entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "007";
transactionDate = formatter.parse("2023-02-06");
valueDate = formatter.parse("2023-02-06");
buyAmount = 2672749.00;
sellAmount = 0.0;
entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "008";
transactionDate = formatter.parse("2023-02-10");
valueDate = formatter.parse("2023-02-10");
buyAmount = 28573.73;
sellAmount = 0.0;
entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "009";
transactionDate = formatter.parse("2023-02-10");
valueDate = formatter.parse("2023-02-10");
buyAmount = 38.10;
sellAmount = 0.0;
entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "010";
transactionDate = formatter.parse("2023-03-29");
valueDate = formatter.parse("2023-03-29");
buyAmount = 0.0;
sellAmount = 199089.20;
entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "011";
transactionDate = formatter.parse("2023-03-31");
valueDate = formatter.parse("2023-03-31");
buyAmount = 0.0;
sellAmount = 85871.39;
entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "012";
transactionDate = formatter.parse("2023-05-17");
valueDate = formatter.parse("2023-05-17");
buyAmount = 0.0;
sellAmount = 18411.19;
entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "013";
transactionDate = formatter.parse("2023-05-17");
valueDate = formatter.parse("2023-05-17");
buyAmount = 0.0;
sellAmount = 17928.59;
entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "014";
transactionDate = formatter.parse("2020-10-15");
valueDate = formatter.parse("2021-03-25");
buyAmount = 224113.70;
sellAmount = 78439795.00;
entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
.build();
result.add(entity);
- id = RandomStringUtils.random(8, "0123456789abcdef");
humanId = "015";
transactionDate = formatter.parse("2020-10-15");
valueDate = formatter.parse("2021-04-15");
buyAmount = 64955.00;
sellAmount = 23513710.00;
entity = Treasury.builder()
- .id(id)
.humanId(humanId)
.buyCurrency(buyCurrency)
.sellCurrency(sellCurrency)
--- /dev/null
+package hu.user.lis.services.nosql;
+
+import hu.user.lis.db.Associate;
+import hu.user.lis.services.data.AssociateService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class AssociateDbService extends DbService<Associate> {
+ public static final String ID = "id";
+ public static final String NAME = "name";
+ public static final String ACTIVE = "active";
+ public static final String LOGIN = "login";
+ public static final String PASSWORD = "password";
+ public static final String MONTHLY_COST = "monthlyCost";
+ @Autowired
+ AssociateService associateService;
+
+ @Override
+ protected Class<Associate> getEntityClass() {
+ return Associate.class;
+ }
+
+ @Override
+ protected List<Associate> generateEntities() {
+ return associateService.getAll();
+ }
+
+ @Override
+ protected void afterGenerateEntities(List<Associate> entities) {
+ associateService.setAll(entities);
+ }
+
+}
--- /dev/null
+package hu.user.lis.services.nosql;
+
+import com.mongodb.client.MongoCollection;
+import org.bson.Document;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public abstract class DbService<T> {
+ @Autowired
+ MongoTemplate mongoTemplate;
+
+ protected abstract Class<T> getEntityClass();
+
+ public List<T> list() {
+ return mongoTemplate.findAll(getEntityClass());
+ }
+
+ public List<T> list(Query query) {
+ return mongoTemplate.find(query, getEntityClass());
+ }
+
+ public long count(Query query) {
+ return mongoTemplate.count(query, getEntityClass());
+ }
+
+ public T get(String id) {
+ return mongoTemplate.findById(id, getEntityClass());
+ }
+
+ public T insert(T entity) {
+ mongoTemplate.insert(entity);
+ return entity;
+ }
+
+ public T save(T entity) {
+ return mongoTemplate.save(entity);
+ }
+
+ public void reset() {
+ String collectionName = mongoTemplate.getCollectionName(getEntityClass());
+ MongoCollection<Document> collection = mongoTemplate.getCollection(collectionName);
+ if (collection != null) {
+ collection.drop();
+ }
+ }
+
+ public List<T> generate() {
+ reset();
+ List<T> result = generateEntities();
+ mongoTemplate.insertAll(result);
+ afterGenerateEntities(result);
+ return result;
+ }
+
+ protected abstract List<T> generateEntities();
+
+ protected void afterGenerateEntities(List<T> entities) {
+ }
+
+}
--- /dev/null
+package hu.user.lis.services.nosql;
+
+import hu.user.lis.db.Invoice;
+import hu.user.lis.services.data.InvoiceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class InvoiceDbService extends DbService<Invoice> {
+ @Autowired
+ InvoiceService invoiceService;
+
+ @Override
+ protected Class<Invoice> getEntityClass() {
+ return Invoice.class;
+ }
+
+ @Override
+ protected List<Invoice> generateEntities() {
+ return invoiceService.getAll();
+ }
+
+ @Override
+ protected void afterGenerateEntities(List<Invoice> entities) {
+ invoiceService.setAll(entities);
+ }
+}
--- /dev/null
+package hu.user.lis.services.nosql;
+
+import hu.user.lis.db.Partner;
+import hu.user.lis.services.data.PartnerService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class PartnerDbService extends DbService<Partner> {
+ public static final String ID = "id";
+ public static final String NAME = "name";
+ public static final String VAT_NR = "vatNr";
+ public static final String ADDRESS = "address";
+ @Autowired
+ PartnerService partnerService;
+
+ @Override
+ protected Class<Partner> getEntityClass() {
+ return Partner.class;
+ }
+
+ @Override
+ protected List<Partner> generateEntities() {
+ return partnerService.getAll();
+ }
+
+ @Override
+ protected void afterGenerateEntities(List<Partner> entities) {
+ partnerService.setAll(entities);
+ }
+}
--- /dev/null
+package hu.user.lis.services.nosql;
+
+import hu.user.lis.db.ProjectAssociate;
+import hu.user.lis.services.data.ProjectAssociateService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class ProjectAssociateDbService extends DbService<ProjectAssociate> {
+ @Autowired
+ ProjectAssociateService projectAssociateService;
+
+ @Override
+ protected Class<ProjectAssociate> getEntityClass() {
+ return ProjectAssociate.class;
+ }
+
+ @Override
+ protected List<ProjectAssociate> generateEntities() {
+ return projectAssociateService.getAll();
+ }
+
+}
--- /dev/null
+package hu.user.lis.services.nosql;
+
+import hu.user.lis.db.Project;
+import hu.user.lis.services.data.ProjectService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class ProjectDbService extends DbService<Project> {
+ @Autowired
+ ProjectService projectService;
+
+ @Override
+ protected Class<Project> getEntityClass() {
+ return Project.class;
+ }
+
+ @Override
+ protected List<Project> generateEntities() {
+ return projectService.getAll();
+ }
+
+ @Override
+ protected void afterGenerateEntities(List<Project> entities) {
+ projectService.setAll(entities);
+ }
+}
--- /dev/null
+package hu.user.lis.services.nosql;
+
+import hu.user.lis.db.ProjectStatus;
+import hu.user.lis.services.data.ProjectStatusService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class ProjectStatusDbService extends DbService<ProjectStatus> {
+ public final String ID = "id";
+ public final String NAME = "name";
+ public final String ACTIVE = "active";
+ public final String ORDER = "order";
+ @Autowired
+ ProjectStatusService projectStatusService;
+
+ @Override
+ protected Class<ProjectStatus> getEntityClass() {
+ return ProjectStatus.class;
+ }
+
+ @Override
+ protected List<ProjectStatus> generateEntities() {
+ return projectStatusService.getAll();
+ }
+
+}
--- /dev/null
+package hu.user.lis.services.nosql;
+
+import hu.user.lis.db.ServiceRecord;
+import hu.user.lis.services.data.ServiceRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class ServiceRecordDbService extends DbService<ServiceRecord> {
+ public static final String ID = "id";
+ public static final String PROJECT_ID = "projectId";
+ public static final String ASSOCIATE_ID = "associateId";
+ @Autowired
+ ServiceRecordService serviceRecordService;
+
+ @Override
+ protected Class<ServiceRecord> getEntityClass() {
+ return ServiceRecord.class;
+ }
+
+ @Override
+ protected List<ServiceRecord> generateEntities() {
+ return serviceRecordService.getAll();
+ }
+
+}
--- /dev/null
+package hu.user.lis.services.nosql;
+
+import hu.user.lis.db.Treasury;
+import hu.user.lis.services.data.TreasuryService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class TreasuryDbService extends DbService<Treasury> {
+ @Autowired
+ TreasuryService treasuryService;
+
+ @Override
+ protected Class<Treasury> getEntityClass() {
+ return Treasury.class;
+ }
+
+ @Override
+ protected List<Treasury> generateEntities() {
+ return treasuryService.getAll();
+ }
+}
import hu.user.lis.db.ProjectStatus;
import hu.user.lis.services.data.ProjectStatusService;
-import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.zkoss.bind.BindContext;
import org.zkoss.zul.Selectbox;
import org.zkoss.zul.ext.Selectable;
+import java.util.Objects;
+
@Component
-public class ProjectStatusConverter implements Converter<Object, String, Selectbox> {
+public class ProjectStatusConverter implements Converter<Object, ProjectStatus, Selectbox> {
@Autowired
ProjectStatusService projectStatusService;
@Override
- public Object coerceToUi(String id, Selectbox box, BindContext bindContext) {
- if (StringUtils.isBlank(id)) {
+ public Object coerceToUi(ProjectStatus projectStatus, Selectbox box, BindContext bindContext) {
+ if (Objects.isNull(projectStatus)) {
return IGNORED_VALUE;
}
- ProjectStatus projectStatus = projectStatusService.getById(id);
final ListModel<?> model = box.getModel();
((Selectable<Object>) model).clearSelection();
- ((Selectable<Object>) model).addToSelection(projectStatus);
+ for (int i = 0; i < model.getSize(); i++) {
+ ProjectStatus status = (ProjectStatus) model.getElementAt(i);
+ if (status.getId().equals(projectStatus.getId())) {
+ return i;
+ }
+ }
return IGNORED_VALUE;
}
@Override
- public String coerceToBean(Object order, Selectbox bandbox, BindContext bindContext) {
- ProjectStatus projectStatus = projectStatusService.getAll().get((Integer) order);
- return projectStatus.getId();
+ public ProjectStatus coerceToBean(Object order, Selectbox bandbox, BindContext bindContext) {
+ return projectStatusService.getAll().get((Integer) order);
}
}
\ No newline at end of file
package hu.user.lis.ui.data;
import hu.user.lis.db.Associate;
-import hu.user.lis.services.data.AssociateService;
+import hu.user.lis.services.nosql.AssociateDbService;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import org.zkoss.bind.BindUtils;
import org.zkoss.zul.FieldComparator;
-import java.util.Comparator;
import java.util.List;
-import java.util.stream.Collectors;
@Component
@Log4j2
public class AssociateSelectorDataModel extends CachedDataModel<Associate> {
static private final int SEARCH_LIMIT = 10;
@Autowired
- AssociateService associateService;
+ AssociateDbService associateDbService;
private String partialName;
- private boolean filter(Associate associate) {
- if (StringUtils.isBlank(partialName)) {
- return true;
- } else {
- if (associate.getName().toLowerCase().startsWith(partialName.toLowerCase())) {
- return true;
- }
+ private Query filter() {
+ Query result = new Query();
+ if (StringUtils.isNotBlank(partialName)) {
+ result.addCriteria(Criteria.where(AssociateDbService.NAME).regex("/^" + partialName + "/i"));
}
- return false;
+ result.addCriteria(Criteria.where(AssociateDbService.ACTIVE).is(true));
+ return result;
}
@Override
- protected List<Associate> getResultSet(long offset, int limit, FieldComparator sortComparator) {
- List<Associate> result = associateService.getAll().stream()
- .sorted(Comparator.comparing(Associate::getName))
- .filter(s -> filter(s))
- .limit(SEARCH_LIMIT)
- .collect(Collectors.toList());
+ protected List<Associate> getResultSet(int page, int pageSize, FieldComparator sortComparator) {
+ Query query = filter();
+ query.with(Sort.by(Sort.Direction.ASC, AssociateDbService.NAME));
+ query.with(PageRequest.of(page, pageSize));
+ List<Associate> result = associateDbService.list(query);
return result;
}
@Override
public int getResultSetCount() {
- int result = (int) associateService.getAll().stream()
- .filter(s -> filter(s))
- .limit(SEARCH_LIMIT)
- .count();
- return result;
+ Query query = filter();
+ int result = (int) associateDbService.count(query);
+ return result > SEARCH_LIMIT ? SEARCH_LIMIT : result;
}
public void search(String partialName) {
import hu.user.lis.db.Associate;
import hu.user.lis.services.data.AssociateService;
-import lombok.Getter;
+import hu.user.lis.services.nosql.AssociateDbService;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
-import org.zkoss.bind.BindUtils;
import org.zkoss.zul.FieldComparator;
-import java.util.Comparator;
import java.util.List;
-import java.util.stream.Collectors;
@Component
@Log4j2
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class AssociatesDataModel extends CachedDataModel<Associate> {
- @Getter
+ @Autowired
+ AssociateDbService associateDbService;
@Autowired
AssociateService associateService;
private String partialName;
private boolean filterShowInActive;
private boolean filterShowActive;
-
- private boolean canExecuteSearch() {
- boolean result = listAll || filterShowActive || filterShowInActive ||
- StringUtils.isNotBlank(partialName);
- log.info("Can execute search: {}", result);
- return result;
- }
-
- private boolean filter(Associate associate) {
+ private Query filter() {
+ Query result = new Query();
if (listAll) {
- return true;
+ result.addCriteria(Criteria.where(AssociateDbService.ID).gt(0));
+ return result;
}
-
- boolean result = true;
if (StringUtils.isNotBlank(partialName)) {
- if (!associate.getName().toLowerCase().startsWith(partialName.toLowerCase())) {
- result = false;
- }
+ result.addCriteria(Criteria.where(AssociateDbService.NAME).regex("/^" + partialName + "/i"));
}
- if (!filterShowActive && associate.isActive()) {
- result = false;
+ if (filterShowActive && !filterShowInActive) {
+ result.addCriteria(Criteria.where(AssociateDbService.ACTIVE).is(true));
}
-
- if (!filterShowInActive && !associate.isActive()) {
- result = false;
+ if (filterShowInActive && !filterShowActive) {
+ result.addCriteria(Criteria.where(AssociateDbService.ACTIVE).is(false));
}
-
return result;
}
@Override
- protected List<Associate> getResultSet(long offset, int limit, FieldComparator sortComparator) {
- List<Associate> result = null;
- if (canExecuteSearch()) {
- result = associateService.getAll().stream()
- .filter(s -> filter(s))
- .sorted(Comparator.comparing(Associate::getName, String.CASE_INSENSITIVE_ORDER))
- .collect(Collectors.toList());
+ protected List<Associate> getResultSet(int page, int pageSize, FieldComparator sortComparator) {
+ Query query = filter();
+ if (sortComparator != null) {
+ String orderBy = sortComparator.getRawOrderBy();
+ Sort.Direction direction = sortComparator.isAscending() ? Sort.Direction.ASC : Sort.Direction.DESC;
+ query.with(Sort.by(direction, orderBy));
}
+
+ Pageable pageable = PageRequest.of(page, pageSize);
+ query.with(pageable);
+
+ List<Associate> result = associateDbService.list(query);
return result;
}
@Override
public int getResultSetCount() {
- int result = 0;
- if (canExecuteSearch()) {
- result = (int) associateService.getAll().stream()
- .filter(s -> filter(s))
- .count();
- }
- return result;
+ Query query = filter();
+ return (int) associateDbService.count(query);
}
public void search(String partialName) {
this.filterShowInActive = true;
this.partialName = partialName;
super.reset();
- BindUtils.postNotifyChange(null, null, this, "*");
}
+ public void limitedSarch(String partialName) {
+ log.info("Litited searching associate using filters: name LIKE {}", partialName);
+ listAll = false;
+ this.filterShowActive = true;
+ this.filterShowInActive = false;
+ this.partialName = partialName;
+ super.reset();
+ }
public void search(boolean filterShowActive, boolean filterShowInActive) {
log.info("Searching associate using filters: filterShowActive {}, filterShowInActive {}",
filterShowActive, filterShowInActive);
+ listAll = false;
this.filterShowActive = filterShowActive;
this.filterShowInActive = filterShowInActive;
- listAll = false;
super.reset();
- BindUtils.postNotifyChange(null, null, this, "*");
}
public void listAll() {
log.info("List all associates");
listAll = true;
super.reset();
- BindUtils.postNotifyChange(null, null, this, "*");
+ }
+
+ public Associate createNew() {
+ return associateService.createNew();
+ }
+
+ public void addNew(Associate entity) {
+ associateDbService.insert(entity);
+ }
+
+ public Associate copy(Associate selectedEntity) {
+ return associateService.copy(selectedEntity);
+ }
+
+ public Associate save(Associate selectedEntity) {
+ return associateDbService.save(selectedEntity);
}
}
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;
+import org.zkoss.bind.BindUtils;
import org.zkoss.zul.FieldComparator;
import org.zkoss.zul.ListModelList;
+import org.zkoss.zul.event.ListDataEvent;
import java.util.Comparator;
import java.util.HashMap;
@Component
@Log4j2
public abstract class CachedDataModel<T> extends ListModelList<T> {
- private int cacheSize = 10;
+ public static final String NATURAL = "natural";
+ public static final String ASCENDING = "ascending";
+ public static final String DESCENDING = "descending";
+ private int cacheSize = 100;
private int cacheStart;
private int cacheEnd;
private int resultSetSize = -1;
this.cacheEnd = 0;
clearCache();
+ fireEvent(ListDataEvent.STRUCTURE_CHANGED, -1, -1);
+ BindUtils.postNotifyChange(null, null, this, "*");
}
public void clearCache() {
}
log.info("Query result from {} to {}", startPos, endPos);
- List<T> resList = getResultSet(startPos, endPos - startPos, sortComparator);
+
+ int limit = endPos - startPos;
+ int page = (int) Math.ceil(this.resultSetSize / limit);
+ List<T> resList = getResultSet(page, limit, sortComparator);
if (resList != null) {
log.info("Got {} records", resList.size());
for (int c = 0; c < resList.size(); c++) {
- cache.put(startPos + c, resList.get(c));
cache.put(startPos + c, resList.get(c));
// logger.debug("CachedListMode.cached idx: " +
// (startPos + c));
cacheStart = startPos + 1;
cacheEnd = cacheStart + (cache.size() == 0 ? 0 : (cache.size() - 1));
-// BindUtils.postNotifyChange(null, null, this, "*");
-
} catch (Exception e) {
log.error("", e);
}
}
- abstract protected List<T> getResultSet(long offset, int limit, FieldComparator sortComparator);
+ abstract protected List<T> getResultSet(int page, int pageSize, FieldComparator sortComparator);
abstract public int getResultSetCount();
+ @Override
+ public String getSortDirection(Comparator comparator) {
+ FieldComparator fieldCmpr = (FieldComparator) comparator;
+ if (sortComparator == null) {
+ return NATURAL;
+ }
+ String sortDirection = sortComparator.isAscending() ? ASCENDING : DESCENDING;
+ return fieldCmpr.getRawOrderBy().equals(sortComparator.getRawOrderBy()) ? sortDirection : NATURAL;
+ }
@Override
public void sort(Comparator<T> cmpr, boolean ascending) {
@Builder
@Log4j2
public class FormDocument extends JSONObject {
+
private Object data;
public FormDocument setData(Object data) {
@Getter
@Setter
@Builder
-public class IncomeMargin {
+public class
+IncomeMargin {
Currency currency;
Double amount;
}
@Log4j2
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class IncomeMarginsDataModel extends ArrayList<IncomeMargin> {
-
public void recalculate(Project project) {
clear();
Map<Currency, Double> balances = new HashMap<>();
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PartnerSelectorDataModel extends CachedDataModel<Partner> {
static private final int SEARCH_LIMIT = 10;
- private String partialName;
@Autowired
PartnerService partnerService;
+ private String partialName;
private boolean filter(Partner partner) {
if (StringUtils.isBlank(partialName)) {
}
@Override
- protected List<Partner> getResultSet(long offset, int limit, FieldComparator sortComparator) {
+ protected List<Partner> getResultSet(int page, int pageSize, FieldComparator sortComparator) {
List<Partner> result = partnerService.getAll().stream()
.sorted(Comparator.comparing(Partner::getName))
.filter(s -> filter(s))
import hu.user.lis.db.Partner;
import hu.user.lis.services.data.PartnerService;
-import lombok.Getter;
+import hu.user.lis.services.nosql.AssociateDbService;
+import hu.user.lis.services.nosql.PartnerDbService;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
-import org.zkoss.bind.BindUtils;
import org.zkoss.zul.FieldComparator;
-import java.util.Comparator;
import java.util.List;
-import java.util.stream.Collectors;
@Component
@Log4j2
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PartnersDataModel extends CachedDataModel<Partner> {
+ @Autowired
+ PartnerDbService partnerDbService;
+ @Autowired
+ PartnerService partnerService;
private String partialName;
private String partialAddress;
private String partialVatNr;
private boolean listAll;
-
- @Getter
- @Autowired
- PartnerService partnerService;
private boolean filterShowInActive;
private boolean filterShowActive;
- private boolean canExecuteSearch() {
- boolean result = listAll || filterShowActive || filterShowInActive ||
- StringUtils.isNotBlank(partialName) ||
- StringUtils.isNotBlank(partialVatNr) ||
- StringUtils.isNotBlank(partialAddress);
- log.info("Can execute search: {}", result);
- return result;
- }
-
- private boolean filter(Partner partner) {
+ private Query filter() {
+ Query result = new Query();
if (listAll) {
- return true;
+ result.addCriteria(Criteria.where(PartnerDbService.ID).gt(0));
+ return result;
}
-
- boolean result = true;
if (StringUtils.isNotBlank(partialName)) {
- if (!partner.getName().toLowerCase().startsWith(partialName.toLowerCase())) {
- result = false;
- }
+ result.addCriteria(Criteria.where(PartnerDbService.NAME).regex("/^" + partialName + "/i"));
}
if (StringUtils.isNotBlank(partialVatNr)) {
- if (!partner.getVatNr().toLowerCase().startsWith(partialVatNr.toLowerCase())) {
- result = false;
- }
+ result.addCriteria(Criteria.where(PartnerDbService.VAT_NR).regex("/^" + partialVatNr + "/i"));
}
if (StringUtils.isNotBlank(partialAddress)) {
- if (!partner.getAddress().toLowerCase().startsWith(partialAddress.toLowerCase())) {
- result = false;
- }
+ result.addCriteria(Criteria.where(PartnerDbService.ADDRESS).regex("/^" + partialAddress + "/i"));
}
-
- if (!filterShowActive && partner.isActive()) {
- result = false;
+ if (filterShowActive && !filterShowInActive) {
+ result.addCriteria(Criteria.where(AssociateDbService.ACTIVE).is(true));
}
-
- if (!filterShowInActive && !partner.isActive()) {
- result = false;
+ if (filterShowInActive && !filterShowActive) {
+ result.addCriteria(Criteria.where(AssociateDbService.ACTIVE).is(false));
}
-
return result;
}
@Override
- protected List<Partner> getResultSet(long offset, int limit, FieldComparator sortComparator) {
- List<Partner> result = null;
- if (canExecuteSearch()) {
- result = partnerService.getAll().stream()
- .filter(s -> filter(s))
- .sorted(Comparator.comparing(Partner::getName, String.CASE_INSENSITIVE_ORDER))
- .collect(Collectors.toList());
+ protected List<Partner> getResultSet(int page, int pageSize, FieldComparator sortComparator) {
+ Query query = filter();
+ if (sortComparator != null) {
+ String orderBy = sortComparator.getRawOrderBy();
+ Sort.Direction direction = sortComparator.isAscending() ? Sort.Direction.ASC : Sort.Direction.DESC;
+ query.with(Sort.by(direction, orderBy));
}
+
+ Pageable pageable = PageRequest.of(page, pageSize);
+ query.with(pageable);
+ List<Partner> result = partnerDbService.list(query);
return result;
}
@Override
public int getResultSetCount() {
- int result = 0;
- if (canExecuteSearch()) {
- result = (int) partnerService.getAll().stream()
- .filter(s -> filter(s))
- .count();
- }
- return result;
+ Query query = filter();
+ return (int) partnerDbService.count(query);
}
public void search(String partialName, String partialVatNr, String partialAddress) {
this.partialVatNr = partialVatNr;
this.partialAddress = partialAddress;
super.reset();
- BindUtils.postNotifyChange(null, null, this, "*");
}
this.filterShowInActive = filterShowInActive;
listAll = false;
super.reset();
- BindUtils.postNotifyChange(null, null, this, "*");
}
public void listAll() {
log.info("List all partners");
listAll = true;
super.reset();
- BindUtils.postNotifyChange(null, null, this, "*");
+ }
+
+ public Partner createNew() {
+ return partnerService.createNew();
+ }
+
+ public void addNew(Partner entity) {
+ partnerDbService.insert(entity);
+ }
+
+ public Partner copy(Partner selectedEntity) {
+ return partnerService.copy(selectedEntity);
+ }
+
+ public Partner save(Partner selectedEntity) {
+ return partnerDbService.save(selectedEntity);
}
}
import org.zkoss.bind.BindUtils;
import org.zkoss.zul.FieldComparator;
-import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
private boolean filter(ProjectAssociate projectAssociate) {
boolean result = true;
if (StringUtils.isNotBlank(projectId)) {
- if (!projectAssociate.getProjectId().equals(projectId)) {
+ if (!projectAssociate.getProject().getId().equals(projectId)) {
result = false;
}
}
}
@Override
- protected List<ProjectAssociate> getResultSet(long offset, int limit, FieldComparator sortComparator) {
+ protected List<ProjectAssociate> getResultSet(int page, int pageSize, FieldComparator sortComparator) {
List<ProjectAssociate> result = null;
if (canExecuteSearch()) {
result = projectAssociateService.getAll().stream()
.filter(s -> filter(s))
- .sorted(Comparator.comparing(ProjectAssociate::getAssociateId))
.collect(Collectors.toList());
}
return result;
}
@Override
- protected List<Project> getResultSet(long offset, int limit, FieldComparator sortComparator) {
+ protected List<Project> getResultSet(int page, int pageSize, FieldComparator sortComparator) {
List<Project> result = projectService.getAll().stream()
.sorted(Comparator.comparing(Project::getName))
.filter(s -> filter(s))
import hu.user.lis.db.ProjectStatus;
import hu.user.lis.services.data.ProjectStatusService;
-import lombok.Getter;
+import hu.user.lis.services.nosql.ProjectStatusDbService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.zkoss.zul.FieldComparator;
import java.util.List;
+import java.util.stream.Collectors;
@Component
@Log4j2
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class ProjectStatusDataModel extends CachedDataModel<ProjectStatus> {
- @Getter
@Autowired
ProjectStatusService projectStatusService;
+ @Autowired
+ ProjectStatusDbService projectStatusDbService;
+ private boolean activeOnly;
@Override
- protected List<ProjectStatus> getResultSet(long offset, int limit, FieldComparator sortComparator) {
- return projectStatusService.getAll();
+ protected List<ProjectStatus> getResultSet(int page, int pageSize, FieldComparator sortComparator) {
+ List<ProjectStatus> result;
+ if (activeOnly) {
+ result = projectStatusService.getAll().stream().filter(e -> e.isActive()).collect(Collectors.toList());
+ } else {
+ result = projectStatusService.getAll();
+ }
+ return result;
}
@Override
public void listAll() {
super.reset();
+ this.activeOnly = false;
+ BindUtils.postNotifyChange(null, null, this, "*");
+ }
+
+ public void listActive() {
+ super.reset();
+ this.activeOnly = true;
BindUtils.postNotifyChange(null, null, this, "*");
}
}
@Override
- protected List<Project> getResultSet(long offset, int limit, FieldComparator sortComparator) {
+ protected List<Project> getResultSet(int page, int pageSize, FieldComparator sortComparator) {
List<Project> result = null;
if (canExecuteSearch()) {
result = projectService.getAll().stream()
import hu.user.lis.db.Project;
import hu.user.lis.db.ServiceRecord;
import hu.user.lis.services.data.ServiceRecordService;
-import lombok.Getter;
+import hu.user.lis.services.nosql.ServiceRecordDbService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
-import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.FieldComparator;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
@Component
@Log4j2
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class ServiceRecordsDataModel extends CachedDataModel<ServiceRecord> {
- @Getter
@Autowired
ServiceRecordService serviceRecordService;
+ @Autowired
+ ServiceRecordDbService serviceRecordDbService;
private boolean listAll;
- private Project filterProject;
- private Associate filterAssociate;
+ private Long filterProjectId;
+ private Long filterAssociateId;
private boolean groupByAssociate;
- public static <T> Predicate<T> distinctByKey(Function<? super T, Object> keyExtractor) {
- Map<Object, Boolean> map = new ConcurrentHashMap<>();
- return t -> map.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
+ private Query filter() {
+ Query result = new Query();
+ if (listAll) {
+ result.addCriteria(Criteria.where(ServiceRecordDbService.ID).gt(0));
+ return result;
+ }
+ if (Objects.nonNull(filterProjectId)) {
+ result.addCriteria(Criteria.where(ServiceRecordDbService.PROJECT_ID).is(filterProjectId));
+ }
+ if (Objects.nonNull(filterAssociateId)) {
+ result.addCriteria(Criteria.where(ServiceRecordDbService.ASSOCIATE_ID).is(filterAssociateId));
+ }
+ return result;
}
@Init
log.info("Initialized");
}
- private boolean canExecuteSearch() {
- boolean result = listAll || Objects.nonNull(filterProject) || Objects.nonNull(filterAssociate);
- log.info("Can execute search: {}", result);
- return result;
- }
-
- private boolean filter(ServiceRecord entity) {
- if (listAll) {
- return true;
- }
- boolean result = true;
- if (Objects.nonNull(filterProject)) {
- if (!entity.getProject().getId().equals(filterProject.getId())) {
- result = false;
- }
- }
- if (Objects.nonNull(filterAssociate)) {
- if (!entity.getAssociate().getId().equals(filterAssociate.getId())) {
- result = false;
- }
- }
- return result;
- }
-
@Override
- protected List<ServiceRecord> getResultSet(long offset, int limit, FieldComparator sortComparator) {
- List<ServiceRecord> result = null;
- if (canExecuteSearch()) {
- if (groupByAssociate) {
- result = getGroupedServiceRecords().values().stream().collect(Collectors.toList());
- } else {
- result = serviceRecordService.getAll().stream()
- .filter(s -> filter(s))
- .sorted(Comparator.comparing(ServiceRecord::getWorkDay))
- .collect(Collectors.toList());
- }
+ protected List<ServiceRecord> getResultSet(int page, int pageSize, FieldComparator sortComparator) {
+ Query query = filter();
+ if (sortComparator != null) {
+ String orderBy = sortComparator.getRawOrderBy();
+ Sort.Direction direction = sortComparator.isAscending() ? Sort.Direction.ASC : Sort.Direction.DESC;
+ query.with(Sort.by(direction, orderBy));
}
+ Pageable pageable = PageRequest.of(page, pageSize);
+ query.with(pageable);
+ List<ServiceRecord> result = serviceRecordDbService.list(query);
return result;
}
- Map<String, ServiceRecord> getGroupedServiceRecords() {
- Map<String, ServiceRecord> grouped = new HashMap<>();
+ Map<Long, ServiceRecord> getGroupedServiceRecords() {
+ Map<Long, ServiceRecord> grouped = new HashMap<>();
+ Query query = filter();
+ List<ServiceRecord> allEntities = serviceRecordDbService.list(query);
- serviceRecordService.getAll().stream().filter(s -> filter(s)).forEach(s -> {
+ allEntities.stream().forEach(s -> {
if (grouped.containsKey(s.getAssociate().getId())) {
ServiceRecord serviceRecord = grouped.get(s.getAssociate().getId());
serviceRecord.setCost(serviceRecord.getCost() + s.getCost());
@Override
public int getResultSetCount() {
- int result = 0;
- if (canExecuteSearch()) {
-
- if (groupByAssociate) {
- Map<String, ServiceRecord> grouped = getGroupedServiceRecords();
- result = grouped.size();
- } else {
- result = (int) serviceRecordService.getAll().stream()
- .filter(s -> filter(s))
- .count();
- }
- }
- return result;
+ Query query = filter();
+ return (int) serviceRecordDbService.count(query);
}
public void listAll() {
log.info("List all service records");
listAll = true;
super.reset();
- BindUtils.postNotifyChange(null, null, this, "*");
}
public void search(Project project, boolean groupByAssociate) {
- log.info("Searching project using filter {} grouping {}", project, groupByAssociate);
- this.groupByAssociate = groupByAssociate;
- this.filterProject = project;
+ log.info("Searching project using filter {} grouping {}", project.getId(), groupByAssociate);
listAll = false;
+ this.groupByAssociate = groupByAssociate;
+ this.filterProjectId = project.getId();
super.reset();
- BindUtils.postNotifyChange(null, null, this, "*");
}
public void search(Project project, Associate associate) {
- log.info("Searching project using filter {} {}", project, associate);
- this.filterAssociate = associate;
- this.filterProject = project;
+ this.filterProjectId = project == null ? null : project.getId();
+ this.filterAssociateId = associate == null ? null : associate.getId();
listAll = false;
+ log.info("Searching project using filter {} {}", this.filterProjectId, this.filterAssociateId);
super.reset();
- BindUtils.postNotifyChange(null, null, this, "*");
+ }
+
+ public ServiceRecord createNew() {
+ return serviceRecordService.createNew();
+ }
+
+ public void addNew(ServiceRecord entity) {
+ serviceRecordDbService.insert(entity);
+ }
+
+ public ServiceRecord copy(ServiceRecord selectedEntity) {
+ return serviceRecordService.copy(selectedEntity);
+ }
+
+ public ServiceRecord save(ServiceRecord selectedEntity) {
+ return serviceRecordDbService.save(selectedEntity);
}
}
@Log4j2
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class SuppliersDataModel extends CachedDataModel<Supplier> {
+ @Autowired
+ SupplierService supplierService;
private String partialName;
private String partialZipCode;
private boolean listAll;
- @Autowired
- SupplierService supplierService;
-
private boolean canExecuteSearch() {
boolean result = StringUtils.isNotBlank(partialName) || StringUtils.isNotBlank(partialZipCode) || listAll;
}
@Override
- protected List<Supplier> getResultSet(long offset, int limit, FieldComparator sortComparator) {
+ protected List<Supplier> getResultSet(int page, int pageSize, FieldComparator sortComparator) {
List<Supplier> result = null;
if (canExecuteSearch()) {
result = supplierService.getAll().stream()
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class SuppliersSimpleDataModel extends CachedDataModel<Supplier> {
static private final int SEARCH_LIMIT = 10;
- private String partialName;
@Autowired
SupplierService supplierService;
+ private String partialName;
private boolean filter(Supplier supplier) {
if (StringUtils.isBlank(partialName)) {
}
@Override
- protected List<Supplier> getResultSet(long offset, int limit, FieldComparator sortComparator) {
+ protected List<Supplier> getResultSet(int page, int pageSize, FieldComparator sortComparator) {
List<Supplier> result = supplierService.getAll().stream()
.sorted(Comparator.comparing(Supplier::getName))
.filter(s -> filter(s))
SessionSettings sessionSettings;
private Project formDocument;
private Project origDocument;
- private Map<String, Boolean> origAssociates;
- private Map<String, Boolean> formAssociates;
+ private Map<Associate, Boolean> origAssociates;
+ private Map<Associate, Boolean> formAssociates;
@WireVariable
private PartnerSelectorDataModel partnerSelectorDataModel;
@WireVariable
private ServiceRecordsDataModel serviceRecordsDataModel;
@WireVariable
private ProjectStatusDataModel projectStatusDataModel;
+ @Getter
+ @WireVariable
+ private ProjectStatusService projectStatusServiceImpl;
@WireVariable
private ProjectStatusConverter projectStatusConverter;
@WireVariable
@Init
public void init() {
- eventBus.register(this);
projectStatusDataModel.listAll();
+ eventBus.register(this);
log.info("Initialized");
}
origDocument = projectServiceImpl.getById(id);
formDocument = projectServiceImpl.copy(origDocument);
}
-
+
if (Objects.isNull(data)) {
formDocument = projectServiceImpl.createNew();
log.info("Loading new entity {} to editor", formDocument.getId());
} else {
args = ImmutableMap.of("origDocument", origDocument, "formDocument", formDocument);
}
- projectAssociateServiceImpl.update(formDocument.getId(), formAssociates);
+ projectAssociateServiceImpl.update(formDocument, formAssociates);
}
eventBus.showProjectsList(args);
Associate associate = associatesDataModel.getElementAt(i);
boolean exists = projectAssociateServiceImpl.getAll().stream()
.anyMatch(
- pa -> pa.getProjectId().equals(formDocument.getId()) &&
- pa.getAssociateId().equals(associate.getId())
+ pa -> pa.getProject().getId().equals(formDocument.getId()) &&
+ pa.getAssociate().getId().equals(associate.getId())
);
if (exists) {
log.info("{} is on project {}", associate.getName(), formDocument.getName());
}
- formAssociates.put(associate.getId(), exists);
- origAssociates.put(associate.getId(), exists);
+ formAssociates.put(associate, exists);
+ origAssociates.put(associate, exists);
}
}
}
}
- @Command
- @NotifyChange("selectedEntity")
- public void search() {
- }
-
@Command
@NotifyChange("selectedEntity")
public void onListSelection() {
@Command
public void onAdd() {
String page = "~./associate-editor.zul";
- Associate newEntity = associatesDataModel.getAssociateService().createNew();
+ Associate newEntity = associatesDataModel.createNew();
Window editorWindow = (Window) Executions.createComponents(page, null,
Collections.singletonMap("formDocument", newEntity));
editorWindow.addEventListener("onClose", e -> {
if (e.getData() != null) {
log.info("Associate popup result {}", e.getData());
- associatesDataModel.getAssociateService().add(newEntity);
+ associatesDataModel.addNew(newEntity);
associatesDataModel.clearSelection();
refresh();
associatesDataModel.addToSelection(newEntity);
return;
}
String page = "~./associate-editor.zul";
- Associate editEntity = associatesDataModel.getAssociateService().copy(selectedEntity);
+ Associate editEntity = associatesDataModel.copy(selectedEntity);
Map<String, Object> arg = new HashMap<>();
arg.put("origDocument", selectedEntity);
arg.put("formDocument", editEntity);
log.info("Partner popup result {}", e.getData());
Associate modifiedEntity = (Associate) e.getData();
associatesDataModel.clearSelection();
- associatesDataModel.getAssociateService().replace(selectedEntity, modifiedEntity);
+ associatesDataModel.save(modifiedEntity);
refresh();
associatesDataModel.addToSelection(modifiedEntity);
selectedEntity = modifiedEntity;
@Command
public void onAdd() {
String page = "~./partner-editor.zul";
- Partner newEntity = partnersDataModel.getPartnerService().createNew();
+ Partner newEntity = partnersDataModel.createNew();
Window editorWindow = (Window) Executions.createComponents(page, null,
Collections.singletonMap("formDocument", newEntity));
editorWindow.addEventListener("onClose", e -> {
if (e.getData() != null) {
log.info("Partner popup result {}", e.getData());
- partnersDataModel.getPartnerService().add(newEntity);
+ partnersDataModel.add(newEntity);
partnersDataModel.clearSelection();
refresh();
partnersDataModel.addToSelection(newEntity);
return;
}
String page = "~./partner-editor.zul";
- Partner editEntity = partnersDataModel.getPartnerService().copy(selectedPartner);
+ Partner editEntity = partnersDataModel.copy(selectedPartner);
Map<String, Object> arg = new HashMap<>();
arg.put("origDocument", selectedPartner);
arg.put("formDocument", editEntity);
log.info("Partner popup result {}", e.getData());
Partner modifiedEntity = (Partner) e.getData();
partnersDataModel.clearSelection();
- partnersDataModel.getPartnerService().replace(selectedPartner, modifiedEntity);
+ partnersDataModel.save(modifiedEntity);
refresh();
partnersDataModel.addToSelection(modifiedEntity);
selectedPartner = modifiedEntity;
package hu.user.lis.ui.view;
import hu.user.lis.db.Project;
-import hu.user.lis.db.ProjectStatus;
-import hu.user.lis.services.data.ProjectStatusService;
import hu.user.lis.ui.Constants;
import hu.user.lis.ui.data.ProjectsDataModel;
import hu.user.lis.ui.event.EventBus;
ProjectsDataModel projectsDataModel;
@WireVariable
EventBus eventBus;
- @WireVariable
- private ProjectStatusService projectStatusServiceImpl;
@Getter
private Project selectedProject;
private boolean filterShowInActive;
log.info("Initialized");
}
- public ProjectStatus getProjectStatus(String id) {
- return projectStatusServiceImpl.getById(id);
- }
-
private void refresh() {
projectsDataModel.clearSelection();
selectedProject = null;
@Command
public void onAdd() {
String page = "~./service-record-editor.zul";
- ServiceRecord newEntity = serviceRecordsDataModel.getServiceRecordService().createNew();
+ ServiceRecord newEntity = serviceRecordsDataModel.createNew();
Window editorWindow = (Window) Executions.createComponents(page, null,
Collections.singletonMap("formDocument", newEntity));
editorWindow.addEventListener("onClose", e -> {
if (e.getData() != null) {
log.info("Partner popup result {}", e.getData());
- serviceRecordsDataModel.getServiceRecordService().add(newEntity);
+ serviceRecordsDataModel.add(newEntity);
serviceRecordsDataModel.clearSelection();
refresh();
serviceRecordsDataModel.addToSelection(newEntity);
return;
}
String page = "~./service-record-editor.zul";
- ServiceRecord editEntity = serviceRecordsDataModel.getServiceRecordService().copy(selectedEntity);
+ ServiceRecord editEntity = serviceRecordsDataModel.copy(selectedEntity);
Map<String, Object> arg = ImmutableMap.of("origDocument", selectedEntity, "formDocument", editEntity);
Window editorWindow = (Window) Executions.createComponents(page, null, arg);
editorWindow.addEventListener("onClose", e -> {
log.info("Partner popup result {}", e.getData());
ServiceRecord modifiedEntity = (ServiceRecord) e.getData();
serviceRecordsDataModel.clearSelection();
- serviceRecordsDataModel.getServiceRecordService().replace(selectedEntity, modifiedEntity);
+ serviceRecordsDataModel.save(modifiedEntity);
refresh();
serviceRecordsDataModel.addToSelection(modifiedEntity);
selectedEntity = modifiedEntity;
</north>
<center border="none" flex="true">
<listbox vflex="true" model="@load(vm.associatesDataModel)"
- autopaging="true" pagingPosition="top" multiple="false"
+ autopaging="true" mold="paging" pagingPosition="top" multiple="false"
onSelect="@command('onListSelection')" onDoubleClick="@command('onEdit')"
onAfterRender="@command('onAfterRenderList')">
<listhead sizable="true">
- <listheader label="Név" align="left"/>
- <listheader label="Login" align="left"/>
- <listheader label="Aktív" align="left"/>
+ <listheader label="Név" sort="auto(name)" align="left"/>
+ <listheader label="Login" sort="auto(login)" align="left"/>
+ <listheader label="Aktív" sort="auto(active)" align="left"/>
</listhead>
<template name="model">
<listitem>
</north>
<center border="none" flex="true">
<listbox id="partnersList" vflex="true" model="@load(vm.partnersDataModel)"
- autopaging="true" pagingPosition="top" multiple="false"
+ autopaging="true" mold="paging" pagingPosition="top" multiple="false"
onSelect="@command('onListSelection')" onDoubleClick="@command('onEdit')"
onAfterRender="@command('onAfterRenderPartners')">
<listhead sizable="true">
- <listheader label="Név" align="left"/>
- <listheader label="Adószám" align="left"/>
- <listheader label="Cím" align="left"/>
- <listheader label="Aktív" align="left"/>
+ <listheader label="Név" sort="auto(name)" align="left"/>
+ <listheader label="Adószám" sort="auto(vatNr)" align="left"/>
+ <listheader label="Cím" sort="auto(address)" align="left"/>
+ <listheader label="Aktív" sort="auto(active)" align="left"/>
</listhead>
<template name="model">
<listitem>
<row>
<vlayout>
<label value="Státusz"/>
- <selectbox model="@load(vm.projectStatusDataModel)"
+ <!-- <combobox model="@load(vm.projectStatusDataModel)"-->
+ <!-- width="100%" readonly="true"-->
+ <!-- selectedItem="@bind(vm.formDocument.projectStatus) @validator(vm)"-->
+ <!-- forward="onOK=submit.onClick, onCancel=cancel.onClick">-->
+ <!-- <template name="model">-->
+ <!-- <comboitem label="${each.name}"/>-->
+ <!-- </template>-->
+ <!-- </combobox>-->
+ <selectbox model="@load(vm.projectStatusServiceImpl.getAll())"
width="100%"
- selectedIndex="@bind(vm.formDocument.projectStatusId) @converter(vm.projectStatusConverter) @validator(vm)"
+ selectedIndex="@bind(vm.formDocument.projectStatus) @converter(vm.projectStatusConverter) @validator(vm)"
forward="onOK=submit.onClick, onCancel=cancel.onClick">
<template name="model">
${each.name}
<listitem>
<listcell label="@load(each.humanId)"/>
<listcell label="@load(each.partner.name)"/>
- <listcell label="@load(vm.getProjectStatus(each.projectStatusId).name)"/>
+ <listcell label="@load(each.projectStatus.name)"/>
<listcell label="@load(each.name)"/>
<listcell label="@load(each.contactName)"/>
<listcell>
</north>
<center border="none" flex="true">
<listbox vflex="true" model="@load(vm.serviceRecordsDataModel)"
- autopaging="true" pagingPosition="top" onSelect="@command('onListSelection')"
+ autopaging="true" mold="paging" pagingPosition="top" onSelect="@command('onListSelection')"
onDoubleClick="@command('onEdit')">
<listhead sizable="true">
- <listheader label="Projekt azonosító" align="left"/>
- <listheader label="Projekt név" align="left"/>
- <listheader label="Partner név" align="left"/>
- <listheader label="Munkatárs" align="left"/>
- <listheader label="Munkanap" align="left"/>
- <listheader label="Leírás" align="left"/>
- <listheader label="Óraszám" align="right" style="text-align: center"/>
+ <listheader label="Projekt azonosító" sort="auto(project.humanId)" align="left"/>
+ <listheader label="Projekt név" sort="auto(project.name)" align="left"/>
+ <listheader label="Partner név" sort="auto(partner.name)" align="left"/>
+ <listheader label="Munkatárs" sort="auto(name)" align="left"/>
+ <listheader label="Munkanap" sort="auto(workDay)" align="left"/>
+ <listheader label="Leírás" sort="auto(description)" align="left"/>
+ <listheader label="Óraszám" sort="auto(workHours)" align="right" style="text-align: center"/>
<listheader label="Aláírt" align="left"/>
</listhead>
<template name="model">