* for authorship of {@link eu.etaxonomy.cdm.model.reference.Reference references} or of {@link eu.etaxonomy.cdm.model.name.TaxonNameBase taxon names}.
*
* @author a.mueller
- * @version 1.0
* @created 17-APR-2008
*/
@XmlAccessorType(XmlAccessType.FIELD)
public class TaxonNameComparator implements Comparator<TaxonNameBase>, Serializable {\r
private static final long serialVersionUID = -1007495803322700031L;\r
\r
- public int compare(TaxonNameBase arg0, TaxonNameBase arg1) {\r
+ @Override\r
+ public int compare(TaxonNameBase arg0, TaxonNameBase arg1) {\r
if (arg0.equals(arg1)){\r
return 0;\r
}\r
- \r
+\r
String nameCacheOfArg0 = arg0.getTitleCache();\r
String nameCacheOfArg1 = arg1.getTitleCache();\r
- \r
+\r
int result = nameCacheOfArg0.compareToIgnoreCase(nameCacheOfArg1);\r
if (result != 0){\r
return result;\r
}else{\r
return arg0.getUuid().compareTo(arg1.getUuid());\r
}\r
- \r
+\r
}\r
\r
}
* @date 24.06.2009\r
*\r
*/\r
-//@Component\r
public class TaxonNodeByNameComparator extends AbstractStringComparator<TaxonNode> implements Comparator<TaxonNode>, ITaxonNodeComparator<TaxonNode> {\r
\r
private static final String HYBRID_SIGN = "\u00D7";\r
*
* 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.
-*/
+*/
package eu.etaxonomy.cdm.model.view.context;
import org.springframework.util.Assert;
/**
- * Class based heavily on GlobalSecurityContextHolderStrategy, part
- * of spring-security, but instead binding a View object to the
- * context.
- *
+ * Class based heavily on GlobalSecurityContextHolderStrategy, part
+ * of spring-security, but instead binding a View object to the
+ * context.
+ *
* @author ben
*
*/
public class GlobalAuditEventContextHolderStrategy implements
AuditEventContextHolderStrategy {
-
+
private static AuditEventContext contextHolder;
- public void clearContext() {
+ @Override
+ public void clearContext() {
contextHolder = null;
}
- public AuditEventContext getContext() {
+ @Override
+ public AuditEventContext getContext() {
if (contextHolder == null) {
contextHolder = new AuditEventContextImpl();
}
return contextHolder;
}
- public void setContext(AuditEventContext context) {
+ @Override
+ public void setContext(AuditEventContext context) {
Assert.notNull(context, "Only non-null AuditEventContext instances are permitted");
contextHolder = context;
}
*
* 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.
-*/
+*/
package eu.etaxonomy.cdm.model.view.context;
import org.springframework.util.Assert;
/**
- * Class based heavily on InheritableThreadLocalSecurityContextHolderStrategy, part
- * of spring-security, but instead binding a View object to the
+ * Class based heavily on InheritableThreadLocalSecurityContextHolderStrategy, part
+ * of spring-security, but instead binding a View object to the
* context.
- *
+ *
* @author ben
* @author Ben Alex
*
*/
public class InheritableThreadLocalAuditEventContextHolderStrategy implements
AuditEventContextHolderStrategy {
-
- private static ThreadLocal contextHolder = new InheritableThreadLocal();
- public void clearContext() {
+ private static ThreadLocal<AuditEventContext> contextHolder = new InheritableThreadLocal<AuditEventContext>();
+
+ @Override
+ public void clearContext() {
contextHolder.set(null);
}
- public AuditEventContext getContext() {
+ @Override
+ public AuditEventContext getContext() {
if (contextHolder.get() == null) {
contextHolder.set(new AuditEventContextImpl());
}
- return (AuditEventContext) contextHolder.get();
+ return contextHolder.get();
}
- public void setContext(AuditEventContext context) {
+ @Override
+ public void setContext(AuditEventContext context) {
Assert.notNull(context, "Only non-null AuditEventContext instances are permitted");
contextHolder.set(context);
}
*
* 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.
-*/
+*/
package eu.etaxonomy.cdm.model.view.context;
import org.springframework.util.Assert;
/**
- * Class based heavily on ThreadLocalSecurityContextHolderStrategy, part
- * of spring-security, but instead binding a View object to the
+ * Class based heavily on ThreadLocalSecurityContextHolderStrategy, part
+ * of spring-security, but instead binding a View object to the
* context.
- *
+ *
* @author ben
* @author Ben Alex
*
AuditEventContextHolderStrategy {
private static ThreadLocal contextHolder = new ThreadLocal();
-
- public void clearContext() {
+
+ @Override
+ public void clearContext() {
contextHolder.set(null);
}
- public AuditEventContext getContext() {
+ @Override
+ public AuditEventContext getContext() {
if (contextHolder.get() == null) {
contextHolder.set(new AuditEventContextImpl());
}
-
+
return (AuditEventContext) contextHolder.get();
}
- public void setContext(AuditEventContext context) {
+ @Override
+ public void setContext(AuditEventContext context) {
Assert.notNull(context, "Only non-null AuditEventContext instances are permitted");
contextHolder.set(context);
}
/**\r
- * \r
+ *\r
*/\r
package eu.etaxonomy.cdm.strategy.cache;\r
\r
\r
/**\r
* Rules to define tagging for HTML tagged string output.\r
- * \r
+ *\r
* @author a.mueller\r
* @created 14/02/2012\r
*\r
public class HTMLTagRules {\r
\r
private List<TagRule> rules = new ArrayList<HTMLTagRules.TagRule>();\r
- \r
+\r
private class TagRule{\r
private TagRule(TagEnum type, String htmlTag){this.type = type; this.htmlTag = htmlTag;}\r
private TagEnum type;\r
// public String getString(){return this.htmlTag;}\r
@Override public String toString(){return type.name() + "-><" + htmlTag + ">";}\r
}\r
- \r
- \r
+\r
+\r
public HTMLTagRules addRule(TagEnum type, String htmlTag){\r
if (type == null || htmlTag == null){\r
throw new NullPointerException("Null tpye or htmlTag not allowed for HTMLTagRule");\r
rules.add(new TagRule(type, htmlTag));\r
return this;\r
}\r
- \r
+\r
public SortedSet<String> getRule(TagEnum type){\r
SortedSet<String> result = new TreeSet<String>();\r
for (TagRule rule : rules){\r
}\r
return result;\r
}\r
- \r
+\r
public boolean hasRule(TagEnum type, String htmlTag){\r
for (TagRule rule : rules){\r
if (rule.type.equals(type) && htmlTag.equals(htmlTag)){\r
}\r
return false;\r
}\r
- \r
+\r
@Override\r
public String toString(){\r
String result = "HTMLTagRules[";\r
result = result.substring(0, result.length() -1) + "]";\r
return result;\r
}\r
- \r
- \r
+\r
+\r
}\r
/**\r
* Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \r
+*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
/**\r
* A default cache strategy for institutions.\r
* TODO This is a preliminary implementation to have at least one default cache strategy.\r
- * Maybe it will need improvement later on. \r
+ * Maybe it will need improvement later on.\r
* @author a.mueller\r
* @date 07.04.2010\r
*\r
private static final long serialVersionUID = 4586884860596045736L;\r
@SuppressWarnings("unused")\r
private static final Logger logger = Logger.getLogger(Collection.class);\r
- \r
+\r
public static UUID uuid = UUID.fromString("20a61a6f-aac9-422e-a95f-20dfacd35b65");\r
- \r
- \r
+\r
+\r
/* (non-Javadoc)\r
* @see eu.etaxonomy.cdm.strategy.StrategyBase#getUuid()\r
*/\r
/* (non-Javadoc)\r
* @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy#getTitleCache(eu.etaxonomy.cdm.model.common.IdentifiableEntity)\r
*/\r
- public String getTitleCache(Institution institution) {\r
+ @Override\r
+ public String getTitleCache(Institution institution) {\r
if (institution == null){\r
return null;\r
}else{\r
*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/ \r
+*/\r
\r
package eu.etaxonomy.cdm.strategy.cache.common;\r
\r
import eu.etaxonomy.cdm.strategy.StrategyBase;\r
\r
public class IdentifiableEntityDefaultCacheStrategy<T extends IdentifiableEntity> extends StrategyBase implements IIdentifiableEntityCacheStrategy<T> {\r
- @SuppressWarnings("unused")\r
+ private static final long serialVersionUID = -6358630407241112369L;\r
+\r
+ @SuppressWarnings("unused")\r
private static final Logger logger = Logger.getLogger(IdentifiableEntityDefaultCacheStrategy.class);\r
\r
final static UUID uuid = UUID.fromString("85cbecb0-2020-11de-8c30-0800200c9a66");\r
- \r
- public String getTitleCache(T object) {\r
+\r
+ @Override\r
+ public String getTitleCache(T object) {\r
return "-title cache generation not implemented-";\r
}\r
\r
/**\r
* Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \r
+*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
*\r
*/\r
public class TermDefaultCacheStrategy<T extends TermBase> extends IdentifiableEntityDefaultCacheStrategy<T> implements IIdentifiableEntityCacheStrategy<T> {\r
- /**\r
- * \r
- */\r
private static final long serialVersionUID = 7687293307791110547L;\r
\r
@SuppressWarnings("unused")\r
private static final Logger logger = Logger.getLogger(TermDefaultCacheStrategy.class);\r
- \r
+\r
final static UUID uuid = UUID.fromString("9cdf52c1-bac4-4b6c-a7f9-1a87401bd8f9");\r
- \r
+\r
@Override\r
protected UUID getUuid() {\r
return uuid;\r
*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/ \r
+*/\r
\r
package eu.etaxonomy.cdm.strategy.cache.description;\r
\r
\r
public class SpecimenDescriptionDefaultCacheStrategy extends StrategyBase implements\r
IIdentifiableEntityCacheStrategy<SpecimenDescription> {\r
+ private static final long serialVersionUID = 310092633142719872L;\r
+\r
+ final static UUID uuid = UUID.fromString("73c03fc4-0429-4ca1-b2cb-b9a56aad4d22");\r
\r
- final static UUID uuid = UUID.fromString("73c03fc4-0429-4ca1-b2cb-b9a56aad4d22");\r
- \r
@Override\r
protected UUID getUuid() {\r
return uuid;\r
}\r
\r
- public String getTitleCache(SpecimenDescription specimenDescription) {\r
+ @Override\r
+ public String getTitleCache(SpecimenDescription specimenDescription) {\r
String title;\r
- SpecimenOrObservationBase specimen = specimenDescription.getDescribedSpecimenOrObservation(); \r
+ SpecimenOrObservationBase specimen = specimenDescription.getDescribedSpecimenOrObservation();\r
if (specimen == null){\r
title = getFirstPart(specimenDescription);\r
title = title.replace(" for ", "");\r
}\r
return title;\r
}\r
- \r
+\r
private String getFirstPart(SpecimenDescription specimenDescription){\r
Set<Marker> markers = specimenDescription.getMarkers();\r
MarkerType markerType = MarkerType.USE();\r
if(marker.getMarkerType().equals(markerType)) {\r
isUseDescription = true;\r
}\r
- } \r
+ }\r
if (specimenDescription.isImageGallery()){\r
return "Image gallery for " ;\r
} else if (isUseDescription) {\r
*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/ \r
+*/\r
\r
package eu.etaxonomy.cdm.strategy.cache.description;\r
\r
IIdentifiableEntityCacheStrategy<TaxonDescription> {\r
\r
final static UUID uuid = UUID.fromString("0517ae48-597d-4d6b-9f18-8752d689720d");\r
- \r
+\r
@Override\r
protected UUID getUuid() {\r
return uuid;\r
}\r
\r
- public String getTitleCache(TaxonDescription taxonDescription) {\r
+ @Override\r
+ public String getTitleCache(TaxonDescription taxonDescription) {\r
String title;\r
- Taxon taxon = taxonDescription.getTaxon(); \r
+ Taxon taxon = taxonDescription.getTaxon();\r
if (taxon == null){\r
title = getFirstPart(taxonDescription);\r
title = title.replace(" for ", "");\r
}\r
return title;\r
}\r
- \r
+\r
private String getFirstPart(TaxonDescription taxonDescription){\r
Set<Marker> markers = taxonDescription.getMarkers();\r
MarkerType markerType = MarkerType.USE();\r
if(marker.getMarkerType().equals(markerType)) {\r
isUseDescription = true;\r
}\r
- } \r
+ }\r
if (taxonDescription.isImageGallery()){\r
return "Image gallery for " ;\r
} else if (isUseDescription) {\r
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;\r
\r
public class MediaDefaultCacheStrategy extends StrategyBase implements IIdentifiableEntityCacheStrategy<Media> {\r
- protected static final Logger logger = Logger.getLogger(MediaDefaultCacheStrategy.class);\r
+ private static final long serialVersionUID = 7246846028810250751L;\r
+\r
+ protected static final Logger logger = Logger.getLogger(MediaDefaultCacheStrategy.class);\r
\r
final static UUID uuid = UUID.fromString("0517ae48-597d-4d6b-9f18-8752d689720d");\r
\r
/**\r
* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \r
+*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
private static final long serialVersionUID = 2679554971446197111L;\r
\r
final static UUID uuid = UUID.fromString("1cdda0d1-d5bc-480f-bf08-40a510a2f223");\r
- \r
+\r
@Override\r
public UUID getUuid(){\r
return uuid;\r
}\r
\r
- \r
+\r
public static BotanicNameDefaultCacheStrategy NewInstance(){\r
return new BotanicNameDefaultCacheStrategy();\r
}\r
- \r
+\r
/**\r
* Returns the AuthorCache part for a combination of an author and an ex author. This applies on combination authors\r
* as well as on basionym/orginal combination authors.\r
- * The correct order is exAuthor ex author though some botanist do not know about and do it the \r
+ * The correct order is exAuthor ex author though some botanist do not know about and do it the\r
* other way round. (see 46.4-46.6 ICBN (Vienna Code, 2006))\r
* @param author the author\r
* @param exAuthor the ex-author\r
String result = "";\r
String authorString = "";\r
String exAuthorString = "";\r
- \r
+\r
if (author != null){\r
authorString = CdmUtils.Nz(author.getNomenclaturalTitle());\r
}\r
exAuthorString = CdmUtils.Nz(exAuthor.getNomenclaturalTitle());\r
exAuthorString += ExAuthorSeperator;\r
}\r
- \r
- result = exAuthorString + authorString; \r
+\r
+ result = exAuthorString + authorString;\r
return result;\r
- \r
+\r
}\r
- \r
+\r
}\r
-package eu.etaxonomy.cdm.strategy.cache.taxon;
-
-
/**
* Copyright (C) 2015 EDIT
* European Distributed Institute of Taxonomy
* See LICENSE.TXT at the top of this package for the full license terms.
*/
-
+package eu.etaxonomy.cdm.strategy.cache.taxon;
import java.util.ArrayList;
import java.util.List;
private List<Feature> features; // the features used to generate the key
private Set<TaxonDescription> taxa; // the base of taxa
- private boolean merge=true; // if this boolean is set to true, branches of the tree will be merged if the corresponding states can be used together without decreasing their score
+ private boolean merge=true; // if this boolean is set to true, branches of the tree will be merged if the corresponding states can be used together without decreasing their score
private FeatureTree dependenciesTree; // the tree containing the dependencies between states and features (InapplicableIf and OnlyApplicableIf)
- private Map<State,Set<Feature>> iIdependencies = new HashMap<State,Set<Feature>>(); // map of a set of Features (value) inapplicables if a State (key) is present
+ private Map<State,Set<Feature>> iIdependencies = new HashMap<State,Set<Feature>>(); // map of a set of Features (value) inapplicables if a State (key) is present
private Map<State,Set<Feature>> oAIdependencies = new HashMap<State,Set<Feature>>(); // map of a set of Features (value) only applicables if a State (key) is present
private Map<Feature,Set<Feature>> featureDependencies = new HashMap<Feature,Set<Feature>>(); // map of all the sets of features (values) which have dependencies with states of other features (keys)
private boolean dependenciesON = true; // if this boolean is true, the dependencies are taken into account
/**
* Sets the features used to generate the key.
- *
+ *
* @param featuresList
*/
public void setFeatures(List<Feature> featuresList){
/**
* Sets the base of taxa.
- *
+ *
* @param featuresList
*/
public void setTaxa(Set<TaxonDescription> taxaSet){
/**
* Sets the tree containing the dependencies between states and features.
- *
+ *
* @param tree
*/
public void setDependencies(FeatureTree tree){
/**
- * Initializes the function buildBranches() with the starting parameters in order to build the key
+ * Initializes the function buildBranches() with the starting parameters in order to build the key
*/
private void loop(){
polytomousKey = PolytomousKey.NewInstance();
/**
* Recursive function that builds the branches of the identification key (FeatureTree)
- *
+ *
* @param father the node considered
* @param featuresLeft List of features that can be used at this point
* @param taxaCovered the taxa left at this point (i.e. that verify the description corresponding to the path leading to this node)
son.setStatement(statement);
father.addChild(son);
boolean areTheTaxaDiscriminated;
- if (newTaxaCovered.size()==taxaCovered.size()) areTheTaxaDiscriminated = false;
- else areTheTaxaDiscriminated = true;
+ if (newTaxaCovered.size()==taxaCovered.size()) {
+ areTheTaxaDiscriminated = false;
+ } else {
+ areTheTaxaDiscriminated = true;
+ }
buildBranches(son,featuresLeft, newTaxaCovered,areTheTaxaDiscriminated);
}
}
// first, get the right DescriptionElementBase
for (DescriptionElementBase deb : td.getElements()) {
- if (deb.getFeature().equals(winnerFeature)) debConcerned = deb;
+ if (deb.getFeature().equals(winnerFeature)) {
+ debConcerned = deb;
+ }
}
if (debConcerned!=null) {
mergeBranches(clique,taxonStatesMap);
}
}
- if (taxonStatesMap!=null && !taxonStatesMap.isEmpty()) {
+ if (taxonStatesMap!=null && !taxonStatesMap.isEmpty()) {
for (Map.Entry<Set<TaxonDescription>,List<State>> entry : taxonStatesMap.entrySet()){
Set<TaxonDescription> newTaxaCovered = entry.getKey();
List<State> listOfStates = entry.getValue();
if (dependenciesON){
// if the dependencies are considered, removes and adds the right features from/to the list of features left
// these features are stored in order to be put back again when the current branch is finished
- if (iIdependencies.get(state)!= null) innapplicables.addAll(iIdependencies.get(state));
- if (oAIdependencies.get(state)!= null) applicables.addAll(oAIdependencies.get(state));
- for (Feature feature : innapplicables) featuresLeft.remove(feature);
- for (Feature feature : applicables) featuresLeft.add(feature);
+ if (iIdependencies.get(state)!= null) {
+ innapplicables.addAll(iIdependencies.get(state));
+ }
+ if (oAIdependencies.get(state)!= null) {
+ applicables.addAll(oAIdependencies.get(state));
+ }
+ for (Feature feature : innapplicables) {
+ featuresLeft.remove(feature);
+ }
+ for (Feature feature : applicables) {
+ featuresLeft.add(feature);
+ }
}
questionLabel.append(state.getLabel());
- if (listOfStates.lastIndexOf(state)!=numberOfStates) questionLabel.append(separator); // append a separator after each state except for the last one
+ if (listOfStates.lastIndexOf(state)!=numberOfStates)
+ {
+ questionLabel.append(separator); // append a separator after each state except for the last one
+ }
}
// old code used when PolytomousKey extended FeatureTree
// Representation question = new Representation(null, questionLabel.toString(),null, Language.DEFAULT());
father.addChild(son);
featuresLeft.remove(winnerFeature); // unlike for quantitative features, once a categorical one has been used, it cannot be reused in the same branch
boolean areTheTaxaDiscriminated;
- if (newTaxaCovered.size()==taxaCovered.size()) areTheTaxaDiscriminated = true;
- else areTheTaxaDiscriminated = false;
+ if (newTaxaCovered.size()==taxaCovered.size()) {
+ areTheTaxaDiscriminated = true;
+ } else {
+ areTheTaxaDiscriminated = false;
+ }
buildBranches(son,featuresLeft, newTaxaCovered,areTheTaxaDiscriminated);
}
}
}
// the features depending on other features are added/removed to/from the features left once the branch is done
if (dependenciesON){
- for (Feature feature : innapplicables) featuresLeft.add(feature);
- for (Feature feature : applicables) featuresLeft.remove(feature);
+ for (Feature feature : innapplicables) {
+ featuresLeft.add(feature);
+ }
+ for (Feature feature : applicables) {
+ featuresLeft.remove(feature);
+ }
}
// the winner features are put back to the features left once the branch is done
featuresLeft.add(winnerFeature);
* If the dependencies are on, this function calculates the score of all children features and give the highest score
* of these to their father (of course, if its score is lower). This way, if a feature has a good score but is
* "onlyApplicableIf" or "InapplicableIf", the feature it depends can be chosen in order to build a better key.
- *
+ *
* @param scoreMap
* @param featuresLeft
* @param coveredTaxa
/**
* This function merges branches of the key belonging to the same clique
* (http://en.wikipedia.org/wiki/Clique_%28graph_theory%29)
- *
+ *
* @param clique the list of States linked together (i.e. if merged have the same score)
* @param taxonStatesMap the map between the taxa (keys) and the states (keys) leading to them
*/
if (clique.size()>1){
Iterator<Map.Entry<Set<TaxonDescription>, List<State>>> it1 = taxonStatesMap.entrySet().iterator();
while (it1.hasNext()){
- Map.Entry<Set<TaxonDescription>,List<State>> branch = (Map.Entry<Set<TaxonDescription>, List<State>>)it1.next();
+ Map.Entry<Set<TaxonDescription>,List<State>> branch = it1.next();
Iterator<State> stateIterator = clique.iterator();
stateFound=false;
// looks for one state of the clique in this branch
* This function looks for the largest clique of States
* (http://en.wikipedia.org/wiki/Clique_%28graph_theory%29)
* from the map of exclusions.
- *
+ *
* @param exclusions map a state (key) to the set of states (value) which can not be merged with it without decreasing its score.
* @return
*/
// looks for the largest clique, i.e. the state with less exclusions
State bestState=null;
for (Iterator<Map.Entry<State,Set<State>>> it1 = exclusions.entrySet().iterator() ; it1.hasNext();){
- Map.Entry<State,Set<State>> pair = (Map.Entry<State,Set<State>>)it1.next();
+ Map.Entry<State,Set<State>> pair = it1.next();
numberOfExclusions = pair.getValue().size();
if ((bestNumberOfExclusions==-1) || numberOfExclusions<bestNumberOfExclusions) {
bestNumberOfExclusions=numberOfExclusions;
boolean isNotExcluded;
// then starts building the clique by adding the states which do not exclude each other
for (Iterator<Map.Entry<State,Set<State>>> iterator = exclusions.entrySet().iterator() ; iterator.hasNext();){
- Map.Entry<State,Set<State>> pair = (Map.Entry<State,Set<State>>)iterator.next();
+ Map.Entry<State,Set<State>> pair = iterator.next();
isNotExcluded = true;
for (State state : clique) {
- if (pair.getValue().contains(state)) isNotExcluded = false;
+ if (pair.getValue().contains(state)) {
+ isNotExcluded = false;
+ }
}
if (isNotExcluded){
clique.add(pair.getKey());
/**
* fills a map of the sets of taxa (key) presenting the different states (value) for the given feature.
- *
+ *
* @param statesDone the list of states already done for this feature
* @param categoricalData the element from which the states are extracted
* @param feature the feature corresponding to the CategoricalData
/**
* returns the list of taxa from previously covered taxa, which have the state featureState for the given feature
- *
+ *
* @param feature
* @param featureState
* @param taxaCovered
}
}
}
- }
+ }
}
}
return newCoveredTaxa;
/**
* This function returns the feature with the highest score. However, if several features have the same score
* the one wich leads to less options is chosen (this way, the key is easier to read).
- *
+ *
* @param nTaxa
* @param scores
* @param taxaCovered
*/
private Feature lessStatesWinner(Map<Feature,Float> scores, Set<TaxonDescription> taxaCovered){
int nTaxa = taxaCovered.size();
- if (nTaxa==1) return null;
- float meanScore = defaultMeanScore(nTaxa);
+ if (nTaxa==1) {
+ return null;
+ }
+ float meanScore = defaultMeanScore(nTaxa);
float bestScore = nTaxa*nTaxa;
List<Feature> bestFeatures = new ArrayList<Feature>(); // if ever different features have the best score, they are put in this list
Feature bestFeature = null;
Iterator<Map.Entry<Feature,Float>> it = scores.entrySet().iterator();
float newScore;
while (it.hasNext()){
- Map.Entry<Feature,Float> pair = (Map.Entry<Feature,Float>)it.next();
+ Map.Entry<Feature,Float> pair = it.next();
if (pair.getValue()!=null){
- newScore = Math.abs((Float)pair.getValue()-meanScore);// the best score is the closest to the score (meanScore here)
+ newScore = Math.abs(pair.getValue()-meanScore);// the best score is the closest to the score (meanScore here)
// a feature would have if it divided the taxa in two equal parts
if (newScore < bestScore){
bestFeatures.clear();
- bestFeatures.add((Feature)pair.getKey());
+ bestFeatures.add(pair.getKey());
bestScore = newScore;
}else if (newScore==bestScore){
- bestFeatures.add((Feature)pair.getKey());
+ bestFeatures.add(pair.getKey());
}
}
}
}
}
}
- }
+ }
}
numberOfDifferentStates=differentStates.size();
}else if (feature.isSupportsQuantitativeData()){
/**
* This function calculates the mean score, i.e. the score a feature dividing the taxa in two equal parts
* would have.
- *
+ *
* @param nTaxa
* @return
*/
int i;
float score=0;
for (i=1;i<nTaxa;i++){
- score = score + Math.round((float)(i+1/2));
+ score = score + Math.round(i+1/2);
}
return score;
}
/**
* This function fills the map of features (keys) with their respecting scores (values)
- *
+ *
* @param featuresLeft
* @param coveredTaxa
* @param quantitativeFeaturesThresholds
* for a given quantitative feature, present either a lower or higher value than a given threshold.
* It returns two Sets of TaxonDescription, one with the taxa under this threshold (taxaBefore) and another one
* with the taxa over (taxaAfter).
- *
+ *
* @param threshold
* @param feature
* @param taxa
/**
* This function returns the score of a quantitative feature.
- *
+ *
* @param feature
* @param coveredTaxa
* @param quantitativeFeaturesThresholds
for (i=0;i<taxaBefore;i++) {
defaultQuantitativeScore += taxaAfter - i;
}
- return (float)(defaultQuantitativeScore);
+ return (defaultQuantitativeScore);
}
/**
* This function returns the score of a categorical feature.
- *
+ *
* @param feature
* @param coveredTaxa
* @return
/**
* This recursive function fills the maps of dependencies by reading the tree containing the dependencies.
- *
+ *
* @param node
*/
private void checkDependencies(FeatureNode node){
if (node.getOnlyApplicableIf()!=null){
Set<State> addToOAI = node.getOnlyApplicableIf();
for (State state : addToOAI){
- if (oAIdependencies.containsKey(state)) oAIdependencies.put(state, new HashSet<Feature>());
+ if (oAIdependencies.containsKey(state)) {
+ oAIdependencies.put(state, new HashSet<Feature>());
+ }
oAIdependencies.get(state).add(node.getFeature());
}
}
if (node.getInapplicableIf()!=null){
Set<State> addToiI = node.getInapplicableIf();
for (State state : addToiI){
- if (iIdependencies.containsKey(state)) iIdependencies.put(state, new HashSet<Feature>());
+ if (iIdependencies.containsKey(state)) {
+ iIdependencies.put(state, new HashSet<Feature>());
+ }
iIdependencies.get(state).add(node.getFeature());
}
}
/**
* This function fills the exclusions map.
- *
+ *
* @param feature
* @param coveredTaxa
* @param exclusions
/**
* Returns the score between two DescriptionElementBase. If one of them is null, returns -1.
* If they are not of the same type (Categorical) returns 0.
- *
+ *
* @param deb1
* @param deb2
* @return
}
if ((deb1.isInstanceOf(CategoricalData.class))&&(deb2.isInstanceOf(CategoricalData.class))) {
return defaultCategoricalPower((CategoricalData)deb1, (CategoricalData)deb2);
- }
- else return 0;
+ } else {
+ return 0;
+ }
}
/**
* Returns the score of a categorical feature.
- *
+ *
* @param deb1
* @param deb2
* @return
}
- if (bool) return 0;
- else return 1;
+ if (bool) {
+ return 0;
+ } else {
+ return 1;
+ }
}
// old code used when PolytomousKey extended FeatureTree
*
* @author n.hoffmann
* @created Jan 22, 2010
- * @version 1.0
*/
public class MatchStrategyConfigurator {
/**\r
* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \r
+*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
/**\r
* @author a.mueller\r
* @created 07.08.2009\r
- * @version 1.0\r
*/\r
public class Matching {\r
@SuppressWarnings("unused")\r
private static final Logger logger = Logger.getLogger(Matching.class);\r
- \r
+\r
private SortedMap<String, FieldMatcher> fieldMatchers = new TreeMap<String, FieldMatcher>();\r
private SortedMap<String, FieldMatcher> tmpFieldMatchers = new TreeMap<String, FieldMatcher>();\r
private List<CacheMatcher> cacheMatchers = new ArrayList<CacheMatcher>();\r
- \r
+\r
\r
public Matching setFieldMatcher(FieldMatcher fieldMatcher){\r
return setFieldMatcher(fieldMatcher, false);\r
}\r
- \r
+\r
public Matching setFieldMatcher(FieldMatcher fieldMatcher,boolean temporary){\r
String propertyName = fieldMatcher.getPropertyName();\r
if (temporary && ! fieldMatchers.containsKey(propertyName)){\r
- tmpFieldMatchers.put(propertyName, fieldMatcher); \r
+ tmpFieldMatchers.put(propertyName, fieldMatcher);\r
}else{\r
fieldMatchers.put(propertyName, fieldMatcher);\r
}\r
if (includeTemporary){\r
for (FieldMatcher fieldMatcher : tmpFieldMatchers.values()){\r
result.add(fieldMatcher);\r
- } \r
+ }\r
}\r
return result;\r
}\r
- \r
+\r
/**\r
* @return the fieldMatchers\r
*/\r
public FieldMatcher getFieldMatcher(String propertyName) {\r
return fieldMatchers.get(propertyName);\r
}\r
- \r
+\r
public boolean exists(String propertyName){\r
return getFieldMatcher(propertyName) != null;\r
}\r
public void deleteTemporaryMatchers(){\r
tmpFieldMatchers = new TreeMap<String, FieldMatcher>();\r
}\r
- \r
- \r
+\r
+\r
}\r
/**\r
* Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \r
+*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
public class NameTypeParser {\r
\r
private static final String desigPattern = "\\sdesig(\\.|nation)?";\r
- \r
+\r
/**\r
* see also CentralAfricaFernsTaxonParser#handleTypeLocationPart\r
*/\r
- public static final String typeTypePattern = "("+ \r
+ public static final String typeTypePattern = "("+\r
"lecto(\\.|type)?+" +\r
"(original|present|subsequent)"+ desigPattern +\r
- "(subsequent monotypy|tautonomy)" + \r
+ "(subsequent monotypy|tautonomy)" +\r
")";\r
- \r
- \r
- \r
+\r
+\r
+\r
public static NameTypeDesignationStatus parseNameTypeStatus(String type) throws UnknownCdmTypeException {\r
if (StringUtils.isBlank(type)){\r
return null;\r
}else if (type.matches("(?i)subsequent" + desigPattern)){\r
return NameTypeDesignationStatus.SUBSEQUENT_DESIGNATION();\r
}\r
- \r
+\r
}else if(type.matches("(?i)subsequent monotypy")){\r
return NameTypeDesignationStatus.SUBSEQUENT_MONOTYPY();\r
}else if(type.matches("(?i)monotypy")){\r
}\r
String message = "Type Status not supported: " + type;\r
throw new UnknownCdmTypeException(message);\r
- \r
+\r
}\r
}\r
/**\r
* Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \r
+*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
/**\r
* @author a.mueller\r
* @date 25.07.2011\r
- *\r
*/\r
public class SpecimenTypeParser {\r
\r
-\r
public static class TypeInfo{\r
public SpecimenTypeDesignationStatus status;\r
public String collectionString;\r
public boolean notDesignated;\r
}\r
- \r
+\r
/**\r
* see also CentralAfricaFernsTaxonParser#handleTypeLocationPart\r
*/\r
public static final String typeTypePattern = "(?i)(holo|lecto|iso|isolecto|syn|isosyn|neo|isoneo|type)\\.?";\r
public static final String collectionPattern = "^[A-Z]+(\\-[A-Z]+)?";\r
- \r
- \r
- \r
+\r
+\r
+\r
public static SpecimenTypeDesignationStatus parseSpecimenTypeStatus(String type) throws UnknownCdmTypeException {\r
//TODO also compare with NameTypeParser\r
//TODO further types\r
- \r
+\r
if (StringUtils.isBlank(type)){\r
return null;\r
}else if (type.endsWith("type") && ! type.equalsIgnoreCase("type")){\r
}else if (type.endsWith("types") && ! type.equalsIgnoreCase("types")){\r
type = type.substring(0, type.length() -5 );\r
}\r
- \r
- SpecimenTypeDesignationStatus status; \r
+\r
+ SpecimenTypeDesignationStatus status;\r
if (type.equalsIgnoreCase("iso")){\r
status = SpecimenTypeDesignationStatus.ISOTYPE();\r
}else if (type.equalsIgnoreCase("isolecto")){\r
+++ /dev/null
-/**\r
-* Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy \r
-* http://www.e-taxonomy.eu\r
-* \r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-package eu.etaxonomy.cdm.strategy.parser;\r
-\r
-import org.apache.log4j.Logger;\r
-\r
-/**\r
- * @author a.mueller\r
- * @date 12.05.2010\r
- *\r
- */\r
-public class TaxonNameParserHistory {\r
- private static final Logger logger = Logger.getLogger(TaxonNameParserHistory.class);\r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- /**\r
- * @param args\r
- */\r
- public static void main(String[] args) {\r
- // TODO Auto-generated method stub\r
-\r
- }\r
-\r
-}\r
\r
import org.hibernate.Hibernate;\r
\r
-//import org.hibernate.Hibernate;\r
import eu.etaxonomy.cdm.model.taxon.Synonym;\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
/**\r
* A Mock class for testing entity validation tasks. DO NOT MODIFY UNLESS YOU ALSO MODIFY\r
* THE UNIT TESTS MAKING USE OF THIS CLASS!\r
- * \r
+ *\r
* @author ayco_holleman\r
- * \r
+ *\r
*/\r
@SuppressWarnings("serial")\r
public class Address extends CdmBase {\r
this.street = street;\r
}\r
\r
-\r
+ @Override\r
public boolean equals(Object obj){\r
if (this == obj) {\r
return true;\r
}\r
\r
\r
- public int hashCode(){\r
+ @Override\r
+ public int hashCode(){\r
return street.hashCode();\r
}\r
\r
)
public class TestsShouldNotFailInSuite_2 {
+ @SuppressWarnings("unused")
private static final Logger logger = Logger.getLogger(TestsShouldNotFailInSuite_2.class);
// the class remains completely empty,