Search in sources :

Example 1 with TimeGapsSearchResult

use of com.qcadoo.mes.timeGapsPreview.TimeGapsSearchResult in project mes by qcadoo.

the class GenerateTimeGapsListeners method generateTimeGaps.

public void generateTimeGaps(final ViewDefinitionState viewState, final ComponentState formState, final String[] args) throws ParseException {
    FormComponent form = (FormComponent) formState;
    Entity contextEntity = form.getPersistedEntityWithIncludedFormValues();
    // We don't want to reuse contexts - in case of the user working with many browser tabs to compare a couple of results
    contextEntity.setId(null);
    contextEntity.setField(TimeGapsContextFields.TIME_GAPS, Collections.<Entity>emptyList());
    // Call validation
    contextEntity = contextEntity.getDataDefinition().save(contextEntity);
    if (!contextEntity.isValid()) {
        clearSummaryFields(contextEntity);
        form.setEntity(contextEntity);
        return;
    }
    // Generate & persist results
    TimeGapsSearchResult searchResult = performGeneration(contextEntity);
    Entity persistedContext = persistResults(contextEntity, searchResult);
    if (persistedContext.isValid()) {
        // Show 'time gaps' tab
        WindowComponent window = (WindowComponent) findComponentByReferenceName(viewState, QcadooViewConstants.L_WINDOW);
        window.setActiveTab("timeGaps");
    }
    form.setEntity(persistedContext);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) WindowComponent(com.qcadoo.view.api.components.WindowComponent) TimeGapsSearchResult(com.qcadoo.mes.timeGapsPreview.TimeGapsSearchResult)

Aggregations

TimeGapsSearchResult (com.qcadoo.mes.timeGapsPreview.TimeGapsSearchResult)1 Entity (com.qcadoo.model.api.Entity)1 FormComponent (com.qcadoo.view.api.components.FormComponent)1 WindowComponent (com.qcadoo.view.api.components.WindowComponent)1