Skip to content

Commit

Permalink
Merge pull request #20 from BLCK-B/dev
Browse files Browse the repository at this point in the history
8.3
  • Loading branch information
BLCK-B authored May 30, 2024
2 parents cd17609 + 9b5c341 commit 83158f2
Show file tree
Hide file tree
Showing 47 changed files with 1,864 additions and 1,286 deletions.
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
}

group 'com.blck'
version '8.1'
version '8.3'

repositories {
mavenCentral()
Expand Down Expand Up @@ -53,16 +53,18 @@ application {

dependencies {

implementation 'org.xerial:sqlite-jdbc:3.45.2.0'
implementation 'org.xerial:sqlite-jdbc:3.46.0.0'
implementation 'org.jsoup:jsoup:1.17.2'
implementation 'com.typesafe:config:1.4.3'

testImplementation(platform('org.junit:junit-bom:5.10.2'))
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
testImplementation 'org.mockito:mockito-core:5.12.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.12.0'

implementation 'org.springframework.boot:spring-boot-starter-web:3.2.4'
testImplementation 'org.springframework.boot:spring-boot-starter-test:3.2.4'
implementation 'org.springframework.boot:spring-boot-starter-web:3.2.6'
testImplementation 'org.springframework.boot:spring-boot-starter-test:3.2.6'
}

bootJar {
Expand Down Expand Up @@ -98,5 +100,6 @@ tasks.jar {

test {
useJUnitPlatform()
jvmArgs("-XX:+EnableDynamicAgentLoading")
}

41 changes: 28 additions & 13 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,11 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,18 +198,28 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/blck/MusicReleaseTracker/ConfigTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public void readConfig(configOptions o) {
store.setThemes(themesMap);
}
case lastScrape -> store.setScrapeDate(config.getString("lastScrape"));
case longTimeout -> store.setLongTimeout(config.getBoolean("longTimeout"));
case isoDates -> store.setIsoDates(config.getBoolean("isoDates"));
case autoTheme -> store.setAutoTheme(config.getBoolean("autoTheme"));
}
Expand Down Expand Up @@ -113,9 +112,8 @@ public void updateSettings() {
VIP=false
}
theme=Black
accent=Classic
accent=Lavender
lastScrape=-
longTimeout=false
isoDates=false
autoTheme=true
""";
Expand Down
58 changes: 58 additions & 0 deletions src/main/java/com/blck/MusicReleaseTracker/Core/BeanConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.blck.MusicReleaseTracker.Core;

import com.blck.MusicReleaseTracker.*;
import com.blck.MusicReleaseTracker.DB.DBqueries;
import com.blck.MusicReleaseTracker.DB.ManageMigrateDB;
import com.blck.MusicReleaseTracker.Scraping.ScrapeProcess;
import com.blck.MusicReleaseTracker.FrontendAPI.SSEController;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/** config class for spring boot to manage lifecycle of the beans, this helps avoid static classes
each bean has a single instance, beans defined here can be used by other classes as dependencies */
@Configuration
public class BeanConfig {

@Bean
public ValueStore valueStore() {
return new ValueStore();
}

@Bean
public ErrorLogging errorLogging(ValueStore store) {
return new ErrorLogging(store);
}

@Bean
public ScrapeProcess scrapeProcess(ErrorLogging errorLogging, DBqueries dBqueries, SSEController sseController) {
return new ScrapeProcess(errorLogging, dBqueries, sseController);
}

@Bean
public GUIController guiController(ValueStore valueStore, ErrorLogging errorLogging,
ScrapeProcess scrapeProcess, ConfigTools config,
ManageMigrateDB manageMigrateDB, DBqueries dBqueries) {
return new GUIController(valueStore, errorLogging, scrapeProcess, config, dBqueries, manageMigrateDB);
}

@Bean
public ConfigTools configTools(ValueStore valueStore, ErrorLogging errorLogging) {
return new ConfigTools(valueStore, errorLogging);
}

@Bean
public ManageMigrateDB manageMigrateDB(ValueStore valueStore, ErrorLogging errorLogging) {
return new ManageMigrateDB(valueStore, errorLogging);
}

@Bean
public DBqueries dBqueries(ValueStore valueStore, ErrorLogging errorLogging, ConfigTools configTools, ManageMigrateDB manageMigrateDB) {
return new DBqueries(valueStore, errorLogging, configTools, manageMigrateDB);
}

@Bean
public StartSetup startSetup(ValueStore valueStore, ErrorLogging errorLogging) {
return new StartSetup(valueStore, errorLogging);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public void error(Exception e, Severity level, String message) {
FileHandler fileHandler = null;
try {
final String errorLogs = store.getErrorLogsPath();
// filehandler logging the error
fileHandler = new FileHandler(errorLogs, true);
fileHandler.setFormatter(new SimpleFormatter());
// clear log when it reaches approx 0.1 MB
Expand All @@ -50,7 +49,6 @@ public void error(Exception e, Severity level, String message) {
if (logFileSize > 100000) {
Files.write(path, new byte[0], StandardOpenOption.TRUNCATE_EXISTING);
}
// log the error
logger.addHandler(fileHandler);
switch (level) {
case SEVERE -> logger.log(Level.SEVERE, message, e);
Expand All @@ -63,7 +61,7 @@ public void error(Exception e, Severity level, String message) {
fileHandler.close();
}
if (level == Severity.SEVERE) {
throw new RuntimeException(e);
System.exit(1);
}
}
}
50 changes: 0 additions & 50 deletions src/main/java/com/blck/MusicReleaseTracker/Core/MRTConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.blck.MusicReleaseTracker.Core;

/** an important enum used throughout the backend */
/** a central enum declaring web sources */
public enum SourcesEnum {
beatport,
musicbrainz,
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/com/blck/MusicReleaseTracker/Core/ValueStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ public ValueStore() {
private ArrayList<String> filterWords;
private Map<String,String> themesMap;
private String scrapeDate;
private boolean longTimeout = false;
private boolean isoDates = false;
private boolean autoTheme = false;
private int timeout = 25000;

public void setAppDataPath(String appDataPath) {
this.appDataPath = appDataPath;
Expand Down Expand Up @@ -78,12 +76,6 @@ public void setScrapeDate(String scrapeDate) {
public String getScrapeDate() {
return scrapeDate;
}
public void setLongTimeout(boolean longTimeout) {
this.longTimeout = longTimeout;
}
public int getTimeout() {
return longTimeout ? timeout + 55000 : timeout;
}
public void setIsoDates(boolean isoDates) {
this.isoDates = isoDates;
}
Expand All @@ -96,10 +88,6 @@ public void setAutoTheme(boolean autoTheme) {
public boolean getAutoTheme() {
return autoTheme;
}
// for testing
public void setTimeout(int timeout) {
this.timeout = timeout;
}

@Override
public String toString() {
Expand Down
Loading

0 comments on commit 83158f2

Please sign in to comment.