Search in sources :

Example 11 with FormComponent

use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.

the class TechnologyDetailsHooksPFTD method fillRangeAndDivision.

private void fillRangeAndDivision(final ViewDefinitionState view) {
    FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    FieldComponent rangeField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPFTD.RANGE);
    LookupComponent divisionLookup = (LookupComponent) view.getComponentByReference(TechnologyFieldsPFTD.DIVISION);
    Long technologyId = technologyForm.getEntityId();
    if (Objects.isNull(technologyId) && view.isViewAfterRedirect()) {
        String range = parameterService.getParameter().getStringField(ParameterFieldsPFTD.RANGE);
        Entity division = parameterService.getParameter().getBelongsToField(ParameterFieldsPFTD.DIVISION);
        rangeField.setFieldValue(range);
        if (Objects.nonNull(division)) {
            divisionLookup.setFieldValue(division.getId());
            fillFieldsForOneDivisionRange(view);
        } else {
            divisionLookup.setFieldValue(null);
        }
    }
    rangeField.requestComponentUpdateState();
    divisionLookup.requestComponentUpdateState();
}
Also used : 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)

Example 12 with FormComponent

use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.

the class TechnologyProductionLineDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    LookupComponent productionLineLookup = (LookupComponent) view.getComponentByReference(TechnologyProductionLineFields.PRODUCTION_LINE);
    Entity entity = form.getEntity();
    Entity technology = entity.getBelongsToField(TechnologyProductionLineFields.TECHNOLOGY);
    Entity division = technology.getBelongsToField(TechnologyFieldsPFTD.DIVISION);
    FilterValueHolder filterValueHolder = productionLineLookup.getFilterValue();
    Long technologyId = technology.getId();
    if (Objects.isNull(technologyId)) {
        filterValueHolder.remove(TechnologyProductionLineCriteriaModifiers.L_TECHNOLOGY_ID);
    } else {
        filterValueHolder.put(TechnologyProductionLineCriteriaModifiers.L_TECHNOLOGY_ID, technologyId);
    }
    if (Objects.nonNull(division)) {
        filterValueHolder.put(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID, division.getId());
    } else if (filterValueHolder.has(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID)) {
        filterValueHolder.remove(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID);
    }
    productionLineLookup.setFilterValue(filterValueHolder);
}
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)

Example 13 with FormComponent

use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.

the class DetailedProductionCountingAndProgressListenersBPC method resourceIssue.

public void resourceIssue(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent formComponent = (FormComponent) view.getComponentByReference(L_ORDER);
    Entity order = formComponent.getEntity().getDataDefinition().get(formComponent.getEntity().getId());
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    Set<Long> ids = grid.getSelectedEntitiesIds();
    List<Entity> pcqs = dataDefinitionService.get(BasicProductionCountingConstants.PLUGIN_IDENTIFIER, BasicProductionCountingConstants.MODEL_PRODUCTION_COUNTING_QUANTITY).find().add(SearchRestrictions.in("id", ids)).list().getEntities();
    if (!canIssueMaterials(order, pcqs)) {
        formComponent.setEntity(order);
        return;
    }
    try {
        productionCountingDocumentService.createInternalOutboundDocument(order, pcqs, false);
        if (order.isValid()) {
            productionCountingDocumentService.updateProductionCountingQuantity(pcqs);
            productionTrackingListenerServicePFTD.updateCostsForOrder(order);
            view.addMessage("productFlowThruDivision.productionCountingQuantity.success.createInternalOutboundDocument", ComponentState.MessageType.SUCCESS);
        }
    } catch (DocumentBuildException documentBuildException) {
        boolean errorsDisplayed = true;
        for (ErrorMessage error : documentBuildException.getEntity().getGlobalErrors()) {
            if (error.getMessage().equalsIgnoreCase(L_ERROR_NOT_ENOUGH_RESOURCES)) {
                order.addGlobalError(error.getMessage(), false, error.getVars());
            } else {
                errorsDisplayed = false;
                order.addGlobalError(error.getMessage(), error.getVars());
            }
        }
        if (!errorsDisplayed) {
            order.addGlobalError("productFlowThruDivision.productionCountingQuantity.productionCountingQuantityError.createInternalOutboundDocument");
        }
        formComponent.setEntity(order);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) ErrorMessage(com.qcadoo.model.api.validators.ErrorMessage) DocumentBuildException(com.qcadoo.mes.materialFlowResources.exceptions.DocumentBuildException)

Example 14 with FormComponent

use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.

the class RealProductionCostService method calculateRealProductionCost.

public void calculateRealProductionCost(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    FormComponent form = (FormComponent) view.getComponentByReference("order");
    Entity order = form.getEntity();
    if (order.getId() == null) {
        return;
    }
    Entity orderDB = order.getDataDefinition().get(order.getId());
    BigDecimal realProductionCost = calculateRealProductionCost(orderDB);
    view.addMessage("productFlowThruDivision.realProductionCost.calculationResult", ComponentState.MessageType.SUCCESS, false, numberService.formatWithMinimumFractionDigits(numberService.setScaleWithDefaultMathContext(realProductionCost, 2), 2));
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) BigDecimal(java.math.BigDecimal)

Example 15 with FormComponent

use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.

the class IssueCommonDetailsHelper method setFilterValue.

public void setFilterValue(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity productToIssue = form.getPersistedEntityWithIncludedFormValues();
    Entity product = productToIssue.getBelongsToField(ProductsToIssueFields.PRODUCT);
    Entity warehouse = productToIssue.getBelongsToField(ProductsToIssueFields.LOCATION);
    LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference(IssueCommonDetailsHelper.STORAGE_LOCATION);
    FilterValueHolder filter = storageLocationLookup.getFilterValue();
    LookupComponent additionalCodeLookup = (LookupComponent) view.getComponentByReference(ADDITIONAL_CODE);
    FilterValueHolder additionalCodeFilter = additionalCodeLookup.getFilterValue();
    if (product != null) {
        filter.put(PRODUCT, product.getId());
        additionalCodeFilter.put(PRODUCT, product.getId());
    } else if (filter.has(PRODUCT)) {
        filter.remove(PRODUCT);
        additionalCodeFilter.remove(PRODUCT);
    }
    if (warehouse != null) {
        filter.remove(LOCATION);
        filter.put(LOCATION, warehouse.getId());
    }
    storageLocationLookup.setFilterValue(filter);
    additionalCodeLookup.setFilterValue(additionalCodeFilter);
}
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)

Aggregations

FormComponent (com.qcadoo.view.api.components.FormComponent)644 Entity (com.qcadoo.model.api.Entity)501 FieldComponent (com.qcadoo.view.api.components.FieldComponent)183 LookupComponent (com.qcadoo.view.api.components.LookupComponent)104 GridComponent (com.qcadoo.view.api.components.GridComponent)83 BigDecimal (java.math.BigDecimal)55 WindowComponent (com.qcadoo.view.api.components.WindowComponent)52 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)45 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)42 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)39 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)36 Date (java.util.Date)33 DataDefinition (com.qcadoo.model.api.DataDefinition)29 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)28 JSONObject (org.json.JSONObject)28 ComponentState (com.qcadoo.view.api.ComponentState)27 Transactional (org.springframework.transaction.annotation.Transactional)20 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)17 Optional (com.google.common.base.Optional)16 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)16