Search in sources :

Example 56 with FormComponent

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) FormComponent(com.qcadoo.view.api.components.FormComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) Transactional(org.springframework.transaction.annotation.Transactional)

Example 57 with FormComponent

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) FormComponent(com.qcadoo.view.api.components.FormComponent) OperationProductComponentWithQuantityContainer(com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer) OperationWorkTime(com.qcadoo.mes.operationTimeCalculations.OperationWorkTime) GridComponent(com.qcadoo.view.api.components.GridComponent) DataDefinition(com.qcadoo.model.api.DataDefinition) BigDecimal(java.math.BigDecimal) Transactional(org.springframework.transaction.annotation.Transactional)

Example 58 with FormComponent

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();
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity)

Example 59 with FormComponent

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);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity)

Example 60 with FormComponent

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);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity)

Aggregations

FormComponent (com.qcadoo.view.api.components.FormComponent)644 Entity (com.qcadoo.model.api.Entity)501 FieldComponent (com.qcadoo.view.api.components.FieldComponent)183 LookupComponent (com.qcadoo.view.api.components.LookupComponent)104 GridComponent (com.qcadoo.view.api.components.GridComponent)83 BigDecimal (java.math.BigDecimal)55 WindowComponent (com.qcadoo.view.api.components.WindowComponent)52 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)45 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)42 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)39 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)36 Date (java.util.Date)33 DataDefinition (com.qcadoo.model.api.DataDefinition)29 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)28 JSONObject (org.json.JSONObject)28 ComponentState (com.qcadoo.view.api.ComponentState)27 Transactional (org.springframework.transaction.annotation.Transactional)20 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)17 Optional (com.google.common.base.Optional)16 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)16