Search in sources :

Example 26 with ComponentState

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

the class GenerateMaterialRequirementCoverageListeners method showReplacementsAvailability.

public void showReplacementsAvailability(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent materialRequirementCoverageForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Long materialRequirementCoverageId = materialRequirementCoverageForm.getEntityId();
    Entity materialRequirement = dataDefinitionService.get(OrderSuppliesConstants.PLUGIN_IDENTIFIER, OrderSuppliesConstants.MODEL_MATERIAL_REQUIREMENT_COVERAGE).get(materialRequirementCoverageId);
    GridComponent grid = (GridComponent) view.getComponentByReference("coverageProducts");
    Long cpId = grid.getSelectedEntitiesIds().stream().findFirst().get();
    Entity cp = dataDefinitionService.get(OrderSuppliesConstants.PLUGIN_IDENTIFIER, OrderSuppliesConstants.MODEL_COVERAGE_PRODUCT).get(cpId);
    Entity product = cp.getBelongsToField(CoverageProductFields.PRODUCT);
    JSONObject json = new JSONObject();
    try {
        json.put("product.id", product.getId());
        json.put("locationsIds", Lists.newArrayList(materialRequirement.getHasManyField(MaterialRequirementCoverageFields.COVERAGE_LOCATIONS).stream().map(cl -> cl.getBelongsToField(CoverageLocationFields.LOCATION).getId()).collect(Collectors.toList())));
    } catch (JSONException e) {
        throw new IllegalStateException(e);
    }
    String url = "/page/productFlowThruDivision/materialReplacementsAvailabilityList.html?context=" + json.toString();
    view.redirectTo(url, false, true);
}
Also used : LocaleContextHolder(org.springframework.context.i18n.LocaleContextHolder) Date(java.util.Date) Autowired(org.springframework.beans.factory.annotation.Autowired) UnitConversionService(com.qcadoo.model.api.units.UnitConversionService) MaterialRequirementCoverageFields(com.qcadoo.mes.orderSupplies.constants.MaterialRequirementCoverageFields) StringUtils(org.apache.commons.lang3.StringUtils) ParameterFields(com.qcadoo.mes.basic.constants.ParameterFields) FileService(com.qcadoo.model.api.file.FileService) BigDecimal(java.math.BigDecimal) ReportService(com.qcadoo.report.api.ReportService) JSONException(org.json.JSONException) OrderSuppliesConstants(com.qcadoo.mes.orderSupplies.constants.OrderSuppliesConstants) JSONObject(org.json.JSONObject) Locale(java.util.Locale) BasicConstants(com.qcadoo.mes.basic.constants.BasicConstants) Map(java.util.Map) CoverageProductSelectedFields(com.qcadoo.mes.orderSupplies.constants.CoverageProductSelectedFields) SearchRestrictions(com.qcadoo.model.api.search.SearchRestrictions) DeliveriesConstants(com.qcadoo.mes.deliveries.constants.DeliveriesConstants) Collectors(java.util.stream.Collectors) DataDefinition(com.qcadoo.model.api.DataDefinition) Objects(java.util.Objects) List(java.util.List) Entity(com.qcadoo.model.api.Entity) CoverageAnalysisForOrderService(com.qcadoo.mes.orderSupplies.coverage.coverageAnalysis.CoverageAnalysisForOrderService) ParameterService(com.qcadoo.mes.basic.ParameterService) EXTERNAL_SYNCHRONIZED(com.qcadoo.mes.deliveries.constants.DeliveryFields.EXTERNAL_SYNCHRONIZED) CompanyFieldsD(com.qcadoo.mes.deliveries.constants.CompanyFieldsD) Optional(java.util.Optional) MessageType(com.qcadoo.view.api.ComponentState.MessageType) DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) ComponentState(com.qcadoo.view.api.ComponentState) QcadooViewConstants(com.qcadoo.view.constants.QcadooViewConstants) SimpleDateFormat(java.text.SimpleDateFormat) NUMBER(com.qcadoo.mes.deliveries.constants.DeliveryFields.NUMBER) DateUtils(com.qcadoo.localization.api.utils.DateUtils) CURRENCY(com.qcadoo.mes.deliveries.constants.DeliveryFields.CURRENCY) DeliveriesService(com.qcadoo.mes.deliveries.DeliveriesService) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) Lists(com.google.common.collect.Lists) PossibleUnitConversions(com.qcadoo.model.api.units.PossibleUnitConversions) NumberGeneratorService(com.qcadoo.view.api.utils.NumberGeneratorService) OrderSuppliesService(com.qcadoo.mes.orderSupplies.OrderSuppliesService) Service(org.springframework.stereotype.Service) FormComponent(com.qcadoo.view.api.components.FormComponent) SecurityService(com.qcadoo.security.api.SecurityService) CoverageProductFields(com.qcadoo.mes.orderSupplies.constants.CoverageProductFields) MaterialRequirementCoverageReportPdfService(com.qcadoo.mes.orderSupplies.print.MaterialRequirementCoverageReportPdfService) IOException(java.io.IOException) UnitConversionItemFieldsB(com.qcadoo.mes.basic.constants.UnitConversionItemFieldsB) DocumentException(com.lowagie.text.DocumentException) OrderedProductFields(com.qcadoo.mes.deliveries.constants.OrderedProductFields) GridComponent(com.qcadoo.view.api.components.GridComponent) CoverageLocationFields(com.qcadoo.mes.orderSupplies.constants.CoverageLocationFields) MaterialRequirementCoverageService(com.qcadoo.mes.orderSupplies.coverage.MaterialRequirementCoverageService) NumberService(com.qcadoo.model.api.NumberService) SUPPLIER(com.qcadoo.mes.deliveries.constants.DeliveryFields.SUPPLIER) ProductFields(com.qcadoo.mes.basic.constants.ProductFields) PageSize(com.lowagie.text.PageSize) CoverageProductGeneratedFields(com.qcadoo.mes.orderSupplies.constants.CoverageProductGeneratedFields) Transactional(org.springframework.transaction.annotation.Transactional) FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) JSONObject(org.json.JSONObject) GridComponent(com.qcadoo.view.api.components.GridComponent) JSONException(org.json.JSONException)

