use of org.libresonic.player.domain.Transcoding in project libresonic by Libresonic.
the class TranscodingDaoTestCase method testUpdateTranscoding.
@Test
public void testUpdateTranscoding() {
Transcoding transcoding = new Transcoding(null, "name", "sourceFormats", "targetFormat", "step1", "step2", "step3", false);
transcodingDao.createTranscoding(transcoding);
transcoding = transcodingDao.getAllTranscodings().get(0);
transcoding.setName("newName");
transcoding.setSourceFormats("newSourceFormats");
transcoding.setTargetFormat("newTargetFormats");
transcoding.setStep1("newStep1");
transcoding.setStep2("newStep2");
transcoding.setStep3("newStep3");
transcoding.setDefaultActive(true);
transcodingDao.updateTranscoding(transcoding);
Transcoding newTranscoding = transcodingDao.getAllTranscodings().get(0);
assertTranscodingEquals(transcoding, newTranscoding);
}
use of org.libresonic.player.domain.Transcoding in project libresonic by Libresonic.
the class TranscodingDaoTestCase method testDeleteTranscoding.
@Test
public void testDeleteTranscoding() {
assertEquals("Wrong number of transcodings.", 0, transcodingDao.getAllTranscodings().size());
transcodingDao.createTranscoding(new Transcoding(null, "name", "sourceFormats", "targetFormat", "step1", "step2", "step3", true));
assertEquals("Wrong number of transcodings.", 1, transcodingDao.getAllTranscodings().size());
transcodingDao.createTranscoding(new Transcoding(null, "name", "sourceFormats", "targetFormat", "step1", "step2", "step3", true));
assertEquals("Wrong number of transcodings.", 2, transcodingDao.getAllTranscodings().size());
transcodingDao.deleteTranscoding(transcodingDao.getAllTranscodings().get(0).getId());
assertEquals("Wrong number of transcodings.", 1, transcodingDao.getAllTranscodings().size());
transcodingDao.deleteTranscoding(transcodingDao.getAllTranscodings().get(0).getId());
assertEquals("Wrong number of transcodings.", 0, transcodingDao.getAllTranscodings().size());
}
use of org.libresonic.player.domain.Transcoding in project libresonic by Libresonic.
the class TranscodingSettingsController method handleParameters.
private String handleParameters(HttpServletRequest request, RedirectAttributes redirectAttributes) {
for (Transcoding transcoding : transcodingService.getAllTranscodings()) {
Integer id = transcoding.getId();
String name = getParameter(request, "name", id);
String sourceFormats = getParameter(request, "sourceFormats", id);
String targetFormat = getParameter(request, "targetFormat", id);
String step1 = getParameter(request, "step1", id);
String step2 = getParameter(request, "step2", id);
boolean delete = getParameter(request, "delete", id) != null;
if (delete) {
transcodingService.deleteTranscoding(id);
} else if (name == null) {
return "transcodingsettings.noname";
} else if (sourceFormats == null) {
return "transcodingsettings.nosourceformat";
} else if (targetFormat == null) {
return "transcodingsettings.notargetformat";
} else if (step1 == null) {
return "transcodingsettings.nostep1";
} else {
transcoding.setName(name);
transcoding.setSourceFormats(sourceFormats);
transcoding.setTargetFormat(targetFormat);
transcoding.setStep1(step1);
transcoding.setStep2(step2);
transcodingService.updateTranscoding(transcoding);
}
}
String name = StringUtils.trimToNull(request.getParameter("name"));
String sourceFormats = StringUtils.trimToNull(request.getParameter("sourceFormats"));
String targetFormat = StringUtils.trimToNull(request.getParameter("targetFormat"));
String step1 = StringUtils.trimToNull(request.getParameter("step1"));
String step2 = StringUtils.trimToNull(request.getParameter("step2"));
boolean defaultActive = request.getParameter("defaultActive") != null;
if (name != null || sourceFormats != null || targetFormat != null || step1 != null || step2 != null) {
Transcoding transcoding = new Transcoding(null, name, sourceFormats, targetFormat, step1, step2, null, defaultActive);
String error = null;
if (name == null) {
error = "transcodingsettings.noname";
} else if (sourceFormats == null) {
error = "transcodingsettings.nosourceformat";
} else if (targetFormat == null) {
error = "transcodingsettings.notargetformat";
} else if (step1 == null) {
error = "transcodingsettings.nostep1";
} else {
transcodingService.createTranscoding(transcoding);
}
if (error != null) {
redirectAttributes.addAttribute("newTranscoding", transcoding);
return error;
}
}
settingsService.setDownsamplingCommand(StringUtils.trim(request.getParameter("downsampleCommand")));
settingsService.setHlsCommand(StringUtils.trim(request.getParameter("hlsCommand")));
settingsService.save();
return null;
}
Aggregations