Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CoTA
cota-backend
Commits
b294c18e
Commit
b294c18e
authored
1 year ago
by
Lückemeyer
Browse files
Options
Download
Email Patches
Plain Diff
refactor & extend url listener
parent
420073ca
master
amg-dev-volumes
amg-svn+ssh
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
Dockerfile
+50
-48
Dockerfile
src/main/java/de/hftstuttgart/dtabackend/rest/v1/task/TaskUpload.java
+97
-97
...a/de/hftstuttgart/dtabackend/rest/v1/task/TaskUpload.java
src/main/java/de/hftstuttgart/dtabackend/utils/CompetencyAssessmentUtil.java
+98
-90
...tstuttgart/dtabackend/utils/CompetencyAssessmentUtil.java
src/main/java/de/hftstuttgart/dtabackend/utils/ExecuteTestUtil.java
+145
-143
...ava/de/hftstuttgart/dtabackend/utils/ExecuteTestUtil.java
src/main/resources/application.properties
+1
-1
src/main/resources/application.properties
with
391 additions
and
379 deletions
+391
-379
Dockerfile
+
50
-
48
View file @
b294c18e
...
...
@@ -30,6 +30,8 @@ ARG AGID=137
ENV
USER=$AUSER
ENV
GID=$AGID
ARG
BUILD_NUMBER=
# Create docker group identical to host
RUN
addgroup
-g
$GID
-S
docker
RUN
adduser
--no-create-home
-u
1000
-G
docker
-D
$USER
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/hftstuttgart/dtabackend/rest/v1/task/TaskUpload.java
+
97
-
97
View file @
b294c18e
...
...
@@ -24,7 +24,7 @@ import jakarta.servlet.annotation.MultipartConfig;
* Rest controller for everything related to the TASK files
*/
@RestController
@RequestMapping
(
"/v1/task"
)
@RequestMapping
(
"/v1/task
/*
"
)
@MultipartConfig
public
class
TaskUpload
{
private
static
final
Logger
LOG
=
LogManager
.
getLogger
(
TaskUpload
.
class
);
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/hftstuttgart/dtabackend/utils/CompetencyAssessmentUtil.java
+
98
-
90
View file @
b294c18e
...
...
@@ -3,14 +3,21 @@ package de.hftstuttgart.dtabackend.utils;
import
java.io.BufferedReader
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.nio.file.Path
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
com.fasterxml.jackson.core.exc.StreamReadException
;
import
com.fasterxml.jackson.databind.DatabindException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
de.hftstuttgart.dtabackend.models.Result
;
import
de.hftstuttgart.dtabackend.models.ResultSummary
;
import
de.hftstuttgart.dtabackend.models.TestCompetencyProfile
;
...
...
@@ -22,16 +29,11 @@ public class CompetencyAssessmentUtil {
public
static
String
TEST_COMPETENCY_MANIFEST_FILE_NAME
=
"competency-tests.mft"
;
/* public static void main(String[] args) throws StreamReadException, DatabindException, MalformedURLException, IOException {
List<TestCompetencyProfile> testCompetencyProfiles=readTestCompetencyProfiles(Path.of(args[0]), args[1]);
sumTestCompetencyProfiles(testCompetencyProfiles);
ObjectMapper objectMapper = new ObjectMapper();
ResultSummary resultSummary = objectMapper.readValue(
new File(Path.of(args[0]).toFile(), args[2]).toURI().toURL(),
ResultSummary.class);
sumSuccessfulCompetencyProfiles(testCompetencyProfiles, resultSummary);
public
static
void
main
(
String
[]
args
)
throws
StreamReadException
,
DatabindException
,
MalformedURLException
,
IOException
{
ResultSummary
summary
=
ExecuteTestUtil
.
generateResult
(
Path
.
of
(
args
[
0
]),
Path
.
of
(
args
[
1
]));
System
.
out
.
println
(
summary
.
successfulTestCompetencyProfile
);
}
*/
public
static
float
[]
sumTestCompetencyProfiles
(
List
<
TestCompetencyProfile
>
testCompetencyProfiles
)
{
float
[]
tcpTotalProfile
=
new
float
[
TestCompetencyProfile
.
MAX_COMPETENCY_DIMENSIONS
];
for
(
TestCompetencyProfile
currentProfile:
testCompetencyProfiles
)
{
...
...
@@ -87,4 +89,10 @@ public class CompetencyAssessmentUtil {
return
testCompetencyProfiles
;
}
public
static
String
packFloats
(
float
[]
array
)
{
return
IntStream
.
range
(
0
,
array
.
length
)
.
mapToObj
(
i
->
String
.
valueOf
(
array
[
i
]))
.
collect
(
Collectors
.
joining
(
";"
));
}
}
This diff is collapsed.
Click to expand it.
src/main/java/de/hftstuttgart/dtabackend/utils/ExecuteTestUtil.java
+
145
-
143
View file @
b294c18e
package
de.hftstuttgart.dtabackend.utils
;
import
com.fasterxml.jackson.core.exc.StreamReadException
;
import
com.fasterxml.jackson.databind.DatabindException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.github.dockerjava.api.model.Bind
;
import
com.github.dockerjava.api.model.Volume
;
...
...
@@ -12,13 +14,12 @@ import org.springframework.core.env.Environment;
import
org.springframework.stereotype.Component
;
import
java.io.*
;
import
java.net.MalformedURLException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
@Component
public
class
ExecuteTestUtil
{
...
...
@@ -109,6 +110,13 @@ public class ExecuteTestUtil {
new
Bind
(
resultPathHost
.
toAbsolutePath
().
toString
(),
new
Volume
(
"/data/result"
))
);
ResultSummary
resultSummary
=
generateResult
(
resultPath
,
testPathHost
);
return
resultSummary
;
}
static
ResultSummary
generateResult
(
Path
resultPath
,
Path
testPathHost
)
throws
IOException
,
StreamReadException
,
DatabindException
,
MalformedURLException
{
// define expected result file
File
resultFile
=
Paths
.
get
(
resultPath
.
toAbsolutePath
().
toString
(),
"result.json"
).
toFile
();
...
...
@@ -123,21 +131,15 @@ public class ExecuteTestUtil {
ResultSummary
resultSummary
=
objectMapper
.
readValue
(
resultFile
.
toURI
().
toURL
(),
ResultSummary
.
class
);
LOG
.
debug
(
"result json returned time "
+
resultSummary
.
timestamp
+
" with "
+
resultSummary
.
results
.
size
()+
" test results."
);
LOG
.
info
(
"Checking for optional test competency profile information for paedagogical agent functionality..."
);
List
<
TestCompetencyProfile
>
testCompetencyProfiles
=
CompetencyAssessmentUtil
.
readTestCompetencyProfiles
(
testPathHost
,
CompetencyAssessmentUtil
.
TEST_COMPETENCY_MANIFEST_FILE_NAME
);
if
(
testCompetencyProfiles
!=
null
)
{
LOG
.
info
(
"Found optional test competency profiles, generating agent profile data..."
);
resultSummary
.
overallTestCompetencyProfile
=
packFloats
(
CompetencyAssessmentUtil
.
sumTestCompetencyProfiles
(
testCompetencyProfiles
));
resultSummary
.
successfulTestCompetencyProfile
=
packFloats
(
CompetencyAssessmentUtil
.
sumSuccessfulCompetencyProfiles
(
testCompetencyProfiles
,
resultSummary
));
resultSummary
.
overallTestCompetencyProfile
=
CompetencyAssessmentUtil
.
packFloats
(
CompetencyAssessmentUtil
.
sumTestCompetencyProfiles
(
testCompetencyProfiles
));
resultSummary
.
successfulTestCompetencyProfile
=
CompetencyAssessmentUtil
.
packFloats
(
CompetencyAssessmentUtil
.
sumSuccessfulCompetencyProfiles
(
testCompetencyProfiles
,
resultSummary
));
}
return
resultSummary
;
}
private
static
String
packFloats
(
float
[]
array
)
{
return
IntStream
.
range
(
0
,
array
.
length
)
.
mapToObj
(
i
->
String
.
valueOf
(
array
[
i
]))
.
collect
(
Collectors
.
joining
(
";"
));
}
}
This diff is collapsed.
Click to expand it.
src/main/resources/application.properties
+
1
-
1
View file @
b294c18e
...
...
@@ -7,7 +7,7 @@ spring.http.multipart.max-file-size=5Mb
###############################################
# Holds the uploaded Zip-Files
tests.tmp.dir
=
/tmp
/dt
t
-tests
tests.tmp.dir
=
~
/dt
a
-tests
host.tests.tmp.dir
=
${tests.tmp.dir}
data.dir
=
/data
data.dir.test.folder.name
=
UnitTests
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets