use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductDetailsListenersT method showTechnologiesWithProduct.
public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity product = productForm.getEntity();
if (product.getId() == null) {
return;
}
String productNumber = product.getStringField(NUMBER);
if (productNumber == null) {
return;
}
Map<String, String> filters = Maps.newHashMap();
filters.put("productNumber", applyInOperator(productNumber));
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, "technology.technologies");
String url = "../page/technologies/technologiesList.html";
view.redirectTo(url, false, true, parameters);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class GenerateTimeGapsListeners method generateTimeGaps.
public void generateTimeGaps(final ViewDefinitionState viewState, final ComponentState formState, final String[] args) throws ParseException {
FormComponent form = (FormComponent) formState;
Entity contextEntity = form.getPersistedEntityWithIncludedFormValues();
// We don't want to reuse contexts - in case of the user working with many browser tabs to compare a couple of results
contextEntity.setId(null);
contextEntity.setField(TimeGapsContextFields.TIME_GAPS, Collections.<Entity>emptyList());
// Call validation
contextEntity = contextEntity.getDataDefinition().save(contextEntity);
if (!contextEntity.isValid()) {
clearSummaryFields(contextEntity);
form.setEntity(contextEntity);
return;
}
// Generate & persist results
TimeGapsSearchResult searchResult = performGeneration(contextEntity);
Entity persistedContext = persistResults(contextEntity, searchResult);
if (persistedContext.isValid()) {
// Show 'time gaps' tab
WindowComponent window = (WindowComponent) findComponentByReferenceName(viewState, QcadooViewConstants.L_WINDOW);
window.setActiveTab("timeGaps");
}
form.setEntity(persistedContext);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class WarehouseMinimumStateListListener method createMultiMinimalStates.
@Transactional
public void createMultiMinimalStates(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity state = form.getPersistedEntityWithIncludedFormValues();
if (state.getBelongsToField(WarehouseMinimumStateFields.LOCATION) == null) {
LookupComponent location = (LookupComponent) view.getComponentByReference(WarehouseMinimumStateFields.LOCATION);
location.addMessage(new ErrorMessage(L_QCADOO_VIEW_VALIDATE_FIELD_ERROR_MISSING));
location.requestComponentUpdateState();
return;
}
if (state.getManyToManyField("products") == null || state.getManyToManyField("products").isEmpty()) {
view.addMessage(new ErrorMessage("warehouseMinimalState.warehouseMinimumStateAddMulti.error.productsEmpthy"));
return;
}
state.getManyToManyField("products").forEach(p -> createMinimalStateEntity(state, p));
componentState.addMessage("warehouseMinimalState.warehouseMinimumStateAddMulti.info.generated", ComponentState.MessageType.SUCCESS);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class TechOperCompWorkstationTimeDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
LookupComponent workstationLookup = (LookupComponent) view.getComponentByReference(TechOperCompWorkstationTimeFields.WORKSTATION);
Entity techOperCompWorkstationTime = form.getEntity();
Entity technologyOperationComponent = techOperCompWorkstationTime.getBelongsToField(TechOperCompWorkstationTimeFields.TECHNOLOGY_OPERATION_COMPONENT);
Entity workstation = techOperCompWorkstationTime.getBelongsToField(TechOperCompWorkstationTimeFields.WORKSTATION);
filterWorkstationLookup(workstationLookup, technologyOperationComponent, workstation);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class TechnologyOperationComponentDetailsHooks method checkOperationOutputQuantities.
public void checkOperationOutputQuantities(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (form.getEntityId() == null) {
return;
}
Entity operationComponent = form.getEntity();
operationComponent = operationComponent.getDataDefinition().get(operationComponent.getId());
BigDecimal timeNormsQuantity = operationComponent.getDecimalField("productionInOneCycle");
Entity productOutComponent = null;
try {
productOutComponent = technologyService.getMainOutputProductComponent(operationComponent);
} catch (IllegalStateException e) {
return;
}
BigDecimal currentQuantity = productOutComponent.getDecimalField("quantity");
if (timeNormsQuantity != null && timeNormsQuantity.compareTo(currentQuantity) != 0) {
form.addMessage("technologies.technologyOperationComponent.validate.error.invalidQuantity", MessageType.INFO, false, numberService.format(currentQuantity), productOutComponent.getBelongsToField("product").getStringField("unit"));
}
}
Aggregations