Search in sources :

Example 31 with FilterValueHolder

use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.

the class AddActionsForPlannedEventHooks method setCriteriaModifiers.

private void setCriteriaModifiers(final ViewDefinitionState view) throws JSONException {
    Long plannedEventId = Long.valueOf(view.getJsonContext().get("window.mainTab.plannedEvent").toString());
    if (plannedEventId != null) {
        Entity event = getPlannedEventDD().get(plannedEventId);
        Entity workstation = event.getBelongsToField(PlannedEventFields.WORKSTATION);
        Entity subassembly = event.getBelongsToField(PlannedEventFields.SUBASSEMBLY);
        if (workstation != null) {
            GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
            FilterValueHolder filter = grid.getFilterValue();
            filter.put(PlannedEventFields.WORKSTATION, workstation.getId());
            if (subassembly != null) {
                Entity workstationType = subassembly.getBelongsToField(SubassemblyFields.WORKSTATION_TYPE);
                filter.put(PlannedEventFields.SUBASSEMBLY, subassembly.getId());
                filter.put(WorkstationFields.WORKSTATION_TYPE, workstationType.getId());
            } else {
                Entity workstationType = workstation.getBelongsToField(WorkstationFields.WORKSTATION_TYPE);
                filter.put(WorkstationFields.WORKSTATION_TYPE, workstationType.getId());
            }
            grid.setFilterValue(filter);
        }
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 32 with FilterValueHolder

use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.

the class EventHooks method setUpFaultTypeLookup.

private void setUpFaultTypeLookup(final ViewDefinitionState view) {
    FormComponent formComponent = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    LookupComponent faultTypeLookup = (LookupComponent) view.getComponentByReference(MaintenanceEventFields.FAULT_TYPE);
    Entity event = formComponent.getPersistedEntityWithIncludedFormValues();
    Entity workstation = event.getBelongsToField(MaintenanceEventFields.WORKSTATION);
    Entity subassembly = event.getBelongsToField(MaintenanceEventFields.SUBASSEMBLY);
    FilterValueHolder filter = faultTypeLookup.getFilterValue();
    if (workstation == null) {
        filter.remove(MaintenanceEventFields.WORKSTATION);
        filter.remove(WorkstationFields.WORKSTATION_TYPE);
        filter.remove(MaintenanceEventFields.SUBASSEMBLY);
    } else {
        filter.put(MaintenanceEventFields.WORKSTATION, workstation.getId());
        if (subassembly == null) {
            filter.remove(MaintenanceEventFields.SUBASSEMBLY);
            Entity workstationType = workstation.getBelongsToField(WorkstationFields.WORKSTATION_TYPE);
            filter.put(WorkstationFields.WORKSTATION_TYPE, workstationType.getId());
        } else {
            Entity workstationType = subassembly.getBelongsToField(SubassemblyFields.WORKSTATION_TYPE);
            filter.put(MaintenanceEventFields.SUBASSEMBLY, subassembly.getId());
            filter.put(WorkstationFields.WORKSTATION_TYPE, workstationType.getId());
        }
    }
    faultTypeLookup.setFilterValue(filter);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 33 with FilterValueHolder

use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.

the class EventHooks method setEventCriteriaModifier.

private void setEventCriteriaModifier(ViewDefinitionState view, Entity event, String fieldFrom, String fieldTo) {
    LookupComponent lookupComponent = (LookupComponent) view.getComponentByReference(fieldTo);
    Entity value = event.getBelongsToField(fieldFrom);
    if (value != null) {
        FilterValueHolder holder = lookupComponent.getFilterValue();
        holder.put(fieldFrom, value.getId());
        lookupComponent.setFilterValue(holder);
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 34 with FilterValueHolder

use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.

the class EventListeners method clearFilterForFaultType.

private void clearFilterForFaultType(final ViewDefinitionState view, final String field) {
    LookupComponent faultType = (LookupComponent) view.getComponentByReference(MaintenanceEventFields.FAULT_TYPE);
    if (faultType != null) {
        FilterValueHolder filter = faultType.getFilterValue();
        if (filter.has(field)) {
            filter.remove(field);
            filter.remove(WorkstationFields.WORKSTATION_TYPE);
        }
        faultType.setFilterValue(filter);
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 35 with FilterValueHolder

use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.

the class TechnologyInstOperProductInCompDetailsHooks method setCriteriaModifiersParameters.

public void setCriteriaModifiersParameters(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity technologyInstOperProductInComp = form.getEntity();
    Entity product = technologyInstOperProductInComp.getBelongsToField(TechnologyInstOperProductInCompFields.PRODUCT);
    Entity order = technologyInstOperProductInComp.getBelongsToField(TechnologyInstOperProductInCompFields.ORDER);
    GridComponent positions = (GridComponent) view.getComponentByReference("positions");
    FilterValueHolder filterValueHolder = positions.getFilterValue();
    filterValueHolder.put(PRODUCT_NUMBER, product.getStringField(ProductFields.NUMBER));
    filterValueHolder.put(ORDER_ID, order.getId().intValue());
    positions.setFilterValue(filterValueHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Aggregations

FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)119 LookupComponent (com.qcadoo.view.api.components.LookupComponent)69 Entity (com.qcadoo.model.api.Entity)64 FormComponent (com.qcadoo.view.api.components.FormComponent)45 GridComponent (com.qcadoo.view.api.components.GridComponent)26 FieldComponent (com.qcadoo.view.api.components.FieldComponent)13 Collectors (java.util.stream.Collectors)11 Autowired (org.springframework.beans.factory.annotation.Autowired)11 Service (org.springframework.stereotype.Service)11 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)10 SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)10 SearchRestrictions (com.qcadoo.model.api.search.SearchRestrictions)10 Objects (java.util.Objects)10 DataDefinition (com.qcadoo.model.api.DataDefinition)9 JSONObject (org.json.JSONObject)9 UserFieldsMF (com.qcadoo.mes.materialFlow.constants.UserFieldsMF)8 UserLocationFields (com.qcadoo.mes.materialFlow.constants.UserLocationFields)8 EntityList (com.qcadoo.model.api.EntityList)8 SecurityService (com.qcadoo.security.api.SecurityService)8 QcadooSecurityConstants (com.qcadoo.security.constants.QcadooSecurityConstants)8