-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a ViewFromTo Scheduler Fetching all Data at Once
We need it for the store-fhir-adapter in conjunction with Blaze. It doesn't have the upload dates of the Central Search and is capable to return all data at once.
- Loading branch information
1 parent
476ca27
commit dc4af06
Showing
15 changed files
with
217 additions
and
282 deletions.
There are no files selected for viewing
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
56 changes: 0 additions & 56 deletions
56
src/main/java/de/samply/share/client/quality/report/QualityReportConfigConstants.java
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
src/main/java/de/samply/share/client/quality/report/QualityReportSchedulerFormat.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package de.samply.share.client.quality.report; | ||
|
||
public enum QualityReportSchedulerFormat { | ||
YEAR, | ||
MONTH, | ||
ALL | ||
} |
95 changes: 20 additions & 75 deletions
95
src/main/java/de/samply/share/client/quality/report/views/fromto/ViewFromToFactory.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 | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,39 @@ | ||
package de.samply.share.client.quality.report.views.fromto; | ||
|
||
import de.samply.share.client.util.Utils; | ||
import java.util.Calendar; | ||
import java.util.Date; | ||
import java.util.GregorianCalendar; | ||
import static java.time.ZoneOffset.UTC; | ||
|
||
public class ViewFromToFactory { | ||
import java.time.LocalDate; | ||
import java.time.Year; | ||
import java.time.YearMonth; | ||
|
||
public class ViewFromToFactory { | ||
|
||
/** | ||
* Creates View between two dates. | ||
* Creates a view between the first day of {@code year} and the first day of the next year. | ||
* | ||
* @param from lower date. | ||
* @param to upper date. | ||
* @return View From - To. | ||
* @param year year. | ||
* @return View from-to. | ||
*/ | ||
public ViewFromTo createViewFromTo(Date from, Date to) { | ||
|
||
String fromS = convert(from); | ||
String toS = convert(to); | ||
|
||
return new ViewFromTo(fromS, toS); | ||
|
||
public ViewFromTo createYear(int year) { | ||
Year start = Year.of(year); | ||
return createViewFromTo(start.atDay(1), start.plusYears(1).atDay(1)); | ||
} | ||
|
||
/** | ||
* Create View between dates for first day to last day of month of a year. | ||
* Create a view between the first day of {@code month} in {@code year} and the first day of the | ||
* next month. | ||
* | ||
* @param month month. | ||
* @param year year. | ||
* @param month month. | ||
* @return View From-To. | ||
*/ | ||
public ViewFromTo createMonth(int month, int year) { | ||
|
||
Calendar calendarStart = createFirstDayOfMonth(month, year); | ||
Calendar calendarEnd = (Calendar) calendarStart.clone(); | ||
calendarEnd.add(Calendar.MONTH, 1); | ||
|
||
return createViewFromTo(calendarStart.getTime(), calendarEnd.getTime()); | ||
|
||
} | ||
|
||
/** | ||
* Create View between first day of a year and last day of the year. | ||
* | ||
* @param year year. | ||
* @return View from-to. | ||
*/ | ||
public ViewFromTo createYear(int year) { | ||
|
||
Calendar calendarStart = createFirstDayOfYear(year); | ||
Calendar calendarEnd = createFirstDayOfYear(year + 1); | ||
|
||
return createViewFromTo(calendarStart.getTime(), calendarEnd.getTime()); | ||
|
||
public ViewFromTo createMonth(int year, int month) { | ||
YearMonth start = YearMonth.of(year, month); | ||
return createViewFromTo(start.atDay(1), start.plusMonths(1).atDay(1)); | ||
} | ||
|
||
private Calendar createFirstDayOfYear(int year) { | ||
|
||
Calendar calendar = new GregorianCalendar(); | ||
calendar.set(Calendar.YEAR, year); | ||
calendar.set(Calendar.MONTH, Calendar.JANUARY); | ||
calendar.set(Calendar.DAY_OF_MONTH, 1); | ||
calendar.set(Calendar.HOUR_OF_DAY, 0); | ||
calendar.set(Calendar.MINUTE, 0); | ||
calendar.set(Calendar.SECOND, 0); | ||
|
||
return calendar; | ||
|
||
private ViewFromTo createViewFromTo(LocalDate from, LocalDate to) { | ||
return new ViewFromTo(from.atStartOfDay().toInstant(UTC).toString(), | ||
to.atStartOfDay().toInstant(UTC).toString()); | ||
} | ||
|
||
|
||
private Calendar createFirstDayOfMonth(int month, int year) { | ||
|
||
Calendar calendar = new GregorianCalendar(); | ||
calendar.set(Calendar.YEAR, year); | ||
calendar.set(Calendar.MONTH, month); | ||
|
||
calendar.set(Calendar.DAY_OF_MONTH, 1); | ||
calendar.set(Calendar.HOUR_OF_DAY, 0); | ||
calendar.set(Calendar.MINUTE, 0); | ||
calendar.set(Calendar.SECOND, 0); | ||
|
||
return calendar; | ||
|
||
} | ||
|
||
private String convert(Date date) { | ||
return Utils.convertDate2(date); | ||
} | ||
|
||
|
||
} |
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 | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,4 @@ | |
public interface ViewFromToScheduler { | ||
|
||
List<ViewFromTo> createViewFromTos(); | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
.../de/samply/share/client/quality/report/views/fromto/scheduler/ViewFromToSchedulerAll.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package de.samply.share.client.quality.report.views.fromto.scheduler; | ||
|
||
import de.samply.share.client.quality.report.views.fromto.ViewFromTo; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* A scheduler that always creates one {@link ViewFromTo} with a date range of 1900 - 2100. | ||
* | ||
* <p>It's meant to load all data at once. | ||
*/ | ||
public enum ViewFromToSchedulerAll implements ViewFromToScheduler { | ||
|
||
INSTANCE; | ||
|
||
@Override | ||
public List<ViewFromTo> createViewFromTos() { | ||
return Collections.singletonList(new ViewFromTo("1900-01-01T00:00:00+00:00", | ||
"2100-01-01T00:00:00+00:00")); | ||
} | ||
} |
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
Oops, something went wrong.