Skip to content

Commit

Permalink
Merge pull request #2922 from dzhw/release
Browse files Browse the repository at this point in the history
Release v1.0.111-HOTFIX
  • Loading branch information
René Reitmann authored Jul 12, 2021
2 parents 72d9296 + b727c5a commit e222844
Show file tree
Hide file tree
Showing 30 changed files with 624 additions and 199 deletions.
16 changes: 11 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Metadatamanagement",
"version": "1.0.111",
"version": "1.0.111-HOTFIX",
"description": "Data Search for Higher Education Research and Science Studies",
"private": true,
"dependencies": {
Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.8</version>
<relativePath/>
<relativePath />
</parent>

<groupId>eu.dzhw.fdz</groupId>
<artifactId>metadatamanagement</artifactId>
<version>1.0.111</version>
<version>1.0.111-HOTFIX</version>
<packaging>war</packaging>
<name>metadatamanagement</name>

Expand Down Expand Up @@ -416,7 +416,7 @@
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
Expand All @@ -429,7 +429,7 @@
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
Expand All @@ -442,7 +442,7 @@
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
Expand All @@ -455,7 +455,7 @@
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class MetadataManagementProperties {

private final Projectmanagement projectmanagement = new Projectmanagement();

private final DatasetReportTask datasetReportTask = new DatasetReportTask();
private final ReportTask reportTask = new ReportTask();

private final Seo4ajax seo4ajax = new Seo4ajax();

Expand Down Expand Up @@ -191,11 +191,11 @@ public static class Dlp {
}

/**
* Properties for the dataset-report-task.
* Properties for the report-task.
*/
@Getter
@Setter
public static class DatasetReportTask {
public static class ReportTask {
private String startCommand;
private String taskDefinition;
private String clusterName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@
import com.amazonaws.services.ecs.model.NetworkConfiguration;
import com.amazonaws.services.ecs.model.RunTaskRequest;
import com.amazonaws.services.ecs.model.TaskOverride;
import com.google.common.base.Function;
import com.google.common.collect.Maps;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import eu.dzhw.fdz.metadatamanagement.common.config.Constants;
import eu.dzhw.fdz.metadatamanagement.common.config.MetadataManagementProperties;
import eu.dzhw.fdz.metadatamanagement.common.config.MetadataManagementProperties.DatasetReportTask;
import eu.dzhw.fdz.metadatamanagement.common.config.MetadataManagementProperties.ReportTask;
import eu.dzhw.fdz.metadatamanagement.common.domain.Task;
import eu.dzhw.fdz.metadatamanagement.common.rest.util.ZipUtil;
import eu.dzhw.fdz.metadatamanagement.common.service.MarkdownHelper;
Expand All @@ -55,6 +54,7 @@
import eu.dzhw.fdz.metadatamanagement.instrumentmanagement.repository.InstrumentRepository;
import eu.dzhw.fdz.metadatamanagement.questionmanagement.domain.Question;
import eu.dzhw.fdz.metadatamanagement.questionmanagement.repository.QuestionRepository;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.AccessWays;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.RelatedQuestion;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.ValidResponse;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.Variable;
Expand All @@ -76,6 +76,7 @@
@Slf4j
@RequiredArgsConstructor
public class DataSetReportService {
private static final String TASK_TYPE = "DATASET_REPORT";

private final FileService fileService;

Expand Down Expand Up @@ -189,6 +190,7 @@ public void generateReport(Path zipTmpFilePath, String originalName, String data
Map<String, Object> dataForTemplate = this.loadDataForTemplateFilling(dataSetId, version);

dataForTemplate.put("removeMarkdown", markdownHelper.createRemoveMarkdownMethod());
dataForTemplate.put("displayAccessWay", AccessWays.createDisplayAccessWayMethod());
try {
String variableListFilledStr = this.fillTemplate(texVariableListFileStr,
templateConfiguration, dataForTemplate, KEY_VARIABLELIST);
Expand Down Expand Up @@ -387,15 +389,15 @@ private Map<String, Object> createVariableDependingMaps(Map<String, Object> data
} else {
variables = Collections.emptyList();
}
Map<String, Variable> variablesMap = Maps.uniqueIndex(variables, new VariableFunction());
Map<String, Variable> variablesMap = Maps.uniqueIndex(variables, Variable::getId);
dataForTemplate.put("variables", variablesMap);

// Create different information from the variable
Map<String, Question> questionsMap = new HashMap<>();
Map<String, Instrument> instrumentMap = new HashMap<>();
Map<String, List<ValidResponse>> firstTenValidResponses = new HashMap<>();
Map<String, List<ValidResponse>> lastTenValidResponses = new HashMap<>();
Map<String, List<VariableSubDocumentProjection>> repeatedMeasurementVariables =
Map<String, List<VariableSubDocumentProjection>> repeatedMeasurementVariables =
new HashMap<>();
Map<String, List<VariableSubDocumentProjection>> derivedVariables = new HashMap<>();

Expand Down Expand Up @@ -463,28 +465,6 @@ private Map<String, Object> createVariableDependingMaps(Map<String, Object> data

}

/**
* Inner class for get the variable ids as index for the variables hashmap.
*
* @author Daniel Katzberg
*
*/
static class VariableFunction implements Function<Variable, String> {
/*
* (non-Javadoc)
*
* @see com.google.common.base.Function#apply(java.lang.Object)
*/
@Override
public String apply(Variable variable) {
if (variable == null) {
return null;
}

return variable.getId();
}
}

/**
* Start one container per language which builds the report. Either via aws fargate or locally via
* docker.
Expand All @@ -500,13 +480,13 @@ public void startDataSetReportTasks(String dataSetId, String version, List<Strin
String onBehalfOf) throws IOException {
for (String language : languages) {
if (environment.acceptsProfiles(Profiles.of(Constants.SPRING_PROFILE_LOCAL))) {
log.debug("Starting docker container from image dataset-report-task...");
log.debug("Starting docker container from image report-task...");
RunProcess dataSetReportTaskContainer =
new RunProcess("src/main/resources/bin/run-dataset-report-task.sh", dataSetId, version,
language, onBehalfOf);
new RunProcess("src/main/resources/bin/run-report-task.sh", dataSetId, version,
language, onBehalfOf, TASK_TYPE);
dataSetReportTaskContainer.run(false);
} else {
DatasetReportTask taskProperties = metadataManagementProperties.getDatasetReportTask();
ReportTask taskProperties = metadataManagementProperties.getReportTask();
log.info("Starting fargate task {}...", taskProperties.getTaskDefinition());
NetworkConfiguration networkConfiguration = ecsClient
.describeServices(
Expand All @@ -524,7 +504,7 @@ public void startDataSetReportTasks(String dataSetId, String version, List<Strin
.withOverrides(new TaskOverride().withContainerOverrides(
new ContainerOverride().withName(taskProperties.getContainerName())
.withCommand(String.format(taskProperties.getStartCommand(), dataSetId,
version, language, onBehalfOf).split("\\s+"))));
version, language, onBehalfOf, TASK_TYPE).split("\\s+"))));
ecsClient.runTask(req);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,17 @@ private Period generateSurveyPeriod(List<SurveySubDocumentProjection> surveys) {
}

/**
* Check the serial number of every survey.
* For the moment the number of waves is equal to the number of surveys within
* a data package.
*
* @param surveys All Survey Sub Document Projections.
* @return The highest (max) serial number.
* @return The number of surveys.
*/
private Integer generateNumberOfWaves(List<SurveySubDocumentProjection> surveys) {
Integer numberOfWaves = 0;

for (SurveySubDocumentProjection survey : surveys) {
if (survey.getSerialNumber() > numberOfWaves) {
numberOfWaves = survey.getSerialNumber();
}
if (surveys != null) {
numberOfWaves = surveys.size();
}

return numberOfWaves;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang3.NotImplementedException;

import eu.dzhw.fdz.metadatamanagement.datasetmanagement.domain.DataSet;
import freemarker.template.SimpleScalar;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;

/**
* An access way of a {@link Variable} or a {@link DataSet} indicates how the data user will be able
Expand All @@ -17,8 +23,52 @@ public class AccessWays {
public static final String REMOTE_DESKTOP = "remote-desktop-suf";
public static final String ONSITE_SUF = "onsite-suf";
public static final String NOT_ACCESSIBLE = "not-accessible";

public static final List<String> ALL =
Collections.unmodifiableList(Arrays.asList(DOWNLOAD_CUF, DOWNLOAD_SUF,
REMOTE_DESKTOP, ONSITE_SUF, NOT_ACCESSIBLE));

public static final List<String> ALL = Collections.unmodifiableList(
Arrays.asList(DOWNLOAD_CUF, DOWNLOAD_SUF, REMOTE_DESKTOP, ONSITE_SUF, NOT_ACCESSIBLE));

/**
* Get a string which can be used for presenting access ways to users.
* @param accessWay an access way
* @return the more human readable string
*/
public static String displayAccessWay(String accessWay) {
if (!ALL.contains(accessWay)) {
throw new NotImplementedException(
"AccessWay '" + accessWay + "' has not yet been implemented!");
}
switch (accessWay) {
case NOT_ACCESSIBLE:
return "Not accessible";
case DOWNLOAD_CUF:
return "CUF: Download";
case DOWNLOAD_SUF:
return "SUF: Download";
case REMOTE_DESKTOP:
return "SUF: Remote-Desktop";
case ONSITE_SUF:
return "SUF: On-Site";
default:
throw new NotImplementedException(
"AccessWay '" + accessWay + "' has not yet been implemented!");
}
}

/**
* Create a freemarker method to be used in freemarker templates to display access ways.
*
* @return The {@link TemplateMethodModelEx} which is a freemarker method.
*/
public static TemplateMethodModelEx createDisplayAccessWayMethod() {
return new TemplateMethodModelEx() {
@SuppressWarnings("rawtypes")
@Override
public TemplateModel exec(List arguments) throws TemplateModelException {
if (arguments.size() != 1) {
throw new TemplateModelException("Wrong arguments");
}
return new SimpleScalar(displayAccessWay(((SimpleScalar) arguments.get(0)).getAsString()));
}
};
}
}
4 changes: 0 additions & 4 deletions src/main/resources/bin/run-dataset-report-task.sh

This file was deleted.

4 changes: 4 additions & 0 deletions src/main/resources/bin/run-report-task.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# this script gives an example for running the report generation
# in the docker container connecting to localhost
docker run --network=host 347729458675.dkr.ecr.eu-central-1.amazonaws.com/dzhw/report-task:latest-dev java -jar /app/report-task.jar --task.id=$1 --task.version=$2 --task.language=$3 --task.onBehalfOf=$4 --task.type=$5 --mdm.username=${MDM_TASK_USER} --mdm.password=${MDM_TASK_PASSWORD} --mdm.endpoint=http://127.0.0.1:8080
4 changes: 2 additions & 2 deletions src/main/resources/config/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ metadatamanagement:
websockets:
allowed-origins:
- https://dev.metadata.fdz.dzhw.eu
dataset-report-task:
task-definition: dataset-report-task-dev
report-task:
task-definition: report-task-dev
cluster-name: dev
mongodb:
ssl-ca-certificate: ${vcap.services.mongodb.cacert}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/config/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ metadatamanagement:
websockets:
allowed-origins:
- https://metadata.fdz.dzhw.eu
dataset-report-task:
task-definition: dataset-report-task-prod
report-task:
task-definition: report-task-prod
cluster-name: prod
mongodb:
ssl-ca-certificate: ${vcap.services.mongodb.cacert}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/config/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ metadatamanagement:
websockets:
allowed-origins:
- https://test.metadata.fdz.dzhw.eu
dataset-report-task:
task-definition: dataset-report-task-test
report-task:
task-definition: report-task-test
cluster-name: test
mongodb:
ssl-ca-certificate: ${vcap.services.mongodb.cacert}
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ metadatamanagement:
email: [email protected]
dlp:
endpoint: https://stage.fdz.dzhw.eu/{language}/form/data-usage-application
dataset-report-task:
start-command: java -jar /app/dataset-report-task.jar --task.dataSetId=%1$s --task.version=%2$s --task.language=%3$s --task.onBehalfOf=%4$s
report-task:
start-command: java -jar /app/report-task.jar --task.id=%1$s --task.version=%2$s --task.language=%3$s --task.onBehalfOf=%4$s --task.type=%5$s
service-name: metadatamanagement-worker
container-name: dataset-report-task
container-name: report-task

# ===================================================================
# JHipster specific properties
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/scripts/app.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ angular.module('metadatamanagementApp')

.constant('ENV', 'local')

.constant('VERSION', '1.0.111')
.constant('VERSION', '1.0.111-HOTFIX')

.constant('ElasticSearchProperties', {apiVersion:'7.x',logLevel:'error',pageSize:10})

Expand Down
Loading

0 comments on commit e222844

Please sign in to comment.