SEBSERV-412 fixed config key
This commit is contained in:
parent
eb4f758328
commit
191b10b8be
7 changed files with 37 additions and 15 deletions
|
@ -174,6 +174,7 @@ public final class API {
|
||||||
|
|
||||||
public static final String CONFIGURATION_NODE_ENDPOINT = "/configuration-node";
|
public static final String CONFIGURATION_NODE_ENDPOINT = "/configuration-node";
|
||||||
public static final String CONFIGURATION_FOLLOWUP_PATH_SEGMENT = "/followup";
|
public static final String CONFIGURATION_FOLLOWUP_PATH_SEGMENT = "/followup";
|
||||||
|
public static final String PARAM_FOLLOWUP = "followup";
|
||||||
public static final String CONFIGURATION_CONFIG_KEY_PATH_SEGMENT = "/configkey";
|
public static final String CONFIGURATION_CONFIG_KEY_PATH_SEGMENT = "/configkey";
|
||||||
public static final String CONFIGURATION_SETTINGS_PUBLISHED_PATH_SEGMENT = "/settings_published";
|
public static final String CONFIGURATION_SETTINGS_PUBLISHED_PATH_SEGMENT = "/settings_published";
|
||||||
public static final String CONFIGURATION_ENDPOINT = "/configuration";
|
public static final String CONFIGURATION_ENDPOINT = "/configuration";
|
||||||
|
|
|
@ -336,7 +336,7 @@ public class SEBExamConfigForm implements TemplateComposer {
|
||||||
|
|
||||||
.newAction(ActionDefinition.SEB_EXAM_CONFIG_GET_CONFIG_KEY)
|
.newAction(ActionDefinition.SEB_EXAM_CONFIG_GET_CONFIG_KEY)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(SEBExamConfigForm.getConfigKeyFunction(this.pageService))
|
.withExec(SEBExamConfigForm.getConfigKeyFunction(this.pageService, true))
|
||||||
.noEventPropagation()
|
.noEventPropagation()
|
||||||
.publishIf(() -> modifyGrant && isReadonly)
|
.publishIf(() -> modifyGrant && isReadonly)
|
||||||
|
|
||||||
|
@ -504,11 +504,15 @@ public class SEBExamConfigForm implements TemplateComposer {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Function<PageAction, PageAction> getConfigKeyFunction(final PageService pageService) {
|
public static Function<PageAction, PageAction> getConfigKeyFunction(
|
||||||
|
final PageService pageService,
|
||||||
|
final boolean followup) {
|
||||||
|
|
||||||
final RestService restService = pageService.getResourceService().getRestService();
|
final RestService restService = pageService.getResourceService().getRestService();
|
||||||
return action -> {
|
return action -> {
|
||||||
final ConfigKey configKey = restService.getBuilder(ExportConfigKey.class)
|
final ConfigKey configKey = restService.getBuilder(ExportConfigKey.class)
|
||||||
.withURIVariable(API.PARAM_MODEL_ID, action.getEntityKey().modelId)
|
.withURIVariable(API.PARAM_MODEL_ID, action.getEntityKey().modelId)
|
||||||
|
.withQueryParam(API.PARAM_FOLLOWUP, String.valueOf(followup))
|
||||||
.call()
|
.call()
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ public class ExamFormConfigs implements TemplateComposer {
|
||||||
if (examConfigMappingKey != null) {
|
if (examConfigMappingKey != null) {
|
||||||
action.withEntityKey(examConfigMappingKey);
|
action.withEntityKey(examConfigMappingKey);
|
||||||
return SEBExamConfigForm
|
return SEBExamConfigForm
|
||||||
.getConfigKeyFunction(this.pageService)
|
.getConfigKeyFunction(this.pageService, false)
|
||||||
.apply(action);
|
.apply(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public interface ExamConfigService {
|
||||||
Result<Long> getFollowupConfigurationId(final Long examConfigNodeId);
|
Result<Long> getFollowupConfigurationId(final Long examConfigNodeId);
|
||||||
|
|
||||||
/** Used to export a specified SEB Exam Configuration as plain XML
|
/** Used to export a specified SEB Exam Configuration as plain XML
|
||||||
* This exports the values of the follow-up configuration defined by a given
|
* This exports the values of the last published changes of a given
|
||||||
* ConfigurationNode (configurationNodeId)
|
* ConfigurationNode (configurationNodeId)
|
||||||
*
|
*
|
||||||
* @param out The output stream to write the plain XML text to.
|
* @param out The output stream to write the plain XML text to.
|
||||||
|
@ -102,8 +102,13 @@ public interface ExamConfigService {
|
||||||
*
|
*
|
||||||
* @param institutionId the institutional id
|
* @param institutionId the institutional id
|
||||||
* @param configurationNodeId the configurationNodeId
|
* @param configurationNodeId the configurationNodeId
|
||||||
|
* @param stable indicates if the follow-up configuration entey shall be used or otherwise the last stable
|
||||||
|
* to calculate the config key
|
||||||
* @return Result refer to the generated Config-Key or to an error if happened. */
|
* @return Result refer to the generated Config-Key or to an error if happened. */
|
||||||
Result<String> generateConfigKey(Long institutionId, Long configurationNodeId);
|
Result<String> generateConfigKey(
|
||||||
|
Long institutionId,
|
||||||
|
Long configurationNodeId,
|
||||||
|
boolean followup);
|
||||||
|
|
||||||
/** Generates a list of Config-Key from a given Exam by collecting all the SEB Exam Configurations that are attached
|
/** Generates a list of Config-Key from a given Exam by collecting all the SEB Exam Configurations that are attached
|
||||||
* to this Exam
|
* to this Exam
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class ExamConfigIO {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME)
|
@Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME)
|
||||||
void exportForConfigKeyGeneration(
|
void exportForConfig(
|
||||||
final OutputStream out,
|
final OutputStream out,
|
||||||
final Long institutionId,
|
final Long institutionId,
|
||||||
final Long configurationNodeId,
|
final Long configurationNodeId,
|
||||||
|
@ -122,7 +122,7 @@ public class ExamConfigIO {
|
||||||
final Long configId) throws Exception {
|
final Long configId) throws Exception {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Start export SEB plain XML configuration asynconously");
|
log.debug("Start export SEB plain XML configuration asynchronously");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -273,11 +273,18 @@ public class ExamConfigServiceImpl implements ExamConfigService {
|
||||||
@Override
|
@Override
|
||||||
public Result<String> generateConfigKey(
|
public Result<String> generateConfigKey(
|
||||||
final Long institutionId,
|
final Long institutionId,
|
||||||
final Long configurationNodeId) {
|
final Long configurationNodeId,
|
||||||
|
final boolean followup) {
|
||||||
|
|
||||||
return this.configurationDAO
|
if (followup) {
|
||||||
.getConfigurationLastStableVersion(configurationNodeId)
|
return this.configurationDAO
|
||||||
.flatMap(config -> generateConfigKey(institutionId, configurationNodeId, config.id));
|
.getFollowupConfiguration(configurationNodeId)
|
||||||
|
.flatMap(config -> generateConfigKey(institutionId, configurationNodeId, config.id));
|
||||||
|
} else {
|
||||||
|
return this.configurationDAO
|
||||||
|
.getConfigurationLastStableVersion(configurationNodeId)
|
||||||
|
.flatMap(config -> generateConfigKey(institutionId, configurationNodeId, config.id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Result<String> generateConfigKey(
|
private Result<String> generateConfigKey(
|
||||||
|
@ -295,7 +302,7 @@ public class ExamConfigServiceImpl implements ExamConfigService {
|
||||||
pout = new PipedOutputStream();
|
pout = new PipedOutputStream();
|
||||||
pin = new PipedInputStream(pout);
|
pin = new PipedInputStream(pout);
|
||||||
|
|
||||||
this.examConfigIO.exportForConfigKeyGeneration(
|
this.examConfigIO.exportForConfig(
|
||||||
pout,
|
pout,
|
||||||
institutionId,
|
institutionId,
|
||||||
configurationNodeId,
|
configurationNodeId,
|
||||||
|
@ -335,7 +342,7 @@ public class ExamConfigServiceImpl implements ExamConfigService {
|
||||||
return this.examConfigurationMapDAO.getConfigurationNodeIds(examId)
|
return this.examConfigurationMapDAO.getConfigurationNodeIds(examId)
|
||||||
.map(ids -> ids
|
.map(ids -> ids
|
||||||
.stream()
|
.stream()
|
||||||
.map(id -> generateConfigKey(institutionId, id)
|
.map(id -> generateConfigKey(institutionId, id, false)
|
||||||
.getOrThrow())
|
.getOrThrow())
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.mybatis.dynamic.sql.SqlTable;
|
import org.mybatis.dynamic.sql.SqlTable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -239,13 +240,17 @@ public class ConfigurationNodeController extends EntityController<ConfigurationN
|
||||||
@RequestParam(
|
@RequestParam(
|
||||||
name = API.PARAM_INSTITUTION_ID,
|
name = API.PARAM_INSTITUTION_ID,
|
||||||
required = true,
|
required = true,
|
||||||
defaultValue = UserService.USERS_INSTITUTION_AS_DEFAULT) final Long institutionId) {
|
defaultValue = UserService.USERS_INSTITUTION_AS_DEFAULT) final Long institutionId,
|
||||||
|
@RequestParam(
|
||||||
|
name = API.PARAM_FOLLOWUP,
|
||||||
|
required = false,
|
||||||
|
defaultValue = "false") final Boolean followup) {
|
||||||
|
|
||||||
this.entityDAO.byPK(modelId)
|
this.entityDAO.byPK(modelId)
|
||||||
.flatMap(this.authorization::checkRead);
|
.flatMap(this.authorization::checkRead);
|
||||||
|
|
||||||
final String configKey = this.sebExamConfigService
|
final String configKey = this.sebExamConfigService
|
||||||
.generateConfigKey(institutionId, modelId)
|
.generateConfigKey(institutionId, modelId, BooleanUtils.toBoolean(followup))
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
|
|
||||||
return new ConfigKey(configKey);
|
return new ConfigKey(configKey);
|
||||||
|
|
Loading…
Reference in a new issue