Search in sources :

Example 11 with TimerSettingsValue

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

the class Bpmn2JsonUnmarshaller method applyTimerEventProperties.

protected void applyTimerEventProperties(TimerEventDefinition timerEventDef, Map<String, String> properties) {
    String timeDate;
    String timeDuration;
    String timeCycle;
    String timeCycleLanguage;
    String timerSettings;
    timerSettings = properties.get(TIMERSETTINGS);
    if (timerSettings != null && !"".equals(timerSettings)) {
        TimerSettingsValue timerSettingsObj = new TimerSettingsTypeSerializer().parse(timerSettings);
        timeDate = timerSettingsObj.getTimeDate();
        timeDuration = timerSettingsObj.getTimeDuration();
        timeCycle = timerSettingsObj.getTimeCycle();
        timeCycleLanguage = timerSettingsObj.getTimeCycleLanguage();
    } else {
        timeDate = properties.get(TIMEDATE);
        timeDuration = properties.get(TIMEDURATION);
        timeCycle = properties.get(TIMECYCLE);
        timeCycleLanguage = properties.get(TIMECYCLELANGUAGE);
    }
    if (timeDate != null && !"".equals(timeDate)) {
        FormalExpression timeDateExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
        timeDateExpression.setBody(timeDate);
        timerEventDef.setTimeDate(timeDateExpression);
    }
    if (timeDuration != null && !"".equals(timeDuration)) {
        FormalExpression timeDurationExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
        timeDurationExpression.setBody(timeDuration);
        timerEventDef.setTimeDuration(timeDurationExpression);
    }
    if (timeCycle != null && !"".equals(timeCycle)) {
        FormalExpression timeCycleExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
        timeCycleExpression.setBody(timeCycle);
        if (timeCycleLanguage != null && timeCycleLanguage.length() > 0) {
            timeCycleExpression.setLanguage(timeCycleLanguage);
        }
        timerEventDef.setTimeCycle(timeCycleExpression);
    }
}
Also used : TimerSettingsTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.TimerSettingsTypeSerializer) TimerSettingsValue(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue) FormalExpression(org.eclipse.bpmn2.FormalExpression)

Example 12 with TimerSettingsValue

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

the class TimerSettingsTypeSerializerTest method setUp.

@Before
public void setUp() {
    timerSettings = new TimerSettingsValue(TIME_DATE, TIME_DURATION, TIME_CYCLE, TIME_CYCLE_LANGUAGE);
    serializer = new TimerSettingsTypeSerializer();
}
Also used : TimerSettingsTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.TimerSettingsTypeSerializer) TimerSettingsValue(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue) Before(org.junit.Before)

Example 13 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 onTimerDurationChange.

protected void onTimerDurationChange() {
    TimerSettingsValue oldValue = value;
    value = copy(oldValue, true);
    value.setTimeDuration(view.getTimeDuration());
    value.setTimeDate(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 14 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 copy.

private TimerSettingsValue copy(TimerSettingsValue source, boolean createIfSourceNull) {
    if (source == null) {
        return createIfSourceNull ? new TimerSettingsValue() : null;
    }
    TimerSettingsValue copy = new TimerSettingsValue();
    copy.setTimeDuration(source.getTimeDuration());
    copy.setTimeDate(source.getTimeDate());
    copy.setTimeCycle(source.getTimeCycle());
    copy.setTimeCycleLanguage(source.getTimeCycleLanguage());
    return copy;
}
Also used : TimerSettingsValue(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue)

Example 15 with TimerSettingsValue

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

the class TimerSettingsFieldEditorPresenterTest method testOnTimeCycleLanguage.

@Test
public void testOnTimeCycleLanguage() {
    TimerSettingsValue value = new TimerSettingsValue();
    editor.setValue(value);
    when(view.getTimeCycle()).thenReturn(VALUE_1);
    when(view.getTimeCycleLanguage()).thenReturn(VALUE_2);
    editor.onTimeCycleLanguageChange();
    verifyMultipleTimerChange(value);
}
Also used : TimerSettingsValue(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue) Test(org.junit.Test) FieldEditorPresenterBaseTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.FieldEditorPresenterBaseTest)

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