use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class TechnologyDetailsHooksPFTD method fillRangeAndDivision.
private void fillRangeAndDivision(final ViewDefinitionState view) {
FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
FieldComponent rangeField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPFTD.RANGE);
LookupComponent divisionLookup = (LookupComponent) view.getComponentByReference(TechnologyFieldsPFTD.DIVISION);
Long technologyId = technologyForm.getEntityId();
if (Objects.isNull(technologyId) && view.isViewAfterRedirect()) {
String range = parameterService.getParameter().getStringField(ParameterFieldsPFTD.RANGE);
Entity division = parameterService.getParameter().getBelongsToField(ParameterFieldsPFTD.DIVISION);
rangeField.setFieldValue(range);
if (Objects.nonNull(division)) {
divisionLookup.setFieldValue(division.getId());
fillFieldsForOneDivisionRange(view);
} else {
divisionLookup.setFieldValue(null);
}
}
rangeField.requestComponentUpdateState();
divisionLookup.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class TechnologyProductionLineDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
LookupComponent productionLineLookup = (LookupComponent) view.getComponentByReference(TechnologyProductionLineFields.PRODUCTION_LINE);
Entity entity = form.getEntity();
Entity technology = entity.getBelongsToField(TechnologyProductionLineFields.TECHNOLOGY);
Entity division = technology.getBelongsToField(TechnologyFieldsPFTD.DIVISION);
FilterValueHolder filterValueHolder = productionLineLookup.getFilterValue();
Long technologyId = technology.getId();
if (Objects.isNull(technologyId)) {
filterValueHolder.remove(TechnologyProductionLineCriteriaModifiers.L_TECHNOLOGY_ID);
} else {
filterValueHolder.put(TechnologyProductionLineCriteriaModifiers.L_TECHNOLOGY_ID, technologyId);
}
if (Objects.nonNull(division)) {
filterValueHolder.put(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID, division.getId());
} else if (filterValueHolder.has(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID)) {
filterValueHolder.remove(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID);
}
productionLineLookup.setFilterValue(filterValueHolder);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class DetailedProductionCountingAndProgressListenersBPC method resourceIssue.
public void resourceIssue(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent formComponent = (FormComponent) view.getComponentByReference(L_ORDER);
Entity order = formComponent.getEntity().getDataDefinition().get(formComponent.getEntity().getId());
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
Set<Long> ids = grid.getSelectedEntitiesIds();
List<Entity> pcqs = dataDefinitionService.get(BasicProductionCountingConstants.PLUGIN_IDENTIFIER, BasicProductionCountingConstants.MODEL_PRODUCTION_COUNTING_QUANTITY).find().add(SearchRestrictions.in("id", ids)).list().getEntities();
if (!canIssueMaterials(order, pcqs)) {
formComponent.setEntity(order);
return;
}
try {
productionCountingDocumentService.createInternalOutboundDocument(order, pcqs, false);
if (order.isValid()) {
productionCountingDocumentService.updateProductionCountingQuantity(pcqs);
productionTrackingListenerServicePFTD.updateCostsForOrder(order);
view.addMessage("productFlowThruDivision.productionCountingQuantity.success.createInternalOutboundDocument", ComponentState.MessageType.SUCCESS);
}
} catch (DocumentBuildException documentBuildException) {
boolean errorsDisplayed = true;
for (ErrorMessage error : documentBuildException.getEntity().getGlobalErrors()) {
if (error.getMessage().equalsIgnoreCase(L_ERROR_NOT_ENOUGH_RESOURCES)) {
order.addGlobalError(error.getMessage(), false, error.getVars());
} else {
errorsDisplayed = false;
order.addGlobalError(error.getMessage(), error.getVars());
}
}
if (!errorsDisplayed) {
order.addGlobalError("productFlowThruDivision.productionCountingQuantity.productionCountingQuantityError.createInternalOutboundDocument");
}
formComponent.setEntity(order);
}
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class RealProductionCostService method calculateRealProductionCost.
public void calculateRealProductionCost(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference("order");
Entity order = form.getEntity();
if (order.getId() == null) {
return;
}
Entity orderDB = order.getDataDefinition().get(order.getId());
BigDecimal realProductionCost = calculateRealProductionCost(orderDB);
view.addMessage("productFlowThruDivision.realProductionCost.calculationResult", ComponentState.MessageType.SUCCESS, false, numberService.formatWithMinimumFractionDigits(numberService.setScaleWithDefaultMathContext(realProductionCost, 2), 2));
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class IssueCommonDetailsHelper method setFilterValue.
public void setFilterValue(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity productToIssue = form.getPersistedEntityWithIncludedFormValues();
Entity product = productToIssue.getBelongsToField(ProductsToIssueFields.PRODUCT);
Entity warehouse = productToIssue.getBelongsToField(ProductsToIssueFields.LOCATION);
LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference(IssueCommonDetailsHelper.STORAGE_LOCATION);
FilterValueHolder filter = storageLocationLookup.getFilterValue();
LookupComponent additionalCodeLookup = (LookupComponent) view.getComponentByReference(ADDITIONAL_CODE);
FilterValueHolder additionalCodeFilter = additionalCodeLookup.getFilterValue();
if (product != null) {
filter.put(PRODUCT, product.getId());
additionalCodeFilter.put(PRODUCT, product.getId());
} else if (filter.has(PRODUCT)) {
filter.remove(PRODUCT);
additionalCodeFilter.remove(PRODUCT);
}
if (warehouse != null) {
filter.remove(LOCATION);
filter.put(LOCATION, warehouse.getId());
}
storageLocationLookup.setFilterValue(filter);
additionalCodeLookup.setFilterValue(additionalCodeFilter);
}
Aggregations