Example 27 with ComponentState

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

the class OperationalTasksDetailsHooks method fetchNumberFromDatabase.

private void fetchNumberFromDatabase(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (form.getEntityId() != null) {
        ComponentState numberField = view.getComponentByReference(OperationalTaskFields.NUMBER);
        String numberFieldValue = (String) numberField.getFieldValue();
        if (Strings.isNullOrEmpty(numberFieldValue)) {
            Entity ot = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_OPERATIONAL_TASK).get(form.getEntityId());
            numberField.setFieldValue(ot.getField(OperationalTaskFields.NUMBER));
        }
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) ComponentState(com.qcadoo.view.api.ComponentState)

Example 28 with ComponentState

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

the class OrderPacksSingleOrderListListeners method printLabels.

public void printLabels(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    Set<Long> packsIds = grid.getSelectedEntitiesIds();
    if (packsIds.isEmpty()) {
        view.addMessage("orders.packs.notSelected", ComponentState.MessageType.INFO);
    } else {
        view.redirectTo("/orders/packsLabels.pdf?" + packsIds.stream().map(id -> "ids=" + id.toString()).collect(Collectors.joining("&")), true, false);
    }
}
Also used : DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) ComponentState(com.qcadoo.view.api.ComponentState) QcadooViewConstants(com.qcadoo.view.constants.QcadooViewConstants) OrderFields(com.qcadoo.mes.orders.constants.OrderFields) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) OrdersConstants(com.qcadoo.mes.orders.constants.OrdersConstants) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) GridComponent(com.qcadoo.view.api.components.GridComponent) Objects(java.util.Objects) Entity(com.qcadoo.model.api.Entity) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) ParameterService(com.qcadoo.mes.basic.ParameterService) OrderPackFields(com.qcadoo.mes.orders.constants.OrderPackFields) ParameterFieldsO(com.qcadoo.mes.orders.constants.ParameterFieldsO) Service(org.springframework.stereotype.Service) FormComponent(com.qcadoo.view.api.components.FormComponent) Map(java.util.Map) StateExecutorService(com.qcadoo.mes.newstates.StateExecutorService) OrderPackServiceMarker(com.qcadoo.mes.orders.states.OrderPackServiceMarker) OrderPackService(com.qcadoo.mes.orders.OrderPackService) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 29 with ComponentState

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

