use of org.springframework.dao.DataIntegrityViolationException in project elastest-torm by elastest.
the class TestLinkService method syncProjectTestCase.
public void syncProjectTestCase(TestCase testCase, ExternalTJob externalTJob) {
ExternalTestCase externalTestCase = new ExternalTestCase(new Long(0));
externalTestCase.setExTJob(externalTJob);
externalTestCase.setName(testCase.getName());
externalTestCase.setFields(this.getTestCaseFields(testCase));
externalTestCase.setExternalId(testCase.getId().toString());
externalTestCase.setExternalSystemId(this.getSystemId());
try {
externalTestCase = externalTestCaseRepository.save(externalTestCase);
} catch (DataIntegrityViolationException existException) {
ExternalTestCase savedTestCase = externalTestCaseRepository.findByExternalIdAndExternalSystemId(externalTestCase.getExternalId(), externalTestCase.getExternalSystemId());
externalTestCase.setId(savedTestCase.getId());
externalTestCase = externalTestCaseRepository.save(externalTestCase);
}
this.syncTestCaseExecs(testCase.getId(), externalTestCase);
}
use of org.springframework.dao.DataIntegrityViolationException in project elastest-torm by elastest.
the class TestLinkService method syncProject.
public void syncProject(TestProject project) {
ExternalProject externalProject = new ExternalProject(new Long(0));
externalProject.setName(project.getName());
externalProject.setType(TypeEnum.TESTLINK);
externalProject.setExternalId(project.getId().toString());
externalProject.setExternalSystemId(this.getSystemId());
try {
externalProject = externalProjectRepository.save(externalProject);
} catch (DataIntegrityViolationException existException) {
ExternalProject savedPj = externalProjectRepository.findByExternalIdAndExternalSystemId(externalProject.getExternalId(), externalProject.getExternalSystemId());
externalProject.setId(savedPj.getId());
externalProject = externalProjectRepository.save(externalProject);
}
this.syncProjectTestPlans(project.getId(), externalProject);
}
use of org.springframework.dao.DataIntegrityViolationException in project elastest-torm by elastest.
the class TestLinkService method syncProjectTestPlan.
public void syncProjectTestPlan(TestPlan testPlan, ExternalProject externalProject) {
ExternalTJob externalTJob = new ExternalTJob(new Long(0));
externalTJob.setExProject(externalProject);
externalTJob.setName(testPlan.getName());
externalTJob.setExternalId(testPlan.getId().toString());
externalTJob.setExternalSystemId(this.getSystemId());
try {
externalTJob = externalTJobRepository.save(externalTJob);
} catch (DataIntegrityViolationException existException) {
ExternalTJob savedTJob = externalTJobRepository.findByExternalIdAndExternalSystemId(externalTJob.getExternalId(), externalTJob.getExternalSystemId());
externalTJob.setId(savedTJob.getId());
externalTJob.setSut(savedTJob.getSut());
externalTJob.setExecDashboardConfig(savedTJob.getExecDashboardConfig());
externalTJob = externalTJobRepository.save(externalTJob);
}
this.syncTestPlanCases(testPlan.getId(), externalTJob);
}
use of org.springframework.dao.DataIntegrityViolationException in project trainning by fernandotomasio.
the class CursosController method saveCurso.
@RequestMapping("/save")
public String saveCurso(Model model, @Valid CursoForm cursoForm, BindingResult bindingResult, WebRequest request) {
if (bindingResult.hasErrors()) {
model.addAttribute("areas", initializeSelectableAreas());
model.addAttribute("planos", initializeSelectablePlanos());
return "cursos/form";
}
CursoDTO dto = new CursoDTO();
dto.setId(cursoForm.getId());
dto.setArea(trainningService.findArea(cursoForm.getAreaId()));
dto.setPlano(trainningService.findPlano(cursoForm.getPlanoId()));
dto.setCodigo(cursoForm.getCodigo());
dto.setDescricao(cursoForm.getDescricao());
dto.setCodigoVelho(cursoForm.getCodigoVelho());
dto.setInstrucao(cursoForm.isInstrucao());
dto.setQuantidadeVagas(cursoForm.getQuantidadeVagas());
dto.setDuracao(cursoForm.getDuracao());
dto.setAtivo(cursoForm.isAtivo());
dto.setVisivel(cursoForm.isVisivel());
dto.setEhGT(cursoForm.isEhGT());
dto.setEstrangeiro(cursoForm.isEstrangeiro());
FolhaRostoDTO folhaRosto = new FolhaRostoDTO();
folhaRosto.setDisciplinas(cursoForm.getDisciplinas());
folhaRosto.setObjetivo(cursoForm.getObjetivo());
folhaRosto.setPreRequisitos(cursoForm.getPreRequisitos());
folhaRosto.setObservacoes(cursoForm.getObservacoes());
dto.setFolhaRosto(folhaRosto);
if (dto.getId() > 0) {
try {
trainningService.updateCurso(dto);
model.addAttribute("successMessage", "Curso atualizado com sucesso.");
model.addAttribute("curso", dto);
return "cursos/detail";
} catch (CoreException e) {
model.addAttribute("errorMessage", e.getMessage());
model.addAttribute("areas", initializeSelectableAreas());
model.addAttribute("planos", initializeSelectablePlanos());
return "cursos/form";
}
} else {
try {
Long cursoId = trainningService.createCurso(dto);
dto.setId(cursoId);
model.addAttribute("successMessage", "Curso criado com sucesso.");
model.addAttribute("curso", dto);
return "cursos/detail";
// } catch (CoreException e) {
} catch (DataIntegrityViolationException e) {
// model.addAttribute("errorMessage", e.getMessage());
model.addAttribute("errorMessage", "O Curso " + dto.getCodigo() + " já existe Cadastrado no Sistema!");
model.addAttribute("areas", initializeSelectableAreas());
model.addAttribute("planos", initializeSelectablePlanos());
return "cursos/form";
}
}
}
use of org.springframework.dao.DataIntegrityViolationException in project cloudbreak by hortonworks.
the class RdsConfigController method createRdsConfig.
private RDSConfigResponse createRdsConfig(IdentityUser user, RDSConfigRequest rdsConfigJson, boolean publicInAccount) {
RDSConfig rdsConfig = conversionService.convert(rdsConfigJson, RDSConfig.class);
rdsConfig.setPublicInAccount(publicInAccount);
try {
rdsConfig = rdsConfigService.create(user, rdsConfig);
notify(user, ResourceEvent.RDS_CONFIG_CREATED);
} catch (DataIntegrityViolationException ex) {
String msg = String.format("Error with resource [%s], error: [%s]", APIResourceType.RDS_CONFIG, getProperSqlErrorMessage(ex));
throw new BadRequestException(msg);
}
return conversionService.convert(rdsConfig, RDSConfigResponse.class);
}
Aggregations