use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.
the class GenerateMRCForOrderHooks method setLocations.
private void setLocations(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity mRCForOrder = form.getEntity();
Entity order = null;
Set<Entity> locations = Sets.newHashSet();
order = mRCForOrder.getBelongsToField("order");
locations = productFlowThruDivisionService.getProductsLocations(order.getBelongsToField(OrderFields.TECHNOLOGY).getId());
List<Entity> parameterCoverageLocations = parameterService.getParameter().getHasManyField(ParameterFieldsOS.COVERAGE_LOCATIONS);
for (Entity parameterCoverageLocation : parameterCoverageLocations) {
Entity location = parameterCoverageLocation.getBelongsToField(com.qcadoo.mes.orderSupplies.constants.CoverageLocationFields.LOCATION);
locations.add(location);
}
AwesomeDynamicListComponent locationADL = (AwesomeDynamicListComponent) view.getComponentByReference("coverageLocations");
if (locationADL.getFormComponents().isEmpty()) {
List<Entity> locationsList = Lists.newArrayList();
for (Entity location : locations) {
Entity coverageLocation = mRCForOrderService.getCoverageLocationDD().create();
coverageLocation.setField(CoverageLocationFields.LOCATION, location);
locationsList.add(coverageLocation);
}
locationADL.setFieldValue(locationsList);
locationADL.requestComponentUpdateState();
}
}
use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.
the class GenerateMRCForOrderHooks method updateFormState.
public void updateFormState(final ViewDefinitionState view) {
FormComponent materialRequirementCoverageForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Long materialRequirementCoverageId = materialRequirementCoverageForm.getEntityId();
AwesomeDynamicListComponent adlc = (AwesomeDynamicListComponent) view.getComponentByReference(CoverageForOrderFields.COVERAGE_LOCATIONS);
boolean saved = checkIfMaterialRequirementCoverageIsSaved(materialRequirementCoverageId);
materialRequirementCoverageForm.setFormEnabled(!saved);
List<FormComponent> formComponents = adlc.getFormComponents();
for (FormComponent formComponent : formComponents) {
formComponent.setFormEnabled(!saved);
}
}
use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.
the class MRCForOrderDetailsHooks method updateFormState.
public void updateFormState(final ViewDefinitionState view) {
FormComponent materialRequirementCoverageForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
AwesomeDynamicListComponent adlc = (AwesomeDynamicListComponent) view.getComponentByReference(CoverageForOrderFields.COVERAGE_LOCATIONS);
Long materialRequirementCoverageId = materialRequirementCoverageForm.getEntityId();
boolean saved = checkIfMaterialRequirementCoverageIsSaved(materialRequirementCoverageId);
materialRequirementCoverageForm.setFormEnabled(!saved);
List<FormComponent> formComponents = adlc.getFormComponents();
for (FormComponent formComponent : formComponents) {
formComponent.setFormEnabled(!saved);
}
}
use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.
the class ProfileHooksMF method setupUserLocationsSection.
public void setupUserLocationsSection(final ViewDefinitionState view) {
view.getComponentByReference(L_USER_LOCATIONS_BORDER_LAYOUT).setVisible(true);
if (!securityService.hasCurrentUserRole("ROLE_ADMIN")) {
view.getComponentByReference(L_USER_LOCATIONS).setEnabled(false);
AwesomeDynamicListComponent userLocations = (AwesomeDynamicListComponent) view.getComponentByReference(L_USER_LOCATIONS);
userLocations.getFormComponents().forEach(fc -> fc.findFieldComponentByName(L_LOCATION).setEnabled(false));
}
}
use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.
the class DivideOrderTechnologicalProcessHooks method updateAwesomeDynamicList.
private void updateAwesomeDynamicList(final ViewDefinitionState view) {
FormComponent orderTechnologicalProcessForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
AwesomeDynamicListComponent orderTechnologicalProcessPartsADL = (AwesomeDynamicListComponent) view.getComponentByReference(OrderTechnologicalProcessFields.ORDER_TECHNOLOGICAL_PROCESS_PARTS);
if (view.isViewAfterRedirect()) {
Entity orderTechnologicalProcess = orderTechnologicalProcessForm.getEntity();
Long orderTechnologicalProcessId = orderTechnologicalProcess.getId();
orderTechnologicalProcess = orderTechnologicalProcess.getDataDefinition().get(orderTechnologicalProcessId);
Entity product = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.PRODUCT);
BigDecimal quantity = orderTechnologicalProcess.getDecimalField(OrderTechnologicalProcessFields.QUANTITY);
String productUnit = product.getStringField(ProductFields.UNIT);
List<Entity> orderTechnologicalProcessParts = Lists.newArrayList();
BigDecimal half = new BigDecimal(2);
BigDecimal quantity1;
BigDecimal quantity2;
BigDecimal quantitySum = BigDecimal.ZERO;
if (dictionaryService.checkIfUnitIsInteger(productUnit)) {
if (isInteger(quantity)) {
BigDecimal quotient = quantity.divide(half, numberService.getMathContext()).setScale(0, RoundingMode.FLOOR);
if (BigDecimal.ZERO.compareTo(quantity.remainder(half, numberService.getMathContext())) == 0) {
quantity1 = quotient;
quantity2 = quotient;
} else {
BigDecimal difference = quantity.subtract(quotient, numberService.getMathContext());
quantity1 = quotient;
quantity2 = difference;
}
quantitySum = quantity1.add(quantity2, numberService.getMathContext());
} else {
quantity1 = null;
quantity2 = null;
}
} else {
BigDecimal quotient = quantity.divide(half, numberService.getMathContext()).setScale(5, RoundingMode.FLOOR);
quantity1 = quotient;
quantity2 = quotient;
quantitySum = quantity1.add(quantity2, numberService.getMathContext());
}
if (quantity.compareTo(quantitySum) != 0) {
quantity1 = null;
quantity2 = null;
}
orderTechnologicalProcessParts.add(createOrderTechnologicalProcessPart("1", quantity1, productUnit));
orderTechnologicalProcessParts.add(createOrderTechnologicalProcessPart("2", quantity2, productUnit));
orderTechnologicalProcessPartsADL.setFieldValue(orderTechnologicalProcessParts);
}
}
Aggregations