Prepare project start button added
authorVásáry Dániel <vasary@elgekko.net>
Tue, 30 Jan 2024 16:08:09 +0000 (17:08 +0100)
committerVásáry Dániel <vasary@elgekko.net>
Tue, 30 Jan 2024 16:08:09 +0000 (17:08 +0100)
KB.md
lis-app/src/test/java/hu/user/lis/FakertIT.java [new file with mode: 0644]
lis-ui/src/main/java/hu/user/lis/ui/editor/common/EntityAttachmentEditorModel.java
lis-ui/src/main/java/hu/user/lis/ui/view/ProjectsViewModel.java
lis-ui/src/main/resources/web/projects.zul
lis-ui/src/main/resources/web/service-records.zul
lis-workflow/src/main/java/hu/user/lis/workflow/invoice/service/WorkflowManagerService.java

diff --git a/KB.md b/KB.md
index 26390f8fd048ff24bb47d7532fc63baf30a5ee6d..fc503732525e46dde9a670439e49ae2983f5756e 100644 (file)
--- a/KB.md
+++ b/KB.md
@@ -109,4 +109,5 @@ https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/
 
 ##### Col reorder
 
-https://stackoverflow.com/questions/14021298/zk-reordering-in-listbox/14021556#14021556
\ No newline at end of file
+https://stackoverflow.com/questions/14021298/zk-reordering-in-listbox/14021556#14021556
+
diff --git a/lis-app/src/test/java/hu/user/lis/FakertIT.java b/lis-app/src/test/java/hu/user/lis/FakertIT.java
new file mode 100644 (file)
index 0000000..1f3a692
--- /dev/null
@@ -0,0 +1,41 @@
+
+/*
+ * Copyright (c) $today.year-$today.month-24.
+ * By elGekko
+ */
+
+package hu.user.lis;
+
+import com.github.javafaker.Company;
+import com.github.javafaker.Faker;
+import lombok.extern.log4j.Log4j2;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.Locale;
+
+@Log4j2
+@SpringBootTest
+@ActiveProfiles("dev")
+@RunWith(SpringRunner.class)
+@ComponentScan("hu.user.lis")
+public class FakertIT {
+    @Test
+    public void test() {
+        Faker faker = new Faker(new Locale("hu-HU"));
+        for (int i = 0; i < 10; i++) {
+            log.info("Személynév: {}", faker.name().fullName());
+            log.info("Cím: {}", faker.address().fullAddress());
+            Company company = faker.company();
+            log.info("Cégnév: {}, ágazat: {}, munkakör: {}", company.name(), company.industry(), company.profession());
+            log.info("Chuck Norris tény :) : {}", faker.chuckNorris().fact());
+        }
+    }
+
+
+}
+
index 2f92f77613b67e7db345c028ff23020f4247f771..6147b5b4c216584bf138a115b9cec4ffd9ff7c1e 100644 (file)
@@ -50,7 +50,7 @@ public abstract class EntityAttachmentEditorModel<T extends Serializable> extend
     public void onUploadFile(@ContextParam(ContextType.BIND_CONTEXT) BindContext ctx) {
         UploadEvent evt = (UploadEvent) ctx.getTriggerEvent();
         if (!evt.getMedia().getName().toLowerCase().endsWith(".pdf")) {
-            Messagebox.show("Csak PDF állomány feltöltése támogatott.", "Error", Messagebox.OK, Messagebox.ERROR);
+            Messagebox.show("Csak PDF állomány feltöltése támogatott.");
             return;
         }
         EDocument document = EDocument.builder()
index 9509cabd7d9b2e1544099ee04f06ec7341e87eda..8e67ec850ce6734a99ae301289080476cde7d4fe 100644 (file)
@@ -8,6 +8,7 @@ import hu.user.lis.ui.data.common.CachedSpringDataModel;
 import hu.user.lis.ui.event.EventBus;
 import hu.user.lis.ui.event.SaveEntityEvent;
 import hu.user.lis.ui.view.common.FilterActiveViewModel;
+import hu.user.lis.workflow.invoice.service.WorkflowManagerService;
 import lombok.Getter;
 import lombok.extern.log4j.Log4j2;
 import org.zkoss.bind.BindUtils;
@@ -17,6 +18,7 @@ import org.zkoss.bind.annotation.Init;
 import org.zkoss.zk.ui.event.Event;
 import org.zkoss.zk.ui.event.EventListener;
 import org.zkoss.zk.ui.select.annotation.WireVariable;
+import org.zkoss.zk.ui.util.Notification;
 import org.zkoss.zul.Messagebox;
 
 import java.util.Map;
@@ -30,9 +32,11 @@ import static hu.user.lis.ui.data.common.CachedDataModel.NATURAL;
 public class ProjectsViewModel extends FilterActiveViewModel<Project> implements EventListener {
     @WireVariable
     @Getter
-    ProjectsDataModel projectsDataModel;
+    private ProjectsDataModel projectsDataModel;
     @WireVariable
-    EventBus eventBus;
+    private EventBus eventBus;
+    @WireVariable
+    private WorkflowManagerService workflowManagerService;
 
     @Override
     protected CachedSpringDataModel<Project> getDataModel() {
@@ -113,4 +117,21 @@ public class ProjectsViewModel extends FilterActiveViewModel<Project> implements
                     }
                 });
     }
