Search in sources :

Example 36 with GridComponent

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);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 37 with GridComponent

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);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 38 with GridComponent

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 39 with GridComponent

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 40 with GridComponent

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Aggregations

GridComponent (com.qcadoo.view.api.components.GridComponent)260 Entity (com.qcadoo.model.api.Entity)131 FormComponent (com.qcadoo.view.api.components.FormComponent)85 FieldComponent (com.qcadoo.view.api.components.FieldComponent)33 WindowComponent (com.qcadoo.view.api.components.WindowComponent)30 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)29 JSONObject (org.json.JSONObject)28 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)26 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)24 ComponentState (com.qcadoo.view.api.ComponentState)23 DataDefinition (com.qcadoo.model.api.DataDefinition)22 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)22 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)20 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)19 Autowired (org.springframework.beans.factory.annotation.Autowired)19 BigDecimal (java.math.BigDecimal)16 Service (org.springframework.stereotype.Service)16 LookupComponent (com.qcadoo.view.api.components.LookupComponent)15 Collectors (java.util.stream.Collectors)15 Lists (com.google.common.collect.Lists)12