Phil il y a 1 an
Parent
commit
e904d1d97f

+ 0 - 0
frontend/themes/flowcrmtutorial/theme-editor.css


+ 7 - 13
pom.xml

@@ -2,17 +2,16 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"
 <project xmlns="http://maven.apache.org/POM/4.0.0"
     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: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">
     <modelVersion>4.0.0</modelVersion>
     <modelVersion>4.0.0</modelVersion>
-    <!-- Project from https://start.vaadin.com/ -->
-    <groupId>rocks.cybermuell.spotting</groupId>
-    <artifactId>spottingweb</artifactId>
-    <name>spottingweb</name>
+    <!-- Project from https://start.vaadin.com/project/2862378d-eb7e-4309-ad02-753cf2dd6084 -->
+    <groupId>com.example.application</groupId>
+    <artifactId>flowcrmtutorial</artifactId>
+    <name>flowcrmtutorial</name>
     <version>1.0-SNAPSHOT</version>
     <version>1.0-SNAPSHOT</version>
     <packaging>jar</packaging>
     <packaging>jar</packaging>
 
 
     <properties>
     <properties>
         <java.version>17</java.version>
         <java.version>17</java.version>
-        <vaadin.version>24.1.3</vaadin.version>
-        <selenium.version>4.10.0</selenium.version>
+        <vaadin.version>24.3.3</vaadin.version>
         <maven.compiler.source>17</maven.compiler.source>
         <maven.compiler.source>17</maven.compiler.source>
         <maven.compiler.target>17</maven.compiler.target>
         <maven.compiler.target>17</maven.compiler.target>
     </properties>
     </properties>
@@ -20,7 +19,7 @@
     <parent>
     <parent>
         <groupId>org.springframework.boot</groupId>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>3.1.0</version>
+        <version>3.2.1</version>
     </parent>
     </parent>
 
 
     <repositories>
     <repositories>
@@ -58,7 +57,7 @@
         <dependency>
         <dependency>
             <groupId>org.parttio</groupId>
             <groupId>org.parttio</groupId>
             <artifactId>line-awesome</artifactId>
             <artifactId>line-awesome</artifactId>
-            <version>1.1.0</version>
+            <version>2.0.0</version>
         </dependency>
         </dependency>
 
 
         <dependency>
         <dependency>
@@ -104,11 +103,6 @@
             <plugin>
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
-                <configuration>
-                    <jvmArguments>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5801</jvmArguments>
-                    <wait>500</wait>
-                    <maxAttempts>240</maxAttempts>
-                </configuration>
             </plugin>
             </plugin>
 
 
             <plugin>
             <plugin>

+ 52 - 0
src/main/java/com/example/application/data/AbstractEntity.java

@@ -0,0 +1,52 @@
+package com.example.application.data;
+
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.GenerationType;
+import jakarta.persistence.Id;
+import jakarta.persistence.MappedSuperclass;
+import jakarta.persistence.SequenceGenerator;
+import jakarta.persistence.Version;
+
+@MappedSuperclass
+public abstract class AbstractEntity {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "idgenerator")
+    // The initial value is to account for data.sql demo data ids
+    @SequenceGenerator(name = "idgenerator", initialValue = 1000)
+    private Long id;
+
+    @Version
+    private int version;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public int getVersion() {
+        return version;
+    }
+
+    @Override
+    public int hashCode() {
+        if (getId() != null) {
+            return getId().hashCode();
+        }
+        return super.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof AbstractEntity that)) {
+            return false; // null or not an AbstractEntity class
+        }
+        if (getId() != null) {
+            return getId().equals(that.getId());
+        }
+        return super.equals(that);
+    }
+}

+ 28 - 0
src/main/java/com/example/application/data/ArrowValue.java

@@ -0,0 +1,28 @@
+package com.example.application.data;
+
+public class ArrowValue {
+    private String L_1 = "";
+    private String L_2 = "";
+    private String L_3 = "";
+    private String R_1 = "";
+    private String R_2 = "";
+    private String R_3 = "";
+    private int sum_l = 0;
+    private int sum_r = 0;
+    private int set_l = 0;
+    private int set_r = 0;
+
+
+    public ArrowValue(String[] left, String[] right, int sum_l,int sum_r, int set_l,int set_r ){
+        L_1 = left[0];
+        L_2 = left[1];
+        L_3 = left[2];
+        R_1 = right[0];
+        R_2 = right[1];
+        R_3 = right[2];
+        this.set_l = set_l;
+        this.set_r = set_r;
+        this.sum_l = set_l;
+        this.sum_r = set_r;
+    }
+}

