Search in sources :

Example 21 with AwesomeDynamicListComponent

use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.

the class ProductionPerShiftDetailsHooks method setProductAndFillProgressForDays.

public void setProductAndFillProgressForDays(final ViewDefinitionState view) {
    Entity order = getEntityFromLookup(view, "order").get();
    OrderState orderState = OrderState.of(order);
    ProgressType progressType = resolveProgressType(view);
    AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view.getComponentByReference(PROGRESS_ADL_REF);
    setProductAndFillProgressForDays(view, progressForDaysADL, orderState, progressType);
}
Also used : Entity(com.qcadoo.model.api.Entity) ProgressType(com.qcadoo.mes.productionPerShift.constants.ProgressType) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent) OrderState(com.qcadoo.mes.orders.states.constants.OrderState)

Example 22 with AwesomeDynamicListComponent

use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.

the class ProductionPerShiftDetailsHooks method disableComponents.

void disableComponents(final AwesomeDynamicListComponent progressForDaysADL, final ProgressType progressType, final OrderState orderState) {
    boolean isEnabled = (progressType == ProgressType.CORRECTED || orderState == OrderState.PENDING) && !UNSUPPORTED_ORDER_STATES.contains(orderState);
    for (FormComponent progressForDaysForm : progressForDaysADL.getFormComponents()) {
        progressForDaysForm.setFormEnabled(isEnabled);
        AwesomeDynamicListComponent dailyProgressADL = (AwesomeDynamicListComponent) progressForDaysForm.findFieldComponentByName(DAILY_PROGRESS_ADL_REF);
        for (FormComponent dailyProgressForm : dailyProgressADL.getFormComponents()) {
            Entity dpEntity = dailyProgressForm.getPersistedEntityWithIncludedFormValues();
            boolean isLocked = dpEntity.getBooleanField(DailyProgressFields.LOCKED);
            dailyProgressForm.setFormEnabled(isEnabled && !isLocked);
        }
        dailyProgressADL.setEnabled(isEnabled);
    }
    progressForDaysADL.setEnabled(isEnabled);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 23 with AwesomeDynamicListComponent

use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.

the class ProductionPerShiftDetailsHooks method deviationNotify.

private void deviationNotify(ViewDefinitionState view) {
    FormComponent productionPerShiftForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity pps = productionPerShiftForm.getPersistedEntityWithIncludedFormValues();
    AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view.getComponentByReference(PROGRESS_ADL_REF);
    ProgressType progressType = resolveProgressType(view);
    if (!progressForDaysADL.getEntities().isEmpty() && pps != null && (view.isViewAfterRedirect())) {
        progressQuantitiesDeviationNotifier.compareAndNotify(view, pps, isCorrectedPlan(view));
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) ProgressType(com.qcadoo.mes.productionPerShift.constants.ProgressType) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 24 with AwesomeDynamicListComponent

use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.

the class ProgressPerShiftViewSaver method saveProgressesAndForm.

@Transactional
private boolean saveProgressesAndForm(final ViewDefinitionState view) {
    AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view.getComponentByReference(PROGRESS_ADL_REF);
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity pps = form.getEntity();
    Long ppsId = pps.getId();
    List<Entity> progressForDays = progressForDaysADL.getEntities();
    ProgressType progressType = extractProgressType(view);
    boolean hasCorrections = progressType == ProgressType.CORRECTED;
    List<Entity> savedProgresses = validateAndSaveProgresses(progressForDays, pps, hasCorrections);
    if (Iterables.all(savedProgresses, IS_VALID)) {
        return tryUpdatePPS(view, pps, hasCorrections, savedProgresses);
    } else {
        progressForDaysADL.setFieldValue(savedProgresses);
        showValidationErrors(view, FluentIterable.from(savedProgresses).transformAndConcat(new Function<Entity, Iterable<ErrorMessage>>() {

            @Override
            public Iterable<ErrorMessage> apply(final Entity input) {
                return input.getGlobalErrors();
            }
        }));
        rollbackCurrentTransaction();
        return false;
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) Function(com.google.common.base.Function) ProgressType(com.qcadoo.mes.productionPerShift.constants.ProgressType) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent) ErrorMessage(com.qcadoo.model.api.validators.ErrorMessage) Transactional(org.springframework.transaction.annotation.Transactional)

Example 25 with AwesomeDynamicListComponent

use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.

the class PalletMoveToStorageLocationHelperListeners method validateRequiredFields.

private boolean validateRequiredFields(final ViewDefinitionState view, final List<Entity> dtos) {
    AwesomeDynamicListComponent adl = (AwesomeDynamicListComponent) view.getComponentByReference(L_PALLET_STORAGE_STATE_DTOS);
    boolean isValid = true;
    for (FormComponent form : adl.getFormComponents()) {
        LookupComponent newStorageLocation = (LookupComponent) form.findFieldComponentByName(L_NEW_STORAGE_LOCATION);
        if (newStorageLocation.getFieldValue() == null) {
            newStorageLocation.addMessage("qcadooView.validate.field.error.missing", ComponentState.MessageType.FAILURE);
            isValid = false;
        }
        Entity newLocation = newStorageLocation.getEntity();
        BigDecimal maxNumberOfPallets = null;
        if (newLocation != null) {
            maxNumberOfPallets = newLocation.getDecimalField(StorageLocationFields.MAXIMUM_NUMBER_OF_PALLETS);
        }
        if (maxNumberOfPallets != null) {
            BigDecimal totalPallets = BigDecimal.valueOf(getNewPalletsCountInStorageLocation(newLocation, dtos) + resourceCorrectionService.getPalletsCountInStorageLocation(newLocation));
            if (totalPallets.compareTo(maxNumberOfPallets) > 0) {
                newStorageLocation.addMessage("materialFlowResources.palletMoveToStorageLocation.error.tooManyPallets", ComponentState.MessageType.FAILURE);
                isValid = false;
            }
        }
    }
    return isValid;
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent) BigDecimal(java.math.BigDecimal)

Aggregations

AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)36 FormComponent (com.qcadoo.view.api.components.FormComponent)26 Entity (com.qcadoo.model.api.Entity)24 FieldComponent (com.qcadoo.view.api.components.FieldComponent)12 BigDecimal (java.math.BigDecimal)6 ProgressType (com.qcadoo.mes.productionPerShift.constants.ProgressType)4 LookupComponent (com.qcadoo.view.api.components.LookupComponent)4 Optional (com.google.common.base.Optional)2 OrderState (com.qcadoo.mes.orders.states.constants.OrderState)2 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)2 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)2 Function (com.google.common.base.Function)1 DataDefinition (com.qcadoo.model.api.DataDefinition)1 EntityRuntimeException (com.qcadoo.model.api.exception.EntityRuntimeException)1 ErrorMessage (com.qcadoo.model.api.validators.ErrorMessage)1 BigInteger (java.math.BigInteger)1 Around (org.aspectj.lang.annotation.Around)1 JSONException (org.json.JSONException)1 Transactional (org.springframework.transaction.annotation.Transactional)1