From a2e2225d0708fab8c74b9c404f5d3fc4822ac139 Mon Sep 17 00:00:00 2001 From: Stefan Renczes Date: Tue, 15 Feb 2022 15:53:19 +0100 Subject: [PATCH 01/13] [NAE-1547] Plugin management - implemented PluginService - implemented PluginInjector - implemented configuration classes for plugins - implemented PluginManagerConfiguration - implemented exception management for plugins --- pom.xml | 7 + .../plugins/services/PluginInjector.groovy | 81 +++++++++++ .../config/PluginManagerConfiguration.java | 16 +++ .../plugins/config/PluginProperties.java | 58 ++++++++ .../config/PluginPropertySourceFactory.java | 23 +++ .../IncompatibleClassLoaderException.java | 12 ++ .../IncompatiblePluginException.java | 13 ++ .../security/PluginSecurityConfiguration.java | 23 +++ .../security/PluginSecurityPolicy.java | 34 +++++ .../plugins/services/PluginService.java | 136 ++++++++++++++++++ .../services/interfaces/IPluginService.java | 12 ++ src/main/resources/plugin.yaml | 0 12 files changed, 415 insertions(+) create mode 100644 src/main/groovy/com/netgrif/application/engine/integration/plugins/services/PluginInjector.groovy create mode 100644 src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginManagerConfiguration.java create mode 100644 src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginProperties.java create mode 100644 src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginPropertySourceFactory.java create mode 100644 src/main/java/com/netgrif/application/engine/integration/plugins/exceptions/IncompatibleClassLoaderException.java create mode 100644 src/main/java/com/netgrif/application/engine/integration/plugins/exceptions/IncompatiblePluginException.java create mode 100644 src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityConfiguration.java create mode 100644 src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityPolicy.java create mode 100644 src/main/java/com/netgrif/application/engine/integration/plugins/services/PluginService.java create mode 100644 src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IPluginService.java create mode 100644 src/main/resources/plugin.yaml diff --git a/pom.xml b/pom.xml index 4acff60838..80e33a3d60 100644 --- a/pom.xml +++ b/pom.xml @@ -405,6 +405,13 @@ 2.2.0-rc2 + + + com.netgrif + plugin-library + 0.0.1 + + org.springframework.boot diff --git a/src/main/groovy/com/netgrif/application/engine/integration/plugins/services/PluginInjector.groovy b/src/main/groovy/com/netgrif/application/engine/integration/plugins/services/PluginInjector.groovy new file mode 100644 index 0000000000..e9832eb4cd --- /dev/null +++ b/src/main/groovy/com/netgrif/application/engine/integration/plugins/services/PluginInjector.groovy @@ -0,0 +1,81 @@ +package com.netgrif.application.engine.integration.plugins.services + +import com.netgrif.application.engine.integration.plugins.config.PluginProperties +import com.netgrif.application.engine.integration.plugins.exceptions.IncompatibleClassLoaderException +import com.netgrif.application.engine.integration.plugins.exceptions.IncompatiblePluginException +import com.netgrif.application.engine.integration.plugins.exceptions.RestrictedPackageException +import com.netgrif.application.engine.petrinet.domain.dataset.logic.action.ActionDelegate +import extensions.NaeExtensionPoint +import groovy.util.logging.Slf4j +import org.pf4j.ExtensionPoint +import org.pf4j.PluginClassLoader +import org.pf4j.PluginWrapper +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.beans.factory.annotation.Value +import org.springframework.stereotype.Component +import wrapper.NaePlugin +import wrapper.PluginExtensionHolder + +import java.util.stream.Collectors + +@Slf4j +@Component +class PluginInjector { + + @Autowired + private PluginProperties pluginProperties + + @Value('${project.version}') + private String projectVersion + + protected void injectExtension(PluginWrapper pluginWrapper) { + pluginWrapper.getPluginManager().getExtensions(NaeExtensionPoint.class).each { extension -> + checkCompatibility(extension) + checkClassLoader(extension as NaeExtensionPoint) + secureCheck(extension as NaeExtensionPoint) + } + + PluginExtensionHolder extensionHolder = ((NaePlugin) pluginWrapper.getPlugin()).getExtensionHolder() + MetaClass actionDelegateMc = ActionDelegate.getMetaClass() + actionDelegateMc[pluginWrapper.pluginId] = extensionHolder + } + + protected void secureCheck(NaeExtensionPoint extension) { + checkPackages(extension.getClass()) + } + + private void checkPackages(Class aClass) { + List filteredRestrictedPackages = filterRestrictedPackages(aClass) + if (!filteredRestrictedPackages.isEmpty()) { + String message = "Plugin " + aClass.getName() + " contains restricted packages: " + + filteredRestrictedPackages.toString() + log.error(message) + throw new RestrictedPackageException(message) + } + aClass.declaredFields.each { field -> + checkPackages(field.class) + } + } + + private List filterRestrictedPackages(Class aClass) { + return aClass.classLoader.definedPackages.toList().stream().filter(p -> { + pluginProperties.restrictedPackages.toList().stream().anyMatch(rp -> { + return p.getName().startsWith(rp) || p.getName().contains(rp) + }) + }).collect(Collectors.toList()) + } + + private void checkCompatibility(NaeExtensionPoint extension) { + if (extension.getPluginVersion() != projectVersion) + log.warn("Netgrif Application Engine end imported library versions are not the same. Some functions may work improperly.") + } + + private void checkClassLoader(NaeExtensionPoint extensionPoint) { + ClassLoader classLoader = extensionPoint.class.classLoader + if (!classLoader instanceof PluginClassLoader) { + String message = "Plugin class loader [" + classLoader.getClass().getName() + "] is not compatible with class loader for plugins." + log.error(message) + throw new IncompatibleClassLoaderException(message) + } + } +} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginManagerConfiguration.java b/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginManagerConfiguration.java new file mode 100644 index 0000000000..044a31cbe4 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginManagerConfiguration.java @@ -0,0 +1,16 @@ +package com.netgrif.application.engine.integration.plugins.config; + +import lombok.extern.slf4j.Slf4j; +import org.pf4j.JarPluginManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Slf4j +@Configuration +public class PluginManagerConfiguration { + + @Bean + public JarPluginManager pluginManager() { + return new JarPluginManager(); + } +} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginProperties.java b/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginProperties.java new file mode 100644 index 0000000000..2b89d6a38e --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginProperties.java @@ -0,0 +1,58 @@ +package com.netgrif.application.engine.integration.plugins.config; + +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Component; + +import java.lang.reflect.InvocationTargetException; +import java.security.Permission; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Data +@Slf4j +@Component +@PropertySource(value = "classpath:plugin.yaml", factory = PluginPropertySourceFactory.class) +@ConfigurationProperties(prefix = "nae.plugins") +public final class PluginProperties { + + private String[] restrictedPackages = new String[]{"java.io","org.springframework.data","com.netgrif.workflow"}; + + private String dir = "plugins"; + + private String[] pluginFileNames = new String[]{"*"}; + + private List permissions = new ArrayList<>(); + + public void setPermissions(Map, Object[]> permissionsMap) { + permissionsMap.forEach((k, v) -> { + Permission permission = createPermissionFromClass(k, v); + if (permission != null) + this.permissions.add(permission); + }); + } + + private Permission createPermissionFromClass(Class permClass, Object... args) { + Permission permission = null; + + if (!permClass.getPackageName().contains("java.security") && !Permission.class.isAssignableFrom(permClass)) { + log.error("Provided permission class is not from the official java.security package or it does not extends" + + "from abstract java.security.Permission class."); + return null; + } + + try { + Class[] argTypes = new Class[args.length]; + Arrays.stream(args).map(Object::getClass).collect(Collectors.toList()).toArray(argTypes); + permission = (Permission) permClass.getDeclaredConstructor(argTypes).newInstance(args); + } catch (InstantiationException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + log.error("Cannot create an instance of type [" + permClass + "]", e); + } + return permission; + } +} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginPropertySourceFactory.java b/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginPropertySourceFactory.java new file mode 100644 index 0000000000..62f902a991 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginPropertySourceFactory.java @@ -0,0 +1,23 @@ +package com.netgrif.application.engine.integration.plugins.config; + +import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; +import org.springframework.core.env.PropertiesPropertySource; +import org.springframework.core.env.PropertySource; +import org.springframework.core.io.support.EncodedResource; +import org.springframework.core.io.support.PropertySourceFactory; +import org.springframework.lang.Nullable; + +import java.util.Objects; +import java.util.Properties; + +class PluginPropertySourceFactory implements PropertySourceFactory { + + @Override + public PropertySource createPropertySource(@Nullable String name, EncodedResource resource) { + YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); + factory.setResources(resource.getResource()); + Properties properties = factory.getObject(); + assert properties != null; + return new PropertiesPropertySource(Objects.requireNonNull(resource.getResource().getFilename()), properties); + } +} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/exceptions/IncompatibleClassLoaderException.java b/src/main/java/com/netgrif/application/engine/integration/plugins/exceptions/IncompatibleClassLoaderException.java new file mode 100644 index 0000000000..9df59bd245 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/exceptions/IncompatibleClassLoaderException.java @@ -0,0 +1,12 @@ +package com.netgrif.application.engine.integration.plugins.exceptions; + +public class IncompatibleClassLoaderException extends Throwable { + + public IncompatibleClassLoaderException() { + super(); + } + + public IncompatibleClassLoaderException(String message) { + super(message); + } +} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/exceptions/IncompatiblePluginException.java b/src/main/java/com/netgrif/application/engine/integration/plugins/exceptions/IncompatiblePluginException.java new file mode 100644 index 0000000000..347802c1aa --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/exceptions/IncompatiblePluginException.java @@ -0,0 +1,13 @@ +package com.netgrif.application.engine.integration.plugins.exceptions; + +public class IncompatiblePluginException extends Throwable { + + public IncompatiblePluginException() { + super(); + } + + public IncompatiblePluginException(String message) { + super(message); + } + +} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityConfiguration.java b/src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityConfiguration.java new file mode 100644 index 0000000000..2b02d916f7 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityConfiguration.java @@ -0,0 +1,23 @@ +package com.netgrif.application.engine.integration.plugins.security; + +import com.netgrif.application.engine.integration.plugins.config.PluginProperties; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; + +import javax.annotation.PostConstruct; +import java.security.Policy; + +@Slf4j +@Configuration +public class PluginSecurityConfiguration { + + @Autowired + private PluginProperties pluginProperties; + + @PostConstruct + protected void init() { + if (pluginProperties.getPermissions() != null && pluginProperties.getPermissions().size() > 0) + Policy.setPolicy(new PluginSecurityPolicy(pluginProperties.getPermissions())); + } +} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityPolicy.java b/src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityPolicy.java new file mode 100644 index 0000000000..967c58efd0 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityPolicy.java @@ -0,0 +1,34 @@ +package com.netgrif.application.engine.integration.plugins.security; + +import lombok.Setter; +import org.pf4j.PluginClassLoader; + +import java.security.*; +import java.util.ArrayList; +import java.util.List; + +class PluginSecurityPolicy extends Policy { + + @Setter + private List permissionList; + + protected PluginSecurityPolicy() { + this.permissionList = new ArrayList<>(); + } + + protected PluginSecurityPolicy(List permissionList) { + this(); + this.permissionList = permissionList; + } + + @Override + public PermissionCollection getPermissions(ProtectionDomain domain) { + Permissions permissions = new Permissions(); + + if (domain.getClassLoader() instanceof PluginClassLoader) { + permissionList.forEach(permissions::add); + } + + return permissions; + } +} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/services/PluginService.java b/src/main/java/com/netgrif/application/engine/integration/plugins/services/PluginService.java new file mode 100644 index 0000000000..6c7acd94c8 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/services/PluginService.java @@ -0,0 +1,136 @@ +package com.netgrif.application.engine.integration.plugins.services; + +import com.netgrif.application.engine.integration.plugins.config.PluginProperties; +import com.netgrif.application.engine.integration.plugins.services.interfaces.IPluginService; +import extensions.NaeExtensionPoint; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.io.filefilter.WildcardFileFilter; +import org.pf4j.Plugin; +import org.pf4j.PluginManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import wrapper.NaePlugin; + +import javax.annotation.PostConstruct; +import java.io.File; +import java.io.FilenameFilter; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +/** + * Service for managing plugins in NAE + * */ +@Slf4j +@Service +public class PluginService implements IPluginService { + + @Autowired + private PluginProperties pluginProperties; + + @Autowired + private PluginManager pluginManager; + + @Autowired + private PluginInjector pluginInjector; + + /** + * Initialization of plugin system inside NAE. Sets properties and loads the plugins. + * */ + @PostConstruct + protected void init() { + if (pluginProperties.getPluginFileNames().length == 1 && pluginProperties.getPluginFileNames()[0].equals("*")) + load(pluginProperties.getDir()); + else if (pluginProperties.getPluginFileNames().length > 0) + Arrays.stream(pluginProperties.getPluginFileNames()).forEach(fileName -> load(pluginProperties.getDir() + "/" + fileName)); + } + + /** + * Returns a plugin by its ID + * @param pluginId the plugin ID of required plugin + * @return the required plugin + * */ + @Override + public final Plugin getPlugin(String pluginId) { + return this.pluginManager.getPlugin(pluginId).getPlugin(); + } + + /** + * Calls a function of an extension point from a single plugin and returns its result. + * @param pluginId ID of the plugin + * @param extensionName name of the extension point class where the function is defined + * @param method name of method to be called + * @param argumentValues the input values of arguments of function + * @param returnType the class type of the return value of the function + * @return an object from the function inside plugin + * */ + @Override + public final T call(String pluginId, String extensionName, String method, List argumentValues, Class returnType) { + NaeExtensionPoint extension = retrieveExtension(pluginId, extensionName); + if (extension == null) { + return null; + } + return extension.call(method, argumentValues, returnType); + } + + /** + * Loads the plugin from the specific path + * @param path input path + * */ + private void load(String path) { + Path pluginPath = Paths.get(path); + if (Files.isDirectory(pluginPath)) { + File dir = new File(path); + File[] pluginJars = dir.listFiles((FilenameFilter) new WildcardFileFilter("*.jar")); + if (pluginJars != null) + Arrays.stream(pluginJars).forEach(jar -> loadAndStartPlugin(Paths.get(jar.getPath()))); + } else if (FilenameUtils.getExtension(pluginPath.getFileName().toString()).equals("jar")) { + loadAndStartPlugin(pluginPath); + } + injectPlugin(); + } + + /** + * Injects the plugin and it's extension + * */ + private void injectPlugin() { + this.pluginManager.getPlugins().forEach(plugin -> { + if (plugin.getPlugin() instanceof NaePlugin) { + ((NaePlugin) plugin.getPlugin()).init(); + pluginInjector.injectExtension(plugin); + } + }); + } + + /** + * Loads and starts the plugin. + * @param pluginPath Path of the plugin to be loaded and started + * */ + private void loadAndStartPlugin(Path pluginPath) { + pluginManager.loadPlugin(pluginPath); + pluginManager.startPlugins(); + } + + /** + * Retrieves extension by the given plugin ID, extension name and method name. + * @param pluginId ID of the plugin where the extension is defined + * @param extensionName name of the extension class + * @return the NaeExtensionPoint object + * */ + private NaeExtensionPoint retrieveExtension(String pluginId, String extensionName) { + Optional extension = pluginManager.getExtensions(pluginId) + .stream() + .filter(ext -> ext.getClass().getName().equals(extensionName)) + .findFirst(); + + if (extension.isEmpty()) { + log.error("There is no extension with given class name [" + extensionName + "]"); + return null; + } + return extension.get(); + } +} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IPluginService.java b/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IPluginService.java new file mode 100644 index 0000000000..a9a1eadbe9 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IPluginService.java @@ -0,0 +1,12 @@ +package com.netgrif.application.engine.integration.plugins.services.interfaces; + +import org.pf4j.Plugin; + +import java.util.List; + +public interface IPluginService { + + Plugin getPlugin(String pluginId); + + T call(String pluginId, String extensionName, String method, List argumentValues, Class returnType); +} diff --git a/src/main/resources/plugin.yaml b/src/main/resources/plugin.yaml new file mode 100644 index 0000000000..e69de29bb2 From f096b993f719dc971e2d673e0d6af60cbf7c8411 Mon Sep 17 00:00:00 2001 From: Stefan Renczes Date: Tue, 15 Feb 2022 15:54:46 +0100 Subject: [PATCH 02/13] [NAE-1567] Global event system - implemented EventSystemService - implemented dispatcher classes --- .../event/dispatchers/AbstractDispatcher.java | 43 +++++++++++++++++++ .../dispatchers/UserEventDispatcher.java | 38 ++++++++++++++++ .../engine/event/events/Event.java | 3 +- .../event/publishers/NaeEventPublisher.java | 34 +++++++++++++++ .../event/publishers/UserEventPublisher.java | 18 ++++++++ .../event/services/EventSystemService.java | 37 ++++++++++++++++ .../interfaces/IEventSystemService.java | 8 ++++ .../RestrictedPackageException.java | 11 +++++ 8 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/netgrif/application/engine/event/dispatchers/AbstractDispatcher.java create mode 100644 src/main/java/com/netgrif/application/engine/event/dispatchers/UserEventDispatcher.java create mode 100644 src/main/java/com/netgrif/application/engine/event/publishers/NaeEventPublisher.java create mode 100644 src/main/java/com/netgrif/application/engine/event/publishers/UserEventPublisher.java create mode 100644 src/main/java/com/netgrif/application/engine/event/services/EventSystemService.java create mode 100644 src/main/java/com/netgrif/application/engine/event/services/interfaces/IEventSystemService.java create mode 100644 src/main/java/com/netgrif/application/engine/integration/plugins/exceptions/RestrictedPackageException.java diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/AbstractDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/AbstractDispatcher.java new file mode 100644 index 0000000000..c941e2b912 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/AbstractDispatcher.java @@ -0,0 +1,43 @@ +package com.netgrif.application.engine.event.dispatchers; + +import com.netgrif.application.engine.event.services.interfaces.IEventSystemService; +import events.IDispatcher; +import events.IEvent; +import events.ISubscriber; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public abstract class AbstractDispatcher implements IDispatcher { + + protected final List subscribers; + + protected AbstractDispatcher(IEventSystemService eventSystemService) { + this.subscribers = new ArrayList<>(); + eventSystemService.registerDispatcher(this); + } + + @Override + public abstract String getId(); + + @Override + public void registerSubscriber(ISubscriber subscriber) { + if (subscriber != null) + subscribers.add(subscriber); + } + + @Override + public void listen(IEvent event) { + subscribers.forEach(s -> System.out.println(s.onEvent(event))); + } + + @Override + public void listen(Class eventClass, T event) { + } + + protected List getSubscribers() { + return this.subscribers; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/UserEventDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/UserEventDispatcher.java new file mode 100644 index 0000000000..dd2ffa63df --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/UserEventDispatcher.java @@ -0,0 +1,38 @@ +package com.netgrif.application.engine.event.dispatchers; + +import com.netgrif.application.engine.event.events.user.UserEvent; +import com.netgrif.application.engine.event.services.interfaces.IEventSystemService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Service; + +import java.util.Collections; +import java.util.List; + +@Service +public class UserEventDispatcher extends AbstractDispatcher { + + protected UserEventDispatcher(@Autowired IEventSystemService eventSystemService) { + super(eventSystemService); + } + + @Override + public String getId() { + return "userEventDispatcher"; + } + + @Override + public List getRequiredPluginIds() { + return Collections.singletonList("pluginex"); + } + + @EventListener + public void listen(UserEvent object) { + super.listen(object); + } + + @Override + public void listen(Class eventClass, T event) { + super.listen(eventClass, event); + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/Event.java b/src/main/java/com/netgrif/application/engine/event/events/Event.java index 82a977bd4b..fa0a3698bf 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/Event.java +++ b/src/main/java/com/netgrif/application/engine/event/events/Event.java @@ -1,11 +1,12 @@ package com.netgrif.application.engine.event.events; +import events.IEvent; import lombok.Getter; import org.springframework.context.ApplicationEvent; import java.time.LocalDateTime; -public abstract class Event extends ApplicationEvent { +public abstract class Event extends ApplicationEvent implements IEvent { @Getter protected LocalDateTime time; diff --git a/src/main/java/com/netgrif/application/engine/event/publishers/NaeEventPublisher.java b/src/main/java/com/netgrif/application/engine/event/publishers/NaeEventPublisher.java new file mode 100644 index 0000000000..de88755e8e --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/publishers/NaeEventPublisher.java @@ -0,0 +1,34 @@ +package com.netgrif.application.engine.event.publishers; + +import com.netgrif.application.engine.event.events.Event; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.ApplicationEventPublisher; + +/** + * Publisher for NAE Event system. + * */ +@Slf4j +public abstract class NaeEventPublisher { + + @Getter + @Setter + private ApplicationEventPublisher applicationEventPublisher; + + protected NaeEventPublisher() { + } + + protected NaeEventPublisher(ApplicationEventPublisher applicationEventPublisher) { + this.applicationEventPublisher = applicationEventPublisher; + } + + /** + * Publishes event to application context. + * @param event - the NaeEvent instance (can be extended class), that contains the source object; + * */ + public void publish(Event event) { + log.info("Publishing event " + event.getTimestamp()); + this.applicationEventPublisher.publishEvent(event); + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/publishers/UserEventPublisher.java b/src/main/java/com/netgrif/application/engine/event/publishers/UserEventPublisher.java new file mode 100644 index 0000000000..eb6b9a39c8 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/publishers/UserEventPublisher.java @@ -0,0 +1,18 @@ +package com.netgrif.application.engine.event.publishers; + +import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.event.events.user.UserLoginEvent; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Service; + +@Service +public class UserEventPublisher extends NaeEventPublisher { + + public UserEventPublisher(ApplicationEventPublisher publisher) { + super(publisher); + } + + public void publish(UserLoginEvent event) { + super.publish(event); + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/services/EventSystemService.java b/src/main/java/com/netgrif/application/engine/event/services/EventSystemService.java new file mode 100644 index 0000000000..f98e3febc5 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/services/EventSystemService.java @@ -0,0 +1,37 @@ +package com.netgrif.application.engine.event.services; + +import com.netgrif.application.engine.event.services.interfaces.IEventSystemService; +import com.netgrif.application.engine.integration.plugins.services.interfaces.IPluginService; +import events.IDispatcher; +import org.pf4j.Plugin; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import wrapper.NaePlugin; + +/** + * Service for managing and handling Spring Event objects inside NAE + * */ +@Service +public class EventSystemService implements IEventSystemService { + + @Autowired + private IPluginService pluginService; + + /** + * Registers dispatcher object in the required plugin, then calls the subscribers to subscribe to this dispatcher. + * @param dispatcher the Dispatcher object that is being registered + * */ + @Override + public void registerDispatcher(IDispatcher dispatcher) { + if (dispatcher.getRequiredPluginIds() != null) { + dispatcher.getRequiredPluginIds().forEach(pluginId -> { + Plugin plugin = this.pluginService.getPlugin(pluginId); + if (plugin instanceof NaePlugin) { + NaePlugin naePlugin = (NaePlugin) plugin; + naePlugin.getEventManager().addDispatcher(dispatcher); + naePlugin.getEventManager().registerSubscribers(dispatcher); + } + }); + } + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/services/interfaces/IEventSystemService.java b/src/main/java/com/netgrif/application/engine/event/services/interfaces/IEventSystemService.java new file mode 100644 index 0000000000..e9d1be84f2 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/services/interfaces/IEventSystemService.java @@ -0,0 +1,8 @@ +package com.netgrif.application.engine.event.services.interfaces; + + +import events.IDispatcher; + +public interface IEventSystemService { + void registerDispatcher(IDispatcher dispatcher); +} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/exceptions/RestrictedPackageException.java b/src/main/java/com/netgrif/application/engine/integration/plugins/exceptions/RestrictedPackageException.java new file mode 100644 index 0000000000..9377b829be --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/exceptions/RestrictedPackageException.java @@ -0,0 +1,11 @@ +package com.netgrif.application.engine.integration.plugins.exceptions; + +public class RestrictedPackageException extends Throwable { + public RestrictedPackageException() { + super(); + } + + public RestrictedPackageException(String message) { + super(message); + } +} From 524f6a619bb0ea12a9598c2f54760491940ab026 Mon Sep 17 00:00:00 2001 From: Stefan Renczes Date: Mon, 28 Feb 2022 08:11:26 +0100 Subject: [PATCH 03/13] [NAE-1567] Global event system - corrected aggording to meeting --- .../engine/event/dispatchers/UserEventDispatcher.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/UserEventDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/UserEventDispatcher.java index dd2ffa63df..b83351da2c 100644 --- a/src/main/java/com/netgrif/application/engine/event/dispatchers/UserEventDispatcher.java +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/UserEventDispatcher.java @@ -21,11 +21,6 @@ public String getId() { return "userEventDispatcher"; } - @Override - public List getRequiredPluginIds() { - return Collections.singletonList("pluginex"); - } - @EventListener public void listen(UserEvent object) { super.listen(object); From 35f714f3734b71914f36c0aba6d23ca2e0bafb5b Mon Sep 17 00:00:00 2001 From: Stefan Renczes Date: Mon, 7 Mar 2022 10:57:10 +0100 Subject: [PATCH 04/13] [NAE-1567] Global event system - refactored dispatcher registering --- .../event/services/EventSystemService.java | 16 +++++------- .../plugins/services/PluginService.java | 25 +++++++++++++++++-- .../services/interfaces/IPluginService.java | 5 +++- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/netgrif/application/engine/event/services/EventSystemService.java b/src/main/java/com/netgrif/application/engine/event/services/EventSystemService.java index f98e3febc5..102c73f1e6 100644 --- a/src/main/java/com/netgrif/application/engine/event/services/EventSystemService.java +++ b/src/main/java/com/netgrif/application/engine/event/services/EventSystemService.java @@ -23,15 +23,11 @@ public class EventSystemService implements IEventSystemService { * */ @Override public void registerDispatcher(IDispatcher dispatcher) { - if (dispatcher.getRequiredPluginIds() != null) { - dispatcher.getRequiredPluginIds().forEach(pluginId -> { - Plugin plugin = this.pluginService.getPlugin(pluginId); - if (plugin instanceof NaePlugin) { - NaePlugin naePlugin = (NaePlugin) plugin; - naePlugin.getEventManager().addDispatcher(dispatcher); - naePlugin.getEventManager().registerSubscribers(dispatcher); - } - }); - } + this.pluginService.getAllPlugin().stream() + .filter(plugin -> plugin.getEventManager().getRequiredDispatchers().contains(dispatcher.getId())) + .forEach(plugin -> { + plugin.getEventManager().addDispatcher(dispatcher); + plugin.getEventManager().registerSubscribers(dispatcher); + }); } } diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/services/PluginService.java b/src/main/java/com/netgrif/application/engine/integration/plugins/services/PluginService.java index 6c7acd94c8..79b4d23bdf 100644 --- a/src/main/java/com/netgrif/application/engine/integration/plugins/services/PluginService.java +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/services/PluginService.java @@ -21,6 +21,7 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; /** * Service for managing plugins in NAE @@ -55,8 +56,28 @@ else if (pluginProperties.getPluginFileNames().length > 0) * @return the required plugin * */ @Override - public final Plugin getPlugin(String pluginId) { - return this.pluginManager.getPlugin(pluginId).getPlugin(); + public final NaePlugin getPlugin(String pluginId) { + Plugin plugin = this.pluginManager.getPlugin(pluginId).getPlugin(); + if (!(plugin instanceof NaePlugin)) { + log.error("Plugin " + plugin.toString() + " is not type of NaePlugin."); + return null; + } + return (NaePlugin) plugin; + } + + /** + * Returns all NaePlugin + * @return the required plugins + * */ + @Override + public final List getAllPlugin() { + List plugins = this.pluginManager.getPlugins().stream().map(pw -> { + if (pw.getPlugin() instanceof NaePlugin) + return (NaePlugin) pw.getPlugin(); + else + return null; + }).collect(Collectors.toList()); + return plugins; } /** diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IPluginService.java b/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IPluginService.java index a9a1eadbe9..d92776de58 100644 --- a/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IPluginService.java +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IPluginService.java @@ -1,12 +1,15 @@ package com.netgrif.application.engine.integration.plugins.services.interfaces; import org.pf4j.Plugin; +import wrapper.NaePlugin; import java.util.List; public interface IPluginService { - Plugin getPlugin(String pluginId); + NaePlugin getPlugin(String pluginId); + + List getAllPlugin(); T call(String pluginId, String extensionName, String method, List argumentValues, Class returnType); } From 91ff1f47a9be5120d74e1cd40a4774b90e4f5575 Mon Sep 17 00:00:00 2001 From: Stefan Renczes Date: Fri, 27 May 2022 11:35:46 +0200 Subject: [PATCH 05/13] [NAE-1567] Plugin management - implemented converter for DTO objects - implemented plugin configuration - added modelmapper dependency --- pom.xml | 5 + .../logic/action/ActionDelegate.groovy | 4 + .../PluginIntegrationConfiguration.java | 119 ++++++++++++++++++ .../config/PluginManagerConfiguration.java | 16 --- .../plugins/services/DtoConverterService.java | 64 ++++++++++ .../interfaces/IDtoConverterService.java | 21 ++++ 6 files changed, 213 insertions(+), 16 deletions(-) create mode 100644 src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginIntegrationConfiguration.java delete mode 100644 src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginManagerConfiguration.java create mode 100644 src/main/java/com/netgrif/application/engine/integration/plugins/services/DtoConverterService.java create mode 100644 src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IDtoConverterService.java diff --git a/pom.xml b/pom.xml index f2f08132dd..0fe29c3460 100644 --- a/pom.xml +++ b/pom.xml @@ -421,6 +421,11 @@ plugin-library 0.0.1 + + org.modelmapper + modelmapper + 3.1.0 + diff --git a/src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/logic/action/ActionDelegate.groovy b/src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/logic/action/ActionDelegate.groovy index a39bc311d3..747de637b0 100644 --- a/src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/logic/action/ActionDelegate.groovy +++ b/src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/logic/action/ActionDelegate.groovy @@ -9,6 +9,7 @@ import com.netgrif.application.engine.auth.service.interfaces.IUserService import com.netgrif.application.engine.auth.web.requestbodies.NewUserRequest import com.netgrif.application.engine.configuration.ApplicationContextProvider import com.netgrif.application.engine.importer.service.FieldFactory +import com.netgrif.application.engine.integration.plugins.services.interfaces.IDtoConverterService import com.netgrif.application.engine.mail.domain.MailDraft import com.netgrif.application.engine.mail.interfaces.IMailAttemptService import com.netgrif.application.engine.mail.interfaces.IMailService @@ -130,6 +131,9 @@ class ActionDelegate { @Autowired IFilterImportExportService filterImportExportService + @Autowired + IDtoConverterService dtoConverterService + /** * Reference of case and task in which current action is taking place. */ diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginIntegrationConfiguration.java b/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginIntegrationConfiguration.java new file mode 100644 index 0000000000..3e8404c17a --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginIntegrationConfiguration.java @@ -0,0 +1,119 @@ +package com.netgrif.application.engine.integration.plugins.config; + +import com.netgrif.application.engine.petrinet.domain.dataset.*; +import com.netgrif.application.engine.workflow.web.responsebodies.*; +import lombok.extern.slf4j.Slf4j; +import org.modelmapper.ModelMapper; +import org.pf4j.JarPluginManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import petrinet.domain.dataset.*; +import workflow.web.responsebodies.*; + +import java.lang.reflect.Type; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * Configuration class for plugin management + * */ +@Slf4j +@Configuration +public class PluginIntegrationConfiguration { + + private static final Class[] fieldClasses = new Class[] { + BooleanField.class, + ButtonField.class, + CaseField.class, + DateField.class, + DateTimeField.class, + EnumerationField.class, + EnumerationMapField.class, + FileField.class, + FileListField.class, + FilterField.class, + I18nField.class, + MultichoiceField.class, + MultichoiceMapField.class, + NumberField.class, + TaskField.class, + TextField.class, + UserField.class + }; + + private static final Class[] localisedFieldClasses = new Class[] { + LocalisedBooleanField.class, + LocalisedCaseField.class, + LocalisedDateField.class, + LocalisedDateTimeField.class, + LocalisedEnumerationField.class, + LocalisedEnumerationMapField.class, + LocalisedFileListField.class, + LocalisedFilterField.class, + LocalisedI18nField.class, + LocalisedMultichoiceField.class, + LocalisedMultichoiceMapField.class, + LocalisedNumberField.class, + LocalisedTextField.class, + LocalisedUserField.class + }; + + private static final Map>> fieldTypeMapping = new HashMap<>() {{ + put(FieldType.BOOLEAN, List.of(BooleanFieldDto.class, LocalisedBooleanFieldDto.class)); + put(FieldType.BUTTON, List.of(ButtonFieldDto.class)); + put(FieldType.CASE_REF, List.of(CaseFieldDto.class, LocalisedCaseFieldDto.class)); + put(FieldType.DATE, List.of(DateFieldDto.class, LocalisedDateFieldDto.class)); + put(FieldType.DATETIME, List.of(DateTimeFieldDto.class, LocalisedDateFieldDto.class)); + put(FieldType.ENUMERATION, List.of(EnumerationFieldDto.class, LocalisedEnumerationFieldDto.class)); + put(FieldType.ENUMERATION_MAP, List.of(EnumerationMapFieldDto.class, LocalisedEnumerationMapFieldDto.class)); + put(FieldType.FILE, List.of(FileFieldDto.class)); + put(FieldType.FILELIST, List.of(FileListFieldDto.class, LocalisedFileListFieldDto.class)); + put(FieldType.FILTER, List.of(FilterFieldDto.class, LocalisedFilterFieldDto.class)); + put(FieldType.I18N, List.of(I18nFieldDto.class, LocalisedI18nFieldDto.class)); + put(FieldType.MULTICHOICE, List.of(MultichoiceFieldDto.class, LocalisedMultichoiceFieldDto.class)); + put(FieldType.MULTICHOICE_MAP, List.of(MultichoiceMapFieldDto.class, LocalisedMultichoiceMapFieldDto.class)); + put(FieldType.NUMBER, List.of(NumberFieldDto.class, LocalisedNumberFieldDto.class)); + put(FieldType.TASK_REF, List.of(TaskFieldDto.class)); + put(FieldType.TEXT, List.of(TextFieldDto.class, LocalisedTextFieldDto.class)); + put(FieldType.USER, List.of(UserFieldDto.class, LocalisedUserFieldDto.class)); + put(FieldType.USERLIST, List.of(UserListFieldDto.class)); + }}; + + /** + * The plugin manager bean to load plugins as JAR files + * */ + @Bean + public JarPluginManager pluginManager() { + return new JarPluginManager(); + } + + + /** + * Model mapper bean to convert domain objects to DTOs + * */ + @Bean + public ModelMapper modelMapper() { + ModelMapper mapper = new ModelMapper(); + + Arrays.stream(fieldClasses).forEach(c -> + mapper.createTypeMap(c, FieldDto.class).setConverter(ctx -> fieldToDto((Field) ctx.getSource()))); + + Arrays.stream(localisedFieldClasses).forEach(c -> + mapper.createTypeMap(c, LocalisedFieldDto.class).setConverter(ctx -> localisedFieldToDto((LocalisedField) ctx.getSource()))); + + return mapper; + } + + private FieldDto fieldToDto(Field field) { + final ModelMapper innerMapper = new ModelMapper(); + return innerMapper.map(field, (Type) fieldTypeMapping.get(field.getType()).get(0)); + } + + private LocalisedFieldDto localisedFieldToDto(LocalisedField field) { + final ModelMapper innerMapper = new ModelMapper(); + return innerMapper.map(field, (Type) fieldTypeMapping.get(field.getType()).get(1)); + } +} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginManagerConfiguration.java b/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginManagerConfiguration.java deleted file mode 100644 index 044a31cbe4..0000000000 --- a/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginManagerConfiguration.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.netgrif.application.engine.integration.plugins.config; - -import lombok.extern.slf4j.Slf4j; -import org.pf4j.JarPluginManager; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Slf4j -@Configuration -public class PluginManagerConfiguration { - - @Bean - public JarPluginManager pluginManager() { - return new JarPluginManager(); - } -} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/services/DtoConverterService.java b/src/main/java/com/netgrif/application/engine/integration/plugins/services/DtoConverterService.java new file mode 100644 index 0000000000..e2c7ea2ded --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/services/DtoConverterService.java @@ -0,0 +1,64 @@ +package com.netgrif.application.engine.integration.plugins.services; + +import com.netgrif.application.engine.integration.plugins.services.interfaces.IDtoConverterService; +import com.netgrif.application.engine.petrinet.domain.DataGroup; +import com.netgrif.application.engine.petrinet.domain.PetriNet; +import com.netgrif.application.engine.workflow.domain.Case; +import com.netgrif.application.engine.workflow.domain.Task; +import org.modelmapper.ModelMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import petrinet.domain.DataGroupDto; +import petrinet.domain.PetriNetDto; +import workflow.domain.CaseDto; +import workflow.domain.TaskDto; + +/** + * Converter service to turn domain objects of NAE into DTO objects of NAE-API library + * */ +@Service +public class DtoConverterService implements IDtoConverterService { + + @Autowired + private ModelMapper modelMapper; + + /** + * Converts Petri Net into its DTO object + * @param net the input Petri Net to be converted into DTO + * @return Petri Net DTO object + * */ + @Override + public PetriNetDto convertPetriNet(PetriNet net) { + return modelMapper.map(net, PetriNetDto.class); + } + + /** + * Converts case into its DTO object + * @param aCase the input case to be converted into DTO + * @return case DTO object + * */ + @Override + public CaseDto convertCase(Case aCase) { + return modelMapper.map(aCase, CaseDto.class); + } + + /** + * Converts data task its DTO object + * @param task the input task to be converted into DTO + * @return task DTO object + * */ + @Override + public TaskDto convertTask(Task task) { + return modelMapper.map(task, TaskDto.class); + } + + /** + * Converts data group into its DTO object + * @param dataGroup the input data group to be converted into DTO + * @return data group DTO object + * */ + @Override + public DataGroupDto convertDataGroup(DataGroup dataGroup) { + return modelMapper.map(dataGroup, DataGroupDto.class); + } +} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IDtoConverterService.java b/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IDtoConverterService.java new file mode 100644 index 0000000000..9deb4a5fd0 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IDtoConverterService.java @@ -0,0 +1,21 @@ +package com.netgrif.application.engine.integration.plugins.services.interfaces; + +import com.netgrif.application.engine.petrinet.domain.DataGroup; +import com.netgrif.application.engine.petrinet.domain.PetriNet; +import com.netgrif.application.engine.workflow.domain.Case; +import com.netgrif.application.engine.workflow.domain.Task; +import petrinet.domain.DataGroupDto; +import petrinet.domain.PetriNetDto; +import workflow.domain.CaseDto; +import workflow.domain.TaskDto; + +public interface IDtoConverterService { + + DataGroupDto convertDataGroup(DataGroup dataGroup); + + PetriNetDto convertPetriNet(PetriNet net); + + CaseDto convertCase(Case aCase); + + TaskDto convertTask(Task task); +} From 69d38d6994051fb9a1986735aeed0893b1a9ba88 Mon Sep 17 00:00:00 2001 From: Stefan Renczes Date: Wed, 1 Jun 2022 14:35:14 +0200 Subject: [PATCH 06/13] [NAE-1567] Plugin management - added nae-api into project --- src/main/java/api/auth/AuthorDto.java | 22 + src/main/java/api/events/IDispatcher.java | 25 ++ src/main/java/api/events/IEvent.java | 4 + src/main/java/api/events/ISubscriber.java | 38 ++ .../api/petrinet/domain/ComponentDto.java | 14 + .../petrinet/domain/DataFieldLogicDto.java | 60 +++ .../domain/DataFieldsResourceDto.java | 25 ++ .../api/petrinet/domain/DataGroupDto.java | 135 ++++++ .../java/api/petrinet/domain/FunctionDto.java | 54 +++ .../api/petrinet/domain/I18nStringDto.java | 50 +++ .../java/api/petrinet/domain/IconDto.java | 19 + .../java/api/petrinet/domain/ImportedDto.java | 20 + .../java/api/petrinet/domain/NodeDto.java | 42 ++ .../java/api/petrinet/domain/PetriNetDto.java | 297 ++++++++++++++ .../petrinet/domain/PetriNetObjectDto.java | 21 + .../java/api/petrinet/domain/PlaceDto.java | 62 +++ .../java/api/petrinet/domain/PositionDto.java | 32 ++ .../api/petrinet/domain/TransactionDto.java | 44 ++ .../api/petrinet/domain/TransitionDto.java | 252 ++++++++++++ .../java/api/petrinet/domain/arcs/ArcDto.java | 79 ++++ .../arcs/reference/ReferencableDto.java | 21 + .../domain/arcs/reference/ReferenceDto.java | 44 ++ .../domain/dataset/BooleanFieldDto.java | 22 + .../domain/dataset/ButtonFieldDto.java | 22 + .../petrinet/domain/dataset/CaseFieldDto.java | 30 ++ .../domain/dataset/ChoiceFieldDto.java | 54 +++ .../petrinet/domain/dataset/DateFieldDto.java | 23 ++ .../domain/dataset/DateTimeFieldDto.java | 22 + .../domain/dataset/EnumerationFieldDto.java | 31 ++ .../dataset/EnumerationMapFieldDto.java | 30 ++ .../api/petrinet/domain/dataset/FieldDto.java | 231 +++++++++++ .../dataset/FieldWithAllowedNetsDto.java | 41 ++ .../petrinet/domain/dataset/FileFieldDto.java | 41 ++ .../domain/dataset/FileFieldValueDto.java | 32 ++ .../domain/dataset/FileListFieldDto.java | 41 ++ .../domain/dataset/FileListFieldValueDto.java | 24 ++ .../domain/dataset/FilterFieldDto.java | 40 ++ .../petrinet/domain/dataset/I18nFieldDto.java | 22 + .../domain/dataset/MapOptionsFieldDto.java | 53 +++ .../domain/dataset/MultichoiceFieldDto.java | 31 ++ .../dataset/MultichoiceMapFieldDto.java | 31 ++ .../domain/dataset/NumberFieldDto.java | 53 +++ .../petrinet/domain/dataset/TaskFieldDto.java | 23 ++ .../petrinet/domain/dataset/TextFieldDto.java | 65 +++ .../petrinet/domain/dataset/UserFieldDto.java | 42 ++ .../domain/dataset/UserFieldValueDto.java | 58 +++ .../domain/dataset/UserListFieldDto.java | 22 + .../domain/dataset/logic/FieldLayoutDto.java | 88 ++++ .../dataset/logic/action/ActionDto.java | 79 ++++ .../logic/action/runner/ExpressionDto.java | 30 ++ .../validation/LocalisedValidationDto.java | 24 ++ .../logic/validation/ValidationDto.java | 27 ++ .../petrinet/domain/events/BaseEventDto.java | 71 ++++ .../petrinet/domain/events/CaseEventDto.java | 35 ++ .../petrinet/domain/events/DataEventDto.java | 27 ++ .../api/petrinet/domain/events/EventDto.java | 27 ++ .../domain/events/ProcessEventDto.java | 27 ++ .../domain/layout/DataGroupLayoutDto.java | 19 + .../petrinet/domain/layout/FormLayoutDto.java | 54 +++ .../api/petrinet/domain/layout/LayoutDto.java | 32 ++ .../petrinet/domain/layout/TaskLayoutDto.java | 62 +++ .../petrinet/domain/roles/ProcessRoleDto.java | 84 ++++ .../java/api/petrinet/version/VersionDto.java | 43 ++ .../java/api/workflow/domain/CaseDto.java | 303 ++++++++++++++ .../api/workflow/domain/DataFieldDto.java | 116 ++++++ .../java/api/workflow/domain/TaskDto.java | 383 ++++++++++++++++++ .../java/api/workflow/domain/TaskPairDto.java | 32 ++ .../workflow/domain/triggers/TriggerDto.java | 23 ++ .../LocalisedBooleanFieldDto.java | 18 + .../responsebodies/LocalisedCaseFieldDto.java | 29 ++ .../LocalisedChoiceFieldDto.java | 37 ++ .../responsebodies/LocalisedDateFieldDto.java | 49 +++ .../LocalisedDateTimeFieldDto.java | 49 +++ .../LocalisedEnumerationFieldDto.java | 26 ++ .../LocalisedEnumerationMapFieldDto.java | 27 ++ .../web/responsebodies/LocalisedFieldDto.java | 171 ++++++++ .../LocalisedFileListFieldDto.java | 18 + .../LocalisedFilterFieldDto.java | 49 +++ .../responsebodies/LocalisedI18nFieldDto.java | 18 + .../LocalisedMapOptionsFieldDto.java | 38 ++ .../LocalisedMultichoiceFieldDto.java | 26 ++ .../LocalisedMultichoiceMapFieldDto.java | 28 ++ .../LocalisedNumberFieldDto.java | 18 + .../responsebodies/LocalisedTextFieldDto.java | 18 + .../responsebodies/LocalisedUserFieldDto.java | 38 ++ 85 files changed, 4687 insertions(+) create mode 100644 src/main/java/api/auth/AuthorDto.java create mode 100644 src/main/java/api/events/IDispatcher.java create mode 100644 src/main/java/api/events/IEvent.java create mode 100644 src/main/java/api/events/ISubscriber.java create mode 100644 src/main/java/api/petrinet/domain/ComponentDto.java create mode 100644 src/main/java/api/petrinet/domain/DataFieldLogicDto.java create mode 100644 src/main/java/api/petrinet/domain/DataFieldsResourceDto.java create mode 100644 src/main/java/api/petrinet/domain/DataGroupDto.java create mode 100644 src/main/java/api/petrinet/domain/FunctionDto.java create mode 100644 src/main/java/api/petrinet/domain/I18nStringDto.java create mode 100644 src/main/java/api/petrinet/domain/IconDto.java create mode 100644 src/main/java/api/petrinet/domain/ImportedDto.java create mode 100644 src/main/java/api/petrinet/domain/NodeDto.java create mode 100644 src/main/java/api/petrinet/domain/PetriNetDto.java create mode 100644 src/main/java/api/petrinet/domain/PetriNetObjectDto.java create mode 100644 src/main/java/api/petrinet/domain/PlaceDto.java create mode 100644 src/main/java/api/petrinet/domain/PositionDto.java create mode 100644 src/main/java/api/petrinet/domain/TransactionDto.java create mode 100644 src/main/java/api/petrinet/domain/TransitionDto.java create mode 100644 src/main/java/api/petrinet/domain/arcs/ArcDto.java create mode 100644 src/main/java/api/petrinet/domain/arcs/reference/ReferencableDto.java create mode 100644 src/main/java/api/petrinet/domain/arcs/reference/ReferenceDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/BooleanFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/ButtonFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/CaseFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/ChoiceFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/DateFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/DateTimeFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/EnumerationFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/EnumerationMapFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/FieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/FieldWithAllowedNetsDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/FileFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/FileFieldValueDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/FileListFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/FileListFieldValueDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/FilterFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/I18nFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/MapOptionsFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/MultichoiceFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/MultichoiceMapFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/NumberFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/TaskFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/TextFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/UserFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/UserFieldValueDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/UserListFieldDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/logic/FieldLayoutDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/logic/action/ActionDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/logic/action/runner/ExpressionDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/logic/validation/LocalisedValidationDto.java create mode 100644 src/main/java/api/petrinet/domain/dataset/logic/validation/ValidationDto.java create mode 100644 src/main/java/api/petrinet/domain/events/BaseEventDto.java create mode 100644 src/main/java/api/petrinet/domain/events/CaseEventDto.java create mode 100644 src/main/java/api/petrinet/domain/events/DataEventDto.java create mode 100644 src/main/java/api/petrinet/domain/events/EventDto.java create mode 100644 src/main/java/api/petrinet/domain/events/ProcessEventDto.java create mode 100644 src/main/java/api/petrinet/domain/layout/DataGroupLayoutDto.java create mode 100644 src/main/java/api/petrinet/domain/layout/FormLayoutDto.java create mode 100644 src/main/java/api/petrinet/domain/layout/LayoutDto.java create mode 100644 src/main/java/api/petrinet/domain/layout/TaskLayoutDto.java create mode 100644 src/main/java/api/petrinet/domain/roles/ProcessRoleDto.java create mode 100644 src/main/java/api/petrinet/version/VersionDto.java create mode 100644 src/main/java/api/workflow/domain/CaseDto.java create mode 100644 src/main/java/api/workflow/domain/DataFieldDto.java create mode 100644 src/main/java/api/workflow/domain/TaskDto.java create mode 100644 src/main/java/api/workflow/domain/TaskPairDto.java create mode 100644 src/main/java/api/workflow/domain/triggers/TriggerDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedBooleanFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedCaseFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedChoiceFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedDateFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedDateTimeFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationMapFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedFileListFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedFilterFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedI18nFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedMapOptionsFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceMapFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedNumberFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedTextFieldDto.java create mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedUserFieldDto.java diff --git a/src/main/java/api/auth/AuthorDto.java b/src/main/java/api/auth/AuthorDto.java new file mode 100644 index 0000000000..21ab8c1798 --- /dev/null +++ b/src/main/java/api/auth/AuthorDto.java @@ -0,0 +1,22 @@ +package api.auth; + +public final class AuthorDto { + + private String id; + + private String email; + + private String fullName; + + public String getId() { + return this.id; + } + + public String getEmail() { + return this.email; + } + + public String getFullName() { + return this.fullName; + } +} diff --git a/src/main/java/api/events/IDispatcher.java b/src/main/java/api/events/IDispatcher.java new file mode 100644 index 0000000000..743cb47645 --- /dev/null +++ b/src/main/java/api/events/IDispatcher.java @@ -0,0 +1,25 @@ +package api.events; + +/** + * Interface for event dispatcher + * */ +public interface IDispatcher { + + /** + * Returns ID of dispatcher + * */ + String getId(); + + /** + * Registers ISubscriber object to dispatcher + * @param subscriber a subscriber object from plugin + * */ + void registerSubscriber(ISubscriber subscriber); + + /** + * Listener function for a type of event + * @param eventClass + * */ + void listen(Class eventClass, T event); + void listen(IEvent event); +} diff --git a/src/main/java/api/events/IEvent.java b/src/main/java/api/events/IEvent.java new file mode 100644 index 0000000000..b3b3bfb293 --- /dev/null +++ b/src/main/java/api/events/IEvent.java @@ -0,0 +1,4 @@ +package api.events; + +public interface IEvent { +} diff --git a/src/main/java/api/events/ISubscriber.java b/src/main/java/api/events/ISubscriber.java new file mode 100644 index 0000000000..ab5522098c --- /dev/null +++ b/src/main/java/api/events/ISubscriber.java @@ -0,0 +1,38 @@ +package api.events; + +import java.util.List; + +/** + * Interface for the event subscriber + * */ +public interface ISubscriber { + + /** + * Returns dispatcher IDs, where the subscriber needs to be subscribed + * @return list of IDs + * */ + List getRequiredDispatcherIds(); + + /** + * Subscribes the subscriber to dispatchers. + * */ + void subscribeToDispatchers(); + + /** + * Subscribes the subscriber to one dispatcher. + * */ + void subscribeToDispatcher(IDispatcher dispatcher); + + /** + * Listener function that is called, when an event has been caught in dispatcher + * @param event the event object that is being sent to subscriber + * */ + Object onEvent(IEvent event); + + /** + * Listener function that is called, when an event has been caught in dispatcher + * @param eventClass the type of the event object + * @param event the event object + * */ + void onEvent(Class eventClass, T event); +} diff --git a/src/main/java/api/petrinet/domain/ComponentDto.java b/src/main/java/api/petrinet/domain/ComponentDto.java new file mode 100644 index 0000000000..547f680978 --- /dev/null +++ b/src/main/java/api/petrinet/domain/ComponentDto.java @@ -0,0 +1,14 @@ +package api.petrinet.domain; + +import java.util.List; +import java.util.Map; + +public class ComponentDto { + + private String name; + + private Map properties; + + private List optionIcons; + +} diff --git a/src/main/java/api/petrinet/domain/DataFieldLogicDto.java b/src/main/java/api/petrinet/domain/DataFieldLogicDto.java new file mode 100644 index 0000000000..5abee2d201 --- /dev/null +++ b/src/main/java/api/petrinet/domain/DataFieldLogicDto.java @@ -0,0 +1,60 @@ +package api.petrinet.domain; + +import api.petrinet.domain.events.DataEventDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.Map; +import java.util.Set; + +public class DataFieldLogicDto { + + private Set behavior; + + private Map events; + + private FieldLayoutDto layout; + + private ComponentDto component; + + public DataFieldLogicDto() { + } + + public DataFieldLogicDto(Set behavior, Map events, FieldLayoutDto layout, ComponentDto component) { + this.behavior = behavior; + this.events = events; + this.layout = layout; + this.component = component; + } + + public Set getBehavior() { + return behavior; + } + + public void setBehavior(Set behavior) { + this.behavior = behavior; + } + + public Map getEvents() { + return events; + } + + public void setEvents(Map events) { + this.events = events; + } + + public FieldLayoutDto getLayout() { + return layout; + } + + public void setLayout(FieldLayoutDto layout) { + this.layout = layout; + } + + public ComponentDto getComponent() { + return component; + } + + public void setComponent(ComponentDto component) { + this.component = component; + } +} diff --git a/src/main/java/api/petrinet/domain/DataFieldsResourceDto.java b/src/main/java/api/petrinet/domain/DataFieldsResourceDto.java new file mode 100644 index 0000000000..238083a3a9 --- /dev/null +++ b/src/main/java/api/petrinet/domain/DataFieldsResourceDto.java @@ -0,0 +1,25 @@ +package api.petrinet.domain; + +import api.workflow.web.responsebodies.LocalisedFieldDto; + +import java.util.Collection; + +public class DataFieldsResourceDto { + + private Collection content; + + public DataFieldsResourceDto() { + } + + public DataFieldsResourceDto(Collection content) { + this.content = content; + } + + public Collection getContent() { + return content; + } + + public void setContent(Collection content) { + this.content = content; + } +} diff --git a/src/main/java/api/petrinet/domain/DataGroupDto.java b/src/main/java/api/petrinet/domain/DataGroupDto.java new file mode 100644 index 0000000000..0f2ff1f256 --- /dev/null +++ b/src/main/java/api/petrinet/domain/DataGroupDto.java @@ -0,0 +1,135 @@ +package api.petrinet.domain; + +import api.petrinet.domain.layout.DataGroupLayoutDto; + +import java.util.Set; + +public class DataGroupDto extends PetriNetObjectDto { + + private Set data; + + private DataFieldsResourceDto fields; + + private DataGroupLayoutDto layout; + + private I18nStringDto title; + + private String alignment; + + private Boolean stretch; + + private String parentTaskId; + + private String parentTransitionId; + + private String parentCaseId; + + private String parentTaskRefId; + + private int nestingLevel; + + public DataGroupDto() { + } + + public DataGroupDto(Set data, DataFieldsResourceDto fields, DataGroupLayoutDto layout, I18nStringDto title, String alignment, Boolean stretch, String parentTaskId, String parentTransitionId, String parentCaseId, String parentTaskRefId, int nestingLevel) { + this.data = data; + this.fields = fields; + this.layout = layout; + this.title = title; + this.alignment = alignment; + this.stretch = stretch; + this.parentTaskId = parentTaskId; + this.parentTransitionId = parentTransitionId; + this.parentCaseId = parentCaseId; + this.parentTaskRefId = parentTaskRefId; + this.nestingLevel = nestingLevel; + } + + public Set getData() { + return data; + } + + public void setData(Set data) { + this.data = data; + } + + public DataFieldsResourceDto getFields() { + return fields; + } + + public void setFields(DataFieldsResourceDto fields) { + this.fields = fields; + } + + public DataGroupLayoutDto getLayout() { + return layout; + } + + public void setLayout(DataGroupLayoutDto layout) { + this.layout = layout; + } + + public I18nStringDto getTitle() { + return title; + } + + public void setTitle(I18nStringDto title) { + this.title = title; + } + + public String getAlignment() { + return alignment; + } + + public void setAlignment(String alignment) { + this.alignment = alignment; + } + + public Boolean getStretch() { + return stretch; + } + + public void setStretch(Boolean stretch) { + this.stretch = stretch; + } + + public String getParentTaskId() { + return parentTaskId; + } + + public void setParentTaskId(String parentTaskId) { + this.parentTaskId = parentTaskId; + } + + public String getParentTransitionId() { + return parentTransitionId; + } + + public void setParentTransitionId(String parentTransitionId) { + this.parentTransitionId = parentTransitionId; + } + + public String getParentCaseId() { + return parentCaseId; + } + + public void setParentCaseId(String parentCaseId) { + this.parentCaseId = parentCaseId; + } + + public String getParentTaskRefId() { + return parentTaskRefId; + } + + public void setParentTaskRefId(String parentTaskRefId) { + this.parentTaskRefId = parentTaskRefId; + } + + public int getNestingLevel() { + return nestingLevel; + } + + public void setNestingLevel(int nestingLevel) { + this.nestingLevel = nestingLevel; + } +} diff --git a/src/main/java/api/petrinet/domain/FunctionDto.java b/src/main/java/api/petrinet/domain/FunctionDto.java new file mode 100644 index 0000000000..d6361dd0eb --- /dev/null +++ b/src/main/java/api/petrinet/domain/FunctionDto.java @@ -0,0 +1,54 @@ +package api.petrinet.domain; + +public class FunctionDto extends PetriNetObjectDto { + + private String definition; + + private String name; + + private String scope; + + public FunctionDto() { + } + + public FunctionDto(String id) { + super(id); + } + + public FunctionDto(String definition, String name, String scope) { + this.definition = definition; + this.name = name; + this.scope = scope; + } + + public FunctionDto(String id, String definition, String name, String scope) { + super(id); + this.definition = definition; + this.name = name; + this.scope = scope; + } + + public String getDefinition() { + return definition; + } + + public void setDefinition(String definition) { + this.definition = definition; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } +} diff --git a/src/main/java/api/petrinet/domain/I18nStringDto.java b/src/main/java/api/petrinet/domain/I18nStringDto.java new file mode 100644 index 0000000000..2dfaaaf548 --- /dev/null +++ b/src/main/java/api/petrinet/domain/I18nStringDto.java @@ -0,0 +1,50 @@ +package api.petrinet.domain; + +import java.util.Map; + +public final class I18nStringDto { + + private String defaultValue; + + private String key; + + private Map translations; + + public I18nStringDto() { + } + + public I18nStringDto(String defaultValue, String key, Map translations) { + this.defaultValue = defaultValue; + this.key = key; + this.translations = translations; + } + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public Map getTranslations() { + return translations; + } + + public void setTranslations(Map translations) { + this.translations = translations; + } + + @Override + public String toString() { + return defaultValue; + } +} diff --git a/src/main/java/api/petrinet/domain/IconDto.java b/src/main/java/api/petrinet/domain/IconDto.java new file mode 100644 index 0000000000..ac31567011 --- /dev/null +++ b/src/main/java/api/petrinet/domain/IconDto.java @@ -0,0 +1,19 @@ +package api.petrinet.domain; + +public class IconDto { + + private String key; + + private String value; + + private String type; + + public IconDto() { + } + + public IconDto(String key, String value, String type) { + this.key = key; + this.value = value; + this.type = type; + } +} diff --git a/src/main/java/api/petrinet/domain/ImportedDto.java b/src/main/java/api/petrinet/domain/ImportedDto.java new file mode 100644 index 0000000000..651a0fb6fa --- /dev/null +++ b/src/main/java/api/petrinet/domain/ImportedDto.java @@ -0,0 +1,20 @@ +package api.petrinet.domain; + +public class ImportedDto { + private String importId; + + public String getImportId() { + return importId; + } + + public void setImportId(String id) { + this.importId = id; + } + + public ImportedDto() { + } + + public ImportedDto(String importId) { + this.importId = importId; + } +} diff --git a/src/main/java/api/petrinet/domain/NodeDto.java b/src/main/java/api/petrinet/domain/NodeDto.java new file mode 100644 index 0000000000..e2ae16adbc --- /dev/null +++ b/src/main/java/api/petrinet/domain/NodeDto.java @@ -0,0 +1,42 @@ +package api.petrinet.domain; + +public class NodeDto extends PetriNetObjectDto { + + private PositionDto position; + + private I18nStringDto title; + + public NodeDto() { + } + + public NodeDto(String id) { + super(id); + } + + public NodeDto(PositionDto position, I18nStringDto title) { + this.position = position; + this.title = title; + } + + public NodeDto(String id, PositionDto position, I18nStringDto title) { + super(id); + this.position = position; + this.title = title; + } + + public PositionDto getPosition() { + return position; + } + + public void setPosition(PositionDto position) { + this.position = position; + } + + public I18nStringDto getTitle() { + return title; + } + + public void setTitle(I18nStringDto title) { + this.title = title; + } +} diff --git a/src/main/java/api/petrinet/domain/PetriNetDto.java b/src/main/java/api/petrinet/domain/PetriNetDto.java new file mode 100644 index 0000000000..8e961532af --- /dev/null +++ b/src/main/java/api/petrinet/domain/PetriNetDto.java @@ -0,0 +1,297 @@ +package api.petrinet.domain; + +import api.auth.AuthorDto; +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.arcs.ArcDto; +import api.petrinet.domain.dataset.FieldDto; +import api.petrinet.domain.events.CaseEventDto; +import api.petrinet.domain.events.ProcessEventDto; +import api.petrinet.domain.roles.ProcessRoleDto; +import api.petrinet.version.VersionDto; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; + +public class PetriNetDto extends PetriNetObjectDto { + private String identifier; + + private I18nStringDto title; + + private boolean defaultRoleEnabled; + + private boolean anonymousRoleEnabled; + + private I18nStringDto defaultCaseName; + + private ExpressionDto defaultCaseNameExpression; + + private String initials; + + private String icon; + + private LocalDateTime creationDate; + + private VersionDto version; + + private AuthorDto author; + + private Map places; + + private Map transitions; + + private Map> arcs; + + private Map dataSet; + + private Map roles; + + private Map transactions; + + private Map processEvents; + + private Map caseEvents; + + private Map> permissions; + + private List negativeViewRoles; + + private Map> userRefs; + + private List functions; + + private boolean initialized; + + private String importXmlPath; + + public PetriNetDto() { + } + + public PetriNetDto(String identifier, I18nStringDto title, boolean defaultRoleEnabled, boolean anonymousRoleEnabled, I18nStringDto defaultCaseName, ExpressionDto defaultCaseNameExpression, String initials, String icon, LocalDateTime creationDate, VersionDto version, AuthorDto author, Map places, Map transitions, Map> arcs, Map dataSet, Map roles, Map transactions, Map processEvents, Map caseEvents, Map> permissions, List negativeViewRoles, Map> userRefs, List functions, boolean initialized, String importXmlPath) { + this.identifier = identifier; + this.title = title; + this.defaultRoleEnabled = defaultRoleEnabled; + this.anonymousRoleEnabled = anonymousRoleEnabled; + this.defaultCaseName = defaultCaseName; + this.defaultCaseNameExpression = defaultCaseNameExpression; + this.initials = initials; + this.icon = icon; + this.creationDate = creationDate; + this.version = version; + this.author = author; + this.places = places; + this.transitions = transitions; + this.arcs = arcs; + this.dataSet = dataSet; + this.roles = roles; + this.transactions = transactions; + this.processEvents = processEvents; + this.caseEvents = caseEvents; + this.permissions = permissions; + this.negativeViewRoles = negativeViewRoles; + this.userRefs = userRefs; + this.functions = functions; + this.initialized = initialized; + this.importXmlPath = importXmlPath; + } + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + public I18nStringDto getTitle() { + return title; + } + + public void setTitle(I18nStringDto title) { + this.title = title; + } + + public boolean isDefaultRoleEnabled() { + return defaultRoleEnabled; + } + + public void setDefaultRoleEnabled(boolean defaultRoleEnabled) { + this.defaultRoleEnabled = defaultRoleEnabled; + } + + public boolean isAnonymousRoleEnabled() { + return anonymousRoleEnabled; + } + + public void setAnonymousRoleEnabled(boolean anonymousRoleEnabled) { + this.anonymousRoleEnabled = anonymousRoleEnabled; + } + + public I18nStringDto getDefaultCaseName() { + return defaultCaseName; + } + + public void setDefaultCaseName(I18nStringDto defaultCaseName) { + this.defaultCaseName = defaultCaseName; + } + + public ExpressionDto getDefaultCaseNameExpression() { + return defaultCaseNameExpression; + } + + public void setDefaultCaseNameExpression(ExpressionDto defaultCaseNameExpression) { + this.defaultCaseNameExpression = defaultCaseNameExpression; + } + + public String getInitials() { + return initials; + } + + public void setInitials(String initials) { + this.initials = initials; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public LocalDateTime getCreationDate() { + return creationDate; + } + + public void setCreationDate(LocalDateTime creationDate) { + this.creationDate = creationDate; + } + + public VersionDto getVersion() { + return version; + } + + public void setVersion(VersionDto version) { + this.version = version; + } + + public AuthorDto getAuthor() { + return author; + } + + public void setAuthor(AuthorDto author) { + this.author = author; + } + + public Map getPlaces() { + return places; + } + + public void setPlaces(Map places) { + this.places = places; + } + + public Map getTransitions() { + return transitions; + } + + public void setTransitions(Map transitions) { + this.transitions = transitions; + } + + public Map> getArcs() { + return arcs; + } + + public void setArcs(Map> arcs) { + this.arcs = arcs; + } + + public Map getDataSet() { + return dataSet; + } + + public void setDataSet(Map dataSet) { + this.dataSet = dataSet; + } + + public Map getRoles() { + return roles; + } + + public void setRoles(Map roles) { + this.roles = roles; + } + + public Map getTransactions() { + return transactions; + } + + public void setTransactions(Map transactions) { + this.transactions = transactions; + } + + public Map getProcessEvents() { + return processEvents; + } + + public void setProcessEvents(Map processEvents) { + this.processEvents = processEvents; + } + + public Map getCaseEvents() { + return caseEvents; + } + + public void setCaseEvents(Map caseEvents) { + this.caseEvents = caseEvents; + } + + public Map> getPermissions() { + return permissions; + } + + public void setPermissions(Map> permissions) { + this.permissions = permissions; + } + + public List getNegativeViewRoles() { + return negativeViewRoles; + } + + public void setNegativeViewRoles(List negativeViewRoles) { + this.negativeViewRoles = negativeViewRoles; + } + + public Map> getUserRefs() { + return userRefs; + } + + public void setUserRefs(Map> userRefs) { + this.userRefs = userRefs; + } + + public List getFunctions() { + return functions; + } + + public void setFunctions(List functions) { + this.functions = functions; + } + + public boolean isInitialized() { + return initialized; + } + + public void setInitialized(boolean initialized) { + this.initialized = initialized; + } + + public String getImportXmlPath() { + return importXmlPath; + } + + public void setImportXmlPath(String importXmlPath) { + this.importXmlPath = importXmlPath; + } +} diff --git a/src/main/java/api/petrinet/domain/PetriNetObjectDto.java b/src/main/java/api/petrinet/domain/PetriNetObjectDto.java new file mode 100644 index 0000000000..446fb08f91 --- /dev/null +++ b/src/main/java/api/petrinet/domain/PetriNetObjectDto.java @@ -0,0 +1,21 @@ +package api.petrinet.domain; + +public class PetriNetObjectDto extends ImportedDto { + + private String id; + + public PetriNetObjectDto() { + } + + public PetriNetObjectDto(String id) { + this.id = id; + } + + public String getStringId() { + return id; + } + + public void setStringId(String id) { + this.id = id; + } +} diff --git a/src/main/java/api/petrinet/domain/PlaceDto.java b/src/main/java/api/petrinet/domain/PlaceDto.java new file mode 100644 index 0000000000..29ee8e0f5c --- /dev/null +++ b/src/main/java/api/petrinet/domain/PlaceDto.java @@ -0,0 +1,62 @@ +package api.petrinet.domain; + +public class PlaceDto extends NodeDto { + + private Integer tokens; + + private Boolean isStatic; + + public PlaceDto() { + } + + public PlaceDto(String id) { + super(id); + } + + public PlaceDto(PositionDto position, I18nStringDto title) { + super(position, title); + } + + public PlaceDto(String id, PositionDto position, I18nStringDto title) { + super(id, position, title); + } + + public PlaceDto(Integer tokens, Boolean isStatic) { + this.tokens = tokens; + this.isStatic = isStatic; + } + + public PlaceDto(String id, Integer tokens, Boolean isStatic) { + super(id); + this.tokens = tokens; + this.isStatic = isStatic; + } + + public PlaceDto(PositionDto position, I18nStringDto title, Integer tokens, Boolean isStatic) { + super(position, title); + this.tokens = tokens; + this.isStatic = isStatic; + } + + public PlaceDto(String id, PositionDto position, I18nStringDto title, Integer tokens, Boolean isStatic) { + super(id, position, title); + this.tokens = tokens; + this.isStatic = isStatic; + } + + public Integer getTokens() { + return tokens; + } + + public void setTokens(Integer tokens) { + this.tokens = tokens; + } + + public Boolean getStatic() { + return isStatic; + } + + public void setStatic(Boolean aStatic) { + isStatic = aStatic; + } +} diff --git a/src/main/java/api/petrinet/domain/PositionDto.java b/src/main/java/api/petrinet/domain/PositionDto.java new file mode 100644 index 0000000000..f5b568426c --- /dev/null +++ b/src/main/java/api/petrinet/domain/PositionDto.java @@ -0,0 +1,32 @@ +package api.petrinet.domain; + +public class PositionDto { + + private Integer x; + + private Integer y; + + public PositionDto() { + } + + public PositionDto(Integer x, Integer y) { + this.x = x; + this.y = y; + } + + public Integer getX() { + return x; + } + + public void setX(Integer x) { + this.x = x; + } + + public Integer getY() { + return y; + } + + public void setY(Integer y) { + this.y = y; + } +} diff --git a/src/main/java/api/petrinet/domain/TransactionDto.java b/src/main/java/api/petrinet/domain/TransactionDto.java new file mode 100644 index 0000000000..7ffa59417c --- /dev/null +++ b/src/main/java/api/petrinet/domain/TransactionDto.java @@ -0,0 +1,44 @@ +package api.petrinet.domain; + +import java.util.List; + +public class TransactionDto extends PetriNetObjectDto { + + private List transitions; + + private I18nStringDto title; + + public TransactionDto() { + } + + public TransactionDto(String id) { + super(id); + } + + public TransactionDto(List transitions, I18nStringDto title) { + this.transitions = transitions; + this.title = title; + } + + public TransactionDto(String id, List transitions, I18nStringDto title) { + super(id); + this.transitions = transitions; + this.title = title; + } + + public List getTransitions() { + return transitions; + } + + public void setTransitions(List transitions) { + this.transitions = transitions; + } + + public I18nStringDto getTitle() { + return title; + } + + public void setTitle(I18nStringDto title) { + this.title = title; + } +} diff --git a/src/main/java/api/petrinet/domain/TransitionDto.java b/src/main/java/api/petrinet/domain/TransitionDto.java new file mode 100644 index 0000000000..47f7be2f48 --- /dev/null +++ b/src/main/java/api/petrinet/domain/TransitionDto.java @@ -0,0 +1,252 @@ +package api.petrinet.domain; + +import api.workflow.domain.triggers.TriggerDto; +import api.petrinet.domain.events.EventDto; +import api.petrinet.domain.layout.TaskLayoutDto; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +public class TransitionDto extends NodeDto { + + private Map dataGroups; + + private LinkedHashMap dataSet; + + private Map> roles; + + private List negativeViewRoles; + + private Map> userRefs; + + private List triggers; + + private TaskLayoutDto layout; + + private Integer priority; + + private String assignPolicy; + + private String icon; + + private String dataFocusPolicy; + + private String finishPolicy; + + private Map events; + + private Map assignedUserPolicy; + + private String defaultRoleId; + + public TransitionDto() { + } + + public TransitionDto(String id) { + super(id); + } + + public TransitionDto(PositionDto position, I18nStringDto title) { + super(position, title); + } + + public TransitionDto(String id, PositionDto position, I18nStringDto title) { + super(id, position, title); + } + + public TransitionDto(Map dataGroups, LinkedHashMap dataSet, Map> roles, List negativeViewRoles, Map> userRefs, List triggers, TaskLayoutDto layout, Integer priority, String assignPolicy, String icon, String dataFocusPolicy, String finishPolicy, Map events, Map assignedUserPolicy, String defaultRoleId) { + this.dataGroups = dataGroups; + this.dataSet = dataSet; + this.roles = roles; + this.negativeViewRoles = negativeViewRoles; + this.userRefs = userRefs; + this.triggers = triggers; + this.layout = layout; + this.priority = priority; + this.assignPolicy = assignPolicy; + this.icon = icon; + this.dataFocusPolicy = dataFocusPolicy; + this.finishPolicy = finishPolicy; + this.events = events; + this.assignedUserPolicy = assignedUserPolicy; + this.defaultRoleId = defaultRoleId; + } + + public TransitionDto(String id, Map dataGroups, LinkedHashMap dataSet, Map> roles, List negativeViewRoles, Map> userRefs, List triggers, TaskLayoutDto layout, Integer priority, String assignPolicy, String icon, String dataFocusPolicy, String finishPolicy, Map events, Map assignedUserPolicy, String defaultRoleId) { + super(id); + this.dataGroups = dataGroups; + this.dataSet = dataSet; + this.roles = roles; + this.negativeViewRoles = negativeViewRoles; + this.userRefs = userRefs; + this.triggers = triggers; + this.layout = layout; + this.priority = priority; + this.assignPolicy = assignPolicy; + this.icon = icon; + this.dataFocusPolicy = dataFocusPolicy; + this.finishPolicy = finishPolicy; + this.events = events; + this.assignedUserPolicy = assignedUserPolicy; + this.defaultRoleId = defaultRoleId; + } + + public TransitionDto(PositionDto position, I18nStringDto title, Map dataGroups, LinkedHashMap dataSet, Map> roles, List negativeViewRoles, Map> userRefs, List triggers, TaskLayoutDto layout, Integer priority, String assignPolicy, String icon, String dataFocusPolicy, String finishPolicy, Map events, Map assignedUserPolicy, String defaultRoleId) { + super(position, title); + this.dataGroups = dataGroups; + this.dataSet = dataSet; + this.roles = roles; + this.negativeViewRoles = negativeViewRoles; + this.userRefs = userRefs; + this.triggers = triggers; + this.layout = layout; + this.priority = priority; + this.assignPolicy = assignPolicy; + this.icon = icon; + this.dataFocusPolicy = dataFocusPolicy; + this.finishPolicy = finishPolicy; + this.events = events; + this.assignedUserPolicy = assignedUserPolicy; + this.defaultRoleId = defaultRoleId; + } + + public TransitionDto(String id, PositionDto position, I18nStringDto title, Map dataGroups, LinkedHashMap dataSet, Map> roles, List negativeViewRoles, Map> userRefs, List triggers, TaskLayoutDto layout, Integer priority, String assignPolicy, String icon, String dataFocusPolicy, String finishPolicy, Map events, Map assignedUserPolicy, String defaultRoleId) { + super(id, position, title); + this.dataGroups = dataGroups; + this.dataSet = dataSet; + this.roles = roles; + this.negativeViewRoles = negativeViewRoles; + this.userRefs = userRefs; + this.triggers = triggers; + this.layout = layout; + this.priority = priority; + this.assignPolicy = assignPolicy; + this.icon = icon; + this.dataFocusPolicy = dataFocusPolicy; + this.finishPolicy = finishPolicy; + this.events = events; + this.assignedUserPolicy = assignedUserPolicy; + this.defaultRoleId = defaultRoleId; + } + + public Map getDataGroups() { + return dataGroups; + } + + public void setDataGroups(Map dataGroups) { + this.dataGroups = dataGroups; + } + + public LinkedHashMap getDataSet() { + return dataSet; + } + + public void setDataSet(LinkedHashMap dataSet) { + this.dataSet = dataSet; + } + + public Map> getRoles() { + return roles; + } + + public void setRoles(Map> roles) { + this.roles = roles; + } + + public List getNegativeViewRoles() { + return negativeViewRoles; + } + + public void setNegativeViewRoles(List negativeViewRoles) { + this.negativeViewRoles = negativeViewRoles; + } + + public Map> getUserRefs() { + return userRefs; + } + + public void setUserRefs(Map> userRefs) { + this.userRefs = userRefs; + } + + public List getTriggers() { + return triggers; + } + + public void setTriggers(List triggers) { + this.triggers = triggers; + } + + public TaskLayoutDto getLayout() { + return layout; + } + + public void setLayout(TaskLayoutDto layout) { + this.layout = layout; + } + + public Integer getPriority() { + return priority; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public String getAssignPolicy() { + return assignPolicy; + } + + public void setAssignPolicy(String assignPolicy) { + this.assignPolicy = assignPolicy; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getDataFocusPolicy() { + return dataFocusPolicy; + } + + public void setDataFocusPolicy(String dataFocusPolicy) { + this.dataFocusPolicy = dataFocusPolicy; + } + + public String getFinishPolicy() { + return finishPolicy; + } + + public void setFinishPolicy(String finishPolicy) { + this.finishPolicy = finishPolicy; + } + + public Map getEvents() { + return events; + } + + public void setEvents(Map events) { + this.events = events; + } + + public Map getAssignedUserPolicy() { + return assignedUserPolicy; + } + + public void setAssignedUserPolicy(Map assignedUserPolicy) { + this.assignedUserPolicy = assignedUserPolicy; + } + + public String getDefaultRoleId() { + return defaultRoleId; + } + + public void setDefaultRoleId(String defaultRoleId) { + this.defaultRoleId = defaultRoleId; + } +} diff --git a/src/main/java/api/petrinet/domain/arcs/ArcDto.java b/src/main/java/api/petrinet/domain/arcs/ArcDto.java new file mode 100644 index 0000000000..bec139cdd3 --- /dev/null +++ b/src/main/java/api/petrinet/domain/arcs/ArcDto.java @@ -0,0 +1,79 @@ +package api.petrinet.domain.arcs; + +import api.petrinet.domain.NodeDto; +import api.petrinet.domain.arcs.reference.ReferenceDto; + +public class ArcDto { + + protected NodeDto source; + + protected String sourceId; + + protected NodeDto destination; + + protected String destinationId; + + protected Integer multiplicity; + + protected ReferenceDto reference; + + public ArcDto() { + } + + public ArcDto(NodeDto source, String sourceId, NodeDto destination, String destinationId, Integer multiplicity, ReferenceDto reference) { + this.source = source; + this.sourceId = sourceId; + this.destination = destination; + this.destinationId = destinationId; + this.multiplicity = multiplicity; + this.reference = reference; + } + + public NodeDto getSource() { + return source; + } + + public void setSource(NodeDto source) { + this.source = source; + } + + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public NodeDto getDestination() { + return destination; + } + + public void setDestination(NodeDto destination) { + this.destination = destination; + } + + public String getDestinationId() { + return destinationId; + } + + public void setDestinationId(String destinationId) { + this.destinationId = destinationId; + } + + public Integer getMultiplicity() { + return multiplicity; + } + + public void setMultiplicity(Integer multiplicity) { + this.multiplicity = multiplicity; + } + + public ReferenceDto getReference() { + return reference; + } + + public void setReference(ReferenceDto reference) { + this.reference = reference; + } +} diff --git a/src/main/java/api/petrinet/domain/arcs/reference/ReferencableDto.java b/src/main/java/api/petrinet/domain/arcs/reference/ReferencableDto.java new file mode 100644 index 0000000000..f4eee79c5f --- /dev/null +++ b/src/main/java/api/petrinet/domain/arcs/reference/ReferencableDto.java @@ -0,0 +1,21 @@ +package api.petrinet.domain.arcs.reference; + +public class ReferencableDto { + + private int multiplicity; + + public ReferencableDto() { + } + + public ReferencableDto(int multiplicity) { + this.multiplicity = multiplicity; + } + + public int getMultiplicity() { + return multiplicity; + } + + public void setMultiplicity(int multiplicity) { + this.multiplicity = multiplicity; + } +} diff --git a/src/main/java/api/petrinet/domain/arcs/reference/ReferenceDto.java b/src/main/java/api/petrinet/domain/arcs/reference/ReferenceDto.java new file mode 100644 index 0000000000..89b0842b44 --- /dev/null +++ b/src/main/java/api/petrinet/domain/arcs/reference/ReferenceDto.java @@ -0,0 +1,44 @@ +package api.petrinet.domain.arcs.reference; + +public class ReferenceDto { + + private String reference; + + private String type; + + private ReferencableDto referencable; + + + public ReferenceDto() { + } + + public ReferenceDto(String reference, String type, ReferencableDto referencable) { + this.reference = reference; + this.type = type; + this.referencable = referencable; + } + + public String getReference() { + return reference; + } + + public void setReference(String reference) { + this.reference = reference; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public ReferencableDto getReferencable() { + return referencable; + } + + public void setReferencable(ReferencableDto referencable) { + this.referencable = referencable; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/BooleanFieldDto.java b/src/main/java/api/petrinet/domain/dataset/BooleanFieldDto.java new file mode 100644 index 0000000000..ec65d5cd9d --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/BooleanFieldDto.java @@ -0,0 +1,22 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.events.DataEventDto; + +import java.util.List; +import java.util.Map; + +public final class BooleanFieldDto extends FieldDto { + + public BooleanFieldDto() { + } + + public BooleanFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, Boolean value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, Boolean defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/ButtonFieldDto.java b/src/main/java/api/petrinet/domain/dataset/ButtonFieldDto.java new file mode 100644 index 0000000000..40c12e26df --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/ButtonFieldDto.java @@ -0,0 +1,22 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import api.petrinet.domain.events.DataEventDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; +import java.util.Map; + +public final class ButtonFieldDto extends FieldDto { + + public ButtonFieldDto() { + } + + public ButtonFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, String value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, String defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/CaseFieldDto.java b/src/main/java/api/petrinet/domain/dataset/CaseFieldDto.java new file mode 100644 index 0000000000..e5b6bccfbb --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/CaseFieldDto.java @@ -0,0 +1,30 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.events.DataEventDto; + +import java.util.List; +import java.util.Map; + +public final class CaseFieldDto extends FieldWithAllowedNetsDto> { + + public CaseFieldDto() { + } + + public CaseFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, List value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, List defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } + + public CaseFieldDto(List allowedNets) { + super(allowedNets); + } + + public CaseFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, List value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, List defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, List allowedNets) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId, allowedNets); + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/ChoiceFieldDto.java b/src/main/java/api/petrinet/domain/dataset/ChoiceFieldDto.java new file mode 100644 index 0000000000..1b9ee29ec1 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/ChoiceFieldDto.java @@ -0,0 +1,54 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import api.petrinet.domain.events.DataEventDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +public abstract class ChoiceFieldDto extends FieldDto { + + private Set choices; + + private ExpressionDto choicesExpression; + + public ChoiceFieldDto() { + } + + public ChoiceFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, T value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, T defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } + + public ChoiceFieldDto(Set choices, ExpressionDto choicesExpression) { + this.choices = choices; + this.choicesExpression = choicesExpression; + } + + public ChoiceFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, T value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, T defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Set choices, ExpressionDto choicesExpression) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + this.choices = choices; + this.choicesExpression = choicesExpression; + } + + public Set getChoices() { + return choices; + } + + public void setChoices(Set choices) { + this.choices = choices; + } + + public ExpressionDto getChoicesExpression() { + return choicesExpression; + } + + public void setChoicesExpression(ExpressionDto choicesExpression) { + this.choicesExpression = choicesExpression; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/DateFieldDto.java b/src/main/java/api/petrinet/domain/dataset/DateFieldDto.java new file mode 100644 index 0000000000..12b0405d47 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/DateFieldDto.java @@ -0,0 +1,23 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.events.DataEventDto; + +import java.time.LocalDate; +import java.util.List; +import java.util.Map; + +public final class DateFieldDto extends FieldDto { + + public DateFieldDto() { + } + + public DateFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, LocalDate value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, LocalDate defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/DateTimeFieldDto.java b/src/main/java/api/petrinet/domain/dataset/DateTimeFieldDto.java new file mode 100644 index 0000000000..c1bab19466 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/DateTimeFieldDto.java @@ -0,0 +1,22 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import api.petrinet.domain.events.DataEventDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; + +public final class DateTimeFieldDto extends FieldDto { + public DateTimeFieldDto() { + } + + public DateTimeFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, LocalDateTime value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, LocalDateTime defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/EnumerationFieldDto.java b/src/main/java/api/petrinet/domain/dataset/EnumerationFieldDto.java new file mode 100644 index 0000000000..22488b124e --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/EnumerationFieldDto.java @@ -0,0 +1,31 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import api.petrinet.domain.events.DataEventDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +public final class EnumerationFieldDto extends ChoiceFieldDto { + + public EnumerationFieldDto() { + } + + public EnumerationFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, I18nStringDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, I18nStringDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } + + public EnumerationFieldDto(Set choices, ExpressionDto choicesExpression) { + super(choices, choicesExpression); + } + + public EnumerationFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, I18nStringDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, I18nStringDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Set choices, ExpressionDto choicesExpression) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId, choices, choicesExpression); + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/EnumerationMapFieldDto.java b/src/main/java/api/petrinet/domain/dataset/EnumerationMapFieldDto.java new file mode 100644 index 0000000000..f82eab0fac --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/EnumerationMapFieldDto.java @@ -0,0 +1,30 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.events.DataEventDto; + +import java.util.List; +import java.util.Map; + +public final class EnumerationMapFieldDto extends MapOptionsFieldDto { + + public EnumerationMapFieldDto() { + } + + public EnumerationMapFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, String value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, String defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } + + public EnumerationMapFieldDto(Map options, ExpressionDto optionsExpression) { + super(options, optionsExpression); + } + + public EnumerationMapFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, String value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, String defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Map options, ExpressionDto optionsExpression) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId, options, optionsExpression); + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/FieldDto.java b/src/main/java/api/petrinet/domain/dataset/FieldDto.java new file mode 100644 index 0000000000..c7ba626133 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/FieldDto.java @@ -0,0 +1,231 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.ImportedDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import api.petrinet.domain.events.DataEventDto; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import java.util.List; +import java.util.Map; + +public abstract class FieldDto extends ImportedDto { + + private String id; + + private String type; + + private I18nStringDto name; + + private I18nStringDto description; + + private I18nStringDto placeholder; + + private ObjectNode behavior; + + private FieldLayoutDto layout; + + private T value; + + private Long order; + + private boolean immediate; + + private Map events; + + private String encryption; + + private Integer length; + + private ComponentDto component; + + private T defaultValue; + + private ExpressionDto initExpression; + + private List validations; + + private String parentTaskId; + + private String parentCaseId; + + public FieldDto() { + } + + public FieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, T value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, T defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + this.id = id; + this.type = type; + this.name = name; + this.description = description; + this.placeholder = placeholder; + this.behavior = behavior; + this.layout = layout; + this.value = value; + this.order = order; + this.immediate = immediate; + this.events = events; + this.encryption = encryption; + this.length = length; + this.component = component; + this.defaultValue = defaultValue; + this.initExpression = initExpression; + this.validations = validations; + this.parentTaskId = parentTaskId; + this.parentCaseId = parentCaseId; + } + + public String getStringId() { + return id; + } + + public void setStringId(String id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public I18nStringDto getName() { + return name; + } + + public void setName(I18nStringDto name) { + this.name = name; + } + + public I18nStringDto getDescription() { + return description; + } + + public void setDescription(I18nStringDto description) { + this.description = description; + } + + public I18nStringDto getPlaceholder() { + return placeholder; + } + + public void setPlaceholder(I18nStringDto placeholder) { + this.placeholder = placeholder; + } + + public ObjectNode getBehavior() { + return behavior; + } + + public void setBehavior(ObjectNode behavior) { + this.behavior = behavior; + } + + public FieldLayoutDto getLayout() { + return layout; + } + + public void setLayout(FieldLayoutDto layout) { + this.layout = layout; + } + + public T getValue() { + return value; + } + + public void setValue(T value) { + this.value = value; + } + + public Long getOrder() { + return order; + } + + public void setOrder(Long order) { + this.order = order; + } + + public boolean isImmediate() { + return immediate; + } + + public void setImmediate(boolean immediate) { + this.immediate = immediate; + } + + public Map getEvents() { + return events; + } + + public void setEvents(Map events) { + this.events = events; + } + + public String getEncryption() { + return encryption; + } + + public void setEncryption(String encryption) { + this.encryption = encryption; + } + + public Integer getLength() { + return length; + } + + public void setLength(Integer length) { + this.length = length; + } + + public ComponentDto getComponent() { + return component; + } + + public void setComponent(ComponentDto component) { + this.component = component; + } + + public T getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(T defaultValue) { + this.defaultValue = defaultValue; + } + + public ExpressionDto getInitExpression() { + return initExpression; + } + + public void setInitExpression(ExpressionDto initExpression) { + this.initExpression = initExpression; + } + + public List getValidations() { + return validations; + } + + public void setValidations(List validations) { + this.validations = validations; + } + + public String getParentTaskId() { + return parentTaskId; + } + + public void setParentTaskId(String parentTaskId) { + this.parentTaskId = parentTaskId; + } + + public String getParentCaseId() { + return parentCaseId; + } + + public void setParentCaseId(String parentCaseId) { + this.parentCaseId = parentCaseId; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/FieldWithAllowedNetsDto.java b/src/main/java/api/petrinet/domain/dataset/FieldWithAllowedNetsDto.java new file mode 100644 index 0000000000..bdd0ae4a90 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/FieldWithAllowedNetsDto.java @@ -0,0 +1,41 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import api.petrinet.domain.events.DataEventDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; +import java.util.Map; + +public abstract class FieldWithAllowedNetsDto extends FieldDto { + + private List allowedNets; + + public FieldWithAllowedNetsDto() { + } + + public FieldWithAllowedNetsDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, T value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, T defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } + + public FieldWithAllowedNetsDto(List allowedNets) { + this.allowedNets = allowedNets; + } + + public FieldWithAllowedNetsDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, T value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, T defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, List allowedNets) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + this.allowedNets = allowedNets; + } + + public List getAllowedNets() { + return allowedNets; + } + + public void setAllowedNets(List allowedNets) { + this.allowedNets = allowedNets; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/FileFieldDto.java b/src/main/java/api/petrinet/domain/dataset/FileFieldDto.java new file mode 100644 index 0000000000..ff58a16531 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/FileFieldDto.java @@ -0,0 +1,41 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.events.DataEventDto; + +import java.util.List; +import java.util.Map; + +public final class FileFieldDto extends FieldDto { + + private Boolean remote; + + public FileFieldDto() { + } + + public FileFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, FileFieldValueDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, FileFieldValueDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } + + public FileFieldDto(Boolean remote) { + this.remote = remote; + } + + public FileFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, FileFieldValueDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, FileFieldValueDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Boolean remote) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + this.remote = remote; + } + + public Boolean getRemote() { + return remote; + } + + public void setRemote(Boolean remote) { + this.remote = remote; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/FileFieldValueDto.java b/src/main/java/api/petrinet/domain/dataset/FileFieldValueDto.java new file mode 100644 index 0000000000..7e931cff7b --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/FileFieldValueDto.java @@ -0,0 +1,32 @@ +package api.petrinet.domain.dataset; + +public final class FileFieldValueDto { + + private String name; + + private String path; + + public FileFieldValueDto() { + } + + public FileFieldValueDto(String name, String path) { + this.name = name; + this.path = path; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/FileListFieldDto.java b/src/main/java/api/petrinet/domain/dataset/FileListFieldDto.java new file mode 100644 index 0000000000..0b7ea587d2 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/FileListFieldDto.java @@ -0,0 +1,41 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.events.DataEventDto; + +import java.util.List; +import java.util.Map; + +public final class FileListFieldDto extends FieldDto { + + private Boolean remote; + + public FileListFieldDto() { + } + + public FileListFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, FileListFieldValueDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, FileListFieldValueDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } + + public FileListFieldDto(Boolean remote) { + this.remote = remote; + } + + public FileListFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, FileListFieldValueDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, FileListFieldValueDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Boolean remote) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + this.remote = remote; + } + + public Boolean getRemote() { + return remote; + } + + public void setRemote(Boolean remote) { + this.remote = remote; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/FileListFieldValueDto.java b/src/main/java/api/petrinet/domain/dataset/FileListFieldValueDto.java new file mode 100644 index 0000000000..c15fe5e1c2 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/FileListFieldValueDto.java @@ -0,0 +1,24 @@ +package api.petrinet.domain.dataset; + +import java.util.HashSet; + +public final class FileListFieldValueDto { + + private HashSet namesPaths; + + public FileListFieldValueDto() { + } + + public FileListFieldValueDto(HashSet namesPaths) { + this.namesPaths = namesPaths; + } + + public HashSet getNamesPaths() { + return namesPaths; + } + + public void setNamesPaths(HashSet namesPaths) { + this.namesPaths = namesPaths; + } +} + diff --git a/src/main/java/api/petrinet/domain/dataset/FilterFieldDto.java b/src/main/java/api/petrinet/domain/dataset/FilterFieldDto.java new file mode 100644 index 0000000000..7a05d5f168 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/FilterFieldDto.java @@ -0,0 +1,40 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.events.DataEventDto; + +import java.util.List; +import java.util.Map; + +public final class FilterFieldDto extends FieldWithAllowedNetsDto { + + private Map filterMetadata; + + public FilterFieldDto() { + } + + public FilterFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, String value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, String defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } + + public FilterFieldDto(List allowedNets) { + super(allowedNets); + } + + public FilterFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, String value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, String defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, List allowedNets) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId, allowedNets); + } + + public Map getFilterMetadata() { + return filterMetadata; + } + + public void setFilterMetadata(Map filterMetadata) { + this.filterMetadata = filterMetadata; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/I18nFieldDto.java b/src/main/java/api/petrinet/domain/dataset/I18nFieldDto.java new file mode 100644 index 0000000000..292d439819 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/I18nFieldDto.java @@ -0,0 +1,22 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.events.DataEventDto; + +import java.util.List; +import java.util.Map; + +public final class I18nFieldDto extends FieldDto { + + public I18nFieldDto() { + } + + public I18nFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, I18nFieldDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, I18nFieldDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/MapOptionsFieldDto.java b/src/main/java/api/petrinet/domain/dataset/MapOptionsFieldDto.java new file mode 100644 index 0000000000..9c29eab2ba --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/MapOptionsFieldDto.java @@ -0,0 +1,53 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import api.petrinet.domain.events.DataEventDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; +import java.util.Map; + +public abstract class MapOptionsFieldDto extends FieldDto { + + private Map options; + + private ExpressionDto optionsExpression; + + public MapOptionsFieldDto() { + } + + public MapOptionsFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, U value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, U defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } + + public MapOptionsFieldDto(Map options, ExpressionDto optionsExpression) { + this.options = options; + this.optionsExpression = optionsExpression; + } + + public MapOptionsFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, U value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, U defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Map options, ExpressionDto optionsExpression) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + this.options = options; + this.optionsExpression = optionsExpression; + } + + public Map getOptions() { + return options; + } + + public void setOptions(Map options) { + this.options = options; + } + + public ExpressionDto getOptionsExpression() { + return optionsExpression; + } + + public void setOptionsExpression(ExpressionDto optionsExpression) { + this.optionsExpression = optionsExpression; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/MultichoiceFieldDto.java b/src/main/java/api/petrinet/domain/dataset/MultichoiceFieldDto.java new file mode 100644 index 0000000000..d2faa8dd04 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/MultichoiceFieldDto.java @@ -0,0 +1,31 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.events.DataEventDto; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +public final class MultichoiceFieldDto extends ChoiceFieldDto { + + public MultichoiceFieldDto() { + } + + public MultichoiceFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, I18nStringDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, I18nStringDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } + + public MultichoiceFieldDto(Set choices, ExpressionDto choicesExpression) { + super(choices, choicesExpression); + } + + public MultichoiceFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, I18nStringDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, I18nStringDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Set choices, ExpressionDto choicesExpression) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId, choices, choicesExpression); + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/MultichoiceMapFieldDto.java b/src/main/java/api/petrinet/domain/dataset/MultichoiceMapFieldDto.java new file mode 100644 index 0000000000..2010e2de2f --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/MultichoiceMapFieldDto.java @@ -0,0 +1,31 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import api.petrinet.domain.events.DataEventDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +public final class MultichoiceMapFieldDto extends MapOptionsFieldDto> { + + public MultichoiceMapFieldDto() { + } + + public MultichoiceMapFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, HashSet value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, HashSet defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } + + public MultichoiceMapFieldDto(Map options, ExpressionDto optionsExpression) { + super(options, optionsExpression); + } + + public MultichoiceMapFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, HashSet value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, HashSet defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Map options, ExpressionDto optionsExpression) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId, options, optionsExpression); + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/NumberFieldDto.java b/src/main/java/api/petrinet/domain/dataset/NumberFieldDto.java new file mode 100644 index 0000000000..8d9d35df83 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/NumberFieldDto.java @@ -0,0 +1,53 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.events.DataEventDto; + +import java.util.List; +import java.util.Map; + +public final class NumberFieldDto extends FieldDto { + + private Double minValue; + + private Double maxValue; + + public NumberFieldDto() { + } + + public NumberFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, Double value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, Double defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } + + public NumberFieldDto(Double minValue, Double maxValue) { + this.minValue = minValue; + this.maxValue = maxValue; + } + + public NumberFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, Double value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, Double defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Double minValue, Double maxValue) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + this.minValue = minValue; + this.maxValue = maxValue; + } + + public Double getMinValue() { + return minValue; + } + + public void setMinValue(Double minValue) { + this.minValue = minValue; + } + + public Double getMaxValue() { + return maxValue; + } + + public void setMaxValue(Double maxValue) { + this.maxValue = maxValue; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/TaskFieldDto.java b/src/main/java/api/petrinet/domain/dataset/TaskFieldDto.java new file mode 100644 index 0000000000..99a3df2b86 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/TaskFieldDto.java @@ -0,0 +1,23 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import api.petrinet.domain.events.DataEventDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public final class TaskFieldDto extends FieldDto> { + + public TaskFieldDto() { + } + + public TaskFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, ArrayList value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, ArrayList defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/TextFieldDto.java b/src/main/java/api/petrinet/domain/dataset/TextFieldDto.java new file mode 100644 index 0000000000..b0c7e5fc66 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/TextFieldDto.java @@ -0,0 +1,65 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import api.petrinet.domain.events.DataEventDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; +import java.util.Map; + +public final class TextFieldDto extends FieldDto { + + private String subType; + + private Integer maxLength; + + private String formatting; + + public TextFieldDto() { + } + + public TextFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, String value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, String defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } + + public TextFieldDto(String subType, Integer maxLength, String formatting) { + this.subType = subType; + this.maxLength = maxLength; + this.formatting = formatting; + } + + public TextFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, String value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, String defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, String subType, Integer maxLength, String formatting) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + this.subType = subType; + this.maxLength = maxLength; + this.formatting = formatting; + } + + public String getSubType() { + return subType; + } + + public void setSubType(String subType) { + this.subType = subType; + } + + public Integer getMaxLength() { + return maxLength; + } + + public void setMaxLength(Integer maxLength) { + this.maxLength = maxLength; + } + + public String getFormatting() { + return formatting; + } + + public void setFormatting(String formatting) { + this.formatting = formatting; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/UserFieldDto.java b/src/main/java/api/petrinet/domain/dataset/UserFieldDto.java new file mode 100644 index 0000000000..e166091718 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/UserFieldDto.java @@ -0,0 +1,42 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import api.petrinet.domain.events.DataEventDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +public final class UserFieldDto extends FieldDto { + + private Set roles; + + public UserFieldDto() { + } + + public UserFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, UserFieldValueDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, UserFieldValueDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } + + public UserFieldDto(Set roles) { + this.roles = roles; + } + + public UserFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, UserFieldValueDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, UserFieldValueDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Set roles) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + this.roles = roles; + } + + public Set getRoles() { + return roles; + } + + public void setRoles(Set roles) { + this.roles = roles; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/UserFieldValueDto.java b/src/main/java/api/petrinet/domain/dataset/UserFieldValueDto.java new file mode 100644 index 0000000000..2498f0139b --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/UserFieldValueDto.java @@ -0,0 +1,58 @@ +package api.petrinet.domain.dataset; + +public final class UserFieldValueDto { + + private String id; + + private String name; + + private String surname; + + private String email; + + public UserFieldValueDto() { + } + + public UserFieldValueDto(String id, String name, String surname, String email) { + this.id = id; + this.name = name; + this.surname = surname; + this.email = email; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSurname() { + return surname; + } + + public void setSurname(String surname) { + this.surname = surname; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getFullName() { + return this.name + " " + this.surname; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/UserListFieldDto.java b/src/main/java/api/petrinet/domain/dataset/UserListFieldDto.java new file mode 100644 index 0000000000..1ea8651ace --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/UserListFieldDto.java @@ -0,0 +1,22 @@ +package api.petrinet.domain.dataset; + +import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import api.petrinet.domain.events.DataEventDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; +import java.util.Map; + +public final class UserListFieldDto extends FieldDto> { + + public UserListFieldDto() { + } + + public UserListFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, List value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, List defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { + super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/logic/FieldLayoutDto.java b/src/main/java/api/petrinet/domain/dataset/logic/FieldLayoutDto.java new file mode 100644 index 0000000000..ce0bf160d4 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/logic/FieldLayoutDto.java @@ -0,0 +1,88 @@ +package api.petrinet.domain.dataset.logic; + +import api.petrinet.domain.layout.LayoutDto; + +public class FieldLayoutDto extends LayoutDto { + + private int x; + + private int y; + + private int offset; + + private String template; + + private String appearance; + + private String alignment; + + public FieldLayoutDto() { + } + + public FieldLayoutDto(int x, int y, int offset, String template, String appearance, String alignment) { + this.x = x; + this.y = y; + this.offset = offset; + this.template = template; + this.appearance = appearance; + this.alignment = alignment; + } + + public FieldLayoutDto(Integer rows, Integer cols, int x, int y, int offset, String template, String appearance, String alignment) { + super(rows, cols); + this.x = x; + this.y = y; + this.offset = offset; + this.template = template; + this.appearance = appearance; + this.alignment = alignment; + } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + public int getOffset() { + return offset; + } + + public void setOffset(int offset) { + this.offset = offset; + } + + public String getTemplate() { + return template; + } + + public void setTemplate(String template) { + this.template = template; + } + + public String getAppearance() { + return appearance; + } + + public void setAppearance(String appearance) { + this.appearance = appearance; + } + + public String getAlignment() { + return alignment; + } + + public void setAlignment(String alignment) { + this.alignment = alignment; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/logic/action/ActionDto.java b/src/main/java/api/petrinet/domain/dataset/logic/action/ActionDto.java new file mode 100644 index 0000000000..3763502e45 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/logic/action/ActionDto.java @@ -0,0 +1,79 @@ +package api.petrinet.domain.dataset.logic.action; + +import java.util.HashMap; +import java.util.Map; + +public class ActionDto { + + private String importId; + + private String id; + + private Map fieldIds = new HashMap<>(); + + private Map transitionIds = new HashMap<>(); + + private String definition; + + private String trigger; + + public ActionDto() { + } + + public ActionDto(String importId, String id, Map fieldIds, Map transitionIds, String definition, String trigger) { + this.importId = importId; + this.id = id; + this.fieldIds = fieldIds; + this.transitionIds = transitionIds; + this.definition = definition; + this.trigger = trigger; + } + + public String getImportId() { + return importId; + } + + public Map getFieldIds() { + return fieldIds; + } + + public Map getTransitionIds() { + return transitionIds; + } + + public String getDefinition() { + return definition; + } + + public String getTrigger() { + return trigger; + } + + public void setImportId(String importId) { + this.importId = importId; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public void setFieldIds(Map fieldIds) { + this.fieldIds = fieldIds; + } + + public void setTransitionIds(Map transitionIds) { + this.transitionIds = transitionIds; + } + + public void setDefinition(String definition) { + this.definition = definition; + } + + public void setTrigger(String trigger) { + this.trigger = trigger; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/logic/action/runner/ExpressionDto.java b/src/main/java/api/petrinet/domain/dataset/logic/action/runner/ExpressionDto.java new file mode 100644 index 0000000000..97ddcc2648 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/logic/action/runner/ExpressionDto.java @@ -0,0 +1,30 @@ +package api.petrinet.domain.dataset.logic.action.runner; + +public class ExpressionDto { + + protected String id; + + protected String definition; + + ExpressionDto() { + } + + ExpressionDto(String id, String definition) { + this(); + this.id = id; + this.definition = definition; + } + + public String getId() { + return this.id; + } + + public String getDefinition() { + return definition; + } + + public String toString() { + return "[$stringId] $definition"; + } + +} diff --git a/src/main/java/api/petrinet/domain/dataset/logic/validation/LocalisedValidationDto.java b/src/main/java/api/petrinet/domain/dataset/logic/validation/LocalisedValidationDto.java new file mode 100644 index 0000000000..7dcf3b75e9 --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/logic/validation/LocalisedValidationDto.java @@ -0,0 +1,24 @@ +package api.petrinet.domain.dataset.logic.validation; + +public class LocalisedValidationDto { + + private String validationRule; + + private String validationMessage; + + public String getValidationRule() { + return validationRule; + } + + public String getValidationMessage() { + return validationMessage; + } + + public void setValidationRule(String validationRule) { + this.validationRule = validationRule; + } + + public void setValidationMessage(String validationMessage) { + this.validationMessage = validationMessage; + } +} diff --git a/src/main/java/api/petrinet/domain/dataset/logic/validation/ValidationDto.java b/src/main/java/api/petrinet/domain/dataset/logic/validation/ValidationDto.java new file mode 100644 index 0000000000..4740113f1c --- /dev/null +++ b/src/main/java/api/petrinet/domain/dataset/logic/validation/ValidationDto.java @@ -0,0 +1,27 @@ +package api.petrinet.domain.dataset.logic.validation; + + +import api.petrinet.domain.I18nStringDto; + +public class ValidationDto { + + private String validationRule; + + private I18nStringDto validationMessage; + + public String getValidationRule() { + return validationRule; + } + + public I18nStringDto getValidationMessage() { + return validationMessage; + } + + public void setValidationRule(String validationRule) { + this.validationRule = validationRule; + } + + public void setValidationMessage(I18nStringDto validationMessage) { + this.validationMessage = validationMessage; + } +} diff --git a/src/main/java/api/petrinet/domain/events/BaseEventDto.java b/src/main/java/api/petrinet/domain/events/BaseEventDto.java new file mode 100644 index 0000000000..483bddb1ca --- /dev/null +++ b/src/main/java/api/petrinet/domain/events/BaseEventDto.java @@ -0,0 +1,71 @@ +package api.petrinet.domain.events; + +import api.petrinet.domain.dataset.logic.action.ActionDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.ImportedDto; + +import java.util.List; + +public class BaseEventDto extends ImportedDto { + + private String id; + + private I18nStringDto title; + + private I18nStringDto message; + + private List preActions; + + private List postActions; + + public BaseEventDto() { + } + + public BaseEventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions) { + this.id = id; + this.title = title; + this.message = message; + this.preActions = preActions; + this.postActions = postActions; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public I18nStringDto getTitle() { + return title; + } + + public void setTitle(I18nStringDto title) { + this.title = title; + } + + public I18nStringDto getMessage() { + return message; + } + + public void setMessage(I18nStringDto message) { + this.message = message; + } + + public List getPreActions() { + return preActions; + } + + public void setPreActions(List preActions) { + this.preActions = preActions; + } + + public List getPostActions() { + return postActions; + } + + public void setPostActions(List postActions) { + this.postActions = postActions; + } +} diff --git a/src/main/java/api/petrinet/domain/events/CaseEventDto.java b/src/main/java/api/petrinet/domain/events/CaseEventDto.java new file mode 100644 index 0000000000..59a343e670 --- /dev/null +++ b/src/main/java/api/petrinet/domain/events/CaseEventDto.java @@ -0,0 +1,35 @@ +package api.petrinet.domain.events; + +import api.petrinet.domain.dataset.logic.action.ActionDto; +import api.petrinet.domain.I18nStringDto; + +import java.util.List; + +public class CaseEventDto extends BaseEventDto { + + private String type; + + public CaseEventDto() { + } + + public CaseEventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions) { + super(id, title, message, preActions, postActions); + } + + public CaseEventDto(String type) { + this.type = type; + } + + public CaseEventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions, String type) { + super(id, title, message, preActions, postActions); + this.type = type; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/src/main/java/api/petrinet/domain/events/DataEventDto.java b/src/main/java/api/petrinet/domain/events/DataEventDto.java new file mode 100644 index 0000000000..a4eeebc89e --- /dev/null +++ b/src/main/java/api/petrinet/domain/events/DataEventDto.java @@ -0,0 +1,27 @@ +package api.petrinet.domain.events; + +import api.petrinet.domain.dataset.logic.action.ActionDto; +import api.petrinet.domain.I18nStringDto; + +import java.util.List; + +public class DataEventDto extends BaseEventDto { + + private String type; + + public DataEventDto() { + } + + public DataEventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions) { + super(id, title, message, preActions, postActions); + } + + public DataEventDto(String type) { + this.type = type; + } + + public DataEventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions, String type) { + super(id, title, message, preActions, postActions); + this.type = type; + } +} diff --git a/src/main/java/api/petrinet/domain/events/EventDto.java b/src/main/java/api/petrinet/domain/events/EventDto.java new file mode 100644 index 0000000000..03faf08420 --- /dev/null +++ b/src/main/java/api/petrinet/domain/events/EventDto.java @@ -0,0 +1,27 @@ +package api.petrinet.domain.events; + +import api.petrinet.domain.dataset.logic.action.ActionDto; +import api.petrinet.domain.I18nStringDto; + +import java.util.List; + +public class EventDto extends BaseEventDto { + + private String type; + + public EventDto() { + } + + public EventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions) { + super(id, title, message, preActions, postActions); + } + + public EventDto(String type) { + this.type = type; + } + + public EventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions, String type) { + super(id, title, message, preActions, postActions); + this.type = type; + } +} diff --git a/src/main/java/api/petrinet/domain/events/ProcessEventDto.java b/src/main/java/api/petrinet/domain/events/ProcessEventDto.java new file mode 100644 index 0000000000..b867e4de59 --- /dev/null +++ b/src/main/java/api/petrinet/domain/events/ProcessEventDto.java @@ -0,0 +1,27 @@ +package api.petrinet.domain.events; + +import api.petrinet.domain.dataset.logic.action.ActionDto; +import api.petrinet.domain.I18nStringDto; + +import java.util.List; + +public class ProcessEventDto extends BaseEventDto { + + private String type; + + public ProcessEventDto() { + } + + public ProcessEventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions) { + super(id, title, message, preActions, postActions); + } + + public ProcessEventDto(String type) { + this.type = type; + } + + public ProcessEventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions, String type) { + super(id, title, message, preActions, postActions); + this.type = type; + } +} diff --git a/src/main/java/api/petrinet/domain/layout/DataGroupLayoutDto.java b/src/main/java/api/petrinet/domain/layout/DataGroupLayoutDto.java new file mode 100644 index 0000000000..0aa29718ea --- /dev/null +++ b/src/main/java/api/petrinet/domain/layout/DataGroupLayoutDto.java @@ -0,0 +1,19 @@ +package api.petrinet.domain.layout; + +public class DataGroupLayoutDto extends FormLayoutDto { + + public DataGroupLayoutDto() { + } + + public DataGroupLayoutDto(Integer rows, Integer cols) { + super(rows, cols); + } + + public DataGroupLayoutDto(String type, String hideEmptyRows, String compactDirection) { + super(type, hideEmptyRows, compactDirection); + } + + public DataGroupLayoutDto(Integer rows, Integer cols, String type, String hideEmptyRows, String compactDirection) { + super(rows, cols, type, hideEmptyRows, compactDirection); + } +} diff --git a/src/main/java/api/petrinet/domain/layout/FormLayoutDto.java b/src/main/java/api/petrinet/domain/layout/FormLayoutDto.java new file mode 100644 index 0000000000..fab0d312c1 --- /dev/null +++ b/src/main/java/api/petrinet/domain/layout/FormLayoutDto.java @@ -0,0 +1,54 @@ +package api.petrinet.domain.layout; + +public class FormLayoutDto extends LayoutDto { + + private String type; + + private String hideEmptyRows; + + private String compactDirection; + + public FormLayoutDto() { + } + + public FormLayoutDto(Integer rows, Integer cols) { + super(rows, cols); + } + + public FormLayoutDto(String type, String hideEmptyRows, String compactDirection) { + this.type = type; + this.hideEmptyRows = hideEmptyRows; + this.compactDirection = compactDirection; + } + + public FormLayoutDto(Integer rows, Integer cols, String type, String hideEmptyRows, String compactDirection) { + super(rows, cols); + this.type = type; + this.hideEmptyRows = hideEmptyRows; + this.compactDirection = compactDirection; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getHideEmptyRows() { + return hideEmptyRows; + } + + public void setHideEmptyRows(String hideEmptyRows) { + this.hideEmptyRows = hideEmptyRows; + } + + public String getCompactDirection() { + return compactDirection; + } + + public void setCompactDirection(String compactDirection) { + this.compactDirection = compactDirection; + } +} diff --git a/src/main/java/api/petrinet/domain/layout/LayoutDto.java b/src/main/java/api/petrinet/domain/layout/LayoutDto.java new file mode 100644 index 0000000000..0e6e232629 --- /dev/null +++ b/src/main/java/api/petrinet/domain/layout/LayoutDto.java @@ -0,0 +1,32 @@ +package api.petrinet.domain.layout; + +public class LayoutDto { + + private Integer rows; + + private Integer cols; + + public LayoutDto() { + } + + public LayoutDto(Integer rows, Integer cols) { + this.rows = rows; + this.cols = cols; + } + + public Integer getRows() { + return rows; + } + + public void setRows(Integer rows) { + this.rows = rows; + } + + public Integer getCols() { + return cols; + } + + public void setCols(Integer cols) { + this.cols = cols; + } +} diff --git a/src/main/java/api/petrinet/domain/layout/TaskLayoutDto.java b/src/main/java/api/petrinet/domain/layout/TaskLayoutDto.java new file mode 100644 index 0000000000..8ad2fcaee3 --- /dev/null +++ b/src/main/java/api/petrinet/domain/layout/TaskLayoutDto.java @@ -0,0 +1,62 @@ +package api.petrinet.domain.layout; + +public class TaskLayoutDto extends FormLayoutDto { + + private Integer offset; + + private String fieldAlignment; + + public TaskLayoutDto() { + } + + public TaskLayoutDto(Integer rows, Integer cols) { + super(rows, cols); + } + + public TaskLayoutDto(String type, String hideEmptyRows, String compactDirection) { + super(type, hideEmptyRows, compactDirection); + } + + public TaskLayoutDto(Integer rows, Integer cols, String type, String hideEmptyRows, String compactDirection) { + super(rows, cols, type, hideEmptyRows, compactDirection); + } + + public TaskLayoutDto(Integer offset, String fieldAlignment) { + this.offset = offset; + this.fieldAlignment = fieldAlignment; + } + + public TaskLayoutDto(Integer rows, Integer cols, Integer offset, String fieldAlignment) { + super(rows, cols); + this.offset = offset; + this.fieldAlignment = fieldAlignment; + } + + public TaskLayoutDto(String type, String hideEmptyRows, String compactDirection, Integer offset, String fieldAlignment) { + super(type, hideEmptyRows, compactDirection); + this.offset = offset; + this.fieldAlignment = fieldAlignment; + } + + public TaskLayoutDto(Integer rows, Integer cols, String type, String hideEmptyRows, String compactDirection, Integer offset, String fieldAlignment) { + super(rows, cols, type, hideEmptyRows, compactDirection); + this.offset = offset; + this.fieldAlignment = fieldAlignment; + } + + public Integer getOffset() { + return offset; + } + + public void setOffset(Integer offset) { + this.offset = offset; + } + + public String getFieldAlignment() { + return fieldAlignment; + } + + public void setFieldAlignment(String fieldAlignment) { + this.fieldAlignment = fieldAlignment; + } +} diff --git a/src/main/java/api/petrinet/domain/roles/ProcessRoleDto.java b/src/main/java/api/petrinet/domain/roles/ProcessRoleDto.java new file mode 100644 index 0000000000..a6e76e57e4 --- /dev/null +++ b/src/main/java/api/petrinet/domain/roles/ProcessRoleDto.java @@ -0,0 +1,84 @@ +package api.petrinet.domain.roles; + +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.ImportedDto; +import api.petrinet.domain.events.EventDto; + +import java.util.Map; + +public class ProcessRoleDto extends ImportedDto { + + private String id; + + private I18nStringDto name; + + private String netId; + + private String description; + + private Map events; + + public ProcessRoleDto() { + } + + public ProcessRoleDto(String importId) { + super(importId); + } + + public ProcessRoleDto(String id, I18nStringDto name, String netId, String description, Map events) { + this.id = id; + this.name = name; + this.netId = netId; + this.description = description; + this.events = events; + } + + public ProcessRoleDto(String importId, String id, I18nStringDto name, String netId, String description, Map events) { + super(importId); + this.id = id; + this.name = name; + this.netId = netId; + this.description = description; + this.events = events; + } + + public String getStringId() { + return id; + } + + public void setStringId(String id) { + this.id = id; + } + + public I18nStringDto getName() { + return name; + } + + public void setName(I18nStringDto name) { + this.name = name; + } + + public String getNetId() { + return netId; + } + + public void setNetId(String netId) { + this.netId = netId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Map getEvents() { + return events; + } + + public void setEvents(Map events) { + this.events = events; + } +} diff --git a/src/main/java/api/petrinet/version/VersionDto.java b/src/main/java/api/petrinet/version/VersionDto.java new file mode 100644 index 0000000000..5e4c99ce7f --- /dev/null +++ b/src/main/java/api/petrinet/version/VersionDto.java @@ -0,0 +1,43 @@ +package api.petrinet.version; + +public class VersionDto { + + private long major; + + private long minor; + + private long patch; + + public VersionDto() { + } + + public VersionDto(long major, long minor, long patch) { + this.major = major; + this.minor = minor; + this.patch = patch; + } + + public long getMajor() { + return major; + } + + public void setMajor(long major) { + this.major = major; + } + + public long getMinor() { + return minor; + } + + public void setMinor(long minor) { + this.minor = minor; + } + + public long getPatch() { + return patch; + } + + public void setPatch(long patch) { + this.patch = patch; + } +} diff --git a/src/main/java/api/workflow/domain/CaseDto.java b/src/main/java/api/workflow/domain/CaseDto.java new file mode 100644 index 0000000000..b3209bac0b --- /dev/null +++ b/src/main/java/api/workflow/domain/CaseDto.java @@ -0,0 +1,303 @@ +package api.workflow.domain; + +import api.auth.AuthorDto; +import api.petrinet.domain.PetriNetDto; +import api.petrinet.domain.dataset.FieldDto; + +import java.time.LocalDateTime; +import java.util.*; + +public class CaseDto { + + private String id; + + private LocalDateTime lastModified; + + private String visualId; + + private String petriNetId; + + private PetriNetDto petriNet; + + private String processIdentifier; + + private Map activePlaces; + + private String title; + + private String color; + + private String icon; + + private LocalDateTime creationDate; + + private LinkedHashMap dataSet; + + private LinkedHashSet immediateDataFields; + + private List immediateData; + + private AuthorDto author; + + private Map consumedTokens; + + private Set tasks; + + private Set enabledRoles; + + private Map> permissions; + + private Map> userRefs; + + private Map> users; + + private List viewRoles; + + private List viewUserRefs; + + private List viewUsers; + + private List negativeViewRoles; + + private List negativeViewUsers; + + public CaseDto() { + } + + public CaseDto(String id, LocalDateTime lastModified, String visualId, String petriNetId, PetriNetDto petriNet, String processIdentifier, Map activePlaces, String title, String color, String icon, LocalDateTime creationDate, LinkedHashMap dataSet, LinkedHashSet immediateDataFields, List immediateData, AuthorDto author, Map consumedTokens, Set tasks, Set enabledRoles, Map> permissions, Map> userRefs, Map> users, List viewRoles, List viewUserRefs, List viewUsers, List negativeViewRoles, List negativeViewUsers) { + this.id = id; + this.lastModified = lastModified; + this.visualId = visualId; + this.petriNetId = petriNetId; + this.petriNet = petriNet; + this.processIdentifier = processIdentifier; + this.activePlaces = activePlaces; + this.title = title; + this.color = color; + this.icon = icon; + this.creationDate = creationDate; + this.dataSet = dataSet; + this.immediateDataFields = immediateDataFields; + this.immediateData = immediateData; + this.author = author; + this.consumedTokens = consumedTokens; + this.tasks = tasks; + this.enabledRoles = enabledRoles; + this.permissions = permissions; + this.userRefs = userRefs; + this.users = users; + this.viewRoles = viewRoles; + this.viewUserRefs = viewUserRefs; + this.viewUsers = viewUsers; + this.negativeViewRoles = negativeViewRoles; + this.negativeViewUsers = negativeViewUsers; + } + + public String getStringId() { + return id; + } + + public void setStringId(String id) { + this.id = id; + } + + public LocalDateTime getLastModified() { + return lastModified; + } + + public void setLastModified(LocalDateTime lastModified) { + this.lastModified = lastModified; + } + + public String getVisualId() { + return visualId; + } + + public void setVisualId(String visualId) { + this.visualId = visualId; + } + + public String getPetriNetId() { + return petriNetId; + } + + public void setPetriNetId(String petriNetId) { + this.petriNetId = petriNetId; + } + + public PetriNetDto getPetriNet() { + return petriNet; + } + + public void setPetriNet(PetriNetDto petriNet) { + this.petriNet = petriNet; + } + + public String getProcessIdentifier() { + return processIdentifier; + } + + public void setProcessIdentifier(String processIdentifier) { + this.processIdentifier = processIdentifier; + } + + public Map getActivePlaces() { + return activePlaces; + } + + public void setActivePlaces(Map activePlaces) { + this.activePlaces = activePlaces; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public LocalDateTime getCreationDate() { + return creationDate; + } + + public void setCreationDate(LocalDateTime creationDate) { + this.creationDate = creationDate; + } + + public LinkedHashMap getDataSet() { + return dataSet; + } + + public void setDataSet(LinkedHashMap dataSet) { + this.dataSet = dataSet; + } + + public LinkedHashSet getImmediateDataFields() { + return immediateDataFields; + } + + public void setImmediateDataFields(LinkedHashSet immediateDataFields) { + this.immediateDataFields = immediateDataFields; + } + + public List getImmediateData() { + return immediateData; + } + + public void setImmediateData(List immediateData) { + this.immediateData = immediateData; + } + + public AuthorDto getAuthor() { + return author; + } + + public void setAuthor(AuthorDto author) { + this.author = author; + } + + public Map getConsumedTokens() { + return consumedTokens; + } + + public void setConsumedTokens(Map consumedTokens) { + this.consumedTokens = consumedTokens; + } + + public Set getTasks() { + return tasks; + } + + public void setTasks(Set tasks) { + this.tasks = tasks; + } + + public Set getEnabledRoles() { + return enabledRoles; + } + + public void setEnabledRoles(Set enabledRoles) { + this.enabledRoles = enabledRoles; + } + + public Map> getPermissions() { + return permissions; + } + + public void setPermissions(Map> permissions) { + this.permissions = permissions; + } + + public Map> getUserRefs() { + return userRefs; + } + + public void setUserRefs(Map> userRefs) { + this.userRefs = userRefs; + } + + public Map> getUsers() { + return users; + } + + public void setUsers(Map> users) { + this.users = users; + } + + public List getViewRoles() { + return viewRoles; + } + + public void setViewRoles(List viewRoles) { + this.viewRoles = viewRoles; + } + + public List getViewUserRefs() { + return viewUserRefs; + } + + public void setViewUserRefs(List viewUserRefs) { + this.viewUserRefs = viewUserRefs; + } + + public List getViewUsers() { + return viewUsers; + } + + public void setViewUsers(List viewUsers) { + this.viewUsers = viewUsers; + } + + public List getNegativeViewRoles() { + return negativeViewRoles; + } + + public void setNegativeViewRoles(List negativeViewRoles) { + this.negativeViewRoles = negativeViewRoles; + } + + public List getNegativeViewUsers() { + return negativeViewUsers; + } + + public void setNegativeViewUsers(List negativeViewUsers) { + this.negativeViewUsers = negativeViewUsers; + } +} diff --git a/src/main/java/api/workflow/domain/DataFieldDto.java b/src/main/java/api/workflow/domain/DataFieldDto.java new file mode 100644 index 0000000000..ff65aaa5eb --- /dev/null +++ b/src/main/java/api/workflow/domain/DataFieldDto.java @@ -0,0 +1,116 @@ +package api.workflow.domain; + +import api.petrinet.domain.dataset.logic.validation.ValidationDto; +import api.petrinet.domain.I18nStringDto; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class DataFieldDto { + + private Map> behavior; + + private Object value; + + private Set choices; + + private List allowedNets; + + private Map options; + + private List validations; + + private Map filterMetadata; + + private String encryption; + + private Long version; + + public DataFieldDto() { + } + + public DataFieldDto(Map> behavior, Object value, Set choices, List allowedNets, Map options, List validations, Map filterMetadata, String encryption, Long version) { + this.behavior = behavior; + this.value = value; + this.choices = choices; + this.allowedNets = allowedNets; + this.options = options; + this.validations = validations; + this.filterMetadata = filterMetadata; + this.encryption = encryption; + this.version = version; + } + + public Map> getBehavior() { + return behavior; + } + + public void setBehavior(Map> behavior) { + this.behavior = behavior; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public Set getChoices() { + return choices; + } + + public void setChoices(Set choices) { + this.choices = choices; + } + + public List getAllowedNets() { + return allowedNets; + } + + public void setAllowedNets(List allowedNets) { + this.allowedNets = allowedNets; + } + + public Map getOptions() { + return options; + } + + public void setOptions(Map options) { + this.options = options; + } + + public List getValidations() { + return validations; + } + + public void setValidations(List validations) { + this.validations = validations; + } + + public Map getFilterMetadata() { + return filterMetadata; + } + + public void setFilterMetadata(Map filterMetadata) { + this.filterMetadata = filterMetadata; + } + + public String getEncryption() { + return encryption; + } + + public void setEncryption(String encryption) { + this.encryption = encryption; + } + + public Long getVersion() { + return version; + } + + public void setVersion(Long version) { + this.version = version; + } +} diff --git a/src/main/java/api/workflow/domain/TaskDto.java b/src/main/java/api/workflow/domain/TaskDto.java new file mode 100644 index 0000000000..b0637f9f28 --- /dev/null +++ b/src/main/java/api/workflow/domain/TaskDto.java @@ -0,0 +1,383 @@ +package api.workflow.domain; + +import api.workflow.domain.triggers.TriggerDto; +import api.petrinet.domain.I18nStringDto; +import api.petrinet.domain.dataset.FieldDto; +import api.petrinet.domain.layout.TaskLayoutDto; + +import java.time.LocalDateTime; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; + +public class TaskDto { + + private String id; + + private String processId; + + private String caseId; + + private String transitionId; + + private TaskLayoutDto layout; + + private I18nStringDto title; + + private String caseColor; + + private String caseTitle; + + private Integer priority; + + private String userId; + + private List triggers; + + private Map> roles; + + private Map> userRefs; + + private Map> users; + + private List viewRoles; + + private List viewUserRefs; + + private List viewUsers; + + private List negativeViewRoles; + + private List negativeViewUsers; + + private LocalDateTime startDate; + + private LocalDateTime finishDate; + + private String finishedBy; + + private String transactionId; + + private Boolean requiredFilled; + + private LinkedHashSet immediateDataFields; + + private List immediateData; + + private String icon; + + private String assignPolicy; + + private String dataFocusPolicy; + + private String finishPolicy; + + private Map eventTitles; + + private Map assignedUserPolicy; + + private Map consumedTokens; + + public TaskDto() { + } + + public TaskDto(String id, String processId, String caseId, String transitionId, TaskLayoutDto layout, I18nStringDto title, String caseColor, String caseTitle, Integer priority, String userId, List triggers, Map> roles, Map> userRefs, Map> users, List viewRoles, List viewUserRefs, List viewUsers, List negativeViewRoles, List negativeViewUsers, LocalDateTime startDate, LocalDateTime finishDate, String finishedBy, String transactionId, Boolean requiredFilled, LinkedHashSet immediateDataFields, List immediateData, String icon, String assignPolicy, String dataFocusPolicy, String finishPolicy, Map eventTitles, Map assignedUserPolicy, Map consumedTokens) { + this.id = id; + this.processId = processId; + this.caseId = caseId; + this.transitionId = transitionId; + this.layout = layout; + this.title = title; + this.caseColor = caseColor; + this.caseTitle = caseTitle; + this.priority = priority; + this.userId = userId; + this.triggers = triggers; + this.roles = roles; + this.userRefs = userRefs; + this.users = users; + this.viewRoles = viewRoles; + this.viewUserRefs = viewUserRefs; + this.viewUsers = viewUsers; + this.negativeViewRoles = negativeViewRoles; + this.negativeViewUsers = negativeViewUsers; + this.startDate = startDate; + this.finishDate = finishDate; + this.finishedBy = finishedBy; + this.transactionId = transactionId; + this.requiredFilled = requiredFilled; + this.immediateDataFields = immediateDataFields; + this.immediateData = immediateData; + this.icon = icon; + this.assignPolicy = assignPolicy; + this.dataFocusPolicy = dataFocusPolicy; + this.finishPolicy = finishPolicy; + this.eventTitles = eventTitles; + this.assignedUserPolicy = assignedUserPolicy; + this.consumedTokens = consumedTokens; + } + + public String getStringId() { + return id; + } + + public void setStringId(String id) { + this.id = id; + } + + public String getProcessId() { + return processId; + } + + public void setProcessId(String processId) { + this.processId = processId; + } + + public String getCaseId() { + return caseId; + } + + public void setCaseId(String caseId) { + this.caseId = caseId; + } + + public String getTransitionId() { + return transitionId; + } + + public void setTransitionId(String transitionId) { + this.transitionId = transitionId; + } + + public TaskLayoutDto getLayout() { + return layout; + } + + public void setLayout(TaskLayoutDto layout) { + this.layout = layout; + } + + public I18nStringDto getTitle() { + return title; + } + + public void setTitle(I18nStringDto title) { + this.title = title; + } + + public String getCaseColor() { + return caseColor; + } + + public void setCaseColor(String caseColor) { + this.caseColor = caseColor; + } + + public String getCaseTitle() { + return caseTitle; + } + + public void setCaseTitle(String caseTitle) { + this.caseTitle = caseTitle; + } + + public Integer getPriority() { + return priority; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public List getTriggers() { + return triggers; + } + + public void setTriggers(List triggers) { + this.triggers = triggers; + } + + public Map> getRoles() { + return roles; + } + + public void setRoles(Map> roles) { + this.roles = roles; + } + + public Map> getUserRefs() { + return userRefs; + } + + public void setUserRefs(Map> userRefs) { + this.userRefs = userRefs; + } + + public Map> getUsers() { + return users; + } + + public void setUsers(Map> users) { + this.users = users; + } + + public List getViewRoles() { + return viewRoles; + } + + public void setViewRoles(List viewRoles) { + this.viewRoles = viewRoles; + } + + public List getViewUserRefs() { + return viewUserRefs; + } + + public void setViewUserRefs(List viewUserRefs) { + this.viewUserRefs = viewUserRefs; + } + + public List getViewUsers() { + return viewUsers; + } + + public void setViewUsers(List viewUsers) { + this.viewUsers = viewUsers; + } + + public List getNegativeViewRoles() { + return negativeViewRoles; + } + + public void setNegativeViewRoles(List negativeViewRoles) { + this.negativeViewRoles = negativeViewRoles; + } + + public List getNegativeViewUsers() { + return negativeViewUsers; + } + + public void setNegativeViewUsers(List negativeViewUsers) { + this.negativeViewUsers = negativeViewUsers; + } + + public LocalDateTime getStartDate() { + return startDate; + } + + public void setStartDate(LocalDateTime startDate) { + this.startDate = startDate; + } + + public LocalDateTime getFinishDate() { + return finishDate; + } + + public void setFinishDate(LocalDateTime finishDate) { + this.finishDate = finishDate; + } + + public String getFinishedBy() { + return finishedBy; + } + + public void setFinishedBy(String finishedBy) { + this.finishedBy = finishedBy; + } + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + + public Boolean getRequiredFilled() { + return requiredFilled; + } + + public void setRequiredFilled(Boolean requiredFilled) { + this.requiredFilled = requiredFilled; + } + + public LinkedHashSet getImmediateDataFields() { + return immediateDataFields; + } + + public void setImmediateDataFields(LinkedHashSet immediateDataFields) { + this.immediateDataFields = immediateDataFields; + } + + public List getImmediateData() { + return immediateData; + } + + public void setImmediateData(List immediateData) { + this.immediateData = immediateData; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getAssignPolicy() { + return assignPolicy; + } + + public void setAssignPolicy(String assignPolicy) { + this.assignPolicy = assignPolicy; + } + + public String getDataFocusPolicy() { + return dataFocusPolicy; + } + + public void setDataFocusPolicy(String dataFocusPolicy) { + this.dataFocusPolicy = dataFocusPolicy; + } + + public String getFinishPolicy() { + return finishPolicy; + } + + public void setFinishPolicy(String finishPolicy) { + this.finishPolicy = finishPolicy; + } + + public Map getEventTitles() { + return eventTitles; + } + + public void setEventTitles(Map eventTitles) { + this.eventTitles = eventTitles; + } + + public Map getAssignedUserPolicy() { + return assignedUserPolicy; + } + + public void setAssignedUserPolicy(Map assignedUserPolicy) { + this.assignedUserPolicy = assignedUserPolicy; + } + + public Map getConsumedTokens() { + return consumedTokens; + } + + public void setConsumedTokens(Map consumedTokens) { + this.consumedTokens = consumedTokens; + } +} diff --git a/src/main/java/api/workflow/domain/TaskPairDto.java b/src/main/java/api/workflow/domain/TaskPairDto.java new file mode 100644 index 0000000000..367325dc59 --- /dev/null +++ b/src/main/java/api/workflow/domain/TaskPairDto.java @@ -0,0 +1,32 @@ +package api.workflow.domain; + +public class TaskPairDto { + + private String task; + + private String transition; + + public TaskPairDto() { + } + + public TaskPairDto(String task, String transition) { + this.task = task; + this.transition = transition; + } + + public String getTask() { + return task; + } + + public void setTask(String task) { + this.task = task; + } + + public String getTransition() { + return transition; + } + + public void setTransition(String transition) { + this.transition = transition; + } +} diff --git a/src/main/java/api/workflow/domain/triggers/TriggerDto.java b/src/main/java/api/workflow/domain/triggers/TriggerDto.java new file mode 100644 index 0000000000..30fda6fd42 --- /dev/null +++ b/src/main/java/api/workflow/domain/triggers/TriggerDto.java @@ -0,0 +1,23 @@ +package api.workflow.domain.triggers; + +import api.petrinet.domain.ImportedDto; + +public class TriggerDto extends ImportedDto { + + private String id; + + public TriggerDto() { + } + + public TriggerDto(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedBooleanFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedBooleanFieldDto.java new file mode 100644 index 0000000000..f5533af93d --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedBooleanFieldDto.java @@ -0,0 +1,18 @@ +package api.workflow.web.responsebodies; + +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; + +public class LocalisedBooleanFieldDto extends LocalisedFieldDto { + + public LocalisedBooleanFieldDto() { + } + + public LocalisedBooleanFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedCaseFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedCaseFieldDto.java new file mode 100644 index 0000000000..53cd261872 --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedCaseFieldDto.java @@ -0,0 +1,29 @@ +package api.workflow.web.responsebodies; + +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; + +public class LocalisedCaseFieldDto extends LocalisedFieldDto { + + private List allowedNets; + + public LocalisedCaseFieldDto() { + } + + public LocalisedCaseFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } + + public LocalisedCaseFieldDto(List allowedNets) { + this.allowedNets = allowedNets; + } + + public LocalisedCaseFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, List allowedNets) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + this.allowedNets = allowedNets; + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedChoiceFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedChoiceFieldDto.java new file mode 100644 index 0000000000..386293d7cc --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedChoiceFieldDto.java @@ -0,0 +1,37 @@ +package api.workflow.web.responsebodies; + +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; + +public class LocalisedChoiceFieldDto extends LocalisedFieldDto { + + private List choices; + + public LocalisedChoiceFieldDto() { + } + + public LocalisedChoiceFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } + + public LocalisedChoiceFieldDto(List choices) { + this.choices = choices; + } + + public LocalisedChoiceFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, List choices) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + this.choices = choices; + } + + public List getChoices() { + return choices; + } + + public void setChoices(List choices) { + this.choices = choices; + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedDateFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedDateFieldDto.java new file mode 100644 index 0000000000..757395ea25 --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedDateFieldDto.java @@ -0,0 +1,49 @@ +package api.workflow.web.responsebodies; + +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; + +public class LocalisedDateFieldDto extends LocalisedFieldDto { + + private String minDate; + + private String maxDate; + + public LocalisedDateFieldDto() { + } + + public LocalisedDateFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } + + public LocalisedDateFieldDto(String minDate, String maxDate) { + this.minDate = minDate; + this.maxDate = maxDate; + } + + public LocalisedDateFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, String minDate, String maxDate) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + this.minDate = minDate; + this.maxDate = maxDate; + } + + public String getMinDate() { + return minDate; + } + + public void setMinDate(String minDate) { + this.minDate = minDate; + } + + public String getMaxDate() { + return maxDate; + } + + public void setMaxDate(String maxDate) { + this.maxDate = maxDate; + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedDateTimeFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedDateTimeFieldDto.java new file mode 100644 index 0000000000..9863eef0e2 --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedDateTimeFieldDto.java @@ -0,0 +1,49 @@ +package api.workflow.web.responsebodies; + +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; + +public class LocalisedDateTimeFieldDto extends LocalisedFieldDto { + + private String minDate; + + private String maxDate; + + public LocalisedDateTimeFieldDto() { + } + + public LocalisedDateTimeFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } + + public LocalisedDateTimeFieldDto(String minDate, String maxDate) { + this.minDate = minDate; + this.maxDate = maxDate; + } + + public LocalisedDateTimeFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, String minDate, String maxDate) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + this.minDate = minDate; + this.maxDate = maxDate; + } + + public String getMinDate() { + return minDate; + } + + public void setMinDate(String minDate) { + this.minDate = minDate; + } + + public String getMaxDate() { + return maxDate; + } + + public void setMaxDate(String maxDate) { + this.maxDate = maxDate; + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationFieldDto.java new file mode 100644 index 0000000000..ab5df59d3c --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationFieldDto.java @@ -0,0 +1,26 @@ +package api.workflow.web.responsebodies; + +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; + +public class LocalisedEnumerationFieldDto extends LocalisedChoiceFieldDto { + + public LocalisedEnumerationFieldDto() { + } + + public LocalisedEnumerationFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } + + public LocalisedEnumerationFieldDto(List choices) { + super(choices); + } + + public LocalisedEnumerationFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, List choices) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId, choices); + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationMapFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationMapFieldDto.java new file mode 100644 index 0000000000..941e7a97f5 --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationMapFieldDto.java @@ -0,0 +1,27 @@ +package api.workflow.web.responsebodies; + +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; +import java.util.Map; + +public class LocalisedEnumerationMapFieldDto extends LocalisedMapOptionsFieldDto { + + public LocalisedEnumerationMapFieldDto() { + } + + public LocalisedEnumerationMapFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } + + public LocalisedEnumerationMapFieldDto(Map options) { + super(options); + } + + public LocalisedEnumerationMapFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, Map options) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId, options); + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedFieldDto.java new file mode 100644 index 0000000000..8234e70df2 --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedFieldDto.java @@ -0,0 +1,171 @@ +package api.workflow.web.responsebodies; + +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; + +import java.util.List; + +public class LocalisedFieldDto { + + private String stringId; + + private String type; + + private String name; + + private String description; + + private String placeholder; + + private ObjectNode behavior; + + private FieldLayoutDto layout; + + private Object value; + + private Long order; + + private Integer length; + + private ComponentDto component; + + private List validations; + + private String parentTaskId; + + private String parentCaseId; + + public LocalisedFieldDto() { + } + + public LocalisedFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + this.stringId = stringId; + this.type = type; + this.name = name; + this.description = description; + this.placeholder = placeholder; + this.behavior = behavior; + this.layout = layout; + this.value = value; + this.order = order; + this.length = length; + this.component = component; + this.validations = validations; + this.parentTaskId = parentTaskId; + this.parentCaseId = parentCaseId; + } + + public String getStringId() { + return stringId; + } + + public void setStringId(String stringId) { + this.stringId = stringId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getPlaceholder() { + return placeholder; + } + + public void setPlaceholder(String placeholder) { + this.placeholder = placeholder; + } + + public ObjectNode getBehavior() { + return behavior; + } + + public void setBehavior(ObjectNode behavior) { + this.behavior = behavior; + } + + public FieldLayoutDto getLayout() { + return layout; + } + + public void setLayout(FieldLayoutDto layout) { + this.layout = layout; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public Long getOrder() { + return order; + } + + public void setOrder(Long order) { + this.order = order; + } + + public Integer getLength() { + return length; + } + + public void setLength(Integer length) { + this.length = length; + } + + public ComponentDto getComponent() { + return component; + } + + public void setComponent(ComponentDto component) { + this.component = component; + } + + public List getValidations() { + return validations; + } + + public void setValidations(List validations) { + this.validations = validations; + } + + public String getParentTaskId() { + return parentTaskId; + } + + public void setParentTaskId(String parentTaskId) { + this.parentTaskId = parentTaskId; + } + + public String getParentCaseId() { + return parentCaseId; + } + + public void setParentCaseId(String parentCaseId) { + this.parentCaseId = parentCaseId; + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedFileListFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedFileListFieldDto.java new file mode 100644 index 0000000000..318ce20246 --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedFileListFieldDto.java @@ -0,0 +1,18 @@ +package api.workflow.web.responsebodies; + +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; + +import java.util.List; + +public class LocalisedFileListFieldDto extends LocalisedFieldDto { + + public LocalisedFileListFieldDto() { + } + + public LocalisedFileListFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedFilterFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedFilterFieldDto.java new file mode 100644 index 0000000000..045de7e422 --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedFilterFieldDto.java @@ -0,0 +1,49 @@ +package api.workflow.web.responsebodies; + +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; + +public class LocalisedFilterFieldDto extends LocalisedFieldDto { + + private List allowedNets; + + private Object filterMetadata; + + public LocalisedFilterFieldDto() { + } + + public LocalisedFilterFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } + + public LocalisedFilterFieldDto(List allowedNets, Object filterMetadata) { + this.allowedNets = allowedNets; + this.filterMetadata = filterMetadata; + } + + public LocalisedFilterFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, List allowedNets, Object filterMetadata) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + this.allowedNets = allowedNets; + this.filterMetadata = filterMetadata; + } + + public List getAllowedNets() { + return allowedNets; + } + + public void setAllowedNets(List allowedNets) { + this.allowedNets = allowedNets; + } + + public Object getFilterMetadata() { + return filterMetadata; + } + + public void setFilterMetadata(Object filterMetadata) { + this.filterMetadata = filterMetadata; + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedI18nFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedI18nFieldDto.java new file mode 100644 index 0000000000..93a208f8a5 --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedI18nFieldDto.java @@ -0,0 +1,18 @@ +package api.workflow.web.responsebodies; + +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; + +public class LocalisedI18nFieldDto extends LocalisedFieldDto { + + public LocalisedI18nFieldDto() { + } + + public LocalisedI18nFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedMapOptionsFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedMapOptionsFieldDto.java new file mode 100644 index 0000000000..00a8308ea7 --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedMapOptionsFieldDto.java @@ -0,0 +1,38 @@ +package api.workflow.web.responsebodies; + +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; +import java.util.Map; + +public class LocalisedMapOptionsFieldDto extends LocalisedFieldDto { + + private Map options; + + public LocalisedMapOptionsFieldDto() { + } + + public LocalisedMapOptionsFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } + + public LocalisedMapOptionsFieldDto(Map options) { + this.options = options; + } + + public LocalisedMapOptionsFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, Map options) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + this.options = options; + } + + public Map getOptions() { + return options; + } + + public void setOptions(Map options) { + this.options = options; + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceFieldDto.java new file mode 100644 index 0000000000..86d1af55d7 --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceFieldDto.java @@ -0,0 +1,26 @@ +package api.workflow.web.responsebodies; + +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; + +public class LocalisedMultichoiceFieldDto extends LocalisedChoiceFieldDto { + + public LocalisedMultichoiceFieldDto() { + } + + public LocalisedMultichoiceFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } + + public LocalisedMultichoiceFieldDto(List choices) { + super(choices); + } + + public LocalisedMultichoiceFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, List choices) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId, choices); + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceMapFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceMapFieldDto.java new file mode 100644 index 0000000000..c7da9a1108 --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceMapFieldDto.java @@ -0,0 +1,28 @@ +package api.workflow.web.responsebodies; + +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class LocalisedMultichoiceMapFieldDto extends LocalisedMapOptionsFieldDto> { + + public LocalisedMultichoiceMapFieldDto() { + } + + public LocalisedMultichoiceMapFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } + + public LocalisedMultichoiceMapFieldDto(Map options) { + super(options); + } + + public LocalisedMultichoiceMapFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, Map options) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId, options); + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedNumberFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedNumberFieldDto.java new file mode 100644 index 0000000000..7fa86b23ee --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedNumberFieldDto.java @@ -0,0 +1,18 @@ +package api.workflow.web.responsebodies; + +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; + +import java.util.List; + +public class LocalisedNumberFieldDto extends LocalisedFieldDto { + + public LocalisedNumberFieldDto() { + } + + public LocalisedNumberFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedTextFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedTextFieldDto.java new file mode 100644 index 0000000000..499f2cc8a7 --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedTextFieldDto.java @@ -0,0 +1,18 @@ +package api.workflow.web.responsebodies; + +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; + +import java.util.List; + +public class LocalisedTextFieldDto extends LocalisedFieldDto { + + public LocalisedTextFieldDto() { + } + + public LocalisedTextFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } +} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedUserFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedUserFieldDto.java new file mode 100644 index 0000000000..25032ded96 --- /dev/null +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedUserFieldDto.java @@ -0,0 +1,38 @@ +package api.workflow.web.responsebodies; + +import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; +import com.fasterxml.jackson.databind.node.ObjectNode; +import api.petrinet.domain.ComponentDto; +import api.petrinet.domain.dataset.logic.FieldLayoutDto; + +import java.util.List; +import java.util.Set; + +public class LocalisedUserFieldDto extends LocalisedFieldDto { + + private Set roles; + + public LocalisedUserFieldDto() { + } + + public LocalisedUserFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + } + + public LocalisedUserFieldDto(Set roles) { + this.roles = roles; + } + + public LocalisedUserFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, Set roles) { + super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); + this.roles = roles; + } + + public Set getRoles() { + return roles; + } + + public void setRoles(Set roles) { + this.roles = roles; + } +} From c1566caf48ea99e961518c7dec7e0730e3ecf29d Mon Sep 17 00:00:00 2001 From: Stefan Renczes Date: Fri, 3 Jun 2022 09:21:00 +0200 Subject: [PATCH 07/13] [NAE-1567] Plugin management - make final and abstract classes in api --- .../api/petrinet/domain/ComponentDto.java | 34 ++++++++++++++++++- .../petrinet/domain/DataFieldLogicDto.java | 2 +- .../domain/DataFieldsResourceDto.java | 2 +- .../api/petrinet/domain/DataGroupDto.java | 2 +- .../java/api/petrinet/domain/FunctionDto.java | 2 +- .../java/api/petrinet/domain/IconDto.java | 26 +++++++++++++- .../java/api/petrinet/domain/ImportedDto.java | 2 +- .../java/api/petrinet/domain/NodeDto.java | 2 +- .../java/api/petrinet/domain/PetriNetDto.java | 2 +- .../petrinet/domain/PetriNetObjectDto.java | 2 +- .../java/api/petrinet/domain/PlaceDto.java | 2 +- .../java/api/petrinet/domain/PositionDto.java | 2 +- .../api/petrinet/domain/TransactionDto.java | 2 +- .../api/petrinet/domain/TransitionDto.java | 2 +- .../java/api/petrinet/domain/arcs/ArcDto.java | 26 +++++++------- .../arcs/reference/ReferencableDto.java | 2 +- .../domain/arcs/reference/ReferenceDto.java | 2 +- .../domain/dataset/logic/FieldLayoutDto.java | 2 +- .../dataset/logic/action/ActionDto.java | 2 +- .../logic/action/runner/ExpressionDto.java | 6 ++-- .../validation/LocalisedValidationDto.java | 2 +- .../logic/validation/ValidationDto.java | 2 +- .../petrinet/domain/events/BaseEventDto.java | 2 +- .../petrinet/domain/events/CaseEventDto.java | 2 +- .../petrinet/domain/events/DataEventDto.java | 2 +- .../api/petrinet/domain/events/EventDto.java | 2 +- .../domain/events/ProcessEventDto.java | 2 +- .../domain/layout/DataGroupLayoutDto.java | 2 +- .../petrinet/domain/layout/FormLayoutDto.java | 2 +- .../api/petrinet/domain/layout/LayoutDto.java | 2 +- .../petrinet/domain/layout/TaskLayoutDto.java | 2 +- .../java/api/petrinet/version/VersionDto.java | 2 +- .../java/api/workflow/domain/CaseDto.java | 2 +- .../api/workflow/domain/DataFieldDto.java | 2 +- .../java/api/workflow/domain/TaskDto.java | 2 +- .../java/api/workflow/domain/TaskPairDto.java | 2 +- .../workflow/domain/triggers/TriggerDto.java | 2 +- .../LocalisedBooleanFieldDto.java | 2 +- .../responsebodies/LocalisedCaseFieldDto.java | 2 +- .../LocalisedChoiceFieldDto.java | 2 +- .../responsebodies/LocalisedDateFieldDto.java | 2 +- .../LocalisedDateTimeFieldDto.java | 2 +- .../LocalisedEnumerationFieldDto.java | 2 +- .../LocalisedEnumerationMapFieldDto.java | 2 +- .../web/responsebodies/LocalisedFieldDto.java | 2 +- .../LocalisedFileListFieldDto.java | 2 +- .../LocalisedFilterFieldDto.java | 2 +- .../responsebodies/LocalisedI18nFieldDto.java | 2 +- .../LocalisedMapOptionsFieldDto.java | 2 +- .../LocalisedMultichoiceFieldDto.java | 2 +- .../LocalisedMultichoiceMapFieldDto.java | 2 +- .../LocalisedNumberFieldDto.java | 2 +- .../responsebodies/LocalisedTextFieldDto.java | 2 +- .../responsebodies/LocalisedUserFieldDto.java | 2 +- 54 files changed, 124 insertions(+), 68 deletions(-) diff --git a/src/main/java/api/petrinet/domain/ComponentDto.java b/src/main/java/api/petrinet/domain/ComponentDto.java index 547f680978..d74e715695 100644 --- a/src/main/java/api/petrinet/domain/ComponentDto.java +++ b/src/main/java/api/petrinet/domain/ComponentDto.java @@ -3,7 +3,7 @@ import java.util.List; import java.util.Map; -public class ComponentDto { +public final class ComponentDto { private String name; @@ -11,4 +11,36 @@ public class ComponentDto { private List optionIcons; + public ComponentDto() { + } + + public ComponentDto(String name, Map properties, List optionIcons) { + this.name = name; + this.properties = properties; + this.optionIcons = optionIcons; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + public List getOptionIcons() { + return optionIcons; + } + + public void setOptionIcons(List optionIcons) { + this.optionIcons = optionIcons; + } } diff --git a/src/main/java/api/petrinet/domain/DataFieldLogicDto.java b/src/main/java/api/petrinet/domain/DataFieldLogicDto.java index 5abee2d201..8a5e4f8922 100644 --- a/src/main/java/api/petrinet/domain/DataFieldLogicDto.java +++ b/src/main/java/api/petrinet/domain/DataFieldLogicDto.java @@ -6,7 +6,7 @@ import java.util.Map; import java.util.Set; -public class DataFieldLogicDto { +public final class DataFieldLogicDto { private Set behavior; diff --git a/src/main/java/api/petrinet/domain/DataFieldsResourceDto.java b/src/main/java/api/petrinet/domain/DataFieldsResourceDto.java index 238083a3a9..014698d22b 100644 --- a/src/main/java/api/petrinet/domain/DataFieldsResourceDto.java +++ b/src/main/java/api/petrinet/domain/DataFieldsResourceDto.java @@ -4,7 +4,7 @@ import java.util.Collection; -public class DataFieldsResourceDto { +public final class DataFieldsResourceDto { private Collection content; diff --git a/src/main/java/api/petrinet/domain/DataGroupDto.java b/src/main/java/api/petrinet/domain/DataGroupDto.java index 0f2ff1f256..5b93d1817f 100644 --- a/src/main/java/api/petrinet/domain/DataGroupDto.java +++ b/src/main/java/api/petrinet/domain/DataGroupDto.java @@ -4,7 +4,7 @@ import java.util.Set; -public class DataGroupDto extends PetriNetObjectDto { +public final class DataGroupDto extends PetriNetObjectDto { private Set data; diff --git a/src/main/java/api/petrinet/domain/FunctionDto.java b/src/main/java/api/petrinet/domain/FunctionDto.java index d6361dd0eb..06b77e47f5 100644 --- a/src/main/java/api/petrinet/domain/FunctionDto.java +++ b/src/main/java/api/petrinet/domain/FunctionDto.java @@ -1,6 +1,6 @@ package api.petrinet.domain; -public class FunctionDto extends PetriNetObjectDto { +public final class FunctionDto extends PetriNetObjectDto { private String definition; diff --git a/src/main/java/api/petrinet/domain/IconDto.java b/src/main/java/api/petrinet/domain/IconDto.java index ac31567011..d5955604df 100644 --- a/src/main/java/api/petrinet/domain/IconDto.java +++ b/src/main/java/api/petrinet/domain/IconDto.java @@ -1,6 +1,6 @@ package api.petrinet.domain; -public class IconDto { +public final class IconDto { private String key; @@ -16,4 +16,28 @@ public IconDto(String key, String value, String type) { this.value = value; this.type = type; } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } } diff --git a/src/main/java/api/petrinet/domain/ImportedDto.java b/src/main/java/api/petrinet/domain/ImportedDto.java index 651a0fb6fa..bfa5d2d012 100644 --- a/src/main/java/api/petrinet/domain/ImportedDto.java +++ b/src/main/java/api/petrinet/domain/ImportedDto.java @@ -1,6 +1,6 @@ package api.petrinet.domain; -public class ImportedDto { +public abstract class ImportedDto { private String importId; public String getImportId() { diff --git a/src/main/java/api/petrinet/domain/NodeDto.java b/src/main/java/api/petrinet/domain/NodeDto.java index e2ae16adbc..2ca9283899 100644 --- a/src/main/java/api/petrinet/domain/NodeDto.java +++ b/src/main/java/api/petrinet/domain/NodeDto.java @@ -1,6 +1,6 @@ package api.petrinet.domain; -public class NodeDto extends PetriNetObjectDto { +public abstract class NodeDto extends PetriNetObjectDto { private PositionDto position; diff --git a/src/main/java/api/petrinet/domain/PetriNetDto.java b/src/main/java/api/petrinet/domain/PetriNetDto.java index 8e961532af..c2ff4d2cde 100644 --- a/src/main/java/api/petrinet/domain/PetriNetDto.java +++ b/src/main/java/api/petrinet/domain/PetriNetDto.java @@ -13,7 +13,7 @@ import java.util.List; import java.util.Map; -public class PetriNetDto extends PetriNetObjectDto { +public final class PetriNetDto extends PetriNetObjectDto { private String identifier; private I18nStringDto title; diff --git a/src/main/java/api/petrinet/domain/PetriNetObjectDto.java b/src/main/java/api/petrinet/domain/PetriNetObjectDto.java index 446fb08f91..a358f0da73 100644 --- a/src/main/java/api/petrinet/domain/PetriNetObjectDto.java +++ b/src/main/java/api/petrinet/domain/PetriNetObjectDto.java @@ -1,6 +1,6 @@ package api.petrinet.domain; -public class PetriNetObjectDto extends ImportedDto { +public abstract class PetriNetObjectDto extends ImportedDto { private String id; diff --git a/src/main/java/api/petrinet/domain/PlaceDto.java b/src/main/java/api/petrinet/domain/PlaceDto.java index 29ee8e0f5c..42e5d3cd83 100644 --- a/src/main/java/api/petrinet/domain/PlaceDto.java +++ b/src/main/java/api/petrinet/domain/PlaceDto.java @@ -1,6 +1,6 @@ package api.petrinet.domain; -public class PlaceDto extends NodeDto { +public final class PlaceDto extends NodeDto { private Integer tokens; diff --git a/src/main/java/api/petrinet/domain/PositionDto.java b/src/main/java/api/petrinet/domain/PositionDto.java index f5b568426c..0f0c47e8cb 100644 --- a/src/main/java/api/petrinet/domain/PositionDto.java +++ b/src/main/java/api/petrinet/domain/PositionDto.java @@ -1,6 +1,6 @@ package api.petrinet.domain; -public class PositionDto { +public final class PositionDto { private Integer x; diff --git a/src/main/java/api/petrinet/domain/TransactionDto.java b/src/main/java/api/petrinet/domain/TransactionDto.java index 7ffa59417c..f52616b8d5 100644 --- a/src/main/java/api/petrinet/domain/TransactionDto.java +++ b/src/main/java/api/petrinet/domain/TransactionDto.java @@ -2,7 +2,7 @@ import java.util.List; -public class TransactionDto extends PetriNetObjectDto { +public final class TransactionDto extends PetriNetObjectDto { private List transitions; diff --git a/src/main/java/api/petrinet/domain/TransitionDto.java b/src/main/java/api/petrinet/domain/TransitionDto.java index 47f7be2f48..018c4e932d 100644 --- a/src/main/java/api/petrinet/domain/TransitionDto.java +++ b/src/main/java/api/petrinet/domain/TransitionDto.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Map; -public class TransitionDto extends NodeDto { +public final class TransitionDto extends NodeDto { private Map dataGroups; diff --git a/src/main/java/api/petrinet/domain/arcs/ArcDto.java b/src/main/java/api/petrinet/domain/arcs/ArcDto.java index bec139cdd3..8ec376a5e5 100644 --- a/src/main/java/api/petrinet/domain/arcs/ArcDto.java +++ b/src/main/java/api/petrinet/domain/arcs/ArcDto.java @@ -3,19 +3,19 @@ import api.petrinet.domain.NodeDto; import api.petrinet.domain.arcs.reference.ReferenceDto; -public class ArcDto { - - protected NodeDto source; - - protected String sourceId; - - protected NodeDto destination; - - protected String destinationId; - - protected Integer multiplicity; - - protected ReferenceDto reference; +public final class ArcDto { + + private NodeDto source; + + private String sourceId; + + private NodeDto destination; + + private String destinationId; + + private Integer multiplicity; + + private ReferenceDto reference; public ArcDto() { } diff --git a/src/main/java/api/petrinet/domain/arcs/reference/ReferencableDto.java b/src/main/java/api/petrinet/domain/arcs/reference/ReferencableDto.java index f4eee79c5f..0f3a4091af 100644 --- a/src/main/java/api/petrinet/domain/arcs/reference/ReferencableDto.java +++ b/src/main/java/api/petrinet/domain/arcs/reference/ReferencableDto.java @@ -1,6 +1,6 @@ package api.petrinet.domain.arcs.reference; -public class ReferencableDto { +public final class ReferencableDto { private int multiplicity; diff --git a/src/main/java/api/petrinet/domain/arcs/reference/ReferenceDto.java b/src/main/java/api/petrinet/domain/arcs/reference/ReferenceDto.java index 89b0842b44..51cb80977b 100644 --- a/src/main/java/api/petrinet/domain/arcs/reference/ReferenceDto.java +++ b/src/main/java/api/petrinet/domain/arcs/reference/ReferenceDto.java @@ -1,6 +1,6 @@ package api.petrinet.domain.arcs.reference; -public class ReferenceDto { +public final class ReferenceDto { private String reference; diff --git a/src/main/java/api/petrinet/domain/dataset/logic/FieldLayoutDto.java b/src/main/java/api/petrinet/domain/dataset/logic/FieldLayoutDto.java index ce0bf160d4..2ea53ccb5a 100644 --- a/src/main/java/api/petrinet/domain/dataset/logic/FieldLayoutDto.java +++ b/src/main/java/api/petrinet/domain/dataset/logic/FieldLayoutDto.java @@ -2,7 +2,7 @@ import api.petrinet.domain.layout.LayoutDto; -public class FieldLayoutDto extends LayoutDto { +public final class FieldLayoutDto extends LayoutDto { private int x; diff --git a/src/main/java/api/petrinet/domain/dataset/logic/action/ActionDto.java b/src/main/java/api/petrinet/domain/dataset/logic/action/ActionDto.java index 3763502e45..b9504d594a 100644 --- a/src/main/java/api/petrinet/domain/dataset/logic/action/ActionDto.java +++ b/src/main/java/api/petrinet/domain/dataset/logic/action/ActionDto.java @@ -3,7 +3,7 @@ import java.util.HashMap; import java.util.Map; -public class ActionDto { +public final class ActionDto { private String importId; diff --git a/src/main/java/api/petrinet/domain/dataset/logic/action/runner/ExpressionDto.java b/src/main/java/api/petrinet/domain/dataset/logic/action/runner/ExpressionDto.java index 97ddcc2648..ecb01859b7 100644 --- a/src/main/java/api/petrinet/domain/dataset/logic/action/runner/ExpressionDto.java +++ b/src/main/java/api/petrinet/domain/dataset/logic/action/runner/ExpressionDto.java @@ -1,10 +1,10 @@ package api.petrinet.domain.dataset.logic.action.runner; -public class ExpressionDto { +public final class ExpressionDto { - protected String id; + private String id; - protected String definition; + private String definition; ExpressionDto() { } diff --git a/src/main/java/api/petrinet/domain/dataset/logic/validation/LocalisedValidationDto.java b/src/main/java/api/petrinet/domain/dataset/logic/validation/LocalisedValidationDto.java index 7dcf3b75e9..3ab9cca4a6 100644 --- a/src/main/java/api/petrinet/domain/dataset/logic/validation/LocalisedValidationDto.java +++ b/src/main/java/api/petrinet/domain/dataset/logic/validation/LocalisedValidationDto.java @@ -1,6 +1,6 @@ package api.petrinet.domain.dataset.logic.validation; -public class LocalisedValidationDto { +public final class LocalisedValidationDto { private String validationRule; diff --git a/src/main/java/api/petrinet/domain/dataset/logic/validation/ValidationDto.java b/src/main/java/api/petrinet/domain/dataset/logic/validation/ValidationDto.java index 4740113f1c..83d254c92f 100644 --- a/src/main/java/api/petrinet/domain/dataset/logic/validation/ValidationDto.java +++ b/src/main/java/api/petrinet/domain/dataset/logic/validation/ValidationDto.java @@ -3,7 +3,7 @@ import api.petrinet.domain.I18nStringDto; -public class ValidationDto { +public final class ValidationDto { private String validationRule; diff --git a/src/main/java/api/petrinet/domain/events/BaseEventDto.java b/src/main/java/api/petrinet/domain/events/BaseEventDto.java index 483bddb1ca..f7a6707cf8 100644 --- a/src/main/java/api/petrinet/domain/events/BaseEventDto.java +++ b/src/main/java/api/petrinet/domain/events/BaseEventDto.java @@ -6,7 +6,7 @@ import java.util.List; -public class BaseEventDto extends ImportedDto { +public abstract class BaseEventDto extends ImportedDto { private String id; diff --git a/src/main/java/api/petrinet/domain/events/CaseEventDto.java b/src/main/java/api/petrinet/domain/events/CaseEventDto.java index 59a343e670..c1524e7278 100644 --- a/src/main/java/api/petrinet/domain/events/CaseEventDto.java +++ b/src/main/java/api/petrinet/domain/events/CaseEventDto.java @@ -5,7 +5,7 @@ import java.util.List; -public class CaseEventDto extends BaseEventDto { +public final class CaseEventDto extends BaseEventDto { private String type; diff --git a/src/main/java/api/petrinet/domain/events/DataEventDto.java b/src/main/java/api/petrinet/domain/events/DataEventDto.java index a4eeebc89e..d206bf0da1 100644 --- a/src/main/java/api/petrinet/domain/events/DataEventDto.java +++ b/src/main/java/api/petrinet/domain/events/DataEventDto.java @@ -5,7 +5,7 @@ import java.util.List; -public class DataEventDto extends BaseEventDto { +public final class DataEventDto extends BaseEventDto { private String type; diff --git a/src/main/java/api/petrinet/domain/events/EventDto.java b/src/main/java/api/petrinet/domain/events/EventDto.java index 03faf08420..fbb6099c67 100644 --- a/src/main/java/api/petrinet/domain/events/EventDto.java +++ b/src/main/java/api/petrinet/domain/events/EventDto.java @@ -5,7 +5,7 @@ import java.util.List; -public class EventDto extends BaseEventDto { +public final class EventDto extends BaseEventDto { private String type; diff --git a/src/main/java/api/petrinet/domain/events/ProcessEventDto.java b/src/main/java/api/petrinet/domain/events/ProcessEventDto.java index b867e4de59..05fc0d65af 100644 --- a/src/main/java/api/petrinet/domain/events/ProcessEventDto.java +++ b/src/main/java/api/petrinet/domain/events/ProcessEventDto.java @@ -5,7 +5,7 @@ import java.util.List; -public class ProcessEventDto extends BaseEventDto { +public final class ProcessEventDto extends BaseEventDto { private String type; diff --git a/src/main/java/api/petrinet/domain/layout/DataGroupLayoutDto.java b/src/main/java/api/petrinet/domain/layout/DataGroupLayoutDto.java index 0aa29718ea..322b64d243 100644 --- a/src/main/java/api/petrinet/domain/layout/DataGroupLayoutDto.java +++ b/src/main/java/api/petrinet/domain/layout/DataGroupLayoutDto.java @@ -1,6 +1,6 @@ package api.petrinet.domain.layout; -public class DataGroupLayoutDto extends FormLayoutDto { +public final class DataGroupLayoutDto extends FormLayoutDto { public DataGroupLayoutDto() { } diff --git a/src/main/java/api/petrinet/domain/layout/FormLayoutDto.java b/src/main/java/api/petrinet/domain/layout/FormLayoutDto.java index fab0d312c1..c27f596607 100644 --- a/src/main/java/api/petrinet/domain/layout/FormLayoutDto.java +++ b/src/main/java/api/petrinet/domain/layout/FormLayoutDto.java @@ -1,6 +1,6 @@ package api.petrinet.domain.layout; -public class FormLayoutDto extends LayoutDto { +public abstract class FormLayoutDto extends LayoutDto { private String type; diff --git a/src/main/java/api/petrinet/domain/layout/LayoutDto.java b/src/main/java/api/petrinet/domain/layout/LayoutDto.java index 0e6e232629..fb5822512e 100644 --- a/src/main/java/api/petrinet/domain/layout/LayoutDto.java +++ b/src/main/java/api/petrinet/domain/layout/LayoutDto.java @@ -1,6 +1,6 @@ package api.petrinet.domain.layout; -public class LayoutDto { +public abstract class LayoutDto { private Integer rows; diff --git a/src/main/java/api/petrinet/domain/layout/TaskLayoutDto.java b/src/main/java/api/petrinet/domain/layout/TaskLayoutDto.java index 8ad2fcaee3..16aaf29548 100644 --- a/src/main/java/api/petrinet/domain/layout/TaskLayoutDto.java +++ b/src/main/java/api/petrinet/domain/layout/TaskLayoutDto.java @@ -1,6 +1,6 @@ package api.petrinet.domain.layout; -public class TaskLayoutDto extends FormLayoutDto { +public final class TaskLayoutDto extends FormLayoutDto { private Integer offset; diff --git a/src/main/java/api/petrinet/version/VersionDto.java b/src/main/java/api/petrinet/version/VersionDto.java index 5e4c99ce7f..e0e94ba5f5 100644 --- a/src/main/java/api/petrinet/version/VersionDto.java +++ b/src/main/java/api/petrinet/version/VersionDto.java @@ -1,6 +1,6 @@ package api.petrinet.version; -public class VersionDto { +public final class VersionDto { private long major; diff --git a/src/main/java/api/workflow/domain/CaseDto.java b/src/main/java/api/workflow/domain/CaseDto.java index b3209bac0b..6a6fd1701c 100644 --- a/src/main/java/api/workflow/domain/CaseDto.java +++ b/src/main/java/api/workflow/domain/CaseDto.java @@ -7,7 +7,7 @@ import java.time.LocalDateTime; import java.util.*; -public class CaseDto { +public final class CaseDto { private String id; diff --git a/src/main/java/api/workflow/domain/DataFieldDto.java b/src/main/java/api/workflow/domain/DataFieldDto.java index ff65aaa5eb..9afeef6625 100644 --- a/src/main/java/api/workflow/domain/DataFieldDto.java +++ b/src/main/java/api/workflow/domain/DataFieldDto.java @@ -7,7 +7,7 @@ import java.util.Map; import java.util.Set; -public class DataFieldDto { +public final class DataFieldDto { private Map> behavior; diff --git a/src/main/java/api/workflow/domain/TaskDto.java b/src/main/java/api/workflow/domain/TaskDto.java index b0637f9f28..63ede42c74 100644 --- a/src/main/java/api/workflow/domain/TaskDto.java +++ b/src/main/java/api/workflow/domain/TaskDto.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; -public class TaskDto { +public final class TaskDto { private String id; diff --git a/src/main/java/api/workflow/domain/TaskPairDto.java b/src/main/java/api/workflow/domain/TaskPairDto.java index 367325dc59..de323900a0 100644 --- a/src/main/java/api/workflow/domain/TaskPairDto.java +++ b/src/main/java/api/workflow/domain/TaskPairDto.java @@ -1,6 +1,6 @@ package api.workflow.domain; -public class TaskPairDto { +public final class TaskPairDto { private String task; diff --git a/src/main/java/api/workflow/domain/triggers/TriggerDto.java b/src/main/java/api/workflow/domain/triggers/TriggerDto.java index 30fda6fd42..7640007088 100644 --- a/src/main/java/api/workflow/domain/triggers/TriggerDto.java +++ b/src/main/java/api/workflow/domain/triggers/TriggerDto.java @@ -2,7 +2,7 @@ import api.petrinet.domain.ImportedDto; -public class TriggerDto extends ImportedDto { +public final class TriggerDto extends ImportedDto { private String id; diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedBooleanFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedBooleanFieldDto.java index f5533af93d..aa00dfba93 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedBooleanFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedBooleanFieldDto.java @@ -7,7 +7,7 @@ import java.util.List; -public class LocalisedBooleanFieldDto extends LocalisedFieldDto { +public final class LocalisedBooleanFieldDto extends LocalisedFieldDto { public LocalisedBooleanFieldDto() { } diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedCaseFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedCaseFieldDto.java index 53cd261872..f3df6c76cd 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedCaseFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedCaseFieldDto.java @@ -7,7 +7,7 @@ import java.util.List; -public class LocalisedCaseFieldDto extends LocalisedFieldDto { +public final class LocalisedCaseFieldDto extends LocalisedFieldDto { private List allowedNets; diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedChoiceFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedChoiceFieldDto.java index 386293d7cc..ff51baabb6 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedChoiceFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedChoiceFieldDto.java @@ -7,7 +7,7 @@ import java.util.List; -public class LocalisedChoiceFieldDto extends LocalisedFieldDto { +public abstract class LocalisedChoiceFieldDto extends LocalisedFieldDto { private List choices; diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedDateFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedDateFieldDto.java index 757395ea25..bc45b8bc70 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedDateFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedDateFieldDto.java @@ -7,7 +7,7 @@ import java.util.List; -public class LocalisedDateFieldDto extends LocalisedFieldDto { +public final class LocalisedDateFieldDto extends LocalisedFieldDto { private String minDate; diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedDateTimeFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedDateTimeFieldDto.java index 9863eef0e2..c1b9014fec 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedDateTimeFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedDateTimeFieldDto.java @@ -7,7 +7,7 @@ import java.util.List; -public class LocalisedDateTimeFieldDto extends LocalisedFieldDto { +public final class LocalisedDateTimeFieldDto extends LocalisedFieldDto { private String minDate; diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationFieldDto.java index ab5df59d3c..c40661c054 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationFieldDto.java @@ -7,7 +7,7 @@ import java.util.List; -public class LocalisedEnumerationFieldDto extends LocalisedChoiceFieldDto { +public final class LocalisedEnumerationFieldDto extends LocalisedChoiceFieldDto { public LocalisedEnumerationFieldDto() { } diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationMapFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationMapFieldDto.java index 941e7a97f5..b6d36ddc79 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationMapFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationMapFieldDto.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Map; -public class LocalisedEnumerationMapFieldDto extends LocalisedMapOptionsFieldDto { +public final class LocalisedEnumerationMapFieldDto extends LocalisedMapOptionsFieldDto { public LocalisedEnumerationMapFieldDto() { } diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedFieldDto.java index 8234e70df2..edfb729672 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedFieldDto.java @@ -7,7 +7,7 @@ import java.util.List; -public class LocalisedFieldDto { +public abstract class LocalisedFieldDto { private String stringId; diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedFileListFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedFileListFieldDto.java index 318ce20246..eea987d2be 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedFileListFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedFileListFieldDto.java @@ -7,7 +7,7 @@ import java.util.List; -public class LocalisedFileListFieldDto extends LocalisedFieldDto { +public final class LocalisedFileListFieldDto extends LocalisedFieldDto { public LocalisedFileListFieldDto() { } diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedFilterFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedFilterFieldDto.java index 045de7e422..46d4d8edb8 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedFilterFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedFilterFieldDto.java @@ -7,7 +7,7 @@ import java.util.List; -public class LocalisedFilterFieldDto extends LocalisedFieldDto { +public final class LocalisedFilterFieldDto extends LocalisedFieldDto { private List allowedNets; diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedI18nFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedI18nFieldDto.java index 93a208f8a5..4bd4557984 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedI18nFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedI18nFieldDto.java @@ -7,7 +7,7 @@ import java.util.List; -public class LocalisedI18nFieldDto extends LocalisedFieldDto { +public final class LocalisedI18nFieldDto extends LocalisedFieldDto { public LocalisedI18nFieldDto() { } diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedMapOptionsFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedMapOptionsFieldDto.java index 00a8308ea7..ad4f69731a 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedMapOptionsFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedMapOptionsFieldDto.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Map; -public class LocalisedMapOptionsFieldDto extends LocalisedFieldDto { +public abstract class LocalisedMapOptionsFieldDto extends LocalisedFieldDto { private Map options; diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceFieldDto.java index 86d1af55d7..56f1ae7743 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceFieldDto.java @@ -7,7 +7,7 @@ import java.util.List; -public class LocalisedMultichoiceFieldDto extends LocalisedChoiceFieldDto { +public final class LocalisedMultichoiceFieldDto extends LocalisedChoiceFieldDto { public LocalisedMultichoiceFieldDto() { } diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceMapFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceMapFieldDto.java index c7da9a1108..cc1af33fc8 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceMapFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceMapFieldDto.java @@ -9,7 +9,7 @@ import java.util.Map; import java.util.Set; -public class LocalisedMultichoiceMapFieldDto extends LocalisedMapOptionsFieldDto> { +public final class LocalisedMultichoiceMapFieldDto extends LocalisedMapOptionsFieldDto> { public LocalisedMultichoiceMapFieldDto() { } diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedNumberFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedNumberFieldDto.java index 7fa86b23ee..117480aa22 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedNumberFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedNumberFieldDto.java @@ -7,7 +7,7 @@ import java.util.List; -public class LocalisedNumberFieldDto extends LocalisedFieldDto { +public final class LocalisedNumberFieldDto extends LocalisedFieldDto { public LocalisedNumberFieldDto() { } diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedTextFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedTextFieldDto.java index 499f2cc8a7..ae7ac19b92 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedTextFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedTextFieldDto.java @@ -7,7 +7,7 @@ import java.util.List; -public class LocalisedTextFieldDto extends LocalisedFieldDto { +public final class LocalisedTextFieldDto extends LocalisedFieldDto { public LocalisedTextFieldDto() { } diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedUserFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedUserFieldDto.java index 25032ded96..631238a1ca 100644 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedUserFieldDto.java +++ b/src/main/java/api/workflow/web/responsebodies/LocalisedUserFieldDto.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Set; -public class LocalisedUserFieldDto extends LocalisedFieldDto { +public final class LocalisedUserFieldDto extends LocalisedFieldDto { private Set roles; From 42ecb3a1bdb0b17a50bbfb1a1aed286f7d626fa2 Mon Sep 17 00:00:00 2001 From: Martin Smetanka Date: Tue, 20 Aug 2024 10:44:07 +0200 Subject: [PATCH 08/13] [NAE-1567] Global event system - Implemented Dispatcher and Listenr class - Added publishing of events via ApplicationEventPublisher in Engine Services --- .../elastic/service/ElasticCaseService.java | 6 + .../elastic/service/ElasticTaskService.java | 15 ++- .../event/dispatchers/AbstractDispatcher.java | 124 ++++++++++++++---- .../event/dispatchers/CaseDispatcher.java | 61 +++++++++ .../event/dispatchers/DataDispatcher.java | 44 +++++++ .../event/dispatchers/ProcessDispatcher.java | 43 ++++++ .../event/dispatchers/TaskDispatcher.java | 108 +++++++++++++++ .../event/dispatchers/UserDispatcher.java | 75 +++++++++++ .../engine/event/events/Event.java | 3 +- .../engine/event/events/EventAction.java | 21 +++ .../event/events/data/GetDataEvent.java | 21 +++ .../event/events/data/SetDataEvent.java | 21 +++ .../events/petrinet/ProcessDeleteEvent.java | 21 +++ .../events/petrinet/ProcessDeployEvent.java | 19 +++ .../event/events/task/AssignTaskEvent.java | 15 +++ .../event/events/task/CancelTaskEvent.java | 15 +++ .../event/events/task/CreateTaskEvent.java | 15 +++ .../event/events/task/DelegateTaskEvent.java | 15 +++ .../event/events/task/FinishTaskEvent.java | 15 +++ .../event/events/task/IndexTaskEvent.java | 20 +++ .../engine/event/events/task/TaskEvent.java | 17 +++ .../event/events/workflow/CaseEvent.java | 15 +++ .../events/workflow/CreateCaseEvent.java | 15 +++ .../events/workflow/DeleteCaseEvent.java | 15 +++ .../event/events/workflow/IndexCaseEvent.java | 21 +++ .../engine/event/listeners/Listener.java | 28 ++++ .../event/listeners/SimpleListener.java | 48 +++++++ .../petrinet/service/PetriNetService.java | 10 +- .../taskoutcomes/CreateTaskEventOutcome.java | 12 ++ .../engine/workflow/service/DataService.java | 4 + .../engine/workflow/service/TaskService.java | 30 ++--- .../workflow/service/WorkflowService.java | 4 + 32 files changed, 849 insertions(+), 47 deletions(-) create mode 100644 src/main/java/com/netgrif/application/engine/event/dispatchers/CaseDispatcher.java create mode 100644 src/main/java/com/netgrif/application/engine/event/dispatchers/DataDispatcher.java create mode 100644 src/main/java/com/netgrif/application/engine/event/dispatchers/ProcessDispatcher.java create mode 100644 src/main/java/com/netgrif/application/engine/event/dispatchers/TaskDispatcher.java create mode 100644 src/main/java/com/netgrif/application/engine/event/dispatchers/UserDispatcher.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/EventAction.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/data/GetDataEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/data/SetDataEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeleteEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeployEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/task/AssignTaskEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/task/CancelTaskEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/task/CreateTaskEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/task/DelegateTaskEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/task/FinishTaskEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/task/IndexTaskEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/task/TaskEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/workflow/CaseEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/workflow/CreateCaseEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/workflow/DeleteCaseEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/events/workflow/IndexCaseEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/listeners/Listener.java create mode 100644 src/main/java/com/netgrif/application/engine/event/listeners/SimpleListener.java create mode 100644 src/main/java/com/netgrif/application/engine/workflow/domain/eventoutcomes/taskoutcomes/CreateTaskEventOutcome.java diff --git a/src/main/java/com/netgrif/application/engine/elastic/service/ElasticCaseService.java b/src/main/java/com/netgrif/application/engine/elastic/service/ElasticCaseService.java index 2fa0bb5697..7360841ea0 100644 --- a/src/main/java/com/netgrif/application/engine/elastic/service/ElasticCaseService.java +++ b/src/main/java/com/netgrif/application/engine/elastic/service/ElasticCaseService.java @@ -11,6 +11,7 @@ import com.netgrif.application.engine.elastic.service.interfaces.IElasticCasePrioritySearch; import com.netgrif.application.engine.elastic.service.interfaces.IElasticCaseService; import com.netgrif.application.engine.elastic.web.requestbodies.CaseSearchRequest; +import com.netgrif.application.engine.event.events.workflow.IndexCaseEvent; import com.netgrif.application.engine.petrinet.domain.PetriNetSearch; import com.netgrif.application.engine.petrinet.service.interfaces.IPetriNetService; import com.netgrif.application.engine.petrinet.web.responsebodies.PetriNetReference; @@ -22,6 +23,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.annotation.Lazy; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.domain.*; @@ -71,6 +73,9 @@ public void setPetriNetService(IPetriNetService petriNetService) { this.petriNetService = petriNetService; } + @Autowired + protected ApplicationEventPublisher publisher; + @Autowired public void setElasticCasePrioritySearch(IElasticCasePrioritySearch iElasticCasePrioritySearch) { this.iElasticCasePrioritySearch = iElasticCasePrioritySearch; @@ -104,6 +109,7 @@ public void index(ElasticCase useCase) { repository.save(elasticCase); } log.debug("[" + useCase.getStringId() + "]: Case \"" + useCase.getTitle() + "\" indexed"); + publisher.publishEvent(new IndexCaseEvent(useCase)); } catch (InvalidDataAccessApiUsageException ignored) { log.debug("[" + useCase.getStringId() + "]: Case \"" + useCase.getTitle() + "\" has duplicates, will be reindexed"); repository.deleteAllByStringId(useCase.getStringId()); diff --git a/src/main/java/com/netgrif/application/engine/elastic/service/ElasticTaskService.java b/src/main/java/com/netgrif/application/engine/elastic/service/ElasticTaskService.java index a273fe6ea5..b201c3904c 100644 --- a/src/main/java/com/netgrif/application/engine/elastic/service/ElasticTaskService.java +++ b/src/main/java/com/netgrif/application/engine/elastic/service/ElasticTaskService.java @@ -11,6 +11,7 @@ import com.netgrif.application.engine.elastic.domain.ElasticTaskJob; import com.netgrif.application.engine.elastic.service.interfaces.IElasticTaskService; import com.netgrif.application.engine.elastic.web.requestbodies.ElasticTaskSearchRequest; +import com.netgrif.application.engine.event.events.task.IndexTaskEvent; import com.netgrif.application.engine.petrinet.domain.PetriNetSearch; import com.netgrif.application.engine.petrinet.service.interfaces.IPetriNetService; import com.netgrif.application.engine.petrinet.web.responsebodies.PetriNetReference; @@ -24,6 +25,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.annotation.Lazy; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -38,6 +40,8 @@ import org.springframework.stereotype.Service; import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.function.BinaryOperator; import java.util.stream.Collectors; @@ -61,6 +65,9 @@ public class ElasticTaskService extends ElasticViewPermissionService implements @Autowired protected IPetriNetService petriNetService; + @Autowired + protected ApplicationEventPublisher publisher; + protected List fullTextFieldMap = ImmutableList.of( "title^1f", "caseTitle^1f" @@ -114,7 +121,13 @@ public Future scheduleTaskIndexing(ElasticTask task) { @Async @Override public void index(ElasticTask task) { - elasticTaskQueueManager.scheduleOperation(new ElasticTaskJob(ElasticJob.INDEX, task)); + Future taskFuture = elasticTaskQueueManager.scheduleOperation(new ElasticTaskJob(ElasticJob.INDEX, task)); + if (taskFuture instanceof CompletableFuture) { + ((CompletableFuture) taskFuture).thenApply(elasticTask -> { + publisher.publishEvent(new IndexTaskEvent(elasticTask)); + return null; + }); + } } @Override diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/AbstractDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/AbstractDispatcher.java index c941e2b912..2fafdba061 100644 --- a/src/main/java/com/netgrif/application/engine/event/dispatchers/AbstractDispatcher.java +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/AbstractDispatcher.java @@ -1,43 +1,119 @@ package com.netgrif.application.engine.event.dispatchers; -import com.netgrif.application.engine.event.services.interfaces.IEventSystemService; -import events.IDispatcher; -import events.IEvent; -import events.ISubscriber; -import lombok.Data; +import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.event.events.EventAction; +import com.netgrif.application.engine.event.listeners.Listener; +import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; -@Data -public abstract class AbstractDispatcher implements IDispatcher { +@Slf4j +public abstract class AbstractDispatcher { - protected final List subscribers; + //TODO: 1. Volanie metod dispatch a dispatch ma byt asynchronne v oboch pripadoch + // 2. Rozdiel je iba v tom ze dispatch caka na skonecnie vykonavania instrukcii v Listeneroch a + // dispatchAsync nie - protected AbstractDispatcher(IEventSystemService eventSystemService) { - this.subscribers = new ArrayList<>(); - eventSystemService.registerDispatcher(this); + private final Set registeredListeners; + + private final Set allowedActions; + + protected AbstractDispatcher(Set allowedActions) { + this.allowedActions = allowedActions; + this.registeredListeners = new HashSet<>(); + } + + public void registerListener(Listener listener, EventAction eventAction, DispatchMethod dispatchMethod) { + RegisteredListener registeredListener = new RegisteredListener(listener, eventAction, dispatchMethod); + if (!isRegistrationAllowed(registeredListener)) { + throw new IllegalArgumentException( + "Cannot register Listener " + listener.getName() + + " for Dispatcher " + this.getName() + + ": Event " + eventAction + + " is not supported in Dispatcher: " + this.getName() + + "\n Allowed Events: " + this.allowedActions + ); + } else if (isListenerRegistered(registeredListener)) { + throw new IllegalArgumentException( + "Cannot register Listener " + listener.getName() + + " for Dispatcher " + this.getName() + + " Listener " + listener.getName() + + " is already registered in this Dispatcher"); + } else { + registeredListeners.add(registeredListener); + } + + } + + public void unregisterListener(Listener listener, EventAction eventAction, DispatchMethod dispatchMethod) { + RegisteredListener registeredListener = new RegisteredListener(listener, eventAction, dispatchMethod); + if (!isListenerRegistered(registeredListener)) { + throw new IllegalArgumentException( + "Cannot unregister Listener " + listener.getName() + + " for Dispatcher " + this.getName() + + " Listener " + listener.getName() + + " is not registered in this Dispatcher"); + } + registeredListeners.remove(registeredListener); + } + + public boolean isListenerRegistered(Listener listener, EventAction eventAction, DispatchMethod dispatchMethod) { + return isListenerRegistered(new RegisteredListener(listener, eventAction, dispatchMethod)); + } + + private boolean isListenerRegistered(RegisteredListener registeredListener) { + return registeredListeners.stream().anyMatch(l -> l.equals(registeredListener)); + } + + protected void dispatch(Event event, AbstractDispatcher dispatcher, Function foo) { +// ExecutorService executorService = Executors.newFixedThreadPool(10); + List> futures = new ArrayList<>(); + + for (RegisteredListener registeredListener : registeredListeners) { + CompletableFuture future = CompletableFuture.runAsync(() -> { + if (foo.apply(registeredListener)) { + log.info("Sending event {} synchronously", event.getMessage()); + registeredListener.listener().onEvent(event, dispatcher); + } + }); + //custom executor ? + futures.add(future); + } + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); +// executorService.shutdown(); } - @Override - public abstract String getId(); + protected void dispatchAsync(Event event, AbstractDispatcher dispatcher, Function foo) { + for (RegisteredListener registeredListener : registeredListeners) { + CompletableFuture.runAsync(() -> { + if (foo.apply(registeredListener)) { + log.info("Sending event {} asynchronously", event.getMessage()); + registeredListener.listener().onEvent(event, dispatcher); + } + }); + //custom executor ? + } + } - @Override - public void registerSubscriber(ISubscriber subscriber) { - if (subscriber != null) - subscribers.add(subscriber); + private boolean isRegistrationAllowed(RegisteredListener registeredListener) { + return allowedActions.contains(registeredListener.eventAction); } - @Override - public void listen(IEvent event) { - subscribers.forEach(s -> System.out.println(s.onEvent(event))); + protected record RegisteredListener(Listener listener, EventAction eventAction, DispatchMethod dispatchMethod) { } - @Override - public void listen(Class eventClass, T event) { + protected String getName() { + return this.getClass().getSimpleName(); } - protected List getSubscribers() { - return this.subscribers; + public enum DispatchMethod { + SYNC, + ASYNC } + } diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/CaseDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/CaseDispatcher.java new file mode 100644 index 0000000000..88463bd567 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/CaseDispatcher.java @@ -0,0 +1,61 @@ +package com.netgrif.application.engine.event.dispatchers; + +import com.netgrif.application.engine.event.events.EventAction; +import com.netgrif.application.engine.event.events.workflow.CreateCaseEvent; +import com.netgrif.application.engine.event.events.workflow.DeleteCaseEvent; +import com.netgrif.application.engine.event.events.workflow.IndexCaseEvent; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; + +import java.util.Set; + +@Component +public class CaseDispatcher extends AbstractDispatcher { + + public CaseDispatcher() { + super(Set.of(EventAction.CASE_CREATE, EventAction.CASE_DELETE, EventAction.CASE_INDEXED)); + } + + @EventListener + public void handleCreateCaseEvent(CreateCaseEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.CASE_CREATE + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncCreateCaseEvent(CreateCaseEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.CASE_CREATE + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + + @EventListener + public void handleDeleteCaseEvent(DeleteCaseEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.CASE_DELETE + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncDeleteCaseEvent(DeleteCaseEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.CASE_DELETE + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + + @EventListener + public void handleIndexCaseEvent(IndexCaseEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.CASE_INDEXED + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncIndexCaseEvent(IndexCaseEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.CASE_INDEXED + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + +} diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/DataDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/DataDispatcher.java new file mode 100644 index 0000000000..a16a0063b4 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/DataDispatcher.java @@ -0,0 +1,44 @@ +package com.netgrif.application.engine.event.dispatchers; + +import com.netgrif.application.engine.event.events.EventAction; +import com.netgrif.application.engine.event.events.data.GetDataEvent; +import com.netgrif.application.engine.event.events.data.SetDataEvent; +import org.springframework.context.event.EventListener; + +import java.util.Set; + +public class DataDispatcher extends AbstractDispatcher { + + public DataDispatcher() { + super(Set.of(EventAction.DATA_GET, EventAction.DATA_SET)); + } + + @EventListener + public void handleGetDataEvent(GetDataEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.DATA_GET + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncGetDataEvent(GetDataEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.DATA_GET + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + + @EventListener + public void handleSetDataEvent(SetDataEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.DATA_SET + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncSetDataEvent(SetDataEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.DATA_SET + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + +} diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/ProcessDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/ProcessDispatcher.java new file mode 100644 index 0000000000..7e0affcecf --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/ProcessDispatcher.java @@ -0,0 +1,43 @@ +package com.netgrif.application.engine.event.dispatchers; + +import com.netgrif.application.engine.event.events.EventAction; +import com.netgrif.application.engine.event.events.petrinet.ProcessDeleteEvent; +import com.netgrif.application.engine.event.events.petrinet.ProcessDeployEvent; +import org.springframework.context.event.EventListener; + +import java.util.Set; + +public class ProcessDispatcher extends AbstractDispatcher { + + public ProcessDispatcher() { + super(Set.of(EventAction.PROCESS_DELETE, EventAction.PROCESS_DEPLOY)); + } + + @EventListener + public void handleProcessDeployEvent(ProcessDeployEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.PROCESS_DEPLOY + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncProcessDeployEvent(ProcessDeployEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.PROCESS_DEPLOY + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + + @EventListener + public void handleProcessDeleteEvent(ProcessDeleteEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.PROCESS_DELETE + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncProcessDeleteEvent(ProcessDeleteEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.PROCESS_DELETE + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/TaskDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/TaskDispatcher.java new file mode 100644 index 0000000000..3e60216ed7 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/TaskDispatcher.java @@ -0,0 +1,108 @@ +package com.netgrif.application.engine.event.dispatchers; + +import com.netgrif.application.engine.event.events.EventAction; +import com.netgrif.application.engine.event.events.task.*; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; + +import java.util.Set; + +@Component +public class TaskDispatcher extends AbstractDispatcher { + + public TaskDispatcher() { + super(Set.of(EventAction.TASK_ASSIGN, + EventAction.TASK_DELEGATE, + EventAction.TASK_CREATE, + EventAction.CASE_DELETE, + EventAction.TASK_FINISH, + EventAction.TASK_CANCEL, + EventAction.TASK_INDEXED + )); + } + + @EventListener + public void handleAssignTaskEvent(AssignTaskEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.TASK_ASSIGN + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncAssignTaskEvent(AssignTaskEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.TASK_ASSIGN + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + + @EventListener + public void handleDelegateTaskEvent(DelegateTaskEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.TASK_DELEGATE + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncDelegateTaskEvent(DelegateTaskEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.TASK_DELEGATE + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + + @EventListener + public void handleFinishTaskEvent(FinishTaskEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.TASK_FINISH + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncFinishTaskEvent(FinishTaskEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.TASK_FINISH + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + + @EventListener + public void handleCancelTaskEvent(CancelTaskEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.TASK_CANCEL + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncCancelTaskEvent(CancelTaskEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.TASK_CANCEL + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + + @EventListener + public void handleIndexedTaskEvent(IndexTaskEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.TASK_INDEXED + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncIndexedTaskEvent(IndexTaskEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.TASK_INDEXED + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + + @EventListener + public void handleCreateTaskEvent(CreateTaskEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.TASK_CREATE + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncCreateTaskEvent(CreateTaskEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.TASK_CREATE + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + +} diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/UserDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/UserDispatcher.java new file mode 100644 index 0000000000..b21efdb976 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/UserDispatcher.java @@ -0,0 +1,75 @@ +package com.netgrif.application.engine.event.dispatchers; + +import com.netgrif.application.engine.event.events.EventAction; +import com.netgrif.application.engine.event.events.user.UserLoginEvent; +import com.netgrif.application.engine.event.events.user.UserLogoutEvent; +import com.netgrif.application.engine.event.events.user.UserRegistrationEvent; +import com.netgrif.application.engine.event.events.user.UserRoleChangeEvent; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; + +import java.util.Set; + +@Component +public class UserDispatcher extends AbstractDispatcher { + + public UserDispatcher() { + super(Set.of(EventAction.USER_LOGIN, EventAction.USER_LOGOUT, EventAction.USER_REGISTER, EventAction.USER_ROLE_CHANGE)); + } + + @EventListener + public void handleUserLoginEvent(UserLoginEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.USER_LOGIN + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncUserLoginEvent(UserLoginEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.USER_LOGIN + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + + @EventListener + public void handleUserLogoutEvent(UserLogoutEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.USER_LOGOUT + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncUserLogoutEvent(UserLogoutEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.USER_LOGOUT + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + + @EventListener + public void handleUserRegisterEvent(UserRegistrationEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.USER_REGISTER + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncUserRegisterEvent(UserRegistrationEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.USER_REGISTER + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } + + @EventListener + public void handleUserRoleChangeEvent(UserRoleChangeEvent event) { + dispatch(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.USER_ROLE_CHANGE + && registeredListener.dispatchMethod() == DispatchMethod.SYNC); + } + + @EventListener + public void handleAsyncUseRoleChangeEvent(UserRoleChangeEvent event) { + dispatchAsync(event, this, (RegisteredListener registeredListener) -> + registeredListener.eventAction() == EventAction.USER_ROLE_CHANGE + && registeredListener.dispatchMethod() == DispatchMethod.ASYNC); + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/Event.java b/src/main/java/com/netgrif/application/engine/event/events/Event.java index fa0a3698bf..82a977bd4b 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/Event.java +++ b/src/main/java/com/netgrif/application/engine/event/events/Event.java @@ -1,12 +1,11 @@ package com.netgrif.application.engine.event.events; -import events.IEvent; import lombok.Getter; import org.springframework.context.ApplicationEvent; import java.time.LocalDateTime; -public abstract class Event extends ApplicationEvent implements IEvent { +public abstract class Event extends ApplicationEvent { @Getter protected LocalDateTime time; diff --git a/src/main/java/com/netgrif/application/engine/event/events/EventAction.java b/src/main/java/com/netgrif/application/engine/event/events/EventAction.java new file mode 100644 index 0000000000..3bece1b914 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/EventAction.java @@ -0,0 +1,21 @@ +package com.netgrif.application.engine.event.events; + +public enum EventAction { + TASK_ASSIGN, + TASK_CANCEL, + TASK_CREATE, + TASK_FINISH, + TASK_DELEGATE, + TASK_INDEXED, + USER_LOGIN, + USER_LOGOUT, + USER_REGISTER, + USER_ROLE_CHANGE, + PROCESS_DEPLOY, + PROCESS_DELETE, + CASE_CREATE, + CASE_DELETE, + CASE_INDEXED, + DATA_GET, + DATA_SET +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/data/GetDataEvent.java b/src/main/java/com/netgrif/application/engine/event/events/data/GetDataEvent.java new file mode 100644 index 0000000000..b619cbb035 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/data/GetDataEvent.java @@ -0,0 +1,21 @@ +package com.netgrif.application.engine.event.events.data; + +import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.workflow.domain.eventoutcomes.dataoutcomes.GetDataEventOutcome; +import lombok.Getter; + +@Getter +public class GetDataEvent extends Event { + + protected GetDataEventOutcome eventOutcome; + + public GetDataEvent(GetDataEventOutcome eventOutcome) { + super(eventOutcome); + this.eventOutcome = eventOutcome; + } + + @Override + public String getMessage() { + return "GetDataEvent: GET [" + eventOutcome.getMessage().toString() + "]"; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/data/SetDataEvent.java b/src/main/java/com/netgrif/application/engine/event/events/data/SetDataEvent.java new file mode 100644 index 0000000000..b32918e083 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/data/SetDataEvent.java @@ -0,0 +1,21 @@ +package com.netgrif.application.engine.event.events.data; + +import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.workflow.domain.eventoutcomes.dataoutcomes.SetDataEventOutcome; +import lombok.Getter; + +@Getter +public class SetDataEvent extends Event { + + protected SetDataEventOutcome eventOutcome; + + public SetDataEvent(SetDataEventOutcome eventOutcome) { + super(eventOutcome); + this.eventOutcome = eventOutcome; + } + + @Override + public String getMessage() { + return "SetDataEvent: SET [" + eventOutcome.getMessage().toString() + "]"; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeleteEvent.java b/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeleteEvent.java new file mode 100644 index 0000000000..7c0b2565b8 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeleteEvent.java @@ -0,0 +1,21 @@ +package com.netgrif.application.engine.event.events.petrinet; + +import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.petrinet.domain.PetriNet; +import lombok.Getter; + +@Getter +public class ProcessDeleteEvent extends Event { + + protected PetriNet petriNet; + + public ProcessDeleteEvent(PetriNet petriNet) { + super(petriNet); + this.petriNet = petriNet; + } + + @Override + public String getMessage() { + return "ProcessDeleteEvent: PetriNet [" + petriNet.getIdentifier() + "] deleted"; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeployEvent.java b/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeployEvent.java new file mode 100644 index 0000000000..ae68e5b38e --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeployEvent.java @@ -0,0 +1,19 @@ +package com.netgrif.application.engine.event.events.petrinet; + +import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.workflow.domain.eventoutcomes.petrinetoutcomes.ImportPetriNetEventOutcome; + +public class ProcessDeployEvent extends Event { + + protected final ImportPetriNetEventOutcome eventOutcome; + + public ProcessDeployEvent(ImportPetriNetEventOutcome eventOutcome) { + super(eventOutcome); + this.eventOutcome = eventOutcome; + } + + @Override + public String getMessage() { + return "ProcessDeployEvent: PetriNet [" + eventOutcome.getNet().getIdentifier() + "] imported"; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/AssignTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/AssignTaskEvent.java new file mode 100644 index 0000000000..1a41d6f53e --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/task/AssignTaskEvent.java @@ -0,0 +1,15 @@ +package com.netgrif.application.engine.event.events.task; + +import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.AssignTaskEventOutcome; + +public class AssignTaskEvent extends TaskEvent { + + public AssignTaskEvent(AssignTaskEventOutcome eventOutcome) { + super(eventOutcome); + } + + @Override + public String getMessage() { + return "AssignTaskEvent: Task [" + taskEventOutcome.getTask().getStringId() + "] assigned"; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/CancelTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/CancelTaskEvent.java new file mode 100644 index 0000000000..0b7cb5e9f9 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/task/CancelTaskEvent.java @@ -0,0 +1,15 @@ +package com.netgrif.application.engine.event.events.task; + +import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.CancelTaskEventOutcome; + +public class CancelTaskEvent extends TaskEvent { + + public CancelTaskEvent(CancelTaskEventOutcome eventOutcome) { + super(eventOutcome); + } + + @Override + public String getMessage() { + return "CancelTaskEvent: Task [" + taskEventOutcome.getTask().getStringId() + "] cancelled"; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/CreateTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/CreateTaskEvent.java new file mode 100644 index 0000000000..b327c91995 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/task/CreateTaskEvent.java @@ -0,0 +1,15 @@ +package com.netgrif.application.engine.event.events.task; + +import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.TaskEventOutcome; + +public class CreateTaskEvent extends TaskEvent { + + public CreateTaskEvent(TaskEventOutcome eventOutcome) { + super(eventOutcome); + } + + @Override + public String getMessage() { + return "CreateTaskEvent: Task [" + taskEventOutcome.getTask().getStringId() + "] created"; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/DelegateTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/DelegateTaskEvent.java new file mode 100644 index 0000000000..2f8cb4ea86 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/task/DelegateTaskEvent.java @@ -0,0 +1,15 @@ +package com.netgrif.application.engine.event.events.task; + +import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.DelegateTaskEventOutcome; + +public class DelegateTaskEvent extends TaskEvent { + + public DelegateTaskEvent(DelegateTaskEventOutcome eventOutcome) { + super(eventOutcome); + } + + @Override + public String getMessage() { + return "DelegateTaskEvent: Task [" + taskEventOutcome.getTask().getStringId() + "] delegated"; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/FinishTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/FinishTaskEvent.java new file mode 100644 index 0000000000..21fbd8a7e3 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/task/FinishTaskEvent.java @@ -0,0 +1,15 @@ +package com.netgrif.application.engine.event.events.task; + +import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.FinishTaskEventOutcome; + +public class FinishTaskEvent extends TaskEvent { + + public FinishTaskEvent(FinishTaskEventOutcome eventOutcome) { + super(eventOutcome); + } + + @Override + public String getMessage() { + return "FinishTaskEvent: Task [" + taskEventOutcome.getTask().getStringId() + "] finished"; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/IndexTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/IndexTaskEvent.java new file mode 100644 index 0000000000..ee2a1e6baf --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/task/IndexTaskEvent.java @@ -0,0 +1,20 @@ +package com.netgrif.application.engine.event.events.task; + +import com.netgrif.application.engine.elastic.domain.ElasticTask; +import com.netgrif.application.engine.event.events.Event; +import lombok.Getter; + +@Getter +public class IndexTaskEvent extends Event { + + protected final ElasticTask task; + + public IndexTaskEvent(ElasticTask task) { + super(task); + this.task = task; + } + + public String getMessage() { + return "IndexTaskEvent: Task [" + task.getStringId() + "] indexed"; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/TaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/TaskEvent.java new file mode 100644 index 0000000000..067004dfd1 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/task/TaskEvent.java @@ -0,0 +1,17 @@ +package com.netgrif.application.engine.event.events.task; + +import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.TaskEventOutcome; +import lombok.Getter; + + +@Getter +public abstract class TaskEvent extends Event { + + protected final TaskEventOutcome taskEventOutcome; + + public TaskEvent(TaskEventOutcome eventOutcome) { + super(eventOutcome); + this.taskEventOutcome = eventOutcome; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/workflow/CaseEvent.java b/src/main/java/com/netgrif/application/engine/event/events/workflow/CaseEvent.java new file mode 100644 index 0000000000..c8e164d14c --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/workflow/CaseEvent.java @@ -0,0 +1,15 @@ +package com.netgrif.application.engine.event.events.workflow; + +import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.workflow.domain.eventoutcomes.caseoutcomes.CaseEventOutcome; + +public abstract class CaseEvent extends Event { + + protected final CaseEventOutcome caseEventOutcome; + + public CaseEvent(CaseEventOutcome caseEventOutcome) { + super(caseEventOutcome); + this.caseEventOutcome = caseEventOutcome; + } + +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/workflow/CreateCaseEvent.java b/src/main/java/com/netgrif/application/engine/event/events/workflow/CreateCaseEvent.java new file mode 100644 index 0000000000..bb8ffcef13 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/workflow/CreateCaseEvent.java @@ -0,0 +1,15 @@ +package com.netgrif.application.engine.event.events.workflow; + +import com.netgrif.application.engine.workflow.domain.eventoutcomes.caseoutcomes.CreateCaseEventOutcome; + +public class CreateCaseEvent extends CaseEvent { + + public CreateCaseEvent(CreateCaseEventOutcome caseEventOutcome) { + super(caseEventOutcome); + } + + @Override + public String getMessage() { + return "CreateCaseEvent: Case [" + caseEventOutcome.getCase().getStringId() + "] created"; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/workflow/DeleteCaseEvent.java b/src/main/java/com/netgrif/application/engine/event/events/workflow/DeleteCaseEvent.java new file mode 100644 index 0000000000..1fdca52531 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/workflow/DeleteCaseEvent.java @@ -0,0 +1,15 @@ +package com.netgrif.application.engine.event.events.workflow; + +import com.netgrif.application.engine.workflow.domain.eventoutcomes.caseoutcomes.DeleteCaseEventOutcome; + +public class DeleteCaseEvent extends CaseEvent { + + public DeleteCaseEvent(DeleteCaseEventOutcome caseEventOutcome) { + super(caseEventOutcome); + } + + @Override + public String getMessage() { + return "DeleteCaseEvent: Case [" + caseEventOutcome.getCase().getStringId() + "] deleted"; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/workflow/IndexCaseEvent.java b/src/main/java/com/netgrif/application/engine/event/events/workflow/IndexCaseEvent.java new file mode 100644 index 0000000000..8a02437ea2 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/workflow/IndexCaseEvent.java @@ -0,0 +1,21 @@ +package com.netgrif.application.engine.event.events.workflow; + +import com.netgrif.application.engine.elastic.domain.ElasticCase; +import com.netgrif.application.engine.event.events.Event; +import lombok.Getter; + +@Getter +public class IndexCaseEvent extends Event { + + protected final ElasticCase elasticCase; + + public IndexCaseEvent(ElasticCase elasticCase) { + super(elasticCase); + this.elasticCase = elasticCase; + } + + @Override + public String getMessage() { + return "IndexCaseEvent: Case [" + elasticCase.getStringId() + "] indexed"; + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/listeners/Listener.java b/src/main/java/com/netgrif/application/engine/event/listeners/Listener.java new file mode 100644 index 0000000000..a6a9efc2da --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/listeners/Listener.java @@ -0,0 +1,28 @@ +package com.netgrif.application.engine.event.listeners; + + +import com.netgrif.application.engine.event.dispatchers.AbstractDispatcher; +import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.event.events.EventAction; + + + +public abstract class Listener { + + public Listener() { + } + + public Listener(AbstractDispatcher dispatcher, EventAction eventAction, AbstractDispatcher.DispatchMethod method) { + dispatcher.registerListener(this, eventAction, method); + } + + public abstract void onEvent(Event event, AbstractDispatcher dispatcher); + + public abstract void onAsyncEvent(Event event, AbstractDispatcher dispatcher); + + public String getName(){ + return this.getClass().getSimpleName(); + } + + +} diff --git a/src/main/java/com/netgrif/application/engine/event/listeners/SimpleListener.java b/src/main/java/com/netgrif/application/engine/event/listeners/SimpleListener.java new file mode 100644 index 0000000000..7eb11f3804 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/listeners/SimpleListener.java @@ -0,0 +1,48 @@ +package com.netgrif.application.engine.event.listeners; + +import com.netgrif.application.engine.event.dispatchers.AbstractDispatcher; +import com.netgrif.application.engine.event.dispatchers.CaseDispatcher; +import com.netgrif.application.engine.event.dispatchers.UserDispatcher; +import com.netgrif.application.engine.event.events.EventAction; +import com.netgrif.application.engine.event.dispatchers.TaskDispatcher; +import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.event.events.task.AssignTaskEvent; +import com.netgrif.application.engine.event.events.workflow.IndexCaseEvent; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + +@Slf4j +@Component +public class SimpleListener extends Listener { + + public SimpleListener(TaskDispatcher taskDispatcher, UserDispatcher userDispatcher, CaseDispatcher caseDispatcher) { + super(taskDispatcher, EventAction.TASK_ASSIGN, AbstractDispatcher.DispatchMethod.SYNC); + taskDispatcher.registerListener(this, EventAction.TASK_ASSIGN, AbstractDispatcher.DispatchMethod.ASYNC); +// taskDispatcher.registerListener(this, EventAction.TASK_ASSIGN, AbstractDispatcher.DispatchMethod.SYNC); +// userDispatcher.registerListener(this, EventAction.TASK_ASSIGN, AbstractDispatcher.DispatchMethod.SYNC); + userDispatcher.registerListener(this, EventAction.USER_LOGOUT, AbstractDispatcher.DispatchMethod.SYNC); + caseDispatcher.registerListener(this, EventAction.CASE_INDEXED, AbstractDispatcher.DispatchMethod.ASYNC); + } + + @Override + public void onEvent(Event event, AbstractDispatcher dispatcher) { + log.info(event.getMessage()); + dispatcher.unregisterListener(this, EventAction.TASK_ASSIGN, AbstractDispatcher.DispatchMethod.SYNC); + } + + @Override + public void onAsyncEvent(Event event, AbstractDispatcher dispatcher) { + if (event instanceof AssignTaskEvent) { + log.info("task"); + } else if (event instanceof IndexCaseEvent) { + log.info("case"); + } + log.info(event.getMessage()); + } + + @Override + public String getName(){ + return "jozo"; + } +} diff --git a/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java b/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java index a4cb56b2fc..1ccf7e1cab 100644 --- a/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java +++ b/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java @@ -7,6 +7,8 @@ import com.netgrif.application.engine.configuration.properties.CacheProperties; import com.netgrif.application.engine.elastic.service.interfaces.IElasticPetriNetMappingService; import com.netgrif.application.engine.elastic.service.interfaces.IElasticPetriNetService; +import com.netgrif.application.engine.event.events.petrinet.ProcessDeleteEvent; +import com.netgrif.application.engine.event.events.petrinet.ProcessDeployEvent; import com.netgrif.application.engine.history.domain.petrinetevents.DeletePetriNetEventLog; import com.netgrif.application.engine.history.domain.petrinetevents.ImportPetriNetEventLog; import com.netgrif.application.engine.history.domain.taskevents.TaskEventLog; @@ -47,6 +49,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.Cacheable; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.core.io.FileSystemResource; import org.springframework.data.domain.*; import org.springframework.data.mongodb.core.MongoTemplate; @@ -130,11 +133,14 @@ public class PetriNetService implements IPetriNetService { @Autowired protected IUriService uriService; + protected ApplicationEventPublisher publisher; + protected IElasticPetriNetService elasticPetriNetService; @Autowired - public void setElasticPetriNetService(IElasticPetriNetService elasticPetriNetService) { + public void setElasticPetriNetService(IElasticPetriNetService elasticPetriNetService, ApplicationEventPublisher publisher) { this.elasticPetriNetService = elasticPetriNetService; + this.publisher = publisher; } protected Importer getImporter() { @@ -245,6 +251,7 @@ public ImportPetriNetEventOutcome importPetriNet(InputStream xmlFile, VersionTyp historyService.save(new ImportPetriNetEventLog(null, EventPhase.POST, net.getObjectId())); addMessageToOutcome(net, ProcessEventType.UPLOAD, outcome); outcome.setNet(imported.get()); + publisher.publishEvent(new ProcessDeployEvent(outcome)); return outcome; } @@ -556,6 +563,7 @@ public void deletePetriNet(String processId, LoggedUser loggedUser) { // net functions must be removed from cache after it was deleted from repository this.functionCacheService.reloadCachedFunctions(petriNet); historyService.save(new DeletePetriNetEventLog(null, EventPhase.PRE, petriNet.getObjectId())); + publisher.publishEvent(new ProcessDeleteEvent(petriNet)); } private Criteria getProcessRolesCriteria(LoggedUser user) { diff --git a/src/main/java/com/netgrif/application/engine/workflow/domain/eventoutcomes/taskoutcomes/CreateTaskEventOutcome.java b/src/main/java/com/netgrif/application/engine/workflow/domain/eventoutcomes/taskoutcomes/CreateTaskEventOutcome.java new file mode 100644 index 0000000000..be20abd263 --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/workflow/domain/eventoutcomes/taskoutcomes/CreateTaskEventOutcome.java @@ -0,0 +1,12 @@ +package com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes; + +import com.netgrif.application.engine.workflow.domain.Case; +import com.netgrif.application.engine.workflow.domain.Task; + +public class CreateTaskEventOutcome extends TaskEventOutcome { + + public CreateTaskEventOutcome(Case useCase, Task task) { + super(useCase, task); + } + +} diff --git a/src/main/java/com/netgrif/application/engine/workflow/service/DataService.java b/src/main/java/com/netgrif/application/engine/workflow/service/DataService.java index 504a39cda2..f1b317c175 100644 --- a/src/main/java/com/netgrif/application/engine/workflow/service/DataService.java +++ b/src/main/java/com/netgrif/application/engine/workflow/service/DataService.java @@ -9,6 +9,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.netgrif.application.engine.auth.domain.IUser; import com.netgrif.application.engine.auth.service.interfaces.IUserService; +import com.netgrif.application.engine.event.events.data.GetDataEvent; +import com.netgrif.application.engine.event.events.data.SetDataEvent; import com.netgrif.application.engine.history.domain.dataevents.GetDataEventLog; import com.netgrif.application.engine.history.domain.dataevents.SetDataEventLog; import com.netgrif.application.engine.history.service.IHistoryService; @@ -185,6 +187,7 @@ public GetDataEventOutcome getData(Task task, Case useCase, Map LongStream.range(0L, dataSetFields.size()) .forEach(index -> dataSetFields.get((int) index).setOrder(index)); outcome.setData(dataSetFields); + publisher.publishEvent(new GetDataEvent(outcome)); return outcome; } @@ -295,6 +298,7 @@ public SetDataEventOutcome setData(Task task, ObjectNode values, Map taskOptional = taskRepository.findByIdObjectId(objectId); + Optional taskOptional = taskRepository.findById(taskId); if (taskOptional.isEmpty()) { throw new IllegalArgumentException("Could not find task with id [" + taskId + "]"); } @@ -434,6 +435,7 @@ public DelegateTaskEventOutcome delegateTask(LoggedUser loggedUser, String deleg DelegateTaskEventOutcome outcome = new DelegateTaskEventOutcome(useCase, task, outcomes); addMessageToOutcome(transition, EventType.DELEGATE, outcome); + publisher.publishEvent(new DelegateTaskEvent(outcome)); historyService.save(new DelegateTaskEventLog(task, useCase, EventPhase.POST, delegateUser, delegatedUser.getStringId())); log.info("Task [" + task.getTitle() + "] in case [" + useCase.getTitle() + "] assigned to [" + delegateUser.getSelfOrImpersonated().getEmail() + "] was delegated to [" + delegatedUser.getEmail() + "]"); @@ -495,8 +497,7 @@ public void reloadTasks(Case useCase) { } else { if (taskId != null) { // task exists - delete task if not assigned - ObjectId objectId = extractObjectId(taskId); - Optional optionalTask = taskRepository.findByIdObjectId(objectId); + Optional optionalTask = taskRepository.findById(taskId); if (optionalTask.isEmpty()) { continue; } @@ -787,9 +788,8 @@ public List save(List tasks) { @Override public void resolveUserRef(Case useCase) { useCase.getTasks().forEach(taskPair -> { - ObjectId objectId = extractObjectId(taskPair.getTask()); - Optional optionalTask = taskRepository.findByIdObjectId(objectId); - optionalTask.ifPresent(task -> resolveUserRef(task, useCase)); + Optional taskOptional = taskRepository.findById(taskPair.getTask()); + taskOptional.ifPresent(task -> resolveUserRef(task, useCase)); }); } @@ -869,6 +869,8 @@ private Task createFromTransition(Transition transition, Case useCase) { } useCase.addTask(task); + CreateTaskEventOutcome outcome = new CreateTaskEventOutcome(useCase, task); + publisher.publishEvent(new CreateTaskEvent(outcome)); return task; } @@ -949,14 +951,4 @@ protected IUser getUserFromLoggedUser(LoggedUser loggedUser) { user.setImpersonated(fromLogged.getImpersonated()); return user; } - - private ObjectId extractObjectId(String taskId) { - String[] parts = taskId.split("-"); - if (parts.length < 2) { - throw new IllegalArgumentException("Invalid NetgrifId format: " + taskId); - } - String objectIdPart = parts[1]; - - return new ObjectId(objectIdPart); - } } diff --git a/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java b/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java index df62de2590..d039dfd3ce 100644 --- a/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java +++ b/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java @@ -6,6 +6,8 @@ import com.netgrif.application.engine.elastic.service.interfaces.IElasticCaseMappingService; import com.netgrif.application.engine.elastic.service.interfaces.IElasticCaseService; import com.netgrif.application.engine.elastic.web.requestbodies.CaseSearchRequest; +import com.netgrif.application.engine.event.events.workflow.CreateCaseEvent; +import com.netgrif.application.engine.event.events.workflow.DeleteCaseEvent; import com.netgrif.application.engine.history.domain.caseevents.CreateCaseEventLog; import com.netgrif.application.engine.history.domain.caseevents.DeleteCaseEventLog; import com.netgrif.application.engine.history.service.IHistoryService; @@ -366,6 +368,7 @@ public CreateCaseEventOutcome createCase(String netId, Function ma historyService.save(new CreateCaseEventLog(useCase, EventPhase.POST)); outcome.setCase(setImmediateDataFields(useCase)); addMessageToOutcome(petriNet, CaseEventType.CREATE, outcome); + publisher.publishEvent(new CreateCaseEvent(outcome)); return outcome; } @@ -414,6 +417,7 @@ public DeleteCaseEventOutcome deleteCase(Case useCase, Map param outcome.addOutcomes(eventService.runActions(useCase.getPetriNet().getPostDeleteActions(), null, Optional.empty(), params)); addMessageToOutcome(useCase.getPetriNet(), CaseEventType.DELETE, outcome); historyService.save(new DeleteCaseEventLog(useCase, EventPhase.POST)); + publisher.publishEvent(new DeleteCaseEvent(outcome)); return outcome; } From e7a68112cd328e46ff676cd664fc7ffad4f80db7 Mon Sep 17 00:00:00 2001 From: Martin Smetanka Date: Wed, 21 Aug 2024 13:18:47 +0200 Subject: [PATCH 09/13] [NAE-1567] Global event system - Code refactor - Added Javadocs --- .../plugins/services/PluginInjector.groovy | 148 ++++----- .../event/dispatchers/CaseDispatcher.java | 3 + .../event/dispatchers/DataDispatcher.java | 5 + .../event/dispatchers/ProcessDispatcher.java | 5 + .../event/dispatchers/TaskDispatcher.java | 4 +- .../event/dispatchers/UserDispatcher.java | 3 + .../dispatchers/UserEventDispatcher.java | 46 +-- .../{ => common}/AbstractDispatcher.java | 78 +++-- .../dispatchers/common/DispatchMethod.java | 6 + .../common/RegisteredListener.java | 7 + .../engine/event/listeners/Listener.java | 19 +- .../event/listeners/SimpleListener.java | 48 --- .../event/services/EventSystemService.java | 54 ++-- .../interfaces/IEventSystemService.java | 10 +- .../PluginIntegrationConfiguration.java | 206 ++++++------- .../security/PluginSecurityConfiguration.java | 30 +- .../security/PluginSecurityPolicy.java | 52 ++-- .../plugins/services/DtoConverterService.java | 128 ++++---- .../plugins/services/PluginService.java | 288 +++++++++--------- .../interfaces/IDtoConverterService.java | 28 +- .../services/interfaces/IPluginService.java | 26 +- 21 files changed, 610 insertions(+), 584 deletions(-) rename src/main/java/com/netgrif/application/engine/event/dispatchers/{ => common}/AbstractDispatcher.java (54%) create mode 100644 src/main/java/com/netgrif/application/engine/event/dispatchers/common/DispatchMethod.java create mode 100644 src/main/java/com/netgrif/application/engine/event/dispatchers/common/RegisteredListener.java delete mode 100644 src/main/java/com/netgrif/application/engine/event/listeners/SimpleListener.java diff --git a/src/main/groovy/com/netgrif/application/engine/integration/plugins/services/PluginInjector.groovy b/src/main/groovy/com/netgrif/application/engine/integration/plugins/services/PluginInjector.groovy index e9832eb4cd..9cd9318753 100644 --- a/src/main/groovy/com/netgrif/application/engine/integration/plugins/services/PluginInjector.groovy +++ b/src/main/groovy/com/netgrif/application/engine/integration/plugins/services/PluginInjector.groovy @@ -5,77 +5,77 @@ import com.netgrif.application.engine.integration.plugins.exceptions.Incompatibl import com.netgrif.application.engine.integration.plugins.exceptions.IncompatiblePluginException import com.netgrif.application.engine.integration.plugins.exceptions.RestrictedPackageException import com.netgrif.application.engine.petrinet.domain.dataset.logic.action.ActionDelegate -import extensions.NaeExtensionPoint -import groovy.util.logging.Slf4j -import org.pf4j.ExtensionPoint -import org.pf4j.PluginClassLoader -import org.pf4j.PluginWrapper -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.beans.factory.annotation.Value -import org.springframework.stereotype.Component -import wrapper.NaePlugin -import wrapper.PluginExtensionHolder - -import java.util.stream.Collectors - -@Slf4j -@Component -class PluginInjector { - - @Autowired - private PluginProperties pluginProperties - - @Value('${project.version}') - private String projectVersion - - protected void injectExtension(PluginWrapper pluginWrapper) { - pluginWrapper.getPluginManager().getExtensions(NaeExtensionPoint.class).each { extension -> - checkCompatibility(extension) - checkClassLoader(extension as NaeExtensionPoint) - secureCheck(extension as NaeExtensionPoint) - } - - PluginExtensionHolder extensionHolder = ((NaePlugin) pluginWrapper.getPlugin()).getExtensionHolder() - MetaClass actionDelegateMc = ActionDelegate.getMetaClass() - actionDelegateMc[pluginWrapper.pluginId] = extensionHolder - } - - protected void secureCheck(NaeExtensionPoint extension) { - checkPackages(extension.getClass()) - } - - private void checkPackages(Class aClass) { - List filteredRestrictedPackages = filterRestrictedPackages(aClass) - if (!filteredRestrictedPackages.isEmpty()) { - String message = "Plugin " + aClass.getName() + " contains restricted packages: " + - filteredRestrictedPackages.toString() - log.error(message) - throw new RestrictedPackageException(message) - } - aClass.declaredFields.each { field -> - checkPackages(field.class) - } - } - - private List filterRestrictedPackages(Class aClass) { - return aClass.classLoader.definedPackages.toList().stream().filter(p -> { - pluginProperties.restrictedPackages.toList().stream().anyMatch(rp -> { - return p.getName().startsWith(rp) || p.getName().contains(rp) - }) - }).collect(Collectors.toList()) - } - - private void checkCompatibility(NaeExtensionPoint extension) { - if (extension.getPluginVersion() != projectVersion) - log.warn("Netgrif Application Engine end imported library versions are not the same. Some functions may work improperly.") - } - - private void checkClassLoader(NaeExtensionPoint extensionPoint) { - ClassLoader classLoader = extensionPoint.class.classLoader - if (!classLoader instanceof PluginClassLoader) { - String message = "Plugin class loader [" + classLoader.getClass().getName() + "] is not compatible with class loader for plugins." - log.error(message) - throw new IncompatibleClassLoaderException(message) - } - } -} +//import extensions.NaeExtensionPoint +//import groovy.util.logging.Slf4j +//import org.pf4j.ExtensionPoint +//import org.pf4j.PluginClassLoader +//import org.pf4j.PluginWrapper +//import org.springframework.beans.factory.annotation.Autowired +//import org.springframework.beans.factory.annotation.Value +//import org.springframework.stereotype.Component +//import wrapper.NaePlugin +//import wrapper.PluginExtensionHolder +// +//import java.util.stream.Collectors +// +//@Slf4j +//@Component +//class PluginInjector { +// +// @Autowired +// private PluginProperties pluginProperties +// +// @Value('${project.version}') +// private String projectVersion +// +// protected void injectExtension(PluginWrapper pluginWrapper) { +// pluginWrapper.getPluginManager().getExtensions(NaeExtensionPoint.class).each { extension -> +// checkCompatibility(extension) +// checkClassLoader(extension as NaeExtensionPoint) +// secureCheck(extension as NaeExtensionPoint) +// } +// +// PluginExtensionHolder extensionHolder = ((NaePlugin) pluginWrapper.getPlugin()).getExtensionHolder() +// MetaClass actionDelegateMc = ActionDelegate.getMetaClass() +// actionDelegateMc[pluginWrapper.pluginId] = extensionHolder +// } +// +// protected void secureCheck(NaeExtensionPoint extension) { +// checkPackages(extension.getClass()) +// } +// +// private void checkPackages(Class aClass) { +// List filteredRestrictedPackages = filterRestrictedPackages(aClass) +// if (!filteredRestrictedPackages.isEmpty()) { +// String message = "Plugin " + aClass.getName() + " contains restricted packages: " + +// filteredRestrictedPackages.toString() +// log.error(message) +// throw new RestrictedPackageException(message) +// } +// aClass.declaredFields.each { field -> +// checkPackages(field.class) +// } +// } +// +// private List filterRestrictedPackages(Class aClass) { +// return aClass.classLoader.definedPackages.toList().stream().filter(p -> { +// pluginProperties.restrictedPackages.toList().stream().anyMatch(rp -> { +// return p.getName().startsWith(rp) || p.getName().contains(rp) +// }) +// }).collect(Collectors.toList()) +// } +// +// private void checkCompatibility(NaeExtensionPoint extension) { +// if (extension.getPluginVersion() != projectVersion) +// log.warn("Netgrif Application Engine end imported library versions are not the same. Some functions may work improperly.") +// } +// +// private void checkClassLoader(NaeExtensionPoint extensionPoint) { +// ClassLoader classLoader = extensionPoint.class.classLoader +// if (!classLoader instanceof PluginClassLoader) { +// String message = "Plugin class loader [" + classLoader.getClass().getName() + "] is not compatible with class loader for plugins." +// log.error(message) +// throw new IncompatibleClassLoaderException(message) +// } +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/CaseDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/CaseDispatcher.java index 88463bd567..ee024ef6d5 100644 --- a/src/main/java/com/netgrif/application/engine/event/dispatchers/CaseDispatcher.java +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/CaseDispatcher.java @@ -1,5 +1,8 @@ package com.netgrif.application.engine.event.dispatchers; +import com.netgrif.application.engine.event.dispatchers.common.AbstractDispatcher; +import com.netgrif.application.engine.event.dispatchers.common.DispatchMethod; +import com.netgrif.application.engine.event.dispatchers.common.RegisteredListener; import com.netgrif.application.engine.event.events.EventAction; import com.netgrif.application.engine.event.events.workflow.CreateCaseEvent; import com.netgrif.application.engine.event.events.workflow.DeleteCaseEvent; diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/DataDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/DataDispatcher.java index a16a0063b4..ce0f15a042 100644 --- a/src/main/java/com/netgrif/application/engine/event/dispatchers/DataDispatcher.java +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/DataDispatcher.java @@ -1,12 +1,17 @@ package com.netgrif.application.engine.event.dispatchers; +import com.netgrif.application.engine.event.dispatchers.common.AbstractDispatcher; +import com.netgrif.application.engine.event.dispatchers.common.DispatchMethod; +import com.netgrif.application.engine.event.dispatchers.common.RegisteredListener; import com.netgrif.application.engine.event.events.EventAction; import com.netgrif.application.engine.event.events.data.GetDataEvent; import com.netgrif.application.engine.event.events.data.SetDataEvent; import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; import java.util.Set; +@Component public class DataDispatcher extends AbstractDispatcher { public DataDispatcher() { diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/ProcessDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/ProcessDispatcher.java index 7e0affcecf..4b08bf0647 100644 --- a/src/main/java/com/netgrif/application/engine/event/dispatchers/ProcessDispatcher.java +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/ProcessDispatcher.java @@ -1,12 +1,17 @@ package com.netgrif.application.engine.event.dispatchers; +import com.netgrif.application.engine.event.dispatchers.common.AbstractDispatcher; +import com.netgrif.application.engine.event.dispatchers.common.DispatchMethod; +import com.netgrif.application.engine.event.dispatchers.common.RegisteredListener; import com.netgrif.application.engine.event.events.EventAction; import com.netgrif.application.engine.event.events.petrinet.ProcessDeleteEvent; import com.netgrif.application.engine.event.events.petrinet.ProcessDeployEvent; import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; import java.util.Set; +@Component public class ProcessDispatcher extends AbstractDispatcher { public ProcessDispatcher() { diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/TaskDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/TaskDispatcher.java index 3e60216ed7..effd79ddf9 100644 --- a/src/main/java/com/netgrif/application/engine/event/dispatchers/TaskDispatcher.java +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/TaskDispatcher.java @@ -1,5 +1,8 @@ package com.netgrif.application.engine.event.dispatchers; +import com.netgrif.application.engine.event.dispatchers.common.AbstractDispatcher; +import com.netgrif.application.engine.event.dispatchers.common.DispatchMethod; +import com.netgrif.application.engine.event.dispatchers.common.RegisteredListener; import com.netgrif.application.engine.event.events.EventAction; import com.netgrif.application.engine.event.events.task.*; import org.springframework.context.event.EventListener; @@ -14,7 +17,6 @@ public TaskDispatcher() { super(Set.of(EventAction.TASK_ASSIGN, EventAction.TASK_DELEGATE, EventAction.TASK_CREATE, - EventAction.CASE_DELETE, EventAction.TASK_FINISH, EventAction.TASK_CANCEL, EventAction.TASK_INDEXED diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/UserDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/UserDispatcher.java index b21efdb976..145e3ebf3a 100644 --- a/src/main/java/com/netgrif/application/engine/event/dispatchers/UserDispatcher.java +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/UserDispatcher.java @@ -1,5 +1,8 @@ package com.netgrif.application.engine.event.dispatchers; +import com.netgrif.application.engine.event.dispatchers.common.AbstractDispatcher; +import com.netgrif.application.engine.event.dispatchers.common.DispatchMethod; +import com.netgrif.application.engine.event.dispatchers.common.RegisteredListener; import com.netgrif.application.engine.event.events.EventAction; import com.netgrif.application.engine.event.events.user.UserLoginEvent; import com.netgrif.application.engine.event.events.user.UserLogoutEvent; diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/UserEventDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/UserEventDispatcher.java index b83351da2c..abe3f73b7f 100644 --- a/src/main/java/com/netgrif/application/engine/event/dispatchers/UserEventDispatcher.java +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/UserEventDispatcher.java @@ -1,7 +1,7 @@ package com.netgrif.application.engine.event.dispatchers; import com.netgrif.application.engine.event.events.user.UserEvent; -import com.netgrif.application.engine.event.services.interfaces.IEventSystemService; +//import com.netgrif.application.engine.event.services.interfaces.IEventSystemService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Service; @@ -9,25 +9,25 @@ import java.util.Collections; import java.util.List; -@Service -public class UserEventDispatcher extends AbstractDispatcher { - - protected UserEventDispatcher(@Autowired IEventSystemService eventSystemService) { - super(eventSystemService); - } - - @Override - public String getId() { - return "userEventDispatcher"; - } - - @EventListener - public void listen(UserEvent object) { - super.listen(object); - } - - @Override - public void listen(Class eventClass, T event) { - super.listen(eventClass, event); - } -} +//@Service +//public class UserEventDispatcher extends AbstractDispatcher { +// +// protected UserEventDispatcher(@Autowired IEventSystemService eventSystemService) { +// super(eventSystemService); +// } +// +// @Override +// public String getId() { +// return "userEventDispatcher"; +// } +// +// @EventListener +// public void listen(UserEvent object) { +// super.listen(object); +// } +// +// @Override +// public void listen(Class eventClass, T event) { +// super.listen(eventClass, event); +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/AbstractDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/common/AbstractDispatcher.java similarity index 54% rename from src/main/java/com/netgrif/application/engine/event/dispatchers/AbstractDispatcher.java rename to src/main/java/com/netgrif/application/engine/event/dispatchers/common/AbstractDispatcher.java index 2fafdba061..e075e3214b 100644 --- a/src/main/java/com/netgrif/application/engine/event/dispatchers/AbstractDispatcher.java +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/common/AbstractDispatcher.java @@ -1,8 +1,9 @@ -package com.netgrif.application.engine.event.dispatchers; +package com.netgrif.application.engine.event.dispatchers.common; import com.netgrif.application.engine.event.events.Event; import com.netgrif.application.engine.event.events.EventAction; import com.netgrif.application.engine.event.listeners.Listener; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; @@ -15,12 +16,10 @@ @Slf4j public abstract class AbstractDispatcher { - //TODO: 1. Volanie metod dispatch a dispatch ma byt asynchronne v oboch pripadoch - // 2. Rozdiel je iba v tom ze dispatch caka na skonecnie vykonavania instrukcii v Listeneroch a - // dispatchAsync nie + //TODO: Configure custom executor private final Set registeredListeners; - + @Getter private final Set allowedActions; protected AbstractDispatcher(Set allowedActions) { @@ -28,6 +27,14 @@ protected AbstractDispatcher(Set allowedActions) { this.registeredListeners = new HashSet<>(); } + /*** + *

Registration of a new {@link Listener}. The Listener will listen for events based on the value + * of {@link EventAction} and {@link DispatchMethod}. Throws an {@link IllegalArgumentException} + * if the listener is already registered or if the dispatcher has no {@link EventAction} value in the allowed events.

+ * @param listener {@link Listener} that will listen to {@link Event} with the onEvent/onAsyncEvent method + * @param eventAction {@link EventAction} that the listener will subscribe to + * @param dispatchMethod {@link DispatchMethod} The method by which the dispatcher will send the Event + */ public void registerListener(Listener listener, EventAction eventAction, DispatchMethod dispatchMethod) { RegisteredListener registeredListener = new RegisteredListener(listener, eventAction, dispatchMethod); if (!isRegistrationAllowed(registeredListener)) { @@ -50,6 +57,14 @@ public void registerListener(Listener listener, EventAction eventAction, Dispatc } + /*** + *

Unregister already registered {@link Listener}. The Listener + * will be unregister only for event based on the value of {@link EventAction} and {@link DispatchMethod}. + * Throws an {@link IllegalArgumentException} if the listener is not registered.

+ * @param listener {@link Listener} that listen to {@link Event} with the onEvent/onAsyncEvent method + * @param eventAction {@link EventAction} that the listener is subscribed to + * @param dispatchMethod {@link DispatchMethod} The method by which the dispatcher is sending the Event + */ public void unregisterListener(Listener listener, EventAction eventAction, DispatchMethod dispatchMethod) { RegisteredListener registeredListener = new RegisteredListener(listener, eventAction, dispatchMethod); if (!isListenerRegistered(registeredListener)) { @@ -62,58 +77,73 @@ public void unregisterListener(Listener listener, EventAction eventAction, Dispa registeredListeners.remove(registeredListener); } + /*** + *

Check if {@link Listener} is registered to Dispatcher.

+ * @param listener {@link Listener} that listen to {@link Event} with the onEvent/onAsyncEvent method + * @param eventAction {@link EventAction} that the listener is subscribed to + * @param dispatchMethod {@link DispatchMethod} The method by which the dispatcher is sending the Event + * @return true if dispatcher holds record of {@link Listener} to {@link EventAction} with {@link DispatchMethod} else false + */ public boolean isListenerRegistered(Listener listener, EventAction eventAction, DispatchMethod dispatchMethod) { return isListenerRegistered(new RegisteredListener(listener, eventAction, dispatchMethod)); } - private boolean isListenerRegistered(RegisteredListener registeredListener) { + /*** + *

Check if {@link Listener} is registered to Dispatcher.

+ * @param registeredListener {@link RegisteredListener} that holds listening content + * @return true if dispatcher holds record of {@link RegisteredListener} else false + */ + public boolean isListenerRegistered(RegisteredListener registeredListener) { return registeredListeners.stream().anyMatch(l -> l.equals(registeredListener)); } + /*** + *

Send event object to registered {@link Listener}. This function sends events asynchronously, + * but wait until all listeners have finished executing the onEvent method. + * See {@link Listener#onEvent}.

+ * @param event Event that the listener is subscribed to + * @param dispatcher Dispatcher object that sends the events + * @param foo Function to decide to which listener the event should be sent + */ protected void dispatch(Event event, AbstractDispatcher dispatcher, Function foo) { -// ExecutorService executorService = Executors.newFixedThreadPool(10); List> futures = new ArrayList<>(); - for (RegisteredListener registeredListener : registeredListeners) { CompletableFuture future = CompletableFuture.runAsync(() -> { if (foo.apply(registeredListener)) { - log.info("Sending event {} synchronously", event.getMessage()); + log.trace("Sending event with message {} synchronously", event.getMessage()); registeredListener.listener().onEvent(event, dispatcher); } }); - //custom executor ? futures.add(future); } CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); -// executorService.shutdown(); } + /*** + *

Send event object to registered {@link Listener}.This function dispatches events asynchronously + * and does not wait for the execution of the onAsyncEvent method to complete. + * See {@link Listener#onAsyncEvent}.

+ * @param event Event that the listener is subscribed to + * @param dispatcher Dispatcher object that sends the events + * @param foo Function to decide to which listener the event should be sent + */ protected void dispatchAsync(Event event, AbstractDispatcher dispatcher, Function foo) { for (RegisteredListener registeredListener : registeredListeners) { CompletableFuture.runAsync(() -> { if (foo.apply(registeredListener)) { - log.info("Sending event {} asynchronously", event.getMessage()); - registeredListener.listener().onEvent(event, dispatcher); + log.trace("Sending event with message {} asynchronously", event.getMessage()); + registeredListener.listener().onAsyncEvent(event, dispatcher); } }); - //custom executor ? } } - private boolean isRegistrationAllowed(RegisteredListener registeredListener) { - return allowedActions.contains(registeredListener.eventAction); - } - - protected record RegisteredListener(Listener listener, EventAction eventAction, DispatchMethod dispatchMethod) { - } - protected String getName() { return this.getClass().getSimpleName(); } - public enum DispatchMethod { - SYNC, - ASYNC + private boolean isRegistrationAllowed(RegisteredListener registeredListener) { + return allowedActions.contains(registeredListener.eventAction()); } } diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/common/DispatchMethod.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/common/DispatchMethod.java new file mode 100644 index 0000000000..36be5f5bcd --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/common/DispatchMethod.java @@ -0,0 +1,6 @@ +package com.netgrif.application.engine.event.dispatchers.common; + +public enum DispatchMethod { + SYNC, + ASYNC +} diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/common/RegisteredListener.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/common/RegisteredListener.java new file mode 100644 index 0000000000..c61957451b --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/common/RegisteredListener.java @@ -0,0 +1,7 @@ +package com.netgrif.application.engine.event.dispatchers.common; + +import com.netgrif.application.engine.event.events.EventAction; +import com.netgrif.application.engine.event.listeners.Listener; + +public record RegisteredListener(Listener listener, EventAction eventAction, DispatchMethod dispatchMethod) { +} diff --git a/src/main/java/com/netgrif/application/engine/event/listeners/Listener.java b/src/main/java/com/netgrif/application/engine/event/listeners/Listener.java index a6a9efc2da..9b9617105b 100644 --- a/src/main/java/com/netgrif/application/engine/event/listeners/Listener.java +++ b/src/main/java/com/netgrif/application/engine/event/listeners/Listener.java @@ -1,10 +1,12 @@ package com.netgrif.application.engine.event.listeners; -import com.netgrif.application.engine.event.dispatchers.AbstractDispatcher; +import com.netgrif.application.engine.event.dispatchers.common.AbstractDispatcher; +import com.netgrif.application.engine.event.dispatchers.common.DispatchMethod; import com.netgrif.application.engine.event.events.Event; import com.netgrif.application.engine.event.events.EventAction; +import java.util.function.Function; public abstract class Listener { @@ -12,17 +14,28 @@ public abstract class Listener { public Listener() { } - public Listener(AbstractDispatcher dispatcher, EventAction eventAction, AbstractDispatcher.DispatchMethod method) { + public Listener(AbstractDispatcher dispatcher, EventAction eventAction, DispatchMethod method) { dispatcher.registerListener(this, eventAction, method); } + /*** + *

Abstract method for handling synchronous events. This method will be invoked by Dispatcher if the Listener is registered. + * See {@link AbstractDispatcher#registerListener(Listener, EventAction, DispatchMethod)}

+ * @param event {@link Event} object, final type of the object is determined based on {@link EventAction} + * @param dispatcher {@link AbstractDispatcher} from which the event was dispatched + */ public abstract void onEvent(Event event, AbstractDispatcher dispatcher); + /*** + *

Abstract method for handling asynchronous events. This method will be invoked by Dispatcher if the Listener is registered. + * See {@link AbstractDispatcher#registerListener(Listener, EventAction, DispatchMethod)}

+ * @param event {@link Event} object, final type of the object is determined based on {@link EventAction} + * @param dispatcher {@link AbstractDispatcher} from which the event was dispatched + */ public abstract void onAsyncEvent(Event event, AbstractDispatcher dispatcher); public String getName(){ return this.getClass().getSimpleName(); } - } diff --git a/src/main/java/com/netgrif/application/engine/event/listeners/SimpleListener.java b/src/main/java/com/netgrif/application/engine/event/listeners/SimpleListener.java deleted file mode 100644 index 7eb11f3804..0000000000 --- a/src/main/java/com/netgrif/application/engine/event/listeners/SimpleListener.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.netgrif.application.engine.event.listeners; - -import com.netgrif.application.engine.event.dispatchers.AbstractDispatcher; -import com.netgrif.application.engine.event.dispatchers.CaseDispatcher; -import com.netgrif.application.engine.event.dispatchers.UserDispatcher; -import com.netgrif.application.engine.event.events.EventAction; -import com.netgrif.application.engine.event.dispatchers.TaskDispatcher; -import com.netgrif.application.engine.event.events.Event; -import com.netgrif.application.engine.event.events.task.AssignTaskEvent; -import com.netgrif.application.engine.event.events.workflow.IndexCaseEvent; -import lombok.extern.slf4j.Slf4j; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -@Slf4j -@Component -public class SimpleListener extends Listener { - - public SimpleListener(TaskDispatcher taskDispatcher, UserDispatcher userDispatcher, CaseDispatcher caseDispatcher) { - super(taskDispatcher, EventAction.TASK_ASSIGN, AbstractDispatcher.DispatchMethod.SYNC); - taskDispatcher.registerListener(this, EventAction.TASK_ASSIGN, AbstractDispatcher.DispatchMethod.ASYNC); -// taskDispatcher.registerListener(this, EventAction.TASK_ASSIGN, AbstractDispatcher.DispatchMethod.SYNC); -// userDispatcher.registerListener(this, EventAction.TASK_ASSIGN, AbstractDispatcher.DispatchMethod.SYNC); - userDispatcher.registerListener(this, EventAction.USER_LOGOUT, AbstractDispatcher.DispatchMethod.SYNC); - caseDispatcher.registerListener(this, EventAction.CASE_INDEXED, AbstractDispatcher.DispatchMethod.ASYNC); - } - - @Override - public void onEvent(Event event, AbstractDispatcher dispatcher) { - log.info(event.getMessage()); - dispatcher.unregisterListener(this, EventAction.TASK_ASSIGN, AbstractDispatcher.DispatchMethod.SYNC); - } - - @Override - public void onAsyncEvent(Event event, AbstractDispatcher dispatcher) { - if (event instanceof AssignTaskEvent) { - log.info("task"); - } else if (event instanceof IndexCaseEvent) { - log.info("case"); - } - log.info(event.getMessage()); - } - - @Override - public String getName(){ - return "jozo"; - } -} diff --git a/src/main/java/com/netgrif/application/engine/event/services/EventSystemService.java b/src/main/java/com/netgrif/application/engine/event/services/EventSystemService.java index 102c73f1e6..8d211e13f1 100644 --- a/src/main/java/com/netgrif/application/engine/event/services/EventSystemService.java +++ b/src/main/java/com/netgrif/application/engine/event/services/EventSystemService.java @@ -1,33 +1,33 @@ package com.netgrif.application.engine.event.services; -import com.netgrif.application.engine.event.services.interfaces.IEventSystemService; -import com.netgrif.application.engine.integration.plugins.services.interfaces.IPluginService; -import events.IDispatcher; -import org.pf4j.Plugin; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import wrapper.NaePlugin; +//import com.netgrif.application.engine.event.services.interfaces.IEventSystemService; +//import com.netgrif.application.engine.integration.plugins.services.interfaces.IPluginService; +//import events.IDispatcher; +//import org.pf4j.Plugin; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Service; +//import wrapper.NaePlugin; /** * Service for managing and handling Spring Event objects inside NAE * */ -@Service -public class EventSystemService implements IEventSystemService { - - @Autowired - private IPluginService pluginService; - - /** - * Registers dispatcher object in the required plugin, then calls the subscribers to subscribe to this dispatcher. - * @param dispatcher the Dispatcher object that is being registered - * */ - @Override - public void registerDispatcher(IDispatcher dispatcher) { - this.pluginService.getAllPlugin().stream() - .filter(plugin -> plugin.getEventManager().getRequiredDispatchers().contains(dispatcher.getId())) - .forEach(plugin -> { - plugin.getEventManager().addDispatcher(dispatcher); - plugin.getEventManager().registerSubscribers(dispatcher); - }); - } -} +//@Service +//public class EventSystemService implements IEventSystemService { +// +// @Autowired +// private IPluginService pluginService; +// +// /** +// * Registers dispatcher object in the required plugin, then calls the subscribers to subscribe to this dispatcher. +// * @param dispatcher the Dispatcher object that is being registered +// * */ +// @Override +// public void registerDispatcher(IDispatcher dispatcher) { +// this.pluginService.getAllPlugin().stream() +// .filter(plugin -> plugin.getEventManager().getRequiredDispatchers().contains(dispatcher.getId())) +// .forEach(plugin -> { +// plugin.getEventManager().addDispatcher(dispatcher); +// plugin.getEventManager().registerSubscribers(dispatcher); +// }); +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/event/services/interfaces/IEventSystemService.java b/src/main/java/com/netgrif/application/engine/event/services/interfaces/IEventSystemService.java index e9d1be84f2..398679b42e 100644 --- a/src/main/java/com/netgrif/application/engine/event/services/interfaces/IEventSystemService.java +++ b/src/main/java/com/netgrif/application/engine/event/services/interfaces/IEventSystemService.java @@ -1,8 +1,8 @@ package com.netgrif.application.engine.event.services.interfaces; -import events.IDispatcher; - -public interface IEventSystemService { - void registerDispatcher(IDispatcher dispatcher); -} +//import events.IDispatcher; +// +//public interface IEventSystemService { +// void registerDispatcher(IDispatcher dispatcher); +//} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginIntegrationConfiguration.java b/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginIntegrationConfiguration.java index 3e8404c17a..0af30ab2aa 100644 --- a/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginIntegrationConfiguration.java +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/config/PluginIntegrationConfiguration.java @@ -3,12 +3,12 @@ import com.netgrif.application.engine.petrinet.domain.dataset.*; import com.netgrif.application.engine.workflow.web.responsebodies.*; import lombok.extern.slf4j.Slf4j; -import org.modelmapper.ModelMapper; -import org.pf4j.JarPluginManager; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import petrinet.domain.dataset.*; -import workflow.web.responsebodies.*; +//import org.modelmapper.ModelMapper; +//import org.pf4j.JarPluginManager; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import petrinet.domain.dataset.*; +//import workflow.web.responsebodies.*; import java.lang.reflect.Type; import java.util.Arrays; @@ -20,100 +20,100 @@ /** * Configuration class for plugin management * */ -@Slf4j -@Configuration -public class PluginIntegrationConfiguration { - - private static final Class[] fieldClasses = new Class[] { - BooleanField.class, - ButtonField.class, - CaseField.class, - DateField.class, - DateTimeField.class, - EnumerationField.class, - EnumerationMapField.class, - FileField.class, - FileListField.class, - FilterField.class, - I18nField.class, - MultichoiceField.class, - MultichoiceMapField.class, - NumberField.class, - TaskField.class, - TextField.class, - UserField.class - }; - - private static final Class[] localisedFieldClasses = new Class[] { - LocalisedBooleanField.class, - LocalisedCaseField.class, - LocalisedDateField.class, - LocalisedDateTimeField.class, - LocalisedEnumerationField.class, - LocalisedEnumerationMapField.class, - LocalisedFileListField.class, - LocalisedFilterField.class, - LocalisedI18nField.class, - LocalisedMultichoiceField.class, - LocalisedMultichoiceMapField.class, - LocalisedNumberField.class, - LocalisedTextField.class, - LocalisedUserField.class - }; - - private static final Map>> fieldTypeMapping = new HashMap<>() {{ - put(FieldType.BOOLEAN, List.of(BooleanFieldDto.class, LocalisedBooleanFieldDto.class)); - put(FieldType.BUTTON, List.of(ButtonFieldDto.class)); - put(FieldType.CASE_REF, List.of(CaseFieldDto.class, LocalisedCaseFieldDto.class)); - put(FieldType.DATE, List.of(DateFieldDto.class, LocalisedDateFieldDto.class)); - put(FieldType.DATETIME, List.of(DateTimeFieldDto.class, LocalisedDateFieldDto.class)); - put(FieldType.ENUMERATION, List.of(EnumerationFieldDto.class, LocalisedEnumerationFieldDto.class)); - put(FieldType.ENUMERATION_MAP, List.of(EnumerationMapFieldDto.class, LocalisedEnumerationMapFieldDto.class)); - put(FieldType.FILE, List.of(FileFieldDto.class)); - put(FieldType.FILELIST, List.of(FileListFieldDto.class, LocalisedFileListFieldDto.class)); - put(FieldType.FILTER, List.of(FilterFieldDto.class, LocalisedFilterFieldDto.class)); - put(FieldType.I18N, List.of(I18nFieldDto.class, LocalisedI18nFieldDto.class)); - put(FieldType.MULTICHOICE, List.of(MultichoiceFieldDto.class, LocalisedMultichoiceFieldDto.class)); - put(FieldType.MULTICHOICE_MAP, List.of(MultichoiceMapFieldDto.class, LocalisedMultichoiceMapFieldDto.class)); - put(FieldType.NUMBER, List.of(NumberFieldDto.class, LocalisedNumberFieldDto.class)); - put(FieldType.TASK_REF, List.of(TaskFieldDto.class)); - put(FieldType.TEXT, List.of(TextFieldDto.class, LocalisedTextFieldDto.class)); - put(FieldType.USER, List.of(UserFieldDto.class, LocalisedUserFieldDto.class)); - put(FieldType.USERLIST, List.of(UserListFieldDto.class)); - }}; - - /** - * The plugin manager bean to load plugins as JAR files - * */ - @Bean - public JarPluginManager pluginManager() { - return new JarPluginManager(); - } - - - /** - * Model mapper bean to convert domain objects to DTOs - * */ - @Bean - public ModelMapper modelMapper() { - ModelMapper mapper = new ModelMapper(); - - Arrays.stream(fieldClasses).forEach(c -> - mapper.createTypeMap(c, FieldDto.class).setConverter(ctx -> fieldToDto((Field) ctx.getSource()))); - - Arrays.stream(localisedFieldClasses).forEach(c -> - mapper.createTypeMap(c, LocalisedFieldDto.class).setConverter(ctx -> localisedFieldToDto((LocalisedField) ctx.getSource()))); - - return mapper; - } - - private FieldDto fieldToDto(Field field) { - final ModelMapper innerMapper = new ModelMapper(); - return innerMapper.map(field, (Type) fieldTypeMapping.get(field.getType()).get(0)); - } - - private LocalisedFieldDto localisedFieldToDto(LocalisedField field) { - final ModelMapper innerMapper = new ModelMapper(); - return innerMapper.map(field, (Type) fieldTypeMapping.get(field.getType()).get(1)); - } -} +//@Slf4j +//@Configuration +//public class PluginIntegrationConfiguration { +// +// private static final Class[] fieldClasses = new Class[] { +// BooleanField.class, +// ButtonField.class, +// CaseField.class, +// DateField.class, +// DateTimeField.class, +// EnumerationField.class, +// EnumerationMapField.class, +// FileField.class, +// FileListField.class, +// FilterField.class, +// I18nField.class, +// MultichoiceField.class, +// MultichoiceMapField.class, +// NumberField.class, +// TaskField.class, +// TextField.class, +// UserField.class +// }; +// +// private static final Class[] localisedFieldClasses = new Class[] { +// LocalisedBooleanField.class, +// LocalisedCaseField.class, +// LocalisedDateField.class, +// LocalisedDateTimeField.class, +// LocalisedEnumerationField.class, +// LocalisedEnumerationMapField.class, +// LocalisedFileListField.class, +// LocalisedFilterField.class, +// LocalisedI18nField.class, +// LocalisedMultichoiceField.class, +// LocalisedMultichoiceMapField.class, +// LocalisedNumberField.class, +// LocalisedTextField.class, +// LocalisedUserField.class +// }; +// +// private static final Map>> fieldTypeMapping = new HashMap<>() {{ +// put(FieldType.BOOLEAN, List.of(BooleanFieldDto.class, LocalisedBooleanFieldDto.class)); +// put(FieldType.BUTTON, List.of(ButtonFieldDto.class)); +// put(FieldType.CASE_REF, List.of(CaseFieldDto.class, LocalisedCaseFieldDto.class)); +// put(FieldType.DATE, List.of(DateFieldDto.class, LocalisedDateFieldDto.class)); +// put(FieldType.DATETIME, List.of(DateTimeFieldDto.class, LocalisedDateFieldDto.class)); +// put(FieldType.ENUMERATION, List.of(EnumerationFieldDto.class, LocalisedEnumerationFieldDto.class)); +// put(FieldType.ENUMERATION_MAP, List.of(EnumerationMapFieldDto.class, LocalisedEnumerationMapFieldDto.class)); +// put(FieldType.FILE, List.of(FileFieldDto.class)); +// put(FieldType.FILELIST, List.of(FileListFieldDto.class, LocalisedFileListFieldDto.class)); +// put(FieldType.FILTER, List.of(FilterFieldDto.class, LocalisedFilterFieldDto.class)); +// put(FieldType.I18N, List.of(I18nFieldDto.class, LocalisedI18nFieldDto.class)); +// put(FieldType.MULTICHOICE, List.of(MultichoiceFieldDto.class, LocalisedMultichoiceFieldDto.class)); +// put(FieldType.MULTICHOICE_MAP, List.of(MultichoiceMapFieldDto.class, LocalisedMultichoiceMapFieldDto.class)); +// put(FieldType.NUMBER, List.of(NumberFieldDto.class, LocalisedNumberFieldDto.class)); +// put(FieldType.TASK_REF, List.of(TaskFieldDto.class)); +// put(FieldType.TEXT, List.of(TextFieldDto.class, LocalisedTextFieldDto.class)); +// put(FieldType.USER, List.of(UserFieldDto.class, LocalisedUserFieldDto.class)); +// put(FieldType.USERLIST, List.of(UserListFieldDto.class)); +// }}; +// +// /** +// * The plugin manager bean to load plugins as JAR files +// * */ +// @Bean +// public JarPluginManager pluginManager() { +// return new JarPluginManager(); +// } +// +// +// /** +// * Model mapper bean to convert domain objects to DTOs +// * */ +// @Bean +// public ModelMapper modelMapper() { +// ModelMapper mapper = new ModelMapper(); +// +// Arrays.stream(fieldClasses).forEach(c -> +// mapper.createTypeMap(c, FieldDto.class).setConverter(ctx -> fieldToDto((Field) ctx.getSource()))); +// +// Arrays.stream(localisedFieldClasses).forEach(c -> +// mapper.createTypeMap(c, LocalisedFieldDto.class).setConverter(ctx -> localisedFieldToDto((LocalisedField) ctx.getSource()))); +// +// return mapper; +// } +// +// private FieldDto fieldToDto(Field field) { +// final ModelMapper innerMapper = new ModelMapper(); +// return innerMapper.map(field, (Type) fieldTypeMapping.get(field.getType()).get(0)); +// } +// +// private LocalisedFieldDto localisedFieldToDto(LocalisedField field) { +// final ModelMapper innerMapper = new ModelMapper(); +// return innerMapper.map(field, (Type) fieldTypeMapping.get(field.getType()).get(1)); +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityConfiguration.java b/src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityConfiguration.java index 2b02d916f7..b68b2540bb 100644 --- a/src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityConfiguration.java +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityConfiguration.java @@ -5,19 +5,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; -import javax.annotation.PostConstruct; -import java.security.Policy; +//import javax.annotation.PostConstruct; +//import java.security.Policy; -@Slf4j -@Configuration -public class PluginSecurityConfiguration { - - @Autowired - private PluginProperties pluginProperties; - - @PostConstruct - protected void init() { - if (pluginProperties.getPermissions() != null && pluginProperties.getPermissions().size() > 0) - Policy.setPolicy(new PluginSecurityPolicy(pluginProperties.getPermissions())); - } -} +//@Slf4j +//@Configuration +//public class PluginSecurityConfiguration { +// +// @Autowired +// private PluginProperties pluginProperties; +// +// @PostConstruct +// protected void init() { +// if (pluginProperties.getPermissions() != null && pluginProperties.getPermissions().size() > 0) +// Policy.setPolicy(new PluginSecurityPolicy(pluginProperties.getPermissions())); +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityPolicy.java b/src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityPolicy.java index 967c58efd0..659a242d21 100644 --- a/src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityPolicy.java +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/security/PluginSecurityPolicy.java @@ -1,34 +1,34 @@ package com.netgrif.application.engine.integration.plugins.security; import lombok.Setter; -import org.pf4j.PluginClassLoader; +//import org.pf4j.PluginClassLoader; import java.security.*; import java.util.ArrayList; import java.util.List; -class PluginSecurityPolicy extends Policy { - - @Setter - private List permissionList; - - protected PluginSecurityPolicy() { - this.permissionList = new ArrayList<>(); - } - - protected PluginSecurityPolicy(List permissionList) { - this(); - this.permissionList = permissionList; - } - - @Override - public PermissionCollection getPermissions(ProtectionDomain domain) { - Permissions permissions = new Permissions(); - - if (domain.getClassLoader() instanceof PluginClassLoader) { - permissionList.forEach(permissions::add); - } - - return permissions; - } -} +//class PluginSecurityPolicy extends Policy { +// +// @Setter +// private List permissionList; +// +// protected PluginSecurityPolicy() { +// this.permissionList = new ArrayList<>(); +// } +// +// protected PluginSecurityPolicy(List permissionList) { +// this(); +// this.permissionList = permissionList; +// } +// +// @Override +// public PermissionCollection getPermissions(ProtectionDomain domain) { +// Permissions permissions = new Permissions(); +// +// if (domain.getClassLoader() instanceof PluginClassLoader) { +// permissionList.forEach(permissions::add); +// } +// +// return permissions; +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/services/DtoConverterService.java b/src/main/java/com/netgrif/application/engine/integration/plugins/services/DtoConverterService.java index e2c7ea2ded..ff09241a92 100644 --- a/src/main/java/com/netgrif/application/engine/integration/plugins/services/DtoConverterService.java +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/services/DtoConverterService.java @@ -1,64 +1,64 @@ -package com.netgrif.application.engine.integration.plugins.services; - -import com.netgrif.application.engine.integration.plugins.services.interfaces.IDtoConverterService; -import com.netgrif.application.engine.petrinet.domain.DataGroup; -import com.netgrif.application.engine.petrinet.domain.PetriNet; -import com.netgrif.application.engine.workflow.domain.Case; -import com.netgrif.application.engine.workflow.domain.Task; -import org.modelmapper.ModelMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import petrinet.domain.DataGroupDto; -import petrinet.domain.PetriNetDto; -import workflow.domain.CaseDto; -import workflow.domain.TaskDto; - -/** - * Converter service to turn domain objects of NAE into DTO objects of NAE-API library - * */ -@Service -public class DtoConverterService implements IDtoConverterService { - - @Autowired - private ModelMapper modelMapper; - - /** - * Converts Petri Net into its DTO object - * @param net the input Petri Net to be converted into DTO - * @return Petri Net DTO object - * */ - @Override - public PetriNetDto convertPetriNet(PetriNet net) { - return modelMapper.map(net, PetriNetDto.class); - } - - /** - * Converts case into its DTO object - * @param aCase the input case to be converted into DTO - * @return case DTO object - * */ - @Override - public CaseDto convertCase(Case aCase) { - return modelMapper.map(aCase, CaseDto.class); - } - - /** - * Converts data task its DTO object - * @param task the input task to be converted into DTO - * @return task DTO object - * */ - @Override - public TaskDto convertTask(Task task) { - return modelMapper.map(task, TaskDto.class); - } - - /** - * Converts data group into its DTO object - * @param dataGroup the input data group to be converted into DTO - * @return data group DTO object - * */ - @Override - public DataGroupDto convertDataGroup(DataGroup dataGroup) { - return modelMapper.map(dataGroup, DataGroupDto.class); - } -} +//package com.netgrif.application.engine.integration.plugins.services; +// +//import com.netgrif.application.engine.integration.plugins.services.interfaces.IDtoConverterService; +//import com.netgrif.application.engine.petrinet.domain.DataGroup; +//import com.netgrif.application.engine.petrinet.domain.PetriNet; +//import com.netgrif.application.engine.workflow.domain.Case; +//import com.netgrif.application.engine.workflow.domain.Task; +//import org.modelmapper.ModelMapper; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Service; +//import petrinet.domain.DataGroupDto; +//import petrinet.domain.PetriNetDto; +//import workflow.domain.CaseDto; +//import workflow.domain.TaskDto; +// +///** +// * Converter service to turn domain objects of NAE into DTO objects of NAE-API library +// * */ +//@Service +//public class DtoConverterService implements IDtoConverterService { +// +// @Autowired +// private ModelMapper modelMapper; +// +// /** +// * Converts Petri Net into its DTO object +// * @param net the input Petri Net to be converted into DTO +// * @return Petri Net DTO object +// * */ +// @Override +// public PetriNetDto convertPetriNet(PetriNet net) { +// return modelMapper.map(net, PetriNetDto.class); +// } +// +// /** +// * Converts case into its DTO object +// * @param aCase the input case to be converted into DTO +// * @return case DTO object +// * */ +// @Override +// public CaseDto convertCase(Case aCase) { +// return modelMapper.map(aCase, CaseDto.class); +// } +// +// /** +// * Converts data task its DTO object +// * @param task the input task to be converted into DTO +// * @return task DTO object +// * */ +// @Override +// public TaskDto convertTask(Task task) { +// return modelMapper.map(task, TaskDto.class); +// } +// +// /** +// * Converts data group into its DTO object +// * @param dataGroup the input data group to be converted into DTO +// * @return data group DTO object +// * */ +// @Override +// public DataGroupDto convertDataGroup(DataGroup dataGroup) { +// return modelMapper.map(dataGroup, DataGroupDto.class); +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/services/PluginService.java b/src/main/java/com/netgrif/application/engine/integration/plugins/services/PluginService.java index 79b4d23bdf..68b25cdf03 100644 --- a/src/main/java/com/netgrif/application/engine/integration/plugins/services/PluginService.java +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/services/PluginService.java @@ -1,19 +1,19 @@ package com.netgrif.application.engine.integration.plugins.services; - -import com.netgrif.application.engine.integration.plugins.config.PluginProperties; -import com.netgrif.application.engine.integration.plugins.services.interfaces.IPluginService; -import extensions.NaeExtensionPoint; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.io.FilenameUtils; -import org.apache.commons.io.filefilter.WildcardFileFilter; -import org.pf4j.Plugin; -import org.pf4j.PluginManager; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import wrapper.NaePlugin; - -import javax.annotation.PostConstruct; -import java.io.File; +// +//import com.netgrif.application.engine.integration.plugins.config.PluginProperties; +//import com.netgrif.application.engine.integration.plugins.services.interfaces.IPluginService; +//import extensions.NaeExtensionPoint; +//import lombok.extern.slf4j.Slf4j; +//import org.apache.commons.io.FilenameUtils; +//import org.apache.commons.io.filefilter.WildcardFileFilter; +//import org.pf4j.Plugin; +//import org.pf4j.PluginManager; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Service; +//import wrapper.NaePlugin; +// +//import javax.annotation.PostConstruct; +//import java.io.File; import java.io.FilenameFilter; import java.nio.file.Files; import java.nio.file.Path; @@ -26,132 +26,132 @@ /** * Service for managing plugins in NAE * */ -@Slf4j -@Service -public class PluginService implements IPluginService { - - @Autowired - private PluginProperties pluginProperties; - - @Autowired - private PluginManager pluginManager; - - @Autowired - private PluginInjector pluginInjector; - - /** - * Initialization of plugin system inside NAE. Sets properties and loads the plugins. - * */ - @PostConstruct - protected void init() { - if (pluginProperties.getPluginFileNames().length == 1 && pluginProperties.getPluginFileNames()[0].equals("*")) - load(pluginProperties.getDir()); - else if (pluginProperties.getPluginFileNames().length > 0) - Arrays.stream(pluginProperties.getPluginFileNames()).forEach(fileName -> load(pluginProperties.getDir() + "/" + fileName)); - } - - /** - * Returns a plugin by its ID - * @param pluginId the plugin ID of required plugin - * @return the required plugin - * */ - @Override - public final NaePlugin getPlugin(String pluginId) { - Plugin plugin = this.pluginManager.getPlugin(pluginId).getPlugin(); - if (!(plugin instanceof NaePlugin)) { - log.error("Plugin " + plugin.toString() + " is not type of NaePlugin."); - return null; - } - return (NaePlugin) plugin; - } - - /** - * Returns all NaePlugin - * @return the required plugins - * */ - @Override - public final List getAllPlugin() { - List plugins = this.pluginManager.getPlugins().stream().map(pw -> { - if (pw.getPlugin() instanceof NaePlugin) - return (NaePlugin) pw.getPlugin(); - else - return null; - }).collect(Collectors.toList()); - return plugins; - } - - /** - * Calls a function of an extension point from a single plugin and returns its result. - * @param pluginId ID of the plugin - * @param extensionName name of the extension point class where the function is defined - * @param method name of method to be called - * @param argumentValues the input values of arguments of function - * @param returnType the class type of the return value of the function - * @return an object from the function inside plugin - * */ - @Override - public final T call(String pluginId, String extensionName, String method, List argumentValues, Class returnType) { - NaeExtensionPoint extension = retrieveExtension(pluginId, extensionName); - if (extension == null) { - return null; - } - return extension.call(method, argumentValues, returnType); - } - - /** - * Loads the plugin from the specific path - * @param path input path - * */ - private void load(String path) { - Path pluginPath = Paths.get(path); - if (Files.isDirectory(pluginPath)) { - File dir = new File(path); - File[] pluginJars = dir.listFiles((FilenameFilter) new WildcardFileFilter("*.jar")); - if (pluginJars != null) - Arrays.stream(pluginJars).forEach(jar -> loadAndStartPlugin(Paths.get(jar.getPath()))); - } else if (FilenameUtils.getExtension(pluginPath.getFileName().toString()).equals("jar")) { - loadAndStartPlugin(pluginPath); - } - injectPlugin(); - } - - /** - * Injects the plugin and it's extension - * */ - private void injectPlugin() { - this.pluginManager.getPlugins().forEach(plugin -> { - if (plugin.getPlugin() instanceof NaePlugin) { - ((NaePlugin) plugin.getPlugin()).init(); - pluginInjector.injectExtension(plugin); - } - }); - } - - /** - * Loads and starts the plugin. - * @param pluginPath Path of the plugin to be loaded and started - * */ - private void loadAndStartPlugin(Path pluginPath) { - pluginManager.loadPlugin(pluginPath); - pluginManager.startPlugins(); - } - - /** - * Retrieves extension by the given plugin ID, extension name and method name. - * @param pluginId ID of the plugin where the extension is defined - * @param extensionName name of the extension class - * @return the NaeExtensionPoint object - * */ - private NaeExtensionPoint retrieveExtension(String pluginId, String extensionName) { - Optional extension = pluginManager.getExtensions(pluginId) - .stream() - .filter(ext -> ext.getClass().getName().equals(extensionName)) - .findFirst(); - - if (extension.isEmpty()) { - log.error("There is no extension with given class name [" + extensionName + "]"); - return null; - } - return extension.get(); - } -} +//@Slf4j +//@Service +//public class PluginService implements IPluginService { +// +// @Autowired +// private PluginProperties pluginProperties; +// +// @Autowired +// private PluginManager pluginManager; +// +// @Autowired +// private PluginInjector pluginInjector; +// +// /** +// * Initialization of plugin system inside NAE. Sets properties and loads the plugins. +// * */ +// @PostConstruct +// protected void init() { +// if (pluginProperties.getPluginFileNames().length == 1 && pluginProperties.getPluginFileNames()[0].equals("*")) +// load(pluginProperties.getDir()); +// else if (pluginProperties.getPluginFileNames().length > 0) +// Arrays.stream(pluginProperties.getPluginFileNames()).forEach(fileName -> load(pluginProperties.getDir() + "/" + fileName)); +// } +// +// /** +// * Returns a plugin by its ID +// * @param pluginId the plugin ID of required plugin +// * @return the required plugin +// * */ +// @Override +// public final NaePlugin getPlugin(String pluginId) { +// Plugin plugin = this.pluginManager.getPlugin(pluginId).getPlugin(); +// if (!(plugin instanceof NaePlugin)) { +// log.error("Plugin " + plugin.toString() + " is not type of NaePlugin."); +// return null; +// } +// return (NaePlugin) plugin; +// } +// +// /** +// * Returns all NaePlugin +// * @return the required plugins +// * */ +// @Override +// public final List getAllPlugin() { +// List plugins = this.pluginManager.getPlugins().stream().map(pw -> { +// if (pw.getPlugin() instanceof NaePlugin) +// return (NaePlugin) pw.getPlugin(); +// else +// return null; +// }).collect(Collectors.toList()); +// return plugins; +// } +// +// /** +// * Calls a function of an extension point from a single plugin and returns its result. +// * @param pluginId ID of the plugin +// * @param extensionName name of the extension point class where the function is defined +// * @param method name of method to be called +// * @param argumentValues the input values of arguments of function +// * @param returnType the class type of the return value of the function +// * @return an object from the function inside plugin +// * */ +// @Override +// public final T call(String pluginId, String extensionName, String method, List argumentValues, Class returnType) { +// NaeExtensionPoint extension = retrieveExtension(pluginId, extensionName); +// if (extension == null) { +// return null; +// } +// return extension.call(method, argumentValues, returnType); +// } +// +// /** +// * Loads the plugin from the specific path +// * @param path input path +// * */ +// private void load(String path) { +// Path pluginPath = Paths.get(path); +// if (Files.isDirectory(pluginPath)) { +// File dir = new File(path); +// File[] pluginJars = dir.listFiles((FilenameFilter) new WildcardFileFilter("*.jar")); +// if (pluginJars != null) +// Arrays.stream(pluginJars).forEach(jar -> loadAndStartPlugin(Paths.get(jar.getPath()))); +// } else if (FilenameUtils.getExtension(pluginPath.getFileName().toString()).equals("jar")) { +// loadAndStartPlugin(pluginPath); +// } +// injectPlugin(); +// } +// +// /** +// * Injects the plugin and it's extension +// * */ +// private void injectPlugin() { +// this.pluginManager.getPlugins().forEach(plugin -> { +// if (plugin.getPlugin() instanceof NaePlugin) { +// ((NaePlugin) plugin.getPlugin()).init(); +// pluginInjector.injectExtension(plugin); +// } +// }); +// } +// +// /** +// * Loads and starts the plugin. +// * @param pluginPath Path of the plugin to be loaded and started +// * */ +// private void loadAndStartPlugin(Path pluginPath) { +// pluginManager.loadPlugin(pluginPath); +// pluginManager.startPlugins(); +// } +// +// /** +// * Retrieves extension by the given plugin ID, extension name and method name. +// * @param pluginId ID of the plugin where the extension is defined +// * @param extensionName name of the extension class +// * @return the NaeExtensionPoint object +// * */ +// private NaeExtensionPoint retrieveExtension(String pluginId, String extensionName) { +// Optional extension = pluginManager.getExtensions(pluginId) +// .stream() +// .filter(ext -> ext.getClass().getName().equals(extensionName)) +// .findFirst(); +// +// if (extension.isEmpty()) { +// log.error("There is no extension with given class name [" + extensionName + "]"); +// return null; +// } +// return extension.get(); +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IDtoConverterService.java b/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IDtoConverterService.java index 9deb4a5fd0..92f86d2ac0 100644 --- a/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IDtoConverterService.java +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IDtoConverterService.java @@ -4,18 +4,18 @@ import com.netgrif.application.engine.petrinet.domain.PetriNet; import com.netgrif.application.engine.workflow.domain.Case; import com.netgrif.application.engine.workflow.domain.Task; -import petrinet.domain.DataGroupDto; -import petrinet.domain.PetriNetDto; -import workflow.domain.CaseDto; -import workflow.domain.TaskDto; +//import petrinet.domain.DataGroupDto; +//import petrinet.domain.PetriNetDto; +//import workflow.domain.CaseDto; +//import workflow.domain.TaskDto; -public interface IDtoConverterService { - - DataGroupDto convertDataGroup(DataGroup dataGroup); - - PetriNetDto convertPetriNet(PetriNet net); - - CaseDto convertCase(Case aCase); - - TaskDto convertTask(Task task); -} +//public interface IDtoConverterService { +// +// DataGroupDto convertDataGroup(DataGroup dataGroup); +// +// PetriNetDto convertPetriNet(PetriNet net); +// +// CaseDto convertCase(Case aCase); +// +// TaskDto convertTask(Task task); +//} diff --git a/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IPluginService.java b/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IPluginService.java index d92776de58..41bb8e5c51 100644 --- a/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IPluginService.java +++ b/src/main/java/com/netgrif/application/engine/integration/plugins/services/interfaces/IPluginService.java @@ -1,15 +1,15 @@ package com.netgrif.application.engine.integration.plugins.services.interfaces; -import org.pf4j.Plugin; -import wrapper.NaePlugin; - -import java.util.List; - -public interface IPluginService { - - NaePlugin getPlugin(String pluginId); - - List getAllPlugin(); - - T call(String pluginId, String extensionName, String method, List argumentValues, Class returnType); -} +//import org.pf4j.Plugin; +//import wrapper.NaePlugin; +// +//import java.util.List; +// +//public interface IPluginService { +// +// NaePlugin getPlugin(String pluginId); +// +// List getAllPlugin(); +// +// T call(String pluginId, String extensionName, String method, List argumentValues, Class returnType); +//} From dc20e63ab0fed9a1320f1d557c91d2eeddd0399c Mon Sep 17 00:00:00 2001 From: Stefan Renczes Date: Tue, 3 Sep 2024 14:03:45 +0200 Subject: [PATCH 10/13] [NAE-1975] NAE nodes gRPC communication - added events to all domain types --- pom.xml | 63 +- .../logic/action/ActionDelegate.groovy | 6 +- .../application/engine/ApplicationEngine.java | 5 +- .../drools/DroolsConfiguration.java | 138 +-- .../drools/KnowledgeBaseInitializer.java | 286 +++---- .../drools/RefreshableKieBase.java | 102 +-- .../drools/RuleEngineGlobal.java | 78 +- .../drools/RuleEngineGlobalsProvider.java | 220 ++--- .../interfaces/IKnowledgeBaseInitializer.java | 30 +- .../interfaces/IRefreshableKieBase.java | 24 +- .../IRuleEngineGlobalsProvider.java | 30 +- .../throwable/RuleValidationException.java | 16 +- .../common/AbstractDispatcher.java | 21 +- .../engine/event/events/Event.java | 12 +- .../events/petrinet/ProcessDeleteEvent.java | 8 +- .../events/petrinet/ProcessDeployEvent.java | 7 +- .../event/events/petrinet/ProcessEvent.java | 14 + .../event/events/task/AssignTaskEvent.java | 5 +- .../event/events/task/CancelTaskEvent.java | 5 +- .../event/events/task/CreateTaskEvent.java | 5 +- .../event/events/task/DelegateTaskEvent.java | 5 +- .../event/events/task/FinishTaskEvent.java | 5 +- .../engine/event/events/task/TaskEvent.java | 6 +- .../event/events/workflow/CaseEvent.java | 7 +- .../events/workflow/CreateCaseEvent.java | 5 +- .../events/workflow/DeleteCaseEvent.java | 5 +- .../listeners/ContextEditingListener.java | 24 + .../event/listeners/RuleEventListener.java | 52 ++ .../petrinet/service/PetriNetService.java | 27 +- .../engine/rules/domain/FactRepository.java | 26 +- .../engine/rules/domain/RuleRepository.java | 38 +- .../engine/rules/domain/StoredRule.java | 118 +-- .../rules/domain/facts/CaseCreatedFact.java | 42 +- .../engine/rules/domain/facts/CaseFact.java | 32 +- .../engine/rules/domain/facts/Fact.java | 46 +- .../rules/domain/facts/NetImportedFact.java | 34 +- .../rules/domain/facts/PetriNetFact.java | 32 +- .../rules/domain/facts/RuleEvaluation.java | 44 +- .../rules/domain/facts/ScheduledRuleFact.java | 40 +- .../domain/facts/TransitionEventFact.java | 96 +-- .../scheduled/CaseRuleEvaluationJob.java | 78 +- .../scheduled/PetriNetRuleEvaluationJob.java | 80 +- .../rules/domain/scheduled/RuleJob.java | 88 +- .../domain/scheduled/ScheduleOutcome.java | 28 +- .../engine/rules/service/RuleEngine.java | 172 ++-- .../RuleEvaluationScheduleService.java | 198 ++--- .../rules/service/interfaces/IRuleEngine.java | 44 +- .../IRuleEvaluationScheduleService.java | 44 +- .../RuleEvaluationScheduleException.java | 20 +- .../startup/runner/RuleEngineRunner.java | 152 ++-- .../engine/workflow/service/TaskService.java | 45 +- .../workflow/service/WorkflowService.java | 36 +- .../domain/dataset/ChangeBehaviorTest.groovy | 1 - .../drools/KnowledgeBaseInitializerTest.java | 218 ++--- .../engine/drools/RefreshableKieBaseTest.java | 354 ++++---- .../engine/rules/service/RuleEngineTest.java | 804 +++++++++--------- .../RuleEvaluationScheduleServiceTest.java | 202 ++--- 57 files changed, 2230 insertions(+), 2093 deletions(-) create mode 100644 src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessEvent.java create mode 100644 src/main/java/com/netgrif/application/engine/event/listeners/ContextEditingListener.java create mode 100644 src/main/java/com/netgrif/application/engine/event/listeners/RuleEventListener.java diff --git a/pom.xml b/pom.xml index 4504bc7e0a..28657db4e0 100644 --- a/pom.xml +++ b/pom.xml @@ -393,35 +393,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - org.kie - kie-ci - ${drools-version} - - - org.drools - drools-decisiontables - ${drools-version} - - - org.drools - drools-mvel - ${drools-version} - - - org.drools - drools-core - ${drools-version} - - - org.drools - drools-compiler - ${drools-version} + com.netgrif + netgrif-drools + 0.0.1-SNAPSHOT + provided - org.kie - kie-spring - ${kie-spring.version} + org.apache.poi + poi + 5.1.0 diff --git a/src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/logic/action/ActionDelegate.groovy b/src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/logic/action/ActionDelegate.groovy index c2b112149a..7138f71aee 100644 --- a/src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/logic/action/ActionDelegate.groovy +++ b/src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/logic/action/ActionDelegate.groovy @@ -36,7 +36,7 @@ import com.netgrif.application.engine.petrinet.domain.roles.ProcessRole import com.netgrif.application.engine.petrinet.domain.version.Version import com.netgrif.application.engine.petrinet.service.interfaces.IPetriNetService import com.netgrif.application.engine.petrinet.service.interfaces.IUriService -import com.netgrif.application.engine.rules.domain.RuleRepository +//import com.netgrif.application.engine.rules.domain.RuleRepository import com.netgrif.application.engine.startup.runner.DefaultFiltersRunner import com.netgrif.application.engine.startup.runner.FilterRunner import com.netgrif.application.engine.startup.ImportHelper @@ -144,8 +144,8 @@ class ActionDelegate { @Autowired IInitValueExpressionEvaluator initValueExpressionEvaluator - @Autowired - RuleRepository ruleRepository +// @Autowired +// RuleRepository ruleRepository @Autowired Scheduler scheduler diff --git a/src/main/java/com/netgrif/application/engine/ApplicationEngine.java b/src/main/java/com/netgrif/application/engine/ApplicationEngine.java index eb667adb4e..bb18c3f8d5 100644 --- a/src/main/java/com/netgrif/application/engine/ApplicationEngine.java +++ b/src/main/java/com/netgrif/application/engine/ApplicationEngine.java @@ -4,11 +4,13 @@ import com.netgrif.application.engine.configuration.JsonRootRelProvider; import com.netgrif.application.engine.configuration.groovy.converter.GStringToStringConverter; import com.netgrif.application.engine.petrinet.domain.version.StringToVersionConverter; +import com.netgrif.netgrifdrools.NetgrifDroolsApplication; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.annotation.Aspect; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.properties.ConfigurationPropertiesScan; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; @@ -16,6 +18,7 @@ import org.springframework.core.convert.converter.Converter; import org.springframework.data.mongodb.config.EnableMongoAuditing; import org.springframework.data.mongodb.core.convert.MongoCustomConversions; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.server.LinkRelationProvider; import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; @@ -29,7 +32,7 @@ @EnableAspectJAutoProxy @SpringBootApplication( exclude = {DataSourceAutoConfiguration.class}, - scanBasePackages = {"com.netgrif.application.engine"}) + scanBasePackages = {"com.netgrif.application.engine", "com.netgrif.netgrifdrools"}) @EnableMongoAuditing @ConfigurationPropertiesScan @Aspect diff --git a/src/main/java/com/netgrif/application/engine/configuration/drools/DroolsConfiguration.java b/src/main/java/com/netgrif/application/engine/configuration/drools/DroolsConfiguration.java index 698b33b159..98842b274b 100644 --- a/src/main/java/com/netgrif/application/engine/configuration/drools/DroolsConfiguration.java +++ b/src/main/java/com/netgrif/application/engine/configuration/drools/DroolsConfiguration.java @@ -1,72 +1,72 @@ -package com.netgrif.application.engine.configuration.drools; - -import com.netgrif.application.engine.configuration.drools.interfaces.IKnowledgeBaseInitializer; -import com.netgrif.application.engine.configuration.drools.interfaces.IRefreshableKieBase; -import com.netgrif.application.engine.configuration.drools.interfaces.IRuleEngineGlobalsProvider; -import com.netgrif.application.engine.rules.domain.RuleRepository; -import org.drools.template.ObjectDataCompiler; -import org.kie.api.KieServices; -import org.kie.api.builder.KieBuilder; -import org.kie.api.builder.KieFileSystem; -import org.kie.api.builder.KieModule; -import org.kie.api.runtime.KieContainer; -import org.kie.api.runtime.KieSession; -import org.kie.internal.io.ResourceFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Scope; - -@Configuration -public class DroolsConfiguration { - - @Autowired - private IKnowledgeBaseInitializer baseInitializer; - - @Autowired - private IRuleEngineGlobalsProvider sessionInitializer; - - @Autowired - private RuleRepository ruleRepository; - - @Value("${drools.template.path:rules/templates/template.drl}") - private String templatePath; - - @Bean(name = "kieRuntime") - @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public KieSession kieRuntime() { - IRefreshableKieBase baseWrapper = refreshableKieBase(); - if (baseWrapper.shouldRefresh()) { - baseWrapper.refresh(); - } - - KieSession runtime = baseWrapper.kieBase().newKieSession(); - sessionInitializer.setGlobals(runtime); - return runtime; - } - -// @Bean -// public KieContainer kieContainer() { -// KieServices kieServices = KieServices.Factory.get(); +//package com.netgrif.application.engine.configuration.drools; +// +//import com.netgrif.application.engine.configuration.drools.interfaces.IKnowledgeBaseInitializer; +//import com.netgrif.application.engine.configuration.drools.interfaces.IRefreshableKieBase; +//import com.netgrif.application.engine.configuration.drools.interfaces.IRuleEngineGlobalsProvider; +//import com.netgrif.application.engine.rules.domain.RuleRepository; +//import org.drools.template.ObjectDataCompiler; +//import org.kie.api.KieServices; +//import org.kie.api.builder.KieBuilder; +//import org.kie.api.builder.KieFileSystem; +//import org.kie.api.builder.KieModule; +//import org.kie.api.runtime.KieContainer; +//import org.kie.api.runtime.KieSession; +//import org.kie.internal.io.ResourceFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.beans.factory.annotation.Value; +//import org.springframework.beans.factory.config.ConfigurableBeanFactory; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.context.annotation.Scope; +// +//@Configuration +//public class DroolsConfiguration { +// +// @Autowired +// private IKnowledgeBaseInitializer baseInitializer; +// +// @Autowired +// private IRuleEngineGlobalsProvider sessionInitializer; +// +// @Autowired +// private RuleRepository ruleRepository; +// +// @Value("${drools.template.path:rules/templates/template.drl}") +// private String templatePath; // -// KieFileSystem kieFileSystem = kieServices.newKieFileSystem(); -// kieFileSystem.write(ResourceFactory.newClassPathResource(templatePath)); -// KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem); -// kieBuilder.buildAll(); -// KieModule kieModule = kieBuilder.getKieModule(); +// @Bean(name = "kieRuntime") +// @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) +// public KieSession kieRuntime() { +// IRefreshableKieBase baseWrapper = refreshableKieBase(); +// if (baseWrapper.shouldRefresh()) { +// baseWrapper.refresh(); +// } // -// return kieServices.newKieContainer(kieModule.getReleaseId()); +// KieSession runtime = baseWrapper.kieBase().newKieSession(); +// sessionInitializer.setGlobals(runtime); +// return runtime; +// } +// +//// @Bean +//// public KieContainer kieContainer() { +//// KieServices kieServices = KieServices.Factory.get(); +//// +//// KieFileSystem kieFileSystem = kieServices.newKieFileSystem(); +//// kieFileSystem.write(ResourceFactory.newClassPathResource(templatePath)); +//// KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem); +//// kieBuilder.buildAll(); +//// KieModule kieModule = kieBuilder.getKieModule(); +//// +//// return kieServices.newKieContainer(kieModule.getReleaseId()); +//// } +// +// @Bean +// public IRefreshableKieBase refreshableKieBase() { +// return new RefreshableKieBase(ruleRepository, baseInitializer); +// } +// +// @Bean +// public ObjectDataCompiler objectDataCompiler() { +// return new ObjectDataCompiler(); // } - - @Bean - public IRefreshableKieBase refreshableKieBase() { - return new RefreshableKieBase(ruleRepository, baseInitializer); - } - - @Bean - public ObjectDataCompiler objectDataCompiler() { - return new ObjectDataCompiler(); - } -} +//} diff --git a/src/main/java/com/netgrif/application/engine/configuration/drools/KnowledgeBaseInitializer.java b/src/main/java/com/netgrif/application/engine/configuration/drools/KnowledgeBaseInitializer.java index 3a2f27c33b..030a32c426 100644 --- a/src/main/java/com/netgrif/application/engine/configuration/drools/KnowledgeBaseInitializer.java +++ b/src/main/java/com/netgrif/application/engine/configuration/drools/KnowledgeBaseInitializer.java @@ -1,143 +1,143 @@ -package com.netgrif.application.engine.configuration.drools; - -import com.netgrif.application.engine.configuration.drools.interfaces.IKnowledgeBaseInitializer; -import com.netgrif.application.engine.configuration.drools.throwable.RuleValidationException; -import com.netgrif.application.engine.rules.domain.RuleRepository; -import com.netgrif.application.engine.rules.domain.StoredRule; -import com.netgrif.application.engine.utils.DateUtils; -import org.drools.template.ObjectDataCompiler; -import org.kie.api.KieBase; -import org.kie.api.KieServices; -import org.kie.api.io.Resource; -import org.kie.api.io.ResourceType; -import org.kie.api.runtime.KieSession; -import org.kie.internal.utils.KieHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.domain.PageRequest; -import org.springframework.stereotype.Service; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Service -public class KnowledgeBaseInitializer implements IKnowledgeBaseInitializer { - - private static final Logger log = LoggerFactory.getLogger(KnowledgeBaseInitializer.class); - - @Value("${drools.template.path:rules/templates/template.drl}") - private String templatePath; - - @Value("${drools.compile.page-size:100}") - private Integer pageSize; - - @Autowired - private RuleRepository ruleRepository; - - @Autowired - private ObjectDataCompiler compiler; - - @Override - public KieBase constructKieBase() { - KieHelper kieHelper = new KieHelper(); - try { - kieHelper = buildAllRules(kieHelper); - } catch (Exception e) { - log.error("Failed to construct rule engine knowledge base", e); - throw new IllegalStateException("Rules not successfully loaded"); - } - - return kieHelper.build(); - } - - @Override - public void validate(List storedRules) throws RuleValidationException { - KieSession testSession = null; - try { - KieHelper kieHelper = new KieHelper(); - buildRules(storedRules, kieHelper); - KieBase base = kieHelper.build(); - testSession = base.newKieSession(); - testSession.fireAllRules(); - } catch (Exception e) { - log.error("Validation unsuccessful", e); - throw new RuleValidationException(e); - } finally { - if (testSession != null) { - testSession.destroy(); - } - } - } - - protected KieHelper buildAllRules(KieHelper kieHelper) throws IOException { - Long count = ruleRepository.count(); - long numOfPages = ((count / pageSize) + 1); - - log.debug("Compiling rules, count=" + count + ", pages=" + numOfPages); - for (int page = 0; page < numOfPages; page++) { - List rules = ruleRepository.findAll(PageRequest.of(page, pageSize)).getContent(); - buildRules(rules, kieHelper); - } - - return kieHelper; - } - - protected KieHelper buildRules(List rules, KieHelper kieHelper) throws IOException { - String generatedDRL = compileRules(rules); - kieHelper = addRulesResource(generatedDRL, kieHelper); - log.debug("drl:\n" + generatedDRL); - - return kieHelper; - } - - protected String compileRules(List rules) throws IOException { - List> ruleAttributes = new ArrayList<>(); - - rules.forEach(persistedRule -> { - Map templateRule = new HashMap<>(); - templateRule.put("ruleId", persistedRule.getStringId()); - templateRule.put("ruleEnabled", Boolean.toString(persistedRule.isEnabled())); - templateRule.put("whenCondition", persistedRule.getWhen()); - templateRule.put("thenAction", persistedRule.getThen()); - - String dateEffective = (persistedRule.getDateEffective() == null) ? "" : "date-effective \"" + formatDate(persistedRule.getDateEffective()) + "\""; - String dateExpires = (persistedRule.getDateExpires() == null) ? "" : "date-expires \"" + formatDate(persistedRule.getDateExpires()) + "\""; - - templateRule.put("salienceVal", Integer.toString(persistedRule.getSalience())); - templateRule.put("dateEffective", dateEffective); - templateRule.put("dateExpires", dateExpires); - - ruleAttributes.add(templateRule); - }); - - try (InputStream template = templateInputStream()) { - return compiler.compile(ruleAttributes, template); - } catch (IOException e) { - log.error("Failed to compile rules", e); - throw e; - } - } - - protected KieHelper addRulesResource(String generatedDRL, KieHelper kieHelper) { - KieServices kieServices = KieServices.Factory.get(); - Resource resource = kieServices.getResources().newByteArrayResource(generatedDRL.getBytes()); - kieHelper.addResource(resource, ResourceType.DRL); - return kieHelper; - } - - protected InputStream templateInputStream() throws IOException { - return new FileInputStream(templatePath); - } - - private String formatDate(LocalDate date) { - return date.format(DateUtils.dd_MMM_yyyy); - } -} +//package com.netgrif.application.engine.configuration.drools; +// +//import com.netgrif.application.engine.configuration.drools.interfaces.IKnowledgeBaseInitializer; +//import com.netgrif.application.engine.configuration.drools.throwable.RuleValidationException; +//import com.netgrif.application.engine.rules.domain.RuleRepository; +//import com.netgrif.application.engine.rules.domain.StoredRule; +//import com.netgrif.application.engine.utils.DateUtils; +//import org.drools.template.ObjectDataCompiler; +//import org.kie.api.KieBase; +//import org.kie.api.KieServices; +//import org.kie.api.io.Resource; +//import org.kie.api.io.ResourceType; +//import org.kie.api.runtime.KieSession; +//import org.kie.internal.utils.KieHelper; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.beans.factory.annotation.Value; +//import org.springframework.data.domain.PageRequest; +//import org.springframework.stereotype.Service; +// +//import java.io.FileInputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.time.LocalDate; +//import java.util.ArrayList; +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +//@Service +//public class KnowledgeBaseInitializer implements IKnowledgeBaseInitializer { +// +// private static final Logger log = LoggerFactory.getLogger(KnowledgeBaseInitializer.class); +// +// @Value("${drools.template.path:rules/templates/template.drl}") +// private String templatePath; +// +// @Value("${drools.compile.page-size:100}") +// private Integer pageSize; +// +// @Autowired +// private RuleRepository ruleRepository; +// +// @Autowired +// private ObjectDataCompiler compiler; +// +// @Override +// public KieBase constructKieBase() { +// KieHelper kieHelper = new KieHelper(); +// try { +// kieHelper = buildAllRules(kieHelper); +// } catch (Exception e) { +// log.error("Failed to construct rule engine knowledge base", e); +// throw new IllegalStateException("Rules not successfully loaded"); +// } +// +// return kieHelper.build(); +// } +// +// @Override +// public void validate(List storedRules) throws RuleValidationException { +// KieSession testSession = null; +// try { +// KieHelper kieHelper = new KieHelper(); +// buildRules(storedRules, kieHelper); +// KieBase base = kieHelper.build(); +// testSession = base.newKieSession(); +// testSession.fireAllRules(); +// } catch (Exception e) { +// log.error("Validation unsuccessful", e); +// throw new RuleValidationException(e); +// } finally { +// if (testSession != null) { +// testSession.destroy(); +// } +// } +// } +// +// protected KieHelper buildAllRules(KieHelper kieHelper) throws IOException { +// Long count = ruleRepository.count(); +// long numOfPages = ((count / pageSize) + 1); +// +// log.debug("Compiling rules, count=" + count + ", pages=" + numOfPages); +// for (int page = 0; page < numOfPages; page++) { +// List rules = ruleRepository.findAll(PageRequest.of(page, pageSize)).getContent(); +// buildRules(rules, kieHelper); +// } +// +// return kieHelper; +// } +// +// protected KieHelper buildRules(List rules, KieHelper kieHelper) throws IOException { +// String generatedDRL = compileRules(rules); +// kieHelper = addRulesResource(generatedDRL, kieHelper); +// log.debug("drl:\n" + generatedDRL); +// +// return kieHelper; +// } +// +// protected String compileRules(List rules) throws IOException { +// List> ruleAttributes = new ArrayList<>(); +// +// rules.forEach(persistedRule -> { +// Map templateRule = new HashMap<>(); +// templateRule.put("ruleId", persistedRule.getStringId()); +// templateRule.put("ruleEnabled", Boolean.toString(persistedRule.isEnabled())); +// templateRule.put("whenCondition", persistedRule.getWhen()); +// templateRule.put("thenAction", persistedRule.getThen()); +// +// String dateEffective = (persistedRule.getDateEffective() == null) ? "" : "date-effective \"" + formatDate(persistedRule.getDateEffective()) + "\""; +// String dateExpires = (persistedRule.getDateExpires() == null) ? "" : "date-expires \"" + formatDate(persistedRule.getDateExpires()) + "\""; +// +// templateRule.put("salienceVal", Integer.toString(persistedRule.getSalience())); +// templateRule.put("dateEffective", dateEffective); +// templateRule.put("dateExpires", dateExpires); +// +// ruleAttributes.add(templateRule); +// }); +// +// try (InputStream template = templateInputStream()) { +// return compiler.compile(ruleAttributes, template); +// } catch (IOException e) { +// log.error("Failed to compile rules", e); +// throw e; +// } +// } +// +// protected KieHelper addRulesResource(String generatedDRL, KieHelper kieHelper) { +// KieServices kieServices = KieServices.Factory.get(); +// Resource resource = kieServices.getResources().newByteArrayResource(generatedDRL.getBytes()); +// kieHelper.addResource(resource, ResourceType.DRL); +// return kieHelper; +// } +// +// protected InputStream templateInputStream() throws IOException { +// return new FileInputStream(templatePath); +// } +// +// private String formatDate(LocalDate date) { +// return date.format(DateUtils.dd_MMM_yyyy); +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/configuration/drools/RefreshableKieBase.java b/src/main/java/com/netgrif/application/engine/configuration/drools/RefreshableKieBase.java index 8a0ef28476..d4903970ba 100644 --- a/src/main/java/com/netgrif/application/engine/configuration/drools/RefreshableKieBase.java +++ b/src/main/java/com/netgrif/application/engine/configuration/drools/RefreshableKieBase.java @@ -1,51 +1,51 @@ -package com.netgrif.application.engine.configuration.drools; - -import com.netgrif.application.engine.configuration.drools.interfaces.IKnowledgeBaseInitializer; -import com.netgrif.application.engine.configuration.drools.interfaces.IRefreshableKieBase; -import com.netgrif.application.engine.rules.domain.RuleRepository; -import org.kie.api.KieBase; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import java.time.LocalDateTime; - -@Component -public class RefreshableKieBase implements IRefreshableKieBase { - - public static final Logger log = LoggerFactory.getLogger(RefreshableKieBase.class); - - private final RuleRepository ruleRepository; - - private final IKnowledgeBaseInitializer knowledgeBaseInitializer; - - @Value("${drools.knowBase.auto-refresh:#{true}}") - private boolean autoRefresh; - - private LocalDateTime lastRefresh; - - private KieBase kieBase; - - - public RefreshableKieBase(@Autowired RuleRepository ruleRepository, @Autowired IKnowledgeBaseInitializer knowledgeBaseInitializer) { - this.ruleRepository = ruleRepository; - this.knowledgeBaseInitializer = knowledgeBaseInitializer; - } - - public KieBase kieBase() { - return kieBase; - } - - public boolean shouldRefresh() { - return autoRefresh && ruleRepository.existsByLastUpdateAfter(lastRefresh); - } - - public void refresh() { - this.lastRefresh = LocalDateTime.now(); - log.info("Refreshing kieBase"); - this.kieBase = knowledgeBaseInitializer.constructKieBase(); - log.info("KieBase refreshed"); - } -} +//package com.netgrif.application.engine.configuration.drools; +// +//import com.netgrif.application.engine.configuration.drools.interfaces.IKnowledgeBaseInitializer; +//import com.netgrif.application.engine.configuration.drools.interfaces.IRefreshableKieBase; +//import com.netgrif.application.engine.rules.domain.RuleRepository; +//import org.kie.api.KieBase; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.beans.factory.annotation.Value; +//import org.springframework.stereotype.Component; +// +//import java.time.LocalDateTime; +// +//@Component +//public class RefreshableKieBase implements IRefreshableKieBase { +// +// public static final Logger log = LoggerFactory.getLogger(RefreshableKieBase.class); +// +// private final RuleRepository ruleRepository; +// +// private final IKnowledgeBaseInitializer knowledgeBaseInitializer; +// +// @Value("${drools.knowBase.auto-refresh:#{true}}") +// private boolean autoRefresh; +// +// private LocalDateTime lastRefresh; +// +// private KieBase kieBase; +// +// +// public RefreshableKieBase(@Autowired RuleRepository ruleRepository, @Autowired IKnowledgeBaseInitializer knowledgeBaseInitializer) { +// this.ruleRepository = ruleRepository; +// this.knowledgeBaseInitializer = knowledgeBaseInitializer; +// } +// +// public KieBase kieBase() { +// return kieBase; +// } +// +// public boolean shouldRefresh() { +// return autoRefresh && ruleRepository.existsByLastUpdateAfter(lastRefresh); +// } +// +// public void refresh() { +// this.lastRefresh = LocalDateTime.now(); +// log.info("Refreshing kieBase"); +// this.kieBase = knowledgeBaseInitializer.constructKieBase(); +// log.info("KieBase refreshed"); +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/configuration/drools/RuleEngineGlobal.java b/src/main/java/com/netgrif/application/engine/configuration/drools/RuleEngineGlobal.java index 7c1bd30fba..9a98b19f08 100644 --- a/src/main/java/com/netgrif/application/engine/configuration/drools/RuleEngineGlobal.java +++ b/src/main/java/com/netgrif/application/engine/configuration/drools/RuleEngineGlobal.java @@ -1,39 +1,39 @@ -package com.netgrif.application.engine.configuration.drools; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class RuleEngineGlobal { - - private String packageName; - - private String className; - - private String globalName; - - private Object injected; - - public static RuleEngineGlobal engineGlobal(String packageName, String className, String globalName, Object injected) { - return new RuleEngineGlobal(packageName, className, globalName, injected); - } - - public static RuleEngineGlobal engineGlobal(String globalName, Object injected) { - return new RuleEngineGlobal( - injected.getClass().getPackage().getName(), - injected.getClass().getSimpleName(), - globalName, injected - ); - } - - public String fullyQualifiedName() { - return packageName + "." + className; - } - - @Override - public String toString() { - return "global " + className + " " + globalName + ";\n"; - } - -} +//package com.netgrif.application.engine.configuration.drools; +// +//import lombok.AllArgsConstructor; +//import lombok.Data; +// +//@Data +//@AllArgsConstructor +//public class RuleEngineGlobal { +// +// private String packageName; +// +// private String className; +// +// private String globalName; +// +// private Object injected; +// +// public static RuleEngineGlobal engineGlobal(String packageName, String className, String globalName, Object injected) { +// return new RuleEngineGlobal(packageName, className, globalName, injected); +// } +// +// public static RuleEngineGlobal engineGlobal(String globalName, Object injected) { +// return new RuleEngineGlobal( +// injected.getClass().getPackage().getName(), +// injected.getClass().getSimpleName(), +// globalName, injected +// ); +// } +// +// public String fullyQualifiedName() { +// return packageName + "." + className; +// } +// +// @Override +// public String toString() { +// return "global " + className + " " + globalName + ";\n"; +// } +// +//} diff --git a/src/main/java/com/netgrif/application/engine/configuration/drools/RuleEngineGlobalsProvider.java b/src/main/java/com/netgrif/application/engine/configuration/drools/RuleEngineGlobalsProvider.java index bec5f13766..af2a99b1d2 100644 --- a/src/main/java/com/netgrif/application/engine/configuration/drools/RuleEngineGlobalsProvider.java +++ b/src/main/java/com/netgrif/application/engine/configuration/drools/RuleEngineGlobalsProvider.java @@ -1,110 +1,110 @@ -package com.netgrif.application.engine.configuration.drools; - -import com.netgrif.application.engine.auth.service.interfaces.IUserService; -import com.netgrif.application.engine.configuration.drools.interfaces.IRuleEngineGlobalsProvider; -import com.netgrif.application.engine.elastic.service.interfaces.IElasticCaseService; -import com.netgrif.application.engine.elastic.service.interfaces.IElasticTaskService; -import com.netgrif.application.engine.mail.interfaces.IMailService; -import com.netgrif.application.engine.rules.domain.FactRepository; -import com.netgrif.application.engine.rules.service.interfaces.IRuleEvaluationScheduleService; -import com.netgrif.application.engine.workflow.service.interfaces.IDataService; -import com.netgrif.application.engine.workflow.service.interfaces.ITaskService; -import com.netgrif.application.engine.workflow.service.interfaces.IWorkflowService; -import org.kie.api.runtime.KieSession; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import jakarta.annotation.PostConstruct; -import java.util.ArrayList; -import java.util.List; - -import static com.netgrif.application.engine.configuration.drools.RuleEngineGlobal.engineGlobal; - -@Service -public class RuleEngineGlobalsProvider implements IRuleEngineGlobalsProvider { - - private static final Logger log = LoggerFactory.getLogger("RuleEngine"); - private final IRuleEvaluationScheduleService ruleEvaluationScheduleService; - private final IWorkflowService workflowService; - private final ITaskService taskService; - private final IElasticCaseService elasticCaseService; - private final IElasticTaskService elasticTaskService; - private final IDataService dataService; - private final IMailService mailService; - private final IUserService userService; - private final FactRepository factRepository; - - protected List globals; - - protected List imports; - - public RuleEngineGlobalsProvider(@Autowired IRuleEvaluationScheduleService ruleEvaluationScheduleService, - @Autowired IWorkflowService workflowService, - @Autowired ITaskService taskService, - @Autowired IElasticCaseService elasticCaseService, - @Autowired IElasticTaskService elasticTaskService, - @Autowired IDataService dataService, - @Autowired IMailService mailService, - @Autowired IUserService userService, - @Autowired FactRepository factRepository) { - this.ruleEvaluationScheduleService = ruleEvaluationScheduleService; - this.workflowService = workflowService; - this.taskService = taskService; - this.elasticCaseService = elasticCaseService; - this.elasticTaskService = elasticTaskService; - this.dataService = dataService; - this.mailService = mailService; - this.userService = userService; - this.factRepository = factRepository; - } - - @PostConstruct - void postConstruct() { - this.globals = initializeGlobals(); - this.imports = initializeImports(); - } - - protected List initializeGlobals() { - List globals = new ArrayList<>(); - globals.add(engineGlobal("com.netgrif.application.engine.workflow.service.interfaces", "ITaskService", "taskService", taskService)); - globals.add(engineGlobal("com.netgrif.application.engine.auth.service.interfaces", "IUserService", "userService", userService)); - globals.add(engineGlobal("com.netgrif.application.engine.elastic.service.interfaces", "IElasticCaseService", "elasticCaseService", elasticCaseService)); - globals.add(engineGlobal("com.netgrif.application.engine.elastic.service.interfaces", "IElasticTaskService", "elasticTaskService", elasticTaskService)); - globals.add(engineGlobal("com.netgrif.application.engine.rules.domain", "FactRepository", "factRepository", factRepository)); - globals.add(engineGlobal("workflowService", workflowService)); - globals.add(engineGlobal("dataService", dataService)); - globals.add(engineGlobal("mailService", mailService)); - globals.add(engineGlobal("ruleEvaluationScheduleService", ruleEvaluationScheduleService)); - globals.add(engineGlobal("org.slf4j", "Logger", "log", log)); - return globals; - } - - protected List initializeImports() { - List imports = new ArrayList<>(); - globals.forEach(global -> imports.add(asImport(global.fullyQualifiedName()))); - imports.add(asImport("com.netgrif.application.engine.petrinet.domain.events.*")); - return imports; - } - - @Override - public List globals() { - return globals; - } - - @Override - public List imports() { - return imports; - } - - @Override - public void setGlobals(KieSession runtime) { - globals.forEach(global -> runtime.setGlobal(global.getGlobalName(), global.getInjected())); - } - - protected String asImport(String name) { - return "import " + name + ";\n"; - } - -} +//package com.netgrif.application.engine.configuration.drools; +// +//import com.netgrif.application.engine.auth.service.interfaces.IUserService; +//import com.netgrif.application.engine.configuration.drools.interfaces.IRuleEngineGlobalsProvider; +//import com.netgrif.application.engine.elastic.service.interfaces.IElasticCaseService; +//import com.netgrif.application.engine.elastic.service.interfaces.IElasticTaskService; +//import com.netgrif.application.engine.mail.interfaces.IMailService; +//import com.netgrif.application.engine.rules.domain.FactRepository; +//import com.netgrif.application.engine.rules.service.interfaces.IRuleEvaluationScheduleService; +//import com.netgrif.application.engine.workflow.service.interfaces.IDataService; +//import com.netgrif.application.engine.workflow.service.interfaces.ITaskService; +//import com.netgrif.application.engine.workflow.service.interfaces.IWorkflowService; +//import org.kie.api.runtime.KieSession; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Service; +// +//import jakarta.annotation.PostConstruct; +//import java.util.ArrayList; +//import java.util.List; +// +//import static com.netgrif.application.engine.configuration.drools.RuleEngineGlobal.engineGlobal; +// +//@Service +//public class RuleEngineGlobalsProvider implements IRuleEngineGlobalsProvider { +// +// private static final Logger log = LoggerFactory.getLogger("RuleEngine"); +// private final IRuleEvaluationScheduleService ruleEvaluationScheduleService; +// private final IWorkflowService workflowService; +// private final ITaskService taskService; +// private final IElasticCaseService elasticCaseService; +// private final IElasticTaskService elasticTaskService; +// private final IDataService dataService; +// private final IMailService mailService; +// private final IUserService userService; +// private final FactRepository factRepository; +// +// protected List globals; +// +// protected List imports; +// +// public RuleEngineGlobalsProvider(@Autowired IRuleEvaluationScheduleService ruleEvaluationScheduleService, +// @Autowired IWorkflowService workflowService, +// @Autowired ITaskService taskService, +// @Autowired IElasticCaseService elasticCaseService, +// @Autowired IElasticTaskService elasticTaskService, +// @Autowired IDataService dataService, +// @Autowired IMailService mailService, +// @Autowired IUserService userService, +// @Autowired FactRepository factRepository) { +// this.ruleEvaluationScheduleService = ruleEvaluationScheduleService; +// this.workflowService = workflowService; +// this.taskService = taskService; +// this.elasticCaseService = elasticCaseService; +// this.elasticTaskService = elasticTaskService; +// this.dataService = dataService; +// this.mailService = mailService; +// this.userService = userService; +// this.factRepository = factRepository; +// } +// +// @PostConstruct +// void postConstruct() { +// this.globals = initializeGlobals(); +// this.imports = initializeImports(); +// } +// +// protected List initializeGlobals() { +// List globals = new ArrayList<>(); +// globals.add(engineGlobal("com.netgrif.application.engine.workflow.service.interfaces", "ITaskService", "taskService", taskService)); +// globals.add(engineGlobal("com.netgrif.application.engine.auth.service.interfaces", "IUserService", "userService", userService)); +// globals.add(engineGlobal("com.netgrif.application.engine.elastic.service.interfaces", "IElasticCaseService", "elasticCaseService", elasticCaseService)); +// globals.add(engineGlobal("com.netgrif.application.engine.elastic.service.interfaces", "IElasticTaskService", "elasticTaskService", elasticTaskService)); +// globals.add(engineGlobal("com.netgrif.application.engine.rules.domain", "FactRepository", "factRepository", factRepository)); +// globals.add(engineGlobal("workflowService", workflowService)); +// globals.add(engineGlobal("dataService", dataService)); +// globals.add(engineGlobal("mailService", mailService)); +// globals.add(engineGlobal("ruleEvaluationScheduleService", ruleEvaluationScheduleService)); +// globals.add(engineGlobal("org.slf4j", "Logger", "log", log)); +// return globals; +// } +// +// protected List initializeImports() { +// List imports = new ArrayList<>(); +// globals.forEach(global -> imports.add(asImport(global.fullyQualifiedName()))); +// imports.add(asImport("com.netgrif.application.engine.petrinet.domain.events.*")); +// return imports; +// } +// +// @Override +// public List globals() { +// return globals; +// } +// +// @Override +// public List imports() { +// return imports; +// } +// +// @Override +// public void setGlobals(KieSession runtime) { +// globals.forEach(global -> runtime.setGlobal(global.getGlobalName(), global.getInjected())); +// } +// +// protected String asImport(String name) { +// return "import " + name + ";\n"; +// } +// +//} diff --git a/src/main/java/com/netgrif/application/engine/configuration/drools/interfaces/IKnowledgeBaseInitializer.java b/src/main/java/com/netgrif/application/engine/configuration/drools/interfaces/IKnowledgeBaseInitializer.java index 8a785c675a..cedf77368a 100644 --- a/src/main/java/com/netgrif/application/engine/configuration/drools/interfaces/IKnowledgeBaseInitializer.java +++ b/src/main/java/com/netgrif/application/engine/configuration/drools/interfaces/IKnowledgeBaseInitializer.java @@ -1,15 +1,15 @@ -package com.netgrif.application.engine.configuration.drools.interfaces; - -import com.netgrif.application.engine.configuration.drools.throwable.RuleValidationException; -import com.netgrif.application.engine.rules.domain.StoredRule; -import org.kie.api.KieBase; -import org.springframework.stereotype.Service; - -import java.util.List; - -public interface IKnowledgeBaseInitializer { - - KieBase constructKieBase(); - - void validate(List storedRule) throws RuleValidationException; -} +//package com.netgrif.application.engine.configuration.drools.interfaces; +// +//import com.netgrif.application.engine.configuration.drools.throwable.RuleValidationException; +//import com.netgrif.application.engine.rules.domain.StoredRule; +//import org.kie.api.KieBase; +//import org.springframework.stereotype.Service; +// +//import java.util.List; +// +//public interface IKnowledgeBaseInitializer { +// +// KieBase constructKieBase(); +// +// void validate(List storedRule) throws RuleValidationException; +//} diff --git a/src/main/java/com/netgrif/application/engine/configuration/drools/interfaces/IRefreshableKieBase.java b/src/main/java/com/netgrif/application/engine/configuration/drools/interfaces/IRefreshableKieBase.java index f3c6918538..4ade15b21c 100644 --- a/src/main/java/com/netgrif/application/engine/configuration/drools/interfaces/IRefreshableKieBase.java +++ b/src/main/java/com/netgrif/application/engine/configuration/drools/interfaces/IRefreshableKieBase.java @@ -1,12 +1,12 @@ -package com.netgrif.application.engine.configuration.drools.interfaces; - -import org.kie.api.KieBase; - -public interface IRefreshableKieBase { - - KieBase kieBase(); - - boolean shouldRefresh(); - - void refresh(); -} +//package com.netgrif.application.engine.configuration.drools.interfaces; +// +//import org.kie.api.KieBase; +// +//public interface IRefreshableKieBase { +// +// KieBase kieBase(); +// +// boolean shouldRefresh(); +// +// void refresh(); +//} diff --git a/src/main/java/com/netgrif/application/engine/configuration/drools/interfaces/IRuleEngineGlobalsProvider.java b/src/main/java/com/netgrif/application/engine/configuration/drools/interfaces/IRuleEngineGlobalsProvider.java index dbc8600db2..3d2083bb44 100644 --- a/src/main/java/com/netgrif/application/engine/configuration/drools/interfaces/IRuleEngineGlobalsProvider.java +++ b/src/main/java/com/netgrif/application/engine/configuration/drools/interfaces/IRuleEngineGlobalsProvider.java @@ -1,15 +1,15 @@ -package com.netgrif.application.engine.configuration.drools.interfaces; - -import com.netgrif.application.engine.configuration.drools.RuleEngineGlobal; -import org.kie.api.runtime.KieSession; - -import java.util.List; - -public interface IRuleEngineGlobalsProvider { - - List globals(); - - List imports(); - - void setGlobals(KieSession session); -} +//package com.netgrif.application.engine.configuration.drools.interfaces; +// +//import com.netgrif.application.engine.configuration.drools.RuleEngineGlobal; +//import org.kie.api.runtime.KieSession; +// +//import java.util.List; +// +//public interface IRuleEngineGlobalsProvider { +// +// List globals(); +// +// List imports(); +// +// void setGlobals(KieSession session); +//} diff --git a/src/main/java/com/netgrif/application/engine/configuration/drools/throwable/RuleValidationException.java b/src/main/java/com/netgrif/application/engine/configuration/drools/throwable/RuleValidationException.java index 29b32f75bb..70e3c912f2 100644 --- a/src/main/java/com/netgrif/application/engine/configuration/drools/throwable/RuleValidationException.java +++ b/src/main/java/com/netgrif/application/engine/configuration/drools/throwable/RuleValidationException.java @@ -1,8 +1,8 @@ -package com.netgrif.application.engine.configuration.drools.throwable; - -public class RuleValidationException extends Exception { - - public RuleValidationException(Exception e) { - super("Validation failed", e); - } -} +//package com.netgrif.application.engine.configuration.drools.throwable; +// +//public class RuleValidationException extends Exception { +// +// public RuleValidationException(Exception e) { +// super("Validation failed", e); +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/event/dispatchers/common/AbstractDispatcher.java b/src/main/java/com/netgrif/application/engine/event/dispatchers/common/AbstractDispatcher.java index e075e3214b..6124314ed7 100644 --- a/src/main/java/com/netgrif/application/engine/event/dispatchers/common/AbstractDispatcher.java +++ b/src/main/java/com/netgrif/application/engine/event/dispatchers/common/AbstractDispatcher.java @@ -2,16 +2,19 @@ import com.netgrif.application.engine.event.events.Event; import com.netgrif.application.engine.event.events.EventAction; +import com.netgrif.application.engine.event.events.task.TaskEvent; +import com.netgrif.application.engine.event.listeners.ContextEditingListener; import com.netgrif.application.engine.event.listeners.Listener; +import com.netgrif.application.engine.workflow.domain.Task; import lombok.Getter; import lombok.extern.slf4j.Slf4j; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.function.Function; +import java.util.stream.Collectors; + +import static java.util.stream.Collectors.groupingBy; @Slf4j public abstract class AbstractDispatcher { @@ -107,7 +110,9 @@ public boolean isListenerRegistered(RegisteredListener registeredListener) { */ protected void dispatch(Event event, AbstractDispatcher dispatcher, Function foo) { List> futures = new ArrayList<>(); - for (RegisteredListener registeredListener : registeredListeners) { + List simpleListeners = registeredListeners.stream().filter(l -> !(l.listener() instanceof ContextEditingListener)).toList(); + List contextEditingListeners = registeredListeners.stream().filter(l -> l.listener() instanceof ContextEditingListener).toList(); + for (RegisteredListener registeredListener : simpleListeners) { CompletableFuture future = CompletableFuture.runAsync(() -> { if (foo.apply(registeredListener)) { log.trace("Sending event with message {} synchronously", event.getMessage()); @@ -117,6 +122,12 @@ protected void dispatch(Event event, AbstractDispatcher dispatcher, Function) registeredListener.listener()).onContextEditingEvent(updatedEvent, dispatcher); + } + } } /*** diff --git a/src/main/java/com/netgrif/application/engine/event/events/Event.java b/src/main/java/com/netgrif/application/engine/event/events/Event.java index 82a977bd4b..bebdd6357e 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/Event.java +++ b/src/main/java/com/netgrif/application/engine/event/events/Event.java @@ -1,12 +1,17 @@ package com.netgrif.application.engine.event.events; +import com.netgrif.application.engine.petrinet.domain.events.EventPhase; import lombok.Getter; import org.springframework.context.ApplicationEvent; +import java.io.Serial; import java.time.LocalDateTime; public abstract class Event extends ApplicationEvent { - + @Serial + private static final long serialVersionUID = -9102232475981679124L; + @Getter + private EventPhase eventPhase; @Getter protected LocalDateTime time; @@ -15,5 +20,10 @@ public Event(Object source) { this.time = LocalDateTime.now(); } + public Event(Object source, EventPhase eventPhase) { + super(source); + this.eventPhase = eventPhase; + } + public abstract String getMessage(); } \ No newline at end of file diff --git a/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeleteEvent.java b/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeleteEvent.java index 7c0b2565b8..9d61764b83 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeleteEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeleteEvent.java @@ -1,16 +1,16 @@ package com.netgrif.application.engine.event.events.petrinet; -import com.netgrif.application.engine.event.events.Event; import com.netgrif.application.engine.petrinet.domain.PetriNet; +import com.netgrif.application.engine.petrinet.domain.events.EventPhase; import lombok.Getter; @Getter -public class ProcessDeleteEvent extends Event { +public class ProcessDeleteEvent extends ProcessEvent { protected PetriNet petriNet; - public ProcessDeleteEvent(PetriNet petriNet) { - super(petriNet); + public ProcessDeleteEvent(PetriNet petriNet, EventPhase phase) { + super(petriNet, phase); this.petriNet = petriNet; } diff --git a/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeployEvent.java b/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeployEvent.java index ae68e5b38e..2a3d2df242 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeployEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessDeployEvent.java @@ -1,14 +1,15 @@ package com.netgrif.application.engine.event.events.petrinet; import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.petrinet.domain.events.EventPhase; import com.netgrif.application.engine.workflow.domain.eventoutcomes.petrinetoutcomes.ImportPetriNetEventOutcome; -public class ProcessDeployEvent extends Event { +public class ProcessDeployEvent extends ProcessEvent { protected final ImportPetriNetEventOutcome eventOutcome; - public ProcessDeployEvent(ImportPetriNetEventOutcome eventOutcome) { - super(eventOutcome); + public ProcessDeployEvent(ImportPetriNetEventOutcome eventOutcome, EventPhase eventPhase) { + super(eventOutcome, eventPhase); this.eventOutcome = eventOutcome; } diff --git a/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessEvent.java b/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessEvent.java new file mode 100644 index 0000000000..fde7e4d1bb --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/events/petrinet/ProcessEvent.java @@ -0,0 +1,14 @@ +package com.netgrif.application.engine.event.events.petrinet; + +import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.petrinet.domain.events.EventPhase; + +public abstract class ProcessEvent extends Event { + public ProcessEvent(Object source) { + super(source); + } + + public ProcessEvent(Object source, EventPhase eventPhase) { + super(source, eventPhase); + } +} diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/AssignTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/AssignTaskEvent.java index 1a41d6f53e..5cae0724cc 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/task/AssignTaskEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/task/AssignTaskEvent.java @@ -1,11 +1,12 @@ package com.netgrif.application.engine.event.events.task; +import com.netgrif.application.engine.petrinet.domain.events.EventPhase; import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.AssignTaskEventOutcome; public class AssignTaskEvent extends TaskEvent { - public AssignTaskEvent(AssignTaskEventOutcome eventOutcome) { - super(eventOutcome); + public AssignTaskEvent(AssignTaskEventOutcome eventOutcome, EventPhase eventPhase) { + super(eventOutcome, eventPhase); } @Override diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/CancelTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/CancelTaskEvent.java index 0b7cb5e9f9..db36e14b28 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/task/CancelTaskEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/task/CancelTaskEvent.java @@ -1,11 +1,12 @@ package com.netgrif.application.engine.event.events.task; +import com.netgrif.application.engine.petrinet.domain.events.EventPhase; import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.CancelTaskEventOutcome; public class CancelTaskEvent extends TaskEvent { - public CancelTaskEvent(CancelTaskEventOutcome eventOutcome) { - super(eventOutcome); + public CancelTaskEvent(CancelTaskEventOutcome eventOutcome, EventPhase eventPhase) { + super(eventOutcome, eventPhase); } @Override diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/CreateTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/CreateTaskEvent.java index b327c91995..332fa54008 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/task/CreateTaskEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/task/CreateTaskEvent.java @@ -1,11 +1,12 @@ package com.netgrif.application.engine.event.events.task; +import com.netgrif.application.engine.petrinet.domain.events.EventPhase; import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.TaskEventOutcome; public class CreateTaskEvent extends TaskEvent { - public CreateTaskEvent(TaskEventOutcome eventOutcome) { - super(eventOutcome); + public CreateTaskEvent(TaskEventOutcome eventOutcome, EventPhase eventPhase) { + super(eventOutcome, eventPhase); } @Override diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/DelegateTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/DelegateTaskEvent.java index 2f8cb4ea86..a47785da77 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/task/DelegateTaskEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/task/DelegateTaskEvent.java @@ -1,11 +1,12 @@ package com.netgrif.application.engine.event.events.task; +import com.netgrif.application.engine.petrinet.domain.events.EventPhase; import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.DelegateTaskEventOutcome; public class DelegateTaskEvent extends TaskEvent { - public DelegateTaskEvent(DelegateTaskEventOutcome eventOutcome) { - super(eventOutcome); + public DelegateTaskEvent(DelegateTaskEventOutcome eventOutcome, EventPhase eventPhase) { + super(eventOutcome, eventPhase); } @Override diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/FinishTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/FinishTaskEvent.java index 21fbd8a7e3..f80ab6f1cb 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/task/FinishTaskEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/task/FinishTaskEvent.java @@ -1,11 +1,12 @@ package com.netgrif.application.engine.event.events.task; +import com.netgrif.application.engine.petrinet.domain.events.EventPhase; import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.FinishTaskEventOutcome; public class FinishTaskEvent extends TaskEvent { - public FinishTaskEvent(FinishTaskEventOutcome eventOutcome) { - super(eventOutcome); + public FinishTaskEvent(FinishTaskEventOutcome eventOutcome, EventPhase eventPhase) { + super(eventOutcome, eventPhase); } @Override diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/TaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/TaskEvent.java index 067004dfd1..48530cc9f9 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/task/TaskEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/task/TaskEvent.java @@ -1,6 +1,7 @@ package com.netgrif.application.engine.event.events.task; import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.petrinet.domain.events.EventPhase; import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.TaskEventOutcome; import lombok.Getter; @@ -10,8 +11,9 @@ public abstract class TaskEvent extends Event { protected final TaskEventOutcome taskEventOutcome; - public TaskEvent(TaskEventOutcome eventOutcome) { - super(eventOutcome); + public TaskEvent(TaskEventOutcome eventOutcome, EventPhase phase) { + super(eventOutcome, phase); this.taskEventOutcome = eventOutcome; } + } diff --git a/src/main/java/com/netgrif/application/engine/event/events/workflow/CaseEvent.java b/src/main/java/com/netgrif/application/engine/event/events/workflow/CaseEvent.java index c8e164d14c..d112f780a3 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/workflow/CaseEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/workflow/CaseEvent.java @@ -1,14 +1,17 @@ package com.netgrif.application.engine.event.events.workflow; import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.petrinet.domain.events.EventPhase; import com.netgrif.application.engine.workflow.domain.eventoutcomes.caseoutcomes.CaseEventOutcome; +import lombok.Getter; +@Getter public abstract class CaseEvent extends Event { protected final CaseEventOutcome caseEventOutcome; - public CaseEvent(CaseEventOutcome caseEventOutcome) { - super(caseEventOutcome); + public CaseEvent(CaseEventOutcome caseEventOutcome, EventPhase eventPhase) { + super(caseEventOutcome, eventPhase); this.caseEventOutcome = caseEventOutcome; } diff --git a/src/main/java/com/netgrif/application/engine/event/events/workflow/CreateCaseEvent.java b/src/main/java/com/netgrif/application/engine/event/events/workflow/CreateCaseEvent.java index bb8ffcef13..fd9e495be4 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/workflow/CreateCaseEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/workflow/CreateCaseEvent.java @@ -1,11 +1,12 @@ package com.netgrif.application.engine.event.events.workflow; +import com.netgrif.application.engine.petrinet.domain.events.EventPhase; import com.netgrif.application.engine.workflow.domain.eventoutcomes.caseoutcomes.CreateCaseEventOutcome; public class CreateCaseEvent extends CaseEvent { - public CreateCaseEvent(CreateCaseEventOutcome caseEventOutcome) { - super(caseEventOutcome); + public CreateCaseEvent(CreateCaseEventOutcome caseEventOutcome, EventPhase phase) { + super(caseEventOutcome, phase); } @Override diff --git a/src/main/java/com/netgrif/application/engine/event/events/workflow/DeleteCaseEvent.java b/src/main/java/com/netgrif/application/engine/event/events/workflow/DeleteCaseEvent.java index 1fdca52531..7784bceb9d 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/workflow/DeleteCaseEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/workflow/DeleteCaseEvent.java @@ -1,11 +1,12 @@ package com.netgrif.application.engine.event.events.workflow; +import com.netgrif.application.engine.petrinet.domain.events.EventPhase; import com.netgrif.application.engine.workflow.domain.eventoutcomes.caseoutcomes.DeleteCaseEventOutcome; public class DeleteCaseEvent extends CaseEvent { - public DeleteCaseEvent(DeleteCaseEventOutcome caseEventOutcome) { - super(caseEventOutcome); + public DeleteCaseEvent(DeleteCaseEventOutcome caseEventOutcome, EventPhase eventPhase) { + super(caseEventOutcome, eventPhase); } @Override diff --git a/src/main/java/com/netgrif/application/engine/event/listeners/ContextEditingListener.java b/src/main/java/com/netgrif/application/engine/event/listeners/ContextEditingListener.java new file mode 100644 index 0000000000..842470e62a --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/listeners/ContextEditingListener.java @@ -0,0 +1,24 @@ +package com.netgrif.application.engine.event.listeners; + +import com.netgrif.application.engine.event.dispatchers.common.AbstractDispatcher; +import com.netgrif.application.engine.event.dispatchers.common.DispatchMethod; +import com.netgrif.application.engine.event.events.Event; +import com.netgrif.application.engine.event.events.EventAction; + +public abstract class ContextEditingListener extends Listener { + + public ContextEditingListener() { + } + + public ContextEditingListener(AbstractDispatcher dispatcher, EventAction eventAction, DispatchMethod method) { + super(dispatcher, eventAction, method); + } + + /*** + *

Abstract method for handling synchronous events with return. This method will be invoked by Dispatcher if the Listener is registered. + * See {@link AbstractDispatcher#registerListener(Listener, EventAction, DispatchMethod)}

+ * @param event {@link Event} object, final type of the object is determined based on {@link EventAction} + * @param dispatcher {@link AbstractDispatcher} from which the event was dispatched + */ + public abstract T onContextEditingEvent(Event event, AbstractDispatcher dispatcher); +} diff --git a/src/main/java/com/netgrif/application/engine/event/listeners/RuleEventListener.java b/src/main/java/com/netgrif/application/engine/event/listeners/RuleEventListener.java new file mode 100644 index 0000000000..7d72006dcf --- /dev/null +++ b/src/main/java/com/netgrif/application/engine/event/listeners/RuleEventListener.java @@ -0,0 +1,52 @@ +//package com.netgrif.application.engine.event.listeners; +// +//import com.netgrif.application.engine.event.dispatchers.common.AbstractDispatcher; +//import com.netgrif.application.engine.event.dispatchers.common.DispatchMethod; +//import com.netgrif.application.engine.event.events.Event; +//import com.netgrif.application.engine.event.events.EventAction; +//import com.netgrif.application.engine.event.events.task.TaskEvent; +//import com.netgrif.application.engine.workflow.domain.Case; +//import com.netgrif.application.engine.workflow.domain.Task; +//import com.netgrif.application.engine.workflow.service.interfaces.IWorkflowService; +//import com.netgrif.netgrifdrools.rules.domain.facts.TransitionEventFact; +//import com.netgrif.netgrifdrools.rules.service.interfaces.IRuleEngine; +//import lombok.extern.slf4j.Slf4j; +// +//@Slf4j +//public class RuleEventListener extends ContextEditingListener { +// private final IWorkflowService workflowService; +// private final IRuleEngine ruleEngine; +// +// public RuleEventListener(AbstractDispatcher dispatcher, EventAction eventAction, DispatchMethod method, +// IWorkflowService workflowService, IRuleEngine ruleEngine) { +// super(dispatcher, eventAction, method); +// this.workflowService = workflowService; +// this.ruleEngine = ruleEngine; +// } +// +// @Override +// public TaskEvent onContextEditingEvent(Event event, AbstractDispatcher dispatcher) { +// TaskEvent taskEvent = (TaskEvent) event; +// Case useCase = taskEvent.getTaskEventOutcome().getCase(); +// Task task = taskEvent.getTaskEventOutcome().getTask(); +// log.info("[" + useCase.getStringId() + "]: Task [" + task.getTitle() + "] in case [" + useCase.getTitle() + "] evaluating rules of event " + taskEvent.getEventType().name() + " of phase " + taskEvent.getEventPhase().name()); +// int rulesExecuted = ruleEngine.evaluateRules(useCase, task, TransitionEventFact.of(task, taskEvent.getEventType(), taskEvent.getEventPhase())); +// if (rulesExecuted == 0) { +// taskEvent.getTaskEventOutcome().setCase(useCase); +// taskEvent.getTaskEventOutcome().setTask(task); +// return taskEvent; +// } +// taskEvent.getTaskEventOutcome().setCase(workflowService.save(useCase)); +// return taskEvent; +// } +// +// @Override +// public void onEvent(Event event, AbstractDispatcher dispatcher) { +// +// } +// +// @Override +// public void onAsyncEvent(Event event, AbstractDispatcher dispatcher) { +// +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java b/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java index 1ccf7e1cab..6ccfd0f49e 100644 --- a/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java +++ b/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java @@ -7,6 +7,7 @@ import com.netgrif.application.engine.configuration.properties.CacheProperties; import com.netgrif.application.engine.elastic.service.interfaces.IElasticPetriNetMappingService; import com.netgrif.application.engine.elastic.service.interfaces.IElasticPetriNetService; +import com.netgrif.application.engine.event.events.Event; import com.netgrif.application.engine.event.events.petrinet.ProcessDeleteEvent; import com.netgrif.application.engine.event.events.petrinet.ProcessDeployEvent; import com.netgrif.application.engine.history.domain.petrinetevents.DeletePetriNetEventLog; @@ -32,8 +33,8 @@ import com.netgrif.application.engine.petrinet.service.interfaces.IProcessRoleService; import com.netgrif.application.engine.petrinet.service.interfaces.IUriService; import com.netgrif.application.engine.petrinet.web.responsebodies.*; -import com.netgrif.application.engine.rules.domain.facts.NetImportedFact; -import com.netgrif.application.engine.rules.service.interfaces.IRuleEngine; +//import com.netgrif.application.engine.rules.domain.facts.NetImportedFact; +//import com.netgrif.application.engine.rules.service.interfaces.IRuleEngine; import com.netgrif.application.engine.workflow.domain.Case; import com.netgrif.application.engine.workflow.domain.FileStorageConfiguration; import com.netgrif.application.engine.workflow.domain.eventoutcomes.petrinetoutcomes.ImportPetriNetEventOutcome; @@ -88,8 +89,8 @@ public class PetriNetService implements IPetriNetService { @Autowired protected FileStorageConfiguration fileStorageConfiguration; - @Autowired - protected IRuleEngine ruleEngine; +// @Autowired +// protected IRuleEngine ruleEngine; @Autowired protected IWorkflowService workflowService; @@ -243,15 +244,17 @@ public ImportPetriNetEventOutcome importPetriNet(InputStream xmlFile, VersionTyp log.info("Petri net " + net.getTitle() + " (" + net.getInitials() + " v" + net.getVersion() + ") imported successfully and saved in a folder: " + savedPath.toString()); outcome.setOutcomes(eventService.runActions(net.getPreUploadActions(), null, Optional.empty(), params)); - evaluateRules(net, EventPhase.PRE); +// evaluateRules(net, EventPhase.PRE); + publisher.publishEvent(new ProcessDeployEvent(outcome, EventPhase.PRE)); historyService.save(new ImportPetriNetEventLog(null, EventPhase.PRE, net.getObjectId())); save(net); outcome.setOutcomes(eventService.runActions(net.getPostUploadActions(), null, Optional.empty(), params)); - evaluateRules(net, EventPhase.POST); +// evaluateRules(net, EventPhase.POST); + publisher.publishEvent(new ProcessDeployEvent(outcome, EventPhase.POST)); historyService.save(new ImportPetriNetEventLog(null, EventPhase.POST, net.getObjectId())); addMessageToOutcome(net, ProcessEventType.UPLOAD, outcome); outcome.setNet(imported.get()); - publisher.publishEvent(new ProcessDeployEvent(outcome)); +// publisher.publishEvent(new ProcessDeployEvent(outcome)); return outcome; } @@ -262,11 +265,9 @@ private ImportPetriNetEventOutcome addMessageToOutcome(PetriNet net, ProcessEven return outcome; } - protected void evaluateRules(PetriNet net, EventPhase phase) { - int rulesExecuted = ruleEngine.evaluateRules(net, new NetImportedFact(net.getStringId(), phase)); - if (rulesExecuted > 0) { - save(net); - } + protected void evaluateRules(Event event) { + publisher.publishEvent(event); + } @Override @@ -563,7 +564,7 @@ public void deletePetriNet(String processId, LoggedUser loggedUser) { // net functions must be removed from cache after it was deleted from repository this.functionCacheService.reloadCachedFunctions(petriNet); historyService.save(new DeletePetriNetEventLog(null, EventPhase.PRE, petriNet.getObjectId())); - publisher.publishEvent(new ProcessDeleteEvent(petriNet)); + publisher.publishEvent(new ProcessDeleteEvent(petriNet, EventPhase.POST)); } private Criteria getProcessRolesCriteria(LoggedUser user) { diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/FactRepository.java b/src/main/java/com/netgrif/application/engine/rules/domain/FactRepository.java index 872031213e..ef51e525d5 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/FactRepository.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/FactRepository.java @@ -1,13 +1,13 @@ -package com.netgrif.application.engine.rules.domain; - -import com.netgrif.application.engine.rules.domain.facts.Fact; -import org.bson.types.ObjectId; -import org.springframework.data.mongodb.repository.MongoRepository; -import org.springframework.data.querydsl.QuerydslPredicateExecutor; -import org.springframework.stereotype.Repository; - - -@Repository -public interface FactRepository extends MongoRepository, QuerydslPredicateExecutor { - -} \ No newline at end of file +//package com.netgrif.application.engine.rules.domain; +// +//import com.netgrif.application.engine.rules.domain.facts.Fact; +//import org.bson.types.ObjectId; +//import org.springframework.data.mongodb.repository.MongoRepository; +//import org.springframework.data.querydsl.QuerydslPredicateExecutor; +//import org.springframework.stereotype.Repository; +// +// +//@Repository +//public interface FactRepository extends MongoRepository, QuerydslPredicateExecutor { +// +//} \ No newline at end of file diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/RuleRepository.java b/src/main/java/com/netgrif/application/engine/rules/domain/RuleRepository.java index 191da46b6b..e3a51738fe 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/RuleRepository.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/RuleRepository.java @@ -1,19 +1,19 @@ -package com.netgrif.application.engine.rules.domain; - -import org.bson.types.ObjectId; -import org.springframework.data.mongodb.repository.MongoRepository; -import org.springframework.data.querydsl.QuerydslPredicateExecutor; -import org.springframework.stereotype.Repository; - -import java.time.LocalDateTime; -import java.util.List; - -@Repository -public interface RuleRepository extends MongoRepository, QuerydslPredicateExecutor { - - boolean existsByLastUpdateAfter(LocalDateTime time); - - StoredRule findByIdentifier(String identifier); - - List findByIdentifierIn(List identifiers); -} \ No newline at end of file +//package com.netgrif.application.engine.rules.domain; +// +//import org.bson.types.ObjectId; +//import org.springframework.data.mongodb.repository.MongoRepository; +//import org.springframework.data.querydsl.QuerydslPredicateExecutor; +//import org.springframework.stereotype.Repository; +// +//import java.time.LocalDateTime; +//import java.util.List; +// +//@Repository +//public interface RuleRepository extends MongoRepository, QuerydslPredicateExecutor { +// +// boolean existsByLastUpdateAfter(LocalDateTime time); +// +// StoredRule findByIdentifier(String identifier); +// +// List findByIdentifierIn(List identifiers); +//} \ No newline at end of file diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/StoredRule.java b/src/main/java/com/netgrif/application/engine/rules/domain/StoredRule.java index 561cc98476..1a267050be 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/StoredRule.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/StoredRule.java @@ -1,59 +1,59 @@ -package com.netgrif.application.engine.rules.domain; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import org.bson.types.ObjectId; -import org.springframework.data.annotation.Id; -import org.springframework.data.mongodb.core.index.Indexed; -import org.springframework.data.mongodb.core.mapping.Document; - -import javax.validation.constraints.NotNull; -import java.time.LocalDate; -import java.time.LocalDateTime; - - -@Data -@Builder -@Document -@AllArgsConstructor -public class StoredRule { - - @Id - private ObjectId _id; - - @Indexed - private String identifier; - - @NotNull - private String when; - - @NotNull - private String then; - - private boolean enabled = true; - - private LocalDate dateEffective; - - private LocalDate dateExpires; - - private int salience = 1; - - @Indexed - private LocalDateTime lastUpdate; - - @Indexed - private LocalDateTime creationDate; - - public StoredRule() { - _id = new ObjectId(); - identifier = _id.toString(); - lastUpdate = LocalDateTime.now(); - creationDate = LocalDateTime.now(); - } - - public String getStringId() { - return _id.toString(); - } - -} +//package com.netgrif.application.engine.rules.domain; +// +//import lombok.AllArgsConstructor; +//import lombok.Builder; +//import lombok.Data; +//import org.bson.types.ObjectId; +//import org.springframework.data.annotation.Id; +//import org.springframework.data.mongodb.core.index.Indexed; +//import org.springframework.data.mongodb.core.mapping.Document; +// +//import javax.validation.constraints.NotNull; +//import java.time.LocalDate; +//import java.time.LocalDateTime; +// +// +//@Data +//@Builder +//@Document +//@AllArgsConstructor +//public class StoredRule { +// +// @Id +// private ObjectId _id; +// +// @Indexed +// private String identifier; +// +// @NotNull +// private String when; +// +// @NotNull +// private String then; +// +// private boolean enabled = true; +// +// private LocalDate dateEffective; +// +// private LocalDate dateExpires; +// +// private int salience = 1; +// +// @Indexed +// private LocalDateTime lastUpdate; +// +// @Indexed +// private LocalDateTime creationDate; +// +// public StoredRule() { +// _id = new ObjectId(); +// identifier = _id.toString(); +// lastUpdate = LocalDateTime.now(); +// creationDate = LocalDateTime.now(); +// } +// +// public String getStringId() { +// return _id.toString(); +// } +// +//} diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/facts/CaseCreatedFact.java b/src/main/java/com/netgrif/application/engine/rules/domain/facts/CaseCreatedFact.java index 96b5ad715f..35e2f022fb 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/facts/CaseCreatedFact.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/facts/CaseCreatedFact.java @@ -1,21 +1,21 @@ -package com.netgrif.application.engine.rules.domain.facts; - -import com.netgrif.application.engine.petrinet.domain.events.EventPhase; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.springframework.data.mongodb.core.mapping.Document; - -@Data -@Document -@EqualsAndHashCode(callSuper = true) -public class CaseCreatedFact extends CaseFact { - - private EventPhase eventPhase; - - public CaseCreatedFact(String caseId, EventPhase eventPhase) { - super(caseId); - this.eventPhase = eventPhase; - } - -} - +//package com.netgrif.application.engine.rules.domain.facts; +// +//import com.netgrif.application.engine.petrinet.domain.events.EventPhase; +//import lombok.Data; +//import lombok.EqualsAndHashCode; +//import org.springframework.data.mongodb.core.mapping.Document; +// +//@Data +//@Document +//@EqualsAndHashCode(callSuper = true) +//public class CaseCreatedFact extends CaseFact { +// +// private EventPhase eventPhase; +// +// public CaseCreatedFact(String caseId, EventPhase eventPhase) { +// super(caseId); +// this.eventPhase = eventPhase; +// } +// +//} +// diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/facts/CaseFact.java b/src/main/java/com/netgrif/application/engine/rules/domain/facts/CaseFact.java index 0c12ca6d79..052a122d59 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/facts/CaseFact.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/facts/CaseFact.java @@ -1,16 +1,16 @@ -package com.netgrif.application.engine.rules.domain.facts; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -@EqualsAndHashCode(callSuper = true) -@Data -public abstract class CaseFact extends Fact { - - private String caseId; - - public CaseFact(String caseId) { - super(); - this.caseId = caseId; - } -} +//package com.netgrif.application.engine.rules.domain.facts; +// +//import lombok.Data; +//import lombok.EqualsAndHashCode; +// +//@EqualsAndHashCode(callSuper = true) +//@Data +//public abstract class CaseFact extends Fact { +// +// private String caseId; +// +// public CaseFact(String caseId) { +// super(); +// this.caseId = caseId; +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/facts/Fact.java b/src/main/java/com/netgrif/application/engine/rules/domain/facts/Fact.java index bbec842253..edcba791a1 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/facts/Fact.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/facts/Fact.java @@ -1,23 +1,23 @@ -package com.netgrif.application.engine.rules.domain.facts; - -import lombok.Data; -import org.bson.types.ObjectId; -import org.springframework.data.annotation.Id; -import org.springframework.data.mongodb.core.mapping.Document; - -import java.time.LocalDateTime; - -@Document -@Data -public abstract class Fact { - - @Id - private ObjectId _id; - - private LocalDateTime creationDate; - - public Fact() { - _id = new ObjectId(); - creationDate = LocalDateTime.now(); - } -} +//package com.netgrif.application.engine.rules.domain.facts; +// +//import lombok.Data; +//import org.bson.types.ObjectId; +//import org.springframework.data.annotation.Id; +//import org.springframework.data.mongodb.core.mapping.Document; +// +//import java.time.LocalDateTime; +// +//@Document +//@Data +//public abstract class Fact { +// +// @Id +// private ObjectId _id; +// +// private LocalDateTime creationDate; +// +// public Fact() { +// _id = new ObjectId(); +// creationDate = LocalDateTime.now(); +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/facts/NetImportedFact.java b/src/main/java/com/netgrif/application/engine/rules/domain/facts/NetImportedFact.java index 6bef3ded4f..662272f634 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/facts/NetImportedFact.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/facts/NetImportedFact.java @@ -1,17 +1,17 @@ -package com.netgrif.application.engine.rules.domain.facts; - -import com.netgrif.application.engine.petrinet.domain.events.EventPhase; -import lombok.Data; -import lombok.EqualsAndHashCode; - -@Data -@EqualsAndHashCode(callSuper = true) -public class NetImportedFact extends PetriNetFact { - - private EventPhase eventPhase; - - public NetImportedFact(String netId, EventPhase eventPhase) { - super(netId); - this.eventPhase = eventPhase; - } -} +//package com.netgrif.application.engine.rules.domain.facts; +// +//import com.netgrif.application.engine.petrinet.domain.events.EventPhase; +//import lombok.Data; +//import lombok.EqualsAndHashCode; +// +//@Data +//@EqualsAndHashCode(callSuper = true) +//public class NetImportedFact extends PetriNetFact { +// +// private EventPhase eventPhase; +// +// public NetImportedFact(String netId, EventPhase eventPhase) { +// super(netId); +// this.eventPhase = eventPhase; +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/facts/PetriNetFact.java b/src/main/java/com/netgrif/application/engine/rules/domain/facts/PetriNetFact.java index 93524faa11..a4cfd9ae9e 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/facts/PetriNetFact.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/facts/PetriNetFact.java @@ -1,16 +1,16 @@ -package com.netgrif.application.engine.rules.domain.facts; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -@EqualsAndHashCode(callSuper = true) -@Data -public abstract class PetriNetFact extends Fact { - - private String netId; - - public PetriNetFact(String netId) { - super(); - this.netId = netId; - } -} +//package com.netgrif.application.engine.rules.domain.facts; +// +//import lombok.Data; +//import lombok.EqualsAndHashCode; +// +//@EqualsAndHashCode(callSuper = true) +//@Data +//public abstract class PetriNetFact extends Fact { +// +// private String netId; +// +// public PetriNetFact(String netId) { +// super(); +// this.netId = netId; +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/facts/RuleEvaluation.java b/src/main/java/com/netgrif/application/engine/rules/domain/facts/RuleEvaluation.java index 9787720f7a..c4f7248a1c 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/facts/RuleEvaluation.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/facts/RuleEvaluation.java @@ -1,22 +1,22 @@ -package com.netgrif.application.engine.rules.domain.facts; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -import java.time.LocalDateTime; - -@EqualsAndHashCode(callSuper = true) -@Data -@NoArgsConstructor -@AllArgsConstructor -public class RuleEvaluation extends Fact { - - private String caseId; - - private LocalDateTime evaluationTime; - -} - - +//package com.netgrif.application.engine.rules.domain.facts; +// +//import lombok.AllArgsConstructor; +//import lombok.Data; +//import lombok.EqualsAndHashCode; +//import lombok.NoArgsConstructor; +// +//import java.time.LocalDateTime; +// +//@EqualsAndHashCode(callSuper = true) +//@Data +//@NoArgsConstructor +//@AllArgsConstructor +//public class RuleEvaluation extends Fact { +// +// private String caseId; +// +// private LocalDateTime evaluationTime; +// +//} +// +// diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/facts/ScheduledRuleFact.java b/src/main/java/com/netgrif/application/engine/rules/domain/facts/ScheduledRuleFact.java index 2b355b8ddf..dae6384080 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/facts/ScheduledRuleFact.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/facts/ScheduledRuleFact.java @@ -1,20 +1,20 @@ -package com.netgrif.application.engine.rules.domain.facts; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -@EqualsAndHashCode(callSuper = true) -@Data -public class ScheduledRuleFact extends Fact { - - private String instanceId; - private String ruleIdentifier; - - public ScheduledRuleFact(String instanceId, String ruleIdentifier) { - super(); - this.instanceId = instanceId; - this.ruleIdentifier = ruleIdentifier; - } -} - - +//package com.netgrif.application.engine.rules.domain.facts; +// +//import lombok.Data; +//import lombok.EqualsAndHashCode; +// +//@EqualsAndHashCode(callSuper = true) +//@Data +//public class ScheduledRuleFact extends Fact { +// +// private String instanceId; +// private String ruleIdentifier; +// +// public ScheduledRuleFact(String instanceId, String ruleIdentifier) { +// super(); +// this.instanceId = instanceId; +// this.ruleIdentifier = ruleIdentifier; +// } +//} +// +// diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/facts/TransitionEventFact.java b/src/main/java/com/netgrif/application/engine/rules/domain/facts/TransitionEventFact.java index e07147209f..e1455fe998 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/facts/TransitionEventFact.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/facts/TransitionEventFact.java @@ -1,48 +1,48 @@ -package com.netgrif.application.engine.rules.domain.facts; - -import com.netgrif.application.engine.petrinet.domain.events.EventPhase; -import com.netgrif.application.engine.petrinet.domain.events.EventType; -import com.netgrif.application.engine.workflow.domain.Task; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.springframework.data.mongodb.core.mapping.Document; - -@Data -@Document -@EqualsAndHashCode(callSuper = true) -public class TransitionEventFact extends CaseFact { - - private String transitionId; - - private EventType type; - - private EventPhase phase; - - public TransitionEventFact(String caseId, String transitionId, EventType type, EventPhase phase) { - super(caseId); - this.transitionId = transitionId; - this.type = type; - this.phase = phase; - } - - public static TransitionEventFact assign(Task task, EventPhase phase) { - return of(task, EventType.ASSIGN, phase); - } - - public static TransitionEventFact cancel(Task task, EventPhase phase) { - return of(task, EventType.CANCEL, phase); - } - - public static TransitionEventFact finish(Task task, EventPhase phase) { - return of(task, EventType.FINISH, phase); - } - - public static TransitionEventFact of(Task task, EventType type, EventPhase phase) { - return new TransitionEventFact(task.getCaseId(), task.getTransitionId(), type, phase); - } - - public static TransitionEventFact of(String caseId, String transitionId, EventType type, EventPhase phase) { - return new TransitionEventFact(caseId, transitionId, type, phase); - } -} - +//package com.netgrif.application.engine.rules.domain.facts; +// +//import com.netgrif.application.engine.petrinet.domain.events.EventPhase; +//import com.netgrif.application.engine.petrinet.domain.events.EventType; +//import com.netgrif.application.engine.workflow.domain.Task; +//import lombok.Data; +//import lombok.EqualsAndHashCode; +//import org.springframework.data.mongodb.core.mapping.Document; +// +//@Data +//@Document +//@EqualsAndHashCode(callSuper = true) +//public class TransitionEventFact extends CaseFact { +// +// private String transitionId; +// +// private EventType type; +// +// private EventPhase phase; +// +// public TransitionEventFact(String caseId, String transitionId, EventType type, EventPhase phase) { +// super(caseId); +// this.transitionId = transitionId; +// this.type = type; +// this.phase = phase; +// } +// +// public static TransitionEventFact assign(Task task, EventPhase phase) { +// return of(task, EventType.ASSIGN, phase); +// } +// +// public static TransitionEventFact cancel(Task task, EventPhase phase) { +// return of(task, EventType.CANCEL, phase); +// } +// +// public static TransitionEventFact finish(Task task, EventPhase phase) { +// return of(task, EventType.FINISH, phase); +// } +// +// public static TransitionEventFact of(Task task, EventType type, EventPhase phase) { +// return new TransitionEventFact(task.getCaseId(), task.getTransitionId(), type, phase); +// } +// +// public static TransitionEventFact of(String caseId, String transitionId, EventType type, EventPhase phase) { +// return new TransitionEventFact(caseId, transitionId, type, phase); +// } +//} +// diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/CaseRuleEvaluationJob.java b/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/CaseRuleEvaluationJob.java index a4f9a4975e..3dccd294c7 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/CaseRuleEvaluationJob.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/CaseRuleEvaluationJob.java @@ -1,39 +1,39 @@ -package com.netgrif.application.engine.rules.domain.scheduled; - -import com.netgrif.application.engine.rules.domain.facts.ScheduledRuleFact; -import com.netgrif.application.engine.rules.service.interfaces.IRuleEngine; -import com.netgrif.application.engine.workflow.domain.Case; -import com.netgrif.application.engine.workflow.service.interfaces.IWorkflowService; -import org.quartz.JobExecutionContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - - -@Component -public class CaseRuleEvaluationJob extends RuleJob { - - public static final String CASE_ID = "caseId"; - - private static final Logger log = LoggerFactory.getLogger(CaseRuleEvaluationJob.class); - - @Autowired - private IRuleEngine ruleEngine; - - @Autowired - private IWorkflowService workflowService; - - @Override - public void doExecute(JobExecutionContext context) { - String caseId = getInstanceId(context); - log.info("Executing CaseRuleEvaluationJob for case " + caseId + " of rule " + getRuleIdentifier(context)); - Case useCase = workflowService.findOne(caseId); - ruleEngine.evaluateRules(useCase, new ScheduledRuleFact(caseId, getRuleIdentifier(context))); - } - - @Override - public String getInstanceId(JobExecutionContext context) { - return (String) context.getJobDetail().getJobDataMap().get(CASE_ID); - } -} \ No newline at end of file +//package com.netgrif.application.engine.rules.domain.scheduled; +// +//import com.netgrif.application.engine.rules.domain.facts.ScheduledRuleFact; +//import com.netgrif.application.engine.rules.service.interfaces.IRuleEngine; +//import com.netgrif.application.engine.workflow.domain.Case; +//import com.netgrif.application.engine.workflow.service.interfaces.IWorkflowService; +//import org.quartz.JobExecutionContext; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +// +// +//@Component +//public class CaseRuleEvaluationJob extends RuleJob { +// +// public static final String CASE_ID = "caseId"; +// +// private static final Logger log = LoggerFactory.getLogger(CaseRuleEvaluationJob.class); +// +// @Autowired +// private IRuleEngine ruleEngine; +// +// @Autowired +// private IWorkflowService workflowService; +// +// @Override +// public void doExecute(JobExecutionContext context) { +// String caseId = getInstanceId(context); +// log.info("Executing CaseRuleEvaluationJob for case " + caseId + " of rule " + getRuleIdentifier(context)); +// Case useCase = workflowService.findOne(caseId); +// ruleEngine.evaluateRules(useCase, new ScheduledRuleFact(caseId, getRuleIdentifier(context))); +// } +// +// @Override +// public String getInstanceId(JobExecutionContext context) { +// return (String) context.getJobDetail().getJobDataMap().get(CASE_ID); +// } +//} \ No newline at end of file diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/PetriNetRuleEvaluationJob.java b/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/PetriNetRuleEvaluationJob.java index aecea6285f..03e3947aa7 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/PetriNetRuleEvaluationJob.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/PetriNetRuleEvaluationJob.java @@ -1,40 +1,40 @@ -package com.netgrif.application.engine.rules.domain.scheduled; - -import com.netgrif.application.engine.petrinet.domain.PetriNet; -import com.netgrif.application.engine.petrinet.service.interfaces.IPetriNetService; -import com.netgrif.application.engine.rules.domain.facts.ScheduledRuleFact; -import com.netgrif.application.engine.rules.service.interfaces.IRuleEngine; -import org.quartz.JobExecutionContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - - -@Component -public class PetriNetRuleEvaluationJob extends RuleJob { - - public static final String NET_ID = "netId"; - - private static final Logger log = LoggerFactory.getLogger(PetriNetRuleEvaluationJob.class); - - @Autowired - private IRuleEngine ruleEngine; - - @Autowired - private IPetriNetService petriNetService; - - @Override - public void doExecute(JobExecutionContext context) { - String netId = getInstanceId(context); - log.info("Executing PetriNetRuleEvaluationJob for net " + netId + " of rule " + getRuleIdentifier(context)); - PetriNet net = petriNetService.getPetriNet(netId); - ruleEngine.evaluateRules(net, new ScheduledRuleFact(netId, getRuleIdentifier(context))); - } - - @Override - public String getInstanceId(JobExecutionContext context) { - return (String) context.getJobDetail().getJobDataMap().get(NET_ID); - } - -} \ No newline at end of file +//package com.netgrif.application.engine.rules.domain.scheduled; +// +//import com.netgrif.application.engine.petrinet.domain.PetriNet; +//import com.netgrif.application.engine.petrinet.service.interfaces.IPetriNetService; +//import com.netgrif.application.engine.rules.domain.facts.ScheduledRuleFact; +//import com.netgrif.application.engine.rules.service.interfaces.IRuleEngine; +//import org.quartz.JobExecutionContext; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +// +// +//@Component +//public class PetriNetRuleEvaluationJob extends RuleJob { +// +// public static final String NET_ID = "netId"; +// +// private static final Logger log = LoggerFactory.getLogger(PetriNetRuleEvaluationJob.class); +// +// @Autowired +// private IRuleEngine ruleEngine; +// +// @Autowired +// private IPetriNetService petriNetService; +// +// @Override +// public void doExecute(JobExecutionContext context) { +// String netId = getInstanceId(context); +// log.info("Executing PetriNetRuleEvaluationJob for net " + netId + " of rule " + getRuleIdentifier(context)); +// PetriNet net = petriNetService.getPetriNet(netId); +// ruleEngine.evaluateRules(net, new ScheduledRuleFact(netId, getRuleIdentifier(context))); +// } +// +// @Override +// public String getInstanceId(JobExecutionContext context) { +// return (String) context.getJobDetail().getJobDataMap().get(NET_ID); +// } +// +//} \ No newline at end of file diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/RuleJob.java b/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/RuleJob.java index 516bdc114b..4c12d2941d 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/RuleJob.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/RuleJob.java @@ -1,44 +1,44 @@ -package com.netgrif.application.engine.rules.domain.scheduled; - -import org.quartz.Job; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public abstract class RuleJob implements Job { - - public static final String RULE_IDENTIFIER = "ruleIdentifier"; - - private static final Logger log = LoggerFactory.getLogger(RuleJob.class); - - public void execute(JobExecutionContext context) throws JobExecutionException { - String instanceId = getInstanceId(context); - String ruleIdentifier = getRuleIdentifier(context); - - if (!validate(context)) { - log.warn("Job does not have instanceId or ruleIdentifier! " + instanceId + ", " + ruleIdentifier); - return; - } - - try { - doExecute(context); - } catch (Exception e) { - log.error("Failed scheduled rule evaluation", e); - throw new JobExecutionException(e); - } - } - - public boolean validate(JobExecutionContext context) { - return getInstanceId(context) != null && getRuleIdentifier(context) != null; - } - - public String getRuleIdentifier(JobExecutionContext context) { - return (String) context.getJobDetail().getJobDataMap().get(RULE_IDENTIFIER); - } - - public abstract void doExecute(JobExecutionContext context); - - public abstract String getInstanceId(JobExecutionContext context); -} \ No newline at end of file +//package com.netgrif.application.engine.rules.domain.scheduled; +// +//import org.quartz.Job; +//import org.quartz.JobExecutionContext; +//import org.quartz.JobExecutionException; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +// +// +//public abstract class RuleJob implements Job { +// +// public static final String RULE_IDENTIFIER = "ruleIdentifier"; +// +// private static final Logger log = LoggerFactory.getLogger(RuleJob.class); +// +// public void execute(JobExecutionContext context) throws JobExecutionException { +// String instanceId = getInstanceId(context); +// String ruleIdentifier = getRuleIdentifier(context); +// +// if (!validate(context)) { +// log.warn("Job does not have instanceId or ruleIdentifier! " + instanceId + ", " + ruleIdentifier); +// return; +// } +// +// try { +// doExecute(context); +// } catch (Exception e) { +// log.error("Failed scheduled rule evaluation", e); +// throw new JobExecutionException(e); +// } +// } +// +// public boolean validate(JobExecutionContext context) { +// return getInstanceId(context) != null && getRuleIdentifier(context) != null; +// } +// +// public String getRuleIdentifier(JobExecutionContext context) { +// return (String) context.getJobDetail().getJobDataMap().get(RULE_IDENTIFIER); +// } +// +// public abstract void doExecute(JobExecutionContext context); +// +// public abstract String getInstanceId(JobExecutionContext context); +//} \ No newline at end of file diff --git a/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/ScheduleOutcome.java b/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/ScheduleOutcome.java index b7fbdcd24b..b2b32b7b36 100644 --- a/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/ScheduleOutcome.java +++ b/src/main/java/com/netgrif/application/engine/rules/domain/scheduled/ScheduleOutcome.java @@ -1,14 +1,14 @@ -package com.netgrif.application.engine.rules.domain.scheduled; - -import lombok.AllArgsConstructor; -import lombok.Data; -import org.quartz.JobDetail; -import org.quartz.Trigger; - -@Data -@AllArgsConstructor -public class ScheduleOutcome { - - private JobDetail jobDetail; - private Trigger trigger; -} +//package com.netgrif.application.engine.rules.domain.scheduled; +// +//import lombok.AllArgsConstructor; +//import lombok.Data; +//import org.quartz.JobDetail; +//import org.quartz.Trigger; +// +//@Data +//@AllArgsConstructor +//public class ScheduleOutcome { +// +// private JobDetail jobDetail; +// private Trigger trigger; +//} diff --git a/src/main/java/com/netgrif/application/engine/rules/service/RuleEngine.java b/src/main/java/com/netgrif/application/engine/rules/service/RuleEngine.java index 7d02c46416..6dc2d87292 100644 --- a/src/main/java/com/netgrif/application/engine/rules/service/RuleEngine.java +++ b/src/main/java/com/netgrif/application/engine/rules/service/RuleEngine.java @@ -1,86 +1,86 @@ -package com.netgrif.application.engine.rules.service; - -import com.netgrif.application.engine.petrinet.domain.PetriNet; -import com.netgrif.application.engine.rules.domain.RuleRepository; -import com.netgrif.application.engine.rules.domain.facts.CaseCreatedFact; -import com.netgrif.application.engine.rules.domain.facts.NetImportedFact; -import com.netgrif.application.engine.rules.domain.facts.ScheduledRuleFact; -import com.netgrif.application.engine.rules.domain.facts.TransitionEventFact; -import com.netgrif.application.engine.rules.service.interfaces.IRuleEngine; -import com.netgrif.application.engine.workflow.domain.Case; -import com.netgrif.application.engine.workflow.domain.Task; -import lombok.extern.slf4j.Slf4j; -import org.kie.api.runtime.KieSession; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Lookup; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -import java.util.Arrays; -import java.util.List; - -@Slf4j -@Service -public abstract class RuleEngine implements IRuleEngine { - - @Value("${rule-engine.rethrow-exceptions:#{false}}") - protected boolean rethrowExceptions; - - @Autowired - private RuleRepository ruleRepository; - - @Lookup - protected abstract KieSession ruleEngine(); - - @Override - public int evaluateRules(Case useCase, CaseCreatedFact caseCreatedFact) { - return evaluateWithFacts(Arrays.asList(useCase, caseCreatedFact)); - } - - @Override - public int evaluateRules(Case useCase, Task task, TransitionEventFact transitionEventFact) { - return evaluateWithFacts(Arrays.asList(useCase, task, transitionEventFact)); - } - - @Override - public int evaluateRules(Case useCase, ScheduledRuleFact scheduledRuleFact) { - return evaluateWithFacts(Arrays.asList(useCase, scheduledRuleFact)); - } - - @Override - public int evaluateRules(PetriNet petriNet, NetImportedFact fact) { - return evaluateWithFacts(Arrays.asList(petriNet, fact)); - } - - @Override - public int evaluateRules(PetriNet petriNet, ScheduledRuleFact scheduledRuleFact) { - return evaluateWithFacts(Arrays.asList(petriNet, scheduledRuleFact)); - } - - private int evaluateWithFacts(List facts) { - if (ruleRepository.count() == 0) { - return 0; - } - KieSession session = null; - int numberOfRulesExecuted = 0; - try { - session = createSession(); - facts.forEach(session::insert); - numberOfRulesExecuted = session.fireAllRules(); - } catch (Exception e) { - log.error("Rule engine failure", e); - if (rethrowExceptions) { - throw e; - } - } finally { - if (session != null) { - session.destroy(); - } - } - return numberOfRulesExecuted; - } - - protected KieSession createSession() { - return ruleEngine(); - } -} +//package com.netgrif.application.engine.rules.service; +// +//import com.netgrif.application.engine.petrinet.domain.PetriNet; +//import com.netgrif.application.engine.rules.domain.RuleRepository; +//import com.netgrif.application.engine.rules.domain.facts.CaseCreatedFact; +//import com.netgrif.application.engine.rules.domain.facts.NetImportedFact; +//import com.netgrif.application.engine.rules.domain.facts.ScheduledRuleFact; +//import com.netgrif.application.engine.rules.domain.facts.TransitionEventFact; +//import com.netgrif.application.engine.rules.service.interfaces.IRuleEngine; +//import com.netgrif.application.engine.workflow.domain.Case; +//import com.netgrif.application.engine.workflow.domain.Task; +//import lombok.extern.slf4j.Slf4j; +//import org.kie.api.runtime.KieSession; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.beans.factory.annotation.Lookup; +//import org.springframework.beans.factory.annotation.Value; +//import org.springframework.stereotype.Service; +// +//import java.util.Arrays; +//import java.util.List; +// +//@Slf4j +//@Service +//public abstract class RuleEngine implements IRuleEngine { +// +// @Value("${rule-engine.rethrow-exceptions:#{false}}") +// protected boolean rethrowExceptions; +// +// @Autowired +// private RuleRepository ruleRepository; +// +// @Lookup +// protected abstract KieSession ruleEngine(); +// +// @Override +// public int evaluateRules(Case useCase, CaseCreatedFact caseCreatedFact) { +// return evaluateWithFacts(Arrays.asList(useCase, caseCreatedFact)); +// } +// +// @Override +// public int evaluateRules(Case useCase, Task task, TransitionEventFact transitionEventFact) { +// return evaluateWithFacts(Arrays.asList(useCase, task, transitionEventFact)); +// } +// +// @Override +// public int evaluateRules(Case useCase, ScheduledRuleFact scheduledRuleFact) { +// return evaluateWithFacts(Arrays.asList(useCase, scheduledRuleFact)); +// } +// +// @Override +// public int evaluateRules(PetriNet petriNet, NetImportedFact fact) { +// return evaluateWithFacts(Arrays.asList(petriNet, fact)); +// } +// +// @Override +// public int evaluateRules(PetriNet petriNet, ScheduledRuleFact scheduledRuleFact) { +// return evaluateWithFacts(Arrays.asList(petriNet, scheduledRuleFact)); +// } +// +// private int evaluateWithFacts(List facts) { +// if (ruleRepository.count() == 0) { +// return 0; +// } +// KieSession session = null; +// int numberOfRulesExecuted = 0; +// try { +// session = createSession(); +// facts.forEach(session::insert); +// numberOfRulesExecuted = session.fireAllRules(); +// } catch (Exception e) { +// log.error("Rule engine failure", e); +// if (rethrowExceptions) { +// throw e; +// } +// } finally { +// if (session != null) { +// session.destroy(); +// } +// } +// return numberOfRulesExecuted; +// } +// +// protected KieSession createSession() { +// return ruleEngine(); +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/rules/service/RuleEvaluationScheduleService.java b/src/main/java/com/netgrif/application/engine/rules/service/RuleEvaluationScheduleService.java index 89a6fad447..081099b697 100644 --- a/src/main/java/com/netgrif/application/engine/rules/service/RuleEvaluationScheduleService.java +++ b/src/main/java/com/netgrif/application/engine/rules/service/RuleEvaluationScheduleService.java @@ -1,99 +1,99 @@ -package com.netgrif.application.engine.rules.service; - -import com.netgrif.application.engine.petrinet.domain.PetriNet; -import com.netgrif.application.engine.rules.domain.RuleRepository; -import com.netgrif.application.engine.rules.domain.StoredRule; -import com.netgrif.application.engine.rules.domain.scheduled.CaseRuleEvaluationJob; -import com.netgrif.application.engine.rules.domain.scheduled.PetriNetRuleEvaluationJob; -import com.netgrif.application.engine.rules.domain.scheduled.RuleJob; -import com.netgrif.application.engine.rules.domain.scheduled.ScheduleOutcome; -import com.netgrif.application.engine.rules.service.interfaces.IRuleEvaluationScheduleService; -import com.netgrif.application.engine.rules.service.throwable.RuleEvaluationScheduleException; -import com.netgrif.application.engine.workflow.domain.Case; -import org.quartz.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.*; - -@Service -public class RuleEvaluationScheduleService implements IRuleEvaluationScheduleService { - - private static final Logger log = LoggerFactory.getLogger(RuleEvaluationScheduleService.class); - - @Autowired - private Scheduler scheduler; - - @Autowired - private RuleRepository ruleRepository; - - @Override - public ScheduleOutcome scheduleRuleEvaluationForCase(Case useCase, String ruleIdentifier, TriggerBuilder triggerBuilder) throws RuleEvaluationScheduleException { - return scheduleRuleEvaluationForCase(useCase, Collections.singletonList(ruleIdentifier), triggerBuilder).values().iterator().next(); - } - - @Override - public Map scheduleRuleEvaluationForCase(Case useCase, List ruleIdentifiers, TriggerBuilder triggerBuilder) throws RuleEvaluationScheduleException { - Map data = new HashMap<>(); - data.put(CaseRuleEvaluationJob.CASE_ID, useCase.getStringId()); - return scheduleRuleEvaluation(useCase.getStringId(), data, ruleIdentifiers, triggerBuilder); - } - - @Override - public ScheduleOutcome scheduleRuleEvaluationForNet(PetriNet petriNet, String ruleIdentifier, TriggerBuilder triggerBuilder) throws RuleEvaluationScheduleException { - return scheduleRuleEvaluationForNet(petriNet, Collections.singletonList(ruleIdentifier), triggerBuilder).values().iterator().next(); - } - - @Override - public Map scheduleRuleEvaluationForNet(PetriNet petriNet, List ruleIdentifiers, TriggerBuilder triggerBuilder) throws RuleEvaluationScheduleException { - Map data = new HashMap<>(); - data.put(PetriNetRuleEvaluationJob.NET_ID, petriNet.getStringId()); - return scheduleRuleEvaluation(petriNet.getStringId(), data, ruleIdentifiers, triggerBuilder); - } - - private void schedule(String stringId, String ruleId, JobDetail jobDetail, Trigger trigger) throws RuleEvaluationScheduleException { - try { - scheduler.scheduleJob(jobDetail, trigger); - } catch (SchedulerException e) { - log.error("Failed to schedule Rule evaluation for " + stringId + " of rule " + ruleId, e); - throw new RuleEvaluationScheduleException(e); - } - } - - public Map scheduleRuleEvaluation(String instanceId, Map jobData, List ruleIdentifiers, TriggerBuilder triggerBuilder) throws RuleEvaluationScheduleException { - List storedRules = ruleRepository.findByIdentifierIn(ruleIdentifiers); - - Map outcomes = new HashMap<>(); - for (StoredRule rule : storedRules) { - log.info("Scheduling rule eval job for " + instanceId + " " + rule.getIdentifier()); - - JobDetail jobDetail = buildJobDetail(instanceId, rule, CaseRuleEvaluationJob.class); - Trigger trigger = buildTrigger(instanceId, triggerBuilder, jobDetail); - jobDetail.getJobDataMap().putAll(jobData); - - schedule(instanceId, rule.getStringId(), jobDetail, trigger); - outcomes.put(rule.getIdentifier(), new ScheduleOutcome(jobDetail, trigger)); - } - - return outcomes; - } - - protected JobDetail buildJobDetail(String instanceStringId, StoredRule rule, Class type) { - JobDetail jobDetail = JobBuilder.newJob().ofType(type) - .storeDurably(false) - .withIdentity(instanceStringId + "-" + rule.getStringId() + "-" + UUID.randomUUID().toString()) - .withDescription("Scheduled eval for " + instanceStringId + " of rule " + rule.getStringId()).build(); - jobDetail.getJobDataMap().put(RuleJob.RULE_IDENTIFIER, rule.getIdentifier()); - return jobDetail; - } - - protected Trigger buildTrigger(String instanceStringId, TriggerBuilder triggerBuilder, JobDetail jobDetail) { - return triggerBuilder - .withIdentity("trigger" + instanceStringId + "-" + jobDetail.getKey().toString() + "-" + UUID.randomUUID().toString()) - .withDescription("Trigger for " + instanceStringId + " for job " + jobDetail.getKey().toString()) - .build(); - } - -} +//package com.netgrif.application.engine.rules.service; +// +//import com.netgrif.application.engine.petrinet.domain.PetriNet; +//import com.netgrif.application.engine.rules.domain.RuleRepository; +//import com.netgrif.application.engine.rules.domain.StoredRule; +//import com.netgrif.application.engine.rules.domain.scheduled.CaseRuleEvaluationJob; +//import com.netgrif.application.engine.rules.domain.scheduled.PetriNetRuleEvaluationJob; +//import com.netgrif.application.engine.rules.domain.scheduled.RuleJob; +//import com.netgrif.application.engine.rules.domain.scheduled.ScheduleOutcome; +//import com.netgrif.application.engine.rules.service.interfaces.IRuleEvaluationScheduleService; +//import com.netgrif.application.engine.rules.service.throwable.RuleEvaluationScheduleException; +//import com.netgrif.application.engine.workflow.domain.Case; +//import org.quartz.*; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Service; +// +//import java.util.*; +// +//@Service +//public class RuleEvaluationScheduleService implements IRuleEvaluationScheduleService { +// +// private static final Logger log = LoggerFactory.getLogger(RuleEvaluationScheduleService.class); +// +// @Autowired +// private Scheduler scheduler; +// +// @Autowired +// private RuleRepository ruleRepository; +// +// @Override +// public ScheduleOutcome scheduleRuleEvaluationForCase(Case useCase, String ruleIdentifier, TriggerBuilder triggerBuilder) throws RuleEvaluationScheduleException { +// return scheduleRuleEvaluationForCase(useCase, Collections.singletonList(ruleIdentifier), triggerBuilder).values().iterator().next(); +// } +// +// @Override +// public Map scheduleRuleEvaluationForCase(Case useCase, List ruleIdentifiers, TriggerBuilder triggerBuilder) throws RuleEvaluationScheduleException { +// Map data = new HashMap<>(); +// data.put(CaseRuleEvaluationJob.CASE_ID, useCase.getStringId()); +// return scheduleRuleEvaluation(useCase.getStringId(), data, ruleIdentifiers, triggerBuilder); +// } +// +// @Override +// public ScheduleOutcome scheduleRuleEvaluationForNet(PetriNet petriNet, String ruleIdentifier, TriggerBuilder triggerBuilder) throws RuleEvaluationScheduleException { +// return scheduleRuleEvaluationForNet(petriNet, Collections.singletonList(ruleIdentifier), triggerBuilder).values().iterator().next(); +// } +// +// @Override +// public Map scheduleRuleEvaluationForNet(PetriNet petriNet, List ruleIdentifiers, TriggerBuilder triggerBuilder) throws RuleEvaluationScheduleException { +// Map data = new HashMap<>(); +// data.put(PetriNetRuleEvaluationJob.NET_ID, petriNet.getStringId()); +// return scheduleRuleEvaluation(petriNet.getStringId(), data, ruleIdentifiers, triggerBuilder); +// } +// +// private void schedule(String stringId, String ruleId, JobDetail jobDetail, Trigger trigger) throws RuleEvaluationScheduleException { +// try { +// scheduler.scheduleJob(jobDetail, trigger); +// } catch (SchedulerException e) { +// log.error("Failed to schedule Rule evaluation for " + stringId + " of rule " + ruleId, e); +// throw new RuleEvaluationScheduleException(e); +// } +// } +// +// public Map scheduleRuleEvaluation(String instanceId, Map jobData, List ruleIdentifiers, TriggerBuilder triggerBuilder) throws RuleEvaluationScheduleException { +// List storedRules = ruleRepository.findByIdentifierIn(ruleIdentifiers); +// +// Map outcomes = new HashMap<>(); +// for (StoredRule rule : storedRules) { +// log.info("Scheduling rule eval job for " + instanceId + " " + rule.getIdentifier()); +// +// JobDetail jobDetail = buildJobDetail(instanceId, rule, CaseRuleEvaluationJob.class); +// Trigger trigger = buildTrigger(instanceId, triggerBuilder, jobDetail); +// jobDetail.getJobDataMap().putAll(jobData); +// +// schedule(instanceId, rule.getStringId(), jobDetail, trigger); +// outcomes.put(rule.getIdentifier(), new ScheduleOutcome(jobDetail, trigger)); +// } +// +// return outcomes; +// } +// +// protected JobDetail buildJobDetail(String instanceStringId, StoredRule rule, Class type) { +// JobDetail jobDetail = JobBuilder.newJob().ofType(type) +// .storeDurably(false) +// .withIdentity(instanceStringId + "-" + rule.getStringId() + "-" + UUID.randomUUID().toString()) +// .withDescription("Scheduled eval for " + instanceStringId + " of rule " + rule.getStringId()).build(); +// jobDetail.getJobDataMap().put(RuleJob.RULE_IDENTIFIER, rule.getIdentifier()); +// return jobDetail; +// } +// +// protected Trigger buildTrigger(String instanceStringId, TriggerBuilder triggerBuilder, JobDetail jobDetail) { +// return triggerBuilder +// .withIdentity("trigger" + instanceStringId + "-" + jobDetail.getKey().toString() + "-" + UUID.randomUUID().toString()) +// .withDescription("Trigger for " + instanceStringId + " for job " + jobDetail.getKey().toString()) +// .build(); +// } +// +//} diff --git a/src/main/java/com/netgrif/application/engine/rules/service/interfaces/IRuleEngine.java b/src/main/java/com/netgrif/application/engine/rules/service/interfaces/IRuleEngine.java index 08d4a4bdc1..64980b17a8 100644 --- a/src/main/java/com/netgrif/application/engine/rules/service/interfaces/IRuleEngine.java +++ b/src/main/java/com/netgrif/application/engine/rules/service/interfaces/IRuleEngine.java @@ -1,22 +1,22 @@ -package com.netgrif.application.engine.rules.service.interfaces; - -import com.netgrif.application.engine.petrinet.domain.PetriNet; -import com.netgrif.application.engine.rules.domain.facts.CaseCreatedFact; -import com.netgrif.application.engine.rules.domain.facts.NetImportedFact; -import com.netgrif.application.engine.rules.domain.facts.ScheduledRuleFact; -import com.netgrif.application.engine.rules.domain.facts.TransitionEventFact; -import com.netgrif.application.engine.workflow.domain.Case; -import com.netgrif.application.engine.workflow.domain.Task; - -public interface IRuleEngine { - - int evaluateRules(Case useCase, CaseCreatedFact caseCreatedFact); - - int evaluateRules(Case useCase, Task task, TransitionEventFact transitionEventFact); - - int evaluateRules(Case useCase, ScheduledRuleFact scheduledRuleFact); - - int evaluateRules(PetriNet petriNet, NetImportedFact fact); - - int evaluateRules(PetriNet petriNet, ScheduledRuleFact scheduledRuleFact); -} +//package com.netgrif.application.engine.rules.service.interfaces; +// +//import com.netgrif.application.engine.petrinet.domain.PetriNet; +//import com.netgrif.application.engine.rules.domain.facts.CaseCreatedFact; +//import com.netgrif.application.engine.rules.domain.facts.NetImportedFact; +//import com.netgrif.application.engine.rules.domain.facts.ScheduledRuleFact; +//import com.netgrif.application.engine.rules.domain.facts.TransitionEventFact; +//import com.netgrif.application.engine.workflow.domain.Case; +//import com.netgrif.application.engine.workflow.domain.Task; +// +//public interface IRuleEngine { +// +// int evaluateRules(Case useCase, CaseCreatedFact caseCreatedFact); +// +// int evaluateRules(Case useCase, Task task, TransitionEventFact transitionEventFact); +// +// int evaluateRules(Case useCase, ScheduledRuleFact scheduledRuleFact); +// +// int evaluateRules(PetriNet petriNet, NetImportedFact fact); +// +// int evaluateRules(PetriNet petriNet, ScheduledRuleFact scheduledRuleFact); +//} diff --git a/src/main/java/com/netgrif/application/engine/rules/service/interfaces/IRuleEvaluationScheduleService.java b/src/main/java/com/netgrif/application/engine/rules/service/interfaces/IRuleEvaluationScheduleService.java index 7128290b49..3e3d1e21a2 100644 --- a/src/main/java/com/netgrif/application/engine/rules/service/interfaces/IRuleEvaluationScheduleService.java +++ b/src/main/java/com/netgrif/application/engine/rules/service/interfaces/IRuleEvaluationScheduleService.java @@ -1,22 +1,22 @@ -package com.netgrif.application.engine.rules.service.interfaces; - -import com.netgrif.application.engine.petrinet.domain.PetriNet; -import com.netgrif.application.engine.rules.domain.scheduled.ScheduleOutcome; -import com.netgrif.application.engine.rules.service.throwable.RuleEvaluationScheduleException; -import com.netgrif.application.engine.workflow.domain.Case; -import org.quartz.Trigger; -import org.quartz.TriggerBuilder; - -import java.util.List; -import java.util.Map; - -public interface IRuleEvaluationScheduleService { - - ScheduleOutcome scheduleRuleEvaluationForCase(Case useCase, String ruleIdentifier, TriggerBuilder trigger) throws RuleEvaluationScheduleException; - - Map scheduleRuleEvaluationForCase(Case useCase, List ruleIdentifiers, TriggerBuilder trigger) throws RuleEvaluationScheduleException; - - ScheduleOutcome scheduleRuleEvaluationForNet(PetriNet petriNet, String ruleIdentifier, TriggerBuilder trigger) throws RuleEvaluationScheduleException; - - Map scheduleRuleEvaluationForNet(PetriNet petriNet, List ruleIdentifiers, TriggerBuilder trigger) throws RuleEvaluationScheduleException; -} +//package com.netgrif.application.engine.rules.service.interfaces; +// +//import com.netgrif.application.engine.petrinet.domain.PetriNet; +//import com.netgrif.application.engine.rules.domain.scheduled.ScheduleOutcome; +//import com.netgrif.application.engine.rules.service.throwable.RuleEvaluationScheduleException; +//import com.netgrif.application.engine.workflow.domain.Case; +//import org.quartz.Trigger; +//import org.quartz.TriggerBuilder; +// +//import java.util.List; +//import java.util.Map; +// +//public interface IRuleEvaluationScheduleService { +// +// ScheduleOutcome scheduleRuleEvaluationForCase(Case useCase, String ruleIdentifier, TriggerBuilder trigger) throws RuleEvaluationScheduleException; +// +// Map scheduleRuleEvaluationForCase(Case useCase, List ruleIdentifiers, TriggerBuilder trigger) throws RuleEvaluationScheduleException; +// +// ScheduleOutcome scheduleRuleEvaluationForNet(PetriNet petriNet, String ruleIdentifier, TriggerBuilder trigger) throws RuleEvaluationScheduleException; +// +// Map scheduleRuleEvaluationForNet(PetriNet petriNet, List ruleIdentifiers, TriggerBuilder trigger) throws RuleEvaluationScheduleException; +//} diff --git a/src/main/java/com/netgrif/application/engine/rules/service/throwable/RuleEvaluationScheduleException.java b/src/main/java/com/netgrif/application/engine/rules/service/throwable/RuleEvaluationScheduleException.java index 6702c4d909..89858a915a 100644 --- a/src/main/java/com/netgrif/application/engine/rules/service/throwable/RuleEvaluationScheduleException.java +++ b/src/main/java/com/netgrif/application/engine/rules/service/throwable/RuleEvaluationScheduleException.java @@ -1,10 +1,10 @@ -package com.netgrif.application.engine.rules.service.throwable; - -import org.quartz.SchedulerException; - -public class RuleEvaluationScheduleException extends Exception { - - public RuleEvaluationScheduleException(SchedulerException e) { - super(e); - } -} +//package com.netgrif.application.engine.rules.service.throwable; +// +//import org.quartz.SchedulerException; +// +//public class RuleEvaluationScheduleException extends Exception { +// +// public RuleEvaluationScheduleException(SchedulerException e) { +// super(e); +// } +//} diff --git a/src/main/java/com/netgrif/application/engine/startup/runner/RuleEngineRunner.java b/src/main/java/com/netgrif/application/engine/startup/runner/RuleEngineRunner.java index c9155e8414..63c903db36 100644 --- a/src/main/java/com/netgrif/application/engine/startup/runner/RuleEngineRunner.java +++ b/src/main/java/com/netgrif/application/engine/startup/runner/RuleEngineRunner.java @@ -1,76 +1,76 @@ -package com.netgrif.application.engine.startup.runner; - -import com.beust.jcommander.Strings; -import com.netgrif.application.engine.configuration.drools.interfaces.IRefreshableKieBase; -import com.netgrif.application.engine.configuration.drools.interfaces.IRuleEngineGlobalsProvider; -import com.netgrif.application.engine.startup.ApplicationEngineStartupRunner; -import com.netgrif.application.engine.startup.annotation.RunnerOrder; -import groovy.text.SimpleTemplateEngine; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.ApplicationArguments; -import org.springframework.core.io.ClassPathResource; -import org.springframework.stereotype.Component; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.LinkedHashMap; -import java.util.stream.Collectors; - -@Slf4j -@Component -@RunnerOrder(30) -@RequiredArgsConstructor -public class RuleEngineRunner implements ApplicationEngineStartupRunner { - - @Value("${drools.template.generate:true}") - private boolean generate; - - @Value("${drools.template.path:rules/templates/template.drl}") - private String generatedTemplatePath; - - @Value("${drools.template-resource.classpath:rules/templates/template.drl}") - private String templateResource; - - private final IRefreshableKieBase refreshableKieBase; - private final IRuleEngineGlobalsProvider sessionInitializer; - - @Override - public void run(ApplicationArguments args) throws Exception { - log.info("Rule engine runner starting"); - if (generate) { - log.info("Generating template to {}", generatedTemplatePath); - generateTemplate(); - } - log.info("Loading rules from database"); - refreshableKieBase.refresh(); - log.info("Rule engine runner finished"); - } - - public void generateTemplate() throws IOException, ClassNotFoundException { - SimpleTemplateEngine engine = new SimpleTemplateEngine(); - LinkedHashMap binding = new LinkedHashMap<>(2); - binding.put("imports", Strings.join("", sessionInitializer.imports())); - binding.put("globals", sessionInitializer.globals().stream().map(Object::toString).collect(Collectors.joining(""))); - - String template = String.valueOf(engine.createTemplate(new String(new ClassPathResource(templateResource).getInputStream().readAllBytes())).make(binding)); - - File templateFile = new File(generatedTemplatePath); - templateFile.getParentFile().mkdirs(); - boolean deleted = templateFile.delete(); - if (!deleted) { - log.warn("Previous generated template file was not deleted"); - } - - templateFile.createNewFile(); - if (!templateFile.exists()) { - throw new IllegalStateException("Template file " + templateFile.getAbsolutePath() + " was not created"); - } - - Files.writeString(templateFile.toPath(), template); - log.info("Generated template into file "); - } - -} +//package com.netgrif.application.engine.startup.runner; +// +//import com.beust.jcommander.Strings; +////import com.netgrif.application.engine.configuration.drools.interfaces.IRefreshableKieBase; +////import com.netgrif.application.engine.configuration.drools.interfaces.IRuleEngineGlobalsProvider; +//import com.netgrif.application.engine.startup.ApplicationEngineStartupRunner; +//import com.netgrif.application.engine.startup.annotation.RunnerOrder; +//import groovy.text.SimpleTemplateEngine; +//import lombok.RequiredArgsConstructor; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Value; +//import org.springframework.boot.ApplicationArguments; +//import org.springframework.core.io.ClassPathResource; +//import org.springframework.stereotype.Component; +// +//import java.io.File; +//import java.io.IOException; +//import java.nio.file.Files; +//import java.util.LinkedHashMap; +//import java.util.stream.Collectors; +// +//@Slf4j +//@Component +//@RunnerOrder(30) +//@RequiredArgsConstructor +//public class RuleEngineRunner implements ApplicationEngineStartupRunner { +// +// @Value("${drools.template.generate:true}") +// private boolean generate; +// +// @Value("${drools.template.path:rules/templates/template.drl}") +// private String generatedTemplatePath; +// +// @Value("${drools.template-resource.classpath:rules/templates/template.drl}") +// private String templateResource; +// +//// private final IRefreshableKieBase refreshableKieBase; +//// private final IRuleEngineGlobalsProvider sessionInitializer; +// +// @Override +// public void run(ApplicationArguments args) throws Exception { +// log.info("Rule engine runner starting"); +// if (generate) { +// log.info("Generating template to {}", generatedTemplatePath); +// generateTemplate(); +// } +// log.info("Loading rules from database"); +// refreshableKieBase.refresh(); +// log.info("Rule engine runner finished"); +// } +// +// public void generateTemplate() throws IOException, ClassNotFoundException { +// SimpleTemplateEngine engine = new SimpleTemplateEngine(); +// LinkedHashMap binding = new LinkedHashMap<>(2); +// binding.put("imports", Strings.join("", sessionInitializer.imports())); +// binding.put("globals", sessionInitializer.globals().stream().map(Object::toString).collect(Collectors.joining(""))); +// +// String template = String.valueOf(engine.createTemplate(new String(new ClassPathResource(templateResource).getInputStream().readAllBytes())).make(binding)); +// +// File templateFile = new File(generatedTemplatePath); +// templateFile.getParentFile().mkdirs(); +// boolean deleted = templateFile.delete(); +// if (!deleted) { +// log.warn("Previous generated template file was not deleted"); +// } +// +// templateFile.createNewFile(); +// if (!templateFile.exists()) { +// throw new IllegalStateException("Template file " + templateFile.getAbsolutePath() + " was not created"); +// } +// +// Files.writeString(templateFile.toPath(), template); +// log.info("Generated template into file "); +// } +// +//} diff --git a/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java b/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java index 2782331f06..e8e8ec7655 100644 --- a/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java +++ b/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java @@ -24,8 +24,7 @@ import com.netgrif.application.engine.petrinet.domain.roles.ProcessRole; import com.netgrif.application.engine.petrinet.domain.throwable.TransitionNotExecutableException; import com.netgrif.application.engine.petrinet.service.interfaces.IProcessRoleService; -import com.netgrif.application.engine.rules.domain.facts.TransitionEventFact; -import com.netgrif.application.engine.rules.service.interfaces.IRuleEngine; + import com.netgrif.application.engine.utils.DateUtils; import com.netgrif.application.engine.utils.FullPageRequest; import com.netgrif.application.engine.validation.service.interfaces.IValidationService; @@ -37,7 +36,6 @@ import com.netgrif.application.engine.workflow.domain.eventoutcomes.dataoutcomes.SetDataEventOutcome; import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.*; import com.netgrif.application.engine.workflow.domain.repositories.TaskRepository; -import com.netgrif.application.engine.workflow.domain.triggers.AutoTrigger; import com.netgrif.application.engine.workflow.domain.triggers.TimeTrigger; import com.netgrif.application.engine.workflow.domain.triggers.Trigger; import com.netgrif.application.engine.workflow.service.interfaces.IDataService; @@ -118,8 +116,8 @@ public void setElasticTaskService(IElasticTaskService elasticTaskService) { this.elasticTaskService = elasticTaskService; } - @Autowired - private IRuleEngine ruleEngine; +// @Autowired +// private IRuleEngine ruleEngine; @Override public List assignTasks(List tasks, IUser user) throws TransitionNotExecutableException { @@ -173,16 +171,16 @@ public AssignTaskEventOutcome assignTask(Task task, IUser user, Map outcomes = new ArrayList<>(eventService.runActions(transition.getPreAssignActions(), useCase, task, transition, params)); task = findOne(task.getStringId()); - useCase = evaluateRules(useCase.getStringId(), task, EventType.ASSIGN, EventPhase.PRE); + useCase = evaluateRules(new AssignTaskEvent(new AssignTaskEventOutcome(useCase, task, outcomes), EventPhase.PRE)); useCase = assignTaskToUser(user, task, useCase.getStringId()); historyService.save(new AssignTaskEventLog(task, useCase, EventPhase.PRE, user)); outcomes.addAll((eventService.runActions(transition.getPostAssignActions(), useCase, task, transition, params))); - useCase = evaluateRules(useCase.getStringId(), task, EventType.ASSIGN, EventPhase.POST); + useCase = evaluateRules(new AssignTaskEvent(new AssignTaskEventOutcome(useCase, task, outcomes), EventPhase.POST)); historyService.save(new AssignTaskEventLog(task, useCase, EventPhase.POST, user)); AssignTaskEventOutcome outcome = new AssignTaskEventOutcome(useCase, task, outcomes); addMessageToOutcome(transition, EventType.ASSIGN, outcome); - publisher.publishEvent(new AssignTaskEvent(outcome)); + //publisher.publishEvent(new AssignTaskEvent(outcome)); log.info("[" + useCase.getStringId() + "]: Task [" + task.getTitle() + "] in case [" + useCase.getTitle() + "] assigned to [" + user.getSelfOrImpersonated().getEmail() + "]"); return outcome; } @@ -270,7 +268,7 @@ public FinishTaskEventOutcome finishTask(Task task, IUser user, Map outcomes = new ArrayList<>(eventService.runActions(transition.getPreFinishActions(), useCase, task, transition, params)); task = findOne(task.getStringId()); - useCase = evaluateRules(useCase.getStringId(), task, EventType.FINISH, EventPhase.PRE); + useCase = evaluateRules(new FinishTaskEvent(new FinishTaskEventOutcome(useCase, task, outcomes), EventPhase.PRE)); finishExecution(transition, useCase.getStringId()); task.setFinishDate(LocalDateTime.now()); @@ -283,11 +281,11 @@ public FinishTaskEventOutcome finishTask(Task task, IUser user, Map outcomes = new ArrayList<>(eventService.runActions(transition.getPreCancelActions(), useCase, task, transition, params)); task = findOne(task.getStringId()); - useCase = evaluateRules(useCase.getStringId(), task, EventType.CANCEL, EventPhase.PRE); + useCase = evaluateRules(new CancelTaskEvent(new CancelTaskEventOutcome(useCase, task, outcomes), EventPhase.PRE)); task = returnTokens(task, useCase.getStringId()); useCase = workflowService.findOne(useCase.getStringId()); reloadTasks(useCase); useCase = workflowService.findOne(useCase.getStringId()); historyService.save(new CancelTaskEventLog(task, useCase, EventPhase.PRE, user)); outcomes.addAll(eventService.runActions(transition.getPostCancelActions(), useCase, task, transition, params)); - useCase = evaluateRules(useCase.getStringId(), task, EventType.CANCEL, EventPhase.POST); + useCase = evaluateRules(new CancelTaskEvent(new CancelTaskEventOutcome(useCase, task, outcomes), EventPhase.POST)); CancelTaskEventOutcome outcome = new CancelTaskEventOutcome(useCase, task); outcome.setOutcomes(outcomes); addMessageToOutcome(transition, EventType.CANCEL, outcome); - publisher.publishEvent(new CancelTaskEvent(outcome)); + //publisher.publishEvent(new CancelTaskEvent(outcome)); historyService.save(new CancelTaskEventLog(task, useCase, EventPhase.POST, user)); log.info("[" + useCase.getStringId() + "]: Task [" + task.getTitle() + "] in case [" + useCase.getTitle() + "] assigned to [" + user.getSelfOrImpersonated().getEmail() + "] was cancelled"); return outcome; @@ -424,18 +422,18 @@ public DelegateTaskEventOutcome delegateTask(LoggedUser loggedUser, String deleg List outcomes = new ArrayList<>(eventService.runActions(transition.getPreDelegateActions(), useCase, task, transition, params)); task = findOne(task.getStringId()); - useCase = evaluateRules(useCase.getStringId(), task, EventType.DELEGATE, EventPhase.PRE); + useCase = evaluateRules(new DelegateTaskEvent(new DelegateTaskEventOutcome(useCase, task, outcomes), EventPhase.PRE)); delegate(delegatedUser, task, useCase); historyService.save(new DelegateTaskEventLog(task, useCase, EventPhase.PRE, delegateUser, delegatedUser.getStringId())); outcomes.addAll(eventService.runActions(transition.getPostDelegateActions(), useCase, task, transition, params)); - useCase = evaluateRules(useCase.getStringId(), task, EventType.DELEGATE, EventPhase.POST); + useCase = evaluateRules(new DelegateTaskEvent(new DelegateTaskEventOutcome(useCase, task, outcomes), EventPhase.POST)); useCase = workflowService.findOne(useCase.getStringId()); reloadTasks(useCase); DelegateTaskEventOutcome outcome = new DelegateTaskEventOutcome(useCase, task, outcomes); addMessageToOutcome(transition, EventType.DELEGATE, outcome); - publisher.publishEvent(new DelegateTaskEvent(outcome)); + //publisher.publishEvent(new DelegateTaskEvent(outcome)); historyService.save(new DelegateTaskEventLog(task, useCase, EventPhase.POST, delegateUser, delegatedUser.getStringId())); log.info("Task [" + task.getTitle() + "] in case [" + useCase.getTitle() + "] assigned to [" + delegateUser.getSelfOrImpersonated().getEmail() + "] was delegated to [" + delegatedUser.getEmail() + "]"); @@ -452,14 +450,9 @@ protected void delegate(IUser delegated, Task task, Case useCase) throws Transit } } - protected Case evaluateRules(String caseId, Task task, EventType eventType, EventPhase eventPhase) { - Case useCase = workflowService.findOne(caseId); - log.info("[" + useCase.getStringId() + "]: Task [" + task.getTitle() + "] in case [" + useCase.getTitle() + "] evaluating rules of event " + eventType.name() + " of phase " + eventPhase.name()); - int rulesExecuted = ruleEngine.evaluateRules(useCase, task, TransitionEventFact.of(task, eventType, eventPhase)); - if (rulesExecuted == 0) { - return useCase; - } - return workflowService.save(useCase); + protected Case evaluateRules(TaskEvent taskEvent) { + publisher.publishEvent(taskEvent); + return workflowService.findOne(taskEvent.getTaskEventOutcome().getCase().getStringId()); } /** @@ -870,7 +863,7 @@ private Task createFromTransition(Transition transition, Case useCase) { useCase.addTask(task); CreateTaskEventOutcome outcome = new CreateTaskEventOutcome(useCase, task); - publisher.publishEvent(new CreateTaskEvent(outcome)); + //publisher.publishEvent(new CreateTaskEvent(outcome)); return task; } diff --git a/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java b/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java index d039dfd3ce..625b0750d1 100644 --- a/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java +++ b/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java @@ -6,6 +6,7 @@ import com.netgrif.application.engine.elastic.service.interfaces.IElasticCaseMappingService; import com.netgrif.application.engine.elastic.service.interfaces.IElasticCaseService; import com.netgrif.application.engine.elastic.web.requestbodies.CaseSearchRequest; +import com.netgrif.application.engine.event.events.workflow.CaseEvent; import com.netgrif.application.engine.event.events.workflow.CreateCaseEvent; import com.netgrif.application.engine.event.events.workflow.DeleteCaseEvent; import com.netgrif.application.engine.history.domain.caseevents.CreateCaseEventLog; @@ -23,8 +24,8 @@ import com.netgrif.application.engine.petrinet.domain.events.EventPhase; import com.netgrif.application.engine.petrinet.service.interfaces.IPetriNetService; import com.netgrif.application.engine.petrinet.service.interfaces.IProcessRoleService; -import com.netgrif.application.engine.rules.domain.facts.CaseCreatedFact; -import com.netgrif.application.engine.rules.service.interfaces.IRuleEngine; +//import com.netgrif.application.engine.rules.domain.facts.CaseCreatedFact; +//import com.netgrif.application.engine.rules.service.interfaces.IRuleEngine; import com.netgrif.application.engine.security.service.EncryptionService; import com.netgrif.application.engine.utils.FullPageRequest; import com.netgrif.application.engine.workflow.domain.Case; @@ -94,8 +95,8 @@ public class WorkflowService implements IWorkflowService { @Autowired protected FieldFactory fieldFactory; - @Autowired - protected IRuleEngine ruleEngine; +// @Autowired +// protected IRuleEngine ruleEngine; @Autowired protected FieldActionsRunner actionsRunner; @@ -333,7 +334,7 @@ public CreateCaseEventOutcome createCase(String netId, Function ma public CreateCaseEventOutcome createCase(String netId, Function makeTitle, String color, LoggedUser user, Map params) { LoggedUser loggedOrImpersonated = user.getSelfOrImpersonated(); PetriNet petriNet = petriNetService.clone(new ObjectId(netId)); - int rulesExecuted; +// int rulesExecuted; Case useCase = new Case(petriNet); useCase.populateDataSet(initValueExpressionEvaluator, params); useCase.setColor(color); @@ -344,10 +345,7 @@ public CreateCaseEventOutcome createCase(String netId, Function ma CreateCaseEventOutcome outcome = new CreateCaseEventOutcome(); outcome.addOutcomes(eventService.runActions(petriNet.getPreCreateActions(), null, Optional.empty(), params)); - rulesExecuted = ruleEngine.evaluateRules(useCase, new CaseCreatedFact(useCase.getStringId(), EventPhase.PRE)); - if (rulesExecuted > 0) { - useCase = save(useCase); - } + useCase = evaluateRules(new CreateCaseEvent(new CreateCaseEventOutcome(useCase, outcome.getOutcomes()), EventPhase.PRE)); historyService.save(new CreateCaseEventLog(useCase, EventPhase.PRE)); log.info("[" + useCase.getStringId() + "]: Case " + useCase.getTitle() + " created"); @@ -360,15 +358,16 @@ public CreateCaseEventOutcome createCase(String netId, Function ma useCase = findOne(useCase.getStringId()); outcome.addOutcomes(eventService.runActions(petriNet.getPostCreateActions(), useCase, Optional.empty(), params)); useCase = findOne(useCase.getStringId()); - rulesExecuted = ruleEngine.evaluateRules(useCase, new CaseCreatedFact(useCase.getStringId(), EventPhase.POST)); - if (rulesExecuted > 0) { - useCase = save(useCase); - } + useCase = evaluateRules(new CreateCaseEvent(new CreateCaseEventOutcome(useCase, outcome.getOutcomes()), EventPhase.POST)); +// rulesExecuted = ruleEngine.evaluateRules(useCase, new CaseCreatedFact(useCase.getStringId(), EventPhase.POST)); +// if (rulesExecuted > 0) { +// useCase = save(useCase); +// } historyService.save(new CreateCaseEventLog(useCase, EventPhase.POST)); outcome.setCase(setImmediateDataFields(useCase)); addMessageToOutcome(petriNet, CaseEventType.CREATE, outcome); - publisher.publishEvent(new CreateCaseEvent(outcome)); +// publisher.publishEvent(new CreateCaseEvent(outcome)); return outcome; } @@ -409,6 +408,7 @@ public DeleteCaseEventOutcome deleteCase(Case useCase, Map param DeleteCaseEventOutcome outcome = new DeleteCaseEventOutcome(useCase, eventService.runActions(useCase.getPetriNet().getPreDeleteActions(), useCase, Optional.empty(), params)); historyService.save(new DeleteCaseEventLog(useCase, EventPhase.PRE)); + useCase = evaluateRules(new DeleteCaseEvent(outcome, EventPhase.PRE)); log.info("[" + useCase.getStringId() + "]: User [" + userService.getLoggedOrSystem().getStringId() + "] is deleting case " + useCase.getTitle()); taskService.deleteTasksByCase(useCase.getStringId()); @@ -416,8 +416,9 @@ public DeleteCaseEventOutcome deleteCase(Case useCase, Map param outcome.addOutcomes(eventService.runActions(useCase.getPetriNet().getPostDeleteActions(), null, Optional.empty(), params)); addMessageToOutcome(useCase.getPetriNet(), CaseEventType.DELETE, outcome); + useCase = evaluateRules(new DeleteCaseEvent(outcome, EventPhase.POST)); historyService.save(new DeleteCaseEventLog(useCase, EventPhase.POST)); - publisher.publishEvent(new DeleteCaseEvent(outcome)); +// publisher.publishEvent(new DeleteCaseEvent(outcome)); return outcome; } @@ -649,4 +650,9 @@ private ObjectId extractObjectId(String caseId) { return new ObjectId(objectIdPart); } + + private Case evaluateRules(CaseEvent event) { + publisher.publishEvent(event); + return findOne(event.getCaseEventOutcome().getCase().getStringId()); + } } diff --git a/src/test/groovy/com/netgrif/application/engine/petrinet/domain/dataset/ChangeBehaviorTest.groovy b/src/test/groovy/com/netgrif/application/engine/petrinet/domain/dataset/ChangeBehaviorTest.groovy index 595d799a36..1c09b3f629 100644 --- a/src/test/groovy/com/netgrif/application/engine/petrinet/domain/dataset/ChangeBehaviorTest.groovy +++ b/src/test/groovy/com/netgrif/application/engine/petrinet/domain/dataset/ChangeBehaviorTest.groovy @@ -13,7 +13,6 @@ import com.netgrif.application.engine.workflow.domain.Task import com.netgrif.application.engine.workflow.service.interfaces.IDataService import com.netgrif.application.engine.workflow.service.interfaces.ITaskService import com.netgrif.application.engine.workflow.service.interfaces.IWorkflowService -import org.dmg.pmml.time_series.MA import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith diff --git a/src/test/java/com/netgrif/application/engine/drools/KnowledgeBaseInitializerTest.java b/src/test/java/com/netgrif/application/engine/drools/KnowledgeBaseInitializerTest.java index b4d051d3c5..cc120a5350 100644 --- a/src/test/java/com/netgrif/application/engine/drools/KnowledgeBaseInitializerTest.java +++ b/src/test/java/com/netgrif/application/engine/drools/KnowledgeBaseInitializerTest.java @@ -1,109 +1,109 @@ -package com.netgrif.application.engine.drools; - -import com.netgrif.application.engine.TestHelper; -import com.netgrif.application.engine.ApplicationEngine; -import com.netgrif.application.engine.configuration.drools.interfaces.IKnowledgeBaseInitializer; -import com.netgrif.application.engine.configuration.drools.throwable.RuleValidationException; -import com.netgrif.application.engine.rules.domain.StoredRule; -import org.bson.types.ObjectId; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.Collections; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -@SpringBootTest( - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - classes = ApplicationEngine.class -) -@TestPropertySource( - locations = "classpath:application-test.properties" -) -@ActiveProfiles({"test"}) -@ExtendWith(SpringExtension.class) -public class KnowledgeBaseInitializerTest { - - @Autowired - private TestHelper testHelper; - - @Autowired - private IKnowledgeBaseInitializer knowledgeBaseInitializer; - - @BeforeEach - public void before() { - testHelper.truncateDbs(); - } - - @Test - public void testInitializerRuleValidation() { - StoredRule rule = StoredRule.builder() - ._id(new ObjectId()) - .when("$item: Object()") - .then("log.info('nothing')") - .identifier("rule1") - .lastUpdate(LocalDateTime.now()) - .enabled(true) - .build(); - - StoredRule rule2 = StoredRule.builder() - ._id(new ObjectId()) - .when("$item: Object()") - .then("log.info('nothing')") - .identifier("rule2") - .lastUpdate(LocalDateTime.now()) - .enabled(true) - .build(); - - knowledgeBaseInitializer.constructKieBase(); - - try { - knowledgeBaseInitializer.validate(Arrays.asList(rule, rule2)); - } catch (RuleValidationException e) { - e.printStackTrace(); - throw new AssertionError(e); - } - } - - @Test - public void testInitializerRuleValidation_EXPECT_EXCEPTION() { - assertThrows(RuleValidationException.class, () -> { - StoredRule rule3 = StoredRule.builder() - ._id(new ObjectId()) - .when("$item: Object()") - .then("log.info(' EXPECTING SYNTAX ERROR") - .identifier("rule3") - .lastUpdate(LocalDateTime.now()) - .enabled(true) - .build(); - - knowledgeBaseInitializer.validate(Collections.singletonList(rule3)); - }); - } - - @Test - public void testInitializerRuleValidation_EXPECT_EXCEPTION2() throws RuleValidationException { - assertThrows(RuleValidationException.class, () -> { - StoredRule rule4 = StoredRule.builder() - ._id(new ObjectId()) - .when("$item: Object") - .then("log.info('nothing')") - .identifier("rule4") - .lastUpdate(LocalDateTime.now()) - .enabled(true) - .build(); - - knowledgeBaseInitializer.validate(Collections.singletonList(rule4)); - }); - } - - -} +//package com.netgrif.application.engine.drools; +// +//import com.netgrif.application.engine.TestHelper; +//import com.netgrif.application.engine.ApplicationEngine; +//import com.netgrif.application.engine.configuration.drools.interfaces.IKnowledgeBaseInitializer; +//import com.netgrif.application.engine.configuration.drools.throwable.RuleValidationException; +//import com.netgrif.application.engine.rules.domain.StoredRule; +//import org.bson.types.ObjectId; +//import org.junit.jupiter.api.BeforeEach; +//import org.junit.jupiter.api.Test; +//import org.junit.jupiter.api.extension.ExtendWith; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.ActiveProfiles; +//import org.springframework.test.context.TestPropertySource; +//import org.springframework.test.context.junit.jupiter.SpringExtension; +// +//import java.time.LocalDateTime; +//import java.util.Arrays; +//import java.util.Collections; +// +//import static org.junit.jupiter.api.Assertions.assertThrows; +// +//@SpringBootTest( +// webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, +// classes = ApplicationEngine.class +//) +//@TestPropertySource( +// locations = "classpath:application-test.properties" +//) +//@ActiveProfiles({"test"}) +//@ExtendWith(SpringExtension.class) +//public class KnowledgeBaseInitializerTest { +// +// @Autowired +// private TestHelper testHelper; +// +// @Autowired +// private IKnowledgeBaseInitializer knowledgeBaseInitializer; +// +// @BeforeEach +// public void before() { +// testHelper.truncateDbs(); +// } +// +// @Test +// public void testInitializerRuleValidation() { +// StoredRule rule = StoredRule.builder() +// ._id(new ObjectId()) +// .when("$item: Object()") +// .then("log.info('nothing')") +// .identifier("rule1") +// .lastUpdate(LocalDateTime.now()) +// .enabled(true) +// .build(); +// +// StoredRule rule2 = StoredRule.builder() +// ._id(new ObjectId()) +// .when("$item: Object()") +// .then("log.info('nothing')") +// .identifier("rule2") +// .lastUpdate(LocalDateTime.now()) +// .enabled(true) +// .build(); +// +// knowledgeBaseInitializer.constructKieBase(); +// +// try { +// knowledgeBaseInitializer.validate(Arrays.asList(rule, rule2)); +// } catch (RuleValidationException e) { +// e.printStackTrace(); +// throw new AssertionError(e); +// } +// } +// +// @Test +// public void testInitializerRuleValidation_EXPECT_EXCEPTION() { +// assertThrows(RuleValidationException.class, () -> { +// StoredRule rule3 = StoredRule.builder() +// ._id(new ObjectId()) +// .when("$item: Object()") +// .then("log.info(' EXPECTING SYNTAX ERROR") +// .identifier("rule3") +// .lastUpdate(LocalDateTime.now()) +// .enabled(true) +// .build(); +// +// knowledgeBaseInitializer.validate(Collections.singletonList(rule3)); +// }); +// } +// +// @Test +// public void testInitializerRuleValidation_EXPECT_EXCEPTION2() throws RuleValidationException { +// assertThrows(RuleValidationException.class, () -> { +// StoredRule rule4 = StoredRule.builder() +// ._id(new ObjectId()) +// .when("$item: Object") +// .then("log.info('nothing')") +// .identifier("rule4") +// .lastUpdate(LocalDateTime.now()) +// .enabled(true) +// .build(); +// +// knowledgeBaseInitializer.validate(Collections.singletonList(rule4)); +// }); +// } +// +// +//} diff --git a/src/test/java/com/netgrif/application/engine/drools/RefreshableKieBaseTest.java b/src/test/java/com/netgrif/application/engine/drools/RefreshableKieBaseTest.java index 9e01da3326..45b4b77c69 100644 --- a/src/test/java/com/netgrif/application/engine/drools/RefreshableKieBaseTest.java +++ b/src/test/java/com/netgrif/application/engine/drools/RefreshableKieBaseTest.java @@ -1,177 +1,177 @@ -package com.netgrif.application.engine.drools; - -import com.netgrif.application.engine.TestHelper; -import com.netgrif.application.engine.ApplicationEngine; -import com.netgrif.application.engine.configuration.drools.RefreshableKieBase; -import com.netgrif.application.engine.rules.domain.RuleRepository; -import com.netgrif.application.engine.rules.domain.StoredRule; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.kie.api.runtime.KieSession; -import org.kie.api.runtime.rule.FactHandle; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.concurrent.atomic.AtomicInteger; - -@SpringBootTest( - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - classes = ApplicationEngine.class -) -@TestPropertySource( - locations = "classpath:application-test.properties" -) -@ActiveProfiles({"test"}) -@ExtendWith(SpringExtension.class) -public class RefreshableKieBaseTest { - - public static final Logger log = LoggerFactory.getLogger(RefreshableKieBaseTest.class); - - @Autowired - private TestHelper testHelper; - - @Autowired - private RefreshableKieBase refreshableKieBase; - - @Autowired - private RuleRepository ruleRepository; - - @BeforeEach - public void before() { - testHelper.truncateDbs(); - } - - @Test - public void kieBaseTest() { - refreshableKieBase.refresh(); - assert refreshableKieBase.kieBase() != null; - assert !refreshableKieBase.shouldRefresh(); - - StoredRule rule = basicRule(); - ruleRepository.save(rule); - - assert refreshableKieBase.shouldRefresh(); - refreshableKieBase.refresh(); - assert !refreshableKieBase.shouldRefresh(); - } - - - @Test - public void kieBaseSessionTest() { - StoredRule rule = basicRule(); - ruleRepository.save(rule); - refreshableKieBase.refresh(); - - KieSession session1 = refreshableKieBase.kieBase().newKieSession(); - KieSession session2 = refreshableKieBase.kieBase().newKieSession(); - session1.setGlobal("log", log); - session2.setGlobal("log", log); - - session1.insert(new AtomicInteger(1)); - FactHandle h1 = session2.insert(new AtomicInteger(2)); - FactHandle h2 = session2.insert(new AtomicInteger(3)); - - refreshableKieBase.refresh(); - - int amount1 = session1.fireAllRules(); - int amount2 = session2.fireAllRules(); - - assert amount1 == 1; - assert amount2 == 2; - - session1.destroy(); - - rule.setLastUpdate(LocalDateTime.now()); - ruleRepository.save(rule); - - assert refreshableKieBase.shouldRefresh(); - refreshableKieBase.refresh(); - - session2.delete(h1); - session2.delete(h2); - - assert session2.getFactHandles().size() == 0; - - session2.insert(new AtomicInteger(4)); - - amount2 = session2.fireAllRules(); - assert amount2 == 1; - - session2.destroy(); - } - - @Test - public void ruleDisabledTest() { - StoredRule rule = basicRule(); - ruleRepository.save(rule); - - refreshableKieBase.refresh(); - KieSession session = refreshableKieBase.kieBase().newKieSession(); - session.setGlobal("log", log); - - session.insert(new AtomicInteger(1)); - int amount = session.fireAllRules(); - assert amount == 1; - session.destroy(); - - rule.setEnabled(false); - ruleRepository.save(rule); - - session = newSession(); - - session.insert(new AtomicInteger(2)); - amount = session.fireAllRules(); - assert amount == 0; - session.destroy(); - - rule.setEnabled(true); - rule.setDateEffective(LocalDate.now().minusDays(1)); - rule.setDateExpires(LocalDate.now().plusDays(2)); - ruleRepository.save(rule); - - session = newSession(); - - session.insert(new AtomicInteger(3)); - amount = session.fireAllRules(); - assert amount == 1; - session.destroy(); - - rule.setDateEffective(LocalDate.now().minusDays(2)); - rule.setDateExpires(LocalDate.now().minusDays(1)); - ruleRepository.save(rule); - - session = newSession(); - - session.insert(new AtomicInteger(4)); - amount = session.fireAllRules(); - assert amount == 0; - session.destroy(); - - } - - private StoredRule basicRule() { - return StoredRule.builder() - .when("$item: Object()") - .then("log.info(\"ITEM: \" + $item.toString())") - .identifier("random") - .lastUpdate(LocalDateTime.now()) - .enabled(true) - .build(); - } - - private KieSession newSession() { - refreshableKieBase.refresh(); - KieSession session = refreshableKieBase.kieBase().newKieSession(); - session.setGlobal("log", log); - return session; - } - -} +//package com.netgrif.application.engine.drools; +// +//import com.netgrif.application.engine.TestHelper; +//import com.netgrif.application.engine.ApplicationEngine; +//import com.netgrif.application.engine.configuration.drools.RefreshableKieBase; +//import com.netgrif.application.engine.rules.domain.RuleRepository; +//import com.netgrif.application.engine.rules.domain.StoredRule; +//import org.junit.jupiter.api.BeforeEach; +//import org.junit.jupiter.api.Test; +//import org.junit.jupiter.api.extension.ExtendWith; +//import org.kie.api.runtime.KieSession; +//import org.kie.api.runtime.rule.FactHandle; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.ActiveProfiles; +//import org.springframework.test.context.TestPropertySource; +//import org.springframework.test.context.junit.jupiter.SpringExtension; +// +//import java.time.LocalDate; +//import java.time.LocalDateTime; +//import java.util.concurrent.atomic.AtomicInteger; +// +//@SpringBootTest( +// webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, +// classes = ApplicationEngine.class +//) +//@TestPropertySource( +// locations = "classpath:application-test.properties" +//) +//@ActiveProfiles({"test"}) +//@ExtendWith(SpringExtension.class) +//public class RefreshableKieBaseTest { +// +// public static final Logger log = LoggerFactory.getLogger(RefreshableKieBaseTest.class); +// +// @Autowired +// private TestHelper testHelper; +// +// @Autowired +// private RefreshableKieBase refreshableKieBase; +// +// @Autowired +// private RuleRepository ruleRepository; +// +// @BeforeEach +// public void before() { +// testHelper.truncateDbs(); +// } +// +// @Test +// public void kieBaseTest() { +// refreshableKieBase.refresh(); +// assert refreshableKieBase.kieBase() != null; +// assert !refreshableKieBase.shouldRefresh(); +// +// StoredRule rule = basicRule(); +// ruleRepository.save(rule); +// +// assert refreshableKieBase.shouldRefresh(); +// refreshableKieBase.refresh(); +// assert !refreshableKieBase.shouldRefresh(); +// } +// +// +// @Test +// public void kieBaseSessionTest() { +// StoredRule rule = basicRule(); +// ruleRepository.save(rule); +// refreshableKieBase.refresh(); +// +// KieSession session1 = refreshableKieBase.kieBase().newKieSession(); +// KieSession session2 = refreshableKieBase.kieBase().newKieSession(); +// session1.setGlobal("log", log); +// session2.setGlobal("log", log); +// +// session1.insert(new AtomicInteger(1)); +// FactHandle h1 = session2.insert(new AtomicInteger(2)); +// FactHandle h2 = session2.insert(new AtomicInteger(3)); +// +// refreshableKieBase.refresh(); +// +// int amount1 = session1.fireAllRules(); +// int amount2 = session2.fireAllRules(); +// +// assert amount1 == 1; +// assert amount2 == 2; +// +// session1.destroy(); +// +// rule.setLastUpdate(LocalDateTime.now()); +// ruleRepository.save(rule); +// +// assert refreshableKieBase.shouldRefresh(); +// refreshableKieBase.refresh(); +// +// session2.delete(h1); +// session2.delete(h2); +// +// assert session2.getFactHandles().size() == 0; +// +// session2.insert(new AtomicInteger(4)); +// +// amount2 = session2.fireAllRules(); +// assert amount2 == 1; +// +// session2.destroy(); +// } +// +// @Test +// public void ruleDisabledTest() { +// StoredRule rule = basicRule(); +// ruleRepository.save(rule); +// +// refreshableKieBase.refresh(); +// KieSession session = refreshableKieBase.kieBase().newKieSession(); +// session.setGlobal("log", log); +// +// session.insert(new AtomicInteger(1)); +// int amount = session.fireAllRules(); +// assert amount == 1; +// session.destroy(); +// +// rule.setEnabled(false); +// ruleRepository.save(rule); +// +// session = newSession(); +// +// session.insert(new AtomicInteger(2)); +// amount = session.fireAllRules(); +// assert amount == 0; +// session.destroy(); +// +// rule.setEnabled(true); +// rule.setDateEffective(LocalDate.now().minusDays(1)); +// rule.setDateExpires(LocalDate.now().plusDays(2)); +// ruleRepository.save(rule); +// +// session = newSession(); +// +// session.insert(new AtomicInteger(3)); +// amount = session.fireAllRules(); +// assert amount == 1; +// session.destroy(); +// +// rule.setDateEffective(LocalDate.now().minusDays(2)); +// rule.setDateExpires(LocalDate.now().minusDays(1)); +// ruleRepository.save(rule); +// +// session = newSession(); +// +// session.insert(new AtomicInteger(4)); +// amount = session.fireAllRules(); +// assert amount == 0; +// session.destroy(); +// +// } +// +// private StoredRule basicRule() { +// return StoredRule.builder() +// .when("$item: Object()") +// .then("log.info(\"ITEM: \" + $item.toString())") +// .identifier("random") +// .lastUpdate(LocalDateTime.now()) +// .enabled(true) +// .build(); +// } +// +// private KieSession newSession() { +// refreshableKieBase.refresh(); +// KieSession session = refreshableKieBase.kieBase().newKieSession(); +// session.setGlobal("log", log); +// return session; +// } +// +//} diff --git a/src/test/java/com/netgrif/application/engine/rules/service/RuleEngineTest.java b/src/test/java/com/netgrif/application/engine/rules/service/RuleEngineTest.java index 02626fe323..a3183b9e9c 100644 --- a/src/test/java/com/netgrif/application/engine/rules/service/RuleEngineTest.java +++ b/src/test/java/com/netgrif/application/engine/rules/service/RuleEngineTest.java @@ -1,402 +1,402 @@ -package com.netgrif.application.engine.rules.service; - -import com.netgrif.application.engine.TestHelper; -import com.netgrif.application.engine.auth.domain.IUser; -import com.netgrif.application.engine.auth.domain.LoggedUser; -import com.netgrif.application.engine.auth.service.interfaces.IUserService; -import com.netgrif.application.engine.configuration.drools.RefreshableKieBase; -import com.netgrif.application.engine.importer.service.throwable.MissingIconKeyException; -import com.netgrif.application.engine.petrinet.domain.VersionType; -import com.netgrif.application.engine.petrinet.domain.throwable.MissingPetriNetMetaDataException; -import com.netgrif.application.engine.petrinet.domain.throwable.TransitionNotExecutableException; -import com.netgrif.application.engine.petrinet.service.interfaces.IPetriNetService; -import com.netgrif.application.engine.rules.domain.FactRepository; -import com.netgrif.application.engine.rules.domain.RuleRepository; -import com.netgrif.application.engine.rules.domain.StoredRule; -import com.netgrif.application.engine.rules.domain.facts.*; -import com.netgrif.application.engine.workflow.domain.Case; -import com.netgrif.application.engine.workflow.domain.Task; -import com.netgrif.application.engine.workflow.domain.eventoutcomes.caseoutcomes.CreateCaseEventOutcome; -import com.netgrif.application.engine.workflow.domain.eventoutcomes.petrinetoutcomes.ImportPetriNetEventOutcome; -import com.netgrif.application.engine.workflow.service.interfaces.ITaskService; -import com.netgrif.application.engine.workflow.service.interfaces.IWorkflowService; -import lombok.extern.slf4j.Slf4j; -import org.bson.types.ObjectId; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.domain.PageRequest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import java.io.FileInputStream; -import java.io.IOException; -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.IntStream; - -@Slf4j -@SpringBootTest -@ActiveProfiles({"test"}) -@ExtendWith(SpringExtension.class) -class RuleEngineTest { - - public static final String TEXT_VALUE = "new text value"; - public static final Double NUM_VALUE = 99.0; - public static final String TRANS_1 = "2"; - @Autowired - private TestHelper testHelper; - @Autowired - private RuleRepository ruleRepository; - @Autowired - private RefreshableKieBase refreshableKieBase; - @Autowired - private IWorkflowService workflowService; - @Autowired - private ITaskService taskService; - @Autowired - private IPetriNetService petriNetService; - @Autowired - private FactRepository factRepository; - @Autowired - private IUserService userService; - - private LoggedUser superUser; - - - @BeforeEach - public void before() { - testHelper.truncateDbs(); - superUser = userService.findByEmail("super@netgrif.com", false).transformToLoggedUser(); - } - - @AfterEach - public void after() { - testHelper.truncateDbs(); - ruleRepository.deleteAll(); - factRepository.deleteAll(); - refreshableKieBase.refresh(); - } - - @Test - void testNetImportRulePRE() throws IOException, MissingPetriNetMetaDataException, MissingIconKeyException { - final String NET_TITLE_PRE = "PRE_TITLE"; - final String TEST_FIELD = "TEST_FIELD"; - - StoredRule rule = StoredRule.builder() - .when("$net: PetriNet() $event: NetImportedFact(netId == $net.stringId, eventPhase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.PRE)") - .then("$net.title.defaultValue = \"" + NET_TITLE_PRE + "\"; \n" + - "$net.dataSet.put(\"" + TEST_FIELD + "\", new com.netgrif.application.engine.petrinet.domain.dataset.TextField()); \n" + - "factRepository.save($event)") - .identifier("rule1") - .lastUpdate(LocalDateTime.now()) - .enabled(true) - .build(); - ruleRepository.save(rule); - - ImportPetriNetEventOutcome outcome = petriNetService.importPetriNet(new FileInputStream("src/test/resources/rule_engine_test.xml"), VersionType.MAJOR, superUser); - - assert outcome.getNet() != null; - assert outcome.getNet().getTitle().getDefaultValue().equals(NET_TITLE_PRE); - assert outcome.getNet().getDataSet().containsKey(TEST_FIELD); - assert outcome.getNet().getDataSet().get(TEST_FIELD) != null; - - List facts = factRepository.findAll(QNetImportedFact.netImportedFact.netId.eq(outcome.getNet().getStringId()), PageRequest.of(0, 100)).getContent(); - assert facts.size() == 1 && facts.get(0) instanceof NetImportedFact; - } - - @Test - void testNetImportRulePOST() throws IOException, MissingPetriNetMetaDataException, MissingIconKeyException { - final String NET_TITLE_POST = "POST_TITLE"; - final String NEW_INITIALS = "PST"; - - StoredRule rule = StoredRule.builder() - .when("$net: PetriNet() $event: NetImportedFact(netId == $net.stringId, eventPhase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.PRE)") - .then("$net.initials = \"" + NEW_INITIALS + "\"; \n" + - "factRepository.save($event)") - .identifier("rule1") - .lastUpdate(LocalDateTime.now()) - .enabled(true) - .build(); - ruleRepository.save(rule); - - StoredRule rule2 = StoredRule.builder() - .when("$net: PetriNet() $event: NetImportedFact(netId == $net.stringId, eventPhase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)") - .then("$net.title.defaultValue = \"" + NET_TITLE_POST + "\"; \n factRepository.save($event)") - .identifier("rule2") - .lastUpdate(LocalDateTime.now()) - .enabled(true) - .build(); - ruleRepository.save(rule2); - - assert refreshableKieBase.shouldRefresh(); - - ImportPetriNetEventOutcome outcome = petriNetService.importPetriNet(new FileInputStream("src/test/resources/rule_engine_test.xml"), VersionType.MAJOR, superUser); - - assert !refreshableKieBase.shouldRefresh(); - - assert outcome.getNet() != null; - assert outcome.getNet().getTitle().getDefaultValue().equals(NET_TITLE_POST); - assert outcome.getNet().getInitials().equals(NEW_INITIALS); - - ruleRepository.deleteAll(); - factRepository.deleteAll(); - refreshableKieBase.shouldRefresh(); - } - - @Test - void testTransitionRules() throws IOException, MissingPetriNetMetaDataException, TransitionNotExecutableException, MissingIconKeyException { - final String TRANS_1 = "2"; - final String TRANS_2 = "4"; - final String NEW_CASE_TITLE = "new case title"; - final String NEW_CASE_TITLE_2 = "new case title 2"; - final String TEXT_VALUE = "TEXT FIELD VALUE"; - - ImportPetriNetEventOutcome outcome = petriNetService.importPetriNet(new FileInputStream("src/test/resources/rule_engine_test.xml"), VersionType.MAJOR, superUser); - assert outcome != null; - - StoredRule rule = StoredRule.builder() - ._id(new ObjectId()) - .when("$case: Case() $event: CaseCreatedFact(caseId == $case.stringId, eventPhase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)") - .then("$case.title = \"" + NEW_CASE_TITLE + "\"; \n log.info(\"rule 1 matched\");") - .identifier("rule1") - .lastUpdate(LocalDateTime.now()) - .enabled(true) - .build(); - StoredRule rule2 = StoredRule.builder() - ._id(new ObjectId()) - .when("$case: Case() $event: TransitionEventFact(caseId == $case.stringId, transitionId == \"" + TRANS_1 + "\", type == com.netgrif.application.engine.petrinet.domain.events.EventType.FINISH, phase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)") - .then("insert(com.netgrif.application.engine.rules.service.RuleEngineTest.TestFact.instance($case.stringId, 0)); \n $case.dataSet[\"text_data\"].value = \"" + TEXT_VALUE + "\"; \n log.info(\"rule 2 matched\");") - .identifier("rule2") - .lastUpdate(LocalDateTime.now()) - .enabled(true) - .build(); - StoredRule rule3 = StoredRule.builder() - ._id(new ObjectId()) - .when("$testFact: com.netgrif.application.engine.rules.service.RuleEngineTest.TestFact()") - .then("$testFact.increment(); \n factRepository.save($testFact) \n log.info(\"rule 3 matched\");") - .identifier("rule3") - .lastUpdate(LocalDateTime.now()) - .enabled(true) - .build(); - StoredRule rule4 = StoredRule.builder() - ._id(new ObjectId()) - .when("$case: Case([\"" + TEXT_VALUE + "\"] contains dataSet[\"text_data\"].value) $event: TransitionEventFact(caseId == $case.stringId, transitionId == \"" + TRANS_2 + "\", type == com.netgrif.application.engine.petrinet.domain.events.EventType.FINISH, phase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)") - .then("$case.title = \"" + NEW_CASE_TITLE_2 + "\"; \n log.info(\"rule 4 matched\");") - .identifier("rule4") - .lastUpdate(LocalDateTime.now()) - .enabled(true) - .build(); - ruleRepository.save(rule); - ruleRepository.save(rule2); - ruleRepository.save(rule3); - ruleRepository.save(rule4); - - CreateCaseEventOutcome caseOutcome = workflowService.createCase(outcome.getNet().getStringId(), "Original title", "original color", superUser); - assert caseOutcome.getCase().getTitle().equals(NEW_CASE_TITLE); - - Task task = findTask(caseOutcome.getCase(), TRANS_1); - taskService.assignTask(task, superUser.transformToUser()); - taskService.finishTask(task, superUser.transformToUser()); - Case newCase = workflowService.findOne(caseOutcome.getCase().getStringId()); - assert newCase.getTitle().equals(NEW_CASE_TITLE); - assert !newCase.getColor().equals(NEW_CASE_TITLE_2); - - List facts = factRepository.findAll(QCaseFact.caseFact.caseId.eq(newCase.getStringId()), PageRequest.of(0, 100)).getContent(); - - assert facts.size() == 1 && facts.get(0) instanceof TestFact && ((TestFact) facts.get(0)).number == 1; - - Task task2 = findTask(newCase, TRANS_2); - taskService.assignTask(task2, superUser.transformToUser()); - taskService.finishTask(task2, superUser.transformToUser()); - newCase = workflowService.findOne(newCase.getStringId()); - - assert newCase.getTitle().equals(NEW_CASE_TITLE_2); - } - - @Test - void assignRuleTest() throws IOException, MissingPetriNetMetaDataException, TransitionNotExecutableException, MissingIconKeyException { - StoredRule rule = transitionRulePre(TRANS_1, "com.netgrif.application.engine.petrinet.domain.events.EventType.ASSIGN"); - StoredRule rule2 = transitionRulePost(TRANS_1, "com.netgrif.application.engine.petrinet.domain.events.EventType.ASSIGN"); - - ruleRepository.save(rule); - ruleRepository.save(rule2); - - Case caze = newCase(); - assert caze != null; - - Task task = findTask(caze, TRANS_1); - taskService.assignTask(task, superUser.transformToUser()); - - caze = workflowService.findOne(caze.getStringId()); - - assert caze != null; - assert caze.getDataSet().get("text_data").getValue().equals(TEXT_VALUE); - assert caze.getDataSet().get("number_data").getValue().equals(NUM_VALUE); - } - - @Test - void testDelegate() throws IOException, MissingPetriNetMetaDataException, TransitionNotExecutableException, MissingIconKeyException { - StoredRule rule = transitionRulePre(TRANS_1, "EventType.DELEGATE"); - StoredRule rule2 = transitionRulePost(TRANS_1, "EventType.DELEGATE"); - - ruleRepository.save(rule); - ruleRepository.save(rule2); - - Case caze = newCase(); - assert caze != null; - - Task task = findTask(caze, TRANS_1); - IUser user = superUser.transformToUser(); - taskService.assignTask(task, user); - taskService.delegateTask(user.transformToLoggedUser(), user.getStringId(), task.getStringId()); - caze = workflowService.findOne(caze.getStringId()); - - assert caze.getDataSet().get("text_data").getValue().equals(TEXT_VALUE); - assert caze.getDataSet().get("number_data").getValue().equals(NUM_VALUE); - } - - @Test - void testFinish() throws IOException, MissingPetriNetMetaDataException, TransitionNotExecutableException, MissingIconKeyException { - StoredRule rule = transitionRulePre(TRANS_1, "EventType.FINISH"); - StoredRule rule2 = transitionRulePost(TRANS_1, "EventType.FINISH"); - - ruleRepository.save(rule); - ruleRepository.save(rule2); - - Case caze = newCase(); - assert caze != null; - - Task task = findTask(caze, TRANS_1); - IUser user = superUser.transformToUser(); - taskService.assignTask(task, user); - taskService.finishTask(task, user); - caze = workflowService.findOne(caze.getStringId()); - - assert caze.getDataSet().get("text_data").getValue().equals(TEXT_VALUE); - assert caze.getDataSet().get("number_data").getValue().equals(NUM_VALUE); - } - - @Test - void testCancel() throws IOException, MissingPetriNetMetaDataException, TransitionNotExecutableException, MissingIconKeyException { - StoredRule rule = transitionRulePre(TRANS_1, "EventType.CANCEL"); - StoredRule rule2 = transitionRulePost(TRANS_1, "EventType.CANCEL"); - - ruleRepository.save(rule); - ruleRepository.save(rule2); - - Case caze = newCase(); - assert caze != null; - - Task task = findTask(caze, TRANS_1); - IUser user = superUser.transformToUser(); - - taskService.assignTask(task, user); - taskService.cancelTask(task, user); - caze = workflowService.findOne(caze.getStringId()); - - assert caze.getDataSet().get("text_data").getValue().equals(TEXT_VALUE); - assert caze.getDataSet().get("number_data").getValue().equals(NUM_VALUE); - } - - @Test - void testQueries() throws IOException, MissingPetriNetMetaDataException, MissingIconKeyException { - String predicate = "$event: CaseCreatedFact(eventPhase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)"; - String then = "factRepository.save(com.netgrif.application.engine.rules.service.RuleEngineTest.TestFact.instance($case.stringId, %d));"; - StoredRule rule0 = rule(predicate + " $case: Case(processIdentifier == \"rule_engine_test\", title == \"FAKE_TITLE\")", String.format(then, -2)); - StoredRule rule1 = rule(predicate + " $case: Case(processIdentifier == \"FAKE_NET\")", String.format(then, -1)); - StoredRule rule2 = rule(predicate + " $case: Case(processIdentifier == \"rule_engine_test\")", String.format(then, 1)); - StoredRule rule3 = rule(predicate + " $case: Case(processIdentifier == \"rule_engine_test\", dataSet[\"text_data\"].value == \"VALUE\")", String.format(then, 2)); - - ruleRepository.save(rule0); - ruleRepository.save(rule1); - ruleRepository.save(rule2); - ruleRepository.save(rule3); - - Case caze = newCase(); - assert caze != null; - - List facts = factRepository.findAll(QCaseFact.caseFact.caseId.eq(caze.getStringId()), PageRequest.of(0, 100)).getContent(); - assert facts.stream().noneMatch(it -> ((TestFact) it).number == -2); - assert facts.stream().noneMatch(it -> ((TestFact) it).number == -1); - assert facts.stream().filter(it -> ((TestFact) it).number == 1).count() == 1; - assert facts.stream().filter(it -> ((TestFact) it).number == 2).count() == 1; - - } - - @Test - @Disabled("TODO:") - void stressTest() throws IOException, MissingPetriNetMetaDataException, MissingIconKeyException { - StoredRule rule = rule("$case: Case() \n $event: CaseCreatedFact(caseId == $case.stringId, eventPhase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)", "log.info($case.stringId)"); - IntStream.range(0, 10000).forEach(number -> { - rule.set_id(new ObjectId()); - ruleRepository.save(rule); - }); - StoredRule rule2 = rule("$case: Case() \n $event: CaseCreatedFact(caseId == $case.stringId, eventPhase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)", "$case.title = \"NEW_TITLE\""); - ruleRepository.save(rule2); - - Case caze = newCase(); - assert caze != null; - - assert caze.getTitle().equals("NEW_TITLE"); - } - - private StoredRule transitionRulePre(String trans, String type) { - String when = "$case: Case() $event: TransitionEventFact(caseId == $case.stringId, transitionId == \"" + trans + "\", type == " + type + ", phase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.PRE)"; - String then = "$case.dataSet[\"text_data\"].value = \"" + TEXT_VALUE + "\";"; - - return rule(when, then); - } - - private StoredRule transitionRulePost(String trans, String type) { - String when = "$case: Case() $event: TransitionEventFact(caseId == $case.stringId, transitionId == \"" + trans + "\", type == " + type + ", phase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)"; - String then = "$case.dataSet[\"number_data\"].value = " + NUM_VALUE + ";"; - - return rule(when, then); - } - - private StoredRule rule(String when, String then) { - ObjectId id = new ObjectId(); - return StoredRule.builder() - ._id(id) - .when(when) - .then(then) - .identifier(id.toString()) - .lastUpdate(LocalDateTime.now()) - .enabled(true) - .build(); - } - - private Case newCase() throws IOException, MissingPetriNetMetaDataException, MissingIconKeyException { - ImportPetriNetEventOutcome outcome = petriNetService.importPetriNet(new FileInputStream("src/test/resources/rule_engine_test.xml"), VersionType.MAJOR, superUser); - return workflowService.createCase(outcome.getNet().getStringId(), "Original title", "original color", superUser).getCase(); - } - - private Task findTask(Case caze, String trans) { - return taskService.findOne(caze.getTasks().stream().filter(it -> it.getTransition().equals(trans)).findFirst().get().getTask()); - } - - public static class TestFact extends CaseFact { - - private Integer number; - - public TestFact(String caseId, Integer number) { - super(caseId); - this.number = number; - } - - public static TestFact instance(String caseId, Integer number) { - return new TestFact(caseId, number); - } - - public Integer increment() { - return ++number; - } - } - - -} +//package com.netgrif.application.engine.rules.service; +// +//import com.netgrif.application.engine.TestHelper; +//import com.netgrif.application.engine.auth.domain.IUser; +//import com.netgrif.application.engine.auth.domain.LoggedUser; +//import com.netgrif.application.engine.auth.service.interfaces.IUserService; +//import com.netgrif.application.engine.configuration.drools.RefreshableKieBase; +//import com.netgrif.application.engine.importer.service.throwable.MissingIconKeyException; +//import com.netgrif.application.engine.petrinet.domain.VersionType; +//import com.netgrif.application.engine.petrinet.domain.throwable.MissingPetriNetMetaDataException; +//import com.netgrif.application.engine.petrinet.domain.throwable.TransitionNotExecutableException; +//import com.netgrif.application.engine.petrinet.service.interfaces.IPetriNetService; +//import com.netgrif.application.engine.rules.domain.FactRepository; +//import com.netgrif.application.engine.rules.domain.RuleRepository; +//import com.netgrif.application.engine.rules.domain.StoredRule; +//import com.netgrif.application.engine.rules.domain.facts.*; +//import com.netgrif.application.engine.workflow.domain.Case; +//import com.netgrif.application.engine.workflow.domain.Task; +//import com.netgrif.application.engine.workflow.domain.eventoutcomes.caseoutcomes.CreateCaseEventOutcome; +//import com.netgrif.application.engine.workflow.domain.eventoutcomes.petrinetoutcomes.ImportPetriNetEventOutcome; +//import com.netgrif.application.engine.workflow.service.interfaces.ITaskService; +//import com.netgrif.application.engine.workflow.service.interfaces.IWorkflowService; +//import lombok.extern.slf4j.Slf4j; +//import org.bson.types.ObjectId; +//import org.junit.jupiter.api.AfterEach; +//import org.junit.jupiter.api.BeforeEach; +//import org.junit.jupiter.api.Disabled; +//import org.junit.jupiter.api.Test; +//import org.junit.jupiter.api.extension.ExtendWith; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.data.domain.PageRequest; +//import org.springframework.test.context.ActiveProfiles; +//import org.springframework.test.context.junit.jupiter.SpringExtension; +// +//import java.io.FileInputStream; +//import java.io.IOException; +//import java.time.LocalDateTime; +//import java.util.List; +//import java.util.stream.IntStream; +// +//@Slf4j +//@SpringBootTest +//@ActiveProfiles({"test"}) +//@ExtendWith(SpringExtension.class) +//class RuleEngineTest { +// +// public static final String TEXT_VALUE = "new text value"; +// public static final Double NUM_VALUE = 99.0; +// public static final String TRANS_1 = "2"; +// @Autowired +// private TestHelper testHelper; +// @Autowired +// private RuleRepository ruleRepository; +// @Autowired +// private RefreshableKieBase refreshableKieBase; +// @Autowired +// private IWorkflowService workflowService; +// @Autowired +// private ITaskService taskService; +// @Autowired +// private IPetriNetService petriNetService; +// @Autowired +// private FactRepository factRepository; +// @Autowired +// private IUserService userService; +// +// private LoggedUser superUser; +// +// +// @BeforeEach +// public void before() { +// testHelper.truncateDbs(); +// superUser = userService.findByEmail("super@netgrif.com", false).transformToLoggedUser(); +// } +// +// @AfterEach +// public void after() { +// testHelper.truncateDbs(); +// ruleRepository.deleteAll(); +// factRepository.deleteAll(); +// refreshableKieBase.refresh(); +// } +// +// @Test +// void testNetImportRulePRE() throws IOException, MissingPetriNetMetaDataException, MissingIconKeyException { +// final String NET_TITLE_PRE = "PRE_TITLE"; +// final String TEST_FIELD = "TEST_FIELD"; +// +// StoredRule rule = StoredRule.builder() +// .when("$net: PetriNet() $event: NetImportedFact(netId == $net.stringId, eventPhase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.PRE)") +// .then("$net.title.defaultValue = \"" + NET_TITLE_PRE + "\"; \n" + +// "$net.dataSet.put(\"" + TEST_FIELD + "\", new com.netgrif.application.engine.petrinet.domain.dataset.TextField()); \n" + +// "factRepository.save($event)") +// .identifier("rule1") +// .lastUpdate(LocalDateTime.now()) +// .enabled(true) +// .build(); +// ruleRepository.save(rule); +// +// ImportPetriNetEventOutcome outcome = petriNetService.importPetriNet(new FileInputStream("src/test/resources/rule_engine_test.xml"), VersionType.MAJOR, superUser); +// +// assert outcome.getNet() != null; +// assert outcome.getNet().getTitle().getDefaultValue().equals(NET_TITLE_PRE); +// assert outcome.getNet().getDataSet().containsKey(TEST_FIELD); +// assert outcome.getNet().getDataSet().get(TEST_FIELD) != null; +// +// List facts = factRepository.findAll(QNetImportedFact.netImportedFact.netId.eq(outcome.getNet().getStringId()), PageRequest.of(0, 100)).getContent(); +// assert facts.size() == 1 && facts.get(0) instanceof NetImportedFact; +// } +// +// @Test +// void testNetImportRulePOST() throws IOException, MissingPetriNetMetaDataException, MissingIconKeyException { +// final String NET_TITLE_POST = "POST_TITLE"; +// final String NEW_INITIALS = "PST"; +// +// StoredRule rule = StoredRule.builder() +// .when("$net: PetriNet() $event: NetImportedFact(netId == $net.stringId, eventPhase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.PRE)") +// .then("$net.initials = \"" + NEW_INITIALS + "\"; \n" + +// "factRepository.save($event)") +// .identifier("rule1") +// .lastUpdate(LocalDateTime.now()) +// .enabled(true) +// .build(); +// ruleRepository.save(rule); +// +// StoredRule rule2 = StoredRule.builder() +// .when("$net: PetriNet() $event: NetImportedFact(netId == $net.stringId, eventPhase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)") +// .then("$net.title.defaultValue = \"" + NET_TITLE_POST + "\"; \n factRepository.save($event)") +// .identifier("rule2") +// .lastUpdate(LocalDateTime.now()) +// .enabled(true) +// .build(); +// ruleRepository.save(rule2); +// +// assert refreshableKieBase.shouldRefresh(); +// +// ImportPetriNetEventOutcome outcome = petriNetService.importPetriNet(new FileInputStream("src/test/resources/rule_engine_test.xml"), VersionType.MAJOR, superUser); +// +// assert !refreshableKieBase.shouldRefresh(); +// +// assert outcome.getNet() != null; +// assert outcome.getNet().getTitle().getDefaultValue().equals(NET_TITLE_POST); +// assert outcome.getNet().getInitials().equals(NEW_INITIALS); +// +// ruleRepository.deleteAll(); +// factRepository.deleteAll(); +// refreshableKieBase.shouldRefresh(); +// } +// +// @Test +// void testTransitionRules() throws IOException, MissingPetriNetMetaDataException, TransitionNotExecutableException, MissingIconKeyException { +// final String TRANS_1 = "2"; +// final String TRANS_2 = "4"; +// final String NEW_CASE_TITLE = "new case title"; +// final String NEW_CASE_TITLE_2 = "new case title 2"; +// final String TEXT_VALUE = "TEXT FIELD VALUE"; +// +// ImportPetriNetEventOutcome outcome = petriNetService.importPetriNet(new FileInputStream("src/test/resources/rule_engine_test.xml"), VersionType.MAJOR, superUser); +// assert outcome != null; +// +// StoredRule rule = StoredRule.builder() +// ._id(new ObjectId()) +// .when("$case: Case() $event: CaseCreatedFact(caseId == $case.stringId, eventPhase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)") +// .then("$case.title = \"" + NEW_CASE_TITLE + "\"; \n log.info(\"rule 1 matched\");") +// .identifier("rule1") +// .lastUpdate(LocalDateTime.now()) +// .enabled(true) +// .build(); +// StoredRule rule2 = StoredRule.builder() +// ._id(new ObjectId()) +// .when("$case: Case() $event: TransitionEventFact(caseId == $case.stringId, transitionId == \"" + TRANS_1 + "\", type == com.netgrif.application.engine.petrinet.domain.events.EventType.FINISH, phase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)") +// .then("insert(com.netgrif.application.engine.rules.service.RuleEngineTest.TestFact.instance($case.stringId, 0)); \n $case.dataSet[\"text_data\"].value = \"" + TEXT_VALUE + "\"; \n log.info(\"rule 2 matched\");") +// .identifier("rule2") +// .lastUpdate(LocalDateTime.now()) +// .enabled(true) +// .build(); +// StoredRule rule3 = StoredRule.builder() +// ._id(new ObjectId()) +// .when("$testFact: com.netgrif.application.engine.rules.service.RuleEngineTest.TestFact()") +// .then("$testFact.increment(); \n factRepository.save($testFact) \n log.info(\"rule 3 matched\");") +// .identifier("rule3") +// .lastUpdate(LocalDateTime.now()) +// .enabled(true) +// .build(); +// StoredRule rule4 = StoredRule.builder() +// ._id(new ObjectId()) +// .when("$case: Case([\"" + TEXT_VALUE + "\"] contains dataSet[\"text_data\"].value) $event: TransitionEventFact(caseId == $case.stringId, transitionId == \"" + TRANS_2 + "\", type == com.netgrif.application.engine.petrinet.domain.events.EventType.FINISH, phase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)") +// .then("$case.title = \"" + NEW_CASE_TITLE_2 + "\"; \n log.info(\"rule 4 matched\");") +// .identifier("rule4") +// .lastUpdate(LocalDateTime.now()) +// .enabled(true) +// .build(); +// ruleRepository.save(rule); +// ruleRepository.save(rule2); +// ruleRepository.save(rule3); +// ruleRepository.save(rule4); +// +// CreateCaseEventOutcome caseOutcome = workflowService.createCase(outcome.getNet().getStringId(), "Original title", "original color", superUser); +// assert caseOutcome.getCase().getTitle().equals(NEW_CASE_TITLE); +// +// Task task = findTask(caseOutcome.getCase(), TRANS_1); +// taskService.assignTask(task, superUser.transformToUser()); +// taskService.finishTask(task, superUser.transformToUser()); +// Case newCase = workflowService.findOne(caseOutcome.getCase().getStringId()); +// assert newCase.getTitle().equals(NEW_CASE_TITLE); +// assert !newCase.getColor().equals(NEW_CASE_TITLE_2); +// +// List facts = factRepository.findAll(QCaseFact.caseFact.caseId.eq(newCase.getStringId()), PageRequest.of(0, 100)).getContent(); +// +// assert facts.size() == 1 && facts.get(0) instanceof TestFact && ((TestFact) facts.get(0)).number == 1; +// +// Task task2 = findTask(newCase, TRANS_2); +// taskService.assignTask(task2, superUser.transformToUser()); +// taskService.finishTask(task2, superUser.transformToUser()); +// newCase = workflowService.findOne(newCase.getStringId()); +// +// assert newCase.getTitle().equals(NEW_CASE_TITLE_2); +// } +// +// @Test +// void assignRuleTest() throws IOException, MissingPetriNetMetaDataException, TransitionNotExecutableException, MissingIconKeyException { +// StoredRule rule = transitionRulePre(TRANS_1, "com.netgrif.application.engine.petrinet.domain.events.EventType.ASSIGN"); +// StoredRule rule2 = transitionRulePost(TRANS_1, "com.netgrif.application.engine.petrinet.domain.events.EventType.ASSIGN"); +// +// ruleRepository.save(rule); +// ruleRepository.save(rule2); +// +// Case caze = newCase(); +// assert caze != null; +// +// Task task = findTask(caze, TRANS_1); +// taskService.assignTask(task, superUser.transformToUser()); +// +// caze = workflowService.findOne(caze.getStringId()); +// +// assert caze != null; +// assert caze.getDataSet().get("text_data").getValue().equals(TEXT_VALUE); +// assert caze.getDataSet().get("number_data").getValue().equals(NUM_VALUE); +// } +// +// @Test +// void testDelegate() throws IOException, MissingPetriNetMetaDataException, TransitionNotExecutableException, MissingIconKeyException { +// StoredRule rule = transitionRulePre(TRANS_1, "EventType.DELEGATE"); +// StoredRule rule2 = transitionRulePost(TRANS_1, "EventType.DELEGATE"); +// +// ruleRepository.save(rule); +// ruleRepository.save(rule2); +// +// Case caze = newCase(); +// assert caze != null; +// +// Task task = findTask(caze, TRANS_1); +// IUser user = superUser.transformToUser(); +// taskService.assignTask(task, user); +// taskService.delegateTask(user.transformToLoggedUser(), user.getStringId(), task.getStringId()); +// caze = workflowService.findOne(caze.getStringId()); +// +// assert caze.getDataSet().get("text_data").getValue().equals(TEXT_VALUE); +// assert caze.getDataSet().get("number_data").getValue().equals(NUM_VALUE); +// } +// +// @Test +// void testFinish() throws IOException, MissingPetriNetMetaDataException, TransitionNotExecutableException, MissingIconKeyException { +// StoredRule rule = transitionRulePre(TRANS_1, "EventType.FINISH"); +// StoredRule rule2 = transitionRulePost(TRANS_1, "EventType.FINISH"); +// +// ruleRepository.save(rule); +// ruleRepository.save(rule2); +// +// Case caze = newCase(); +// assert caze != null; +// +// Task task = findTask(caze, TRANS_1); +// IUser user = superUser.transformToUser(); +// taskService.assignTask(task, user); +// taskService.finishTask(task, user); +// caze = workflowService.findOne(caze.getStringId()); +// +// assert caze.getDataSet().get("text_data").getValue().equals(TEXT_VALUE); +// assert caze.getDataSet().get("number_data").getValue().equals(NUM_VALUE); +// } +// +// @Test +// void testCancel() throws IOException, MissingPetriNetMetaDataException, TransitionNotExecutableException, MissingIconKeyException { +// StoredRule rule = transitionRulePre(TRANS_1, "EventType.CANCEL"); +// StoredRule rule2 = transitionRulePost(TRANS_1, "EventType.CANCEL"); +// +// ruleRepository.save(rule); +// ruleRepository.save(rule2); +// +// Case caze = newCase(); +// assert caze != null; +// +// Task task = findTask(caze, TRANS_1); +// IUser user = superUser.transformToUser(); +// +// taskService.assignTask(task, user); +// taskService.cancelTask(task, user); +// caze = workflowService.findOne(caze.getStringId()); +// +// assert caze.getDataSet().get("text_data").getValue().equals(TEXT_VALUE); +// assert caze.getDataSet().get("number_data").getValue().equals(NUM_VALUE); +// } +// +// @Test +// void testQueries() throws IOException, MissingPetriNetMetaDataException, MissingIconKeyException { +// String predicate = "$event: CaseCreatedFact(eventPhase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)"; +// String then = "factRepository.save(com.netgrif.application.engine.rules.service.RuleEngineTest.TestFact.instance($case.stringId, %d));"; +// StoredRule rule0 = rule(predicate + " $case: Case(processIdentifier == \"rule_engine_test\", title == \"FAKE_TITLE\")", String.format(then, -2)); +// StoredRule rule1 = rule(predicate + " $case: Case(processIdentifier == \"FAKE_NET\")", String.format(then, -1)); +// StoredRule rule2 = rule(predicate + " $case: Case(processIdentifier == \"rule_engine_test\")", String.format(then, 1)); +// StoredRule rule3 = rule(predicate + " $case: Case(processIdentifier == \"rule_engine_test\", dataSet[\"text_data\"].value == \"VALUE\")", String.format(then, 2)); +// +// ruleRepository.save(rule0); +// ruleRepository.save(rule1); +// ruleRepository.save(rule2); +// ruleRepository.save(rule3); +// +// Case caze = newCase(); +// assert caze != null; +// +// List facts = factRepository.findAll(QCaseFact.caseFact.caseId.eq(caze.getStringId()), PageRequest.of(0, 100)).getContent(); +// assert facts.stream().noneMatch(it -> ((TestFact) it).number == -2); +// assert facts.stream().noneMatch(it -> ((TestFact) it).number == -1); +// assert facts.stream().filter(it -> ((TestFact) it).number == 1).count() == 1; +// assert facts.stream().filter(it -> ((TestFact) it).number == 2).count() == 1; +// +// } +// +// @Test +// @Disabled("TODO:") +// void stressTest() throws IOException, MissingPetriNetMetaDataException, MissingIconKeyException { +// StoredRule rule = rule("$case: Case() \n $event: CaseCreatedFact(caseId == $case.stringId, eventPhase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)", "log.info($case.stringId)"); +// IntStream.range(0, 10000).forEach(number -> { +// rule.set_id(new ObjectId()); +// ruleRepository.save(rule); +// }); +// StoredRule rule2 = rule("$case: Case() \n $event: CaseCreatedFact(caseId == $case.stringId, eventPhase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)", "$case.title = \"NEW_TITLE\""); +// ruleRepository.save(rule2); +// +// Case caze = newCase(); +// assert caze != null; +// +// assert caze.getTitle().equals("NEW_TITLE"); +// } +// +// private StoredRule transitionRulePre(String trans, String type) { +// String when = "$case: Case() $event: TransitionEventFact(caseId == $case.stringId, transitionId == \"" + trans + "\", type == " + type + ", phase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.PRE)"; +// String then = "$case.dataSet[\"text_data\"].value = \"" + TEXT_VALUE + "\";"; +// +// return rule(when, then); +// } +// +// private StoredRule transitionRulePost(String trans, String type) { +// String when = "$case: Case() $event: TransitionEventFact(caseId == $case.stringId, transitionId == \"" + trans + "\", type == " + type + ", phase == com.netgrif.application.engine.petrinet.domain.events.EventPhase.POST)"; +// String then = "$case.dataSet[\"number_data\"].value = " + NUM_VALUE + ";"; +// +// return rule(when, then); +// } +// +// private StoredRule rule(String when, String then) { +// ObjectId id = new ObjectId(); +// return StoredRule.builder() +// ._id(id) +// .when(when) +// .then(then) +// .identifier(id.toString()) +// .lastUpdate(LocalDateTime.now()) +// .enabled(true) +// .build(); +// } +// +// private Case newCase() throws IOException, MissingPetriNetMetaDataException, MissingIconKeyException { +// ImportPetriNetEventOutcome outcome = petriNetService.importPetriNet(new FileInputStream("src/test/resources/rule_engine_test.xml"), VersionType.MAJOR, superUser); +// return workflowService.createCase(outcome.getNet().getStringId(), "Original title", "original color", superUser).getCase(); +// } +// +// private Task findTask(Case caze, String trans) { +// return taskService.findOne(caze.getTasks().stream().filter(it -> it.getTransition().equals(trans)).findFirst().get().getTask()); +// } +// +// public static class TestFact extends CaseFact { +// +// private Integer number; +// +// public TestFact(String caseId, Integer number) { +// super(caseId); +// this.number = number; +// } +// +// public static TestFact instance(String caseId, Integer number) { +// return new TestFact(caseId, number); +// } +// +// public Integer increment() { +// return ++number; +// } +// } +// +// +//} diff --git a/src/test/java/com/netgrif/application/engine/rules/service/RuleEvaluationScheduleServiceTest.java b/src/test/java/com/netgrif/application/engine/rules/service/RuleEvaluationScheduleServiceTest.java index 80940c3161..cf0460b712 100644 --- a/src/test/java/com/netgrif/application/engine/rules/service/RuleEvaluationScheduleServiceTest.java +++ b/src/test/java/com/netgrif/application/engine/rules/service/RuleEvaluationScheduleServiceTest.java @@ -1,101 +1,101 @@ -package com.netgrif.application.engine.rules.service; - -import com.netgrif.application.engine.TestHelper; -import com.netgrif.application.engine.auth.domain.LoggedUser; -import com.netgrif.application.engine.importer.service.throwable.MissingIconKeyException; -import com.netgrif.application.engine.petrinet.domain.VersionType; -import com.netgrif.application.engine.petrinet.domain.throwable.MissingPetriNetMetaDataException; -import com.netgrif.application.engine.petrinet.service.interfaces.IPetriNetService; -import com.netgrif.application.engine.rules.domain.RuleRepository; -import com.netgrif.application.engine.rules.domain.StoredRule; -import com.netgrif.application.engine.rules.domain.scheduled.ScheduleOutcome; -import com.netgrif.application.engine.rules.service.interfaces.IRuleEvaluationScheduleService; -import com.netgrif.application.engine.rules.service.throwable.RuleEvaluationScheduleException; -import com.netgrif.application.engine.startup.runner.SuperCreatorRunner; -import com.netgrif.application.engine.workflow.domain.Case; -import com.netgrif.application.engine.workflow.domain.eventoutcomes.caseoutcomes.CreateCaseEventOutcome; -import com.netgrif.application.engine.workflow.domain.eventoutcomes.petrinetoutcomes.ImportPetriNetEventOutcome; -import com.netgrif.application.engine.workflow.service.interfaces.IWorkflowService; -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.quartz.SimpleScheduleBuilder; -import org.quartz.TriggerBuilder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import java.io.FileInputStream; -import java.io.IOException; -import java.time.LocalDateTime; - -@Disabled -@Slf4j -@SpringBootTest -@ActiveProfiles({"test"}) -@ExtendWith(SpringExtension.class) -class RuleEvaluationScheduleServiceTest { - - @Autowired - private TestHelper testHelper; - - @Autowired - private RuleRepository ruleRepository; - - @Autowired - private IWorkflowService workflowService; - - @Autowired - private IPetriNetService petriNetService; - - @Autowired - private SuperCreatorRunner superCreator; - - @Autowired - private IRuleEvaluationScheduleService ruleEvaluationScheduleService; - - @BeforeEach - public void before() { - testHelper.truncateDbs(); - } - - @Test - @Disabled - void testScheduledRule() throws IOException, MissingPetriNetMetaDataException, RuleEvaluationScheduleException, InterruptedException, MissingIconKeyException { - LoggedUser user = superCreator.getLoggedSuper(); - ImportPetriNetEventOutcome importOutcome = petriNetService.importPetriNet(new FileInputStream("src/test/resources/rule_engine_test.xml"), VersionType.MAJOR, user); - - StoredRule rule = StoredRule.builder() - .when("$case: Case() $event: ScheduledRuleFact(instanceId == $case.stringId, ruleIdentifier == \"rule2\")") - .then("log.info(\"matched rule\"); \n $case.dataSet[\"number_data\"].value += " + 1.0 + "; \n workflowService.save($case);") - .identifier("rule2") - .lastUpdate(LocalDateTime.now()) - .enabled(true) - .build(); - ruleRepository.save(rule); - - CreateCaseEventOutcome caseOutcome = workflowService.createCase(importOutcome.getNet().getStringId(), "Original title", "original color", user); - ScheduleOutcome outcome = ruleEvaluationScheduleService.scheduleRuleEvaluationForCase(caseOutcome.getCase(), "rule2", TriggerBuilder.newTrigger().withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(1).withRepeatCount(5))); - - assert outcome.getJobDetail() != null; - assert outcome.getTrigger() != null; - - Thread.sleep(10000); - String id = caseOutcome.getCase().getStringId(); - assert id != null; - Case caze = workflowService.findOne(id); - assert caze != null; - assert caze.getDataSet().get("number_data").getValue().equals(5561.0); - - } - - @AfterEach - public void after() { - testHelper.truncateDbs(); - } - -} +//package com.netgrif.application.engine.rules.service; +// +//import com.netgrif.application.engine.TestHelper; +//import com.netgrif.application.engine.auth.domain.LoggedUser; +//import com.netgrif.application.engine.importer.service.throwable.MissingIconKeyException; +//import com.netgrif.application.engine.petrinet.domain.VersionType; +//import com.netgrif.application.engine.petrinet.domain.throwable.MissingPetriNetMetaDataException; +//import com.netgrif.application.engine.petrinet.service.interfaces.IPetriNetService; +////import com.netgrif.application.engine.rules.domain.RuleRepository; +////import com.netgrif.application.engine.rules.domain.StoredRule; +////import com.netgrif.application.engine.rules.domain.scheduled.ScheduleOutcome; +////import com.netgrif.application.engine.rules.service.interfaces.IRuleEvaluationScheduleService; +////import com.netgrif.application.engine.rules.service.throwable.RuleEvaluationScheduleException; +//import com.netgrif.application.engine.startup.runner.SuperCreatorRunner; +//import com.netgrif.application.engine.workflow.domain.Case; +//import com.netgrif.application.engine.workflow.domain.eventoutcomes.caseoutcomes.CreateCaseEventOutcome; +//import com.netgrif.application.engine.workflow.domain.eventoutcomes.petrinetoutcomes.ImportPetriNetEventOutcome; +//import com.netgrif.application.engine.workflow.service.interfaces.IWorkflowService; +//import lombok.extern.slf4j.Slf4j; +//import org.junit.jupiter.api.AfterEach; +//import org.junit.jupiter.api.BeforeEach; +//import org.junit.jupiter.api.Disabled; +//import org.junit.jupiter.api.Test; +//import org.junit.jupiter.api.extension.ExtendWith; +//import org.quartz.SimpleScheduleBuilder; +//import org.quartz.TriggerBuilder; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.ActiveProfiles; +//import org.springframework.test.context.junit.jupiter.SpringExtension; +// +//import java.io.FileInputStream; +//import java.io.IOException; +//import java.time.LocalDateTime; +// +//@Disabled +//@Slf4j +//@SpringBootTest +//@ActiveProfiles({"test"}) +//@ExtendWith(SpringExtension.class) +//class RuleEvaluationScheduleServiceTest { +// +// @Autowired +// private TestHelper testHelper; +// +// @Autowired +// private RuleRepository ruleRepository; +// +// @Autowired +// private IWorkflowService workflowService; +// +// @Autowired +// private IPetriNetService petriNetService; +// +// @Autowired +// private SuperCreatorRunner superCreator; +// +// @Autowired +// private IRuleEvaluationScheduleService ruleEvaluationScheduleService; +// +// @BeforeEach +// public void before() { +// testHelper.truncateDbs(); +// } +// +// @Test +// @Disabled +// void testScheduledRule() throws IOException, MissingPetriNetMetaDataException, RuleEvaluationScheduleException, InterruptedException, MissingIconKeyException { +// LoggedUser user = superCreator.getLoggedSuper(); +// ImportPetriNetEventOutcome importOutcome = petriNetService.importPetriNet(new FileInputStream("src/test/resources/rule_engine_test.xml"), VersionType.MAJOR, user); +// +// StoredRule rule = StoredRule.builder() +// .when("$case: Case() $event: ScheduledRuleFact(instanceId == $case.stringId, ruleIdentifier == \"rule2\")") +// .then("log.info(\"matched rule\"); \n $case.dataSet[\"number_data\"].value += " + 1.0 + "; \n workflowService.save($case);") +// .identifier("rule2") +// .lastUpdate(LocalDateTime.now()) +// .enabled(true) +// .build(); +// ruleRepository.save(rule); +// +// CreateCaseEventOutcome caseOutcome = workflowService.createCase(importOutcome.getNet().getStringId(), "Original title", "original color", user); +// ScheduleOutcome outcome = ruleEvaluationScheduleService.scheduleRuleEvaluationForCase(caseOutcome.getCase(), "rule2", TriggerBuilder.newTrigger().withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(1).withRepeatCount(5))); +// +// assert outcome.getJobDetail() != null; +// assert outcome.getTrigger() != null; +// +// Thread.sleep(10000); +// String id = caseOutcome.getCase().getStringId(); +// assert id != null; +// Case caze = workflowService.findOne(id); +// assert caze != null; +// assert caze.getDataSet().get("number_data").getValue().equals(5561.0); +// +// } +// +// @AfterEach +// public void after() { +// testHelper.truncateDbs(); +// } +// +//} From aed26f4ebb7763f5a0cd34b9a5d365400d70b391 Mon Sep 17 00:00:00 2001 From: Stefan Renczes Date: Thu, 5 Sep 2024 08:19:57 +0200 Subject: [PATCH 11/13] [NAE-1975] NAE nodes gRPC communication - modified task events --- pom.xml | 12 ++++++------ .../application/engine/ApplicationEngine.java | 5 +---- .../engine/event/events/task/AssignTaskEvent.java | 6 ++++++ .../engine/event/events/task/CancelTaskEvent.java | 5 +++++ .../engine/event/events/task/CreateTaskEvent.java | 8 +++++++- .../engine/event/events/task/DelegateTaskEvent.java | 5 +++++ .../engine/event/events/task/FinishTaskEvent.java | 6 ++++++ .../engine/event/events/task/TaskEvent.java | 3 +++ .../engine/workflow/service/TaskService.java | 2 +- 9 files changed, 40 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 8871bc233f..7cdc21b159 100644 --- a/pom.xml +++ b/pom.xml @@ -423,12 +423,12 @@ - - com.netgrif - netgrif-drools - 0.0.1-SNAPSHOT - provided - + + + + + + org.apache.poi poi diff --git a/src/main/java/com/netgrif/application/engine/ApplicationEngine.java b/src/main/java/com/netgrif/application/engine/ApplicationEngine.java index bb18c3f8d5..eb667adb4e 100644 --- a/src/main/java/com/netgrif/application/engine/ApplicationEngine.java +++ b/src/main/java/com/netgrif/application/engine/ApplicationEngine.java @@ -4,13 +4,11 @@ import com.netgrif.application.engine.configuration.JsonRootRelProvider; import com.netgrif.application.engine.configuration.groovy.converter.GStringToStringConverter; import com.netgrif.application.engine.petrinet.domain.version.StringToVersionConverter; -import com.netgrif.netgrifdrools.NetgrifDroolsApplication; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.annotation.Aspect; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.properties.ConfigurationPropertiesScan; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; @@ -18,7 +16,6 @@ import org.springframework.core.convert.converter.Converter; import org.springframework.data.mongodb.config.EnableMongoAuditing; import org.springframework.data.mongodb.core.convert.MongoCustomConversions; -import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.server.LinkRelationProvider; import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; @@ -32,7 +29,7 @@ @EnableAspectJAutoProxy @SpringBootApplication( exclude = {DataSourceAutoConfiguration.class}, - scanBasePackages = {"com.netgrif.application.engine", "com.netgrif.netgrifdrools"}) + scanBasePackages = {"com.netgrif.application.engine"}) @EnableMongoAuditing @ConfigurationPropertiesScan @Aspect diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/AssignTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/AssignTaskEvent.java index 5cae0724cc..48f7235b4f 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/task/AssignTaskEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/task/AssignTaskEvent.java @@ -1,6 +1,7 @@ package com.netgrif.application.engine.event.events.task; import com.netgrif.application.engine.petrinet.domain.events.EventPhase; +import com.netgrif.application.engine.petrinet.domain.events.EventType; import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.AssignTaskEventOutcome; public class AssignTaskEvent extends TaskEvent { @@ -13,4 +14,9 @@ public AssignTaskEvent(AssignTaskEventOutcome eventOutcome, EventPhase eventPhas public String getMessage() { return "AssignTaskEvent: Task [" + taskEventOutcome.getTask().getStringId() + "] assigned"; } + + @Override + public EventType getEventType() { + return EventType.ASSIGN; + } } diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/CancelTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/CancelTaskEvent.java index db36e14b28..7339307307 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/task/CancelTaskEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/task/CancelTaskEvent.java @@ -1,6 +1,7 @@ package com.netgrif.application.engine.event.events.task; import com.netgrif.application.engine.petrinet.domain.events.EventPhase; +import com.netgrif.application.engine.petrinet.domain.events.EventType; import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.CancelTaskEventOutcome; public class CancelTaskEvent extends TaskEvent { @@ -13,4 +14,8 @@ public CancelTaskEvent(CancelTaskEventOutcome eventOutcome, EventPhase eventPhas public String getMessage() { return "CancelTaskEvent: Task [" + taskEventOutcome.getTask().getStringId() + "] cancelled"; } + @Override + public EventType getEventType() { + return EventType.CANCEL; + } } diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/CreateTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/CreateTaskEvent.java index 332fa54008..237a6abe19 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/task/CreateTaskEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/task/CreateTaskEvent.java @@ -1,9 +1,10 @@ package com.netgrif.application.engine.event.events.task; import com.netgrif.application.engine.petrinet.domain.events.EventPhase; +import com.netgrif.application.engine.petrinet.domain.events.EventType; import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.TaskEventOutcome; -public class CreateTaskEvent extends TaskEvent { +public class CreateTaskEvent extends TaskEvent { public CreateTaskEvent(TaskEventOutcome eventOutcome, EventPhase eventPhase) { super(eventOutcome, eventPhase); @@ -13,4 +14,9 @@ public CreateTaskEvent(TaskEventOutcome eventOutcome, EventPhase eventPhase) { public String getMessage() { return "CreateTaskEvent: Task [" + taskEventOutcome.getTask().getStringId() + "] created"; } + + @Override + public EventType getEventType() { + return null; + } } diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/DelegateTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/DelegateTaskEvent.java index a47785da77..ce30338b57 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/task/DelegateTaskEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/task/DelegateTaskEvent.java @@ -1,6 +1,7 @@ package com.netgrif.application.engine.event.events.task; import com.netgrif.application.engine.petrinet.domain.events.EventPhase; +import com.netgrif.application.engine.petrinet.domain.events.EventType; import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.DelegateTaskEventOutcome; public class DelegateTaskEvent extends TaskEvent { @@ -13,4 +14,8 @@ public DelegateTaskEvent(DelegateTaskEventOutcome eventOutcome, EventPhase event public String getMessage() { return "DelegateTaskEvent: Task [" + taskEventOutcome.getTask().getStringId() + "] delegated"; } + @Override + public EventType getEventType() { + return EventType.DELEGATE; + } } diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/FinishTaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/FinishTaskEvent.java index f80ab6f1cb..cd068d717f 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/task/FinishTaskEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/task/FinishTaskEvent.java @@ -1,6 +1,7 @@ package com.netgrif.application.engine.event.events.task; import com.netgrif.application.engine.petrinet.domain.events.EventPhase; +import com.netgrif.application.engine.petrinet.domain.events.EventType; import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.FinishTaskEventOutcome; public class FinishTaskEvent extends TaskEvent { @@ -13,4 +14,9 @@ public FinishTaskEvent(FinishTaskEventOutcome eventOutcome, EventPhase eventPhas public String getMessage() { return "FinishTaskEvent: Task [" + taskEventOutcome.getTask().getStringId() + "] finished"; } + + @Override + public EventType getEventType() { + return EventType.FINISH; + } } diff --git a/src/main/java/com/netgrif/application/engine/event/events/task/TaskEvent.java b/src/main/java/com/netgrif/application/engine/event/events/task/TaskEvent.java index 48530cc9f9..9ce0ac2ee9 100644 --- a/src/main/java/com/netgrif/application/engine/event/events/task/TaskEvent.java +++ b/src/main/java/com/netgrif/application/engine/event/events/task/TaskEvent.java @@ -2,6 +2,7 @@ import com.netgrif.application.engine.event.events.Event; import com.netgrif.application.engine.petrinet.domain.events.EventPhase; +import com.netgrif.application.engine.petrinet.domain.events.EventType; import com.netgrif.application.engine.workflow.domain.eventoutcomes.taskoutcomes.TaskEventOutcome; import lombok.Getter; @@ -16,4 +17,6 @@ public TaskEvent(TaskEventOutcome eventOutcome, EventPhase phase) { this.taskEventOutcome = eventOutcome; } + public abstract EventType getEventType(); + } diff --git a/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java b/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java index e8e8ec7655..6312e3a732 100644 --- a/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java +++ b/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java @@ -863,7 +863,7 @@ private Task createFromTransition(Transition transition, Case useCase) { useCase.addTask(task); CreateTaskEventOutcome outcome = new CreateTaskEventOutcome(useCase, task); - //publisher.publishEvent(new CreateTaskEvent(outcome)); + publisher.publishEvent(new CreateTaskEvent(outcome, EventPhase.POST)); return task; } From dec40ca0b50d72e7cb15818903646396dced064a Mon Sep 17 00:00:00 2001 From: Stefan Renczes Date: Fri, 27 Sep 2024 14:44:47 +0200 Subject: [PATCH 12/13] - updated events --- .../application/engine/workflow/service/WorkflowService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java b/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java index 625b0750d1..7201a319d1 100644 --- a/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java +++ b/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java @@ -345,7 +345,7 @@ public CreateCaseEventOutcome createCase(String netId, Function ma CreateCaseEventOutcome outcome = new CreateCaseEventOutcome(); outcome.addOutcomes(eventService.runActions(petriNet.getPreCreateActions(), null, Optional.empty(), params)); - useCase = evaluateRules(new CreateCaseEvent(new CreateCaseEventOutcome(useCase, outcome.getOutcomes()), EventPhase.PRE)); + //evaluateRules(new CreateCaseEvent(new CreateCaseEventOutcome(null, outcome.getOutcomes()), EventPhase.PRE)); historyService.save(new CreateCaseEventLog(useCase, EventPhase.PRE)); log.info("[" + useCase.getStringId() + "]: Case " + useCase.getTitle() + " created"); From 42c5757669c85b0f1b790339dbe2f8f2399dce61 Mon Sep 17 00:00:00 2001 From: Stefan Renczes Date: Mon, 11 Nov 2024 14:57:23 +0100 Subject: [PATCH 13/13] - removed unnecessary classes --- src/main/java/api/auth/AuthorDto.java | 22 - src/main/java/api/events/IDispatcher.java | 25 -- src/main/java/api/events/IEvent.java | 4 - src/main/java/api/events/ISubscriber.java | 38 -- .../api/petrinet/domain/ComponentDto.java | 46 --- .../petrinet/domain/DataFieldLogicDto.java | 60 --- .../domain/DataFieldsResourceDto.java | 25 -- .../api/petrinet/domain/DataGroupDto.java | 135 ------ .../java/api/petrinet/domain/FunctionDto.java | 54 --- .../api/petrinet/domain/I18nStringDto.java | 50 --- .../java/api/petrinet/domain/IconDto.java | 43 -- .../java/api/petrinet/domain/ImportedDto.java | 20 - .../java/api/petrinet/domain/NodeDto.java | 42 -- .../java/api/petrinet/domain/PetriNetDto.java | 297 -------------- .../petrinet/domain/PetriNetObjectDto.java | 21 - .../java/api/petrinet/domain/PlaceDto.java | 62 --- .../java/api/petrinet/domain/PositionDto.java | 32 -- .../api/petrinet/domain/TransactionDto.java | 44 -- .../api/petrinet/domain/TransitionDto.java | 252 ------------ .../java/api/petrinet/domain/arcs/ArcDto.java | 79 ---- .../arcs/reference/ReferencableDto.java | 21 - .../domain/arcs/reference/ReferenceDto.java | 44 -- .../domain/dataset/BooleanFieldDto.java | 22 - .../domain/dataset/ButtonFieldDto.java | 22 - .../petrinet/domain/dataset/CaseFieldDto.java | 30 -- .../domain/dataset/ChoiceFieldDto.java | 54 --- .../petrinet/domain/dataset/DateFieldDto.java | 23 -- .../domain/dataset/DateTimeFieldDto.java | 22 - .../domain/dataset/EnumerationFieldDto.java | 31 -- .../dataset/EnumerationMapFieldDto.java | 30 -- .../api/petrinet/domain/dataset/FieldDto.java | 231 ----------- .../dataset/FieldWithAllowedNetsDto.java | 41 -- .../petrinet/domain/dataset/FileFieldDto.java | 41 -- .../domain/dataset/FileFieldValueDto.java | 32 -- .../domain/dataset/FileListFieldDto.java | 41 -- .../domain/dataset/FileListFieldValueDto.java | 24 -- .../domain/dataset/FilterFieldDto.java | 40 -- .../petrinet/domain/dataset/I18nFieldDto.java | 22 - .../domain/dataset/MapOptionsFieldDto.java | 53 --- .../domain/dataset/MultichoiceFieldDto.java | 31 -- .../dataset/MultichoiceMapFieldDto.java | 31 -- .../domain/dataset/NumberFieldDto.java | 53 --- .../petrinet/domain/dataset/TaskFieldDto.java | 23 -- .../petrinet/domain/dataset/TextFieldDto.java | 65 --- .../petrinet/domain/dataset/UserFieldDto.java | 42 -- .../domain/dataset/UserFieldValueDto.java | 58 --- .../domain/dataset/UserListFieldDto.java | 22 - .../domain/dataset/logic/FieldLayoutDto.java | 88 ---- .../dataset/logic/action/ActionDto.java | 79 ---- .../logic/action/runner/ExpressionDto.java | 30 -- .../validation/LocalisedValidationDto.java | 24 -- .../logic/validation/ValidationDto.java | 27 -- .../petrinet/domain/events/BaseEventDto.java | 71 ---- .../petrinet/domain/events/CaseEventDto.java | 35 -- .../petrinet/domain/events/DataEventDto.java | 27 -- .../api/petrinet/domain/events/EventDto.java | 27 -- .../domain/events/ProcessEventDto.java | 27 -- .../domain/layout/DataGroupLayoutDto.java | 19 - .../petrinet/domain/layout/FormLayoutDto.java | 54 --- .../api/petrinet/domain/layout/LayoutDto.java | 32 -- .../petrinet/domain/layout/TaskLayoutDto.java | 62 --- .../petrinet/domain/roles/ProcessRoleDto.java | 84 ---- .../java/api/petrinet/version/VersionDto.java | 43 -- .../java/api/workflow/domain/CaseDto.java | 303 -------------- .../api/workflow/domain/DataFieldDto.java | 116 ------ .../java/api/workflow/domain/TaskDto.java | 383 ------------------ .../java/api/workflow/domain/TaskPairDto.java | 32 -- .../workflow/domain/triggers/TriggerDto.java | 23 -- .../LocalisedBooleanFieldDto.java | 18 - .../responsebodies/LocalisedCaseFieldDto.java | 29 -- .../LocalisedChoiceFieldDto.java | 37 -- .../responsebodies/LocalisedDateFieldDto.java | 49 --- .../LocalisedDateTimeFieldDto.java | 49 --- .../LocalisedEnumerationFieldDto.java | 26 -- .../LocalisedEnumerationMapFieldDto.java | 27 -- .../web/responsebodies/LocalisedFieldDto.java | 171 -------- .../LocalisedFileListFieldDto.java | 18 - .../LocalisedFilterFieldDto.java | 49 --- .../responsebodies/LocalisedI18nFieldDto.java | 18 - .../LocalisedMapOptionsFieldDto.java | 38 -- .../LocalisedMultichoiceFieldDto.java | 26 -- .../LocalisedMultichoiceMapFieldDto.java | 28 -- .../LocalisedNumberFieldDto.java | 18 - .../responsebodies/LocalisedTextFieldDto.java | 18 - .../responsebodies/LocalisedUserFieldDto.java | 38 -- 85 files changed, 4743 deletions(-) delete mode 100644 src/main/java/api/auth/AuthorDto.java delete mode 100644 src/main/java/api/events/IDispatcher.java delete mode 100644 src/main/java/api/events/IEvent.java delete mode 100644 src/main/java/api/events/ISubscriber.java delete mode 100644 src/main/java/api/petrinet/domain/ComponentDto.java delete mode 100644 src/main/java/api/petrinet/domain/DataFieldLogicDto.java delete mode 100644 src/main/java/api/petrinet/domain/DataFieldsResourceDto.java delete mode 100644 src/main/java/api/petrinet/domain/DataGroupDto.java delete mode 100644 src/main/java/api/petrinet/domain/FunctionDto.java delete mode 100644 src/main/java/api/petrinet/domain/I18nStringDto.java delete mode 100644 src/main/java/api/petrinet/domain/IconDto.java delete mode 100644 src/main/java/api/petrinet/domain/ImportedDto.java delete mode 100644 src/main/java/api/petrinet/domain/NodeDto.java delete mode 100644 src/main/java/api/petrinet/domain/PetriNetDto.java delete mode 100644 src/main/java/api/petrinet/domain/PetriNetObjectDto.java delete mode 100644 src/main/java/api/petrinet/domain/PlaceDto.java delete mode 100644 src/main/java/api/petrinet/domain/PositionDto.java delete mode 100644 src/main/java/api/petrinet/domain/TransactionDto.java delete mode 100644 src/main/java/api/petrinet/domain/TransitionDto.java delete mode 100644 src/main/java/api/petrinet/domain/arcs/ArcDto.java delete mode 100644 src/main/java/api/petrinet/domain/arcs/reference/ReferencableDto.java delete mode 100644 src/main/java/api/petrinet/domain/arcs/reference/ReferenceDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/BooleanFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/ButtonFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/CaseFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/ChoiceFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/DateFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/DateTimeFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/EnumerationFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/EnumerationMapFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/FieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/FieldWithAllowedNetsDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/FileFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/FileFieldValueDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/FileListFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/FileListFieldValueDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/FilterFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/I18nFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/MapOptionsFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/MultichoiceFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/MultichoiceMapFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/NumberFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/TaskFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/TextFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/UserFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/UserFieldValueDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/UserListFieldDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/logic/FieldLayoutDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/logic/action/ActionDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/logic/action/runner/ExpressionDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/logic/validation/LocalisedValidationDto.java delete mode 100644 src/main/java/api/petrinet/domain/dataset/logic/validation/ValidationDto.java delete mode 100644 src/main/java/api/petrinet/domain/events/BaseEventDto.java delete mode 100644 src/main/java/api/petrinet/domain/events/CaseEventDto.java delete mode 100644 src/main/java/api/petrinet/domain/events/DataEventDto.java delete mode 100644 src/main/java/api/petrinet/domain/events/EventDto.java delete mode 100644 src/main/java/api/petrinet/domain/events/ProcessEventDto.java delete mode 100644 src/main/java/api/petrinet/domain/layout/DataGroupLayoutDto.java delete mode 100644 src/main/java/api/petrinet/domain/layout/FormLayoutDto.java delete mode 100644 src/main/java/api/petrinet/domain/layout/LayoutDto.java delete mode 100644 src/main/java/api/petrinet/domain/layout/TaskLayoutDto.java delete mode 100644 src/main/java/api/petrinet/domain/roles/ProcessRoleDto.java delete mode 100644 src/main/java/api/petrinet/version/VersionDto.java delete mode 100644 src/main/java/api/workflow/domain/CaseDto.java delete mode 100644 src/main/java/api/workflow/domain/DataFieldDto.java delete mode 100644 src/main/java/api/workflow/domain/TaskDto.java delete mode 100644 src/main/java/api/workflow/domain/TaskPairDto.java delete mode 100644 src/main/java/api/workflow/domain/triggers/TriggerDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedBooleanFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedCaseFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedChoiceFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedDateFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedDateTimeFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationMapFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedFileListFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedFilterFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedI18nFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedMapOptionsFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceMapFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedNumberFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedTextFieldDto.java delete mode 100644 src/main/java/api/workflow/web/responsebodies/LocalisedUserFieldDto.java diff --git a/src/main/java/api/auth/AuthorDto.java b/src/main/java/api/auth/AuthorDto.java deleted file mode 100644 index 21ab8c1798..0000000000 --- a/src/main/java/api/auth/AuthorDto.java +++ /dev/null @@ -1,22 +0,0 @@ -package api.auth; - -public final class AuthorDto { - - private String id; - - private String email; - - private String fullName; - - public String getId() { - return this.id; - } - - public String getEmail() { - return this.email; - } - - public String getFullName() { - return this.fullName; - } -} diff --git a/src/main/java/api/events/IDispatcher.java b/src/main/java/api/events/IDispatcher.java deleted file mode 100644 index 743cb47645..0000000000 --- a/src/main/java/api/events/IDispatcher.java +++ /dev/null @@ -1,25 +0,0 @@ -package api.events; - -/** - * Interface for event dispatcher - * */ -public interface IDispatcher { - - /** - * Returns ID of dispatcher - * */ - String getId(); - - /** - * Registers ISubscriber object to dispatcher - * @param subscriber a subscriber object from plugin - * */ - void registerSubscriber(ISubscriber subscriber); - - /** - * Listener function for a type of event - * @param eventClass - * */ - void listen(Class eventClass, T event); - void listen(IEvent event); -} diff --git a/src/main/java/api/events/IEvent.java b/src/main/java/api/events/IEvent.java deleted file mode 100644 index b3b3bfb293..0000000000 --- a/src/main/java/api/events/IEvent.java +++ /dev/null @@ -1,4 +0,0 @@ -package api.events; - -public interface IEvent { -} diff --git a/src/main/java/api/events/ISubscriber.java b/src/main/java/api/events/ISubscriber.java deleted file mode 100644 index ab5522098c..0000000000 --- a/src/main/java/api/events/ISubscriber.java +++ /dev/null @@ -1,38 +0,0 @@ -package api.events; - -import java.util.List; - -/** - * Interface for the event subscriber - * */ -public interface ISubscriber { - - /** - * Returns dispatcher IDs, where the subscriber needs to be subscribed - * @return list of IDs - * */ - List getRequiredDispatcherIds(); - - /** - * Subscribes the subscriber to dispatchers. - * */ - void subscribeToDispatchers(); - - /** - * Subscribes the subscriber to one dispatcher. - * */ - void subscribeToDispatcher(IDispatcher dispatcher); - - /** - * Listener function that is called, when an event has been caught in dispatcher - * @param event the event object that is being sent to subscriber - * */ - Object onEvent(IEvent event); - - /** - * Listener function that is called, when an event has been caught in dispatcher - * @param eventClass the type of the event object - * @param event the event object - * */ - void onEvent(Class eventClass, T event); -} diff --git a/src/main/java/api/petrinet/domain/ComponentDto.java b/src/main/java/api/petrinet/domain/ComponentDto.java deleted file mode 100644 index d74e715695..0000000000 --- a/src/main/java/api/petrinet/domain/ComponentDto.java +++ /dev/null @@ -1,46 +0,0 @@ -package api.petrinet.domain; - -import java.util.List; -import java.util.Map; - -public final class ComponentDto { - - private String name; - - private Map properties; - - private List optionIcons; - - public ComponentDto() { - } - - public ComponentDto(String name, Map properties, List optionIcons) { - this.name = name; - this.properties = properties; - this.optionIcons = optionIcons; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Map getProperties() { - return properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } - - public List getOptionIcons() { - return optionIcons; - } - - public void setOptionIcons(List optionIcons) { - this.optionIcons = optionIcons; - } -} diff --git a/src/main/java/api/petrinet/domain/DataFieldLogicDto.java b/src/main/java/api/petrinet/domain/DataFieldLogicDto.java deleted file mode 100644 index 8a5e4f8922..0000000000 --- a/src/main/java/api/petrinet/domain/DataFieldLogicDto.java +++ /dev/null @@ -1,60 +0,0 @@ -package api.petrinet.domain; - -import api.petrinet.domain.events.DataEventDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.Map; -import java.util.Set; - -public final class DataFieldLogicDto { - - private Set behavior; - - private Map events; - - private FieldLayoutDto layout; - - private ComponentDto component; - - public DataFieldLogicDto() { - } - - public DataFieldLogicDto(Set behavior, Map events, FieldLayoutDto layout, ComponentDto component) { - this.behavior = behavior; - this.events = events; - this.layout = layout; - this.component = component; - } - - public Set getBehavior() { - return behavior; - } - - public void setBehavior(Set behavior) { - this.behavior = behavior; - } - - public Map getEvents() { - return events; - } - - public void setEvents(Map events) { - this.events = events; - } - - public FieldLayoutDto getLayout() { - return layout; - } - - public void setLayout(FieldLayoutDto layout) { - this.layout = layout; - } - - public ComponentDto getComponent() { - return component; - } - - public void setComponent(ComponentDto component) { - this.component = component; - } -} diff --git a/src/main/java/api/petrinet/domain/DataFieldsResourceDto.java b/src/main/java/api/petrinet/domain/DataFieldsResourceDto.java deleted file mode 100644 index 014698d22b..0000000000 --- a/src/main/java/api/petrinet/domain/DataFieldsResourceDto.java +++ /dev/null @@ -1,25 +0,0 @@ -package api.petrinet.domain; - -import api.workflow.web.responsebodies.LocalisedFieldDto; - -import java.util.Collection; - -public final class DataFieldsResourceDto { - - private Collection content; - - public DataFieldsResourceDto() { - } - - public DataFieldsResourceDto(Collection content) { - this.content = content; - } - - public Collection getContent() { - return content; - } - - public void setContent(Collection content) { - this.content = content; - } -} diff --git a/src/main/java/api/petrinet/domain/DataGroupDto.java b/src/main/java/api/petrinet/domain/DataGroupDto.java deleted file mode 100644 index 5b93d1817f..0000000000 --- a/src/main/java/api/petrinet/domain/DataGroupDto.java +++ /dev/null @@ -1,135 +0,0 @@ -package api.petrinet.domain; - -import api.petrinet.domain.layout.DataGroupLayoutDto; - -import java.util.Set; - -public final class DataGroupDto extends PetriNetObjectDto { - - private Set data; - - private DataFieldsResourceDto fields; - - private DataGroupLayoutDto layout; - - private I18nStringDto title; - - private String alignment; - - private Boolean stretch; - - private String parentTaskId; - - private String parentTransitionId; - - private String parentCaseId; - - private String parentTaskRefId; - - private int nestingLevel; - - public DataGroupDto() { - } - - public DataGroupDto(Set data, DataFieldsResourceDto fields, DataGroupLayoutDto layout, I18nStringDto title, String alignment, Boolean stretch, String parentTaskId, String parentTransitionId, String parentCaseId, String parentTaskRefId, int nestingLevel) { - this.data = data; - this.fields = fields; - this.layout = layout; - this.title = title; - this.alignment = alignment; - this.stretch = stretch; - this.parentTaskId = parentTaskId; - this.parentTransitionId = parentTransitionId; - this.parentCaseId = parentCaseId; - this.parentTaskRefId = parentTaskRefId; - this.nestingLevel = nestingLevel; - } - - public Set getData() { - return data; - } - - public void setData(Set data) { - this.data = data; - } - - public DataFieldsResourceDto getFields() { - return fields; - } - - public void setFields(DataFieldsResourceDto fields) { - this.fields = fields; - } - - public DataGroupLayoutDto getLayout() { - return layout; - } - - public void setLayout(DataGroupLayoutDto layout) { - this.layout = layout; - } - - public I18nStringDto getTitle() { - return title; - } - - public void setTitle(I18nStringDto title) { - this.title = title; - } - - public String getAlignment() { - return alignment; - } - - public void setAlignment(String alignment) { - this.alignment = alignment; - } - - public Boolean getStretch() { - return stretch; - } - - public void setStretch(Boolean stretch) { - this.stretch = stretch; - } - - public String getParentTaskId() { - return parentTaskId; - } - - public void setParentTaskId(String parentTaskId) { - this.parentTaskId = parentTaskId; - } - - public String getParentTransitionId() { - return parentTransitionId; - } - - public void setParentTransitionId(String parentTransitionId) { - this.parentTransitionId = parentTransitionId; - } - - public String getParentCaseId() { - return parentCaseId; - } - - public void setParentCaseId(String parentCaseId) { - this.parentCaseId = parentCaseId; - } - - public String getParentTaskRefId() { - return parentTaskRefId; - } - - public void setParentTaskRefId(String parentTaskRefId) { - this.parentTaskRefId = parentTaskRefId; - } - - public int getNestingLevel() { - return nestingLevel; - } - - public void setNestingLevel(int nestingLevel) { - this.nestingLevel = nestingLevel; - } -} diff --git a/src/main/java/api/petrinet/domain/FunctionDto.java b/src/main/java/api/petrinet/domain/FunctionDto.java deleted file mode 100644 index 06b77e47f5..0000000000 --- a/src/main/java/api/petrinet/domain/FunctionDto.java +++ /dev/null @@ -1,54 +0,0 @@ -package api.petrinet.domain; - -public final class FunctionDto extends PetriNetObjectDto { - - private String definition; - - private String name; - - private String scope; - - public FunctionDto() { - } - - public FunctionDto(String id) { - super(id); - } - - public FunctionDto(String definition, String name, String scope) { - this.definition = definition; - this.name = name; - this.scope = scope; - } - - public FunctionDto(String id, String definition, String name, String scope) { - super(id); - this.definition = definition; - this.name = name; - this.scope = scope; - } - - public String getDefinition() { - return definition; - } - - public void setDefinition(String definition) { - this.definition = definition; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getScope() { - return scope; - } - - public void setScope(String scope) { - this.scope = scope; - } -} diff --git a/src/main/java/api/petrinet/domain/I18nStringDto.java b/src/main/java/api/petrinet/domain/I18nStringDto.java deleted file mode 100644 index 2dfaaaf548..0000000000 --- a/src/main/java/api/petrinet/domain/I18nStringDto.java +++ /dev/null @@ -1,50 +0,0 @@ -package api.petrinet.domain; - -import java.util.Map; - -public final class I18nStringDto { - - private String defaultValue; - - private String key; - - private Map translations; - - public I18nStringDto() { - } - - public I18nStringDto(String defaultValue, String key, Map translations) { - this.defaultValue = defaultValue; - this.key = key; - this.translations = translations; - } - - public String getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public Map getTranslations() { - return translations; - } - - public void setTranslations(Map translations) { - this.translations = translations; - } - - @Override - public String toString() { - return defaultValue; - } -} diff --git a/src/main/java/api/petrinet/domain/IconDto.java b/src/main/java/api/petrinet/domain/IconDto.java deleted file mode 100644 index d5955604df..0000000000 --- a/src/main/java/api/petrinet/domain/IconDto.java +++ /dev/null @@ -1,43 +0,0 @@ -package api.petrinet.domain; - -public final class IconDto { - - private String key; - - private String value; - - private String type; - - public IconDto() { - } - - public IconDto(String key, String value, String type) { - this.key = key; - this.value = value; - this.type = type; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } -} diff --git a/src/main/java/api/petrinet/domain/ImportedDto.java b/src/main/java/api/petrinet/domain/ImportedDto.java deleted file mode 100644 index bfa5d2d012..0000000000 --- a/src/main/java/api/petrinet/domain/ImportedDto.java +++ /dev/null @@ -1,20 +0,0 @@ -package api.petrinet.domain; - -public abstract class ImportedDto { - private String importId; - - public String getImportId() { - return importId; - } - - public void setImportId(String id) { - this.importId = id; - } - - public ImportedDto() { - } - - public ImportedDto(String importId) { - this.importId = importId; - } -} diff --git a/src/main/java/api/petrinet/domain/NodeDto.java b/src/main/java/api/petrinet/domain/NodeDto.java deleted file mode 100644 index 2ca9283899..0000000000 --- a/src/main/java/api/petrinet/domain/NodeDto.java +++ /dev/null @@ -1,42 +0,0 @@ -package api.petrinet.domain; - -public abstract class NodeDto extends PetriNetObjectDto { - - private PositionDto position; - - private I18nStringDto title; - - public NodeDto() { - } - - public NodeDto(String id) { - super(id); - } - - public NodeDto(PositionDto position, I18nStringDto title) { - this.position = position; - this.title = title; - } - - public NodeDto(String id, PositionDto position, I18nStringDto title) { - super(id); - this.position = position; - this.title = title; - } - - public PositionDto getPosition() { - return position; - } - - public void setPosition(PositionDto position) { - this.position = position; - } - - public I18nStringDto getTitle() { - return title; - } - - public void setTitle(I18nStringDto title) { - this.title = title; - } -} diff --git a/src/main/java/api/petrinet/domain/PetriNetDto.java b/src/main/java/api/petrinet/domain/PetriNetDto.java deleted file mode 100644 index c2ff4d2cde..0000000000 --- a/src/main/java/api/petrinet/domain/PetriNetDto.java +++ /dev/null @@ -1,297 +0,0 @@ -package api.petrinet.domain; - -import api.auth.AuthorDto; -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.arcs.ArcDto; -import api.petrinet.domain.dataset.FieldDto; -import api.petrinet.domain.events.CaseEventDto; -import api.petrinet.domain.events.ProcessEventDto; -import api.petrinet.domain.roles.ProcessRoleDto; -import api.petrinet.version.VersionDto; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; - -public final class PetriNetDto extends PetriNetObjectDto { - private String identifier; - - private I18nStringDto title; - - private boolean defaultRoleEnabled; - - private boolean anonymousRoleEnabled; - - private I18nStringDto defaultCaseName; - - private ExpressionDto defaultCaseNameExpression; - - private String initials; - - private String icon; - - private LocalDateTime creationDate; - - private VersionDto version; - - private AuthorDto author; - - private Map places; - - private Map transitions; - - private Map> arcs; - - private Map dataSet; - - private Map roles; - - private Map transactions; - - private Map processEvents; - - private Map caseEvents; - - private Map> permissions; - - private List negativeViewRoles; - - private Map> userRefs; - - private List functions; - - private boolean initialized; - - private String importXmlPath; - - public PetriNetDto() { - } - - public PetriNetDto(String identifier, I18nStringDto title, boolean defaultRoleEnabled, boolean anonymousRoleEnabled, I18nStringDto defaultCaseName, ExpressionDto defaultCaseNameExpression, String initials, String icon, LocalDateTime creationDate, VersionDto version, AuthorDto author, Map places, Map transitions, Map> arcs, Map dataSet, Map roles, Map transactions, Map processEvents, Map caseEvents, Map> permissions, List negativeViewRoles, Map> userRefs, List functions, boolean initialized, String importXmlPath) { - this.identifier = identifier; - this.title = title; - this.defaultRoleEnabled = defaultRoleEnabled; - this.anonymousRoleEnabled = anonymousRoleEnabled; - this.defaultCaseName = defaultCaseName; - this.defaultCaseNameExpression = defaultCaseNameExpression; - this.initials = initials; - this.icon = icon; - this.creationDate = creationDate; - this.version = version; - this.author = author; - this.places = places; - this.transitions = transitions; - this.arcs = arcs; - this.dataSet = dataSet; - this.roles = roles; - this.transactions = transactions; - this.processEvents = processEvents; - this.caseEvents = caseEvents; - this.permissions = permissions; - this.negativeViewRoles = negativeViewRoles; - this.userRefs = userRefs; - this.functions = functions; - this.initialized = initialized; - this.importXmlPath = importXmlPath; - } - - public String getIdentifier() { - return identifier; - } - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - public I18nStringDto getTitle() { - return title; - } - - public void setTitle(I18nStringDto title) { - this.title = title; - } - - public boolean isDefaultRoleEnabled() { - return defaultRoleEnabled; - } - - public void setDefaultRoleEnabled(boolean defaultRoleEnabled) { - this.defaultRoleEnabled = defaultRoleEnabled; - } - - public boolean isAnonymousRoleEnabled() { - return anonymousRoleEnabled; - } - - public void setAnonymousRoleEnabled(boolean anonymousRoleEnabled) { - this.anonymousRoleEnabled = anonymousRoleEnabled; - } - - public I18nStringDto getDefaultCaseName() { - return defaultCaseName; - } - - public void setDefaultCaseName(I18nStringDto defaultCaseName) { - this.defaultCaseName = defaultCaseName; - } - - public ExpressionDto getDefaultCaseNameExpression() { - return defaultCaseNameExpression; - } - - public void setDefaultCaseNameExpression(ExpressionDto defaultCaseNameExpression) { - this.defaultCaseNameExpression = defaultCaseNameExpression; - } - - public String getInitials() { - return initials; - } - - public void setInitials(String initials) { - this.initials = initials; - } - - public String getIcon() { - return icon; - } - - public void setIcon(String icon) { - this.icon = icon; - } - - public LocalDateTime getCreationDate() { - return creationDate; - } - - public void setCreationDate(LocalDateTime creationDate) { - this.creationDate = creationDate; - } - - public VersionDto getVersion() { - return version; - } - - public void setVersion(VersionDto version) { - this.version = version; - } - - public AuthorDto getAuthor() { - return author; - } - - public void setAuthor(AuthorDto author) { - this.author = author; - } - - public Map getPlaces() { - return places; - } - - public void setPlaces(Map places) { - this.places = places; - } - - public Map getTransitions() { - return transitions; - } - - public void setTransitions(Map transitions) { - this.transitions = transitions; - } - - public Map> getArcs() { - return arcs; - } - - public void setArcs(Map> arcs) { - this.arcs = arcs; - } - - public Map getDataSet() { - return dataSet; - } - - public void setDataSet(Map dataSet) { - this.dataSet = dataSet; - } - - public Map getRoles() { - return roles; - } - - public void setRoles(Map roles) { - this.roles = roles; - } - - public Map getTransactions() { - return transactions; - } - - public void setTransactions(Map transactions) { - this.transactions = transactions; - } - - public Map getProcessEvents() { - return processEvents; - } - - public void setProcessEvents(Map processEvents) { - this.processEvents = processEvents; - } - - public Map getCaseEvents() { - return caseEvents; - } - - public void setCaseEvents(Map caseEvents) { - this.caseEvents = caseEvents; - } - - public Map> getPermissions() { - return permissions; - } - - public void setPermissions(Map> permissions) { - this.permissions = permissions; - } - - public List getNegativeViewRoles() { - return negativeViewRoles; - } - - public void setNegativeViewRoles(List negativeViewRoles) { - this.negativeViewRoles = negativeViewRoles; - } - - public Map> getUserRefs() { - return userRefs; - } - - public void setUserRefs(Map> userRefs) { - this.userRefs = userRefs; - } - - public List getFunctions() { - return functions; - } - - public void setFunctions(List functions) { - this.functions = functions; - } - - public boolean isInitialized() { - return initialized; - } - - public void setInitialized(boolean initialized) { - this.initialized = initialized; - } - - public String getImportXmlPath() { - return importXmlPath; - } - - public void setImportXmlPath(String importXmlPath) { - this.importXmlPath = importXmlPath; - } -} diff --git a/src/main/java/api/petrinet/domain/PetriNetObjectDto.java b/src/main/java/api/petrinet/domain/PetriNetObjectDto.java deleted file mode 100644 index a358f0da73..0000000000 --- a/src/main/java/api/petrinet/domain/PetriNetObjectDto.java +++ /dev/null @@ -1,21 +0,0 @@ -package api.petrinet.domain; - -public abstract class PetriNetObjectDto extends ImportedDto { - - private String id; - - public PetriNetObjectDto() { - } - - public PetriNetObjectDto(String id) { - this.id = id; - } - - public String getStringId() { - return id; - } - - public void setStringId(String id) { - this.id = id; - } -} diff --git a/src/main/java/api/petrinet/domain/PlaceDto.java b/src/main/java/api/petrinet/domain/PlaceDto.java deleted file mode 100644 index 42e5d3cd83..0000000000 --- a/src/main/java/api/petrinet/domain/PlaceDto.java +++ /dev/null @@ -1,62 +0,0 @@ -package api.petrinet.domain; - -public final class PlaceDto extends NodeDto { - - private Integer tokens; - - private Boolean isStatic; - - public PlaceDto() { - } - - public PlaceDto(String id) { - super(id); - } - - public PlaceDto(PositionDto position, I18nStringDto title) { - super(position, title); - } - - public PlaceDto(String id, PositionDto position, I18nStringDto title) { - super(id, position, title); - } - - public PlaceDto(Integer tokens, Boolean isStatic) { - this.tokens = tokens; - this.isStatic = isStatic; - } - - public PlaceDto(String id, Integer tokens, Boolean isStatic) { - super(id); - this.tokens = tokens; - this.isStatic = isStatic; - } - - public PlaceDto(PositionDto position, I18nStringDto title, Integer tokens, Boolean isStatic) { - super(position, title); - this.tokens = tokens; - this.isStatic = isStatic; - } - - public PlaceDto(String id, PositionDto position, I18nStringDto title, Integer tokens, Boolean isStatic) { - super(id, position, title); - this.tokens = tokens; - this.isStatic = isStatic; - } - - public Integer getTokens() { - return tokens; - } - - public void setTokens(Integer tokens) { - this.tokens = tokens; - } - - public Boolean getStatic() { - return isStatic; - } - - public void setStatic(Boolean aStatic) { - isStatic = aStatic; - } -} diff --git a/src/main/java/api/petrinet/domain/PositionDto.java b/src/main/java/api/petrinet/domain/PositionDto.java deleted file mode 100644 index 0f0c47e8cb..0000000000 --- a/src/main/java/api/petrinet/domain/PositionDto.java +++ /dev/null @@ -1,32 +0,0 @@ -package api.petrinet.domain; - -public final class PositionDto { - - private Integer x; - - private Integer y; - - public PositionDto() { - } - - public PositionDto(Integer x, Integer y) { - this.x = x; - this.y = y; - } - - public Integer getX() { - return x; - } - - public void setX(Integer x) { - this.x = x; - } - - public Integer getY() { - return y; - } - - public void setY(Integer y) { - this.y = y; - } -} diff --git a/src/main/java/api/petrinet/domain/TransactionDto.java b/src/main/java/api/petrinet/domain/TransactionDto.java deleted file mode 100644 index f52616b8d5..0000000000 --- a/src/main/java/api/petrinet/domain/TransactionDto.java +++ /dev/null @@ -1,44 +0,0 @@ -package api.petrinet.domain; - -import java.util.List; - -public final class TransactionDto extends PetriNetObjectDto { - - private List transitions; - - private I18nStringDto title; - - public TransactionDto() { - } - - public TransactionDto(String id) { - super(id); - } - - public TransactionDto(List transitions, I18nStringDto title) { - this.transitions = transitions; - this.title = title; - } - - public TransactionDto(String id, List transitions, I18nStringDto title) { - super(id); - this.transitions = transitions; - this.title = title; - } - - public List getTransitions() { - return transitions; - } - - public void setTransitions(List transitions) { - this.transitions = transitions; - } - - public I18nStringDto getTitle() { - return title; - } - - public void setTitle(I18nStringDto title) { - this.title = title; - } -} diff --git a/src/main/java/api/petrinet/domain/TransitionDto.java b/src/main/java/api/petrinet/domain/TransitionDto.java deleted file mode 100644 index 018c4e932d..0000000000 --- a/src/main/java/api/petrinet/domain/TransitionDto.java +++ /dev/null @@ -1,252 +0,0 @@ -package api.petrinet.domain; - -import api.workflow.domain.triggers.TriggerDto; -import api.petrinet.domain.events.EventDto; -import api.petrinet.domain.layout.TaskLayoutDto; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -public final class TransitionDto extends NodeDto { - - private Map dataGroups; - - private LinkedHashMap dataSet; - - private Map> roles; - - private List negativeViewRoles; - - private Map> userRefs; - - private List triggers; - - private TaskLayoutDto layout; - - private Integer priority; - - private String assignPolicy; - - private String icon; - - private String dataFocusPolicy; - - private String finishPolicy; - - private Map events; - - private Map assignedUserPolicy; - - private String defaultRoleId; - - public TransitionDto() { - } - - public TransitionDto(String id) { - super(id); - } - - public TransitionDto(PositionDto position, I18nStringDto title) { - super(position, title); - } - - public TransitionDto(String id, PositionDto position, I18nStringDto title) { - super(id, position, title); - } - - public TransitionDto(Map dataGroups, LinkedHashMap dataSet, Map> roles, List negativeViewRoles, Map> userRefs, List triggers, TaskLayoutDto layout, Integer priority, String assignPolicy, String icon, String dataFocusPolicy, String finishPolicy, Map events, Map assignedUserPolicy, String defaultRoleId) { - this.dataGroups = dataGroups; - this.dataSet = dataSet; - this.roles = roles; - this.negativeViewRoles = negativeViewRoles; - this.userRefs = userRefs; - this.triggers = triggers; - this.layout = layout; - this.priority = priority; - this.assignPolicy = assignPolicy; - this.icon = icon; - this.dataFocusPolicy = dataFocusPolicy; - this.finishPolicy = finishPolicy; - this.events = events; - this.assignedUserPolicy = assignedUserPolicy; - this.defaultRoleId = defaultRoleId; - } - - public TransitionDto(String id, Map dataGroups, LinkedHashMap dataSet, Map> roles, List negativeViewRoles, Map> userRefs, List triggers, TaskLayoutDto layout, Integer priority, String assignPolicy, String icon, String dataFocusPolicy, String finishPolicy, Map events, Map assignedUserPolicy, String defaultRoleId) { - super(id); - this.dataGroups = dataGroups; - this.dataSet = dataSet; - this.roles = roles; - this.negativeViewRoles = negativeViewRoles; - this.userRefs = userRefs; - this.triggers = triggers; - this.layout = layout; - this.priority = priority; - this.assignPolicy = assignPolicy; - this.icon = icon; - this.dataFocusPolicy = dataFocusPolicy; - this.finishPolicy = finishPolicy; - this.events = events; - this.assignedUserPolicy = assignedUserPolicy; - this.defaultRoleId = defaultRoleId; - } - - public TransitionDto(PositionDto position, I18nStringDto title, Map dataGroups, LinkedHashMap dataSet, Map> roles, List negativeViewRoles, Map> userRefs, List triggers, TaskLayoutDto layout, Integer priority, String assignPolicy, String icon, String dataFocusPolicy, String finishPolicy, Map events, Map assignedUserPolicy, String defaultRoleId) { - super(position, title); - this.dataGroups = dataGroups; - this.dataSet = dataSet; - this.roles = roles; - this.negativeViewRoles = negativeViewRoles; - this.userRefs = userRefs; - this.triggers = triggers; - this.layout = layout; - this.priority = priority; - this.assignPolicy = assignPolicy; - this.icon = icon; - this.dataFocusPolicy = dataFocusPolicy; - this.finishPolicy = finishPolicy; - this.events = events; - this.assignedUserPolicy = assignedUserPolicy; - this.defaultRoleId = defaultRoleId; - } - - public TransitionDto(String id, PositionDto position, I18nStringDto title, Map dataGroups, LinkedHashMap dataSet, Map> roles, List negativeViewRoles, Map> userRefs, List triggers, TaskLayoutDto layout, Integer priority, String assignPolicy, String icon, String dataFocusPolicy, String finishPolicy, Map events, Map assignedUserPolicy, String defaultRoleId) { - super(id, position, title); - this.dataGroups = dataGroups; - this.dataSet = dataSet; - this.roles = roles; - this.negativeViewRoles = negativeViewRoles; - this.userRefs = userRefs; - this.triggers = triggers; - this.layout = layout; - this.priority = priority; - this.assignPolicy = assignPolicy; - this.icon = icon; - this.dataFocusPolicy = dataFocusPolicy; - this.finishPolicy = finishPolicy; - this.events = events; - this.assignedUserPolicy = assignedUserPolicy; - this.defaultRoleId = defaultRoleId; - } - - public Map getDataGroups() { - return dataGroups; - } - - public void setDataGroups(Map dataGroups) { - this.dataGroups = dataGroups; - } - - public LinkedHashMap getDataSet() { - return dataSet; - } - - public void setDataSet(LinkedHashMap dataSet) { - this.dataSet = dataSet; - } - - public Map> getRoles() { - return roles; - } - - public void setRoles(Map> roles) { - this.roles = roles; - } - - public List getNegativeViewRoles() { - return negativeViewRoles; - } - - public void setNegativeViewRoles(List negativeViewRoles) { - this.negativeViewRoles = negativeViewRoles; - } - - public Map> getUserRefs() { - return userRefs; - } - - public void setUserRefs(Map> userRefs) { - this.userRefs = userRefs; - } - - public List getTriggers() { - return triggers; - } - - public void setTriggers(List triggers) { - this.triggers = triggers; - } - - public TaskLayoutDto getLayout() { - return layout; - } - - public void setLayout(TaskLayoutDto layout) { - this.layout = layout; - } - - public Integer getPriority() { - return priority; - } - - public void setPriority(Integer priority) { - this.priority = priority; - } - - public String getAssignPolicy() { - return assignPolicy; - } - - public void setAssignPolicy(String assignPolicy) { - this.assignPolicy = assignPolicy; - } - - public String getIcon() { - return icon; - } - - public void setIcon(String icon) { - this.icon = icon; - } - - public String getDataFocusPolicy() { - return dataFocusPolicy; - } - - public void setDataFocusPolicy(String dataFocusPolicy) { - this.dataFocusPolicy = dataFocusPolicy; - } - - public String getFinishPolicy() { - return finishPolicy; - } - - public void setFinishPolicy(String finishPolicy) { - this.finishPolicy = finishPolicy; - } - - public Map getEvents() { - return events; - } - - public void setEvents(Map events) { - this.events = events; - } - - public Map getAssignedUserPolicy() { - return assignedUserPolicy; - } - - public void setAssignedUserPolicy(Map assignedUserPolicy) { - this.assignedUserPolicy = assignedUserPolicy; - } - - public String getDefaultRoleId() { - return defaultRoleId; - } - - public void setDefaultRoleId(String defaultRoleId) { - this.defaultRoleId = defaultRoleId; - } -} diff --git a/src/main/java/api/petrinet/domain/arcs/ArcDto.java b/src/main/java/api/petrinet/domain/arcs/ArcDto.java deleted file mode 100644 index 8ec376a5e5..0000000000 --- a/src/main/java/api/petrinet/domain/arcs/ArcDto.java +++ /dev/null @@ -1,79 +0,0 @@ -package api.petrinet.domain.arcs; - -import api.petrinet.domain.NodeDto; -import api.petrinet.domain.arcs.reference.ReferenceDto; - -public final class ArcDto { - - private NodeDto source; - - private String sourceId; - - private NodeDto destination; - - private String destinationId; - - private Integer multiplicity; - - private ReferenceDto reference; - - public ArcDto() { - } - - public ArcDto(NodeDto source, String sourceId, NodeDto destination, String destinationId, Integer multiplicity, ReferenceDto reference) { - this.source = source; - this.sourceId = sourceId; - this.destination = destination; - this.destinationId = destinationId; - this.multiplicity = multiplicity; - this.reference = reference; - } - - public NodeDto getSource() { - return source; - } - - public void setSource(NodeDto source) { - this.source = source; - } - - public String getSourceId() { - return sourceId; - } - - public void setSourceId(String sourceId) { - this.sourceId = sourceId; - } - - public NodeDto getDestination() { - return destination; - } - - public void setDestination(NodeDto destination) { - this.destination = destination; - } - - public String getDestinationId() { - return destinationId; - } - - public void setDestinationId(String destinationId) { - this.destinationId = destinationId; - } - - public Integer getMultiplicity() { - return multiplicity; - } - - public void setMultiplicity(Integer multiplicity) { - this.multiplicity = multiplicity; - } - - public ReferenceDto getReference() { - return reference; - } - - public void setReference(ReferenceDto reference) { - this.reference = reference; - } -} diff --git a/src/main/java/api/petrinet/domain/arcs/reference/ReferencableDto.java b/src/main/java/api/petrinet/domain/arcs/reference/ReferencableDto.java deleted file mode 100644 index 0f3a4091af..0000000000 --- a/src/main/java/api/petrinet/domain/arcs/reference/ReferencableDto.java +++ /dev/null @@ -1,21 +0,0 @@ -package api.petrinet.domain.arcs.reference; - -public final class ReferencableDto { - - private int multiplicity; - - public ReferencableDto() { - } - - public ReferencableDto(int multiplicity) { - this.multiplicity = multiplicity; - } - - public int getMultiplicity() { - return multiplicity; - } - - public void setMultiplicity(int multiplicity) { - this.multiplicity = multiplicity; - } -} diff --git a/src/main/java/api/petrinet/domain/arcs/reference/ReferenceDto.java b/src/main/java/api/petrinet/domain/arcs/reference/ReferenceDto.java deleted file mode 100644 index 51cb80977b..0000000000 --- a/src/main/java/api/petrinet/domain/arcs/reference/ReferenceDto.java +++ /dev/null @@ -1,44 +0,0 @@ -package api.petrinet.domain.arcs.reference; - -public final class ReferenceDto { - - private String reference; - - private String type; - - private ReferencableDto referencable; - - - public ReferenceDto() { - } - - public ReferenceDto(String reference, String type, ReferencableDto referencable) { - this.reference = reference; - this.type = type; - this.referencable = referencable; - } - - public String getReference() { - return reference; - } - - public void setReference(String reference) { - this.reference = reference; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public ReferencableDto getReferencable() { - return referencable; - } - - public void setReferencable(ReferencableDto referencable) { - this.referencable = referencable; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/BooleanFieldDto.java b/src/main/java/api/petrinet/domain/dataset/BooleanFieldDto.java deleted file mode 100644 index ec65d5cd9d..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/BooleanFieldDto.java +++ /dev/null @@ -1,22 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.events.DataEventDto; - -import java.util.List; -import java.util.Map; - -public final class BooleanFieldDto extends FieldDto { - - public BooleanFieldDto() { - } - - public BooleanFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, Boolean value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, Boolean defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/ButtonFieldDto.java b/src/main/java/api/petrinet/domain/dataset/ButtonFieldDto.java deleted file mode 100644 index 40c12e26df..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/ButtonFieldDto.java +++ /dev/null @@ -1,22 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import api.petrinet.domain.events.DataEventDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; -import java.util.Map; - -public final class ButtonFieldDto extends FieldDto { - - public ButtonFieldDto() { - } - - public ButtonFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, String value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, String defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/CaseFieldDto.java b/src/main/java/api/petrinet/domain/dataset/CaseFieldDto.java deleted file mode 100644 index e5b6bccfbb..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/CaseFieldDto.java +++ /dev/null @@ -1,30 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.events.DataEventDto; - -import java.util.List; -import java.util.Map; - -public final class CaseFieldDto extends FieldWithAllowedNetsDto> { - - public CaseFieldDto() { - } - - public CaseFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, List value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, List defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } - - public CaseFieldDto(List allowedNets) { - super(allowedNets); - } - - public CaseFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, List value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, List defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, List allowedNets) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId, allowedNets); - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/ChoiceFieldDto.java b/src/main/java/api/petrinet/domain/dataset/ChoiceFieldDto.java deleted file mode 100644 index 1b9ee29ec1..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/ChoiceFieldDto.java +++ /dev/null @@ -1,54 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import api.petrinet.domain.events.DataEventDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -public abstract class ChoiceFieldDto extends FieldDto { - - private Set choices; - - private ExpressionDto choicesExpression; - - public ChoiceFieldDto() { - } - - public ChoiceFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, T value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, T defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } - - public ChoiceFieldDto(Set choices, ExpressionDto choicesExpression) { - this.choices = choices; - this.choicesExpression = choicesExpression; - } - - public ChoiceFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, T value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, T defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Set choices, ExpressionDto choicesExpression) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - this.choices = choices; - this.choicesExpression = choicesExpression; - } - - public Set getChoices() { - return choices; - } - - public void setChoices(Set choices) { - this.choices = choices; - } - - public ExpressionDto getChoicesExpression() { - return choicesExpression; - } - - public void setChoicesExpression(ExpressionDto choicesExpression) { - this.choicesExpression = choicesExpression; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/DateFieldDto.java b/src/main/java/api/petrinet/domain/dataset/DateFieldDto.java deleted file mode 100644 index 12b0405d47..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/DateFieldDto.java +++ /dev/null @@ -1,23 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.events.DataEventDto; - -import java.time.LocalDate; -import java.util.List; -import java.util.Map; - -public final class DateFieldDto extends FieldDto { - - public DateFieldDto() { - } - - public DateFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, LocalDate value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, LocalDate defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/DateTimeFieldDto.java b/src/main/java/api/petrinet/domain/dataset/DateTimeFieldDto.java deleted file mode 100644 index c1bab19466..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/DateTimeFieldDto.java +++ /dev/null @@ -1,22 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import api.petrinet.domain.events.DataEventDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; - -public final class DateTimeFieldDto extends FieldDto { - public DateTimeFieldDto() { - } - - public DateTimeFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, LocalDateTime value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, LocalDateTime defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/EnumerationFieldDto.java b/src/main/java/api/petrinet/domain/dataset/EnumerationFieldDto.java deleted file mode 100644 index 22488b124e..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/EnumerationFieldDto.java +++ /dev/null @@ -1,31 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import api.petrinet.domain.events.DataEventDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -public final class EnumerationFieldDto extends ChoiceFieldDto { - - public EnumerationFieldDto() { - } - - public EnumerationFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, I18nStringDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, I18nStringDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } - - public EnumerationFieldDto(Set choices, ExpressionDto choicesExpression) { - super(choices, choicesExpression); - } - - public EnumerationFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, I18nStringDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, I18nStringDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Set choices, ExpressionDto choicesExpression) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId, choices, choicesExpression); - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/EnumerationMapFieldDto.java b/src/main/java/api/petrinet/domain/dataset/EnumerationMapFieldDto.java deleted file mode 100644 index f82eab0fac..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/EnumerationMapFieldDto.java +++ /dev/null @@ -1,30 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.events.DataEventDto; - -import java.util.List; -import java.util.Map; - -public final class EnumerationMapFieldDto extends MapOptionsFieldDto { - - public EnumerationMapFieldDto() { - } - - public EnumerationMapFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, String value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, String defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } - - public EnumerationMapFieldDto(Map options, ExpressionDto optionsExpression) { - super(options, optionsExpression); - } - - public EnumerationMapFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, String value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, String defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Map options, ExpressionDto optionsExpression) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId, options, optionsExpression); - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/FieldDto.java b/src/main/java/api/petrinet/domain/dataset/FieldDto.java deleted file mode 100644 index c7ba626133..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/FieldDto.java +++ /dev/null @@ -1,231 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.ImportedDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import api.petrinet.domain.events.DataEventDto; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import java.util.List; -import java.util.Map; - -public abstract class FieldDto extends ImportedDto { - - private String id; - - private String type; - - private I18nStringDto name; - - private I18nStringDto description; - - private I18nStringDto placeholder; - - private ObjectNode behavior; - - private FieldLayoutDto layout; - - private T value; - - private Long order; - - private boolean immediate; - - private Map events; - - private String encryption; - - private Integer length; - - private ComponentDto component; - - private T defaultValue; - - private ExpressionDto initExpression; - - private List validations; - - private String parentTaskId; - - private String parentCaseId; - - public FieldDto() { - } - - public FieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, T value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, T defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - this.id = id; - this.type = type; - this.name = name; - this.description = description; - this.placeholder = placeholder; - this.behavior = behavior; - this.layout = layout; - this.value = value; - this.order = order; - this.immediate = immediate; - this.events = events; - this.encryption = encryption; - this.length = length; - this.component = component; - this.defaultValue = defaultValue; - this.initExpression = initExpression; - this.validations = validations; - this.parentTaskId = parentTaskId; - this.parentCaseId = parentCaseId; - } - - public String getStringId() { - return id; - } - - public void setStringId(String id) { - this.id = id; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public I18nStringDto getName() { - return name; - } - - public void setName(I18nStringDto name) { - this.name = name; - } - - public I18nStringDto getDescription() { - return description; - } - - public void setDescription(I18nStringDto description) { - this.description = description; - } - - public I18nStringDto getPlaceholder() { - return placeholder; - } - - public void setPlaceholder(I18nStringDto placeholder) { - this.placeholder = placeholder; - } - - public ObjectNode getBehavior() { - return behavior; - } - - public void setBehavior(ObjectNode behavior) { - this.behavior = behavior; - } - - public FieldLayoutDto getLayout() { - return layout; - } - - public void setLayout(FieldLayoutDto layout) { - this.layout = layout; - } - - public T getValue() { - return value; - } - - public void setValue(T value) { - this.value = value; - } - - public Long getOrder() { - return order; - } - - public void setOrder(Long order) { - this.order = order; - } - - public boolean isImmediate() { - return immediate; - } - - public void setImmediate(boolean immediate) { - this.immediate = immediate; - } - - public Map getEvents() { - return events; - } - - public void setEvents(Map events) { - this.events = events; - } - - public String getEncryption() { - return encryption; - } - - public void setEncryption(String encryption) { - this.encryption = encryption; - } - - public Integer getLength() { - return length; - } - - public void setLength(Integer length) { - this.length = length; - } - - public ComponentDto getComponent() { - return component; - } - - public void setComponent(ComponentDto component) { - this.component = component; - } - - public T getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(T defaultValue) { - this.defaultValue = defaultValue; - } - - public ExpressionDto getInitExpression() { - return initExpression; - } - - public void setInitExpression(ExpressionDto initExpression) { - this.initExpression = initExpression; - } - - public List getValidations() { - return validations; - } - - public void setValidations(List validations) { - this.validations = validations; - } - - public String getParentTaskId() { - return parentTaskId; - } - - public void setParentTaskId(String parentTaskId) { - this.parentTaskId = parentTaskId; - } - - public String getParentCaseId() { - return parentCaseId; - } - - public void setParentCaseId(String parentCaseId) { - this.parentCaseId = parentCaseId; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/FieldWithAllowedNetsDto.java b/src/main/java/api/petrinet/domain/dataset/FieldWithAllowedNetsDto.java deleted file mode 100644 index bdd0ae4a90..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/FieldWithAllowedNetsDto.java +++ /dev/null @@ -1,41 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import api.petrinet.domain.events.DataEventDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; -import java.util.Map; - -public abstract class FieldWithAllowedNetsDto extends FieldDto { - - private List allowedNets; - - public FieldWithAllowedNetsDto() { - } - - public FieldWithAllowedNetsDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, T value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, T defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } - - public FieldWithAllowedNetsDto(List allowedNets) { - this.allowedNets = allowedNets; - } - - public FieldWithAllowedNetsDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, T value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, T defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, List allowedNets) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - this.allowedNets = allowedNets; - } - - public List getAllowedNets() { - return allowedNets; - } - - public void setAllowedNets(List allowedNets) { - this.allowedNets = allowedNets; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/FileFieldDto.java b/src/main/java/api/petrinet/domain/dataset/FileFieldDto.java deleted file mode 100644 index ff58a16531..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/FileFieldDto.java +++ /dev/null @@ -1,41 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.events.DataEventDto; - -import java.util.List; -import java.util.Map; - -public final class FileFieldDto extends FieldDto { - - private Boolean remote; - - public FileFieldDto() { - } - - public FileFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, FileFieldValueDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, FileFieldValueDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } - - public FileFieldDto(Boolean remote) { - this.remote = remote; - } - - public FileFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, FileFieldValueDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, FileFieldValueDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Boolean remote) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - this.remote = remote; - } - - public Boolean getRemote() { - return remote; - } - - public void setRemote(Boolean remote) { - this.remote = remote; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/FileFieldValueDto.java b/src/main/java/api/petrinet/domain/dataset/FileFieldValueDto.java deleted file mode 100644 index 7e931cff7b..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/FileFieldValueDto.java +++ /dev/null @@ -1,32 +0,0 @@ -package api.petrinet.domain.dataset; - -public final class FileFieldValueDto { - - private String name; - - private String path; - - public FileFieldValueDto() { - } - - public FileFieldValueDto(String name, String path) { - this.name = name; - this.path = path; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/FileListFieldDto.java b/src/main/java/api/petrinet/domain/dataset/FileListFieldDto.java deleted file mode 100644 index 0b7ea587d2..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/FileListFieldDto.java +++ /dev/null @@ -1,41 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.events.DataEventDto; - -import java.util.List; -import java.util.Map; - -public final class FileListFieldDto extends FieldDto { - - private Boolean remote; - - public FileListFieldDto() { - } - - public FileListFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, FileListFieldValueDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, FileListFieldValueDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } - - public FileListFieldDto(Boolean remote) { - this.remote = remote; - } - - public FileListFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, FileListFieldValueDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, FileListFieldValueDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Boolean remote) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - this.remote = remote; - } - - public Boolean getRemote() { - return remote; - } - - public void setRemote(Boolean remote) { - this.remote = remote; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/FileListFieldValueDto.java b/src/main/java/api/petrinet/domain/dataset/FileListFieldValueDto.java deleted file mode 100644 index c15fe5e1c2..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/FileListFieldValueDto.java +++ /dev/null @@ -1,24 +0,0 @@ -package api.petrinet.domain.dataset; - -import java.util.HashSet; - -public final class FileListFieldValueDto { - - private HashSet namesPaths; - - public FileListFieldValueDto() { - } - - public FileListFieldValueDto(HashSet namesPaths) { - this.namesPaths = namesPaths; - } - - public HashSet getNamesPaths() { - return namesPaths; - } - - public void setNamesPaths(HashSet namesPaths) { - this.namesPaths = namesPaths; - } -} - diff --git a/src/main/java/api/petrinet/domain/dataset/FilterFieldDto.java b/src/main/java/api/petrinet/domain/dataset/FilterFieldDto.java deleted file mode 100644 index 7a05d5f168..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/FilterFieldDto.java +++ /dev/null @@ -1,40 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.events.DataEventDto; - -import java.util.List; -import java.util.Map; - -public final class FilterFieldDto extends FieldWithAllowedNetsDto { - - private Map filterMetadata; - - public FilterFieldDto() { - } - - public FilterFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, String value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, String defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } - - public FilterFieldDto(List allowedNets) { - super(allowedNets); - } - - public FilterFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, String value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, String defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, List allowedNets) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId, allowedNets); - } - - public Map getFilterMetadata() { - return filterMetadata; - } - - public void setFilterMetadata(Map filterMetadata) { - this.filterMetadata = filterMetadata; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/I18nFieldDto.java b/src/main/java/api/petrinet/domain/dataset/I18nFieldDto.java deleted file mode 100644 index 292d439819..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/I18nFieldDto.java +++ /dev/null @@ -1,22 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.events.DataEventDto; - -import java.util.List; -import java.util.Map; - -public final class I18nFieldDto extends FieldDto { - - public I18nFieldDto() { - } - - public I18nFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, I18nFieldDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, I18nFieldDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/MapOptionsFieldDto.java b/src/main/java/api/petrinet/domain/dataset/MapOptionsFieldDto.java deleted file mode 100644 index 9c29eab2ba..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/MapOptionsFieldDto.java +++ /dev/null @@ -1,53 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import api.petrinet.domain.events.DataEventDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; -import java.util.Map; - -public abstract class MapOptionsFieldDto extends FieldDto { - - private Map options; - - private ExpressionDto optionsExpression; - - public MapOptionsFieldDto() { - } - - public MapOptionsFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, U value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, U defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } - - public MapOptionsFieldDto(Map options, ExpressionDto optionsExpression) { - this.options = options; - this.optionsExpression = optionsExpression; - } - - public MapOptionsFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, U value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, U defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Map options, ExpressionDto optionsExpression) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - this.options = options; - this.optionsExpression = optionsExpression; - } - - public Map getOptions() { - return options; - } - - public void setOptions(Map options) { - this.options = options; - } - - public ExpressionDto getOptionsExpression() { - return optionsExpression; - } - - public void setOptionsExpression(ExpressionDto optionsExpression) { - this.optionsExpression = optionsExpression; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/MultichoiceFieldDto.java b/src/main/java/api/petrinet/domain/dataset/MultichoiceFieldDto.java deleted file mode 100644 index d2faa8dd04..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/MultichoiceFieldDto.java +++ /dev/null @@ -1,31 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.events.DataEventDto; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -public final class MultichoiceFieldDto extends ChoiceFieldDto { - - public MultichoiceFieldDto() { - } - - public MultichoiceFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, I18nStringDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, I18nStringDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } - - public MultichoiceFieldDto(Set choices, ExpressionDto choicesExpression) { - super(choices, choicesExpression); - } - - public MultichoiceFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, I18nStringDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, I18nStringDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Set choices, ExpressionDto choicesExpression) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId, choices, choicesExpression); - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/MultichoiceMapFieldDto.java b/src/main/java/api/petrinet/domain/dataset/MultichoiceMapFieldDto.java deleted file mode 100644 index 2010e2de2f..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/MultichoiceMapFieldDto.java +++ /dev/null @@ -1,31 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import api.petrinet.domain.events.DataEventDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -public final class MultichoiceMapFieldDto extends MapOptionsFieldDto> { - - public MultichoiceMapFieldDto() { - } - - public MultichoiceMapFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, HashSet value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, HashSet defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } - - public MultichoiceMapFieldDto(Map options, ExpressionDto optionsExpression) { - super(options, optionsExpression); - } - - public MultichoiceMapFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, HashSet value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, HashSet defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Map options, ExpressionDto optionsExpression) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId, options, optionsExpression); - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/NumberFieldDto.java b/src/main/java/api/petrinet/domain/dataset/NumberFieldDto.java deleted file mode 100644 index 8d9d35df83..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/NumberFieldDto.java +++ /dev/null @@ -1,53 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.events.DataEventDto; - -import java.util.List; -import java.util.Map; - -public final class NumberFieldDto extends FieldDto { - - private Double minValue; - - private Double maxValue; - - public NumberFieldDto() { - } - - public NumberFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, Double value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, Double defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } - - public NumberFieldDto(Double minValue, Double maxValue) { - this.minValue = minValue; - this.maxValue = maxValue; - } - - public NumberFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, Double value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, Double defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Double minValue, Double maxValue) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - this.minValue = minValue; - this.maxValue = maxValue; - } - - public Double getMinValue() { - return minValue; - } - - public void setMinValue(Double minValue) { - this.minValue = minValue; - } - - public Double getMaxValue() { - return maxValue; - } - - public void setMaxValue(Double maxValue) { - this.maxValue = maxValue; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/TaskFieldDto.java b/src/main/java/api/petrinet/domain/dataset/TaskFieldDto.java deleted file mode 100644 index 99a3df2b86..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/TaskFieldDto.java +++ /dev/null @@ -1,23 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import api.petrinet.domain.events.DataEventDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public final class TaskFieldDto extends FieldDto> { - - public TaskFieldDto() { - } - - public TaskFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, ArrayList value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, ArrayList defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/TextFieldDto.java b/src/main/java/api/petrinet/domain/dataset/TextFieldDto.java deleted file mode 100644 index b0c7e5fc66..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/TextFieldDto.java +++ /dev/null @@ -1,65 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import api.petrinet.domain.events.DataEventDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; -import java.util.Map; - -public final class TextFieldDto extends FieldDto { - - private String subType; - - private Integer maxLength; - - private String formatting; - - public TextFieldDto() { - } - - public TextFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, String value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, String defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } - - public TextFieldDto(String subType, Integer maxLength, String formatting) { - this.subType = subType; - this.maxLength = maxLength; - this.formatting = formatting; - } - - public TextFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, String value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, String defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, String subType, Integer maxLength, String formatting) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - this.subType = subType; - this.maxLength = maxLength; - this.formatting = formatting; - } - - public String getSubType() { - return subType; - } - - public void setSubType(String subType) { - this.subType = subType; - } - - public Integer getMaxLength() { - return maxLength; - } - - public void setMaxLength(Integer maxLength) { - this.maxLength = maxLength; - } - - public String getFormatting() { - return formatting; - } - - public void setFormatting(String formatting) { - this.formatting = formatting; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/UserFieldDto.java b/src/main/java/api/petrinet/domain/dataset/UserFieldDto.java deleted file mode 100644 index e166091718..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/UserFieldDto.java +++ /dev/null @@ -1,42 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import api.petrinet.domain.events.DataEventDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -public final class UserFieldDto extends FieldDto { - - private Set roles; - - public UserFieldDto() { - } - - public UserFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, UserFieldValueDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, UserFieldValueDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } - - public UserFieldDto(Set roles) { - this.roles = roles; - } - - public UserFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, UserFieldValueDto value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, UserFieldValueDto defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId, Set roles) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - this.roles = roles; - } - - public Set getRoles() { - return roles; - } - - public void setRoles(Set roles) { - this.roles = roles; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/UserFieldValueDto.java b/src/main/java/api/petrinet/domain/dataset/UserFieldValueDto.java deleted file mode 100644 index 2498f0139b..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/UserFieldValueDto.java +++ /dev/null @@ -1,58 +0,0 @@ -package api.petrinet.domain.dataset; - -public final class UserFieldValueDto { - - private String id; - - private String name; - - private String surname; - - private String email; - - public UserFieldValueDto() { - } - - public UserFieldValueDto(String id, String name, String surname, String email) { - this.id = id; - this.name = name; - this.surname = surname; - this.email = email; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getSurname() { - return surname; - } - - public void setSurname(String surname) { - this.surname = surname; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getFullName() { - return this.name + " " + this.surname; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/UserListFieldDto.java b/src/main/java/api/petrinet/domain/dataset/UserListFieldDto.java deleted file mode 100644 index 1ea8651ace..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/UserListFieldDto.java +++ /dev/null @@ -1,22 +0,0 @@ -package api.petrinet.domain.dataset; - -import api.petrinet.domain.dataset.logic.action.runner.ExpressionDto; -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import api.petrinet.domain.events.DataEventDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; -import java.util.Map; - -public final class UserListFieldDto extends FieldDto> { - - public UserListFieldDto() { - } - - public UserListFieldDto(String id, String type, I18nStringDto name, I18nStringDto description, I18nStringDto placeholder, ObjectNode behavior, FieldLayoutDto layout, List value, Long order, boolean immediate, Map events, String encryption, Integer length, ComponentDto component, List defaultValue, ExpressionDto initExpression, List validations, String parentTaskId, String parentCaseId) { - super(id, type, name, description, placeholder, behavior, layout, value, order, immediate, events, encryption, length, component, defaultValue, initExpression, validations, parentTaskId, parentCaseId); - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/logic/FieldLayoutDto.java b/src/main/java/api/petrinet/domain/dataset/logic/FieldLayoutDto.java deleted file mode 100644 index 2ea53ccb5a..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/logic/FieldLayoutDto.java +++ /dev/null @@ -1,88 +0,0 @@ -package api.petrinet.domain.dataset.logic; - -import api.petrinet.domain.layout.LayoutDto; - -public final class FieldLayoutDto extends LayoutDto { - - private int x; - - private int y; - - private int offset; - - private String template; - - private String appearance; - - private String alignment; - - public FieldLayoutDto() { - } - - public FieldLayoutDto(int x, int y, int offset, String template, String appearance, String alignment) { - this.x = x; - this.y = y; - this.offset = offset; - this.template = template; - this.appearance = appearance; - this.alignment = alignment; - } - - public FieldLayoutDto(Integer rows, Integer cols, int x, int y, int offset, String template, String appearance, String alignment) { - super(rows, cols); - this.x = x; - this.y = y; - this.offset = offset; - this.template = template; - this.appearance = appearance; - this.alignment = alignment; - } - - public int getX() { - return x; - } - - public void setX(int x) { - this.x = x; - } - - public int getY() { - return y; - } - - public void setY(int y) { - this.y = y; - } - - public int getOffset() { - return offset; - } - - public void setOffset(int offset) { - this.offset = offset; - } - - public String getTemplate() { - return template; - } - - public void setTemplate(String template) { - this.template = template; - } - - public String getAppearance() { - return appearance; - } - - public void setAppearance(String appearance) { - this.appearance = appearance; - } - - public String getAlignment() { - return alignment; - } - - public void setAlignment(String alignment) { - this.alignment = alignment; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/logic/action/ActionDto.java b/src/main/java/api/petrinet/domain/dataset/logic/action/ActionDto.java deleted file mode 100644 index b9504d594a..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/logic/action/ActionDto.java +++ /dev/null @@ -1,79 +0,0 @@ -package api.petrinet.domain.dataset.logic.action; - -import java.util.HashMap; -import java.util.Map; - -public final class ActionDto { - - private String importId; - - private String id; - - private Map fieldIds = new HashMap<>(); - - private Map transitionIds = new HashMap<>(); - - private String definition; - - private String trigger; - - public ActionDto() { - } - - public ActionDto(String importId, String id, Map fieldIds, Map transitionIds, String definition, String trigger) { - this.importId = importId; - this.id = id; - this.fieldIds = fieldIds; - this.transitionIds = transitionIds; - this.definition = definition; - this.trigger = trigger; - } - - public String getImportId() { - return importId; - } - - public Map getFieldIds() { - return fieldIds; - } - - public Map getTransitionIds() { - return transitionIds; - } - - public String getDefinition() { - return definition; - } - - public String getTrigger() { - return trigger; - } - - public void setImportId(String importId) { - this.importId = importId; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public void setFieldIds(Map fieldIds) { - this.fieldIds = fieldIds; - } - - public void setTransitionIds(Map transitionIds) { - this.transitionIds = transitionIds; - } - - public void setDefinition(String definition) { - this.definition = definition; - } - - public void setTrigger(String trigger) { - this.trigger = trigger; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/logic/action/runner/ExpressionDto.java b/src/main/java/api/petrinet/domain/dataset/logic/action/runner/ExpressionDto.java deleted file mode 100644 index ecb01859b7..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/logic/action/runner/ExpressionDto.java +++ /dev/null @@ -1,30 +0,0 @@ -package api.petrinet.domain.dataset.logic.action.runner; - -public final class ExpressionDto { - - private String id; - - private String definition; - - ExpressionDto() { - } - - ExpressionDto(String id, String definition) { - this(); - this.id = id; - this.definition = definition; - } - - public String getId() { - return this.id; - } - - public String getDefinition() { - return definition; - } - - public String toString() { - return "[$stringId] $definition"; - } - -} diff --git a/src/main/java/api/petrinet/domain/dataset/logic/validation/LocalisedValidationDto.java b/src/main/java/api/petrinet/domain/dataset/logic/validation/LocalisedValidationDto.java deleted file mode 100644 index 3ab9cca4a6..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/logic/validation/LocalisedValidationDto.java +++ /dev/null @@ -1,24 +0,0 @@ -package api.petrinet.domain.dataset.logic.validation; - -public final class LocalisedValidationDto { - - private String validationRule; - - private String validationMessage; - - public String getValidationRule() { - return validationRule; - } - - public String getValidationMessage() { - return validationMessage; - } - - public void setValidationRule(String validationRule) { - this.validationRule = validationRule; - } - - public void setValidationMessage(String validationMessage) { - this.validationMessage = validationMessage; - } -} diff --git a/src/main/java/api/petrinet/domain/dataset/logic/validation/ValidationDto.java b/src/main/java/api/petrinet/domain/dataset/logic/validation/ValidationDto.java deleted file mode 100644 index 83d254c92f..0000000000 --- a/src/main/java/api/petrinet/domain/dataset/logic/validation/ValidationDto.java +++ /dev/null @@ -1,27 +0,0 @@ -package api.petrinet.domain.dataset.logic.validation; - - -import api.petrinet.domain.I18nStringDto; - -public final class ValidationDto { - - private String validationRule; - - private I18nStringDto validationMessage; - - public String getValidationRule() { - return validationRule; - } - - public I18nStringDto getValidationMessage() { - return validationMessage; - } - - public void setValidationRule(String validationRule) { - this.validationRule = validationRule; - } - - public void setValidationMessage(I18nStringDto validationMessage) { - this.validationMessage = validationMessage; - } -} diff --git a/src/main/java/api/petrinet/domain/events/BaseEventDto.java b/src/main/java/api/petrinet/domain/events/BaseEventDto.java deleted file mode 100644 index f7a6707cf8..0000000000 --- a/src/main/java/api/petrinet/domain/events/BaseEventDto.java +++ /dev/null @@ -1,71 +0,0 @@ -package api.petrinet.domain.events; - -import api.petrinet.domain.dataset.logic.action.ActionDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.ImportedDto; - -import java.util.List; - -public abstract class BaseEventDto extends ImportedDto { - - private String id; - - private I18nStringDto title; - - private I18nStringDto message; - - private List preActions; - - private List postActions; - - public BaseEventDto() { - } - - public BaseEventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions) { - this.id = id; - this.title = title; - this.message = message; - this.preActions = preActions; - this.postActions = postActions; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public I18nStringDto getTitle() { - return title; - } - - public void setTitle(I18nStringDto title) { - this.title = title; - } - - public I18nStringDto getMessage() { - return message; - } - - public void setMessage(I18nStringDto message) { - this.message = message; - } - - public List getPreActions() { - return preActions; - } - - public void setPreActions(List preActions) { - this.preActions = preActions; - } - - public List getPostActions() { - return postActions; - } - - public void setPostActions(List postActions) { - this.postActions = postActions; - } -} diff --git a/src/main/java/api/petrinet/domain/events/CaseEventDto.java b/src/main/java/api/petrinet/domain/events/CaseEventDto.java deleted file mode 100644 index c1524e7278..0000000000 --- a/src/main/java/api/petrinet/domain/events/CaseEventDto.java +++ /dev/null @@ -1,35 +0,0 @@ -package api.petrinet.domain.events; - -import api.petrinet.domain.dataset.logic.action.ActionDto; -import api.petrinet.domain.I18nStringDto; - -import java.util.List; - -public final class CaseEventDto extends BaseEventDto { - - private String type; - - public CaseEventDto() { - } - - public CaseEventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions) { - super(id, title, message, preActions, postActions); - } - - public CaseEventDto(String type) { - this.type = type; - } - - public CaseEventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions, String type) { - super(id, title, message, preActions, postActions); - this.type = type; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } -} diff --git a/src/main/java/api/petrinet/domain/events/DataEventDto.java b/src/main/java/api/petrinet/domain/events/DataEventDto.java deleted file mode 100644 index d206bf0da1..0000000000 --- a/src/main/java/api/petrinet/domain/events/DataEventDto.java +++ /dev/null @@ -1,27 +0,0 @@ -package api.petrinet.domain.events; - -import api.petrinet.domain.dataset.logic.action.ActionDto; -import api.petrinet.domain.I18nStringDto; - -import java.util.List; - -public final class DataEventDto extends BaseEventDto { - - private String type; - - public DataEventDto() { - } - - public DataEventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions) { - super(id, title, message, preActions, postActions); - } - - public DataEventDto(String type) { - this.type = type; - } - - public DataEventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions, String type) { - super(id, title, message, preActions, postActions); - this.type = type; - } -} diff --git a/src/main/java/api/petrinet/domain/events/EventDto.java b/src/main/java/api/petrinet/domain/events/EventDto.java deleted file mode 100644 index fbb6099c67..0000000000 --- a/src/main/java/api/petrinet/domain/events/EventDto.java +++ /dev/null @@ -1,27 +0,0 @@ -package api.petrinet.domain.events; - -import api.petrinet.domain.dataset.logic.action.ActionDto; -import api.petrinet.domain.I18nStringDto; - -import java.util.List; - -public final class EventDto extends BaseEventDto { - - private String type; - - public EventDto() { - } - - public EventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions) { - super(id, title, message, preActions, postActions); - } - - public EventDto(String type) { - this.type = type; - } - - public EventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions, String type) { - super(id, title, message, preActions, postActions); - this.type = type; - } -} diff --git a/src/main/java/api/petrinet/domain/events/ProcessEventDto.java b/src/main/java/api/petrinet/domain/events/ProcessEventDto.java deleted file mode 100644 index 05fc0d65af..0000000000 --- a/src/main/java/api/petrinet/domain/events/ProcessEventDto.java +++ /dev/null @@ -1,27 +0,0 @@ -package api.petrinet.domain.events; - -import api.petrinet.domain.dataset.logic.action.ActionDto; -import api.petrinet.domain.I18nStringDto; - -import java.util.List; - -public final class ProcessEventDto extends BaseEventDto { - - private String type; - - public ProcessEventDto() { - } - - public ProcessEventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions) { - super(id, title, message, preActions, postActions); - } - - public ProcessEventDto(String type) { - this.type = type; - } - - public ProcessEventDto(String id, I18nStringDto title, I18nStringDto message, List preActions, List postActions, String type) { - super(id, title, message, preActions, postActions); - this.type = type; - } -} diff --git a/src/main/java/api/petrinet/domain/layout/DataGroupLayoutDto.java b/src/main/java/api/petrinet/domain/layout/DataGroupLayoutDto.java deleted file mode 100644 index 322b64d243..0000000000 --- a/src/main/java/api/petrinet/domain/layout/DataGroupLayoutDto.java +++ /dev/null @@ -1,19 +0,0 @@ -package api.petrinet.domain.layout; - -public final class DataGroupLayoutDto extends FormLayoutDto { - - public DataGroupLayoutDto() { - } - - public DataGroupLayoutDto(Integer rows, Integer cols) { - super(rows, cols); - } - - public DataGroupLayoutDto(String type, String hideEmptyRows, String compactDirection) { - super(type, hideEmptyRows, compactDirection); - } - - public DataGroupLayoutDto(Integer rows, Integer cols, String type, String hideEmptyRows, String compactDirection) { - super(rows, cols, type, hideEmptyRows, compactDirection); - } -} diff --git a/src/main/java/api/petrinet/domain/layout/FormLayoutDto.java b/src/main/java/api/petrinet/domain/layout/FormLayoutDto.java deleted file mode 100644 index c27f596607..0000000000 --- a/src/main/java/api/petrinet/domain/layout/FormLayoutDto.java +++ /dev/null @@ -1,54 +0,0 @@ -package api.petrinet.domain.layout; - -public abstract class FormLayoutDto extends LayoutDto { - - private String type; - - private String hideEmptyRows; - - private String compactDirection; - - public FormLayoutDto() { - } - - public FormLayoutDto(Integer rows, Integer cols) { - super(rows, cols); - } - - public FormLayoutDto(String type, String hideEmptyRows, String compactDirection) { - this.type = type; - this.hideEmptyRows = hideEmptyRows; - this.compactDirection = compactDirection; - } - - public FormLayoutDto(Integer rows, Integer cols, String type, String hideEmptyRows, String compactDirection) { - super(rows, cols); - this.type = type; - this.hideEmptyRows = hideEmptyRows; - this.compactDirection = compactDirection; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getHideEmptyRows() { - return hideEmptyRows; - } - - public void setHideEmptyRows(String hideEmptyRows) { - this.hideEmptyRows = hideEmptyRows; - } - - public String getCompactDirection() { - return compactDirection; - } - - public void setCompactDirection(String compactDirection) { - this.compactDirection = compactDirection; - } -} diff --git a/src/main/java/api/petrinet/domain/layout/LayoutDto.java b/src/main/java/api/petrinet/domain/layout/LayoutDto.java deleted file mode 100644 index fb5822512e..0000000000 --- a/src/main/java/api/petrinet/domain/layout/LayoutDto.java +++ /dev/null @@ -1,32 +0,0 @@ -package api.petrinet.domain.layout; - -public abstract class LayoutDto { - - private Integer rows; - - private Integer cols; - - public LayoutDto() { - } - - public LayoutDto(Integer rows, Integer cols) { - this.rows = rows; - this.cols = cols; - } - - public Integer getRows() { - return rows; - } - - public void setRows(Integer rows) { - this.rows = rows; - } - - public Integer getCols() { - return cols; - } - - public void setCols(Integer cols) { - this.cols = cols; - } -} diff --git a/src/main/java/api/petrinet/domain/layout/TaskLayoutDto.java b/src/main/java/api/petrinet/domain/layout/TaskLayoutDto.java deleted file mode 100644 index 16aaf29548..0000000000 --- a/src/main/java/api/petrinet/domain/layout/TaskLayoutDto.java +++ /dev/null @@ -1,62 +0,0 @@ -package api.petrinet.domain.layout; - -public final class TaskLayoutDto extends FormLayoutDto { - - private Integer offset; - - private String fieldAlignment; - - public TaskLayoutDto() { - } - - public TaskLayoutDto(Integer rows, Integer cols) { - super(rows, cols); - } - - public TaskLayoutDto(String type, String hideEmptyRows, String compactDirection) { - super(type, hideEmptyRows, compactDirection); - } - - public TaskLayoutDto(Integer rows, Integer cols, String type, String hideEmptyRows, String compactDirection) { - super(rows, cols, type, hideEmptyRows, compactDirection); - } - - public TaskLayoutDto(Integer offset, String fieldAlignment) { - this.offset = offset; - this.fieldAlignment = fieldAlignment; - } - - public TaskLayoutDto(Integer rows, Integer cols, Integer offset, String fieldAlignment) { - super(rows, cols); - this.offset = offset; - this.fieldAlignment = fieldAlignment; - } - - public TaskLayoutDto(String type, String hideEmptyRows, String compactDirection, Integer offset, String fieldAlignment) { - super(type, hideEmptyRows, compactDirection); - this.offset = offset; - this.fieldAlignment = fieldAlignment; - } - - public TaskLayoutDto(Integer rows, Integer cols, String type, String hideEmptyRows, String compactDirection, Integer offset, String fieldAlignment) { - super(rows, cols, type, hideEmptyRows, compactDirection); - this.offset = offset; - this.fieldAlignment = fieldAlignment; - } - - public Integer getOffset() { - return offset; - } - - public void setOffset(Integer offset) { - this.offset = offset; - } - - public String getFieldAlignment() { - return fieldAlignment; - } - - public void setFieldAlignment(String fieldAlignment) { - this.fieldAlignment = fieldAlignment; - } -} diff --git a/src/main/java/api/petrinet/domain/roles/ProcessRoleDto.java b/src/main/java/api/petrinet/domain/roles/ProcessRoleDto.java deleted file mode 100644 index a6e76e57e4..0000000000 --- a/src/main/java/api/petrinet/domain/roles/ProcessRoleDto.java +++ /dev/null @@ -1,84 +0,0 @@ -package api.petrinet.domain.roles; - -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.ImportedDto; -import api.petrinet.domain.events.EventDto; - -import java.util.Map; - -public class ProcessRoleDto extends ImportedDto { - - private String id; - - private I18nStringDto name; - - private String netId; - - private String description; - - private Map events; - - public ProcessRoleDto() { - } - - public ProcessRoleDto(String importId) { - super(importId); - } - - public ProcessRoleDto(String id, I18nStringDto name, String netId, String description, Map events) { - this.id = id; - this.name = name; - this.netId = netId; - this.description = description; - this.events = events; - } - - public ProcessRoleDto(String importId, String id, I18nStringDto name, String netId, String description, Map events) { - super(importId); - this.id = id; - this.name = name; - this.netId = netId; - this.description = description; - this.events = events; - } - - public String getStringId() { - return id; - } - - public void setStringId(String id) { - this.id = id; - } - - public I18nStringDto getName() { - return name; - } - - public void setName(I18nStringDto name) { - this.name = name; - } - - public String getNetId() { - return netId; - } - - public void setNetId(String netId) { - this.netId = netId; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map getEvents() { - return events; - } - - public void setEvents(Map events) { - this.events = events; - } -} diff --git a/src/main/java/api/petrinet/version/VersionDto.java b/src/main/java/api/petrinet/version/VersionDto.java deleted file mode 100644 index e0e94ba5f5..0000000000 --- a/src/main/java/api/petrinet/version/VersionDto.java +++ /dev/null @@ -1,43 +0,0 @@ -package api.petrinet.version; - -public final class VersionDto { - - private long major; - - private long minor; - - private long patch; - - public VersionDto() { - } - - public VersionDto(long major, long minor, long patch) { - this.major = major; - this.minor = minor; - this.patch = patch; - } - - public long getMajor() { - return major; - } - - public void setMajor(long major) { - this.major = major; - } - - public long getMinor() { - return minor; - } - - public void setMinor(long minor) { - this.minor = minor; - } - - public long getPatch() { - return patch; - } - - public void setPatch(long patch) { - this.patch = patch; - } -} diff --git a/src/main/java/api/workflow/domain/CaseDto.java b/src/main/java/api/workflow/domain/CaseDto.java deleted file mode 100644 index 6a6fd1701c..0000000000 --- a/src/main/java/api/workflow/domain/CaseDto.java +++ /dev/null @@ -1,303 +0,0 @@ -package api.workflow.domain; - -import api.auth.AuthorDto; -import api.petrinet.domain.PetriNetDto; -import api.petrinet.domain.dataset.FieldDto; - -import java.time.LocalDateTime; -import java.util.*; - -public final class CaseDto { - - private String id; - - private LocalDateTime lastModified; - - private String visualId; - - private String petriNetId; - - private PetriNetDto petriNet; - - private String processIdentifier; - - private Map activePlaces; - - private String title; - - private String color; - - private String icon; - - private LocalDateTime creationDate; - - private LinkedHashMap dataSet; - - private LinkedHashSet immediateDataFields; - - private List immediateData; - - private AuthorDto author; - - private Map consumedTokens; - - private Set tasks; - - private Set enabledRoles; - - private Map> permissions; - - private Map> userRefs; - - private Map> users; - - private List viewRoles; - - private List viewUserRefs; - - private List viewUsers; - - private List negativeViewRoles; - - private List negativeViewUsers; - - public CaseDto() { - } - - public CaseDto(String id, LocalDateTime lastModified, String visualId, String petriNetId, PetriNetDto petriNet, String processIdentifier, Map activePlaces, String title, String color, String icon, LocalDateTime creationDate, LinkedHashMap dataSet, LinkedHashSet immediateDataFields, List immediateData, AuthorDto author, Map consumedTokens, Set tasks, Set enabledRoles, Map> permissions, Map> userRefs, Map> users, List viewRoles, List viewUserRefs, List viewUsers, List negativeViewRoles, List negativeViewUsers) { - this.id = id; - this.lastModified = lastModified; - this.visualId = visualId; - this.petriNetId = petriNetId; - this.petriNet = petriNet; - this.processIdentifier = processIdentifier; - this.activePlaces = activePlaces; - this.title = title; - this.color = color; - this.icon = icon; - this.creationDate = creationDate; - this.dataSet = dataSet; - this.immediateDataFields = immediateDataFields; - this.immediateData = immediateData; - this.author = author; - this.consumedTokens = consumedTokens; - this.tasks = tasks; - this.enabledRoles = enabledRoles; - this.permissions = permissions; - this.userRefs = userRefs; - this.users = users; - this.viewRoles = viewRoles; - this.viewUserRefs = viewUserRefs; - this.viewUsers = viewUsers; - this.negativeViewRoles = negativeViewRoles; - this.negativeViewUsers = negativeViewUsers; - } - - public String getStringId() { - return id; - } - - public void setStringId(String id) { - this.id = id; - } - - public LocalDateTime getLastModified() { - return lastModified; - } - - public void setLastModified(LocalDateTime lastModified) { - this.lastModified = lastModified; - } - - public String getVisualId() { - return visualId; - } - - public void setVisualId(String visualId) { - this.visualId = visualId; - } - - public String getPetriNetId() { - return petriNetId; - } - - public void setPetriNetId(String petriNetId) { - this.petriNetId = petriNetId; - } - - public PetriNetDto getPetriNet() { - return petriNet; - } - - public void setPetriNet(PetriNetDto petriNet) { - this.petriNet = petriNet; - } - - public String getProcessIdentifier() { - return processIdentifier; - } - - public void setProcessIdentifier(String processIdentifier) { - this.processIdentifier = processIdentifier; - } - - public Map getActivePlaces() { - return activePlaces; - } - - public void setActivePlaces(Map activePlaces) { - this.activePlaces = activePlaces; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getColor() { - return color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getIcon() { - return icon; - } - - public void setIcon(String icon) { - this.icon = icon; - } - - public LocalDateTime getCreationDate() { - return creationDate; - } - - public void setCreationDate(LocalDateTime creationDate) { - this.creationDate = creationDate; - } - - public LinkedHashMap getDataSet() { - return dataSet; - } - - public void setDataSet(LinkedHashMap dataSet) { - this.dataSet = dataSet; - } - - public LinkedHashSet getImmediateDataFields() { - return immediateDataFields; - } - - public void setImmediateDataFields(LinkedHashSet immediateDataFields) { - this.immediateDataFields = immediateDataFields; - } - - public List getImmediateData() { - return immediateData; - } - - public void setImmediateData(List immediateData) { - this.immediateData = immediateData; - } - - public AuthorDto getAuthor() { - return author; - } - - public void setAuthor(AuthorDto author) { - this.author = author; - } - - public Map getConsumedTokens() { - return consumedTokens; - } - - public void setConsumedTokens(Map consumedTokens) { - this.consumedTokens = consumedTokens; - } - - public Set getTasks() { - return tasks; - } - - public void setTasks(Set tasks) { - this.tasks = tasks; - } - - public Set getEnabledRoles() { - return enabledRoles; - } - - public void setEnabledRoles(Set enabledRoles) { - this.enabledRoles = enabledRoles; - } - - public Map> getPermissions() { - return permissions; - } - - public void setPermissions(Map> permissions) { - this.permissions = permissions; - } - - public Map> getUserRefs() { - return userRefs; - } - - public void setUserRefs(Map> userRefs) { - this.userRefs = userRefs; - } - - public Map> getUsers() { - return users; - } - - public void setUsers(Map> users) { - this.users = users; - } - - public List getViewRoles() { - return viewRoles; - } - - public void setViewRoles(List viewRoles) { - this.viewRoles = viewRoles; - } - - public List getViewUserRefs() { - return viewUserRefs; - } - - public void setViewUserRefs(List viewUserRefs) { - this.viewUserRefs = viewUserRefs; - } - - public List getViewUsers() { - return viewUsers; - } - - public void setViewUsers(List viewUsers) { - this.viewUsers = viewUsers; - } - - public List getNegativeViewRoles() { - return negativeViewRoles; - } - - public void setNegativeViewRoles(List negativeViewRoles) { - this.negativeViewRoles = negativeViewRoles; - } - - public List getNegativeViewUsers() { - return negativeViewUsers; - } - - public void setNegativeViewUsers(List negativeViewUsers) { - this.negativeViewUsers = negativeViewUsers; - } -} diff --git a/src/main/java/api/workflow/domain/DataFieldDto.java b/src/main/java/api/workflow/domain/DataFieldDto.java deleted file mode 100644 index 9afeef6625..0000000000 --- a/src/main/java/api/workflow/domain/DataFieldDto.java +++ /dev/null @@ -1,116 +0,0 @@ -package api.workflow.domain; - -import api.petrinet.domain.dataset.logic.validation.ValidationDto; -import api.petrinet.domain.I18nStringDto; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -public final class DataFieldDto { - - private Map> behavior; - - private Object value; - - private Set choices; - - private List allowedNets; - - private Map options; - - private List validations; - - private Map filterMetadata; - - private String encryption; - - private Long version; - - public DataFieldDto() { - } - - public DataFieldDto(Map> behavior, Object value, Set choices, List allowedNets, Map options, List validations, Map filterMetadata, String encryption, Long version) { - this.behavior = behavior; - this.value = value; - this.choices = choices; - this.allowedNets = allowedNets; - this.options = options; - this.validations = validations; - this.filterMetadata = filterMetadata; - this.encryption = encryption; - this.version = version; - } - - public Map> getBehavior() { - return behavior; - } - - public void setBehavior(Map> behavior) { - this.behavior = behavior; - } - - public Object getValue() { - return value; - } - - public void setValue(Object value) { - this.value = value; - } - - public Set getChoices() { - return choices; - } - - public void setChoices(Set choices) { - this.choices = choices; - } - - public List getAllowedNets() { - return allowedNets; - } - - public void setAllowedNets(List allowedNets) { - this.allowedNets = allowedNets; - } - - public Map getOptions() { - return options; - } - - public void setOptions(Map options) { - this.options = options; - } - - public List getValidations() { - return validations; - } - - public void setValidations(List validations) { - this.validations = validations; - } - - public Map getFilterMetadata() { - return filterMetadata; - } - - public void setFilterMetadata(Map filterMetadata) { - this.filterMetadata = filterMetadata; - } - - public String getEncryption() { - return encryption; - } - - public void setEncryption(String encryption) { - this.encryption = encryption; - } - - public Long getVersion() { - return version; - } - - public void setVersion(Long version) { - this.version = version; - } -} diff --git a/src/main/java/api/workflow/domain/TaskDto.java b/src/main/java/api/workflow/domain/TaskDto.java deleted file mode 100644 index 63ede42c74..0000000000 --- a/src/main/java/api/workflow/domain/TaskDto.java +++ /dev/null @@ -1,383 +0,0 @@ -package api.workflow.domain; - -import api.workflow.domain.triggers.TriggerDto; -import api.petrinet.domain.I18nStringDto; -import api.petrinet.domain.dataset.FieldDto; -import api.petrinet.domain.layout.TaskLayoutDto; - -import java.time.LocalDateTime; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; - -public final class TaskDto { - - private String id; - - private String processId; - - private String caseId; - - private String transitionId; - - private TaskLayoutDto layout; - - private I18nStringDto title; - - private String caseColor; - - private String caseTitle; - - private Integer priority; - - private String userId; - - private List triggers; - - private Map> roles; - - private Map> userRefs; - - private Map> users; - - private List viewRoles; - - private List viewUserRefs; - - private List viewUsers; - - private List negativeViewRoles; - - private List negativeViewUsers; - - private LocalDateTime startDate; - - private LocalDateTime finishDate; - - private String finishedBy; - - private String transactionId; - - private Boolean requiredFilled; - - private LinkedHashSet immediateDataFields; - - private List immediateData; - - private String icon; - - private String assignPolicy; - - private String dataFocusPolicy; - - private String finishPolicy; - - private Map eventTitles; - - private Map assignedUserPolicy; - - private Map consumedTokens; - - public TaskDto() { - } - - public TaskDto(String id, String processId, String caseId, String transitionId, TaskLayoutDto layout, I18nStringDto title, String caseColor, String caseTitle, Integer priority, String userId, List triggers, Map> roles, Map> userRefs, Map> users, List viewRoles, List viewUserRefs, List viewUsers, List negativeViewRoles, List negativeViewUsers, LocalDateTime startDate, LocalDateTime finishDate, String finishedBy, String transactionId, Boolean requiredFilled, LinkedHashSet immediateDataFields, List immediateData, String icon, String assignPolicy, String dataFocusPolicy, String finishPolicy, Map eventTitles, Map assignedUserPolicy, Map consumedTokens) { - this.id = id; - this.processId = processId; - this.caseId = caseId; - this.transitionId = transitionId; - this.layout = layout; - this.title = title; - this.caseColor = caseColor; - this.caseTitle = caseTitle; - this.priority = priority; - this.userId = userId; - this.triggers = triggers; - this.roles = roles; - this.userRefs = userRefs; - this.users = users; - this.viewRoles = viewRoles; - this.viewUserRefs = viewUserRefs; - this.viewUsers = viewUsers; - this.negativeViewRoles = negativeViewRoles; - this.negativeViewUsers = negativeViewUsers; - this.startDate = startDate; - this.finishDate = finishDate; - this.finishedBy = finishedBy; - this.transactionId = transactionId; - this.requiredFilled = requiredFilled; - this.immediateDataFields = immediateDataFields; - this.immediateData = immediateData; - this.icon = icon; - this.assignPolicy = assignPolicy; - this.dataFocusPolicy = dataFocusPolicy; - this.finishPolicy = finishPolicy; - this.eventTitles = eventTitles; - this.assignedUserPolicy = assignedUserPolicy; - this.consumedTokens = consumedTokens; - } - - public String getStringId() { - return id; - } - - public void setStringId(String id) { - this.id = id; - } - - public String getProcessId() { - return processId; - } - - public void setProcessId(String processId) { - this.processId = processId; - } - - public String getCaseId() { - return caseId; - } - - public void setCaseId(String caseId) { - this.caseId = caseId; - } - - public String getTransitionId() { - return transitionId; - } - - public void setTransitionId(String transitionId) { - this.transitionId = transitionId; - } - - public TaskLayoutDto getLayout() { - return layout; - } - - public void setLayout(TaskLayoutDto layout) { - this.layout = layout; - } - - public I18nStringDto getTitle() { - return title; - } - - public void setTitle(I18nStringDto title) { - this.title = title; - } - - public String getCaseColor() { - return caseColor; - } - - public void setCaseColor(String caseColor) { - this.caseColor = caseColor; - } - - public String getCaseTitle() { - return caseTitle; - } - - public void setCaseTitle(String caseTitle) { - this.caseTitle = caseTitle; - } - - public Integer getPriority() { - return priority; - } - - public void setPriority(Integer priority) { - this.priority = priority; - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public List getTriggers() { - return triggers; - } - - public void setTriggers(List triggers) { - this.triggers = triggers; - } - - public Map> getRoles() { - return roles; - } - - public void setRoles(Map> roles) { - this.roles = roles; - } - - public Map> getUserRefs() { - return userRefs; - } - - public void setUserRefs(Map> userRefs) { - this.userRefs = userRefs; - } - - public Map> getUsers() { - return users; - } - - public void setUsers(Map> users) { - this.users = users; - } - - public List getViewRoles() { - return viewRoles; - } - - public void setViewRoles(List viewRoles) { - this.viewRoles = viewRoles; - } - - public List getViewUserRefs() { - return viewUserRefs; - } - - public void setViewUserRefs(List viewUserRefs) { - this.viewUserRefs = viewUserRefs; - } - - public List getViewUsers() { - return viewUsers; - } - - public void setViewUsers(List viewUsers) { - this.viewUsers = viewUsers; - } - - public List getNegativeViewRoles() { - return negativeViewRoles; - } - - public void setNegativeViewRoles(List negativeViewRoles) { - this.negativeViewRoles = negativeViewRoles; - } - - public List getNegativeViewUsers() { - return negativeViewUsers; - } - - public void setNegativeViewUsers(List negativeViewUsers) { - this.negativeViewUsers = negativeViewUsers; - } - - public LocalDateTime getStartDate() { - return startDate; - } - - public void setStartDate(LocalDateTime startDate) { - this.startDate = startDate; - } - - public LocalDateTime getFinishDate() { - return finishDate; - } - - public void setFinishDate(LocalDateTime finishDate) { - this.finishDate = finishDate; - } - - public String getFinishedBy() { - return finishedBy; - } - - public void setFinishedBy(String finishedBy) { - this.finishedBy = finishedBy; - } - - public String getTransactionId() { - return transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - - public Boolean getRequiredFilled() { - return requiredFilled; - } - - public void setRequiredFilled(Boolean requiredFilled) { - this.requiredFilled = requiredFilled; - } - - public LinkedHashSet getImmediateDataFields() { - return immediateDataFields; - } - - public void setImmediateDataFields(LinkedHashSet immediateDataFields) { - this.immediateDataFields = immediateDataFields; - } - - public List getImmediateData() { - return immediateData; - } - - public void setImmediateData(List immediateData) { - this.immediateData = immediateData; - } - - public String getIcon() { - return icon; - } - - public void setIcon(String icon) { - this.icon = icon; - } - - public String getAssignPolicy() { - return assignPolicy; - } - - public void setAssignPolicy(String assignPolicy) { - this.assignPolicy = assignPolicy; - } - - public String getDataFocusPolicy() { - return dataFocusPolicy; - } - - public void setDataFocusPolicy(String dataFocusPolicy) { - this.dataFocusPolicy = dataFocusPolicy; - } - - public String getFinishPolicy() { - return finishPolicy; - } - - public void setFinishPolicy(String finishPolicy) { - this.finishPolicy = finishPolicy; - } - - public Map getEventTitles() { - return eventTitles; - } - - public void setEventTitles(Map eventTitles) { - this.eventTitles = eventTitles; - } - - public Map getAssignedUserPolicy() { - return assignedUserPolicy; - } - - public void setAssignedUserPolicy(Map assignedUserPolicy) { - this.assignedUserPolicy = assignedUserPolicy; - } - - public Map getConsumedTokens() { - return consumedTokens; - } - - public void setConsumedTokens(Map consumedTokens) { - this.consumedTokens = consumedTokens; - } -} diff --git a/src/main/java/api/workflow/domain/TaskPairDto.java b/src/main/java/api/workflow/domain/TaskPairDto.java deleted file mode 100644 index de323900a0..0000000000 --- a/src/main/java/api/workflow/domain/TaskPairDto.java +++ /dev/null @@ -1,32 +0,0 @@ -package api.workflow.domain; - -public final class TaskPairDto { - - private String task; - - private String transition; - - public TaskPairDto() { - } - - public TaskPairDto(String task, String transition) { - this.task = task; - this.transition = transition; - } - - public String getTask() { - return task; - } - - public void setTask(String task) { - this.task = task; - } - - public String getTransition() { - return transition; - } - - public void setTransition(String transition) { - this.transition = transition; - } -} diff --git a/src/main/java/api/workflow/domain/triggers/TriggerDto.java b/src/main/java/api/workflow/domain/triggers/TriggerDto.java deleted file mode 100644 index 7640007088..0000000000 --- a/src/main/java/api/workflow/domain/triggers/TriggerDto.java +++ /dev/null @@ -1,23 +0,0 @@ -package api.workflow.domain.triggers; - -import api.petrinet.domain.ImportedDto; - -public final class TriggerDto extends ImportedDto { - - private String id; - - public TriggerDto() { - } - - public TriggerDto(String id) { - this.id = id; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedBooleanFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedBooleanFieldDto.java deleted file mode 100644 index aa00dfba93..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedBooleanFieldDto.java +++ /dev/null @@ -1,18 +0,0 @@ -package api.workflow.web.responsebodies; - -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; - -public final class LocalisedBooleanFieldDto extends LocalisedFieldDto { - - public LocalisedBooleanFieldDto() { - } - - public LocalisedBooleanFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedCaseFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedCaseFieldDto.java deleted file mode 100644 index f3df6c76cd..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedCaseFieldDto.java +++ /dev/null @@ -1,29 +0,0 @@ -package api.workflow.web.responsebodies; - -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; - -public final class LocalisedCaseFieldDto extends LocalisedFieldDto { - - private List allowedNets; - - public LocalisedCaseFieldDto() { - } - - public LocalisedCaseFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } - - public LocalisedCaseFieldDto(List allowedNets) { - this.allowedNets = allowedNets; - } - - public LocalisedCaseFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, List allowedNets) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - this.allowedNets = allowedNets; - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedChoiceFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedChoiceFieldDto.java deleted file mode 100644 index ff51baabb6..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedChoiceFieldDto.java +++ /dev/null @@ -1,37 +0,0 @@ -package api.workflow.web.responsebodies; - -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; - -public abstract class LocalisedChoiceFieldDto extends LocalisedFieldDto { - - private List choices; - - public LocalisedChoiceFieldDto() { - } - - public LocalisedChoiceFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } - - public LocalisedChoiceFieldDto(List choices) { - this.choices = choices; - } - - public LocalisedChoiceFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, List choices) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - this.choices = choices; - } - - public List getChoices() { - return choices; - } - - public void setChoices(List choices) { - this.choices = choices; - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedDateFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedDateFieldDto.java deleted file mode 100644 index bc45b8bc70..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedDateFieldDto.java +++ /dev/null @@ -1,49 +0,0 @@ -package api.workflow.web.responsebodies; - -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; - -public final class LocalisedDateFieldDto extends LocalisedFieldDto { - - private String minDate; - - private String maxDate; - - public LocalisedDateFieldDto() { - } - - public LocalisedDateFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } - - public LocalisedDateFieldDto(String minDate, String maxDate) { - this.minDate = minDate; - this.maxDate = maxDate; - } - - public LocalisedDateFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, String minDate, String maxDate) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - this.minDate = minDate; - this.maxDate = maxDate; - } - - public String getMinDate() { - return minDate; - } - - public void setMinDate(String minDate) { - this.minDate = minDate; - } - - public String getMaxDate() { - return maxDate; - } - - public void setMaxDate(String maxDate) { - this.maxDate = maxDate; - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedDateTimeFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedDateTimeFieldDto.java deleted file mode 100644 index c1b9014fec..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedDateTimeFieldDto.java +++ /dev/null @@ -1,49 +0,0 @@ -package api.workflow.web.responsebodies; - -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; - -public final class LocalisedDateTimeFieldDto extends LocalisedFieldDto { - - private String minDate; - - private String maxDate; - - public LocalisedDateTimeFieldDto() { - } - - public LocalisedDateTimeFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } - - public LocalisedDateTimeFieldDto(String minDate, String maxDate) { - this.minDate = minDate; - this.maxDate = maxDate; - } - - public LocalisedDateTimeFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, String minDate, String maxDate) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - this.minDate = minDate; - this.maxDate = maxDate; - } - - public String getMinDate() { - return minDate; - } - - public void setMinDate(String minDate) { - this.minDate = minDate; - } - - public String getMaxDate() { - return maxDate; - } - - public void setMaxDate(String maxDate) { - this.maxDate = maxDate; - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationFieldDto.java deleted file mode 100644 index c40661c054..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationFieldDto.java +++ /dev/null @@ -1,26 +0,0 @@ -package api.workflow.web.responsebodies; - -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; - -public final class LocalisedEnumerationFieldDto extends LocalisedChoiceFieldDto { - - public LocalisedEnumerationFieldDto() { - } - - public LocalisedEnumerationFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } - - public LocalisedEnumerationFieldDto(List choices) { - super(choices); - } - - public LocalisedEnumerationFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, List choices) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId, choices); - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationMapFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationMapFieldDto.java deleted file mode 100644 index b6d36ddc79..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedEnumerationMapFieldDto.java +++ /dev/null @@ -1,27 +0,0 @@ -package api.workflow.web.responsebodies; - -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; -import java.util.Map; - -public final class LocalisedEnumerationMapFieldDto extends LocalisedMapOptionsFieldDto { - - public LocalisedEnumerationMapFieldDto() { - } - - public LocalisedEnumerationMapFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } - - public LocalisedEnumerationMapFieldDto(Map options) { - super(options); - } - - public LocalisedEnumerationMapFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, Map options) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId, options); - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedFieldDto.java deleted file mode 100644 index edfb729672..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedFieldDto.java +++ /dev/null @@ -1,171 +0,0 @@ -package api.workflow.web.responsebodies; - -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; - -import java.util.List; - -public abstract class LocalisedFieldDto { - - private String stringId; - - private String type; - - private String name; - - private String description; - - private String placeholder; - - private ObjectNode behavior; - - private FieldLayoutDto layout; - - private Object value; - - private Long order; - - private Integer length; - - private ComponentDto component; - - private List validations; - - private String parentTaskId; - - private String parentCaseId; - - public LocalisedFieldDto() { - } - - public LocalisedFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - this.stringId = stringId; - this.type = type; - this.name = name; - this.description = description; - this.placeholder = placeholder; - this.behavior = behavior; - this.layout = layout; - this.value = value; - this.order = order; - this.length = length; - this.component = component; - this.validations = validations; - this.parentTaskId = parentTaskId; - this.parentCaseId = parentCaseId; - } - - public String getStringId() { - return stringId; - } - - public void setStringId(String stringId) { - this.stringId = stringId; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getPlaceholder() { - return placeholder; - } - - public void setPlaceholder(String placeholder) { - this.placeholder = placeholder; - } - - public ObjectNode getBehavior() { - return behavior; - } - - public void setBehavior(ObjectNode behavior) { - this.behavior = behavior; - } - - public FieldLayoutDto getLayout() { - return layout; - } - - public void setLayout(FieldLayoutDto layout) { - this.layout = layout; - } - - public Object getValue() { - return value; - } - - public void setValue(Object value) { - this.value = value; - } - - public Long getOrder() { - return order; - } - - public void setOrder(Long order) { - this.order = order; - } - - public Integer getLength() { - return length; - } - - public void setLength(Integer length) { - this.length = length; - } - - public ComponentDto getComponent() { - return component; - } - - public void setComponent(ComponentDto component) { - this.component = component; - } - - public List getValidations() { - return validations; - } - - public void setValidations(List validations) { - this.validations = validations; - } - - public String getParentTaskId() { - return parentTaskId; - } - - public void setParentTaskId(String parentTaskId) { - this.parentTaskId = parentTaskId; - } - - public String getParentCaseId() { - return parentCaseId; - } - - public void setParentCaseId(String parentCaseId) { - this.parentCaseId = parentCaseId; - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedFileListFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedFileListFieldDto.java deleted file mode 100644 index eea987d2be..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedFileListFieldDto.java +++ /dev/null @@ -1,18 +0,0 @@ -package api.workflow.web.responsebodies; - -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; - -import java.util.List; - -public final class LocalisedFileListFieldDto extends LocalisedFieldDto { - - public LocalisedFileListFieldDto() { - } - - public LocalisedFileListFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedFilterFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedFilterFieldDto.java deleted file mode 100644 index 46d4d8edb8..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedFilterFieldDto.java +++ /dev/null @@ -1,49 +0,0 @@ -package api.workflow.web.responsebodies; - -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; - -public final class LocalisedFilterFieldDto extends LocalisedFieldDto { - - private List allowedNets; - - private Object filterMetadata; - - public LocalisedFilterFieldDto() { - } - - public LocalisedFilterFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } - - public LocalisedFilterFieldDto(List allowedNets, Object filterMetadata) { - this.allowedNets = allowedNets; - this.filterMetadata = filterMetadata; - } - - public LocalisedFilterFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, List allowedNets, Object filterMetadata) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - this.allowedNets = allowedNets; - this.filterMetadata = filterMetadata; - } - - public List getAllowedNets() { - return allowedNets; - } - - public void setAllowedNets(List allowedNets) { - this.allowedNets = allowedNets; - } - - public Object getFilterMetadata() { - return filterMetadata; - } - - public void setFilterMetadata(Object filterMetadata) { - this.filterMetadata = filterMetadata; - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedI18nFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedI18nFieldDto.java deleted file mode 100644 index 4bd4557984..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedI18nFieldDto.java +++ /dev/null @@ -1,18 +0,0 @@ -package api.workflow.web.responsebodies; - -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; - -public final class LocalisedI18nFieldDto extends LocalisedFieldDto { - - public LocalisedI18nFieldDto() { - } - - public LocalisedI18nFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedMapOptionsFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedMapOptionsFieldDto.java deleted file mode 100644 index ad4f69731a..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedMapOptionsFieldDto.java +++ /dev/null @@ -1,38 +0,0 @@ -package api.workflow.web.responsebodies; - -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; -import java.util.Map; - -public abstract class LocalisedMapOptionsFieldDto extends LocalisedFieldDto { - - private Map options; - - public LocalisedMapOptionsFieldDto() { - } - - public LocalisedMapOptionsFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } - - public LocalisedMapOptionsFieldDto(Map options) { - this.options = options; - } - - public LocalisedMapOptionsFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, Map options) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - this.options = options; - } - - public Map getOptions() { - return options; - } - - public void setOptions(Map options) { - this.options = options; - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceFieldDto.java deleted file mode 100644 index 56f1ae7743..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceFieldDto.java +++ /dev/null @@ -1,26 +0,0 @@ -package api.workflow.web.responsebodies; - -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; - -public final class LocalisedMultichoiceFieldDto extends LocalisedChoiceFieldDto { - - public LocalisedMultichoiceFieldDto() { - } - - public LocalisedMultichoiceFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } - - public LocalisedMultichoiceFieldDto(List choices) { - super(choices); - } - - public LocalisedMultichoiceFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, List choices) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId, choices); - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceMapFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceMapFieldDto.java deleted file mode 100644 index cc1af33fc8..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedMultichoiceMapFieldDto.java +++ /dev/null @@ -1,28 +0,0 @@ -package api.workflow.web.responsebodies; - -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -public final class LocalisedMultichoiceMapFieldDto extends LocalisedMapOptionsFieldDto> { - - public LocalisedMultichoiceMapFieldDto() { - } - - public LocalisedMultichoiceMapFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } - - public LocalisedMultichoiceMapFieldDto(Map options) { - super(options); - } - - public LocalisedMultichoiceMapFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, Map options) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId, options); - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedNumberFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedNumberFieldDto.java deleted file mode 100644 index 117480aa22..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedNumberFieldDto.java +++ /dev/null @@ -1,18 +0,0 @@ -package api.workflow.web.responsebodies; - -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; - -import java.util.List; - -public final class LocalisedNumberFieldDto extends LocalisedFieldDto { - - public LocalisedNumberFieldDto() { - } - - public LocalisedNumberFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedTextFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedTextFieldDto.java deleted file mode 100644 index ae7ac19b92..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedTextFieldDto.java +++ /dev/null @@ -1,18 +0,0 @@ -package api.workflow.web.responsebodies; - -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; - -import java.util.List; - -public final class LocalisedTextFieldDto extends LocalisedFieldDto { - - public LocalisedTextFieldDto() { - } - - public LocalisedTextFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } -} diff --git a/src/main/java/api/workflow/web/responsebodies/LocalisedUserFieldDto.java b/src/main/java/api/workflow/web/responsebodies/LocalisedUserFieldDto.java deleted file mode 100644 index 631238a1ca..0000000000 --- a/src/main/java/api/workflow/web/responsebodies/LocalisedUserFieldDto.java +++ /dev/null @@ -1,38 +0,0 @@ -package api.workflow.web.responsebodies; - -import api.petrinet.domain.dataset.logic.validation.LocalisedValidationDto; -import com.fasterxml.jackson.databind.node.ObjectNode; -import api.petrinet.domain.ComponentDto; -import api.petrinet.domain.dataset.logic.FieldLayoutDto; - -import java.util.List; -import java.util.Set; - -public final class LocalisedUserFieldDto extends LocalisedFieldDto { - - private Set roles; - - public LocalisedUserFieldDto() { - } - - public LocalisedUserFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - } - - public LocalisedUserFieldDto(Set roles) { - this.roles = roles; - } - - public LocalisedUserFieldDto(String stringId, String type, String name, String description, String placeholder, ObjectNode behavior, FieldLayoutDto layout, Object value, Long order, Integer length, ComponentDto component, List validations, String parentTaskId, String parentCaseId, Set roles) { - super(stringId, type, name, description, placeholder, behavior, layout, value, order, length, component, validations, parentTaskId, parentCaseId); - this.roles = roles; - } - - public Set getRoles() { - return roles; - } - - public void setRoles(Set roles) { - this.roles = roles; - } -}