* <p>ParseHandler class.</p>
*
* @author n.hoffmann
+ * @author a.mueller
*/
public class ParseHandler{
-// private class MatchMatrix {
-//
-// List<TaxonName> duplicateNames = new ArrayList<>();
-// List<INomenclaturalReference> duplicateReferences = new ArrayList<>();
-// List<INomenclaturalReference> duplicateInReferences = new ArrayList<>();
-//
-// List<TeamOrPersonBase<?>> duplicateCombinationAuthorships = new ArrayList<>();
-// List<TeamOrPersonBase<?>> duplicateExCombinationAuthorships = new ArrayList<>();
-// List<TeamOrPersonBase<?>> duplicateBasionymAuthorships = new ArrayList<>();
-// List<TeamOrPersonBase<?>> duplicateExBasionymAuthorships = new ArrayList<>();
-// }
-
private static NonViralNameParserImpl nonViralNameParser = NonViralNameParserImpl.NewInstance();
/**
*/
private TaxonName name;
-// private boolean doResolveInReferences;
-
/**
* Creates a new instance
*/
*/
public INonViralName parseAndResolveDuplicates(String unparsedNameString){
-// INonViralName parsedName = parse(unparsedNameString);
-
- TaxonName parsedName2 = (TaxonName)CdmStore.getService(INameService.class).parseName(name, unparsedNameString, null, true, true).getCdmEntity();
-
-// MatchMatrix matchMatrix = findMatches(parsedName);
-//
-// resolveDuplicates(parsedName, matchMatrix);
-
- return parsedName2;
+ TaxonName parsedName = (TaxonName)CdmStore.getService(INameService.class).parseName(name, unparsedNameString, null, true, true).getCdmEntity();
+ return parsedName;
}
-// /**
-// * @param name The name to resolve duplicates for.
-// */
-// private void resolveDuplicates(INonViralName name, MatchMatrix matchMatrix) {
-// resolveDuplicateNames(name, matchMatrix);
-//
-// resolveAllDuplicateAuthors(name, matchMatrix);
-//
-// resolveDuplicateReferences(name, matchMatrix);
-//
-//// if(matchMatrix.duplicateInReferences != null) {
-//// resolveDuplicateInReferences(name, matchMatrix);
-//// }
-// }
-//
-//
-// /**
-// * @param name The name to resolve duplicates for.
-// */
-// private void resolveDuplicateNames(INonViralName name, MatchMatrix matchMatrix) {
-// //FIXME this has no effect yet as the new name is not used
-// if (matchMatrix.duplicateNames.size() == 1){
-// name = matchMatrix.duplicateNames.iterator().next();
-// }else if(matchMatrix.duplicateNames.size() > 1){
-// // FIXME TODO resolve multiple duplications. Use first match for a start
-// name = matchMatrix.duplicateNames.iterator().next();
-// }
-// }
-//
-// /**
-// * @param name The name to resolve duplicates for.
-// */
-// private void resolveDuplicateReferences(INonViralName name, MatchMatrix matchMatrix) {
-// if(matchMatrix.duplicateReferences.size() == 1){
-// // exactly one match. We assume that the user wants this reference
-// INomenclaturalReference duplicate = matchMatrix.duplicateReferences.iterator().next();
-// name.setNomenclaturalReference(duplicate);
-// }else if(matchMatrix.duplicateReferences.size() > 1){
-// // FIXME TODO resolve multiple duplications. Use first match for a start
-// INomenclaturalReference duplicate = matchMatrix.duplicateReferences.iterator().next();
-// name.setNomenclaturalReference(duplicate);
-// }
-// //if reference is new but the in reference is already in db
-// if (matchMatrix.duplicateReferences.size() == 0 && (name.getNomenclaturalReference() != null && name.getNomenclaturalReference().getInReference() != null) && matchMatrix.duplicateInReferences.size() > 0){
-// resolveDuplicateInReferences(name, matchMatrix);
-// }
-// }
-//
-// /**
-// * @param name The name to resolve duplicates for.
-// */
-// private void resolveDuplicateInReferences(INonViralName name, MatchMatrix matchMatrix) {
-// Reference reference = HibernateProxyHelper.deproxy(name.getNomenclaturalReference());
-//
-// if(matchMatrix.duplicateInReferences.size() > 0){
-// Reference inReference = (Reference) matchMatrix.duplicateInReferences.iterator().next();
-// reference.setInReference(inReference);
-// MessagingUtils.warn(this.getClass(), reference.generateTitle());
-// // FIXME TODO resolve multiple duplications. We use first match for a start
-// MessagingUtils.warn(this.getClass(), reference.getTitleCache());
-// }
-// }
-//
-//
-// /**
-// * @param name The name to resolve duplicates for.
-// */
-// private void resolveAllDuplicateAuthors(INonViralName name, MatchMatrix matchMatrix) {
-//
-// if(matchMatrix.duplicateCombinationAuthorships.size() > 0){
-// name.setCombinationAuthorship(matchMatrix.duplicateCombinationAuthorships.iterator().next());
-// Reference reference = name.getNomenclaturalReference();
-// if(reference != null){
-// reference.setAuthorship(matchMatrix.duplicateCombinationAuthorships.iterator().next());
-// }
-// // FIXME TODO resolve multiple duplications. We use first match for a start.
-// }
-//
-// if(matchMatrix.duplicateExCombinationAuthorships.size() > 0){
-// name.setExCombinationAuthorship(matchMatrix.duplicateExCombinationAuthorships.iterator().next());
-// // FIXME TODO resolve multiple duplications. We use first match for a start.
-// }
-//
-// if(matchMatrix.duplicateBasionymAuthorships.size() > 0){
-// name.setBasionymAuthorship(matchMatrix.duplicateBasionymAuthorships.iterator().next());
-// // FIXME TODO resolve multiple duplications. We use first match for a start.
-// }
-//
-// if(matchMatrix.duplicateExBasionymAuthorships.size() > 0){
-// name.setExBasionymAuthorship(matchMatrix.duplicateExBasionymAuthorships.iterator().next());
-// // FIXME TODO resolve multiple duplications. We use first match for a start.
-// }
-// }
-//
-// /**
-// * Splits a NonViralName into its parts and calls methods to find matches for these
-// * parts in the database.
-// *
-// * @param name The NonViralName to find matches for.
-// */
-// private MatchMatrix findMatches(INonViralName name){
-//
-// MatchMatrix matchMatrix = new MatchMatrix();
-//
-// matchMatrix.duplicateNames = findMatchingLatinNames(name);
-//
-// matchMatrix.duplicateCombinationAuthorships = findMatchingAuthors(name.getCombinationAuthorship());
-// matchMatrix.duplicateExCombinationAuthorships = findMatchingAuthors(name.getExCombinationAuthorship());
-// matchMatrix.duplicateBasionymAuthorships = findMatchingAuthors(name.getBasionymAuthorship());
-// matchMatrix.duplicateExBasionymAuthorships = findMatchingAuthors(name.getExBasionymAuthorship());
-//
-// INomenclaturalReference nomenclaturalReference = name.getNomenclaturalReference();
-//
-// // check if the reference has an inreference and also check if the inReference already exists
-// if(nomenclaturalReference != null){
-// Reference inReference = ((Reference)nomenclaturalReference).getInReference();
-// if(inReference != null){
-// doResolveInReferences = true;
-// matchMatrix.duplicateInReferences = findMatchingNomenclaturalReference(inReference);
-// }
-// }
-//
-// matchMatrix.duplicateReferences = findMatchingNomenclaturalReference(nomenclaturalReference);
-//
-// return matchMatrix;
-// }
-//
-// /**
-// * @param nomenclaturalReference The NomenclaturalReference to find matches for.
-// * @return A <code>List</code> of possibly matching NomenclaturalReference's.
-// */
-// private List<INomenclaturalReference> findMatchingNomenclaturalReference(INomenclaturalReference nomenclaturalReference) {
-// if(nomenclaturalReference == null) {
-// return new ArrayList<INomenclaturalReference>();
-// }
-// try{
-// return CdmStore.getCommonService().findMatching(nomenclaturalReference, MatchStrategy.Reference);
-// }catch (MatchException e) {
-// MessagingUtils.error(this.getClass(), "Error finding matching references", e);
-// }
-// return null;
-// }
-//
-// /**
-// * @param authorTeam The TeamOrPersonBase to find matches for.
-// * @return A <code>List</code> of possibly matching TeamOrPersonBase's.
-// */
-// private List<TeamOrPersonBase<?>> findMatchingAuthors(TeamOrPersonBase<?> authorTeam) {
-//
-// if(authorTeam == null){
-// return new ArrayList<>();
-// }
-// try{
-// return CdmStore.getCommonService().findMatching(authorTeam, MatchStrategy.TeamOrPerson);
-//
-// }catch (MatchException e) {
-// MessagingUtils.error(this.getClass(), "Error finding matching authors", e);
-// }
-// return null;
-// }
-//
-// /**
-// * @param taxonName The TaxonNameBase to find matches for.
-// * @return A <code>List</code> of possibly matching TaxonNameBase's.
-// */
-// private List<TaxonName> findMatchingLatinNames(ITaxonNameBase taxonName) {
-// try {
-// return CdmStore.getCommonService().findMatching(TaxonName.castAndDeproxy(taxonName), MatchStrategy.NonViralName);
-// } catch (MatchException e) {
-// MessagingUtils.error(this.getClass(), "Error finding matching names", e);
-// }
-// return null;
-// }
}