Search in sources :

Example 16 with FormComponent

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

the class IssueCommonDetailsHelper method fillStorageLocation.

public void fillStorageLocation(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);
    Entity storageLocation = productToIssue.getBelongsToField(ProductsToIssueFields.STORAGE_LOCATION);
    if (product != null && warehouse != null && storageLocation == null) {
        Optional<Entity> option = findStorageLocationForProduct(product, warehouse);
        if (option.isPresent()) {
            LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference(IssueCommonDetailsHelper.STORAGE_LOCATION);
            storageLocationLookup.setFieldValue(option.get().getId());
            storageLocationLookup.requestComponentUpdateState();
        }
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 17 with FormComponent

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

the class ModelCardDetailsListeners method generateModelCard.

@Transactional
public void generateModelCard(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent productsGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    if (productsGrid.getEntities().isEmpty()) {
        view.addMessage("productFlowThruDivision.modelCard.generate.failure.noProducts", ComponentState.MessageType.INFO);
        return;
    }
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference(ModelCardFields.GENERATED);
    FieldComponent workerField = (FieldComponent) view.getComponentByReference(ModelCardFields.WORKER);
    FieldComponent dateField = (FieldComponent) view.getComponentByReference(ModelCardFields.DATE);
    workerField.setFieldValue(securityService.getCurrentUserName());
    dateField.setFieldValue(DateUtils.toDateTimeString(new Date()));
    generated.setChecked(true);
    Entity modelCard = form.getEntity();
    modelCard = modelCard.getDataDefinition().save(modelCard);
    form.setEntity(modelCard);
    Entity modelCardWithFileName = fileService.updateReportFileName(modelCard, ModelCardFields.DATE, "productFlowThruDivision.modelCard.report.fileName");
    try {
        modelCardPdfService.generateDocument(modelCardWithFileName, state.getLocale(), PageSize.A4.rotate());
    } catch (IOException | DocumentException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
    view.addMessage("productFlowThruDivision.modelCard.generate.success", ComponentState.MessageType.SUCCESS);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) DocumentException(com.lowagie.text.DocumentException) IOException(java.io.IOException) Date(java.util.Date) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with FormComponent

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

the class OrderDetailsListenersPFTD method showMaterialAvailabilityForProductionTracking.

public void showMaterialAvailabilityForProductionTracking(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent productionRecordForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity productionRecord = productionRecordForm.getEntity();
    Long orderId = productionRecord.getBelongsToField(ProductionTrackingFields.ORDER).getId();
    showMaterialAvailability(view, orderId);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity)

Example 19 with FormComponent

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

the class TechnologyDetailsListenersPFTD method createModelCard.

public void createModelCard(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity technology = technologyForm.getPersistedEntityWithIncludedFormValues();
    Entity product = technology.getBelongsToField(TechnologyFields.PRODUCT);
    Entity parameter = parameterService.getParameter();
    DataDefinition modelCardDD = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_MODEL_CARD);
    Entity modelCard = modelCardDD.create();
    modelCard.setField(ModelCardFields.NAME, product.getField(ProductFields.NAME));
    modelCard.setField(ModelCardFields.MATERIAL_COSTS_USED, parameter.getStringField(ParameterFieldsPFTD.MATERIAL_COSTS_USED_MC));
    modelCard.setField(ModelCardFields.USE_NOMINAL_COST_PRICE_NOT_SPECIFIED, parameter.getBooleanField(ParameterFieldsPFTD.USE_NOMINAL_COST_PRICE_NOT_SPECIFIED_MC));
    DataDefinition modelCardProductDD = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_MODEL_CARD_PRODUCT);
    Entity modelCardProduct = modelCardProductDD.create();
    modelCardProduct.setField(ModelCardProductFields.PRODUCT, product);
    modelCardProduct.setField(ModelCardProductFields.TECHNOLOGY, technology);
    modelCardProduct.setField(ModelCardProductFields.QUANTITY, 1L);
    modelCard.setField(ModelCardFields.MODEL_CARD_PRODUCTS, Collections.singletonList(modelCardProduct));
    modelCard = modelCardDD.save(modelCard);
    Map<String, Object> parameters = Maps.newHashMap();
    parameters.put("form.id", modelCard.getId());
    String url = "../page/productFlowThruDivision/modelCardDetails.html";
    view.redirectTo(url, false, true, parameters);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) JSONObject(org.json.JSONObject) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 20 with FormComponent

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

the class IssueDetailsHooks method fillUnit.

private void fillUnit(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity issue = form.getPersistedEntityWithIncludedFormValues();
    if (issue.getBooleanField(IssueFields.ISSUED)) {
        form.setFormEnabled(false);
        return;
    }
    Entity product = issue.getBelongsToField(IssueFields.PRODUCT);
    FieldComponent issueUnitField = (FieldComponent) view.getComponentByReference("issueQuantityUnit");
    FieldComponent demandUnitField = (FieldComponent) view.getComponentByReference("demandQuantityUnit");
    if (product != null) {
        String unit = product.getStringField(ProductFields.UNIT);
        issueUnitField.setFieldValue(unit);
        demandUnitField.setFieldValue(unit);
    } else {
        issueUnitField.setFieldValue(StringUtils.EMPTY);
        demandUnitField.setFieldValue(StringUtils.EMPTY);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

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