use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class IssueCommonDetailsHelper method fillStorageLocation.
public void fillStorageLocation(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);
Entity storageLocation = productToIssue.getBelongsToField(ProductsToIssueFields.STORAGE_LOCATION);
if (product != null && warehouse != null && storageLocation == null) {
Optional<Entity> option = findStorageLocationForProduct(product, warehouse);
if (option.isPresent()) {
LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference(IssueCommonDetailsHelper.STORAGE_LOCATION);
storageLocationLookup.setFieldValue(option.get().getId());
storageLocationLookup.requestComponentUpdateState();
}
}
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ModelCardDetailsListeners method generateModelCard.
@Transactional
public void generateModelCard(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent productsGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
if (productsGrid.getEntities().isEmpty()) {
view.addMessage("productFlowThruDivision.modelCard.generate.failure.noProducts", ComponentState.MessageType.INFO);
return;
}
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference(ModelCardFields.GENERATED);
FieldComponent workerField = (FieldComponent) view.getComponentByReference(ModelCardFields.WORKER);
FieldComponent dateField = (FieldComponent) view.getComponentByReference(ModelCardFields.DATE);
workerField.setFieldValue(securityService.getCurrentUserName());
dateField.setFieldValue(DateUtils.toDateTimeString(new Date()));
generated.setChecked(true);
Entity modelCard = form.getEntity();
modelCard = modelCard.getDataDefinition().save(modelCard);
form.setEntity(modelCard);
Entity modelCardWithFileName = fileService.updateReportFileName(modelCard, ModelCardFields.DATE, "productFlowThruDivision.modelCard.report.fileName");
try {
modelCardPdfService.generateDocument(modelCardWithFileName, state.getLocale(), PageSize.A4.rotate());
} catch (IOException | DocumentException e) {
throw new IllegalStateException(e.getMessage(), e);
}
view.addMessage("productFlowThruDivision.modelCard.generate.success", ComponentState.MessageType.SUCCESS);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class OrderDetailsListenersPFTD method showMaterialAvailabilityForProductionTracking.
public void showMaterialAvailabilityForProductionTracking(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent productionRecordForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity productionRecord = productionRecordForm.getEntity();
Long orderId = productionRecord.getBelongsToField(ProductionTrackingFields.ORDER).getId();
showMaterialAvailability(view, orderId);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class TechnologyDetailsListenersPFTD method createModelCard.
public void createModelCard(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity technology = technologyForm.getPersistedEntityWithIncludedFormValues();
Entity product = technology.getBelongsToField(TechnologyFields.PRODUCT);
Entity parameter = parameterService.getParameter();
DataDefinition modelCardDD = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_MODEL_CARD);
Entity modelCard = modelCardDD.create();
modelCard.setField(ModelCardFields.NAME, product.getField(ProductFields.NAME));
modelCard.setField(ModelCardFields.MATERIAL_COSTS_USED, parameter.getStringField(ParameterFieldsPFTD.MATERIAL_COSTS_USED_MC));
modelCard.setField(ModelCardFields.USE_NOMINAL_COST_PRICE_NOT_SPECIFIED, parameter.getBooleanField(ParameterFieldsPFTD.USE_NOMINAL_COST_PRICE_NOT_SPECIFIED_MC));
DataDefinition modelCardProductDD = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_MODEL_CARD_PRODUCT);
Entity modelCardProduct = modelCardProductDD.create();
modelCardProduct.setField(ModelCardProductFields.PRODUCT, product);
modelCardProduct.setField(ModelCardProductFields.TECHNOLOGY, technology);
modelCardProduct.setField(ModelCardProductFields.QUANTITY, 1L);
modelCard.setField(ModelCardFields.MODEL_CARD_PRODUCTS, Collections.singletonList(modelCardProduct));
modelCard = modelCardDD.save(modelCard);
Map<String, Object> parameters = Maps.newHashMap();
parameters.put("form.id", modelCard.getId());
String url = "../page/productFlowThruDivision/modelCardDetails.html";
view.redirectTo(url, false, true, parameters);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class IssueDetailsHooks method fillUnit.
private void fillUnit(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity issue = form.getPersistedEntityWithIncludedFormValues();
if (issue.getBooleanField(IssueFields.ISSUED)) {
form.setFormEnabled(false);
return;
}
Entity product = issue.getBelongsToField(IssueFields.PRODUCT);
FieldComponent issueUnitField = (FieldComponent) view.getComponentByReference("issueQuantityUnit");
FieldComponent demandUnitField = (FieldComponent) view.getComponentByReference("demandQuantityUnit");
if (product != null) {
String unit = product.getStringField(ProductFields.UNIT);
issueUnitField.setFieldValue(unit);
demandUnitField.setFieldValue(unit);
} else {
issueUnitField.setFieldValue(StringUtils.EMPTY);
demandUnitField.setFieldValue(StringUtils.EMPTY);
}
}
Aggregations