use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class DivisionDetailsListenersPL method onRemoveSelectedEntity.
public void onRemoveSelectedEntity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent workstationsGrid = (GridComponent) view.getComponentByReference("workstations");
List<Entity> workstationsToDelete = workstationsGrid.getSelectedEntities();
for (Entity workstation : workstationsToDelete) {
workstation.setField(WorkstationFieldsPL.PRODUCTION_LINE, null);
workstation.setField(WorkstationFields.DIVISION, null);
workstation.getDataDefinition().save(workstation);
}
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class OrderTimePredictionHooks method setCriteriaModifierParameters.
private void setCriteriaModifierParameters(ViewDefinitionState view) {
LookupComponent techComponent = (LookupComponent) view.getComponentByReference("technology");
Entity tech = techComponent.getEntity();
GridComponent grid = (GridComponent) view.getComponentByReference("operCompTimeCalculationsGrid");
FilterValueHolder holder = grid.getFilterValue();
if (Objects.nonNull(tech)) {
holder.put(OperCompTimeCalculationsCM.TECHNOLOGY_PARAMETER, tech.getId());
grid.setFilterValue(holder);
} else {
if (holder.has(OperCompTimeCalculationsCM.TECHNOLOGY_PARAMETER)) {
holder.remove(OperCompTimeCalculationsCM.TECHNOLOGY_PARAMETER);
grid.setFilterValue(holder);
}
}
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class ProductionLineScheduleDetailsListenersPS method generatePlan.
@Transactional
public void generatePlan(final ViewDefinitionState view, final ComponentState state, final String[] args) {
List<Entity> productionLines = dataDefinitionService.get(ProductionLinesConstants.PLUGIN_IDENTIFIER, ProductionLinesConstants.MODEL_PRODUCTION_LINE).find().add(SearchRestrictions.eq(ProductionLineFields.PRODUCTION, true)).list().getEntities();
if (productionLines.isEmpty()) {
view.addMessage("orders.error.productionLineScheduleNoProductionLines", ComponentState.MessageType.SUCCESS);
return;
}
FormComponent formComponent = (FormComponent) state;
GridComponent ordersGrid = (GridComponent) view.getComponentByReference(ProductionLineScheduleFields.ORDERS);
Entity schedule = getOrders(ordersGrid.getEntities(), formComponent.getEntity());
formComponent.setEntity(schedule);
assignOrdersToProductionLines(schedule, productionLines);
view.addMessage("orders.info.productionLineSchedulePositionsGenerated", ComponentState.MessageType.SUCCESS);
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class ScheduleDetailsListenersPS method getOperations.
@Transactional
public void getOperations(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent ordersGrid = (GridComponent) view.getComponentByReference(ScheduleFields.ORDERS);
List<Entity> orders = ordersGrid.getEntities();
FormComponent formComponent = (FormComponent) state;
Entity schedule = formComponent.getEntity();
boolean includeTpz = schedule.getBooleanField(ScheduleFields.INCLUDE_TPZ);
DataDefinition schedulePositionDD = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_SCHEDULE_POSITION);
List<Entity> positions = Lists.newArrayList();
for (Entity order : orders) {
Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);
if (technology == null) {
continue;
}
final Map<Long, BigDecimal> operationRuns = Maps.newHashMap();
OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer = productQuantitiesService.getProductComponentQuantities(technology, order.getDecimalField(OrderFields.PLANNED_QUANTITY), operationRuns);
List<Entity> operationComponents = technology.getHasManyField(TechnologyFields.OPERATION_COMPONENTS);
for (Entity operationComponent : operationComponents) {
BigDecimal operationComponentRuns = BigDecimalUtils.convertNullToZero(operationRuns.get(operationComponent.getId()));
BigDecimal staffFactor = getStaffFactor(operationComponent);
OperationWorkTime operationWorkTime = operationWorkTimeService.estimateTechOperationWorkTime(operationComponent, operationComponentRuns, includeTpz, false, false, staffFactor);
Entity schedulePosition = createSchedulePosition(schedule, schedulePositionDD, order, operationComponent, operationWorkTime, operationProductComponentWithQuantityContainer, operationComponentRuns);
positions.add(schedulePosition);
}
}
schedule.setField(ScheduleFields.POSITIONS, positions);
schedule = schedule.getDataDefinition().save(schedule);
formComponent.setEntity(schedule);
view.addMessage("productionScheduling.info.schedulePositionsGenerated", ComponentState.MessageType.SUCCESS);
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class NegotiationDetailsHooks method changeFieldsEnabled.
private void changeFieldsEnabled(final ViewDefinitionState view, final boolean enabledForm, final boolean enabledGrid) {
FormComponent negotiationForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
GridComponent negotiationProducts = (GridComponent) view.getComponentByReference(NEGOTIATION_PRODUCTS);
negotiationForm.setFormEnabled(enabledForm);
negotiationProducts.setEnabled(enabledGrid);
negotiationProducts.setEditable(enabledGrid);
}
Aggregations