Search in sources :

Example 1 with TimerSettingsValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue in project kie-wb-common by kiegroup.

the class EventPropertyReader method getTimerSettings.

public TimerSettingsValue getTimerSettings(TimerEventDefinition eventDefinition) {
    TimerSettingsValue timerSettingsValue = new TimerSettings().getValue();
    toFormalExpression(eventDefinition.getTimeCycle()).ifPresent(timeCycle -> {
        timerSettingsValue.setTimeCycle(timeCycle.getBody());
        timerSettingsValue.setTimeCycleLanguage(timeCycle.getLanguage());
    });
    toFormalExpression(eventDefinition.getTimeDate()).ifPresent(timeDate -> {
        timerSettingsValue.setTimeDate(timeDate.getBody());
    });
    toFormalExpression(eventDefinition.getTimeDuration()).ifPresent(timeDateDuration -> {
        timerSettingsValue.setTimeDuration(timeDateDuration.getBody());
    });
    return timerSettingsValue;
}
Also used : TimerSettings(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettings) TimerSettingsValue(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue)

Example 2 with TimerSettingsValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue in project kie-wb-common by kiegroup.

the class TimerSettingsValueValidatorTest method gwtSetUp.

@Override
protected void gwtSetUp() throws Exception {
    super.gwtSetUp();
    validator = new TimerSettingsValueValidator();
    value = new TimerSettingsValue();
    context = new ConstraintValidatorContext() {

        @Override
        public void disableDefaultConstraintViolation() {
        }

        @Override
        public String getDefaultConstraintMessageTemplate() {
            return null;
        }

        @Override
        public ConstraintViolationBuilder buildConstraintViolationWithTemplate(String message) {
            errorMessages.add(message);
            return new ConstraintViolationBuilder() {

                @Override
                public NodeBuilderDefinedContext addNode(String name) {
                    return null;
                }

                @Override
                public ConstraintValidatorContext addConstraintViolation() {
                    return context;
                }
            };
        }
    };
}
Also used : ConstraintValidatorContext(javax.validation.ConstraintValidatorContext) TimerSettingsValue(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue)

Example 3 with TimerSettingsValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue in project kie-wb-common by kiegroup.

the class EventPropertyWriter method addTimer.

public void addTimer(TimerSettings timerSettings) {
    TimerEventDefinition eventDefinition = bpmn2.createTimerEventDefinition();
    TimerSettingsValue timerSettingsValue = timerSettings.getValue();
    String date = timerSettingsValue.getTimeDate();
    if (date != null) {
        FormalExpression timeDate = bpmn2.createFormalExpression();
        timeDate.setBody(date);
        eventDefinition.setTimeDate(timeDate);
    }
    String duration = timerSettingsValue.getTimeDuration();
    if (duration != null) {
        FormalExpression timeDuration = bpmn2.createFormalExpression();
        timeDuration.setBody(duration);
        eventDefinition.setTimeDuration(timeDuration);
    }
    String cycle = timerSettingsValue.getTimeCycle();
    String cycleLanguage = timerSettingsValue.getTimeCycleLanguage();
    if (cycle != null && cycleLanguage != null) {
        FormalExpression timeCycleExpression = bpmn2.createFormalExpression();
        timeCycleExpression.setBody(cycle);
        timeCycleExpression.setLanguage(cycleLanguage);
        eventDefinition.setTimeCycle(timeCycleExpression);
    }
    addEventDefinition(eventDefinition);
}
Also used : TimerSettingsValue(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) FormalExpression(org.eclipse.bpmn2.FormalExpression)

Example 4 with TimerSettingsValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue in project kie-wb-common by kiegroup.

the class TimerSettingsFieldEditorPresenter method onTimeDateChange.

protected void onTimeDateChange() {
    TimerSettingsValue oldValue = value;
    value = copy(oldValue, true);
    value.setTimeDate(view.getTimeDate());
    value.setTimeDuration(null);
    value.setTimeCycle(null);
    value.setTimeCycleLanguage(null);
    notifyChange(oldValue, value);
}
Also used : TimerSettingsValue(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue)

Example 5 with TimerSettingsValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue in project kie-wb-common by kiegroup.

the class TimerSettingsFieldEditorPresenter method onMultipleTimerValuesChange.

protected void onMultipleTimerValuesChange() {
    TimerSettingsValue oldValue = value;
    value = copy(oldValue, true);
    value.setTimeCycleLanguage(view.getTimeCycleLanguage());
    value.setTimeCycle(view.getTimeCycle());
    value.setTimeDuration(null);
    value.setTimeDate(null);
    notifyChange(oldValue, value);
}
Also used : TimerSettingsValue(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue)

Aggregations

TimerSettingsValue (org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue)18 Test (org.junit.Test)8 FieldEditorPresenterBaseTest (org.kie.workbench.common.stunner.bpmn.client.forms.util.FieldEditorPresenterBaseTest)7 TimerSettingsTypeSerializer (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.TimerSettingsTypeSerializer)3 FormalExpression (org.eclipse.bpmn2.FormalExpression)2 ConstraintValidatorContext (javax.validation.ConstraintValidatorContext)1 TimerEventDefinition (org.eclipse.bpmn2.TimerEventDefinition)1 Before (org.junit.Before)1 TimerSettings (org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettings)1