download name client config over exam
This commit is contained in:
parent
c72bf2cf9c
commit
0790b5827f
3 changed files with 22 additions and 18 deletions
|
@ -14,11 +14,13 @@ import java.util.function.Predicate;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.eclipse.rap.rwt.RWT;
|
import org.eclipse.rap.rwt.RWT;
|
||||||
import org.eclipse.rap.rwt.client.service.UrlLauncher;
|
import org.eclipse.rap.rwt.client.service.UrlLauncher;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.joda.time.DateTime;
|
||||||
|
import org.joda.time.DateTimeZone;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -57,22 +59,25 @@ public class ExamCreateClientConfigPopup {
|
||||||
|
|
||||||
private final PageService pageService;
|
private final PageService pageService;
|
||||||
private final DownloadService downloadService;
|
private final DownloadService downloadService;
|
||||||
private final String downloadFileName;
|
|
||||||
|
|
||||||
public ExamCreateClientConfigPopup(
|
public ExamCreateClientConfigPopup(
|
||||||
final PageService pageService,
|
final PageService pageService,
|
||||||
final DownloadService downloadService,
|
final DownloadService downloadService) {
|
||||||
@Value("${sebserver.gui.seb.exam.config.download.filename}") final String downloadFileName) {
|
|
||||||
|
|
||||||
this.pageService = pageService;
|
this.pageService = pageService;
|
||||||
this.downloadService = downloadService;
|
this.downloadService = downloadService;
|
||||||
this.downloadFileName = downloadFileName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Function<PageAction, PageAction> exportFunction(final Long examInstitutionId) {
|
public Function<PageAction, PageAction> exportFunction(
|
||||||
|
final Long examInstitutionId,
|
||||||
|
final String examName) {
|
||||||
|
|
||||||
return action -> {
|
return action -> {
|
||||||
|
|
||||||
|
final DateTime now = DateTime.now(DateTimeZone.UTC);
|
||||||
|
final String downloadFileName = StringUtils.remove(examName, " ") + "_" + now.getYear() + "-"
|
||||||
|
+ now.getMonthOfYear() + "-" + now.getDayOfMonth() + ".seb";
|
||||||
|
|
||||||
final ModalInputDialog<FormHandle<?>> dialog =
|
final ModalInputDialog<FormHandle<?>> dialog =
|
||||||
new ModalInputDialog<FormHandle<?>>(
|
new ModalInputDialog<FormHandle<?>>(
|
||||||
action.pageContext().getParent().getShell(),
|
action.pageContext().getParent().getShell(),
|
||||||
|
@ -88,7 +93,8 @@ public class ExamCreateClientConfigPopup {
|
||||||
this.pageService,
|
this.pageService,
|
||||||
action.pageContext(),
|
action.pageContext(),
|
||||||
action.getEntityKey(),
|
action.getEntityKey(),
|
||||||
formHandle);
|
formHandle,
|
||||||
|
downloadFileName);
|
||||||
|
|
||||||
dialog.open(
|
dialog.open(
|
||||||
TITLE_KEY,
|
TITLE_KEY,
|
||||||
|
@ -104,7 +110,8 @@ public class ExamCreateClientConfigPopup {
|
||||||
final PageService pageService,
|
final PageService pageService,
|
||||||
final PageContext pageContext,
|
final PageContext pageContext,
|
||||||
final EntityKey examKey,
|
final EntityKey examKey,
|
||||||
final FormHandle<?> formHandle) {
|
final FormHandle<?> formHandle,
|
||||||
|
final String downloadFileName) {
|
||||||
|
|
||||||
if (formHandle == null) {
|
if (formHandle == null) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -116,7 +123,7 @@ public class ExamCreateClientConfigPopup {
|
||||||
modelId,
|
modelId,
|
||||||
examKey.modelId,
|
examKey.modelId,
|
||||||
SEBClientConfigDownload.class,
|
SEBClientConfigDownload.class,
|
||||||
this.downloadFileName);
|
downloadFileName);
|
||||||
urlLauncher.openURL(downloadURL);
|
urlLauncher.openURL(downloadURL);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -141,8 +140,7 @@ public class ExamForm implements TemplateComposer {
|
||||||
final ExamDeletePopup examDeletePopup,
|
final ExamDeletePopup examDeletePopup,
|
||||||
final ExamFormConfigs examFormConfigs,
|
final ExamFormConfigs examFormConfigs,
|
||||||
final ExamFormIndicators examFormIndicators,
|
final ExamFormIndicators examFormIndicators,
|
||||||
final ExamCreateClientConfigPopup examCreateClientConfigPopup,
|
final ExamCreateClientConfigPopup examCreateClientConfigPopup) {
|
||||||
@Value("${sebserver.gui.seb.exam.config.download.filename}") final String downloadFileName) {
|
|
||||||
|
|
||||||
this.pageService = pageService;
|
this.pageService = pageService;
|
||||||
this.resourceService = pageService.getResourceService();
|
this.resourceService = pageService.getResourceService();
|
||||||
|
@ -358,6 +356,7 @@ public class ExamForm implements TemplateComposer {
|
||||||
final PageActionBuilder actionBuilder = this.pageService.pageActionBuilder(formContext
|
final PageActionBuilder actionBuilder = this.pageService.pageActionBuilder(formContext
|
||||||
.clearEntityKeys()
|
.clearEntityKeys()
|
||||||
.removeAttribute(AttributeKeys.IMPORT_FROM_QUIZ_DATA));
|
.removeAttribute(AttributeKeys.IMPORT_FROM_QUIZ_DATA));
|
||||||
|
|
||||||
// propagate content actions to action-pane
|
// propagate content actions to action-pane
|
||||||
actionBuilder
|
actionBuilder
|
||||||
|
|
||||||
|
@ -380,7 +379,9 @@ public class ExamForm implements TemplateComposer {
|
||||||
|
|
||||||
.newAction(ActionDefinition.EXAM_SEB_CLIENT_CONFIG_EXPORT)
|
.newAction(ActionDefinition.EXAM_SEB_CLIENT_CONFIG_EXPORT)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(this.examCreateClientConfigPopup.exportFunction(exam.institutionId))
|
.withExec(this.examCreateClientConfigPopup.exportFunction(
|
||||||
|
exam.institutionId,
|
||||||
|
exam.getName()))
|
||||||
.publishIf(() -> writeGrant && readonly)
|
.publishIf(() -> writeGrant && readonly)
|
||||||
|
|
||||||
.newAction(ActionDefinition.EXAM_MODIFY_SEB_RESTRICTION_DETAILS)
|
.newAction(ActionDefinition.EXAM_MODIFY_SEB_RESTRICTION_DETAILS)
|
||||||
|
|
|
@ -16,7 +16,6 @@ import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -35,14 +34,11 @@ public class SEBClientConfigDownload extends AbstractDownloadServiceHandler {
|
||||||
private static final Logger log = LoggerFactory.getLogger(SEBClientConfigDownload.class);
|
private static final Logger log = LoggerFactory.getLogger(SEBClientConfigDownload.class);
|
||||||
|
|
||||||
private final RestService restService;
|
private final RestService restService;
|
||||||
public final String downloadFileName;
|
|
||||||
|
|
||||||
protected SEBClientConfigDownload(
|
protected SEBClientConfigDownload(
|
||||||
final RestService restService,
|
final RestService restService) {
|
||||||
@Value("${sebserver.gui.seb.client.config.download.filename}") final String downloadFileName) {
|
|
||||||
|
|
||||||
this.restService = restService;
|
this.restService = restService;
|
||||||
this.downloadFileName = downloadFileName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue