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 org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
-import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
+import eu.etaxonomy.cdm.api.application.ICdmRepository;
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.IFindTaxaAndNamesConfigurator;
import eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
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;
-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.model.term.FeatureTree;
+import eu.etaxonomy.cdm.model.term.IDefinedTerm;
+import eu.etaxonomy.cdm.model.term.ISimpleTerm;
+import eu.etaxonomy.cdm.model.term.TermBase;
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 {
public static final String P2_REPOSITORIES_DELIM = ",";
public static final String P2_REPOSITORY_FIELDS_DELIM = ";";
+ private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
+
+
+
/**
return TaxeditorStorePlugin.getDefault().getPreferenceStore();
}
+ static String prefKey(String name) {
+ return name + "_"+ ((CdmRemoteSource)CdmStore.getActiveCdmSource()).toString();
+ }
+
+ public static String prefOverrideKey(String name) {
+ return name + "_OVERRIDE_";
+ }
+
+ /**
+ * <p>
+ * setStringValue
+ * </p>
+ *
+ *
+ **/
+ public static void setStringValue(String name, String value) {
+ if (value != null){
+ getPreferenceStore().setValue(prefKey(name), value);
+ }else{
+ getPreferenceStore().setToDefault(name);
+ }
+ }
+
+ /**
+ * <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(prefKey(name), 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) {
+
+ CdmPreference pref = getDBPreferenceValue(name);
+ String prefValue = null;
+ String overrideKey = createPreferenceString(createOverridePreferenceString(name));
+ boolean override = true;
+ if (getPreferenceStore().contains(overrideKey)){
+ override = getPreferenceStore().getBoolean(overrideKey);
+ }
+ if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
+ String dbSpecific = prefKey(name);
+ if (getPreferenceStore().contains(dbSpecific)){
+ prefValue = getPreferenceStore().getString(dbSpecific);
+ }else{
+ prefValue = getPreferenceStore().
+ getString(name);
+ }
+ }else if (pref != null){
+ prefValue = pref.getValue();
+ }
+ return prefValue;
+
+ }
+
+ public static String getStringValue(String name){
+ return getStringValue(name, false);
+ }
+
+ private static CdmPreference getDBPreferenceValue(String name) {
+ CdmPreferenceCache cache = CdmPreferenceCache.instance();
+ CdmPreference pref = null;
+//
+ pref = cache.get(name);
+ if (pref == null ){
+ //get default value for Predicate
+ IPreferencePredicate pred = PreferencePredicate.getByKey(name);
+ if (pred != null){
+ if (pred.getDefaultValue() != null){
+ pref = CdmPreference.NewTaxEditorInstance(pred, pred.getDefaultValue().toString());
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance(pred, null);
+ }
+ pref.setAllowOverride(true);
+ }
+ }
+ return pref;
+ }
+
+ /**
+ * <p>
+ * setIntValue
+ * </p>
+ *
+ *
+ **/
+ public static int getIntValue(String name) {
+ CdmPreference pref= getDBPreferenceValue(name);
+ String prefValue = null;
+ if (pref != null){
+ prefValue = pref.getValue();
+ }
+ 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;
+
+
+ }
+
+ public static boolean getBooleanValue(String name) {
+ return getBooleanValue(name, false);
+ }
+
+ /**
+ * <p>
+ * getBooleanValue
+ * </p>
+ *
+ *
+ **/
+ public static boolean getBooleanValue(String name, boolean local) {
+ if (CdmStore.isActive()){
+ CdmPreference pref = getDBPreferenceValue(name);
+ String prefValue = null;
+ if (pref == null || local){
+ String dbSpecific = prefKey(name);
+ if (getPreferenceStore().contains(dbSpecific)){
+ return getPreferenceStore().getBoolean(dbSpecific);
+ }else{
+ return getPreferenceStore().
+ getBoolean(name);
+ }
+ }else{
+ return Boolean.valueOf(pref.getValue());
+ }
+
+ }else{
+ return getPreferenceStore().getBoolean(name);
+ }
+
+ }
+
+ /**
+ * <p>
+ * setBooleanValue
+ * </p>
+ *
+ *
+ **/
+ public static double getDoubleValue(String name) {
+ CdmPreference pref = getDBPreferenceValue(name);
+ String prefValue = null;
+ if (pref != null){
+ prefValue = pref.getValue();
+ }
+ 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) {
+ CdmPreference pref = getDBPreferenceValue(name);
+ String prefValue = null;
+ if (pref != null){
+ prefValue = pref.getValue();
+ }
+ 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) {
+ CdmPreference pref = getDBPreferenceValue(name);
+ String prefValue = null;
+ if (pref != null){
+ prefValue = pref.getValue();
+ }
+ 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{
- ICdmApplicationConfiguration controller;
+ 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);
}
}
- public static NomenclaturalCode getPreferredNomenclaturalCode(){
- if (getPreferenceStore().getBoolean(OVERRIDE_NOMENCLATURAL_CODE_KEY)) {
- return getPreferredNomenclaturalCode(true);
- } else{
- return getPreferredNomenclaturalCode(false);
+ /**
+ * <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);
+
+ }
+
+
+
/**
* <p>
*
* @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
*/
- public static NomenclaturalCode getPreferredNomenclaturalCode(boolean useLocal) {
- ICdmApplicationConfiguration controller;
- CdmPreference pref = null;
- if (!useLocal){
- try{
- controller = CdmStore.getCurrentApplicationConfiguration();
- PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
- pref = controller.getPreferenceService().find(key);
- }catch(Exception e){
- e.printStackTrace();
- }
- }
+ public static NomenclaturalCode getPreferredNomenclaturalCode() {
+
+ CdmPreference pref = getPreferenceFromDB(PreferencePredicate.NomenclaturalCode);
+
String preferredCode;
- if(pref == null){
- preferredCode = getPreferenceStore().getString(
- PREFERRED_NOMENCLATURAL_CODE_KEY);
+ if(pref == null || (pref.isAllowOverride() && getBooleanValue(prefOverrideKey(PreferencePredicate.NomenclaturalCode.getKey())))){
+ preferredCode = getStringValue(
+ PreferencePredicate.NomenclaturalCode.getKey(), true);
}else{
preferredCode = pref.getValue();
}
+ if (StringUtils.isBlank(preferredCode)){
+ preferredCode = getPreferenceKey((NomenclaturalCode)PreferencePredicate.NomenclaturalCode.getDefaultValue());
+ }
- for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
- if (getPreferenceKey(code).equals(preferredCode)) {
- return code;
- }
- }
- return null;
+ return getPreferredNomenclaturalCode(preferredCode);
+
+ }
+
+ /**
+ * <p>
+ * getPreferredNomenclaturalCode
+ * </p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
+ */
+ public static NomenclaturalCode getPreferredNomenclaturalCode(String preferenceKeyNomenclaturalCode) {
+
+ for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
+ if (getPreferenceKey(code).equals(preferenceKeyNomenclaturalCode)) {
+ return code;
+ }
+ }
+ return null;
+ }
+
+ public static boolean isShowTaxonAssociations(){
+ boolean result = getBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey());
+ return result;
+ }
+
+ public static boolean isShowLifeForm(){
+ boolean result = getBooleanValue(PreferencePredicate.ShowLifeForm.getKey());
+ return result;
+ }
+
+ public static boolean isDeterminationOnlyForFieldUnits(){
+ boolean result = getBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey());
+ return result;
+ }
+
+ public static boolean isCollectingAreaInGeneralSection(){
+ boolean result = getBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey());
+ return result;
}
+ public static CdmPreference getPreferenceFromDB(IPreferencePredicate predicate){
+ ICdmRepository controller;
+ CdmPreference pref = null;
+
+ try{
+ if(CdmStore.isActive()){
+ controller = CdmStore.getCurrentApplicationConfiguration();
+ PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), predicate);
+ pref = controller.getPreferenceService().find(key);
+ }
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+
+ return pref;
+
+ }
+
+ public static List<CdmPreference> getPreferencesFromDB(IPreferencePredicate predicate){
+ ICdmRepository controller;
+ List<CdmPreference> prefs = null;
+
+ try{
+ if(CdmStore.isActive()){
+ controller = CdmStore.getCurrentApplicationConfiguration();
+ PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), predicate);
+ prefs = controller.getPreferenceService().list(predicate);
+ }
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+
+ return prefs;
+
+ }
+
+ public static CdmPreference getPreferenceFromDB(PrefKey key){
+ ICdmRepository controller;
+ CdmPreference pref = null;
+
+ try{
+ if(CdmStore.isActive()){
+ controller = CdmStore.getCurrentApplicationConfiguration();
+ pref = controller.getPreferenceService().find(key);
+ }
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+
+ return pref;
+
+ }
+
+
+
+ public static void setPreferenceToDB(CdmPreference preference){
+ ICdmRepository controller;
+ try{
+ if(CdmStore.isActive()){
+ controller = CdmStore.getCurrentApplicationConfiguration();
+ controller.getPreferenceService().set(preference);
+ CdmPreferenceCache.instance().put(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(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, 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(createPreferenceString(OPENURL_IMAGE_MAX_WIDTH), "1000");
+ getPreferenceStore().setDefault(createPreferenceString(OPENURL_IMAGE_MAX_HEIGHT), "1000");
+ //Distribution Editor:
+ getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DistributionEditorActivated.getKey()), Boolean.valueOf(PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString()));
+// getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString());
+// getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DisplayOfStatus.getKey()), PreferencePredicate.DisplayOfStatus.getDefaultValue().toString());
+
+
+ //Name Details
+ getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.NameDetailsView.getKey()), new NameDetailsConfigurator(false).toString());
+
+ //Navigator preferences
+ getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.TaxonNodeOrder.getKey()), NavigatorOrderEnum.RankAndNameOrder.getKey());
+
+ getPreferenceStore().setDefault(createPreferenceString(SORT_TAXA_BY_RANK_AND_NAME), true);
+
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_ADVANCED_MEDIA_SECTION), false);
+
+ getPreferenceStore().setDefault(createPreferenceString(SHOW_MEDIA_PREVIEW), false);
+ //override db preferences
+ getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.AbcdImportConfig.getKey())), false);
+ getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.ShowSpecimen.getKey())), true);
+ getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.NameDetailsView.getKey())), false);
+ getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey())), true);
+ getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.AvailableDistributionStatus.getKey())), true);
+ getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.AvailableDistributionAreaTerms.getKey())), true);
+ getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey())), true);
+ getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.CommonNameAreaVocabularies.getKey())), false);
+ getPreferenceStore().setDefault(createPreferenceString(FILTER_COMMON_NAME_REFERENCES), false);
+ getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowTaxonNodeWizard.getKey()), Boolean.valueOf(PreferencePredicate.ShowTaxonNodeWizard.getDefaultValue().toString()));
+ getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowNamespaceInSource.getKey()), Boolean.valueOf(PreferencePredicate.ShowNamespaceInSource.getDefaultValue().toString()));
+ getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowIdInSource.getKey()), Boolean.valueOf(PreferencePredicate.ShowIdInSource.getDefaultValue().toString()));
+ getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DisableMultiClassification.getKey()), Boolean.valueOf(PreferencePredicate.DisableMultiClassification.getDefaultValue().toString()));
+ getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowImportExportMenu.getKey()), Boolean.valueOf(PreferencePredicate.ShowImportExportMenu.getDefaultValue().toString()));
+
}
/**
*/
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);
+ if (PreferencesUtil.getPreferredNomenclaturalCode() == null) {
+ PreferencesUtil.setPreferredNomenclaturalCode(getPreferenceKey(NomenclaturalCode.ICNAFP), true);
}
}
public static void setNomenclaturalCodePreferences(){
- ICdmApplicationConfiguration controller;
+ ICdmRepository controller;
controller = CdmStore.getCurrentApplicationConfiguration();
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
CdmPreference preference = null;
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;
}
* getDefaultFeatureTreeForTextualDescription
* </p>
*
- * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
+ * @return a {@link eu.etaxonomy.cdm.model.term.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 (StringUtils.isBlank(uuidString)) {
+ return null;
+ }
+ FeatureTree tree = CdmStore.getService(
+ IFeatureTreeService.class).load(UUID.fromString(uuidString));
+ if (tree.getId() == 0) {
+ return null;
+ }
+ return tree;
}
/**
* getDefaultFeatureTreeForStructuredDescription
* </p>
*
- * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
+ * @return a {@link eu.etaxonomy.cdm.model.term.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(PreferencePredicate.TaxonNodeOrder.getKey(), 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(PreferencePredicate.TaxonNodeOrder.getKey()));
- /**
- * <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(PreferencePredicate.TaxonNodeOrder.getKey()));
+ return value.equals(NavigatorOrderEnum.NaturalOrder);
+
+ }
+ /**
+ * @param orderActivated
+ */
+ public static boolean isNodesSortedByName() {
+ NavigatorOrderEnum value = NavigatorOrderEnum.valueOf(getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()));
+ return value.equals(NavigatorOrderEnum.AlphabeticalOrder);
+
+ }
+
+ /**
+ * @param orderActivated
+ */
+ public static boolean isNodesSortedByNameAndRank() {
+ NavigatorOrderEnum value = NavigatorOrderEnum.valueOf(getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()));
+ 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(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
+ if (area_display.equals(TermDisplayEnum.IdInVocabulary.getKey())) {
+ return true;
+ }else{
+ return false;
+ }
+ }
+ public static boolean isShowSymbol1InChecklistEditor() {
+ String area_display = getStringValue(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
+ if (area_display.equals(TermDisplayEnum.Symbol1.getKey())) {
+ return true;
+ }else{
+ return false;
+ }
+ }
+ public static boolean isShowSymbol2InChecklistEditor() {
+ String area_display = getStringValue(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
+ if (area_display.equals(TermDisplayEnum.Symbol2.getKey())) {
+ return true;
+ }else{
+ return false;
+ }
+ }
+ public static void setAreaDisplayInChecklistEditor(String selection) {
+ setStringValue(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey(), selection);
+ }
+
+ public static void setOwnDescriptionForChecklistEditor(boolean selection) {
+ setBooleanValue(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey(), selection);
}
- public static void setShowIdInVocabularyInChecklistEditor(boolean selection) {
- getPreferenceStore().setValue(CHECKLIST_ID_IN_VOCABULARY, selection);
+
+ public static boolean isOwnDescriptionForChecklistEditor() {
+ return getBooleanValue(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey());
+ }
+
+ /**
+ * @return
+ */
+ public static String displayAreaInChecklistEditor() {
+ String result = getStringValue(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
+ if (StringUtils.isBlank(result)){
+ return ((TermDisplayEnum) PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue()).getKey();
+ }
+ return result;
+ }
+
+ /**
+ * @return
+ */
+ public static String displayStatusInChecklistEditor() {
+ String result = getStringValue(PreferencePredicate.DisplayOfStatus.getKey());
+ if (StringUtils.isBlank(result)){
+ return((TermDisplayEnum) PreferencePredicate.DisplayOfStatus.getDefaultValue()).getKey();
+ }
+ return result;
+ }
+ public static void setDisplayStatusInChecklistEditor(String selection) {
+ setStringValue(PreferencePredicate.DisplayOfStatus.getKey(), selection);
+
}
/**
* @return
*/
public static boolean isShowRankInChecklistEditor() {
- return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_SHOW_RANK);
+ return getBooleanValue(PreferencePredicate.ShowRankInDistributionEditor.getKey());
}
public static void setShowRankInChecklistEditor(boolean selection) {
- getPreferenceStore().setValue(CHECKLIST_SHOW_RANK, selection);
+ setBooleanValue(PreferencePredicate.ShowRankInDistributionEditor.getKey(), selection);
}
/**
* @param b
* @return
*/
- public static NameDetailsConfigurator setPreferredNameDetailsConfiguration( boolean local) {
+ public static NameDetailsConfigurator getPreferredNameDetailsConfiguration( boolean local) {
NameDetailsConfigurator config = new NameDetailsConfigurator(true);
- ICdmApplicationConfiguration controller;
- controller = CdmStore.getCurrentApplicationConfiguration();
- PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NameDetailsView);
+ CdmPreferenceCache cache = CdmPreferenceCache.instance();
CdmPreference preference = null;
- if (controller == null){
- return null;
+ String value;
+ if (!local) {
+ PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.NameDetailsView);
+ preference = cache.findBestMatching(key);
+ if (preference == null){
+ return null;
+ }
+
+ // setBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS, preference.isAllowOverride());
+ value = preference.getValue();
+ config.setAllowOverride(preference.isAllowOverride());
+ //the preference value is build like this:
+ //<section1>:true;<section2>:false....
+ }else{
+ value = getStringValue(PreferencePredicate.NameDetailsView.getKey(), local);
}
- preference = controller.getPreferenceService().find(key);
- if (preference == null){
- return null;
+ 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]));
}
- getPreferenceStore().setValue(ALLOW_OVERRIDE_NAMEDETAILS, preference.isAllowOverride());
- //the preference value is build like this:
- //<section1>:true;<section2>:false....
+ config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
+
+ config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
+
+ config.setSecDetailsActivated(getValue(sectionMap, "taxon.SecDetails"));
+ config.setSecEnabled(getValue(sectionMap, "taxon.SecEnabled"));
+
+ config.setLSIDActivated(getValue(sectionMap, "lsid"));
+
+ config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
+
+ config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
+
+ config.setRankActivated(getValue(sectionMap, "rank"));
+
+ config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
+
+ config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
+
+ config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
+
+ config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
+
+ config.setProtologueActivated(getValue(sectionMap,"protologue"));
+
+ config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
+
+ config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
+
+ config.setHybridActivated(getValue(sectionMap,"hybrid"));
+
+ return config;
+ }
+
+ public static NameDetailsConfigurator getPreferredNameDetailsConfiguration() {
+ NameDetailsConfigurator config = new NameDetailsConfigurator(true);
+
+ String value;
+
+ value = getStringValue(PreferencePredicate.NameDetailsView.getKey(), false);
- String value = preference.getValue();
String [] sections = value.split(";");
Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
String[] sectionValues;
sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
}
+ config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
+ config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
- getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
- (sectionMap.get("taxon")));
- config.setTaxonSectionActivated(sectionMap.get("taxon"));
+ config.setSecDetailsActivated(getValue(sectionMap, "taxon.SecDetails"));
+ config.setSecEnabled(getValue(sectionMap, "taxon.SecEnabled"));
- getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
- (sectionMap.get("lsid")));
- config.setLSIDActivated(sectionMap.get("lsid"));
+ config.setLSIDActivated(getValue(sectionMap, "lsid"));
- getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
- (sectionMap.get("nc")));
- config.setNomenclaturalCodeActived(sectionMap.get("nc"));
+ config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
- getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
- (sectionMap.get("ap")));
- config.setAppendedPhraseActivated(sectionMap.get("ap"));
+ config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
- getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
- (sectionMap.get("rank")));
- config.setRankActivated(sectionMap.get("rank"));
+ config.setRankActivated(getValue(sectionMap, "rank"));
+ config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
- getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
- (sectionMap.get("atomisedEpithets")));
- config.setAtomisedEpithetsActivated(sectionMap.get("atomisedEpithets"));
+ config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
- getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
- (sectionMap.get("author")));
- config.setAuthorshipSectionActivated(sectionMap.get("author"));
-
- getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
- (sectionMap.get("nomRef")));
config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
- getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
- (sectionMap.get("nomStat")));
- config.setNomenclaturalStatusSectionActivated(sectionMap.get("nomStat"));
+ config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
+
+ config.setProtologueActivated(getValue(sectionMap,"protologue"));
+
+ config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
+
+ config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
+
+ config.setHybridActivated(getValue(sectionMap,"hybrid"));
+
+ return config;
+ }
+
+
+ /**
+ * @param object
+ * @param b
+ * @return
+ */
+ public static void setPreferredNameDetailsConfiguration(NameDetailsConfigurator config, boolean local) {
+ CdmPreference preference = null;
+
+ if (!local) {
+ preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.NameDetailsView, config.toString());
+
+ setPreferenceToDB(preference);
+ }
+ else{
+ setStringValue(PreferencePredicate.NameDetailsView.getKey(), config.toString());
+ }
+
+
+ }
+
+ private static Boolean getValue(Map<String, Boolean> sectionMap, String string) {
+ if (sectionMap.containsKey(string)){
+ return sectionMap.get(string);
+ }else{
+ return true;
+ }
+
+ }
+
- getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
- (sectionMap.get("protologue")));
- config.setProtologueActivated(sectionMap.get("protologue"));
+ /**
+ * <p>
+ * setAbcdConfigurator
+ * </p>
+ *
+ * @param preferredConfiguration
+ * a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
+ * object.
+ */
+ public static Abcd206ImportConfigurator getDBAbcdImportConfigurationPreference() {
- getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
- (sectionMap.get("typeDes")));
- config.setTypeDesignationSectionActivated(sectionMap.get("typeDes"));
+ Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
+ ICdmRepository controller;
+ controller = CdmStore.getCurrentApplicationConfiguration();
+ PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AbcdImportConfig);
+ CdmPreference preference = null;
+ if (controller == null){
+ return null;
+ }
+ 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 = null;
+ if (keyValue.length>1){
+ valueString = keyValue[1];
+ }
+ if (keyString.equals("ignoreImportOfExistingSpecimen")){
+ config.setIgnoreImportOfExistingSpecimen(Boolean.valueOf(valueString));
+ }else if (keyString.equals("addIndividualsAssociationsSuchAsSpecimenAndObservations")){
+ config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(Boolean.valueOf(valueString));
+ }else if (keyString.equals("reuseExistingTaxaWhenPossible")){
+ config.setReuseExistingTaxaWhenPossible(Boolean.valueOf(valueString));
+ }else if (keyString.equals("ignoreAuthorship")){
+ config.setIgnoreAuthorship(Boolean.valueOf(valueString));
+ }else if (keyString.equals("addMediaAsMediaSpecimen")){
+ config.setAddMediaAsMediaSpecimen(Boolean.valueOf(valueString));
+ }else if (keyString.equals("reuseExistingMetaData")){
+ config.setReuseExistingMetaData(Boolean.valueOf(valueString));
+ }else if (keyString.equals("reuseExistingDescriptiveGroups")){
+ config.setReuseExistingDescriptiveGroups(Boolean.valueOf(valueString));
+ }else if (keyString.equals("allowReuseOtherClassifications")){
+ config.setAllowReuseOtherClassifications(Boolean.valueOf(valueString));
+ }else if (keyString.equals("deduplicateReferences")){
+ config.setDeduplicateReferences(Boolean.valueOf(valueString));
+ }else if (keyString.equals("deduplicateClassifications")){
+ config.setDeduplicateClassifications(Boolean.valueOf(valueString));
+ }else if (keyString.equals("moveNewTaxaToDefaultClassification")){
+ config.setMoveNewTaxaToDefaultClassification(Boolean.valueOf(valueString));
+ }else if (keyString.equals("mapUnitIdToCatalogNumber")){
+ config.setMapUnitIdToCatalogNumber(Boolean.valueOf(valueString));
+ }else if (keyString.equals("mapUnitIdToAccessionNumber")){
+ config.setMapUnitIdToAccessionNumber(Boolean.valueOf(valueString));
+ }else if (keyString.equals("mapUnitIdToBarcode")){
+ 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;
+ }
- getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
- (sectionMap.get("nameRelation")));
- config.setNameRelationsSectionActivated(sectionMap.get("nameRelation"));
+ 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.findBestMatching(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AbcdImportConfig));
+
+ if (!getBooleanValue(prefOverrideKey(PreferencePredicate.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());
+ }
+ }
+
+
+
+
+
+
+
+/**
+ * @return
+ */
+public static boolean isSortTaxaByRankAndName() {
+
+ return getBooleanValue(IPreferenceKeys.SORT_TAXA_BY_RANK_AND_NAME);
+}
+
+/**
+ * @return
+ */
+public static String getSortNamedAreasInDistributionEditor() {
+
+ return getStringValue(PreferencePredicate.AreasSortedInDistributionEditor.getKey());
+}
+
+public static void setSortNamedAreasInDistributionEditor(String isSortByVocabularyOrder) {
+ setStringValue(PreferencePredicate.AreasSortedInDistributionEditor.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(PreferencePredicate.AvailableDistributionAreaTerms.getKey(), saveCheckedElements);
+
+ }
+ else{
+ CdmPreference preference = null;
+
+ if (saveCheckedElements == null){
+ preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaTerms);
+
+ if (preference == null){
+ return ;
+ } else{
+ setStringValue(PreferencePredicate.AvailableDistributionAreaTerms.getKey(),
+ saveCheckedElements);
+ preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
+ setPreferenceToDB(preference);
+
+ }
+ } else{
+ preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
+ setPreferenceToDB(preference);
+ setStringValue(PreferencePredicate.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 List<UUID> createUUIDListFromStringPref(String prefKey) {
+ String prefValue = PreferencesUtil.getStringValue(prefKey);
+ String[] stringArray = prefValue.split(";");
+ List<UUID> uuidList = new ArrayList();
+ for (String uuid: stringArray){
+ if (!StringUtils.isBlank(uuid)){
+ uuidList.add(UUID.fromString(uuid));
+ }
+ }
+ return uuidList;
+}
+
+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);
+// }
+// }
+
+
+
+
+
+
+
+
+}
+
+/**
+ * @param string
+ * @param saveCheckedElements
+ */
+public static void setPreferencesToDB(List<CdmPreference> preferences) {
+
+ ICdmRepository controller;
+ try{
+ if(CdmStore.isActive()){
+ controller = CdmStore.getCurrentApplicationConfiguration();
+ for (CdmPreference preference: preferences){
+
+ controller.getPreferenceService().set(preference);
+
+ CdmPreferenceCache.instance().put(preference);
+ }
+ }
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+}
+
+
+
+
+
+
+
+
}