added launch arguments

This commit is contained in:
s5260822 2025-03-13 16:59:11 +01:00
parent 1c88da9883
commit 290b17080e

View file

@ -18,27 +18,35 @@ public class Main {
public static final String RESOURCES_DIR="src/main/resources/";
public static boolean UPLOAD_MEMBER_PHOTOS;
public static boolean FORCE_UPLOAD_MEMBERS;
public static boolean FORCE_UPLOAD_SPEECHES;
private static final FileObjectFactory xmlFactory = FileObjectFactory.getFactory();
private static final MongoObjectFactory mongoFactory = MongoObjectFactory.getFactory();
private static final SpeechParser speechParser = new SpeechParser();
public static void main(String[] args) throws Exception {
UPLOAD_MEMBER_PHOTOS = Arrays.asList(args).contains("uploadMemberPhotos");
FORCE_UPLOAD_MEMBERS = Arrays.asList(args).contains("forceUploadMembers");
FORCE_UPLOAD_SPEECHES = Arrays.asList(args).contains("forceUploadSpeeches");
System.out.println("Starting Speech Indexer...");
System.out.println("--------------------------");
System.out.println("Arguments:");
System.out.println(" - Upload the Member Photos to the DB: " + UPLOAD_MEMBER_PHOTOS);
System.out.println(" - Force Upload Members: " + FORCE_UPLOAD_MEMBERS);
System.out.println(" - Force Upload Speeches: " + FORCE_UPLOAD_SPEECHES);
System.out.println("--------------------------");
//TEST
MongoDBHandler mongoDBHandler = new MongoDBHandler();
SpeechIndexFactoryImpl speechIndexFactory = new SpeechIndexFactoryImpl();
if (mongoDBHandler.getDatabase().getCollection(MongoPprUtils.SPEECH_COLLECTION_NAME).countDocuments() != 0) {
}
else {
if ((mongoDBHandler.getDatabase().getCollection(MongoPprUtils.SPEECH_COLLECTION_NAME).countDocuments() != 0) && !FORCE_UPLOAD_SPEECHES) {
Logger.info("Skipping Speech parsing and DB insertion as they are already present...");
} else {
Logger.pink("Deleting all speeches from DB if existing...");
mongoDBHandler.deleteSpeechRelatedDocuments();
Logger.pink("Parsing XML and inserting data into DB (Uebung 2)...");
SpeechIndex speechIndex = speechIndexFactory
.parseLegislativePeriods(TRUE)