All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netgrif.application.engine.importer.service.TriggerFactory Maven / Gradle / Ivy

Go to download

System provides workflow management functions including user, role and data management.

There is a newer version: 6.3.3
Show newest version
package com.netgrif.application.engine.importer.service;

import com.netgrif.application.engine.workflow.domain.triggers.*;
import org.springframework.stereotype.Component;

import java.time.format.DateTimeParseException;

@Component
public class TriggerFactory {

    public Trigger buildTrigger(com.netgrif.application.engine.importer.model.Trigger trigger) throws IllegalArgumentException, DateTimeParseException {
        switch (trigger.getType()) {
            case AUTO:
                return buildAutoTrigger();
            case TIME:
                return buildTimeTrigger(trigger);
            case USER:
                return buildUserTrigger();
            default:
                throw new IllegalArgumentException(trigger.getType() + " is not a valid Trigger type");
        }
    }

    private AutoTrigger buildAutoTrigger() {
        return new AutoTrigger();
    }

    private TimeTrigger buildTimeTrigger(com.netgrif.application.engine.importer.model.Trigger trigger) throws DateTimeParseException {
        if (trigger.getDelay() != null) {
            return new DelayTimeTrigger(trigger.getDelay().toString());
        } else if (trigger.getExact() != null) {
            return new DateTimeTrigger(trigger.getExact().toString());
        }
        throw new IllegalArgumentException("Unsupported time trigger value");
    }

    private UserTrigger buildUserTrigger() {
        return new UserTrigger();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy