use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class ModelCardProductDetailsListeners method fillDefaultTechnology.
public void fillDefaultTechnology(final ViewDefinitionState view, final ComponentState state, final String[] args) {
LookupComponent productLookup = (LookupComponent) view.getComponentByReference(ModelCardProductFields.PRODUCT);
Entity product = productLookup.getEntity();
LookupComponent technologyLookup = (LookupComponent) view.getComponentByReference(ModelCardProductFields.TECHNOLOGY);
if (product != null) {
Entity defaultTechnology = technologyServiceO.getDefaultTechnology(product);
if (defaultTechnology != null) {
technologyLookup.setFieldValue(defaultTechnology.getId());
} else {
Entity productFamily = product.getBelongsToField(ProductFields.PARENT);
if (productFamily != null) {
defaultTechnology = technologyServiceO.getDefaultTechnology(productFamily);
if (defaultTechnology != null) {
technologyLookup.setFieldValue(defaultTechnology.getId());
} else {
technologyLookup.setFieldValue(null);
}
} else {
technologyLookup.setFieldValue(null);
}
}
} else {
technologyLookup.setFieldValue(null);
}
technologyLookup.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class ProductsIntermediateInDetailsHooks method onProductionFlowComponentChange.
public void onProductionFlowComponentChange(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
LookupComponent productsFlowLocationLookup = (LookupComponent) view.getComponentByReference(TechnologyFieldsPFTD.PRODUCTS_FLOW_LOCATION);
productsFlowLocationLookup.setFieldValue(null);
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class UseReplacementHooks method fillFields.
private void fillFields(ViewDefinitionState view) {
if (view.isViewAfterRedirect()) {
JSONObject context = view.getJsonContext();
LookupComponent basicProductComponent = (LookupComponent) view.getComponentByReference(BASIC_PRODUCT);
LookupComponent productComponent = (LookupComponent) view.getComponentByReference(PRODUCT);
if (context.has(L_WINDOW_MAIN_TAB_FORM_BASIC_PRODUCT)) {
try {
basicProductComponent.setFieldValue(context.getLong(L_WINDOW_MAIN_TAB_FORM_BASIC_PRODUCT));
FilterValueHolder filterValueHolder = productComponent.getFilterValue();
filterValueHolder.put("BASIC_PRODUCT_ID", context.getLong(L_WINDOW_MAIN_TAB_FORM_BASIC_PRODUCT));
productComponent.setFilterValue(filterValueHolder);
} catch (JSONException ex) {
throw new RuntimeException(ex);
}
}
}
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class UsedBatchDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity usedBatch = form.getEntity();
Entity trackingOperationProductInComponent = usedBatch.getBelongsToField(UsedBatchFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENT);
if (view.isViewAfterRedirect() && Objects.nonNull(trackingOperationProductInComponent)) {
Entity product = trackingOperationProductInComponent.getBelongsToField(TrackingOperationProductInComponentFields.PRODUCT);
FieldComponent unitField = (FieldComponent) view.getComponentByReference(L_UNIT);
unitField.setFieldValue(product.getStringField(ProductFields.UNIT));
unitField.requestComponentUpdateState();
LookupComponent batchLookup = (LookupComponent) view.getComponentByReference(UsedBatchFields.BATCH);
FilterValueHolder batchFilterValueHolder = batchLookup.getFilterValue();
batchFilterValueHolder.put(L_PRODUCT_ID, product.getId());
batchLookup.setFilterValue(batchFilterValueHolder);
}
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class TrackingOperationProductOutComponentDetailsHooks method fillStorageLocation.
private void fillStorageLocation(final ViewDefinitionState view) {
FormComponent trackingOperationProductOutComponentForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity trackingOperationProductOutComponent = trackingOperationProductOutComponentForm.getEntity();
if (view.isViewAfterRedirect()) {
LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference(L_STORAGE_LOCATION);
Entity productionTracking = trackingOperationProductOutComponent.getBelongsToField(TrackingOperationProductOutComponentFields.PRODUCTION_TRACKING);
Entity order = productionTracking.getBelongsToField(ProductionTrackingFields.ORDER);
Entity product = trackingOperationProductOutComponent.getBelongsToField(TrackingOperationProductOutComponentFields.PRODUCT);
FilterValueHolder storageLocationFilterValueHolder = storageLocationLookup.getFilterValue();
Entity bpcq = basicProductionCountingService.getProductionCountingQuantityDD().find().add(SearchRestrictions.eq(ProductionCountingQuantityFields.ORDER + L_ID, order.getId())).add(SearchRestrictions.eq(ProductionCountingQuantityFields.ROLE, ProductionCountingQuantityRole.PRODUCED.getStringValue())).add(SearchRestrictions.eq(ProductionCountingQuantityFields.PRODUCT + L_ID, product.getId())).setMaxResults(1).uniqueResult();
if (ProductionCountingQuantityTypeOfMaterial.FINAL_PRODUCT.getStringValue().equals(bpcq.getStringField(ProductionCountingQuantityFields.TYPE_OF_MATERIAL))) {
if (Objects.nonNull(bpcq.getBelongsToField(ProductionCountingQuantityFields.PRODUCTS_INPUT_LOCATION))) {
storageLocationFilterValueHolder.put(L_LOCATION_ID, bpcq.getBelongsToField(ProductionCountingQuantityFields.PRODUCTS_INPUT_LOCATION).getId());
storageLocationFilterValueHolder.put(L_PRODUCT_ID, order.getBelongsToField(OrderFields.PRODUCT).getId());
Optional<Entity> option = findStorageLocationForProduct(order.getBelongsToField(OrderFields.PRODUCT), bpcq.getBelongsToField(ProductionCountingQuantityFields.PRODUCTS_INPUT_LOCATION));
if (option.isPresent()) {
if (Objects.isNull(storageLocationLookup.getEntity())) {
storageLocationLookup.setFieldValue(option.get().getId());
storageLocationLookup.requestComponentUpdateState();
}
storageLocationLookup.setEnabled(false);
}
} else if (storageLocationFilterValueHolder.has(L_LOCATION_ID)) {
storageLocationFilterValueHolder.remove(L_LOCATION_ID);
}
} else {
if (Objects.nonNull(bpcq.getBelongsToField(ProductionCountingQuantityFields.PRODUCTS_FLOW_LOCATION))) {
storageLocationFilterValueHolder.put(L_LOCATION_ID, bpcq.getBelongsToField(ProductionCountingQuantityFields.PRODUCTS_FLOW_LOCATION).getId());
storageLocationFilterValueHolder.put(L_PRODUCT_ID, bpcq.getBelongsToField(ProductionCountingQuantityFields.PRODUCT).getId());
Optional<Entity> option = findStorageLocationForProduct(bpcq.getBelongsToField(ProductionCountingQuantityFields.PRODUCT), bpcq.getBelongsToField(ProductionCountingQuantityFields.PRODUCTS_FLOW_LOCATION));
if (option.isPresent()) {
if (Objects.isNull(storageLocationLookup.getEntity())) {
storageLocationLookup.setFieldValue(option.get().getId());
storageLocationLookup.requestComponentUpdateState();
}
storageLocationLookup.setEnabled(false);
}
} else if (storageLocationFilterValueHolder.has(L_LOCATION_ID)) {
storageLocationFilterValueHolder.remove(L_LOCATION_ID);
}
}
storageLocationLookup.setFilterValue(storageLocationFilterValueHolder);
}
}
Aggregations