+ 34 - 0
src/main/java/com/example/application/data/Company.java

@@ -0,0 +1,34 @@
+package com.example.application.data;
+
+import jakarta.annotation.Nullable;
+import jakarta.persistence.Entity;
+import jakarta.persistence.OneToMany;
+import jakarta.validation.constraints.NotBlank;
+import java.util.LinkedList;
+import java.util.List;
+
+@Entity
+public class Company extends AbstractEntity {
+    @NotBlank
+    private String name;
+
+    @OneToMany(mappedBy = "company")
+    @Nullable
+    private List<Contact> employees = new LinkedList<>();
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public List<Contact> getEmployees() {
+        return employees;
+    }
+
+    public void setEmployees(List<Contact> employees) {
+        this.employees = employees;
+    }
+}

+ 8 - 0
src/main/java/com/example/application/data/CompanyRepository.java

@@ -0,0 +1,8 @@
+package com.example.application.data;
+
+
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface CompanyRepository extends JpaRepository<Company, Long> {
+
+}

+ 78 - 0
src/main/java/com/example/application/data/Contact.java

@@ -0,0 +1,78 @@
+package com.example.application.data;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import jakarta.persistence.Entity;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.ManyToOne;
+import jakarta.validation.constraints.Email;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+
+@Entity
+public class Contact extends AbstractEntity {
+
+    @NotEmpty
+    private String firstName = "";
+
+    @NotEmpty
+    private String lastName = "";
+
+    @ManyToOne
+    @JoinColumn(name = "company_id")
+    @NotNull
+    @JsonIgnoreProperties({"employees"})
+    private Company company;
+
+    @NotNull
+    @ManyToOne
+    private Status status;
+
+    @Email
+    @NotEmpty
+    private String email = "";
+
+    @Override
+    public String toString() {
+        return firstName + " " + lastName;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    public Company getCompany() {
+        return company;
+    }
+
+    public void setCompany(Company company) {
+        this.company = company;
+    }
+
+    public Status getStatus() {
+        return status;
+    }
+
+    public void setStatus(Status status) {
+        this.status = status;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+}

+ 8 - 0
src/main/java/com/example/application/data/ContactRepository.java

@@ -0,0 +1,8 @@
+package com.example.application.data;
+
+
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface ContactRepository extends JpaRepository<Contact, Long> {
+
+}

+ 61 - 17
src/main/java/com/example/application/data/DataThingy.java

@@ -1,11 +1,21 @@
 package com.example.application.data;
 package com.example.application.data;
 
 
+import com.google.gson.Gson;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+
 public class DataThingy {
 public class DataThingy {
 
 
     private String path = "C:/tst/test.txt";
     private String path = "C:/tst/test.txt";
     private boolean set = true;
     private boolean set = true;
     private int sum_l = 0;
     private int sum_l = 0;
     private int sum_r = 0;
     private int sum_r = 0;
+    private int set_l = 0;
+    private int set_r = 0;
+    private BufferedWriter writer;
+    private ArrowValue valueObj = null;
 
 
     public DataThingy(){
     public DataThingy(){
 
 
@@ -14,58 +24,92 @@ public class DataThingy {
     private void calc(String[] vals_l, String[] vals_r){
     private void calc(String[] vals_l, String[] vals_r){
         int tmp_l = 0;
         int tmp_l = 0;
         int tmp_r = 0;
         int tmp_r = 0;
+        String[] vals_out_l = new String[3];
+        String[] vals_out_r = new String[3];
 
 
         if(set){
         if(set){
             for(String s : vals_l){
             for(String s : vals_l){
                 if(s.equals("m"))
                 if(s.equals("m"))
                     tmp_l += 0;
                     tmp_l += 0;
-                if(s.equals("x"))
-                    tmp_l += 10;
+                if(s.equals("x")){
+                    s = "10";
+                    tmp_l += 10;}
                 if(!s.isBlank())
                 if(!s.isBlank())
                     tmp_l += Integer.valueOf(s);
                     tmp_l += Integer.valueOf(s);
             }
             }
             for(String s : vals_r){
             for(String s : vals_r){
                 if(s.equals("m"))
                 if(s.equals("m"))
                     tmp_r += 0;
                     tmp_r += 0;
-                if(s.equals("x"))
-                    tmp_r += 10;
+                if(s.equals("x")){
+                    s = "10";
+                    tmp_r += 10;}
                 if(!s.isBlank())
                 if(!s.isBlank())
                     tmp_r += Integer.valueOf(s);
                     tmp_r += Integer.valueOf(s);
             }
             }
+
             if(tmp_l > tmp_r){
             if(tmp_l > tmp_r){
-                sum_l += 2;
-            }else if(tmp_l > tmp_r){
-                sum_r += 2;
+                set_l += 2;
+            }else if(tmp_l < tmp_r){
+                set_r += 2;
             }else{
             }else{
-                sum_l ++;
-                sum_r ++;
+                if (isSetDone(vals_l,vals_r)){
+                    set_l ++;
+                    set_r ++;
+                }
             }
             }
         }else{
         }else{
             for(String s : vals_l){
             for(String s : vals_l){
                 if(s.equals("m"))
                 if(s.equals("m"))
                     tmp_l += 0;
                     tmp_l += 0;
-                if(s.equals("x"))
-                    tmp_l += 10;
+                if(s.equals("x")){
+                    s = "10";
+                    tmp_l += 10;}
                 if(!s.isBlank())
                 if(!s.isBlank())
                     tmp_l += Integer.valueOf(s);
                     tmp_l += Integer.valueOf(s);
             }
             }
             for(String s : vals_r){
             for(String s : vals_r){
-                if(s.equals("m"))
+                if(s.equals("m")){
                     tmp_r += 0;
                     tmp_r += 0;
-                if(s.equals("x"))
+                    break;}
+                if(s.equals("x")){
+                    s = "10";
                     tmp_r += 10;
                     tmp_r += 10;
-                if(!s.isBlank())
+                    break;}
+                if(!s.isBlank() )
                     tmp_r += Integer.valueOf(s);
                     tmp_r += Integer.valueOf(s);
             }
             }
-            sum_l += tmp_l;
-            sum_r += tmp_r;
+            if (isSetDone(vals_l,vals_r)){
+                sum_l += tmp_l;
+                sum_r += tmp_r;
+            }
         }
         }
 
 
     }
     }
 
 
+    private boolean isSetDone(String[] vals_l, String[] vals_r){
+        for (String s : vals_l){
+            if (s.isBlank())
+                    return false;
+        }
+        for (String s : vals_r){
+            if (s.isBlank())
+                return false;
+        }
+        return true;
+    }
+
     public void write(String[] vals_l, String[] vals_r){
     public void write(String[] vals_l, String[] vals_r){
         calc(vals_l,vals_r);
         calc(vals_l,vals_r);
-
+        Gson gson = new Gson();
+        valueObj = new ArrowValue(vals_l,vals_r,sum_l,sum_r,set_l,set_r);
+        ArrowValue[] vals = {valueObj};
+        try {
+            writer = new BufferedWriter(new FileWriter("C:/tst/test.txt"));
+            writer.write(gson.toJson(vals));
+            writer.close();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
 
 
     }
     }
 
 

+ 25 - 0
src/main/java/com/example/application/data/Status.java

@@ -0,0 +1,25 @@
+package com.example.application.data;
+
+import jakarta.persistence.Entity;
+
+@Entity
+public class Status extends AbstractEntity {
+    private String name;
+
+    public Status() {
+
+    }
+
+    public Status(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+}

+ 8 - 0
src/main/java/com/example/application/data/StatusRepository.java

@@ -0,0 +1,8 @@
+package com.example.application.data;
+
+
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface StatusRepository extends JpaRepository<Status, Long> {
+
+}

+ 4 - 1
src/main/java/com/example/application/views/list/ListView.java

@@ -1,15 +1,18 @@
 package com.example.application.views.list;
 package com.example.application.views.list;
 
 
+import com.vaadin.flow.component.html.H2;
+import com.vaadin.flow.component.html.Image;
+import com.vaadin.flow.component.html.Paragraph;
 import com.vaadin.flow.component.orderedlayout.VerticalLayout;
 import com.vaadin.flow.component.orderedlayout.VerticalLayout;
 import com.vaadin.flow.router.PageTitle;
 import com.vaadin.flow.router.PageTitle;
 import com.vaadin.flow.router.Route;
 import com.vaadin.flow.router.Route;
+import com.vaadin.flow.theme.lumo.LumoUtility.Margin;
 
 
 @PageTitle("list")
 @PageTitle("list")
 @Route(value = "")
 @Route(value = "")
 public class ListView extends VerticalLayout {
 public class ListView extends VerticalLayout {
 
 
     public ListView() {
     public ListView() {
-
     }
     }
 
 
 }
 }

+ 11 - 13
src/main/java/com/example/application/views/list/Spotting.java

@@ -1,5 +1,7 @@
 package com.example.application.views.list;
 package com.example.application.views.list;
 
 
+import com.example.application.data.ArrowValue;
+import com.example.application.data.DataThingy;
 import com.google.gson.Gson;
 import com.google.gson.Gson;
 import com.vaadin.flow.component.Component;
 import com.vaadin.flow.component.Component;
 import com.vaadin.flow.component.Key;
 import com.vaadin.flow.component.Key;
@@ -19,6 +21,8 @@ import java.io.IOException;
 public class Spotting extends HorizontalLayout {
 public class Spotting extends HorizontalLayout {
     private boolean start_right = false;
     private boolean start_right = false;
     private BufferedWriter writer;
     private BufferedWriter writer;
+    private DataThingy data = new DataThingy();
+
     //left
     //left
     VerticalLayout left = new VerticalLayout(Alignment.END);
     VerticalLayout left = new VerticalLayout(Alignment.END);
     TextField left_one = new TextField("Pfeil 1");
     TextField left_one = new TextField("Pfeil 1");
@@ -45,30 +49,24 @@ public class Spotting extends HorizontalLayout {
         for (Component c : left.getChildren().toList()){
         for (Component c : left.getChildren().toList()){
             if(c instanceof TextField){
             if(c instanceof TextField){
                 ((TextField)c).addValueChangeListener(textFieldStringComponentValueChangeEvent -> write());
                 ((TextField)c).addValueChangeListener(textFieldStringComponentValueChangeEvent -> write());
-                ((TextField)c).setAllowedCharPattern("[0-9mx]");
-                ((TextField)c).setMaxLength(1);
+                ((TextField)c).setAllowedCharPattern("[0-9mx*]");
+                ((TextField)c).setMaxLength(2);
             }
             }
         }
         }
         for (Component c : right.getChildren().toList()){
         for (Component c : right.getChildren().toList()){
             if(c instanceof TextField) {
             if(c instanceof TextField) {
                 ((TextField) c).addValueChangeListener(textFieldStringComponentValueChangeEvent -> write());
                 ((TextField) c).addValueChangeListener(textFieldStringComponentValueChangeEvent -> write());
-                ((TextField) c).setAllowedCharPattern("[0-9mx]");
-                ((TextField)c).setMaxLength(1);
+                ((TextField) c).setAllowedCharPattern("[0-9mx*]");
+                ((TextField)c).setMaxLength(2);
             }
             }
         }
         }
 
 
     }
     }
 
 
     private void write(){
     private void write(){
-        Gson gson = new Gson();
-        String vals[] = {left_one.getValue()left_two.getValue(),left_three.getValue(),right_one.getValue(),right_two.getValue(),right_three.getValue()};
-        try {
-            writer = new BufferedWriter(new FileWriter("C:/tst/test.txt"));
-            writer.write(gson.toJson(vals));
-            writer.close();
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
+        String[] vals_l = {left_one.getValue(),left_two.getValue(),left_three.getValue()};
+        String[] vals_r = {right_one.getValue(),right_two.getValue(),right_three.getValue()};
+        data.write(vals_l,vals_r);
     }
     }
 
 
 
 

+ 0 - 2
src/main/resources/vaadin-featureflags.properties

@@ -1,2 +0,0 @@
-# SideNav component (Production ready but tweaks to at least the internal DOM will still take place)
-com.vaadin.experimental.sideNavComponent=true