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);
}
}
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);
}
}
}
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())));
}
}
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))));
}
}
}
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);
}
}
Aggregations