- def processId = petriNetService.getNewestVersionByIdentifier("export_test").stringId
+ def processId = petriNetService.getActiveVersionByIdentifier("export_test").stringId
def config = new com.netgrif.application.engine.export.domain.ExportDataConfig()
config.setDataToExport(["immediate_multichoice","immediate_number", "text"] as LinkedHashSet)
exportTasksToFile({it.processId.eq(processId) & it.transitionId.eq("t3")},"src/test/resources/csv/task_mongo_export.csv", config)
diff --git a/application-engine/src/test/resources/petriNets/process_version_1_0_0.xml b/application-engine/src/test/resources/petriNets/process_version_1_0_0.xml
new file mode 100644
index 0000000000..6359404689
--- /dev/null
+++ b/application-engine/src/test/resources/petriNets/process_version_1_0_0.xml
@@ -0,0 +1,9 @@
+
+
+ process_version_test
+ 1.0.0
+ PVT
+ Process Version 1.0.0 test
+ false
+
diff --git a/application-engine/src/test/resources/petriNets/process_version_2_0_0.xml b/application-engine/src/test/resources/petriNets/process_version_2_0_0.xml
new file mode 100644
index 0000000000..f095c407ae
--- /dev/null
+++ b/application-engine/src/test/resources/petriNets/process_version_2_0_0.xml
@@ -0,0 +1,9 @@
+
+
+ process_version_test
+ 2.0.0
+ PVT
+ Process Version 2.0.0 test
+ false
+
diff --git a/application-engine/src/test/resources/petriNets/process_version_3_0_0.xml b/application-engine/src/test/resources/petriNets/process_version_3_0_0.xml
new file mode 100644
index 0000000000..fdf75f4294
--- /dev/null
+++ b/application-engine/src/test/resources/petriNets/process_version_3_0_0.xml
@@ -0,0 +1,9 @@
+
+
+ process_version_test
+ 3.0.0
+ PVT
+ Process Version 3.0.0 test
+ false
+
diff --git a/application-engine/src/test/resources/petriNets/process_version_4_0_0.xml b/application-engine/src/test/resources/petriNets/process_version_4_0_0.xml
new file mode 100644
index 0000000000..58e472c139
--- /dev/null
+++ b/application-engine/src/test/resources/petriNets/process_version_4_0_0.xml
@@ -0,0 +1,9 @@
+
+
+ process_version_test
+ 4.0.0
+ PVT
+ Process Version 4.0.0 test
+ false
+
diff --git a/application-engine/src/test/resources/petriNets/process_version_5_0_0.xml b/application-engine/src/test/resources/petriNets/process_version_5_0_0.xml
new file mode 100644
index 0000000000..21b309f9be
--- /dev/null
+++ b/application-engine/src/test/resources/petriNets/process_version_5_0_0.xml
@@ -0,0 +1,9 @@
+
+
+ process_version_test
+ 5.0.0
+ PVT
+ Process Version 5.0.0 test
+ false
+
diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ElasticPetriNet.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ElasticPetriNet.java
index bdec2b24c7..5f86772a42 100644
--- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ElasticPetriNet.java
+++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ElasticPetriNet.java
@@ -24,6 +24,8 @@ public abstract class ElasticPetriNet {
private Version version;
+ private boolean versionActive;
+
private String uriNodeId;
private I18nField title;
@@ -38,6 +40,7 @@ public ElasticPetriNet(PetriNet net) {
this.id = net.getStringId();
this.identifier = net.getIdentifier();
this.version = net.getVersion();
+ this.versionActive = net.isVersionActive();
this.uriNodeId = net.getUriNodeId();
this.title = this.transformToField(net.getTitle());
this.initials = net.getInitials();
@@ -46,6 +49,7 @@ public ElasticPetriNet(PetriNet net) {
public void update(ElasticPetriNet net) {
this.version = net.getVersion();
+ this.versionActive = net.isVersionActive();
if (net.getUriNodeId() != null) {
this.uriNodeId = net.getUriNodeId();
}
diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/FunctionScope.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/FunctionScope.java
index 3d22260234..55f4ee7d02 100644
--- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/FunctionScope.java
+++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/FunctionScope.java
@@ -1,9 +1,21 @@
package com.netgrif.application.engine.objects.petrinet.domain;
+/**
+ * Enum representing the scope of a function.
+ *
+ * This enumeration defines the possible scopes in which a function can operate.
+ */
public enum FunctionScope {
- NAMESPACE("namespace"),
- PROCESS("process");
+ /**
+ * Represents the process-specific scope of a function.
+ */
+ PROCESS("process"),
+
+ /**
+ * Represents the global scope of a function.
+ */
+ GLOBAL("global");
private final String value;
diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/PetriNet.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/PetriNet.java
index a8b2fa447c..a2d5627ac5 100644
--- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/PetriNet.java
+++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/PetriNet.java
@@ -1,5 +1,6 @@
package com.netgrif.application.engine.objects.petrinet.domain;
+import com.netgrif.application.engine.objects.annotations.Indexed;
import com.netgrif.application.engine.objects.auth.domain.ActorRef;
import com.netgrif.application.engine.objects.petrinet.domain.arcs.Arc;
import com.netgrif.application.engine.objects.petrinet.domain.arcs.reference.Referencable;
@@ -30,7 +31,7 @@ public abstract class PetriNet extends PetriNetObject {
@Getter
@Setter
- private String identifier; //combination of identifier and version must be unique ... maybe use @CompoundIndex?
+ private String identifier; // todo: combination of identifier and version must be unique ... maybe use @CompoundIndex?
@Getter
@Setter
@@ -72,6 +73,11 @@ public abstract class PetriNet extends PetriNetObject {
@Setter
private Version version;
+ @Getter
+ @Setter
+ @Indexed
+ private boolean versionActive;
+
@Getter
@Setter
private ActorRef author;
@@ -141,22 +147,23 @@ public PetriNet() {
this.title = new I18nString("");
this.importId = "";
this.version = new Version();
- defaultCaseName = new I18nString("");
- initialized = false;
- creationDate = LocalDateTime.now();
- places = new LinkedHashMap<>();
- transitions = new LinkedHashMap<>();
- arcs = new LinkedHashMap<>();
- dataSet = new LinkedHashMap<>();
- roles = new LinkedHashMap<>();
- negativeViewRoles = new LinkedList<>();
- transactions = new LinkedHashMap<>();
- processEvents = new LinkedHashMap<>();
- caseEvents = new LinkedHashMap<>();
- permissions = new HashMap<>();
- userRefs = new HashMap<>();
- functions = new LinkedList<>();
- tags = new HashMap<>();
+ this.defaultCaseName = new I18nString("");
+ this.initialized = false;
+ this.creationDate = LocalDateTime.now();
+ this.places = new LinkedHashMap<>();
+ this.transitions = new LinkedHashMap<>();
+ this.arcs = new LinkedHashMap<>();
+ this.dataSet = new LinkedHashMap<>();
+ this.roles = new LinkedHashMap<>();
+ this.negativeViewRoles = new LinkedList<>();
+ this.transactions = new LinkedHashMap<>();
+ this.processEvents = new LinkedHashMap<>();
+ this.caseEvents = new LinkedHashMap<>();
+ this.permissions = new HashMap<>();
+ this.userRefs = new HashMap<>();
+ this.functions = new LinkedList<>();
+ this.tags = new HashMap<>();
+ this.makeInactive();
}
public PetriNet(PetriNet petriNet) {
@@ -167,6 +174,7 @@ public PetriNet(PetriNet petriNet) {
this.title = petriNet.getTitle();
this.importId = petriNet.getImportId();
this.version = petriNet.getVersion();
+ this.versionActive = petriNet.isVersionActive();
this.defaultCaseName = petriNet.getDefaultCaseName();
this.defaultCaseNameExpression = petriNet.getDefaultCaseNameExpression();
this.initials = petriNet.getInitials();
@@ -430,6 +438,14 @@ public boolean hasDynamicCaseName() {
return defaultCaseNameExpression != null;
}
+ public void makeActive() {
+ this.setVersionActive(true);
+ }
+
+ public void makeInactive() {
+ this.setVersionActive(false);
+ }
+
@Override
public String getStringId() {
return _id.toString();
diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/version/Version.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/version/Version.java
index 3c5c2d84be..50dd1f5481 100644
--- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/version/Version.java
+++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/version/Version.java
@@ -52,6 +52,12 @@ public void increment(VersionType type) {
}
}
+ /**
+ * Compares this version to the other version
+ *
+ * @param other other version to be compared with
+ * @return 0 if the versions equal, <0 if this is lower than other, >0 if this is higher than other0>
+ */
public int compareTo(Version other) {
if (this.major != other.major) {
return Long.compare(this.major, other.major);
@@ -62,6 +68,24 @@ public int compareTo(Version other) {
return Long.compare(this.patch, other.patch);
}
+ /**
+ * Checks if this version is higher than the other
+ * @param other other version to be compared with
+ * @return true if this version is higher than the other
+ */
+ public boolean isHigherThan(Version other) {
+ return compareTo(other) > 0;
+ }
+
+ /**
+ * Checks if this version is lower than the other
+ * @param other other version to be compared with
+ * @return true if this version is lower than the other
+ */
+ public boolean isLowerThan(Version other) {
+ return compareTo(other) < 0;
+ }
+
@Override
public Version clone() {
diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/petrinet/domain/PetriNet.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/petrinet/domain/PetriNet.java
index 7e91f07c13..4076351e98 100644
--- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/petrinet/domain/PetriNet.java
+++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/petrinet/domain/PetriNet.java
@@ -60,6 +60,7 @@ public LinkedHashMap getRoles() {
return super.getRoles();
}
+ // todo: delete clone method if not needed
// @Override
// public PetriNet clone() {
// PetriNet clone = new PetriNet();