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