From 43f1207e7946d03abcf7c827dd51789f1ab78c27 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Wed, 22 Feb 2017 13:33:02 +0100
Subject: [PATCH] appointment type resolving conflicts improved

---
 .../main/java/smash/appointment/parse/AppointmentType.java    | 3 ++-
 .../src/main/java/smash/appointment/parse/CellParser.java     | 4 +++-
 .../src/main/java/smash/appointment/parse/Utils.java          | 2 +-
 .../src/test/java/smash/appointment/parse/CellParserTest.java | 4 +++-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/appointment-import/src/main/java/smash/appointment/parse/AppointmentType.java b/appointment-import/src/main/java/smash/appointment/parse/AppointmentType.java
index 9698bedc..af458ee0 100644
--- a/appointment-import/src/main/java/smash/appointment/parse/AppointmentType.java
+++ b/appointment-import/src/main/java/smash/appointment/parse/AppointmentType.java
@@ -15,7 +15,8 @@ public enum AppointmentType {
 	LEVEL_A(new String[] { "level A" }), //
 	LEVEL_B(new String[] { "evel B" }), //
 	LEVEL_B_M_POWER(new String[] { "mPower" }), // 
-	OTHER(new String[] {}), //
+	OTHER(new String[] {}), // 
+	LEVEL_BV_BG_SB_MPOWER(new String[] {"BV + BG + SB + mPower"}), //
 	;
 
 	private String[] queryStrings;
diff --git a/appointment-import/src/main/java/smash/appointment/parse/CellParser.java b/appointment-import/src/main/java/smash/appointment/parse/CellParser.java
index efc2e388..1cea5812 100644
--- a/appointment-import/src/main/java/smash/appointment/parse/CellParser.java
+++ b/appointment-import/src/main/java/smash/appointment/parse/CellParser.java
@@ -78,11 +78,13 @@ public class CellParser {
 								//new one is a substring of old
 							} else { //if there is no substring then we might have a problem
 								AppointmentType newType = result;
+								logger.warn(string+ "  ----- "+usedString);
 								if (usedString.length() < string.length()) {
-									result = type;
 									usedString = string;
+									newType = type;
 								}
 								logger.warn("More than one type possible for query: " + query + ". Type 1: " + result + ". Type 2: " + type + ". Choosing: " + newType);
+								result = newType;
 							}
 						}
 
diff --git a/appointment-import/src/main/java/smash/appointment/parse/Utils.java b/appointment-import/src/main/java/smash/appointment/parse/Utils.java
index 0667ea3e..916487ba 100644
--- a/appointment-import/src/main/java/smash/appointment/parse/Utils.java
+++ b/appointment-import/src/main/java/smash/appointment/parse/Utils.java
@@ -2,6 +2,6 @@ package smash.appointment.parse;
 
 public class Utils {
 	public static String simplifyString(String query) {
-		return query.replaceAll("[\\s\\-©]", "").toLowerCase();
+		return query.replaceAll("[\\s\\-©]", "").toLowerCase().replaceAll("\\(c\\)", "");
 	}
 }
diff --git a/appointment-import/src/test/java/smash/appointment/parse/CellParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/CellParserTest.java
index 40311eba..5c96c720 100644
--- a/appointment-import/src/test/java/smash/appointment/parse/CellParserTest.java
+++ b/appointment-import/src/test/java/smash/appointment/parse/CellParserTest.java
@@ -29,7 +29,9 @@ public class CellParserTest extends TestBase {
 		testCases.add(new CellParseTestCase("John Doe BV + BG + SB", johnDoe, null, AppointmentType.LEVEL_BV_BG_SB));
 		testCases.add(new CellParseTestCase("Kowalski-Nowak m-Power", janKowalskiNowak, null, AppointmentType.LEVEL_B_M_POWER));
 		testCases.add(new CellParseTestCase("ND0004 Name BV ©", cateKowalsky, null, AppointmentType.LEVEL_BV));
-		
+		testCases.add(new CellParseTestCase("ND0004 level BV (c) + SB ©", cateKowalsky, null, AppointmentType.LEVEL_BV_SB));
+		testCases.add(new CellParseTestCase("Cate Kowalsky level BV + BG + SB + m-Power", cateKowalsky, null, AppointmentType.LEVEL_BV_BG_SB_MPOWER));
+		testCases.add(new CellParseTestCase("sb name level A", null, null, AppointmentType.LEVEL_A));
 	}
 
 
-- 
GitLab