use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class SkillOperationDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity opSkill = form.getEntity();
FieldComponent maxSkillLevelField = (FieldComponent) view.getComponentByReference(MAX_LEVEL);
maxSkillLevelField.setFieldValue(opSkill.getBelongsToField(OperationSkillFields.SKILL).getIntegerField(SkillFields.MAXIMUM_LEVEL));
LookupComponent operationLookup = (LookupComponent) view.getComponentByReference(OperationSkillFields.OPERATION);
FilterValueHolder filterValueHolder = operationLookup.getFilterValue();
Long skillId = opSkill.getBelongsToField(StaffSkillsFields.SKILL).getId();
if (Objects.isNull(skillId)) {
filterValueHolder.remove(L_SKILL_ID);
} else {
filterValueHolder.put(L_SKILL_ID, skillId);
}
operationLookup.setFilterValue(filterValueHolder);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class TOCProcessListDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
Long operationId = ((FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM)).getPersistedEntityWithIncludedFormValues().getBelongsToField(TechnologyOperationComponentFields.OPERATION).getId();
LookupComponent technologicalProcessList = (LookupComponent) view.getComponentByReference(TechnologyOperationComponentFields.TECHNOLOGICAL_PROCESS_LIST);
FilterValueHolder filterValueHolder = technologicalProcessList.getFilterValue();
filterValueHolder.put(TechnologicalProcessListFields.OPERATION, operationId);
technologicalProcessList.setFilterValue(filterValueHolder);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class AddProcessesListeners method addProcesses.
public void addProcesses(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
GridComponent technologicalProcesses = (GridComponent) view.getComponentByReference(L_TECHNOLOGICAL_PROCESSES);
Set<Long> selectedEntities = technologicalProcesses.getSelectedEntitiesIds();
if (selectedEntities.isEmpty()) {
view.addMessage("technologies.addProcesses.noSelectedProcesses", ComponentState.MessageType.INFO);
return;
}
for (Long technologicalProcessId : selectedEntities) {
Entity technologicalProcess = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS).get(technologicalProcessId);
Entity technologicalProcessComponent = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS_COMPONENT).create();
technologicalProcessComponent.setField(TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS, technologicalProcess);
technologicalProcessComponent.setField(TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS_LIST, form.getEntityId());
technologicalProcessComponent.setField(TechnologicalProcessFields.TPZ, technologicalProcess.getField(TechnologicalProcessFields.TPZ));
technologicalProcessComponent.setField(TechnologicalProcessFields.TJ, technologicalProcess.getField(TechnologicalProcessFields.TJ));
technologicalProcessComponent.setField(TechnologicalProcessFields.ADDITIONAL_TIME, technologicalProcess.getField(TechnologicalProcessFields.ADDITIONAL_TIME));
technologicalProcessComponent.setField(TechnologicalProcessFields.EXTENDED_TIME_FOR_SIZE_GROUP, technologicalProcess.getField(TechnologicalProcessFields.EXTENDED_TIME_FOR_SIZE_GROUP));
technologicalProcessComponent.setField(TechnologicalProcessFields.INCREASE_PERCENT, technologicalProcess.getField(TechnologicalProcessFields.INCREASE_PERCENT));
technologicalProcessComponent.setField(TechnologicalProcessFields.SIZE_GROUP, technologicalProcess.getField(TechnologicalProcessFields.SIZE_GROUP));
technologicalProcessComponent.getDataDefinition().save(technologicalProcessComponent);
}
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class TOCDetailsListeners method addUpTheNumberOfWorkstations.
public void addUpTheNumberOfWorkstations(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
int size = form.getPersistedEntityWithIncludedFormValues().getHasManyField(TechnologyOperationComponentFields.WORKSTATIONS).size();
FieldComponent quantityOfWorkstations = (FieldComponent) view.getComponentByReference(TechnologyOperationComponentFields.QUANTITY_OF_WORKSTATIONS);
quantityOfWorkstations.setFieldValue(size);
quantityOfWorkstations.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class TechnologiesWithUsingProductListListeners method goToModifyTechnology.
public void goToModifyTechnology(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
List<Integer> entitiesId = Lists.newArrayList();
Set<Long> selected = grid.getSelectedEntitiesIds();
List<Entity> entities = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, "operationProductInProductDto").find().add(SearchRestrictions.in("id", selected)).list().getEntities();
boolean isProductBySize = entities.stream().anyMatch(entry -> selected.contains(entry.getId()) && entry.getBooleanField("sizeProduct"));
for (Entity entity : entities) {
if (selected.contains(entity.getId())) {
if (isProductBySize) {
if (!entitiesId.contains(entity.getIntegerField("productBySizeGroupId"))) {
entitiesId.add(entity.getIntegerField("productBySizeGroupId"));
}
} else {
if (!entitiesId.contains(entity.getIntegerField("operationProductInComponentId"))) {
entitiesId.add(entity.getIntegerField("operationProductInComponentId"));
}
}
}
}
Entity modifyTechnology = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODIFY_TECHNOLOGY_HELPER).create();
modifyTechnology.setField("product", form.getEntityId());
modifyTechnology.setField("sizeProduct", isProductBySize);
modifyTechnology.setField("selectedEntities", entitiesId.stream().map(e -> e.toString()).collect(Collectors.joining(",")));
modifyTechnology = modifyTechnology.getDataDefinition().save(modifyTechnology);
Map<String, Object> parameters = Maps.newHashMap();
parameters.put("form.id", modifyTechnology.getId());
String url = "../page/technologies/modifyTechnology.html";
view.openModal(url, parameters);
}
Aggregations