Search in sources :

Example 81 with CheckBoxComponent

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

the class CostCalculationDetailsHooks method fillCheckboxWithProperty.

private void fillCheckboxWithProperty(String componentName, boolean propertyValue, ViewDefinitionState view) {
    CheckBoxComponent component = (CheckBoxComponent) view.getComponentByReference(componentName);
    component.setFieldValue(propertyValue);
}
Also used : CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 82 with CheckBoxComponent

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

the class MasterOrderPositionsListListeners method generateOrders.

public void generateOrders(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent masterOrderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    CheckBoxComponent generatedCheckBox = (CheckBoxComponent) view.getComponentByReference(L_GENERATED);
    Entity helper = masterOrderForm.getPersistedEntityWithIncludedFormValues();
    String selectedEntities = helper.getStringField(GeneratingOrdersHelperFields.SELECTED_ENTITIES);
    Date start = helper.getDateField(GeneratingOrdersHelperFields.START_DATE);
    Date finish = helper.getDateField(GeneratingOrdersHelperFields.FINISH_DATE);
    List<Long> ids = Lists.newArrayList(selectedEntities.split(",")).stream().map(Long::valueOf).collect(Collectors.toList());
    List<Entity> masterOrderProducts = getMasterOrderPositionDtoDD().find().add(SearchRestrictions.in("id", ids)).list().getEntities();
    ordersGenerationService.generateOrders(masterOrderProducts, start, finish, true).showMessage(view);
    generatedCheckBox.setChecked(true);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) Date(java.util.Date) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 83 with CheckBoxComponent

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

the class MasterOrdersMaterialRequirementDetailsListeners method generateMasterOrdersMaterialRequirement.

public void generateMasterOrdersMaterialRequirement(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent masterOrdersMaterialRequirementForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    GridComponent masterOrdersGrid = (GridComponent) view.getComponentByReference(MasterOrdersMaterialRequirementFields.MASTER_ORDERS);
    CheckBoxComponent generatedCheckBox = (CheckBoxComponent) view.getComponentByReference(MasterOrdersMaterialRequirementFields.GENERATED);
    FieldComponent workerField = (FieldComponent) view.getComponentByReference(MasterOrdersMaterialRequirementFields.WORKER);
    FieldComponent dateField = (FieldComponent) view.getComponentByReference(MasterOrdersMaterialRequirementFields.DATE);
    List<Entity> masterOrders = masterOrdersGrid.getEntities();
    if (validateMasterOrdersMaterialRequirement(masterOrdersMaterialRequirementForm, masterOrders)) {
        workerField.setFieldValue(securityService.getCurrentUserName());
        dateField.setFieldValue(DateUtils.toDateTimeString(new Date()));
        generatedCheckBox.setChecked(true);
        Entity masterOrdersMaterialRequirement = masterOrdersMaterialRequirementForm.getEntity();
        List<Entity> masterOrdersMaterialRequirementProducts = masterOrdersMaterialRequirementHelper.generateMasterOrdersMaterialRequirementProducts(masterOrdersMaterialRequirement, masterOrders);
        masterOrdersMaterialRequirement.setField(MasterOrdersMaterialRequirementFields.MASTER_ORDERS_MATERIAL_REQUIREMENT_PRODUCTS, masterOrdersMaterialRequirementProducts);
        masterOrdersMaterialRequirement = masterOrdersMaterialRequirement.getDataDefinition().save(masterOrdersMaterialRequirement);
        masterOrdersMaterialRequirementForm.setEntity(masterOrdersMaterialRequirement);
        view.addMessage("masterOrders.masterOrdersMaterialRequirement.generate.success", ComponentState.MessageType.SUCCESS);
    } else {
        view.addMessage("masterOrders.masterOrdersMaterialRequirement.generate.failure", ComponentState.MessageType.FAILURE);
    }
}
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) Date(java.util.Date) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 84 with CheckBoxComponent

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

the class PalletMoveToStorageLocationHelperListeners method movePallets.

