Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TIPM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BARBIER Marc
TIPM
Commits
b0413ac6
Unverified
Commit
b0413ac6
authored
3 years ago
by
BARBIER Marc
Browse files
Options
Downloads
Patches
Plain Diff
simplifiew the windows fetching
parent
c4fd0974
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/be/uantwerpen/mime_webapp/controller/TableLoadController.java
+30
-40
30 additions, 40 deletions
...antwerpen/mime_webapp/controller/TableLoadController.java
with
30 additions
and
40 deletions
src/main/java/be/uantwerpen/mime_webapp/controller/TableLoadController.java
+
30
−
40
View file @
b0413ac6
...
...
@@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpSession
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Required
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
...
...
@@ -31,44 +32,24 @@ public class TableLoadController {
@Autowired
ProjectRepository
repository
;
/**
* CSV or ARFF
*/
@RequestMapping
(
value
=
"/rest/load-data"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
Table
loadData
(
@RequestParam
(
"pagination"
)
String
pagination
,
HttpServletRequest
request
)
@RequestMapping
(
value
=
"/rest/load-data-windows"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
Table
loadData
(
@RequestParam
(
"pagination"
)
Optional
<
String
>
pagination
,
@RequestParam
(
"id"
)
Optional
<
String
>
id
,
HttpServletRequest
request
)
{
FileItem
item
=
getCurrentItem
(
request
.
getSession
());
if
(
item
==
null
)
return
null
;
//Access database to get filename
if
(!
item
.
isArff
()
&&
!
item
.
isCSV
())
throw
new
RuntimeException
(
"Only ARRF or CSV input expected"
);
System
.
out
.
println
(
"rest>>loadData("
+
item
.
getId
()
+
","
+
item
+
")"
);
//Load ARRF or CSV file
if
(
pagination
.
equals
(
""
)){
pagination
=
"0-1000"
;
//default only first 1000 rows read
return
loadDataWindows
(
Optional
.
of
(
true
),
pagination
,
id
,
request
);
}
int
from
=
Math
.
max
(
0
,
Integer
.
valueOf
(
pagination
.
split
(
"-"
)[
0
]));
int
to
=
Integer
.
valueOf
(
pagination
.
split
(
"-"
)[
1
]);
try
{
Table
table
=
null
;
if
(
item
.
isArff
()){
table
=
new
ArffDenseUtils
().
loadArff
(
item
.
getFile
(),
from
,
to
);
}
else
{
table
=
CSVUtils
.
loadCSV
(
item
.
getFile
(),
from
,
to
);
}
return
table
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
null
;
@RequestMapping
(
value
=
"/rest/load-data"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
Table
loadDataWindows
(
@RequestParam
(
"windowed"
)
Optional
<
Boolean
>
windowed
,
@RequestParam
(
"pagination"
)
Optional
<
String
>
pagination
,
@RequestParam
(
"id"
)
Optional
<
String
>
id
,
HttpServletRequest
request
)
{
String
page
;
FileItem
item
=
null
;
if
(
id
.
isPresent
())
{
item
=
repository
.
findItemById
(
id
.
get
().
trim
());
}
if
(
item
==
null
)
{
item
=
getCurrentItem
(
request
.
getSession
());
}
@RequestMapping
(
value
=
"/rest/load-data-windows"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
Table
loadDataWindows
(
@RequestParam
(
"pagination"
)
String
pagination
,
HttpServletRequest
request
)
{
FileItem
item
=
getCurrentItem
(
request
.
getSession
());
if
(
item
==
null
)
return
null
;
//Access database to get filename
...
...
@@ -76,15 +57,24 @@ public class TableLoadController {
throw
new
RuntimeException
(
"ARRF input expected"
);
System
.
out
.
println
(
"rest>>loadDataWindows("
+
item
.
getId
()
+
","
+
item
+
")"
);
//Load ARRF or CSV file
if
(
pagination
.
equals
(
""
)){
pagination
=
"0-1000"
;
//default only first 1000 rows read
if
(
pagination
.
isPresent
()
&&
pagination
.
get
().
equals
(
""
)
||
!
pagination
.
isPresent
()){
page
=
"0-1000"
;
//default only first 1000 rows read
}
else
{
page
=
pagination
.
get
();
}
int
from
=
Math
.
max
(
0
,
Integer
.
valueOf
(
pagination
.
split
(
"-"
)[
0
]));
int
to
=
Integer
.
valueOf
(
pagination
.
split
(
"-"
)[
1
]);
File
f
=
item
.
getFile
();
int
from
=
Math
.
max
(
0
,
Integer
.
valueOf
(
page
.
split
(
"-"
)[
0
]));
int
to
=
Integer
.
parseInt
(
page
.
split
(
"-"
)[
1
]);
try
{
Table
tab
=
MakePatternOccurrences
.
groupByWindow
(
f
,
from
,
to
);
return
tab
;
if
(
windowed
.
isPresent
()
&&
windowed
.
get
())
{
return
MakePatternOccurrences
.
groupByWindow
(
item
.
getFile
(),
from
,
to
);
}
else
{
if
(
item
.
isArff
()){
return
new
ArffDenseUtils
().
loadArff
(
item
.
getFile
(),
from
,
to
);
}
else
{
return
CSVUtils
.
loadCSV
(
item
.
getFile
(),
from
,
to
);
}
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
null
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment