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);
}
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);
}
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));
}
}
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;
}
}
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;
}
Aggregations