public void movePallets(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity helper = form.getPersistedEntityWithIncludedFormValues();
    CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference("generated");
    List<Entity> dtos = helper.getHasManyField(L_PALLET_STORAGE_STATE_DTOS);
    if (!validateRequiredFields(view, dtos)) {
        generated.setChecked(false);
        return;
    }
    DataDefinition resourceDD = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_RESOURCE);
    for (Entity dto : dtos) {
        final List<Entity> resources = resourceDD.find().createAlias(ResourceFields.PALLET_NUMBER, ResourceFields.PALLET_NUMBER, JoinType.INNER).createAlias(ResourceFields.LOCATION, ResourceFields.LOCATION, JoinType.INNER).createAlias(ResourceFields.STORAGE_LOCATION, ResourceFields.STORAGE_LOCATION, JoinType.LEFT).add(eq(ResourceFields.PALLET_NUMBER + ".number", dto.getStringField(PalletStorageStateDtoFields.PALLET_NUMBER))).add(eq(ResourceFields.LOCATION + ".number", dto.getStringField(PalletStorageStateDtoFields.LOCATION_NUMBER))).add(storageLocationCriterion(dto)).add(typeOfPalletCriterion(dto)).list().getEntities();
        Entity newStorageLocation = dto.getBelongsToField(L_NEW_STORAGE_LOCATION);
        String previousLocationNumber = dto.getStringField("storageLocationNumber");
        List<String> resourcesOnDifferentLocations = Lists.newArrayList();
        for (Entity resource : resources) {
            Entity oldStorageLocation = resource.getBelongsToField(ResourceFields.STORAGE_LOCATION);
            if (newStorageLocation != null && (oldStorageLocation == null || !oldStorageLocation.getId().equals(newStorageLocation.getId()))) {
                if (previousLocationNumber != null && oldStorageLocation != null && !oldStorageLocation.getStringField(StorageLocationFields.NUMBER).equals(previousLocationNumber)) {
                    resourcesOnDifferentLocations.add(resource.getStringField(ResourceFields.NUMBER));
                }
                resource.setField(ResourceFields.STORAGE_LOCATION, newStorageLocation);
                resource.setField(ResourceFields.VALIDATE_PALLET, false);
                resourceCorrectionService.createCorrectionForResource(resource, false);
            }
        }
        if (!resourcesOnDifferentLocations.isEmpty()) {
            view.addMessage("materialFlowResources.palletMoveToStorageLocation.info.resourcesInDifferentLocations", ComponentState.MessageType.INFO, false, resourcesOnDifferentLocations.stream().collect(Collectors.joining(", ")), dto.getStringField(L_PALLET_NUMBER), previousLocationNumber);
        }
    }
    view.addMessage("materialFlowResources.palletMoveToStorageLocation.success", ComponentState.MessageType.SUCCESS);
    generated.setChecked(true);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 85 with CheckBoxComponent

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

the class ParametersMFRListeners method addColumns.

public void addColumns(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference("generated");
    Set<Long> ids = grid.getSelectedEntitiesIds();
    if (ids.isEmpty()) {
        generated.setChecked(false);
        view.addMessage("materialFlowResources.documentAttributePosition.noSelectedAttributes", ComponentState.MessageType.INFO);
        return;
    }
    ids.forEach(attrId -> {
        Entity attribute = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.ATTRIBUTE).get(attrId);
        Entity positionItem = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_DOCUMENT_POSITION_PARAMETERS_ITEM).create();
        positionItem.setField(DocumentPositionParametersItemFields.NAME, attribute.getStringField(AttributeFields.NUMBER));
        positionItem.setField(DocumentPositionParametersItemFields.CHECKED, true);
        positionItem.setField(DocumentPositionParametersItemFields.EDITABLE, true);
        positionItem.setField(DocumentPositionParametersItemFields.PARAMETERS, parameterService.getParameter().getBelongsToField(ParameterFieldsMFR.DOCUMENT_POSITION_PARAMETERS).getId());
        positionItem.setField(DocumentPositionParametersItemFields.FOR_ATTRIBUTE, true);
        positionItem.setField(DocumentPositionParametersItemFields.ATTRIBUTE, attribute.getId());
        positionItem = positionItem.getDataDefinition().save(positionItem);
    });
    generated.setChecked(true);
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Aggregations

CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)100 FormComponent (com.qcadoo.view.api.components.FormComponent)38 Entity (com.qcadoo.model.api.Entity)33 FieldComponent (com.qcadoo.view.api.components.FieldComponent)30 GridComponent (com.qcadoo.view.api.components.GridComponent)19 LookupComponent (com.qcadoo.view.api.components.LookupComponent)11 Date (java.util.Date)7 JSONObject (org.json.JSONObject)7 BigDecimal (java.math.BigDecimal)6 ComponentState (com.qcadoo.view.api.ComponentState)4 WindowComponent (com.qcadoo.view.api.components.WindowComponent)4 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)4 IOException (java.io.IOException)4 MaterialFlowResourcesConstants (com.qcadoo.mes.materialFlowResources.constants.MaterialFlowResourcesConstants)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)2 SearchRestrictions (com.qcadoo.model.api.search.SearchRestrictions)2 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)2 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)2 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)2