use of com.qcadoo.view.api.components.FormComponent 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.FormComponent 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.FormComponent in project mes by qcadoo.
the class StateChangeViewClientUtil method isFormEntityValid.
public boolean isFormEntityValid(final ViewContextHolder viewContext) {
final FormComponent formComponent = (FormComponent) viewContext.getInvoker();
final Entity entity = formComponent.getEntity();
formComponent.setEntity(entity.getDataDefinition().save(entity));
return formComponent.isValid();
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class AllStoppagesListeners method addNewFromProductionTracking.
public void addNewFromProductionTracking(final ViewDefinitionState view, final ComponentState state, final String[] args) throws JSONException {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity productionTracking = form.getEntity();
Map<String, Object> parameters = Maps.newHashMap();
parameters.put("form.productionTracking", productionTracking.getId());
parameters.put("form.order", productionTracking.getBelongsToField(L_ORDER).getId());
view.openModal("../page/stoppage/allStoppagesForm.html", parameters);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class RequestForQuotationDetailsListeners method showOffersForGivenRequestForQuotation.
public final void showOffersForGivenRequestForQuotation(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent requestForQuotationForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Long requestForQuotationId = requestForQuotationForm.getEntityId();
if (requestForQuotationId == null) {
return;
}
Entity requestForQuotation = requestForQuotationForm.getEntity();
String requestForQuotationNumber = requestForQuotation.getStringField(NUMBER);
if (requestForQuotationNumber == null) {
return;
}
Map<String, String> filters = Maps.newHashMap();
filters.put("requestForQuotationNumber", requestForQuotationNumber);
Map<String, Object> gridOptions = Maps.newHashMap();
gridOptions.put(L_FILTERS, filters);
Map<String, Object> parameters = Maps.newHashMap();
parameters.put(L_GRID_OPTIONS, gridOptions);
parameters.put(L_WINDOW_ACTIVE_MENU, "requirements.offer");
String url = "../page/supplyNegotiations/offersList.html";
view.redirectTo(url, false, true, parameters);
}
Aggregations