the class LocationDetailsPFTD method changeDivisionsTabAndGridVisibility.

public void changeDivisionsTabAndGridVisibility(final ViewDefinitionState view) {
    FormComponent locationForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    GridComponent divisionsGrid = (GridComponent) view.getComponentByReference(L_DIVISIONS);
    ComponentState divisionsTab = view.getComponentByReference(L_DIVISIONS_TAB);
    Entity location = locationForm.getEntity();
    boolean isVisible = location.getId() != null;
    divisionsGrid.setVisible(isVisible);
    divisionsTab.setVisible(isVisible);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) ComponentState(com.qcadoo.view.api.ComponentState)

Example 30 with ComponentState

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

the class OrderDetailsHooksPFTD method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    orderDetailsRibbonHelper.setButtonEnabled(view, "materialFlow", "warehouseIssues", OrderDetailsRibbonHelper.HAS_CHECKED_OR_ACCEPTED_TECHNOLOGY::test);
    orderDetailsRibbonHelper.setButtonEnabled(view, "materialFlow", "componentAvailability", OrderDetailsRibbonHelper.HAS_CHECKED_OR_ACCEPTED_TECHNOLOGY::test);
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    ComponentState staffTab = view.getComponentByReference("staffTab");
    if (form.getEntityId() != null) {
        Entity order = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).get(form.getEntityId());
        staffTab.setVisible(TypeOfProductionRecording.CUMULATED.getStringValue().equals(order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING)));
        LookupComponent technologyLookup = (LookupComponent) view.getComponentByReference(OrderFields.TECHNOLOGY_PROTOTYPE);
        LookupComponent productionLineLookup = (LookupComponent) view.getComponentByReference(OrderFields.PRODUCTION_LINE);
        Entity technology = technologyLookup.getEntity();
        Entity productionLine = productionLineLookup.getEntity();
        if (technology != null && productionLine != null) {
            FieldComponent plannedStaffField = (FieldComponent) view.getComponentByReference("plannedStaff");
            Optional<Integer> plannedStaff = technologyService.getPlannedStaff(technology, productionLine);
            if (plannedStaff.isPresent()) {
                plannedStaffField.setFieldValue(plannedStaff.get());
            } else {
                plannedStaffField.setFieldValue(null);
            }
        }
        FieldComponent actualStaff = (FieldComponent) view.getComponentByReference("actualStaff");
        actualStaff.setFieldValue(order.getManyToManyField(OrderFields.STAFF).size());
        LookupComponent staffLookup = (LookupComponent) view.getComponentByReference("staffLookup");
        FilterValueHolder valueHolder = staffLookup.getFilterValue();
        valueHolder.put(StaffCriteriaModifierPFTD.L_ORDER_ID, form.getEntityId());
        if (productionLine != null) {
            valueHolder.put(StaffCriteriaModifierPFTD.L_PRODUCTION_LINE_ID, productionLine.getId());
        } else if (valueHolder.has(StaffCriteriaModifierPFTD.L_PRODUCTION_LINE_ID)) {
            valueHolder.remove(StaffCriteriaModifierPFTD.L_PRODUCTION_LINE_ID);
        }
        staffLookup.setFilterValue(valueHolder);
    } else {
        staffTab.setVisible(false);
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) ComponentState(com.qcadoo.view.api.ComponentState)

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