- adapted method calls to cdmlib changes
authorPatric Plitzner <p.plitzner@bgbm.org>
Mon, 20 Oct 2014 08:21:56 +0000 (08:21 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Mon, 20 Oct 2014 08:21:56 +0000 (08:21 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/parser/ParseHandler.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/ReferenceSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/openurl/OpenUrlSelectorWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java

index 9fc72e2b883a582e44396a7c9be12fc2aa3bfa12..23e6825e38192a9c63de4dd6f5e2daa86db0c334 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * 
+ *
  */
 package eu.etaxonomy.taxeditor.parser;
 
@@ -29,10 +29,10 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
 public class ParseHandler{
 
        private TaxonNameBase taxonNameBase;
-       
+
        private class MatchMatrix {
                List<TaxonNameBase> duplicateNames = new ArrayList<TaxonNameBase>();
-               
+
                List<INomenclaturalReference> duplicateReferences = new ArrayList<INomenclaturalReference>();
                List<INomenclaturalReference> duplicateInReferences = new ArrayList<INomenclaturalReference>();
 
@@ -50,10 +50,10 @@ public class ParseHandler{
        private NonViralName name;
 
        private boolean doResolveInReferences;
-       
+
        /**
-        * Creates a new instance 
-        * 
+        * Creates a new instance
+        *
         * @param textWidget
         * @param name
         */
@@ -64,7 +64,7 @@ public class ParseHandler{
                        this.name = (NonViralName) HibernateProxyHelper.deproxy(name);
                }
        }
-       
+
        /**
         * Factory method to create a new instance of the this class
         *
@@ -74,9 +74,9 @@ public class ParseHandler{
         */
        public static ParseHandler NewInstance(TaxonNameBase name){
                return new ParseHandler(name);
-               
+
        }
-       
+
        /**
         * Parses a given string and returns a <code>TaxonNameBase</code> instance with the
         * results of the parsing.
@@ -95,17 +95,17 @@ public class ParseHandler{
 //             if (name.hasProblem()) {
 //                     name.setFullTitleCache(unparsedNameString);
 //             }
-               
+
                return name;
        }
-       
+
        public static TaxonNameBase parseName(String unparsedNameString, Rank rank){
                TaxonNameBase name = nonViralNameParser.parseFullName(unparsedNameString,
                                PreferencesUtil.getPreferredNomenclaturalCode(), rank);
-               
+
                return name;
        }
-       
+
        /**
         * Creates an empty <code>TaxonNameBase</code> instance with the nomenclatural code
         * currently set in preferences.
@@ -115,7 +115,7 @@ public class ParseHandler{
        public static TaxonNameBase createEmptyName(){
                return nonViralNameParser.getNonViralNameInstance("", PreferencesUtil.getPreferredNomenclaturalCode());
        }
-       
+
        /**
         * Parses the string that was entered into the text widget and returns a
         * NonViralName object that resulted from the parsing process.
@@ -123,7 +123,7 @@ public class ParseHandler{
         * @return      The parsed NonViralName object
         */
        public NonViralName parse(String unparsedNameString){
-               
+
 //             String unparsedNameString = "";
 //             try {
 //                     Method getText;
@@ -133,18 +133,18 @@ public class ParseHandler{
 //                     // we should never get here
 //                     StoreUtil.error(this.getClass(), "Error trying to invoke getText method", e);
 //             }
-               
-               
+
+
                nonViralNameParser.parseReferencedName(name, unparsedNameString,
                                name.getRank(), true);
 
 //             if (name.hasProblem()) {
 //                     name.setFullTitleCache(unparsedNameString);
 //             }
-               
+
                return name;
        }
-       
+
        /**
         * Parses the string that was entered into the text widget and returns a
         * NonViralName object that resulted from the parsing process.
@@ -157,39 +157,40 @@ public class ParseHandler{
         * @return      The parsed NonViralName object
         */
        public NonViralName parseAndResolveDuplicates(String unparsedNameString){
-               
+
                NonViralName parsedName = parse(unparsedNameString);
-               
+
                MatchMatrix matchMatrix = findMatches(parsedName);
-               
+
                resolveDuplicates(parsedName, matchMatrix);
-               
+
                return parsedName;
        }
-               
-       
-       
-       
-       /** 
+
+
+
+
+       /**
         * @param name The name to resolve duplicates for.
         */
        private void resolveDuplicates(NonViralName name, MatchMatrix matchMatrix) {
                resolveDuplicateNames(name, matchMatrix);
-               
+
                resolveAllDuplicateAuthors(name, matchMatrix);
-               
+
                resolveDuplicateReferences(name, matchMatrix);
-               
-               if(matchMatrix.duplicateInReferences != null)
-                       resolveDuplicateInReferences(name, matchMatrix);
+
+               if(matchMatrix.duplicateInReferences != null) {
+            resolveDuplicateInReferences(name, matchMatrix);
+        }
        }
 
 
-       /** 
+       /**
         * @param name The name to resolve duplicates for.
         */
        private void resolveDuplicateNames(NonViralName name, MatchMatrix matchMatrix) {
-                               
+
                if (matchMatrix.duplicateNames.size() == 1){
                        name = (NonViralName) matchMatrix.duplicateNames.iterator().next();
                }else if(matchMatrix.duplicateNames.size() > 1){
@@ -198,27 +199,27 @@ public class ParseHandler{
                }
        }
 
-       /** 
+       /**
         * @param name The name to resolve duplicates for.
         */
        private void resolveDuplicateReferences(NonViralName 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();  
+                       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);
-               }               
+               }
        }
 
-       /** 
+       /**
         * @param name The name to resolve duplicates for.
         */
        private void resolveDuplicateInReferences(NonViralName name, MatchMatrix matchMatrix) {
                Reference reference = (Reference) HibernateProxyHelper.deproxy(name.getNomenclaturalReference());
-               
+
                if(matchMatrix.duplicateInReferences.size() > 0){
                        Reference inReference = (Reference) matchMatrix.duplicateInReferences.iterator().next();
                        reference.setInReference(inReference);
@@ -227,58 +228,58 @@ public class ParseHandler{
                        MessagingUtils.warn(this.getClass(), reference.getTitleCache());
                }
        }
-       
 
-       /** 
+
+       /**
         * @param name The name to resolve duplicates for.
         */
        private void resolveAllDuplicateAuthors(NonViralName name, MatchMatrix matchMatrix) {
-               
+
                if(matchMatrix.duplicateCombinationAuthorTeams.size() > 0){
                        name.setCombinationAuthorTeam(matchMatrix.duplicateCombinationAuthorTeams.iterator().next());
                        Reference reference = (Reference) name.getNomenclaturalReference();
                        if(reference != null){
-                               reference.setAuthorTeam(matchMatrix.duplicateCombinationAuthorTeams.iterator().next());
+                               reference.setAuthorship(matchMatrix.duplicateCombinationAuthorTeams.iterator().next());
                        }
                        // FIXME TODO resolve multiple duplications. We use first match for a start.
                }
-               
+
                if(matchMatrix.duplicateExCombinationAuthorTeams.size() > 0){
                        name.setExCombinationAuthorTeam(matchMatrix.duplicateExCombinationAuthorTeams.iterator().next());
                        // FIXME TODO resolve multiple duplications. We use first match for a start.
                }
-               
+
                if(matchMatrix.duplicateBasionymAuthorTeams.size() > 0){
                        name.setBasionymAuthorTeam(matchMatrix.duplicateBasionymAuthorTeams.iterator().next());
                        // FIXME TODO resolve multiple duplications. We use first match for a start.
                }
-               
+
                if(matchMatrix.duplicateExBasionymAuthorTeams.size() > 0){
                        name.setExBasionymAuthorTeam(matchMatrix.duplicateExBasionymAuthorTeams.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(NonViralName name){
-               
+
                MatchMatrix matchMatrix = new MatchMatrix();
-               
+
                matchMatrix.duplicateNames = findMatchingLatinNames(name);
-               
-               matchMatrix.duplicateCombinationAuthorTeams = findMatchingAuthors((TeamOrPersonBase) name.getCombinationAuthorTeam());
-               matchMatrix.duplicateExCombinationAuthorTeams = findMatchingAuthors((TeamOrPersonBase) name.getExCombinationAuthorTeam());
-               matchMatrix.duplicateBasionymAuthorTeams = findMatchingAuthors((TeamOrPersonBase) name.getBasionymAuthorTeam());
-               matchMatrix.duplicateExBasionymAuthorTeams = findMatchingAuthors((TeamOrPersonBase) name.getExBasionymAuthorTeam());
-               
+
+               matchMatrix.duplicateCombinationAuthorTeams = findMatchingAuthors(name.getCombinationAuthorTeam());
+               matchMatrix.duplicateExCombinationAuthorTeams = findMatchingAuthors(name.getExCombinationAuthorTeam());
+               matchMatrix.duplicateBasionymAuthorTeams = findMatchingAuthors(name.getBasionymAuthorTeam());
+               matchMatrix.duplicateExBasionymAuthorTeams = findMatchingAuthors(name.getExBasionymAuthorTeam());
+
                INomenclaturalReference nomenclaturalReference = name.getNomenclaturalReference();
-               
-               // check if the reference has an inreference and also check if the inReference already exists 
+
+               // 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){
@@ -286,18 +287,20 @@ public class ParseHandler{
                                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>();
+               if(nomenclaturalReference == null) {
+            return new ArrayList<INomenclaturalReference>();
+        }
                try{
                        return CdmStore.getService(ICommonService.class).findMatching(nomenclaturalReference, MatchStrategyConfigurator.ReferenceMatchStrategy());
                }catch (MatchException e) {
@@ -315,7 +318,7 @@ public class ParseHandler{
                if(authorTeam == null){
                        return new ArrayList<TeamOrPersonBase>();
                }
-               
+
                try{
                        return CdmStore.getService(ICommonService.class).findMatching(authorTeam, MatchStrategyConfigurator.TeamOrPersonMatchStrategy());
                }catch (MatchException e) {
@@ -332,7 +335,7 @@ public class ParseHandler{
 
                try {
                        return CdmStore.getService(ICommonService.class).findMatching(taxonNameBase, MatchStrategyConfigurator.NonViralNameMatchStrategy());
-                       
+
                } catch (MatchException e) {
                        MessagingUtils.error(this.getClass(), "Error finding matching names", e);
                }
index db37406d42e9673f27a5e6c072bef21039db4c17..a4754ca91b16209fce35b94e9232401cd6015c84 100644 (file)
@@ -84,10 +84,10 @@ public class ReferenceSelectionDialog extends AbstractFilteredCdmResourceSelecti
        protected String getTitle(Reference cdmObject) {
                if(cdmObject == null){
                        return "";
-               }else if(cdmObject.getAuthorTeam() == null){
+               }else if(cdmObject.getAuthorship() == null){
                        return super.getTitle(cdmObject);
                }else{
-                       return ReferenceDefaultCacheStrategy.putAuthorToEndOfString(cdmObject.getTitleCache(), cdmObject.getAuthorTeam().getTitleCache());
+                       return ReferenceDefaultCacheStrategy.putAuthorToEndOfString(cdmObject.getTitleCache(), cdmObject.getAuthorship().getTitleCache());
                }
        }
 
index 12bcab92169b0318100cbe566bc56d8b9d09055a..3bacbb7a91485e9881d40888cb4297d64531af7f 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
@@ -31,48 +31,48 @@ import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
  * @version 1.0
  */
 public class OpenUrlSelectorWizard extends Wizard {
-       
-       private MobotOpenUrlServiceWrapper openUrlServiceWrapper;
 
-       private MobotOpenUrlQuery query;
-       
+       private final MobotOpenUrlServiceWrapper openUrlServiceWrapper;
+
+       private final MobotOpenUrlQuery query;
+
        private OpenUrlReference openUrlReference;
-       
-       private CdmFormFactory formFactory;
+
+       private final CdmFormFactory formFactory;
 
        private URI openUrlReferenceImageUri;
-       
-       private Reference reference;
-       
-       private String referenceDetail;
-       
-       
-       
+
+       private final Reference reference;
+
+       private final String referenceDetail;
+
+
+
        /**
-        * @param openUrlSelectorElement 
+        * @param openUrlSelectorElement
         * @param reference
         */
        public OpenUrlSelectorWizard(Reference reference, String referenceDetail) {
                if(reference == null){
                        throw new IllegalArgumentException("Reference may not be empty");
                }
-               
+
                this.reference = reference;
                this.referenceDetail = referenceDetail;
-               
+
                setWindowTitle("Mobot Open Url");
                setNeedsProgressMonitor(true);
-               
+
                formFactory = new CdmFormFactory(Display.getDefault());
-               
+
                openUrlServiceWrapper = new MobotOpenUrlServiceWrapper();
                openUrlServiceWrapper.setBaseUrl(PreferencesUtil.getPreferenceStore().getString(IPreferenceKeys.OPENURL_ACCESS_POINT));
-               
+
                query  = new MobotOpenUrlQuery();
-               
+
                query.refType = ReferenceType.getReferenceType(reference);
-               if(reference.getAuthorTeam() != null){
-                       query.authorName = reference.getAuthorTeam().getTitleCache();
+               if(reference.getAuthorship() != null){
+                       query.authorName = reference.getAuthorship().getTitleCache();
                }
                query.abbreviation = reference.getTitle();
                if(reference.getInReference() != null){
@@ -86,19 +86,19 @@ public class OpenUrlSelectorWizard extends Wizard {
                query.publicationPlace = reference.getPlacePublished();
                query.publisherName = reference.getPublisher();
                query.volume = reference.getVolume();
-               
+
                query.startPage = referenceDetail;
        }
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.jface.wizard.Wizard#addPages()
         */
        @Override
        public void addPages() {
-               
+
                addPage(new OpenUrlResultPage());
                addPage(new OpenUrlReferencePage());
-               
+
                super.addPages();
        }
 
index f497d941619b9b811ed108f61b26a8deafb70e47..31bd726b4aea5249f8ce22cc658bf36301a3497b 100644 (file)
@@ -129,7 +129,7 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
                selection_authorTeam = formFactory
                                .createSelectionElement(AgentBase.class,
                                                getConversationHolder(), formElement, "Author",
-                                               AuthorHelper.getAuthor(entity.getAuthorTeam()),
+                                               AuthorHelper.getAuthor(entity.getAuthorship()),
                                                EntitySelectionElement.ALL, style);
 
                ReferenceType referenceType = entity.getType();
@@ -398,7 +398,7 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
                }
                // selections
                else if (eventSource == selection_authorTeam) {
-                       getEntity().setAuthorTeam(
+                       getEntity().setAuthorship(
                                        (TeamOrPersonBase) selection_authorTeam.getSelection());
                } else if (eventSource == selection_inReference) {
                        getEntity().setInReference(selection_inReference.getSelection());