use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class UsedBatchDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity usedBatch = form.getEntity();
Entity trackingOperationProductInComponent = usedBatch.getBelongsToField(UsedBatchFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENT);
if (view.isViewAfterRedirect() && Objects.nonNull(trackingOperationProductInComponent)) {
Entity product = trackingOperationProductInComponent.getBelongsToField(TrackingOperationProductInComponentFields.PRODUCT);
FieldComponent unitField = (FieldComponent) view.getComponentByReference(L_UNIT);
unitField.setFieldValue(product.getStringField(ProductFields.UNIT));
unitField.requestComponentUpdateState();
LookupComponent batchLookup = (LookupComponent) view.getComponentByReference(UsedBatchFields.BATCH);
FilterValueHolder batchFilterValueHolder = batchLookup.getFilterValue();
batchFilterValueHolder.put(L_PRODUCT_ID, product.getId());
batchLookup.setFilterValue(batchFilterValueHolder);
}
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class BeforeAdditionalActionsAnalysisGeneratorListeners method calculateTotalQuantity.
public void calculateTotalQuantity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
String query = buildQuery();
Map<String, String> filter = grid.getFilters();
GridComponentMultiSearchFilter multiSearchFilter = grid.getMultiSearchFilter();
String filterQ;
try {
filterQ = GridComponentFilterSQLUtils.addFilters(filter, grid.getColumns(), "productioncounting_beforeadditionalactionsanalysisentry", dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, ProductionCountingConstants.MODEL_BEFORE_ADDITIONAL_ACTIONS_ANALYSIS_ENTRY));
String multiFilterQ = GridComponentFilterSQLUtils.addMultiSearchFilter(multiSearchFilter, grid.getColumns(), "productioncounting_beforeadditionalactionsanalysisentry", dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, ProductionCountingConstants.MODEL_BEFORE_ADDITIONAL_ACTIONS_ANALYSIS_ENTRY));
if (!Strings.isNullOrEmpty(multiFilterQ)) {
if (!Strings.isNullOrEmpty(filterQ))
filterQ += " AND ";
filterQ += multiFilterQ;
}
} catch (Exception e) {
filterQ = "";
}
if (!Strings.isNullOrEmpty(filterQ)) {
query = query + " WHERE " + filterQ;
}
Map<String, Object> values = jdbcTemplate.queryForMap(query, Collections.emptyMap());
FieldComponent totalQuantity = (FieldComponent) view.getComponentByReference("totalQuantity");
totalQuantity.setFieldValue(numberService.format(values.get("totalDoneQuantity")));
totalQuantity.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class FinalProductAnalysisGeneratorListeners method calculateTotalQuantity.
public void calculateTotalQuantity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
String query = buildQuery();
Map<String, String> filter = grid.getFilters();
GridComponentMultiSearchFilter multiSearchFilter = grid.getMultiSearchFilter();
String filterQ;
try {
filterQ = GridComponentFilterSQLUtils.addFilters(filter, grid.getColumns(), "productioncounting_finalproductanalysisentry", dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, ProductionCountingConstants.MODEL_FINAL_PRODUCT_ANALYSIS_ENTRY));
String multiFilterQ = GridComponentFilterSQLUtils.addMultiSearchFilter(multiSearchFilter, grid.getColumns(), "productioncounting_finalproductanalysisentry", dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, ProductionCountingConstants.MODEL_FINAL_PRODUCT_ANALYSIS_ENTRY));
if (!Strings.isNullOrEmpty(multiFilterQ)) {
if (!Strings.isNullOrEmpty(filterQ))
filterQ += " AND ";
filterQ += multiFilterQ;
}
} catch (Exception e) {
filterQ = "";
}
if (!Strings.isNullOrEmpty(filterQ)) {
query = query + " WHERE " + filterQ;
}
Map<String, Object> values = jdbcTemplate.queryForMap(query, Collections.emptyMap());
FieldComponent totalQuantity = (FieldComponent) view.getComponentByReference("totalQuantity");
totalQuantity.setFieldValue(numberService.format(values.get("totalDoneQuantity")));
totalQuantity.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class ProductionTrackingDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent productionTrackingForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
setCriteriaModifierParameters(view);
productionTrackingService.fillProductionLineLookup(view);
if ((view.isViewAfterRedirect() || view.isViewAfterReload()) && !((CheckBoxComponent) view.getComponentByReference(ProductionTrackingFields.ADD_BATCH)).isChecked()) {
FieldComponent batchNumber = (FieldComponent) view.getComponentByReference(ProductionTrackingFields.BATCH_NUMBER);
batchNumber.setEnabled(false);
}
if (Objects.isNull(productionTrackingForm.getEntityId())) {
setStateFieldValueToDraft(view);
} else {
Entity productionTracking = getProductionTrackingFromDB(productionTrackingForm.getEntityId());
initializeProductionTrackingDetailsView(view);
showLastStateChangeFailNotification(productionTrackingForm, productionTracking);
changeFieldComponentsEnabledAndGridsEditable(view);
updateRibbonState(view);
toggleCorrectButton(view, productionTracking);
toggleCorrectionFields(view, productionTracking);
fetchNumberFromDatabase(view, productionTracking);
}
fillBatchOrderedProductLabel(view);
changeStoppagesTabVisible(view);
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class TechnologyDetailsHooksPC method setTechnologyDefaultValues.
public void setTechnologyDefaultValues(final ViewDefinitionState view) {
FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
FieldComponent typeOfProductionRecordingField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
if (Objects.nonNull(orderForm.getEntityId())) {
return;
}
for (String fieldComponentName : L_TECHNOLOGY_FIELD_NAMES) {
FieldComponent fieldComponent = (FieldComponent) view.getComponentByReference(fieldComponentName);
if (Objects.isNull(fieldComponent.getFieldValue())) {
fieldComponent.setFieldValue(getDefaultValueForProductionCountingFromParameter(fieldComponentName));
fieldComponent.requestComponentUpdateState();
}
fieldComponent.setEnabled(false);
}
if (Objects.isNull(typeOfProductionRecordingField.getFieldValue())) {
typeOfProductionRecordingField.setFieldValue(getDefaultValueForTypeOfProductionRecordingParameter(TechnologyFieldsPC.TYPE_OF_PRODUCTION_RECORDING));
}
}
Aggregations