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);
}
}
}
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);
}
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);
}
}
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);
}
}
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);
}
Aggregations