Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PLANNER-1168 conference scheduling devoxx rest api (#407)
* PLANNER-1168: Setup and create Importer class * Implement importer methods * Check response code and redirect the request if necessary * Fix start/endDateTime zoneId in timeslot * Implement importing timeslots and update talks accordingly * Fix managed dependency issue and import talkTypes properly * Aggregate timeslots that start and end at same time, and implement a workaround inconsistent data in DevoxxFr * Add breaks as talks and fix talkTypes for rooms * Add room tag sets for rooms and talks according to room size and talk type * Use lambda function to get JsonObject and JsonArray and refactor checking redirects into a utility class" * Add trackId endpoint and use trackId instead of track description * Add tests for ConnectionFollowRedirects * Clean-up ConnectionFollowRedirectsTest * Close unused inputStream in ConnectionFollowRedirectsTest * Exclude duplicate dependency from mockserver-netty * Downgrade javax.json to workarount IllegalArgumentException issue Scout24/illegal-transitive-dependency-check#30 * Fix typos and style * Add workaround for missing speakers in DevoxxBE18 * Replace e.printStackTrace by logging an error * Move dependencyManagement to parent pom * Workaround to read talks from local file * Get timeslot's talkTypes from timeslot's slotId * Import talk's contentTag and add statistics * Remove RESTEndpoints class and replace its fields with local variables * Initialize new Talk's fields * Convert score to HardMediumSoft and make MutuallyExclusiveTalks a medium constraint * Color cells with negative mediumScore with mediumPenaltyStyle * Convert Talk mutually-exclusive-talks to a medium and soft constraint * Update importer to new version of talks * Write another roomView with rooms as columns * Replace roomView 2 with separate view sheet per day * Color printed views according to theme tracks * Fix printing daysSheets even if some talks aren't scheduled * Abbreviate title in DaysView * Remove mock-server dependency * Fix typo in configuration sheet * Fix typo in test xlsx file
- Loading branch information
1 parent
eb68bc0
commit fb8f167
Showing
18 changed files
with
845 additions
and
50 deletions.
There are no files selected for viewing
Binary file modified
BIN
+4.88 KB
(110%)
optaplanner-examples/data/conferencescheduling/unsolved/108talks-18timeslots-10rooms.xlsx
Binary file not shown.
Binary file modified
BIN
+2.37 KB
(110%)
optaplanner-examples/data/conferencescheduling/unsolved/18talks-6timeslots-5rooms.xlsx
Binary file not shown.
Binary file modified
BIN
+4.84 KB
(110%)
optaplanner-examples/data/conferencescheduling/unsolved/216talks-18timeslots-20rooms.xlsx
Binary file not shown.
Binary file modified
BIN
+3.61 KB
(110%)
optaplanner-examples/data/conferencescheduling/unsolved/36talks-12timeslots-5rooms.xlsx
Binary file not shown.
Binary file modified
BIN
+3.58 KB
(110%)
optaplanner-examples/data/conferencescheduling/unsolved/72talks-12timeslots-10rooms.xlsx
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
576 changes: 576 additions & 0 deletions
576
...nner/examples/conferencescheduling/persistence/ConferenceSchedulingCfpDevoxxImporter.java
Large diffs are not rendered by default.
Oops, something went wrong.
138 changes: 119 additions & 19 deletions
138
...optaplanner/examples/conferencescheduling/persistence/ConferenceSchedulingXlsxFileIO.java
Large diffs are not rendered by default.
Oops, something went wrong.
91 changes: 91 additions & 0 deletions
91
.../org/optaplanner/examples/conferencescheduling/persistence/ConnectionFollowRedirects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,91 @@ | |||
/* | |||
* Copyright 2018 Red Hat, Inc. and/or its affiliates. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
// credits for https://www.cs.mun.ca/java-api-1.5/guide/deployment/deployment-guide/upgrade-guide/article-17.html | |||
|
|||
package org.optaplanner.examples.conferencescheduling.persistence; | |||
|
|||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.net.HttpURLConnection; | |||
import java.net.URL; | |||
import java.net.URLConnection; | |||
|
|||
public class ConnectionFollowRedirects { | |||
|
|||
private URLConnection connection; | |||
private boolean isRedirect; | |||
private int redirects = 0; | |||
|
|||
public ConnectionFollowRedirects(String url) throws IOException { | |||
this.connection = new URL(url).openConnection(); | |||
} | |||
|
|||
public URLConnection getConnection() { | |||
return connection; | |||
} | |||
|
|||
public int getRedirects() { | |||
return redirects; | |||
} | |||
|
|||
public InputStream getInputStream() throws IOException { | |||
InputStream in = null; | |||
do { | |||
if (connection instanceof HttpURLConnection) { | |||
((HttpURLConnection) connection).setInstanceFollowRedirects(false); | |||
} | |||
// We want to open the input stream before getting headers | |||
// because getHeaderField() et al swallow IOExceptions. | |||
in = connection.getInputStream(); | |||
followRedirects(); | |||
} | |||
while (isRedirect); | |||
return in; | |||
} | |||
|
|||
private void followRedirects() throws IOException { | |||
isRedirect = false; | |||
if (connection instanceof HttpURLConnection) { | |||
HttpURLConnection http = (HttpURLConnection) connection; | |||
int stat = http.getResponseCode(); | |||
if (stat >= 300 && stat <= 307 && stat != 306 && | |||
stat != HttpURLConnection.HTTP_NOT_MODIFIED) { | |||
redirectConnection(http); | |||
} | |||
} | |||
} | |||
|
|||
private void redirectConnection(HttpURLConnection http) throws IOException { | |||
URL base = http.getURL(); | |||
String location = http.getHeaderField("Location"); | |||
URL target = null; | |||
if (location != null) { | |||
target = new URL(base, location); | |||
} | |||
http.disconnect(); | |||
// Redirection should be allowed only for HTTP and HTTPS | |||
// and should be limited to 5 redirections at most. | |||
if (target == null || !(target.getProtocol().equals("http") | |||
|| target.getProtocol().equals("https")) | |||
|| redirects >= 5) { | |||
throw new SecurityException("illegal URL redirect"); | |||
} | |||
isRedirect = true; | |||
connection = target.openConnection(); | |||
redirects++; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-257 Bytes
(100%)
.../optaplanner/examples/conferencescheduling/solver/testConferenceSchedulingScoreRules.xlsx
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters