Search in sources :

Example 36 with ComponentState

use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.

the class DeliveriesServiceImpl method getProductEntityByComponentName.

private Entity getProductEntityByComponentName(final ViewDefinitionState view, final String productName) {
    ComponentState productComponentState = view.getComponentByReference(productName);
    Entity product = null;
    if (productComponentState instanceof LookupComponent) {
        product = ((LookupComponent) productComponentState).getEntity();
    }
    return product;
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) ComponentState(com.qcadoo.view.api.ComponentState)

Example 37 with ComponentState

use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.

the class OperationDurationDetailsInOrderListenerOFSPG method saveDatesInSubOrders.

@Transactional
public final void saveDatesInSubOrders(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Long orderId = form.getEntityId();
    List<Entity> orders = getOrdersForComponent(orderId);
    if (!orders.isEmpty()) {
        List<Entity> ordersTimeCalculations = dataDefinitionService.get(TimeNormsConstants.PLUGIN_PRODUCTION_SCHEDULING_IDENTIFIER, TimeNormsConstants.MODEL_ORDER_TIME_CALCULATION).find().createAlias("order", "ord", JoinType.LEFT).add(SearchRestrictions.in("ord.id", getOrdersForComponent(orderId).stream().map(entity -> entity.getId()).collect(Collectors.toList()))).list().getEntities();
        Map<Long, Entity> ordersTimeCalculationsByOrder = ordersTimeCalculations.stream().collect(Collectors.toMap(x -> x.getBelongsToField(OrderTimeCalculationFields.ORDER).getId(), x -> x));
        for (Entity order : orders) {
            order.setField(OrderFields.DATE_FROM, getStartDate(ordersTimeCalculationsByOrder.get(order.getId())));
            order.setField(OrderFields.DATE_TO, getFinishDate(ordersTimeCalculationsByOrder.get(order.getId())));
            order.getDataDefinition().save(order);
        }
        form.addMessage("productionScheduling.info.saveDatesInSubOrdersSuccess", ComponentState.MessageType.SUCCESS);
    } else {
        form.addMessage("productionScheduling.info.saveDatesInSubOrdersNoOrders", ComponentState.MessageType.INFO);
    }
    state.performEvent(view, "reset", new String[0]);
}
Also used : DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) OrderTimeCalculationFields(com.qcadoo.mes.productionScheduling.constants.OrderTimeCalculationFields) SearchRestrictions(com.qcadoo.model.api.search.SearchRestrictions) ComponentState(com.qcadoo.view.api.ComponentState) QcadooViewConstants(com.qcadoo.view.constants.QcadooViewConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) OrderFields(com.qcadoo.mes.orders.constants.OrderFields) OrdersConstants(com.qcadoo.mes.orders.constants.OrdersConstants) Collectors(java.util.stream.Collectors) DataDefinition(com.qcadoo.model.api.DataDefinition) TimeNormsConstants(com.qcadoo.mes.timeNormsForOperations.constants.TimeNormsConstants) JoinType(com.qcadoo.model.api.search.JoinType) List(java.util.List) Entity(com.qcadoo.model.api.Entity) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) Lists(com.google.common.collect.Lists) Service(org.springframework.stereotype.Service) Map(java.util.Map) FormComponent(com.qcadoo.view.api.components.FormComponent) Transactional(org.springframework.transaction.annotation.Transactional) FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 38 with ComponentState

use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.

the class SupplyParametersHooksPFTD method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    ComponentState warehouseIssueProductsSource = view.getComponentByReference(ParameterFieldsPFTD.WAREHOUSE_ISSUE_PRODUCTS_SOURCE);
    supplyParametersListenersPFTD.toggleGenerateIssuesTo(view, warehouseIssueProductsSource, null);
    toggleStateReservation(view);
}
Also used : ComponentState(com.qcadoo.view.api.ComponentState)

Example 39 with ComponentState

use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.

the class WorkPlanDetailsListeners method validateOrders.

