use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class TechnologiesWithUsingProductListListeners method goToModifyTechnology.
public void goToModifyTechnology(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
List<Integer> entitiesId = Lists.newArrayList();
Set<Long> selected = grid.getSelectedEntitiesIds();
List<Entity> entities = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, "operationProductInProductDto").find().add(SearchRestrictions.in("id", selected)).list().getEntities();
boolean isProductBySize = entities.stream().anyMatch(entry -> selected.contains(entry.getId()) && entry.getBooleanField("sizeProduct"));
for (Entity entity : entities) {
if (selected.contains(entity.getId())) {
if (isProductBySize) {
if (!entitiesId.contains(entity.getIntegerField("productBySizeGroupId"))) {
entitiesId.add(entity.getIntegerField("productBySizeGroupId"));
}
} else {
if (!entitiesId.contains(entity.getIntegerField("operationProductInComponentId"))) {
entitiesId.add(entity.getIntegerField("operationProductInComponentId"));
}
}
}
}
Entity modifyTechnology = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODIFY_TECHNOLOGY_HELPER).create();
modifyTechnology.setField("product", form.getEntityId());
modifyTechnology.setField("sizeProduct", isProductBySize);
modifyTechnology.setField("selectedEntities", entitiesId.stream().map(e -> e.toString()).collect(Collectors.joining(",")));
modifyTechnology = modifyTechnology.getDataDefinition().save(modifyTechnology);
Map<String, Object> parameters = Maps.newHashMap();
parameters.put("form.id", modifyTechnology.getId());
String url = "../page/technologies/modifyTechnology.html";
view.openModal(url, parameters);
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class TechnologyDetailsListeners method moveProducts.
public void moveProducts(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent inProducts = (GridComponent) view.getComponentByReference("inProducts");
if (inProducts.getSelectedEntitiesIds().isEmpty()) {
state.addMessage("technologies.technologyDetails.window.noSelectedProducts", MessageType.INFO);
return;
}
boolean invalidProducts = false;
for (Entity inProductDto : inProducts.getSelectedEntities()) {
DataDefinition operationProductInComponentDD = getOperationProductInComponentDD();
Entity inProduct = operationProductInComponentDD.get(inProductDto.getId());
Entity operationComponent = inProduct.getBelongsToField(OperationProductInComponentFields.OPERATION_COMPONENT);
Entity parent = operationComponent.getBelongsToField(TechnologyOperationComponentFields.PARENT);
if (parent != null) {
Entity product = inProduct.getBelongsToField(OperationProductInComponentFields.PRODUCT);
if (product != null && technologyService.isIntermediateProduct(inProduct)) {
state.addMessage("technologies.technologyDetails.window.noOutProductInOperation", MessageType.INFO, product.getStringField(ProductFields.NUMBER));
}
inProduct.setField(OperationProductInComponentFields.OPERATION_COMPONENT, parent);
inProduct = operationProductInComponentDD.save(inProduct);
if (!inProduct.isValid()) {
invalidProducts = true;
}
} else {
state.addMessage("technologies.technologyDetails.window.operationWithoutParent", MessageType.INFO);
return;
}
}
if (invalidProducts) {
state.addMessage("technologies.technologyDetails.window.moveProducts.info", MessageType.INFO);
} else {
state.addMessage("technologies.technologyDetails.window.moveProducts.success", MessageType.SUCCESS);
}
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class TechnologyOperCompDetailsListenersTNFO method copyTimeNormsFromOperationForTechnologies.
public void copyTimeNormsFromOperationForTechnologies(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
Set<Long> selectedEntities = grid.getSelectedEntitiesIds();
selectedEntities.forEach(techId -> {
Entity technology = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY).get(techId);
for (Entity toc : technology.getHasManyField(TechnologyFields.OPERATION_COMPONENTS)) {
Entity operation = toc.getBelongsToField(OPERATION);
copyOperationWorkstationTimes(toc, operation);
applyTimeNormsFromGivenSource(toc, operation);
}
});
view.addMessage("qcadooView.notification.success", SUCCESS);
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class OrdersListListenersWP method addSelectedOrdersToWorkPlan.
public final void addSelectedOrdersToWorkPlan(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent ordersGrid = (GridComponent) state;
List<Entity> orders = workPlanService.getSelectedOrders(ordersGrid.getSelectedEntitiesIds());
Entity workPlan = workPlanService.generateWorkPlanEntity(orders);
Map<String, Object> parameters = Maps.newHashMap();
parameters.put("form.id", workPlan.getId());
parameters.put("window.activeMenu", "reports.workPlans");
view.redirectTo("/page/workPlans/workPlanDetails.html", false, true, parameters);
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class OrdersPlanningListListenersWP method addSelectedOrdersToWorkPlan.
public final void addSelectedOrdersToWorkPlan(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent ordersGrid = (GridComponent) state;
List<Entity> orders = workPlanService.getSelectedOrders(ordersGrid.getSelectedEntitiesIds());
Entity workPlan = workPlanService.generateWorkPlanEntity(orders);
Map<String, Object> parameters = Maps.newHashMap();
parameters.put("form.id", workPlan.getId());
parameters.put("window.activeMenu", "reports.workPlans");
view.redirectTo("/page/workPlans/workPlanDetails.html", false, true, parameters);
}
Aggregations