Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Softa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Meißner
Softa
Commits
3d271a62
Commit
3d271a62
authored
1 year ago
by
Florian Meissner
Browse files
Options
Downloads
Patches
Plain Diff
initial commit; print works but is unelegant (switch from CompletableFuture to Stream)
parent
599c9562
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/ohm/softa/a11/App.java
+27
-4
27 additions, 4 deletions
src/main/java/ohm/softa/a11/App.java
with
27 additions
and
4 deletions
src/main/java/ohm/softa/a11/App.java
+
27
−
4
View file @
3d271a62
...
...
@@ -2,14 +2,17 @@ package ohm.softa.a11;
import
ohm.softa.a11.openmensa.OpenMensaAPI
;
import
ohm.softa.a11.openmensa.OpenMensaAPIService
;
import
ohm.softa.a11.openmensa.model.Canteen
;
import
ohm.softa.a11.openmensa.model.PageInfo
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.
Calendar
;
import
java.util.
Dat
e
;
import
java.util.
Locale
;
import
java.util.
Scanner
;
import
java.util.
*
;
import
java.util.
concurrent.CompletableFutur
e
;
import
java.util.
concurrent.ExecutionException
;
import
java.util.
stream.Collectors
;
import
java.util.stream.IntStream
;
import
java.util.stream.Stream
;
/**
* @author Peter Kurfer
...
...
@@ -55,6 +58,26 @@ public class App {
* at first get a page without an index to be able to extract the required pagination information
* afterwards you can iterate the remaining pages
* keep in mind that you should await the process as the user has to select canteen with a specific id */
OpenMensaAPI
api
=
OpenMensaAPIService
.
getInstance
().
getOpenMensaAPI
();
var
response
=
api
.
getCanteens
();
try
{
var
pageInfo
=
PageInfo
.
extractFromResponse
(
response
.
get
());
var
firstCanteenPage
=
response
.
get
().
body
();
var
N
=
pageInfo
.
getTotalCountOfPages
();
var
canteens
=
IntStream
.
range
(
2
,
N
).
parallel
()
.
mapToObj
((
n
)
->
api
.
getCanteens
(
n
).
join
())
.
flatMap
(
Collection:
:
stream
)
.
collect
(
Collectors
.
toList
());
canteens
.
addAll
(
0
,
firstCanteenPage
);
canteens
.
sort
(
Comparator
.
comparingInt
(
Canteen:
:
getId
));
//canteens = canteens.thenCombine(api.getCanteens(Integer.parseInt(pageN.get())), (l1, l2) -> Stream.concat(l1.parallelStream(), l2.parallelStream()))
canteens
.
forEach
((
c
)
->
System
.
out
.
println
(
c
.
toString
()));
}
catch
(
InterruptedException
|
ExecutionException
|
NumberFormatException
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
"WHYYYYYYYYYYy!!!!"
);
}
}
private
static
void
printMeals
()
{
...
...
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