+
+    @Command
+    public void onStartProcess() {
+        Project selectedEntity = getSelectedEntity();
+        if (Objects.nonNull(selectedEntity)) {
+            Messagebox.show("Biztosan elindítja a projekt mappa és fájl előkészítést?", "Megerősítés",
+                    Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION, e -> {
+                        if (e.getName().equals("onOK")) {
+                            String processId = workflowManagerService.startPrepareProjectProcess(selectedEntity);
+                            Notification.show("A folyamat elindult, azonosító: {}: " + processId, null, null, null, 3000, true);
+                        }
+                    });
+
+        } else {
+            Messagebox.show("Nincs kiválasztott projekt.");
+        }
+    }
 }
index 2f9a51fd510a177cfe56ce6749bde2cc6fcfca24..9c42ba9d81fc1ef01150404fedde654355740112 100644 (file)
                     <toolbarbutton label="Törlés" iconSclass="z-icon-remove" onClick="@command('onDelete')"
                                    disabled="@load(empty vm.selectedEntity)"/>
                     <separator orient="vertical"/>
+                    <toolbarbutton label="Háttér folyamat indítása" iconSclass="z-icon-play-circle"
+                                   onClick="@command('onStartProcess')"
+                                   disabled="@load(empty vm.selectedEntity)"/>
+                    <separator orient="vertical"/>
                     <toolbarbutton mode="toggle" iconSclass="z-icon-check" label="Aktív"
                                    checked="@bind(vm.filterShowActive)"/>
                     <toolbarbutton mode="toggle" iconSclass="z-icon-ban" label="Inaktív"
index 20202f1b015ffe4044b988f2f588ab657dc3c786..d751f0261442424cc024dfe563b5f065359135a2 100644 (file)
@@ -11,8 +11,6 @@
                     <toolbarbutton label="Törlés" iconSclass="z-icon-remove" onClick="@command('onDelete')"
                                    disabled="@load(empty vm.selectedEntity)"/>
                     <separator orient="vertical"/>
-                    <toolbarbutton label="Törlés" iconSclass="z-icon-minus" onClick="@command('onDelete')"
-                                   disabled="@load(empty vm.selectedEntity)"/>
                     <separator orient="vertical"/>
                     <label value="Projekt"/>
                     <separator orient="vertical"/>
index d40aa6430778a5c5da86606200d00a28b501540a..407f0041a68d33866718d054aa24d10b98fd5b71 100644 (file)
@@ -2,6 +2,7 @@ package hu.user.lis.workflow.invoice.service;
 
 import com.google.common.collect.ImmutableMap;
 import hu.user.lis.db.InvoiceImport;
+import hu.user.lis.db.Project;
 import hu.user.lis.service.data.EntityDataService;
 import hu.user.lis.workflow.event.WorkflowProcessEvent;
 import lombok.extern.log4j.Log4j2;
@@ -25,6 +26,7 @@ import java.util.Map;
 public class WorkflowManagerService {
     public static final String IMPORT_INCOMING_INVOICES = "importIncomingInvoices";
     public static final String ASSIGN_INCOMING_INVOICES = "assignIncomingInvoices";
+    private final String PREPARE_PROJECT = "prepareProject";
     @Autowired
     EntityDataService<InvoiceImport> invoiceImportEntityDataService;
     @Autowired
@@ -42,6 +44,12 @@ public class WorkflowManagerService {
         runtimeService.startProcessInstanceByKey(IMPORT_INCOMING_INVOICES);
     }
 
+    public String startPrepareProjectProcess(Project project) {
+        ImmutableMap<String, Object> params = ImmutableMap.of("projectId", project.getId());
+        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(PREPARE_PROJECT, params);
+        return processInstance.getProcessInstanceId();
+    }
+
     public String startAssignIncomingInvoiceProcess(InvoiceImport invoiceImport) {
         Map<String, Object> params = ImmutableMap.of(
                 "invoiceImportId", invoiceImport.getId(),