* a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
* object.
*/
- public static NomenclaturalCode setPreferredNomenclaturalCode(
+ public static CdmPreference setPreferredNomenclaturalCode(
NomenclaturalCode preferredCode, boolean local) {
if (local){
getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
int index = StringUtils.lastIndexOf(preference.getValue(), ".");
UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
preferredCode = NomenclaturalCode.getByUuid(uuid);
- return preferredCode;
+
+ 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());
}
}
- return preferredCode;
+ return null;
if (PreferencesUtil.getPreferredNomenclaturalCode(true) == null) {
PreferencesUtil.setPreferredNomenclaturalCode(NomenclaturalCode.ICNAFP, true);
- /*
-
- StoreUtil.info("No nomencatural code set.");
-
- Shell shell = StoreUtil.getShell();
-
- Query user re: preferred nom. code
- Dialog dialog = new InitNomenclaturalCodePrefDialog(shell);
- dialog.open();
-
- // Short message confirming user's choice
- NomenclaturalCode code = PreferencesUtil
- .getPreferredNomenclaturalCode();
- MessageDialog
- .openInformation(
- shell,
- "Nomenclatural code set",
- "The following has been set as your preferred nomenclatural code:\n\n\t"
- + NomenclaturalCodeHelper
- .getDescription(code)
- + "\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");*/
}
+
+
+
+ }
+ public static void setNomenclaturalCodePreferences(){
+ ICdmApplicationConfiguration controller;
+ controller = CdmStore.getCurrentApplicationConfiguration();
+ PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
+ CdmPreference preference = null;
+ if (controller == null){
+ return ;
+ }
+ preference = controller.getPreferenceService().find(key);
+ if (preference == null){
+ return;
+ }
+ getPreferenceStore().setValue(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,
+ getPreferenceKey(preferredCode));
+
+ if (!preference.isAllowOverride()){
+ getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
+ getPreferenceKey(preferredCode));
+ }
}
public static void checkDefaultLanguage(){