Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/old filmlist rw #159

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@ public class FilmlistManager extends MessageCreator {
private static final Logger LOG = LogManager.getLogger(FilmlistManager.class);
private static final String TEMP_ENDING = "_TEMP";
private static FilmlistManager instance;
private final FilmlistOldFormatWriter filmlistOldFormatWriter;
private final FilmlistWriter filmlistWriter;


private FilmlistManager() {
super();
filmlistOldFormatWriter = new FilmlistOldFormatWriter();
filmlistWriter = new FilmlistWriter();
}

public static FilmlistManager getInstance() {
Expand Down Expand Up @@ -107,11 +104,13 @@ public boolean save(
final FilmlistFormats aFormat, final Filmlist aFilmlist, final Path aSavePath) {
try {
publishMessage(LibMessages.FILMLIST_WRITE_STARTED, aSavePath);
filmlistWriter.addAllMessageListener(messageListeners);
filmlistOldFormatWriter.addAllMessageListener(messageListeners);
if (aFormat.isOldFormat()) {
final FilmlistOldFormatWriter filmlistOldFormatWriter = new FilmlistOldFormatWriter();
filmlistOldFormatWriter.addAllMessageListener(messageListeners);
return save(filmlistOldFormatWriter, aFormat, aFilmlist, aSavePath);
} else {
final FilmlistWriter filmlistWriter = new FilmlistWriter();
filmlistWriter.addAllMessageListener(messageListeners);
return save(filmlistWriter, aFormat, aFilmlist, aSavePath);
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ public Optional<Filmlist> read(InputStream aInputStream) {
long start = System.currentTimeMillis();
Filmlist filmlist = new Filmlist();
debug = "LINE " + cnt;
//

// these must be reset for each loading run
this.sender = "";
this.thema = "";
this.cnt = 0;
try (JsonReader jsonReader = new JsonReader(new InputStreamReader(aInputStream, StandardCharsets.UTF_8)))
{
headerMeta(jsonReader, filmlist);
Expand All @@ -67,7 +69,6 @@ public Optional<Filmlist> read(InputStream aInputStream) {
throw(e);
}
}
cnt++;
}
} catch (IOException e) {
LOG.error(e);
Expand Down Expand Up @@ -248,25 +249,25 @@ private Optional<URL> rebuildUrl(URL urlNromal, String targetUrl) {

////////////////////////////////////////////////////////////

protected String readRecord01Sender(String in, String sender) {
private String readRecord01Sender(String in, String sender) {
if (!in.isBlank()) {
sender = in;
}
return sender;
}

protected String readRecord02Thema(String in, String thema) {
private String readRecord02Thema(String in, String thema) {
if (!in.isBlank()) {
thema = in;
}
return thema;
}

protected String readRecord03Titel(String in) {
private String readRecord03Titel(String in) {
return in;
}

protected LocalDate readRecord04Datum(String in) {
private LocalDate readRecord04Datum(String in) {
if (StringUtils.isNotBlank(in)) {
try {
return LocalDate.parse(in, DATE_FORMATTER);
Expand All @@ -277,7 +278,7 @@ protected LocalDate readRecord04Datum(String in) {
return DEFAULT_DATE;
}

protected LocalTime readRecord05Zeit(String in) {
private LocalTime readRecord05Zeit(String in) {
if (StringUtils.isNotBlank(in)) {
try {
return LocalTime.parse(in, TIME_FORMATTER);
Expand All @@ -288,7 +289,7 @@ protected LocalTime readRecord05Zeit(String in) {
return LocalTime.MIDNIGHT;
}

protected Duration readRecord06Dauer(String in) {
private Duration readRecord06Dauer(String in) {
if (StringUtils.isNotBlank(in)) {
try {
return Duration.between(LocalTime.MIDNIGHT, LocalTime.parse(in));
Expand All @@ -299,7 +300,7 @@ protected Duration readRecord06Dauer(String in) {
return Duration.ZERO;
}

protected long readRecord07Groesse(String in) {
private long readRecord07Groesse(String in) {
if (StringUtils.isNotBlank(in)) {
try {
return Long.parseLong(in)*1024; // oldFilmlist format is MB - new DM is KB
Expand All @@ -310,11 +311,11 @@ protected long readRecord07Groesse(String in) {
return 0L;
}

protected String readRecord08Beschreibung(String in) {
private String readRecord08Beschreibung(String in) {
return in;
}

protected URL readRecord09Url(String in) {
private URL readRecord09Url(String in) {
if (!in.isBlank()) {
try {
return new URL(in);
Expand All @@ -325,7 +326,7 @@ protected URL readRecord09Url(String in) {
return null;
}

protected URL readRecord10Website(String in) {
private URL readRecord10Website(String in) {
if (!in.isBlank() && in.startsWith("http")) {
try {
return new URL(in);
Expand All @@ -336,7 +337,7 @@ protected URL readRecord10Website(String in) {
return null;
}

protected URL readRecord11Untertitel(String in) {
private URL readRecord11Untertitel(String in) {
if (!in.isBlank() && in.startsWith("http")) {
try {
return new URL(in);
Expand All @@ -347,35 +348,35 @@ protected URL readRecord11Untertitel(String in) {
return null;
}

protected String readRecord12UrlRTMP(String in) {
private String readRecord12UrlRTMP(String in) {
return in;
}

protected String readRecord13UrlKlein(String in) {
private String readRecord13UrlKlein(String in) {
return in;
}

protected String readRecord14UrlRTMPKlein(String in) {
private String readRecord14UrlRTMPKlein(String in) {
return in;
}
protected String readRecord15UrlHD(String in) {

private String readRecord15UrlHD(String in) {
return in;
}

protected String readRecord16UrlRTMPHD(String in) {
private String readRecord16UrlRTMPHD(String in) {
return in;
}

protected String readRecord17DatumL(String in) {
private String readRecord17DatumL(String in) {
return in;
}

protected String readRecord18UrlHistory(String in) {
private String readRecord18UrlHistory(String in) {
return in;
}

protected Collection<GeoLocations> readRecord19Geo(String in) {
private Collection<GeoLocations> readRecord19Geo(String in) {
final Collection<GeoLocations> geoLocations = new ArrayList<>();

final GeoLocations singleGeoLocation = GeoLocations.getFromDescription(in);
Expand All @@ -393,7 +394,7 @@ protected Collection<GeoLocations> readRecord19Geo(String in) {
return geoLocations;
}

protected Boolean readRecord20Neu(String in) {
private Boolean readRecord20Neu(String in) {
return Boolean.parseBoolean(in);
}

Expand Down
Loading
Loading