use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class OrderWithMaterialAvailabilityListListeners method showReplacementsAvailability.
public void showReplacementsAvailability(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
Entity record = grid.getSelectedEntities().get(0);
Entity oma = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_MATERIAL_AVAILABILITY).get(record.getId());
Long productId = oma.getBelongsToField(MaterialAvailabilityFields.PRODUCT).getId();
JSONObject json = new JSONObject();
try {
json.put("product.id", productId);
} catch (JSONException e) {
throw new IllegalStateException(e);
}
String url = "/page/productFlowThruDivision/materialReplacementsAvailabilityList.html?context=" + json.toString();
view.redirectTo(url, false, true);
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class OrdersPlanningListListenersPFTD method showMaterialAvailabilityForOrders.
public void showMaterialAvailabilityForOrders(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
Map<String, Object> parameters = Maps.newHashMap();
parameters.put("ordersIds", grid.getSelectedEntitiesIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
String url = "/page/productFlowThruDivision/ordersWithMaterialAvailabilityList.html";
view.redirectTo(url, false, true, parameters);
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class AnomalyExplanationDetailsListeners method onRemoveSelectedEntity.
public void onRemoveSelectedEntity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent anomalyExplanationsGrid = (GridComponent) view.getComponentByReference("anomalyExplanations");
DataDefinition dataDefinition = dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, ProductionCountingConstants.MODEL_ANOMALY_EXPLANATION);
dataDefinition.delete(toArray(anomalyExplanationsGrid.getSelectedEntitiesIds(), Long.class));
FormComponent documentForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
documentForm.performEvent(view, "reset");
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class AnomalyListListeners method completeWithoutIssue.
public void completeWithoutIssue(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent gridComponent = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
for (Long anomalyId : gridComponent.getSelectedEntitiesIds()) {
DataDefinition anomalyDD = getAnomalyDD();
Entity anomaly = anomalyDD.get(anomalyId);
anomaly.setField(AnomalyFields.STATE, AnomalyFields.State.COMPLETED);
anomaly.setField(AnomalyFields.ISSUED, false);
anomalyDD.save(anomaly);
}
}
use of com.qcadoo.view.api.components.GridComponent 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();
}
Aggregations