use of com.qcadoo.mes.basic.controllers.dataProvider.responses.WorkstationResponse in project mes by qcadoo.
the class BasicApiController method saveWorkstation.
@ResponseBody
@RequestMapping(value = "/workstation", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public WorkstationResponse saveWorkstation(@RequestBody WorkstationRequest workstation) {
Entity workstationEntity = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_WORKSTATION).create();
workstationEntity.setField(WorkstationFields.NUMBER, workstation.getNumber());
workstationEntity.setField(WorkstationFields.NAME, workstation.getName());
workstationEntity.setField(WorkstationFields.WORKSTATION_TYPE, workstation.getType());
workstationEntity = workstationEntity.getDataDefinition().save(workstationEntity);
if (workstationEntity.isValid()) {
WorkstationResponse workstationResponse = new WorkstationResponse(WorkstationResponse.StatusCode.OK);
workstationResponse.setId(workstationEntity.getId());
workstationResponse.setNumber(workstation.getNumber());
workstationResponse.setName(workstation.getName());
return workstationResponse;
} else {
//
ErrorMessage numberError = workstationEntity.getError(WorkstationFields.NUMBER);
if (Objects.nonNull(numberError) && numberError.getMessage().equals("qcadooView.validate.field.error.duplicated")) {
WorkstationResponse response = new WorkstationResponse(WorkstationResponse.StatusCode.ERROR);
response.setMessage(translationService.translate("basic.dashboard.operationalTasksDefinitionWizard.error.validationError.workstationDuplicated", LocaleContextHolder.getLocale()));
return response;
}
}
WorkstationResponse response = new WorkstationResponse(WorkstationResponse.StatusCode.ERROR);
response.setMessage(translationService.translate("basic.dashboard.operationalTasksDefinitionWizard.error.validationError.workstationErrors", LocaleContextHolder.getLocale()));
return response;
}
use of com.qcadoo.mes.basic.controllers.dataProvider.responses.WorkstationResponse in project mes by qcadoo.
the class BasicApiController method saveWorkstationType.
@ResponseBody
@RequestMapping(value = "/workstationType", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public WorkstationResponse saveWorkstationType(@RequestBody WorkstationRequest workstation) {
Entity workstationEntity = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_WORKSTATION_TYPE).create();
workstationEntity.setField(WorkstationTypeFields.NUMBER, workstation.getNumber());
workstationEntity.setField(WorkstationTypeFields.NAME, workstation.getName());
workstationEntity = workstationEntity.getDataDefinition().save(workstationEntity);
if (workstationEntity.isValid()) {
WorkstationResponse workstationResponse = new WorkstationResponse(WorkstationResponse.StatusCode.OK);
workstationResponse.setId(workstationEntity.getId());
workstationResponse.setNumber(workstation.getNumber());
workstationResponse.setName(workstation.getName());
return workstationResponse;
} else {
//
ErrorMessage numberError = workstationEntity.getError(WorkstationFields.NUMBER);
if (Objects.nonNull(numberError) && numberError.getMessage().equals("qcadooView.validate.field.error.duplicated")) {
WorkstationResponse response = new WorkstationResponse(WorkstationResponse.StatusCode.ERROR);
response.setMessage(translationService.translate("basic.dashboard.operationalTasksDefinitionWizard.error.validationError.workstationTypeDuplicated", LocaleContextHolder.getLocale()));
return response;
}
}
WorkstationResponse response = new WorkstationResponse(WorkstationResponse.StatusCode.ERROR);
response.setMessage(translationService.translate("basic.dashboard.operationalTasksDefinitionWizard.error.validationError.workstationErrors", LocaleContextHolder.getLocale()));
return response;
}
Aggregations