import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.Set;
import java.util.StringTokenizer;
import java.util.UUID;
import eu.etaxonomy.cdm.model.description.FeatureTree;
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
+import eu.etaxonomy.cdm.model.metadata.IPreferencePredicate;
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
+import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
import eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy;
+import eu.etaxonomy.cdm.strategy.match.FieldMatcher;
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
import eu.etaxonomy.cdm.strategy.match.MatchException;
import eu.etaxonomy.cdm.strategy.match.MatchMode;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
+import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
import eu.etaxonomy.taxeditor.ui.dialog.DefaultLanguageDialog;
* @author p.ciardelli
* @author n.hoffmann
* @created 05.12.2008
- * @version 1.0
*/
public class PreferencesUtil implements IPreferenceKeys {
private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
+
+
+
+
/**
* <p>
* getPreferenceStore
return TaxeditorStorePlugin.getDefault().getPreferenceStore();
}
+ private static String prefKey(String name) {
+ return name + "_"+ ((CdmRemoteSource)CdmStore.getActiveCdmSource()).toString();
+ }
+
+ public static String prefOverrideKey(String name) {
+ return name + "_OVERRIDE_"+ ((CdmRemoteSource)CdmStore.getActiveCdmSource()).toString();
+ }
+
+ /**
+ * <p>
+ * setStringValue
+ * </p>
+ *
+ *
+ **/
+ public static void setStringValue(String name, String value) {
+ getPreferenceStore().setValue(prefKey(name), value);
+ }
+
+ /**
+ * <p>
+ * setIntValue
+ * </p>
+ *
+ *
+ **/
+ public static void setIntValue(String name, int value) {
+ getPreferenceStore().setValue(prefKey(name), value);
+ }
+
+ /**
+ * <p>
+ * setBooleanValue
+ * </p>
+ *
+ *
+ **/
+ public static void setBooleanValue(String name, boolean value) {
+ getPreferenceStore().setValue(prefKey(name), value);
+ }
+
+ /**
+ * <p>
+ * setBooleanValue
+ * </p>
+ *
+ *
+ **/
+ public static void setDoubleValue(String name, double value) {
+ getPreferenceStore().setValue(prefKey(name), value);
+ }
+
+ /**
+ * <p>
+ * setFloatValue
+ * </p>
+ *
+ *
+ **/
+ public static void setFloatValue(String name, float value) {
+ getPreferenceStore().setValue(name + ((CdmRemoteSource)CdmStore.getActiveCdmSource()).toString(), value);
+ }
+
+ /**
+ * <p>
+ * setFloatValue
+ * </p>
+ *
+ *
+ **/
+ public static void setLongValue(String name, long value) {
+ getPreferenceStore().setValue(prefKey(name), value);
+ }
+
+ /**
+ * <p>
+ * getStringValue
+ * </p>
+ *
+ *
+ **/
+ public static String getStringValue(String name, boolean local) {
+
+ String prefValue = getDBPreferenceValue(name);
+ if (prefValue == null || local){
+ String dbSpecific = prefKey(name);
+ if (getPreferenceStore().contains(dbSpecific)){
+ prefValue = getPreferenceStore().getString(dbSpecific);
+ }else{
+ prefValue = getPreferenceStore().
+ getString(name);
+ }
+ }
+ return prefValue;
+
+ }
+
+ public static String getStringValue(String name){
+ return getStringValue(name, false);
+ }
+
+ private static String getDBPreferenceValue(String name) {
+ CdmPreferenceCache cache = CdmPreferenceCache.instance();
+ if (cache.get(name) != null){
+ CdmPreference pref = cache.get(name);
+ if (!pref.isAllowOverride() || !getBooleanValue(prefOverrideKey(name))){
+ return pref.getValue();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * <p>
+ * setIntValue
+ * </p>
+ *
+ *
+ **/
+ public static int getIntValue(String name) {
+ String prefValue = getDBPreferenceValue(name);
+ Integer result = null;
+ try{
+ result = Integer.parseInt(prefValue);
+ }catch(NumberFormatException e){
+ logger.debug("Preference value of " + name + " is not a number");
+ }
+ if (result == null){
+ String dbSpecific = prefKey(name);
+ if (getPreferenceStore().contains(dbSpecific)){
+ result = getPreferenceStore().getInt(dbSpecific);
+ }else{
+ result = getPreferenceStore().
+ getInt(name);
+ }
+ }
+ return result;
+
+
+ }
+
+ /**
+ * <p>
+ * setBooleanValue
+ * </p>
+ *
+ *
+ **/
+ public static boolean getBooleanValue(String name) {
+ if (CdmStore.isActive()){
+ String prefValue = getDBPreferenceValue(name);
+ if (prefValue == null){
+ String dbSpecific = prefKey(name);
+ if (getPreferenceStore().contains(dbSpecific)){
+ return getPreferenceStore().getBoolean(dbSpecific);
+ }else{
+ return getPreferenceStore().
+ getBoolean(name);
+ }
+ }else{
+ return Boolean.valueOf(prefValue);
+ }
+
+ }else{
+ return getPreferenceStore().getBoolean(name);
+ }
+
+ }
+
+ /**
+ * <p>
+ * setBooleanValue
+ * </p>
+ *
+ *
+ **/
+ public static double getDoubleValue(String name) {
+ String prefValue = getDBPreferenceValue(name);
+ Double result = null;
+ try{
+ result = Double.parseDouble(prefValue);
+ }catch(NumberFormatException e){
+ logger.debug("Preference value of " + name + " is not a number");
+ }
+ if (result == null){
+ String dbSpecific = prefKey(name);
+ if (getPreferenceStore().contains(dbSpecific)){
+ result = getPreferenceStore().getDouble(dbSpecific);
+ }else{
+ result = getPreferenceStore().
+ getDouble(name);
+ }
+ }
+ return result;
+
+ }
+
+ /**
+ * <p>
+ * getFloatValue
+ * </p>
+ *
+ *
+ **/
+ public static float getFloatValue(String name) {
+ String prefValue = getDBPreferenceValue(name);
+ Float result = null;
+ try{
+ result = Float.parseFloat(prefValue);
+ }catch(NumberFormatException e){
+ logger.debug("Preference value of " + name + " is not a number");
+ }
+ if (result == null){
+ String dbSpecific = prefKey(name);
+ if (getPreferenceStore().contains(dbSpecific)){
+ result = getPreferenceStore().getFloat(dbSpecific);
+ }else{
+ result = getPreferenceStore().
+ getFloat(name);
+ }
+ }
+ return result;
+
+ }
+
+ /**
+ * <p>
+ * getLongValue
+ * </p>
+ *
+ *
+ **/
+ public static long getLongValue(String name) {
+ String prefValue = getDBPreferenceValue(name);
+ Long result = null;
+ try{
+ result = Long.parseLong(prefValue);
+ }catch(NumberFormatException e){
+ logger.debug("Preference value of " + name + " is not a number");
+ }
+ if (result == null){
+ String dbSpecific = prefKey(name);
+ if (getPreferenceStore().contains(dbSpecific)){
+ result = getPreferenceStore().getLong(dbSpecific);
+ }else{
+ result = getPreferenceStore().
+ getLong(name);
+ }
+ }
+ return result;
+ }
+
+
/**
* <p>
* setPreferredNomenclaturalCode
* object.
*/
public static CdmPreference setPreferredNomenclaturalCode(
- NomenclaturalCode preferredCode, boolean local) {
+ String preferenceValue, boolean local) {
if (local){
- getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
- getPreferenceKey(preferredCode));
+ setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
+ preferenceValue);
}
else{
ICdmRepository controller;
controller = CdmStore.getCurrentApplicationConfiguration();
- PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
- CdmPreference preference = null;
if (controller == null){
- return null;
+ return null;
+ }
+ PrefKey key = null;
+ try{
+ key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
+ }catch (Exception e){
+ System.out.println(e.getStackTrace());
}
- if (preferredCode == null){
+ CdmPreference preference = null;
+
+ if (preferenceValue == null){
preference = controller.getPreferenceService().find(key);
if (preference == null){
return null;
} else{
- int index = StringUtils.lastIndexOf(preference.getValue(), ".");
- UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
- preferredCode = NomenclaturalCode.getByUuid(uuid);
+ setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
+ preference.getValue());
- getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
- getPreferenceKey(preferredCode));
- getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY,preference.isAllowOverride());
return preference;
}
} else{
- preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferredCode.getKey());
+ preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferenceValue);
controller.getPreferenceService().set(preference);
}
}
+ /**
+ * <p>
+ * setPreferredNomenclaturalCode
+ * </p>
+ *
+ * @param preferredCode
+ * a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
+ * object.
+ */
+ public static void setPreferredNomenclaturalCode(
+ CdmPreference preference) {
+
+ ICdmRepository controller;
+ controller = CdmStore.getCurrentApplicationConfiguration();
+ if (controller == null){
+ return;
+ }
+ PrefKey key = null;
+ try{
+ key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
+ }catch (Exception e){
+ System.out.println(e.getStackTrace());
+ }
+
+ controller.getPreferenceService().set(preference);
+
+ }
+
+
public static NomenclaturalCode getPreferredNomenclaturalCode(){
- if (getPreferenceStore().getBoolean(OVERRIDE_NOMENCLATURAL_CODE_KEY)) {
+ if (getBooleanValue(prefOverrideKey(PreferencePredicate.NomenclaturalCode.getKey()))) {
return getPreferredNomenclaturalCode(true);
} else{
return getPreferredNomenclaturalCode(false);
String preferredCode;
if(pref == null){
- preferredCode = getPreferenceStore().getString(
- PREFERRED_NOMENCLATURAL_CODE_KEY);
+ preferredCode = getStringValue(
+ PREFERRED_NOMENCLATURAL_CODE_KEY, true);
}else{
preferredCode = pref.getValue();
}
- for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
- if (getPreferenceKey(code).equals(preferredCode)) {
- return code;
- }
- }
- return null;
+ return getPreferredNomenclaturalCode(preferredCode);
+
}
- public static boolean isShowTaxonAssociations(){
- if (getPreferenceStore().getBoolean(OVERRIDE_SPECIMEN_PREF) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF)) {
- return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS);
- } else{
- CdmPreference pref = getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
+ /**
+ * <p>
+ * getPreferredNomenclaturalCode
+ * </p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
+ */
+ public static NomenclaturalCode getPreferredNomenclaturalCode(String preferenceKeyNomenclaturalCode) {
- return pref!=null?Boolean.valueOf(pref.getValue()):false;
+ for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
+ if (getPreferenceKey(code).equals(preferenceKeyNomenclaturalCode)) {
+ return code;
+ }
}
+ return null;
}
- public static boolean isShowLifeForm(){
- if (getPreferenceStore().getBoolean(OVERRIDE_SPECIMEN_PREF) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF)) {
- return getPreferenceStore().getBoolean(SHOW_LIFE_FORM);
- } else{
- CdmPreference pref = getPreferenceFromDB(PreferencePredicate.ShowLifeForm);
+ public static boolean isShowTaxonAssociations(){
+ boolean result = getBooleanValue(EditorPreferencePredicate.ShowTaxonAssociations.getKey());
+ return result;
+ }
- return pref!=null?Boolean.valueOf(pref.getValue()):false;
- }
+ public static boolean isShowLifeForm(){
+ boolean result = getBooleanValue(EditorPreferencePredicate.ShowLifeForm.getKey());
+ return result;
}
public static boolean isDeterminationOnlyForFieldUnits(){
- if (getPreferenceStore().getBoolean(OVERRIDE_SPECIMEN_PREF) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF)) {
- return getPreferenceStore().getBoolean(DETERMINATION_ONLY_FOR_FIELD_UNITS);
- } else{
- CdmPreference pref = getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
-
- return pref!=null?Boolean.valueOf(pref.getValue()):false;
- }
+ boolean result = getBooleanValue(EditorPreferencePredicate.DeterminationOnlyForFieldUnits.getKey());
+ return result;
}
public static boolean isCollectingAreaInGeneralSection(){
- if (getPreferenceStore().getBoolean(OVERRIDE_SPECIMEN_PREF) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF)) {
- return getPreferenceStore().getBoolean(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION);
- } else{
- CdmPreference pref = getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
-
- return pref!=null?Boolean.valueOf(pref.getValue()):false;
- }
- }
-
- public static boolean isShowSimpleDetailsView(){
- if (getPreferenceStore().getBoolean(OVERRIDE_NAME_DETAILS) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_NAME_DETAILS)) {
- return getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_SECTION);
- } else{
- CdmPreference pref = getPreferenceFromDB(PreferencePredicate.NameDetailsView);
-
- return pref!=null?Boolean.valueOf(pref.getValue()):false;
- }
- }
-
-
+ boolean result = getBooleanValue(EditorPreferencePredicate.ShowCollectingAreasInGeneralSection.getKey());
+ return result;
+ }
- public static CdmPreference getPreferenceFromDB(PreferencePredicate predicate){
+ public static CdmPreference getPreferenceFromDB(IPreferencePredicate predicate){
ICdmRepository controller;
CdmPreference pref = null;
try{
if(CdmStore.isActive()){
controller = CdmStore.getCurrentApplicationConfiguration();
- PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), predicate);
+ PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), predicate);
pref = controller.getPreferenceService().find(key);
}
}catch(Exception e){
}
+ public static void setPreferenceToDB(CdmPreference preference){
+ ICdmRepository controller;
+ try{
+ if(CdmStore.isActive()){
+ controller = CdmStore.getCurrentApplicationConfiguration();
+ controller.getPreferenceService().set(preference);
+ }
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+
+ }
+
+
public static String getPreferredDefaultLangugae(){
- String preferredLanguage = getPreferenceStore().getString(DEFAULT_LANGUAGE_EDITOR);
+ String preferredLanguage = getStringValue(DEFAULT_LANGUAGE_EDITOR);
if(StringUtils.isNotEmpty(preferredLanguage) && StringUtils.isNotBlank(preferredLanguage)){
return preferredLanguage;
}
return null;
}
+ public static boolean isShowMediaPreview(){
+ boolean isShowMediaPreview = getBooleanValue(SHOW_MEDIA_PREVIEW);
+ return isShowMediaPreview;
+ }
+
/**
* Get the match strategy for the given class that was stored in preferences
* or the default strategy if it was not stored in preferences
* a {@link java.lang.Class} object.
* @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
*/
- public static IMatchStrategy getMatchStrategy(Class clazz) {
+ public static IMatchStrategy getMatchStrategy(Class<?> clazz) {
String className = clazz.getName();
- if (getPreferenceStore().getBoolean(MATCH_STRATEGY_PREFIX + className)) {
+ if (getBooleanValue(MATCH_STRATEGY_PREFIX + className)) {
IMatchStrategy matchStrategy = getDefaultMatchStrategy(clazz);
- for (String fieldName : matchStrategy.getMatchFieldPropertyNames()) {
- String matchModeName = getPreferenceStore().getString(
+ //TODO CacheMatchers (or multiple field matchers in future) are missing here
+ for (FieldMatcher fieldMatcher : matchStrategy.getMatching().getFieldMatchers(false)) {
+ String fieldName = fieldMatcher.getPropertyName();
+ String matchModeName = getStringValue(
getMatchStrategyFieldName(className, fieldName));
MatchMode matchMode = MatchMode.valueOf(matchModeName);
try {
* object.
*/
public static void setMatchStrategy(IMatchStrategy matchStrategy) {
- String className = matchStrategy.getMatchClass().getName();
- getPreferenceStore().setValue(MATCH_STRATEGY_PREFIX + className, true);
+ String className = "ANY class"; //FIXME was: matchStrategy.getMatchClass().getName(); seems currently not in use
+ setBooleanValue(MATCH_STRATEGY_PREFIX + className, true);
- Set<String> matchFields = matchStrategy.getMatchFieldPropertyNames();
+ List<FieldMatcher> fieldMatchers = matchStrategy.getMatching().getFieldMatchers(false);
- for (String fieldName : matchFields) {
- getPreferenceStore().setValue(
+ for (FieldMatcher fieldMatcher : fieldMatchers) {
+ String fieldName = fieldMatcher.getPropertyName();
+ setStringValue(
getMatchStrategyFieldName(className, fieldName),
- matchStrategy.getMatchMode(fieldName).name());
+ fieldMatcher.getMatchMode().name());
}
}
public static IFindTaxaAndNamesConfigurator getSearchConfigurator() {
IFindTaxaAndNamesConfigurator configurator = initializeSearchConfigurator();
- configurator.setDoTaxa(getPreferenceStore().getBoolean(
+ configurator.setDoTaxa(getBooleanValue(
TAXON_SERVICE_CONFIGURATOR_TAXA));
- configurator.setDoSynonyms(getPreferenceStore().getBoolean(
+ configurator.setDoSynonyms(getBooleanValue(
TAXON_SERVICE_CONFIGURATOR_SYNONYMS));
- configurator.setDoNamesWithoutTaxa(getPreferenceStore().getBoolean(
+ configurator.setDoNamesWithoutTaxa(getBooleanValue(
TAXON_SERVICE_CONFIGURATOR_NAMES));
- configurator.setDoTaxaByCommonNames(getPreferenceStore().getBoolean(
+ configurator.setDoTaxaByCommonNames(getBooleanValue(
TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES));
- //configurator.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.valueOf(getPreferenceStore().getString(TAXON_SERVICE_CONFIGURATOR_MATCH_MODE)));
+ //configurator.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.valueOf(getStringValue(TAXON_SERVICE_CONFIGURATOR_MATCH_MODE)));
return configurator;
}
* object.
*/
public static IFindTaxaAndNamesConfigurator initializeSearchConfigurator() {
- IFindTaxaAndNamesConfigurator configurator = new FindTaxaAndNamesConfiguratorImpl();
+ IFindTaxaAndNamesConfigurator configurator = FindTaxaAndNamesConfiguratorImpl.NewInstance();
configurator.setDoTaxa(true);
configurator.setDoSynonyms(true);
"name", "name.$", "relationsFromThisTaxon.$"));
configurator.setSynonymPropertyPath(Arrays.asList("$", "titleCache",
- "name", "name.$", "synonymRelations.relatedTo.*"));
+ "name", "name.$", "synonyms.relatedTo.*"));
// DEFAULT VALUES
// match mode is a simple like, actually all other match modes are kind
configurator.setPageNumber(0);
// TODO currently limit results to 10000
configurator.setPageSize(10000);
-
+ setSearchConfigurator(configurator) ;
return configurator;
}
null, clazz);
}
+ public static String createPreferenceString(String property){
+ return prefKey(property);
+
+ }
+ public static String createOverridePreferenceString(String property){
+ return prefOverrideKey(property);
+
+ }
+
/**
* Set default values for preferences
*/
getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_TAXA, true);
getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
true);
- getPreferenceStore().setDefault(EDIT_MAP_SERVICE_ACCES_POINT,
+ getPreferenceStore().setDefault(createPreferenceString(EDIT_MAP_SERVICE_ACCES_POINT),
"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,
+ getPreferenceStore().setDefault(createPreferenceString(SHOULD_CONNECT_AT_STARTUP), false);
+ getPreferenceStore().setDefault(createPreferenceString(OPENURL_ACCESS_POINT),
"http://www.biodiversitylibrary.org/openurl");
- getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_WIDTH, "1000");
- getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_HEIGHT, "1000");
- getPreferenceStore().setDefault(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, false);
- getPreferenceStore().setDefault(CHECKLIST_ID_IN_VOCABULARY, true);
- getPreferenceStore().setDefault(CHECKLIST_SYMBOL, false);
- getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, true);
- getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE, true);
- getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, true);
- getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_HYBRID, true);
- getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_LSID, true);
- getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, true);
- getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAMECACHE, true);
- getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, true);
- getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, true);
- getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, true);
- getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, true);
- getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_RANK, true);
- getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, true);
- getPreferenceStore().setDefault(SORT_NODES_NATURALLY, false);
- getPreferenceStore().setDefault(SORT_NODES_ALPHABETICALLY, false);
-
+ getPreferenceStore().setDefault(createPreferenceString(OPENURL_IMAGE_MAX_WIDTH), "1000");
+ getPreferenceStore().setDefault(createPreferenceString(OPENURL_IMAGE_MAX_HEIGHT), "1000");
+ //Distribution Editor:
+ getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate.DistributionEditorActivated.getKey()), Boolean.valueOf(EditorPreferencePredicate.DistributionEditorActivated.getDefaultValue().toString()));
+ getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString());
+ getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate.DisplayOfStatus.getKey()), EditorPreferencePredicate.DisplayOfStatus.getDefaultValue().toString());
+
+
+ //Name Details
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS), true);
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE), true);
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP), true);
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_HYBRID), true);
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_LSID), true);
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP), true);
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NAMECACHE), true);
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE), true);
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE), true);
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS), true);
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE), true);
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_RANK), true);
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION), true);
+ //Navigator preferences
+ getPreferenceStore().setDefault(createPreferenceString(SORT_NODES), NavigatorOrderEnum.RankAndNameOrder.getKey());
+
+ getPreferenceStore().setDefault(createPreferenceString(SORT_TAXA_BY_RANK_AND_NAME), true);
+ //override db preferences
+ getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate.AbcdImportConfig.getKey())), false);
+ getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate.ShowSpecimen.getKey())), false);
+ getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate.NameDetailsView.getKey())), false);
+ getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate.DistributionEditorActivated.getKey())), false);
+
+ getPreferenceStore().setDefault(createPreferenceString(FILTER_COMMON_NAME_REFERENCES), false);
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_SPECIMEN), true);
+ getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate.ShowTaxonNodeWizard.getKey()), Boolean.valueOf(EditorPreferencePredicate.ShowTaxonNodeWizard.getDefaultValue().toString()));
+ getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate.ShowNamespaceInSource.getKey()), Boolean.valueOf(EditorPreferencePredicate.ShowNamespaceInSource.getDefaultValue().toString()));
+ getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate.ShowIdInSource.getKey()), Boolean.valueOf(EditorPreferencePredicate.ShowIdInSource.getDefaultValue().toString()));
+ getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate.DisableMultiClassification.getKey()), Boolean.valueOf(EditorPreferencePredicate.DisableMultiClassification.getDefaultValue().toString()));
+ getPreferenceStore().setDefault(createPreferenceString(DISABLE_SEC), false);
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_SEC_DETAILS), true);
}
/**
*/
public static void checkNomenclaturalCode() {
// First time Editor is opened, no nomenclatural code has been set
-
-
if (PreferencesUtil.getPreferredNomenclaturalCode(true) == null) {
- PreferencesUtil.setPreferredNomenclaturalCode(NomenclaturalCode.ICNAFP, true);
+ PreferencesUtil.setPreferredNomenclaturalCode(getPreferenceKey(NomenclaturalCode.ICNAFP), true);
}
if (preference == null){
return;
}
- getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY, preference.isAllowOverride());
+// setBooleanValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY, preference.isAllowOverride());
int index = StringUtils.lastIndexOf(preference.getValue(), ".");
UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
NomenclaturalCode preferredCode = NomenclaturalCode.getByUuid(uuid);
- getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
+ setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
getPreferenceKey(preferredCode));
- if (!preference.isAllowOverride()){
- getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
- getPreferenceKey(preferredCode));
- }
}
public static void checkDefaultLanguage(){
* @return a {@link java.lang.String} object.
*/
public static String getMapServiceAccessPoint() {
- return getPreferenceStore().getString(EDIT_MAP_SERVICE_ACCES_POINT);
+ return getStringValue(EDIT_MAP_SERVICE_ACCES_POINT);
}
/**
*/
public static boolean shouldConnectAtStartUp() {
//FIXME : force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
- //return getPreferenceStore().getBoolean(SHOULD_CONNECT_AT_STARTUP);
+ //return getBooleanValue(SHOULD_CONNECT_AT_STARTUP);
return false;
}
* @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
*/
public static FeatureTree getDefaultFeatureTreeForTextualDescription() {
- String uuidString = getPreferenceStore().getString(
+ String uuidString = getStringValue(
FEATURE_TREE_DEFAULT_TEXT);
- return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
- IFeatureTreeService.class).load(UUID.fromString(uuidString));
+ if (uuidString == null) {
+ return null;
+ }
+ FeatureTree tree = CdmStore.getService(
+ IFeatureTreeService.class).load(UUID.fromString(uuidString));
+ if (tree.getId() == 0) {
+ return null;
+ }
+ return tree;
}
/**
* @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
*/
public static FeatureTree getDefaultFeatureTreeForStructuredDescription() {
- String uuidString = getPreferenceStore().getString(
+ String uuidString = getStringValue(
FEATURE_TREE_DEFAULT_STRUCTURE);
return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
IFeatureTreeService.class).load(UUID.fromString(uuidString));
* a boolean.
*/
public static void setSortRanksHierarchichally(boolean selection) {
- getPreferenceStore().setValue(SORT_RANKS_HIERARCHICHALLY, selection);
+ setBooleanValue(SORT_RANKS_HIERARCHICHALLY, selection);
}
/**
* @return a boolean.
*/
public static boolean getSortRanksHierarchichally() {
- return getPreferenceStore().getBoolean(SORT_RANKS_HIERARCHICHALLY);
+ return getBooleanValue(SORT_RANKS_HIERARCHICHALLY);
}
public static boolean isMultilanguageTextEditingCapability() {
- return getPreferenceStore().getBoolean(
+ return getBooleanValue(
MULTILANGUAGE_TEXT_EDITING_CAPABILITY);
}
public static Language getGlobalLanguage() {
- String languageUuidString = getPreferenceStore().getString(
+ String languageUuidString = getStringValue(
GLOBAL_LANGUAGE_UUID);
if(!CdmStore.isActive()) {
public static void setGlobalLanguage(Language language) {
if(language != null) {
- getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID,language.getUuid().toString());
+ setStringValue(GLOBAL_LANGUAGE_UUID,language.getUuid().toString());
CdmStore.setDefaultLanguage(language);
}
for (MarkerType markerType : markerTypes) {
String name = getMarkerTypeEditingPreferenceKey(markerType);
- Boolean value = getPreferenceStore().getBoolean(name);
+ Boolean value = getBooleanValue(name);
result.put(markerType, value);
}
Map<MarkerType, Boolean> markerTypeEditingMap) {
for (MarkerType markerType : markerTypeEditingMap.keySet()) {
String name = getMarkerTypeEditingPreferenceKey(markerType);
- getPreferenceStore().setValue(name,
+ setBooleanValue(name,
markerTypeEditingMap.get(markerType));
}
*/
public static void setEditMarkerTypePreference(MarkerType markerType,
boolean edit) {
- getPreferenceStore().setValue(
+ setBooleanValue(
getMarkerTypeEditingPreferenceKey(markerType), edit);
}
switch(setLanguage){
case 0:
properties.setProperty("osgi.nl", "de");
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "de");
+ setStringValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "de");
break;
case 1:
properties.setProperty("osgi.nl", "en");
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "en");
+ setStringValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "en");
break;
default:
break;
*/
public static List<MetadataRepositoryElement> getP2Repositories() {
List<MetadataRepositoryElement> p2Repos = new ArrayList<MetadataRepositoryElement>();
- String p2ReposPref = getPreferenceStore().getString(P2_REPOSITORY_LIST);
+ String p2ReposPref = getStringValue(P2_REPOSITORY_LIST);
if(p2ReposPref != null && !p2ReposPref.isEmpty()) {
StringTokenizer p2ReposPrefST = new StringTokenizer(p2ReposPref,P2_REPOSITORIES_DELIM);
}
}
+
+
+
/**
- * <p>
- * getSortRanksNaturally
- * </p>
- *
- * @return a boolean.
- */
- public static boolean getSortNodesNaturally() {
- return getPreferenceStore().getBoolean(SORT_NODES_NATURALLY);
- }
+ * @param orderActivated
+ */
+ public static void setSortNodes(NavigatorOrderEnum nodesOrder) {
+ setStringValue(SORT_NODES, nodesOrder.key);
- /**
- * <p>
- * setSortRanksNaturally
- * </p>
- *
- * @param selection
- * a boolean.
- */
- public static void setSortNodesNaturally(boolean selection) {
- getPreferenceStore().setValue(SORT_NODES_NATURALLY, selection);
- }
+ }
+ /**
+ * @param orderActivated
+ */
+ public static NavigatorOrderEnum getSortNodes() {
+ return NavigatorOrderEnum.valueOf(getStringValue(SORT_NODES));
- /**
- * <p>
- * getSortRanksNaturally
- * </p>
- *
- * @return a boolean.
- */
- public static boolean getSortNodesStrictlyAlphabetically() {
- return getPreferenceStore().getBoolean(SORT_NODES_ALPHABETICALLY);
- }
+ }
- /**
- * <p>
- * setSortRanksNaturally
- * </p>
- *
- * @param selection
- * a boolean.
- */
- public static void setSortNodesStrictlyAlphabetically(boolean selection) {
- getPreferenceStore().setValue(SORT_NODES_ALPHABETICALLY, selection);
- }
+ /**
+ * @param orderActivated
+ */
+ public static boolean isNodesSortedNaturally() {
+ NavigatorOrderEnum value = NavigatorOrderEnum.valueOf(getStringValue(SORT_NODES));
+ return value.equals(NavigatorOrderEnum.NaturalOrder);
+
+ }
+
+ /**
+ * @param orderActivated
+ */
+ public static boolean isNodesSortedByName() {
+ NavigatorOrderEnum value = NavigatorOrderEnum.valueOf(getStringValue(SORT_NODES));
+ return value.equals(NavigatorOrderEnum.AlphabeticalOrder);
+
+ }
+ /**
+ * @param orderActivated
+ */
+ public static boolean isNodesSortedByNameAndRank() {
+ NavigatorOrderEnum value = NavigatorOrderEnum.valueOf(getStringValue(SORT_NODES));
+ return value.equals(NavigatorOrderEnum.RankAndNameOrder);
+
+ }
/**
* <p>
* setStoreNavigatorState
* a boolean.
*/
public static boolean isStoreNavigatorState() {
- return getPreferenceStore().getBoolean(RESTORE_NAVIGATOR_STATE);
+ return getBooleanValue(RESTORE_NAVIGATOR_STATE);
}
* a boolean.
*/
public static void setStoreNavigatorState(boolean selection) {
- getPreferenceStore().setValue(RESTORE_NAVIGATOR_STATE, selection);
+ setBooleanValue(RESTORE_NAVIGATOR_STATE, selection);
}
* @return
*/
public static boolean isShowUpWidgetIsDisposedMessages() {
- return getPreferenceStore().getBoolean(IS_SHOW_UP_WIDGET_IS_DISPOSED);
+ return getBooleanValue(IS_SHOW_UP_WIDGET_IS_DISPOSED);
}
public static void setShowUpWidgetIsDisposedMessages(boolean selection) {
- getPreferenceStore().setValue(IS_SHOW_UP_WIDGET_IS_DISPOSED, selection);
+ setBooleanValue(IS_SHOW_UP_WIDGET_IS_DISPOSED, selection);
}
/**
* @return
*/
public static boolean isShowIdInVocabularyInChecklistEditor() {
- return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_ID_IN_VOCABULARY);
+ String area_display = getStringValue(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
+ if (area_display.equals(TermDisplayEnum.IdInVocabulary.getKey())) {
+ return true;
+ }else{
+ return false;
+ }
+ }
+ public static boolean isShowSymbol1InChecklistEditor() {
+ String area_display = getStringValue(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
+ if (area_display.equals(TermDisplayEnum.Symbol1.getKey())) {
+ return true;
+ }else{
+ return false;
+ }
+ }
+ public static boolean isShowSymbol2InChecklistEditor() {
+ String area_display = getStringValue(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
+ if (area_display.equals(TermDisplayEnum.Symbol2.getKey())) {
+ return true;
+ }else{
+ return false;
+ }
+ }
+ public static void setAreaDisplayInChecklistEditor(String selection) {
+ setStringValue(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey(), selection);
}
- public static void setShowIdInVocabularyInChecklistEditor(boolean selection) {
- getPreferenceStore().setValue(CHECKLIST_ID_IN_VOCABULARY, selection);
+
+ public static void setOwnDescriptionForChecklistEditor(boolean selection) {
+ setBooleanValue(EditorPreferencePredicate.OwnDescriptionForDistributionEditor.getKey(), selection);
+ }
+
+ public static boolean isOwnDescriptionForChecklistEditor() {
+ return getBooleanValue(EditorPreferencePredicate.OwnDescriptionForDistributionEditor.getKey());
}
/**
* @return
*/
- public static boolean isShowSymbolInChecklistEditor() {
- return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_SYMBOL);
+ public static String displayStatusInChecklistEditor() {
+ return getStringValue(EditorPreferencePredicate.DisplayOfStatus.getKey());
}
- public static void setShowSymbolInChecklistEditor(boolean selection) {
- getPreferenceStore().setValue(CHECKLIST_SYMBOL, selection);
+ public static void setDisplayStatusInChecklistEditor(String selection) {
+ setStringValue(EditorPreferencePredicate.DisplayOfStatus.getKey(), selection);
}
/**
* @return
*/
public static boolean isShowRankInChecklistEditor() {
- return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_SHOW_RANK);
+ return getBooleanValue(EditorPreferencePredicate.ShowRankInDistributionEditor.getKey());
}
public static void setShowRankInChecklistEditor(boolean selection) {
- getPreferenceStore().setValue(CHECKLIST_SHOW_RANK, selection);
+ setBooleanValue(EditorPreferencePredicate.ShowRankInDistributionEditor.getKey(), selection);
}
/**
* @param b
* @return
*/
- public static NameDetailsConfigurator setPreferredNameDetailsConfiguration( boolean local) {
+ public static NameDetailsConfigurator getPreferredNameDetailsConfiguration( boolean local) {
NameDetailsConfigurator config = new NameDetailsConfigurator(true);
-
+ CdmPreferenceCache cache = CdmPreferenceCache.instance();
CdmPreference preference = null;
if (!local) {
- preference = getPreferenceFromDB(PreferencePredicate.NameDetailsView);
- }
- if (preference == null){
- return null;
- }
+ preference = cache.get(EditorPreferencePredicate.NameDetailsView.getKey());
+ if (preference == null){
+ return null;
+ }
- getPreferenceStore().setValue(ALLOW_OVERRIDE_NAME_DETAILS, preference.isAllowOverride());
+ setBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS, preference.isAllowOverride());
- //the preference value is build like this:
- //<section1>:true;<section2>:false....
+ //the preference value is build like this:
+ //<section1>:true;<section2>:false....
- String value = preference.getValue();
- String [] sections = value.split(";");
- Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
- String[] sectionValues;
- for (String sectionValue: sections){
- sectionValues = sectionValue.split(":");
- sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
+ String value = preference.getValue();
+ String [] sections = value.split(";");
+ Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
+ String[] sectionValues;
+ for (String sectionValue: sections){
+ sectionValues = sectionValue.split(":");
+ sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
+ }
+ config.setAllowOverride(preference.isAllowOverride());
+ config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
+
+ // getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
+ // (getValue(sectionMap, "taxon")));
+ config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
+
+ config.setSecDetailsActivated(getValue(sectionMap, "taxon.SecEnabled"));
+ config.setSecEnabled(getValue(sectionMap, "taxon.SecDetails"));
+
+ // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
+ // (getValue(sectionMap, "lsid")));
+ config.setLSIDActivated(getValue(sectionMap, "lsid"));
+
+ // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
+ // (getValue(sectionMap, "nc")));
+ config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
+
+ // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
+ // (getValue(sectionMap, "ap")));
+ config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
+
+ // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
+ // (getValue(sectionMap, "rank")));
+ config.setRankActivated(getValue(sectionMap, "rank"));
+
+
+ // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
+ // (getValue(sectionMap, "atomisedEpithets")));
+ config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
+
+ // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
+ // (getValue(sectionMap,"author")));
+ config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
+
+ // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
+ // (getValue(sectionMap, "nomRef")));
+ config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
+
+ // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
+ // (getValue(sectionMap, "nomStat")));
+ config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
+
+
+ // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
+ // (getValue(sectionMap,"protologue")));
+ config.setProtologueActivated(getValue(sectionMap,"protologue"));
+
+ // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
+ // (getValue(sectionMap,"typeDes")));
+ config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
+
+ // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
+ // (getValue(sectionMap,"nameRelation")));
+ config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
+
+ // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_HYBRID,
+ // (getValue(sectionMap, "hybrid")));
+ config.setHybridActivated(getValue(sectionMap,"hybrid"));
+ }else{
+ config.setSimpleDetailsViewActivated(getBooleanValue(SHOW_SIMPLE_NAME_DETAILS_SECTION));
+ config.setTaxonSectionActivated(getBooleanValue(SHOW_SIMPLE_NAME_DETAILS_TAXON));
+ config.setSecDetailsActivated(getBooleanValue(SHOW_SEC_DETAILS));
+ config.setSecEnabled(getBooleanValue(DISABLE_SEC));
+ config.setLSIDActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_LSID));
+ config.setNomenclaturalCodeActived(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
+ config.setAppendedPhraseActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
+ config.setRankActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_RANK));
+ config.setAtomisedEpithetsActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
+ config.setAuthorshipSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
+ config.setNomenclaturalReferenceSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
+ config.setNomenclaturalStatusSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
+ config.setProtologueActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
+ config.setTypeDesignationSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
+ config.setNameRelationsSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
+ config.setHybridActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_HYBRID));
}
+ return config;
+ }
- config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
-
-// getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
-// (getValue(sectionMap, "taxon")));
- config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
-
-// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
-// (getValue(sectionMap, "lsid")));
- config.setLSIDActivated(getValue(sectionMap, "lsid"));
-
-// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
-// (getValue(sectionMap, "nc")));
- config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
-
-// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
-// (getValue(sectionMap, "ap")));
- config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
-
-// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
-// (getValue(sectionMap, "rank")));
- config.setRankActivated(getValue(sectionMap, "rank"));
-
-
-// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
-// (getValue(sectionMap, "atomisedEpithets")));
- config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
-
-// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
-// (getValue(sectionMap,"author")));
- config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
-
-// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
-// (getValue(sectionMap, "nomRef")));
- config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
-
-// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
-// (getValue(sectionMap, "nomStat")));
- config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
-
-
-// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
-// (getValue(sectionMap,"protologue")));
- config.setProtologueActivated(getValue(sectionMap,"protologue"));
-
-// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
-// (getValue(sectionMap,"typeDes")));
- config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
+ /**
+ * @param object
+ * @param b
+ * @return
+ */
+ public static void setPreferredNameDetailsConfiguration(NameDetailsConfigurator config, boolean local) {
+ CdmPreference preference = null;
-// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
-// (getValue(sectionMap,"nameRelation")));
- config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
+ if (!local) {
+ preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), EditorPreferencePredicate.NameDetailsView, config.toString());
-// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_HYBRID,
-// (getValue(sectionMap, "hybrid")));
- config.setHybridActivated(getValue(sectionMap,"hybrid"));
+ setPreferenceToDB(preference);
+ }
+ //also add to local preferences
+ setBooleanValue(SHOW_SIMPLE_NAME_DETAILS_SECTION, config.isSimpleDetailsViewActivated());
+ setBooleanValue(SHOW_SIMPLE_NAME_DETAILS_TAXON, config.isTaxonSectionActivated());
+ setBooleanValue(SHOW_SEC_DETAILS, config.isSecDetailsActivated());
+ setBooleanValue(DISABLE_SEC, config.isSecEnabled());
+ setBooleanValue(SHOW_NAME_DETAILS_SECTION_LSID, config.isLSIDActivated());
+ setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, config.isNomenclaturalCodeActived());
+ setBooleanValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, config.isAppendedPhraseActivated());
+ setBooleanValue(SHOW_NAME_DETAILS_SECTION_RANK, config.isRankActivated());
+ setBooleanValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, config.isAtomisedEpithetsActivated());
+ setBooleanValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, config.isAuthorshipSectionActivated());
+ setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, config.isNomenclaturalReferenceSectionActivated());
+ setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, config.isNomenclaturalStatusSectionActivated());
+ setBooleanValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, config.isProtologueActivated());
+ setBooleanValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, config.isTypeDesignationSectionActivated());
+ setBooleanValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, config.isNameRelationsSectionActivated());
+ setBooleanValue(SHOW_NAME_DETAILS_SECTION_HYBRID, config.isHybridActivated());
- return config;
}
private static Boolean getValue(Map<String, Boolean> sectionMap, String string) {
}
-// public static boolean isDeterminiationOnlyForFieldUnit(boolean local){
-// CdmPreference preference = null;
-//
-// if (!local) {
-// preference = getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
-// }
-// if (preference == null){
-// return getPreferenceStore().getBoolean(DETERMINATION_ONLY_FOR_FIELD_UNITS);
-// }
-// return Boolean.valueOf(preference.getValue());
-// }
-//
-// public static boolean isShowCollectingAreasInGeneralSection(boolean local){
-// CdmPreference preference = null;
-//
-// if (!local) {
-// preference = getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
-// }
-// if (preference == null){
-// return getPreferenceStore().getBoolean(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION);
-// }
-// return Boolean.valueOf(preference.getValue());
-// }
-//
-// public static boolean isShowTaxonAssociations(boolean local){
-// CdmPreference preference = null;
-//
-// if (!local) {
-// preference = getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
-// }
-// if (preference == null){
-// return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS);
-// }
-// return Boolean.valueOf(preference.getValue());
-// }
-
-// public static boolean getBioCaseProvider(boolean local){
-// CdmPreference preference = null;
-//
-// if (!local) {
-// preference = getPreferenceFromDB(PreferencePredicate.BioCaseProvider);
-// }
-// if (preference == null){
-// return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS);
-// }
-// return Boolean.valueOf(preference.getValue());
-// }
/**
* a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
* object.
*/
- public static Abcd206ImportConfigurator getAbcdImportConfigurationPreference(boolean useLocal) {
+ public static Abcd206ImportConfigurator getDBAbcdImportConfigurationPreference() {
Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
-
- if (useLocal){
- config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS));
-
- config.setAddMediaAsMediaSpecimen(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN));
-
- config.setAllowReuseOtherClassifications(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS));
- config.setDeduplicateClassifications(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS));
- config.setDeduplicateReferences(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES));
-
- config.setGetSiblings(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS));
- config.setIgnoreAuthorship(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP));
- config.setIgnoreImportOfExistingSpecimen(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN));
- config.setMapUnitIdToAccessionNumber(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER));
- config.setMapUnitIdToBarcode(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE));
- config.setMapUnitIdToCatalogNumber(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER));
- config.setMoveNewTaxaToDefaultClassification(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION));
- config.setOverwriteExistingSpecimens(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN));
- config.setReuseExistingDescriptiveGroups(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS));
- config.setReuseExistingMetaData(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA));
- config.setReuseExistingTaxaWhenPossible(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE));
- return config;
-
+ ICdmRepository controller;
+ controller = CdmStore.getCurrentApplicationConfiguration();
+ PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.AbcdImportConfig);
+ CdmPreference preference = null;
+ if (controller == null){
+ return null;
}
- ICdmRepository controller;
- controller = CdmStore.getCurrentApplicationConfiguration();
- PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AbcdImportConfig);
- CdmPreference preference = null;
- if (controller == null){
- return null;
- }
- preference = controller.getPreferenceService().find(key);
- if (preference == null){
- return config;
- } else{
+ preference = controller.getPreferenceService().find(key);
+ if (preference == null){
+ return config;
+ } else{
String configString = preference.getValue();
String[] configArray = configString.split(";");
for (String configItem: configArray){
String[] keyValue = configItem.split(":");
String keyString = keyValue[0];
- String valueString = keyValue[1];
+ String valueString = null;
+ if (keyValue.length>1){
+ valueString = keyValue[1];
+ }
if (keyString.equals("ignoreImportOfExistingSpecimen")){
config.setIgnoreImportOfExistingSpecimen(Boolean.valueOf(valueString));
}else if (keyString.equals("addIndividualsAssociationsSuchAsSpecimenAndObservations")){
config.setMapUnitIdToBarcode(Boolean.valueOf(valueString));
}else if (keyString.equals("overwriteExistingSpecimens")){
config.setOverwriteExistingSpecimens(Boolean.valueOf(valueString));
+ }else if (keyString.equals("nomenclaturalCode")){
+ config.setNomenclaturalCode(NomenclaturalCode.fromString(valueString));
}else{
logger.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString);
}
- }
+ }
}
return config;
+ }
+ public static Abcd206ImportConfigurator getLocalAbcdImportConfigurator(){
+ Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
+
+ config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS));
+
+ config.setAddMediaAsMediaSpecimen(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN));
+
+ config.setAllowReuseOtherClassifications(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS));
+ config.setDeduplicateClassifications(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS));
+ config.setDeduplicateReferences(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES));
+ config.setRemoveCountryFromLocalityText(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REMOVE_COUNTRY_FROM_LOCALITY_TEXT));
+ config.setGetSiblings(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS));
+ config.setIgnoreAuthorship(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP));
+ config.setIgnoreImportOfExistingSpecimen(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN));
+ config.setMapUnitIdToAccessionNumber(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER));
+ config.setMapUnitIdToBarcode(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE));
+ config.setMapUnitIdToCatalogNumber(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER));
+ config.setMoveNewTaxaToDefaultClassification(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION));
+ config.setOverwriteExistingSpecimens(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN));
+ config.setReuseExistingDescriptiveGroups(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS));
+ config.setReuseExistingMetaData(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA));
+ config.setReuseExistingTaxaWhenPossible(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE));
+ config.setNomenclaturalCode(NomenclaturalCode.getByKey(getStringValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE)));
+ return config;
}
+
+ public static void updateAbcdImportConfigurationPreference() {
+ CdmPreferenceCache cache = CdmPreferenceCache.instance();
+ CdmPreference pref = cache.get(EditorPreferencePredicate.AbcdImportConfig.getKey());
+
+ if (!getBooleanValue(prefOverrideKey(EditorPreferencePredicate.AbcdImportConfig.getKey())) || !pref.isAllowOverride()){
+ resetToDBPreferenceAbcdCOnfigurator();
+
+ }
+ }
+
+ public static void resetToDBPreferenceAbcdCOnfigurator(){
+ Abcd206ImportConfigurator config = getDBAbcdImportConfigurationPreference();
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS, config.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN, config.isAddMediaAsMediaSpecimen());
+
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS, config.isAllowReuseOtherClassifications());
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS, config.isDeduplicateClassifications());
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES, config.isDeduplicateReferences());
+
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS, config.isGetSiblings());
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP, config.isIgnoreAuthorship());
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN, config.isIgnoreImportOfExistingSpecimen());
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER, config.isMapUnitIdToAccessionNumber());
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE, config.isMapUnitIdToBarcode());
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER, config.isMapUnitIdToCatalogNumber());
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION, config.isMoveNewTaxaToDefaultClassification());
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN, config.isOverwriteExistingSpecimens());
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS, config.isReuseExistingDescriptiveGroups());
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA, config.isReuseExistingMetaData());
+ setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE, config.isReuseExistingTaxaWhenPossible());
+ if (config.getNomenclaturalCode() != null){
+ setStringValue(ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE, config.getNomenclaturalCode().getKey());
+ }
+ }
+
+
/**
*
*/
public NameDetailsConfigurator createLocalNameDetailsViewConfig(boolean local) {
NameDetailsConfigurator config = new NameDetailsConfigurator(true);
if (local){
- config.setSimpleDetailsViewActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION));
- config.setAppendedPhraseActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
- config.setAtomisedEpithetsActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
- config.setAuthorshipSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
- config.setLSIDActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID));
- config.setNameApprobiationActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION));
- config.setNameCacheActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_CACHE));
- config.setNameRelationsSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
- config.setNomenclaturalCodeActived(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
- config.setNomenclaturalStatusSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
- config.setNomenclaturalReferenceSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
- config.setProtologueActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
- config.setRankActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK));
- config.setTaxonSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON));
- config.setTypeDesignationSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
- config.setHybridActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID));
+ config.setSimpleDetailsViewActivated(getBooleanValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION));
+ config.setAppendedPhraseActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
+ config.setAtomisedEpithetsActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
+ config.setAuthorshipSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
+ config.setLSIDActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID));
+ config.setNameApprobiationActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION));
+ config.setNameCacheActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_CACHE));
+ config.setNameRelationsSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
+ config.setNomenclaturalCodeActived(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
+ config.setNomenclaturalStatusSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
+ config.setNomenclaturalReferenceSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
+ config.setProtologueActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
+ config.setRankActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK));
+ config.setTaxonSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON));
+ config.setTypeDesignationSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
+ config.setHybridActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID));
}else{
}
public static void saveConfigToPrefernceStore(NameDetailsConfigurator config) {
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION,
+ setBooleanValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION,
config.isSimpleDetailsViewActivated());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, config.isTaxonSectionActivated());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, config.isLSIDActivated());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
+ setBooleanValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, config.isTaxonSectionActivated());
+ setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, config.isLSIDActivated());
+ setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
config.isNomenclaturalCodeActived());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE,
+ setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE,
config.isNameCacheActivated());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
+ setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
config.isAppendedPhraseActivated());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, config.isRankActivated());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
+ setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, config.isRankActivated());
+ setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
config.isAtomisedEpithetsActivated());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE,
+ setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE,
config.isAuthorCacheActivated());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
+ setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
config.isAuthorshipSectionActivated());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
+ setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
config.isNomenclaturalReferenceSectionActivated());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
+ setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
config.isNomenclaturalStatusSectionActivated());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
+ setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
config.isProtologueActivated());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
+ setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
config.isTypeDesignationSectionActivated());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
+ setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
config.isNameRelationsSectionActivated());
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID,
+ setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID,
config.isHybridActivated());
}
+/**
+ * @return
+ */
+public static boolean isSortTaxaByRankAndName() {
+
+ return getBooleanValue(IPreferenceKeys.SORT_TAXA_BY_RANK_AND_NAME);
+}
+
+/**
+ * @return
+ */
+public static boolean isSortNamedAreaByOrderInVocabulary() {
+
+ return getBooleanValue(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getKey());
+}
+
+public static void setSortNamedAreasByOrderInVocabulary(boolean isSortByVocabularyOrder) {
+ setBooleanValue(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getKey(), isSortByVocabularyOrder);
+
+}
+
+/**
+ * <p>
+ * setPreferredNamedAreasForDistributionEditor
+ * </p>
+ *
+ * @param saveCheckedElements
+ * @param saveGrayedElements
+ */
+public static void setLastSelectedReference(
+ List<String> lastSelectedReferences) {
+
+ setStringValue(PreferencesUtil.LAST_SELECTED_REFERENCES, lastSelectedReferences.toString());
+ }
+
+/**
+ * <p>
+ * setPreferredNamedAreasForDistributionEditor
+ * </p>
+ *
+ * @param saveCheckedElements
+ * @param saveGrayedElements
+ */
+public static List<String> getLastSelectedReferences() {
+
+ //IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
+ String lastSelected = getStringValue(PreferencesUtil.LAST_SELECTED_REFERENCES);
+ List<String> result = new ArrayList<>();
+ if (!StringUtils.isBlank(lastSelected)){
+ Collections.addAll(result, lastSelected.substring(1,lastSelected.length()-1).split(", "));
+ }
+ return result;
+ }
+
+
+/**
+ * <p>
+ * setPreferredNamedAreasForDistributionEditor
+ * </p>
+ *
+ * @param saveCheckedElements
+ * @param saveGrayedElements
+ */
+public static void setPreferredNamedAreasForDistributionEditor(
+ String saveCheckedElements, String saveGrayedElements, boolean local) {
+ if (local){
+ setStringValue(EditorPreferencePredicate.AvailableDistributionAreaTerms.getKey(), saveCheckedElements);
+
+ }
+ else{
+ CdmPreference preference = null;
+
+ if (saveCheckedElements == null){
+ preference = getPreferenceFromDB(EditorPreferencePredicate.AvailableDistributionAreaTerms);
+
+ if (preference == null){
+ return ;
+ } else{
+ setStringValue(EditorPreferencePredicate.AvailableDistributionAreaTerms.getKey(),
+ saveCheckedElements);
+ preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
+ setPreferenceToDB(preference);
+
+ }
+ } else{
+ preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
+ setPreferenceToDB(preference);
+ setStringValue(EditorPreferencePredicate.AvailableDistributionAreaTerms.getKey(),
+ saveCheckedElements);
+
+ }
+ }
+
+}
+
+/**
+ * @param saveCheckedElements
+ * @param saveCheckedElements2
+ * @param b
+ */
+public static void setPreferredVocabulariesForDistributionEditor(String saveCheckedElements,
+ boolean local, boolean isOverride) {
+ if (local){
+ setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(), saveCheckedElements);
+ setBooleanValue(prefOverrideKey(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey()), isOverride);
+ }
+ else{
+ ICdmRepository controller;
+ CdmPreference preference = null;
+
+ if (saveCheckedElements == null){
+ preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
+
+ if (preference == null){
+ return ;
+ } else{
+ setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(),
+ saveCheckedElements);
+ preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
+ preference.setAllowOverride(isOverride);
+ setPreferenceToDB(preference);
+ }
+ } else{
+ preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
+ preference.setAllowOverride(isOverride);
+ setPreferenceToDB(preference);
+ setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(),
+ saveCheckedElements);
+
+ }
+ }
+}
+
+
+
+
+/**
+ * @param saveCheckedElements
+ * @param saveCheckedElements2
+ * @param b
+ */
+public static String getPreferredVocabulariesForDistributionEditor(boolean local) {
+ if (local){
+
+ String pref = getStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(), local);
+ return pref;
+ }
+ else{
+ CdmPreference preference = null;
+ preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
+ if (preference == null){
+ return null;
+ } else{
+ return preference.getValue();
+ }
+
+ }
+
+
+
+}
+
+public static boolean getFilterCommonNameReferences(){
+ return getBooleanValue(PreferencesUtil.FILTER_COMMON_NAME_REFERENCES);
+}
+
+/**
+ *
+ */
+public static void updateDBPreferences() {
+ CdmPreference preference = null;
+ CdmPreferenceCache cache = CdmPreferenceCache.instance();
+ cache.getAllTaxEditorDBPreferences();
+
+ //ABCD Configurator
+
+ updateAbcdImportConfigurationPreference();
+
+ //Name Details
+ NameDetailsConfigurator config = getPreferredNameDetailsConfiguration(false);
+ if (config != null ){
+ if (!getBooleanValue(OVERRIDE_NAME_DETAILS) || !getBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS)){
+ setPreferredNameDetailsConfiguration(config, false);
+ }
+ }
+
+
+
+
+
+
+
+
+}
+
+
+
+
+
+
}