Search in sources :

Example 96 with FilterValueHolder

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

the class WorkPlanDetailsHooks method setCriteriaModifierParameters.

private void setCriteriaModifierParameters(final ViewDefinitionState view) {
    // set technologies id
    FormComponent workPlanForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (workPlanForm.getEntityId() == null) {
        return;
    }
    List<Long> technologyIDs = Lists.newArrayList();
    List<Entity> orders = workPlanForm.getPersistedEntityWithIncludedFormValues().getManyToManyField(WorkPlanFields.ORDERS);
    if (orders.isEmpty()) {
        return;
    }
    for (Entity order : orders) {
        if (order.isActive() && order.getBelongsToField(OrderFields.TECHNOLOGY_PROTOTYPE) != null) {
            technologyIDs.add(order.getBelongsToField(OrderFields.TECHNOLOGY_PROTOTYPE).getId());
        }
    }
    GridComponent atachmentsGrid = (GridComponent) view.getComponentByReference(L_ATTCHMENT_GRID);
    FilterValueHolder atachmentsGridHolder = atachmentsGrid.getFilterValue();
    atachmentsGridHolder.put(WorkPlansCriteriaModifiers.TECHNOLOGY_IDS, technologyIDs);
    atachmentsGrid.setFilterValue(atachmentsGridHolder);
}
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)

Example 97 with FilterValueHolder

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

the class SalesPlanFillTechnologyHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) throws JSONException {
    String productFamilyId = view.getJsonContext().get("window.mainTab.salesPlanProduct.gridLayout.productFamilyId").toString();
    Entity productFamily = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_PRODUCT).get(Long.parseLong(productFamilyId));
    FieldComponent productFamilyField = (FieldComponent) view.getComponentByReference("productFamily");
    productFamilyField.setFieldValue(productFamily.getStringField(ProductFields.NUMBER));
    LookupComponent technologyLookup = (LookupComponent) view.getComponentByReference(SalesPlanProductFields.TECHNOLOGY);
    FilterValueHolder technologyFilterValueHolder = technologyLookup.getFilterValue();
    technologyFilterValueHolder.put(TechnologyCriteriaModifiersO.PRODUCT_PARAMETER, productFamily.getId());
    technologyLookup.setFilterValue(technologyFilterValueHolder);
    technologyLookup.setRequired(true);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 98 with FilterValueHolder

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

the class SalesPlanProductDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    List<String> referenceNames = Lists.newArrayList(L_PLANNED_QUANTITY_UNIT, L_ORDERED_QUANTITY_UNIT, ORDERED_TO_WAREHOUSE_UNIT, L_SURPLUS_FROM_PLAN_UNIT);
    LookupComponent productLookup = (LookupComponent) view.getComponentByReference(SalesPlanProductFields.PRODUCT);
    FilterValueHolder filterValueHolder = productLookup.getFilterValue();
    Entity product = productLookup.getEntity();
    String unit = "";
    if (product != null) {
        unit = product.getStringField(ProductFields.UNIT);
        LookupComponent technologyLookup = (LookupComponent) view.getComponentByReference(SalesPlanProductFields.TECHNOLOGY);
        FilterValueHolder technologyFilterValueHolder = technologyLookup.getFilterValue();
        technologyFilterValueHolder.put(TechnologyCriteriaModifiersO.PRODUCT_PARAMETER, product.getId());
        technologyLookup.setFilterValue(technologyFilterValueHolder);
    }
    for (String referenceName : referenceNames) {
        FieldComponent field = (FieldComponent) view.getComponentByReference(referenceName);
        field.setFieldValue(unit);
        field.requestComponentUpdateState();
    }
    Entity salesPlanProduct = ((FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM)).getEntity();
    Long salesPlanId = salesPlanProduct.getBelongsToField(SalesPlanProductFields.SALES_PLAN).getId();
    filterValueHolder.put(ProductCriteriaModifiersMO.L_SALES_PLAN_ID, salesPlanId);
    Entity productFromDb = salesPlanProduct.getBelongsToField(SalesPlanProductFields.PRODUCT);
    if (productFromDb != null) {
        filterValueHolder.put(ProductCriteriaModifiersMO.L_PRODUCT_ID, productFromDb.getId());
    }
    productLookup.setFilterValue(filterValueHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) FormComponent(com.qcadoo.view.api.components.FormComponent) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 99 with FilterValueHolder

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

the class WarehouseStockReportDetailsHooks method setCriteriaModifierParameters.

private void setCriteriaModifierParameters(final ViewDefinitionState view, final Entity warehouseStockReport) {
    LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference("storageLocationLookup");
    Entity location = warehouseStockReport.getBelongsToField(WarehouseStockReportFields.LOCATION);
    FilterValueHolder filterValueHolder = storageLocationLookup.getFilterValue();
    if (location != null) {
        filterValueHolder.put(WarehouseStockReportFields.LOCATION, location.getId());
    } else {
        filterValueHolder.put(WarehouseStockReportFields.LOCATION, 0L);
    }
    storageLocationLookup.setFilterValue(filterValueHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 100 with FilterValueHolder

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

the class ProductsToIssueCriteriaModifier method restrictToUserLocations.

public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) {
    Long currentUserId = securityService.getCurrentUserId();
    if (Objects.nonNull(currentUserId)) {
        EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS);
        if (!userLocations.isEmpty()) {
            Set<Integer> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)).mapToInt(e -> e.getId().intValue()).boxed().collect(Collectors.toSet());
            scb.add(SearchRestrictions.or(SearchRestrictions.in(LOCATION_TO_ID, locationIds), SearchRestrictions.in(LOCATION_FROM_ID, locationIds)));
        }
    }
}
Also used : DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) SearchRestrictions(com.qcadoo.model.api.search.SearchRestrictions) QcadooSecurityConstants(com.qcadoo.security.constants.QcadooSecurityConstants) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) DataDefinition(com.qcadoo.model.api.DataDefinition) EntityList(com.qcadoo.model.api.EntityList) Objects(java.util.Objects) FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) UserFieldsMF(com.qcadoo.mes.materialFlow.constants.UserFieldsMF) UserLocationFields(com.qcadoo.mes.materialFlow.constants.UserLocationFields) Service(org.springframework.stereotype.Service) SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) SecurityService(com.qcadoo.security.api.SecurityService) EntityList(com.qcadoo.model.api.EntityList)

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