/**
* 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.
*/
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeConfigurator;
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
import eu.etaxonomy.cdm.api.service.ITermService;
-import eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator;
-import eu.etaxonomy.cdm.api.service.config.impl.TaxonServiceConfiguratorImpl;
+import eu.etaxonomy.cdm.api.service.config.FindTaxaAndNamesConfiguratorImpl;
+import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
import eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.common.ICdmBase;
import eu.etaxonomy.cdm.model.common.IDefinedTerm;
+import eu.etaxonomy.cdm.model.common.ISimpleTerm;
import eu.etaxonomy.cdm.model.common.Language;
import eu.etaxonomy.cdm.model.common.MarkerType;
import eu.etaxonomy.cdm.model.common.TermBase;
* <p>
* PreferencesUtil class.
* </p>
- *
+ *
* @author p.ciardelli
* @author n.hoffmann
* @created 05.12.2008
public class PreferencesUtil implements IPreferenceKeys {
/**
- *
+ *
*/
public static final String PREFERRED_TERMS_CHANGE = "preferred_terms";
* <p>
* getPreferenceStore
* </p>
- *
+ *
* @return a {@link org.eclipse.jface.preference.IPreferenceStore} object.
*/
public static IPreferenceStore getPreferenceStore() {
* <p>
* setPreferredNomenclaturalCode
* </p>
- *
+ *
* @param preferredCode
* a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
* object.
* <p>
* getPreferredNomenclaturalCode
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
*/
public static NomenclaturalCode getPreferredNomenclaturalCode() {
/**
* Get the match strategy for the given class that was stored in preferences
* or the default strategy if it was not stored in preferences
- *
+ *
* @param clazz
* a {@link java.lang.Class} object.
* @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
/**
* Stores a matchStrategy into the preference store.
- *
+ *
* @param matchStrategy
* a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy}
* object.
/**
* Helper method to create the preference property for a match field.
- *
+ *
* @param className
* @param fieldName
* @return
/**
* Returns the default match strategy for a given class.
- *
+ *
* @param clazz
* a {@link java.lang.Class} object.
* @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
* <p>
* getDateFormatPattern
* </p>
- *
+ *
* @return a {@link java.lang.String} object.
*/
public static String getDateFormatPattern() {
* <p>
* addTermToPreferredTerms
* </p>
- *
+ *
* @param term
* a T object.
* @param <T>
/**
* Construct a unique key using the CdmBase object's uuid
- *
+ *
* @param cdmBase
* @return
*/
/**
* Construct a unique key using the CdmBase object's uuid
- *
+ *
+ * @param cdmBase
+ * @return
+ */
+ public static String getPreferenceKey(ISimpleTerm simpleTerm) {
+ simpleTerm = (ISimpleTerm) HibernateProxyHelper.deproxy(simpleTerm);
+ String key = simpleTerm.getClass().getName().concat(".")
+ .concat(simpleTerm.getUuid().toString());
+ if (key.contains("javassist")) {
+ StoreUtil.warn(PreferencesUtil.class,
+ "Trying to persist a preference based on a proxy class.");
+ }
+ return key;
+ }
+
+
+
+ /**
+ * Construct a unique key using the CdmBase object's uuid
+ *
* @param cdmBase
* @return
*/
/**
* Retrieves search preferences from the preference store
- *
+ *
* @return an {@link ITaxonServiceConfigurator} to pass to search methods
*/
- public static ITaxonServiceConfigurator getSearchConfigurator() {
- ITaxonServiceConfigurator configurator = initializeSearchConfigurator();
+ public static IFindTaxaAndNamesConfigurator getSearchConfigurator() {
+ IFindTaxaAndNamesConfigurator configurator = initializeSearchConfigurator();
configurator.setDoTaxa(getPreferenceStore().getBoolean(
TAXON_SERVICE_CONFIGURATOR_TAXA));
/**
* create new preferences, setting all search options to true
- *
+ *
* @return a
* {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
* object.
*/
- public static ITaxonServiceConfigurator initializeSearchConfigurator() {
- ITaxonServiceConfigurator configurator = TaxonServiceConfiguratorImpl
- .NewInstance();
+ public static IFindTaxaAndNamesConfigurator initializeSearchConfigurator() {
+ IFindTaxaAndNamesConfigurator configurator = new FindTaxaAndNamesConfiguratorImpl();
configurator.setDoTaxa(true);
configurator.setDoSynonyms(true);
// match mode is a simple like, actually all other match modes are kind
// of bogus
configurator
- .setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.LIKE);
+ .setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.ANYWHERE);
// we set page number and size here as this should always be unlimited
configurator.setPageNumber(0);
// TODO currently limit results to 10000
/**
* Store search preferences
- *
+ *
* @param configurator
* a
* {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
* object.
*/
public static void setSearchConfigurator(
- ITaxonServiceConfigurator configurator) {
+ IFindTaxaAndNamesConfigurator configurator) {
getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_TAXA,
configurator.isDoTaxa());
getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
* <p>
* firePreferencesChanged
* </p>
- *
+ *
* @param clazz
* a {@link java.lang.Class} object.
*/
getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
true);
getPreferenceStore().setDefault(EDIT_MAP_SERVICE_ACCES_POINT,
- "http://edit.br.fgov.be/edit_wp5/v1/areas.php");
- getPreferenceStore().setDefault(SHOULD_CONNECT_AT_STARTUP, true);
+ "http://edit.africamuseum.be/edit_wp5/v1.2/rest_gen.php");
+ //FIXME : changed default for SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
+ getPreferenceStore().setDefault(SHOULD_CONNECT_AT_STARTUP, false);
getPreferenceStore().setDefault(OPENURL_ACCESS_POINT,
"http://www.biodiversitylibrary.org/openurl");
getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_WIDTH, "1000");
*/
public static void checkNomenclaturalCode() {
// First time Editor is opened, no nomenclatural code has been set
+
+
if (PreferencesUtil.getPreferredNomenclaturalCode() == null) {
+ PreferencesUtil.setPreferredNomenclaturalCode(NomenclaturalCode.ICNAFP);
+ /*
StoreUtil.info("No nomencatural code set.");
Shell shell = StoreUtil.getShell();
- // Query user re: preferred nom. code
+ Query user re: preferred nom. code
Dialog dialog = new InitNomenclaturalCodePrefDialog(shell);
dialog.open();
"The following has been set as your preferred nomenclatural code:\n\n\t"
+ NomenclaturalCodeHelper
.getDescription(code)
- + "\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");
+ + "\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");*/
}
}
* <p>
* getMapServiceAccessPoint
* </p>
- *
+ *
* @return a {@link java.lang.String} object.
*/
public static String getMapServiceAccessPoint() {
* <p>
* shouldConnectAtStartUp
* </p>
- *
+ *
* @return a boolean.
*/
public static boolean shouldConnectAtStartUp() {
- return getPreferenceStore().getBoolean(SHOULD_CONNECT_AT_STARTUP);
+ //FIXME : force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
+ //return getPreferenceStore().getBoolean(SHOULD_CONNECT_AT_STARTUP);
+ return false;
}
/**
* <p>
* getDefaultFeatureTreeForTextualDescription
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
*/
public static FeatureTree getDefaultFeatureTreeForTextualDescription() {
* <p>
* getDefaultFeatureTreeForStructuredDescription
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
*/
public static FeatureTree getDefaultFeatureTreeForStructuredDescription() {
* <p>
* setSortRanksHierarchichally
* </p>
- *
+ *
* @param selection
* a boolean.
*/
* <p>
* getSortRanksHierarchichally
* </p>
- *
+ *
* @return a boolean.
*/
public static boolean getSortRanksHierarchichally() {
*/
public static Map<MarkerType, Boolean> getEditMarkerTypePreferences() {
List<MarkerType> markerTypes = CdmStore.getTermManager()
- .getPreferredMarkerTypes();
+ .getPreferredTerms(MarkerType.class);
Map<MarkerType, Boolean> result = new HashMap<MarkerType, Boolean>();
* <p>
* setEditMarkerTypePreference
* </p>
- *
+ *
* @param input
* a {@link org.eclipse.ui.IEditorInput} object.
* @param markerType