private boolean validateOrders(final ComponentState state, final List<Entity> orders) {
    List<String> numbers = Lists.newArrayList();
    for (Entity order : orders) {
        if (order.getBelongsToField(OrderFields.TECHNOLOGY) == null) {
            numbers.add(order.getStringField(OrderFields.NUMBER));
        }
    }
    if (!numbers.isEmpty()) {
        String commaSeparatedNumbers = numbers.stream().map(i -> i).collect(Collectors.joining(", "));
        state.addMessage("workPlans.workPlanDetails.window.workPlan.missingTechnologyInOrders", MessageType.FAILURE, commaSeparatedNumbers);
        return false;
    }
    return true;
}
Also used : TechnologyFields(com.qcadoo.mes.technologies.constants.TechnologyFields) WorkPlansService(com.qcadoo.mes.workPlans.WorkPlansService) MessageType(com.qcadoo.view.api.ComponentState.MessageType) Date(java.util.Date) ComponentState(com.qcadoo.view.api.ComponentState) SimpleDateFormat(java.text.SimpleDateFormat) Autowired(org.springframework.beans.factory.annotation.Autowired) OrderFields(com.qcadoo.mes.orders.constants.OrderFields) StringUtils(org.apache.commons.lang3.StringUtils) DateUtils(com.qcadoo.localization.api.utils.DateUtils) FileService(com.qcadoo.model.api.file.FileService) WorkPlanForDivisionPdfService(com.qcadoo.mes.workPlans.print.WorkPlanForDivisionPdfService) ReportService(com.qcadoo.report.api.ReportService) OrderHelperService(com.qcadoo.mes.orders.util.OrderHelperService) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) Lists(com.google.common.collect.Lists) WorkPlanType(com.qcadoo.mes.workPlans.constants.WorkPlanType) WorkPlansConstants(com.qcadoo.mes.workPlans.constants.WorkPlansConstants) Service(org.springframework.stereotype.Service) FormComponent(com.qcadoo.view.api.components.FormComponent) WorkPlanFields(com.qcadoo.mes.workPlans.constants.WorkPlanFields) SecurityService(com.qcadoo.security.api.SecurityService) WorkPlanPdfService(com.qcadoo.mes.workPlans.print.WorkPlanPdfService) IOException(java.io.IOException) DocumentException(com.lowagie.text.DocumentException) Collectors(java.util.stream.Collectors) GridComponent(com.qcadoo.view.api.components.GridComponent) List(java.util.List) Entity(com.qcadoo.model.api.Entity) BarcodeOperationComponentService(com.qcadoo.mes.technologies.BarcodeOperationComponentService) FieldComponent(com.qcadoo.view.api.components.FieldComponent) PageSize(com.lowagie.text.PageSize) Transactional(org.springframework.transaction.annotation.Transactional) Entity(com.qcadoo.model.api.Entity)

Example 40 with ComponentState

use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.

the class WorkPlanDetailsListeners method checkIfInactiveOrders.

private boolean checkIfInactiveOrders(final ComponentState state, final List<Entity> orders) {
    List<String> numbers = Lists.newArrayList();
    for (Entity order : orders) {
        if (!order.isActive()) {
            numbers.add(order.getStringField(OrderFields.NUMBER));
        }
    }
    if (!numbers.isEmpty()) {
        String commaSeparatedNumbers = numbers.stream().map(i -> i).collect(Collectors.joining(", "));
        state.addMessage("workPlans.workPlanDetails.window.workPlan.isInactiveOrders", MessageType.INFO, commaSeparatedNumbers);
        return false;
    }
    return true;
}
Also used : TechnologyFields(com.qcadoo.mes.technologies.constants.TechnologyFields) WorkPlansService(com.qcadoo.mes.workPlans.WorkPlansService) MessageType(com.qcadoo.view.api.ComponentState.MessageType) Date(java.util.Date) ComponentState(com.qcadoo.view.api.ComponentState) SimpleDateFormat(java.text.SimpleDateFormat) Autowired(org.springframework.beans.factory.annotation.Autowired) OrderFields(com.qcadoo.mes.orders.constants.OrderFields) StringUtils(org.apache.commons.lang3.StringUtils) DateUtils(com.qcadoo.localization.api.utils.DateUtils) FileService(com.qcadoo.model.api.file.FileService) WorkPlanForDivisionPdfService(com.qcadoo.mes.workPlans.print.WorkPlanForDivisionPdfService) ReportService(com.qcadoo.report.api.ReportService) OrderHelperService(com.qcadoo.mes.orders.util.OrderHelperService) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) Lists(com.google.common.collect.Lists) WorkPlanType(com.qcadoo.mes.workPlans.constants.WorkPlanType) WorkPlansConstants(com.qcadoo.mes.workPlans.constants.WorkPlansConstants) Service(org.springframework.stereotype.Service) FormComponent(com.qcadoo.view.api.components.FormComponent) WorkPlanFields(com.qcadoo.mes.workPlans.constants.WorkPlanFields) SecurityService(com.qcadoo.security.api.SecurityService) WorkPlanPdfService(com.qcadoo.mes.workPlans.print.WorkPlanPdfService) IOException(java.io.IOException) DocumentException(com.lowagie.text.DocumentException) Collectors(java.util.stream.Collectors) GridComponent(com.qcadoo.view.api.components.GridComponent) List(java.util.List) Entity(com.qcadoo.model.api.Entity) BarcodeOperationComponentService(com.qcadoo.mes.technologies.BarcodeOperationComponentService) FieldComponent(com.qcadoo.view.api.components.FieldComponent) PageSize(com.lowagie.text.PageSize) Transactional(org.springframework.transaction.annotation.Transactional) Entity(com.qcadoo.model.api.Entity)

Aggregations

ComponentState (com.qcadoo.view.api.ComponentState)68 Entity (com.qcadoo.model.api.Entity)33 FormComponent (com.qcadoo.view.api.components.FormComponent)31 GridComponent (com.qcadoo.view.api.components.GridComponent)23 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)21 Autowired (org.springframework.beans.factory.annotation.Autowired)17 FieldComponent (com.qcadoo.view.api.components.FieldComponent)16 Test (org.junit.Test)16 Service (org.springframework.stereotype.Service)16 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)15 Collectors (java.util.stream.Collectors)14 List (java.util.List)13 DataDefinition (com.qcadoo.model.api.DataDefinition)12 Lists (com.google.common.collect.Lists)11 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)11 Map (java.util.Map)11 BigDecimal (java.math.BigDecimal)10 Maps (com.google.common.collect.Maps)8 LookupComponent (com.qcadoo.view.api.components.LookupComponent)8 Transactional (org.springframework.transaction.annotation.Transactional)8