Search in sources :

Example 96 with GridComponent

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

the class DocumentDetailsListeners method showProductAttributesFromPositionLists.

public void showProductAttributesFromPositionLists(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent positionGird = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    Set<Long> ids = positionGird.getSelectedEntitiesIds();
    if (ids.size() == 1) {
        Entity position = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_POSITION).get(ids.stream().findFirst().get());
        Map<String, Object> parameters = Maps.newHashMap();
        parameters.put("form.id", position.getBelongsToField(PositionFields.PRODUCT).getId());
        view.redirectTo("/page/materialFlowResources/productAttributesForPositionList.html", false, true, parameters);
    } else {
        view.addMessage("materialFlow.info.document.showProductAttributes.toManyPositionsSelected", MessageType.INFO);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) JSONObject(org.json.JSONObject)

Example 97 with GridComponent

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

the class DocumentsListListeners method createResourcesForDocuments.

public void createResourcesForDocuments(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    DataDefinition documentDD = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_DOCUMENT);
    GridComponent gridComponent = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    List<Entity> documentsFromDB = Lists.newArrayList();
    boolean allAccepted = getDocumentsToAccept(documentDD, gridComponent, documentsFromDB);
    if (!allAccepted) {
        gridComponent.addMessage("materialFlow.info.document.acceptInfo", ComponentState.MessageType.INFO);
    }
    if (!documentsFromDB.isEmpty()) {
        documentService.setAcceptationInProgress(documentsFromDB, true);
        try {
            createResourcesForDocuments(view, gridComponent, documentDD, documentsFromDB);
        } catch (Exception e) {
            gridComponent.addMessage("materialFlow.error.document.acceptError", ComponentState.MessageType.FAILURE);
            LOG.error("Error in createResourcesForDocuments ", e);
            throw new IllegalStateException(e.getMessage(), e);
        } finally {
            documentService.setAcceptationInProgress(documentsFromDB, false);
        }
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 98 with GridComponent

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

the class ResourcesListHooks method applyFilters.

public void applyFilters(ViewDefinitionState view) {
    boolean isShortFilter = ((CheckBoxComponent) view.getComponentByReference(ResourceDtoFields.IS_SHORT_FILTER)).isChecked();
    boolean isDeadlineFilter = ((CheckBoxComponent) view.getComponentByReference(ResourceDtoFields.IS_DEADLINE_FILTER)).isChecked();
    GridComponent resourcesGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    Integer shortExpiryDate = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_DOCUMENT_POSITION_PARAMETERS).find().setMaxResults(1).uniqueResult().getIntegerField(DocumentPositionParametersFields.SHORT_EXPIRY_DATE);
    if (isShortFilter) {
        if (shortExpiryDate == null) {
            resourcesGrid.addMessage("materialFlowResources.resource.missing.parameter.shortExpiryDate.error", ComponentState.MessageType.FAILURE);
        } else {
            resourcesGrid.setCustomRestriction(searchBuilder -> searchBuilder.add(SearchRestrictions.and(SearchRestrictions.ge(ResourceDtoFields.EXPIRATION_DATE, DateTime.now().withTimeAtStartOfDay().toDate()), SearchRestrictions.le(ResourceDtoFields.EXPIRATION_DATE, DateTime.now().withTimeAtStartOfDay().plusDays(shortExpiryDate).toDate()))));
        }
    } else if (isDeadlineFilter) {
        resourcesGrid.setCustomRestriction(searchBuilder -> searchBuilder.add(SearchRestrictions.lt(ResourceDtoFields.EXPIRATION_DATE, DateTime.now().withTimeAtStartOfDay().toDate())));
    }
}
Also used : DocumentPositionParametersFields(com.qcadoo.mes.materialFlowResources.constants.DocumentPositionParametersFields) DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) SearchRestrictions(com.qcadoo.model.api.search.SearchRestrictions) DateTime(org.joda.time.DateTime) ComponentState(com.qcadoo.view.api.ComponentState) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent) QcadooViewConstants(com.qcadoo.view.constants.QcadooViewConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) GridComponent(com.qcadoo.view.api.components.GridComponent) MaterialFlowResourcesConstants(com.qcadoo.mes.materialFlowResources.constants.MaterialFlowResourcesConstants) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) Service(org.springframework.stereotype.Service) ResourceDtoFields(com.qcadoo.mes.materialFlowResources.constants.ResourceDtoFields) GridComponent(com.qcadoo.view.api.components.GridComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 99 with GridComponent

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

the class PalletStorageStateListHooks method applyFilters.

public void applyFilters(ViewDefinitionState view) {
    boolean isShiftFilter = ((CheckBoxComponent) view.getComponentByReference(PalletStorageStateDtoFields.IS_SHIFT_FILTER)).isChecked();
    boolean isFreeFilter = ((CheckBoxComponent) view.getComponentByReference(PalletStorageStateDtoFields.IS_FREE_FILTER)).isChecked();
    GridComponent palletGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    Integer palletToShift = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_DOCUMENT_POSITION_PARAMETERS).find().setMaxResults(1).uniqueResult().getIntegerField(DocumentPositionParametersItemValues.PALLET_TO_SHIFT);
    Integer palletWithFreePlace = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_DOCUMENT_POSITION_PARAMETERS).find().setMaxResults(1).uniqueResult().getIntegerField(DocumentPositionParametersItemValues.PALLET_WITH_FREE_PALECE);
    if (isShiftFilter) {
        if (palletToShift == null) {
            palletGrid.addMessage("materialFlowResources.pallet.missing.parameter.palletToShift.error", ComponentState.MessageType.FAILURE);
        } else {
            palletGrid.setCustomRestriction(searchBuilder -> searchBuilder.add(SearchRestrictions.lt(PalletStorageStateDtoFields.TOTAL_QUANTITY, BigDecimal.valueOf(palletToShift))));
        }
    } else if (isFreeFilter) {
        if (palletWithFreePlace == null) {
            palletGrid.addMessage("materialFlowResources.pallet.missing.parameter.palletWithFreeSpace.error", ComponentState.MessageType.FAILURE);
        } else {
            palletGrid.setCustomRestriction(searchBuilder -> searchBuilder.add(SearchRestrictions.lt(PalletStorageStateDtoFields.TOTAL_QUANTITY, BigDecimal.valueOf(palletWithFreePlace))));
        }
    }
}
Also used : DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) SearchRestrictions(com.qcadoo.model.api.search.SearchRestrictions) ComponentState(com.qcadoo.view.api.ComponentState) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent) QcadooViewConstants(com.qcadoo.view.constants.QcadooViewConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) DocumentPositionParametersItemValues(com.qcadoo.mes.materialFlowResources.constants.DocumentPositionParametersItemValues) GridComponent(com.qcadoo.view.api.components.GridComponent) MaterialFlowResourcesConstants(com.qcadoo.mes.materialFlowResources.constants.MaterialFlowResourcesConstants) BigDecimal(java.math.BigDecimal) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) Service(org.springframework.stereotype.Service) PalletStorageStateDtoFields(com.qcadoo.mes.materialFlowResources.constants.PalletStorageStateDtoFields) GridComponent(com.qcadoo.view.api.components.GridComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 100 with GridComponent

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

the class StocktakingDetailsHooks method disableForm.

private void disableForm(final ViewDefinitionState view, final FormComponent form, final Entity stocktaking) {
    if (stocktaking.getBooleanField(StocktakingFields.GENERATED)) {
        form.setFormEnabled(false);
        GridComponent storageLocations = (GridComponent) view.getComponentByReference(StocktakingFields.STORAGE_LOCATIONS);
        storageLocations.setEnabled(false);
    } else {
        form.setFormEnabled(true);
        changeStorageLocationsGridEnabled(view);
    }
}
Also used : GridComponent(com.qcadoo.view.api.components.GridComponent)

Aggregations

GridComponent (com.qcadoo.view.api.components.GridComponent)260 Entity (com.qcadoo.model.api.Entity)131 FormComponent (com.qcadoo.view.api.components.FormComponent)85 FieldComponent (com.qcadoo.view.api.components.FieldComponent)33 WindowComponent (com.qcadoo.view.api.components.WindowComponent)30 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)29 JSONObject (org.json.JSONObject)28 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)26 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)24 ComponentState (com.qcadoo.view.api.ComponentState)23 DataDefinition (com.qcadoo.model.api.DataDefinition)22 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)22 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)20 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)19 Autowired (org.springframework.beans.factory.annotation.Autowired)19 BigDecimal (java.math.BigDecimal)16 Service (org.springframework.stereotype.Service)16 LookupComponent (com.qcadoo.view.api.components.LookupComponent)15 Collectors (java.util.stream.Collectors)15 Lists (com.google.common.collect.Lists)12