try {
IParsedMatchStrategy parsedBookSectionMatchStrategy = (IParsedMatchStrategy)NewDefaultInstance(Reference.class);
- addParsedReferenceMatchModes(parsedBookSectionMatchStrategy);
+ addParsedSectionReferenceMatchModes(parsedBookSectionMatchStrategy);
//author (or either title or authorship match, but usually only authorship is known for parsed instances)
parsedBookSectionMatchStrategy.setMatchMode("authorship", MatchMode.MATCH_REQUIRED, NewParsedTeamOrPersonInstance());
try {
IParsedMatchStrategy articleMatchStrategy = (IParsedMatchStrategy)NewDefaultInstance(Reference.class);
- addParsedReferenceMatchModes(articleMatchStrategy);
+ addParsedSectionReferenceMatchModes(articleMatchStrategy);
//if a title or abbrevTitle exists for the existing (first) article
//we can not guarantee that the article is really the one that is
}
/**
- * Adds all typical parsed reference match modes which are equal for journal, article,
- * book section, book (and generic?).
+ * Adds all typical parsed reference match modes which are equal for non section references
+ * (journal, book, (generic(?))).
* The following fields need to be handled explicitly by each calling method:<BR>
*
* <LI>authorship</LI>
* <LI>protectedAbbrevTitleCache</LI>
* <LI>inReference</LI>
*
+ * @see #addParsedSectionReferenceMatchModes(IParsedMatchStrategy)
* @param referenceMatchStrategy the strategy to fill
* @throws MatchException
*/
}
}
+ /**
+ * Adds all typical parsed reference match modes which are equal for section references
+ * (article, book section).
+ * The following fields need to be handled explicitly by each calling method:<BR>
+ *
+ * For further information see: #9157
+ *
+ * <LI>authorship</LI>
+ * <LI>title</LI>
+ * <LI>abbrevTitle</LI>
+ * <LI>titleCache</LI>
+ * <LI>abbrevTitleCache</LI>
+ * <LI>protectedTitleCache</LI>
+ * <LI>protectedAbbrevTitleCache</LI>
+ * <LI>inReference</LI>
+ *
+ * @see #addParsedReferenceMatchModes(IParsedMatchStrategy)
+ * @param referenceMatchStrategy the strategy to fill
+ * @throws MatchException
+ */
+ private static void addParsedSectionReferenceMatchModes(IParsedMatchStrategy referenceMatchStrategy) throws MatchException {
+
+ //"placePublished" should be MatchMode.EQUAL if parser parses place published
+ //TODO datePublished could also be more detailed in first then in second, e.g. Apr 2008 <-> 2008,
+ //something like MatchMode.IncludedIn is needed here
+ //TODO pages if a page number is given the parsed reference may not be unidentified anymore
+
+ //TODO externally managed
+
+ addParsedIdentifiableEntityModes(referenceMatchStrategy);
+
+ //here the result differs from addParsedReferenceMatchModes
+ String[] equalOrNullParams = new String[]{"accessed","doi",
+ "institution","isbn","issn","organization",
+ "pages","publisher","placePublished",
+ "referenceAbstract","school","uri"};
+ for(String param : equalOrNullParams){
+ referenceMatchStrategy.setMatchMode(param, MatchMode.EQUAL); //EQUAL !!
+ }
+
+ String[] equalParams = new String[]{"datePublished","edition",
+ "editor","seriesPart","volume"};
+ for(String param : equalParams){
+ referenceMatchStrategy.setMatchMode(param, MatchMode.EQUAL);
+ }
+ String[] matchOrNullParams = new String[]{"institution"};
+ for(String param : matchOrNullParams){
+ referenceMatchStrategy.setMatchMode(param, MatchMode.MATCH); //MATCH!!
+ }
+ }
+
private static void addParsedAgentBaseMatchModes(IParsedMatchStrategy matchStrategy) throws MatchException {
//FIXME adapt for inRef authors
import org.junit.BeforeClass;
import org.junit.Test;
+import eu.etaxonomy.cdm.common.DOI;
import eu.etaxonomy.cdm.model.agent.Institution;
import eu.etaxonomy.cdm.model.agent.Person;
import eu.etaxonomy.cdm.model.agent.Team;
parsedBook = getDefaultParsedBook();
Assert.assertTrue("Same abbrev. title should match",
matchStrategy.invoke(parsedBook, fullBook).isSuccessful());
+ fullBook.setDoi(DOI.fromString("10.1234/abc"));
+ Assert.assertTrue("DOI only with full book should match as abbrev title identifies the book",
+ matchStrategy.invoke(parsedBook, fullBook).isSuccessful());
//differing nom. title.
parsedBook.setAbbrevTitle("Wrong");
parsedBookSection = getDefaultParsedBookSection();
Assert.assertTrue("Only author, book and date published should match",
matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful() );
+ fullBookSection.setDoi(DOI.fromString("10.1234/abc"));
+ Assert.assertFalse("Full book section having additional parameters should not match if parsed article has no identifying parameter like (abbrev)title or page",
+ matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
+ fullBookSection.setDoi(null);
+ fullBookSection.setReferenceAbstract("My abstract");
+ Assert.assertFalse("Full book section having additional parameters should not match if parsed article has no identifying parameter like (abbrev)title or page",
+ matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
//should match
fullBookSection = getDefaultFullBookSection();
fullArticle = getMatchingFullArticle();
parsedArticle = getDefaultParsedArticle();
- Assert.assertTrue("Only author, book and date published should match",
- matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful() );
+ Assert.assertTrue("Having only paramters both have in common like author, book and date published "
+ + "should match", matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
+ fullArticle.setDoi(DOI.fromString("10.1234/abc"));
+ Assert.assertFalse("Full article having additional parameters should not match if parsed article has no identifying parameter like (abbrev)title or page",
+ matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
- //should match
+ //no match due to missing abbrev title match
fullArticle = getDefaultFullArticle();
Assert.assertFalse("Abbrev. title must be equal or null", matchStrategy.invoke(parsedArticle,
fullArticle).isSuccessful());
parsedArticle.setAbbrevTitle(fullArticle.getAbbrevTitle());
Assert.assertFalse("Still not match because pages are not equal (parsed is null)",
matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
+ //FIXME in future this should not fail, but parsed articles never have really pages, they only have page or a page span in the parsed detail which is not the same as the pages of the article
parsedArticle.setPages(fullArticle.getPages());
Assert.assertFalse("Now they should match",
matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());