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;
private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
+
+
/**
* <p>
* getPreferenceStore
* object.
*/
public static CdmPreference setPreferredNomenclaturalCode(
- NomenclaturalCode preferredCode, boolean local) {
+ String preferenceKey, boolean local) {
if (local){
getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
- getPreferenceKey(preferredCode));
+ preferenceKey);
}
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 (preferenceKey == 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);
+// int index = StringUtils.lastIndexOf(preference.getValue(), ".");
+// UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
+// preferredCode = NomenclaturalCode.getByUuid(uuid);
- getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
- getPreferenceKey(preferredCode));
+ getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
+ preferenceKey);
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, preferenceKey);
controller.getPreferenceService().set(preference);
}
preferredCode = pref.getValue();
}
- 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(){
if (getPreferenceStore().getBoolean(OVERRIDE_SPECIMEN_PREF) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF)) {
return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS);
}
+ 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);
* 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
"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);
+ //Distribution Editor:
+ getPreferenceStore().setDefault(DISTRIBUTION_AREA_PREFRENCES_ACTIVE, false);
getPreferenceStore().setDefault(CHECKLIST_ID_IN_VOCABULARY, true);
getPreferenceStore().setDefault(CHECKLIST_SYMBOL, false);
+
+
+ //Name Details
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_PROTOLOGUE, true);
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_RANK, true);
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, true);
+ //Navigator preferences
getPreferenceStore().setDefault(SORT_NODES_NATURALLY, false);
getPreferenceStore().setDefault(SORT_NODES_ALPHABETICALLY, false);
+ getPreferenceStore().setDefault(SORT_TAXA_BY_RANK_AND_NAME, true);
+ //override db preferences
+ getPreferenceStore().setDefault(ABCD_IMPORT_OVERRIDE, false);
+ getPreferenceStore().setDefault(OVERRIDE_SPECIMEN_PREF, false);
+ getPreferenceStore().setDefault(OVERRIDE_NAME_DETAILS, false);
+ getPreferenceStore().setDefault(DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE, false);
+
}
*/
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);
}
UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
NomenclaturalCode preferredCode = NomenclaturalCode.getByUuid(uuid);
- getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
+ getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
getPreferenceKey(preferredCode));
- if (!preference.isAllowOverride()){
- getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
- getPreferenceKey(preferredCode));
- }
}
public static void checkDefaultLanguage(){
* @param b
* @return
*/
- public static NameDetailsConfigurator setPreferredNameDetailsConfiguration( boolean local) {
+ public static NameDetailsConfigurator getPreferredNameDetailsConfiguration( boolean local) {
NameDetailsConfigurator config = new NameDetailsConfigurator(true);
CdmPreference preference = null;
if (!local) {
preference = getPreferenceFromDB(PreferencePredicate.NameDetailsView);
- }
- if (preference == null){
- return null;
- }
+ if (preference == null){
+ return null;
+ }
- getPreferenceStore().setValue(ALLOW_OVERRIDE_NAME_DETAILS, preference.isAllowOverride());
+ getPreferenceStore().setValue(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"));
+
+ // 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(getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_SECTION));
+ config.setTaxonSectionActivated(getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_TAXON));
+ config.setLSIDActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_LSID));
+ config.setNomenclaturalCodeActived(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
+ config.setAppendedPhraseActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
+ config.setRankActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_RANK));
+ config.setAtomisedEpithetsActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
+ config.setAuthorshipSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
+ config.setNomenclaturalReferenceSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
+ config.setNomenclaturalStatusSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
+ config.setProtologueActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
+ config.setTypeDesignationSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
+ config.setNameRelationsSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
+ config.setHybridActivated(getPreferenceStore().getBoolean(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(), PreferencePredicate.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
+ getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_SECTION, config.isSimpleDetailsViewActivated());
+ getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON, config.isTaxonSectionActivated());
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID, config.isLSIDActivated());
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, config.isNomenclaturalCodeActived());
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, config.isAppendedPhraseActivated());
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK, config.isRankActivated());
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, config.isAtomisedEpithetsActivated());
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, config.isAuthorshipSectionActivated());
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, config.isNomenclaturalReferenceSectionActivated());
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, config.isNomenclaturalStatusSectionActivated());
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, config.isProtologueActivated());
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, config.isTypeDesignationSectionActivated());
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, config.isNameRelationsSectionActivated());
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_HYBRID, config.isHybridActivated());
- return config;
}
private static Boolean getValue(Map<String, Boolean> sectionMap, String string) {
* a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
* object.
*/
- public static Abcd206ImportConfigurator getAbcdImportConfigurationPreference(boolean useLocal) {
+ public static Abcd206ImportConfigurator getAbcdImportConfigurationPreference() {
Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,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);
+ boolean allowOverride = true;
+ if (preference != null && !preference.isAllowOverride()){
+ allowOverride = false;
+ }
+ if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_OVERRIDE) && allowOverride){
- 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.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));
+ config.setNomenclaturalCode(NomenclaturalCode.getByKey(PreferencesUtil.getPreferenceStore().getString(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE)));
return config;
}
- 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{
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 void updateAbcdImportConfigurationPreference() {
+
+ Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
+ ICdmRepository controller;
+ controller = CdmStore.getCurrentApplicationConfiguration();
+ PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AbcdImportConfig);
+ CdmPreference preference = null;
+ if (controller == null){
+ return ;
+ }
+ preference = controller.getPreferenceService().find(key);
+ boolean allowOverride = true;
+ if (preference != null && !preference.isAllowOverride()){
+ allowOverride = false;
+ }
+ if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_OVERRIDE) || !allowOverride){
+
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS, config.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN, config.isAddMediaAsMediaSpecimen());
+
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS, config.isAllowReuseOtherClassifications());
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS, config.isDeduplicateClassifications());
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES, config.isDeduplicateReferences());
+
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS, config.isGetSiblings());
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP, config.isIgnoreAuthorship());
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN, config.isIgnoreImportOfExistingSpecimen());
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER, config.isMapUnitIdToAccessionNumber());
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE, config.isMapUnitIdToBarcode());
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER, config.isMapUnitIdToCatalogNumber());
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION, config.isMoveNewTaxaToDefaultClassification());
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN, config.isOverwriteExistingSpecimens());
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS, config.isReuseExistingDescriptiveGroups());
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA, config.isReuseExistingMetaData());
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE, config.isReuseExistingTaxaWhenPossible());
+ if (config.getNomenclaturalCode() != null){
+ getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE, config.getNomenclaturalCode().getKey());
+ }
+ }
}
+
/**
*
*/
* @return
*/
public static boolean isSortTaxaByRankAndName() {
+
return getPreferenceStore().getBoolean(IPreferenceKeys.SORT_TAXA_BY_RANK_AND_NAME);
}
+/**
+ * @return
+ */
+public static boolean isSortNamedAreaByOrderInVocabulary() {
+
+ return getPreferenceStore().getBoolean(IPreferenceKeys.SORT_NAMED_AREA_BY_VOCABULARY_ORDER);
+}
+
+public static void setSortNamedAreasByOrderInVocabulary(boolean isSortByVocabularyOrder) {
+ getPreferenceStore().setValue(IPreferenceKeys.SORT_NAMED_AREA_BY_VOCABULARY_ORDER, isSortByVocabularyOrder);
+
+}
+
+/**
+ * <p>
+ * setPreferredNamedAreasForDistributionEditor
+ * </p>
+ *
+ * @param saveCheckedElements
+ * @param saveGrayedElements
+ */
+public static void setLastSelectedReference(
+ List<String> lastSelectedReferences) {
+
+ IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
+ preferenceStore.setValue(PreferencesUtil.LAST_SELECTED_REFERENCES, lastSelectedReferences.toString());
+ }
+
+/**
+ * <p>
+ * setPreferredNamedAreasForDistributionEditor
+ * </p>
+ *
+ * @param saveCheckedElements
+ * @param saveGrayedElements
+ */
+public static List<String> getLastSelectedReferences() {
+
+ IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
+ String lastSelected = preferenceStore.getString(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){
+ IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
+ preferenceStore.setValue(PreferencesUtil.DISTRIBUTION_AREA_OCCURENCE_STATUS, saveCheckedElements);
+ preferenceStore.setValue(PreferencesUtil.DISTRIBUTION_AREA_OCCURENCE_STATUS_GRAYED, saveGrayedElements);
+
+ }
+ else{
+// ICdmRepository controller;
+
+// PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaTerms);
+ CdmPreference preference = null;
+
+ if (saveCheckedElements == null){
+ preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaTerms);
+
+ if (preference == null){
+ return ;
+ } else{
+ getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS,
+ saveCheckedElements);
+ preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
+ setPreferenceToDB(preference);
+
+ }
+ } else{
+ preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
+ setPreferenceToDB(preference);
+ getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS,
+ saveCheckedElements);
+
+ }
+ }
+
+}
+
+/**
+ * @param saveCheckedElements
+ * @param saveCheckedElements2
+ * @param b
+ */
+public static void setPreferredVocabulariesForDistributionEditor(String saveCheckedElements,
+ boolean local) {
+ if (local){
+ IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
+ preferenceStore.setValue(PreferencesUtil.DISTRIBUTION_VOCABULARIES, saveCheckedElements);
+
+
+ }
+ else{
+ ICdmRepository controller;
+ CdmPreference preference = null;
+
+ if (saveCheckedElements == null){
+ preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
+
+ if (preference == null){
+ return ;
+ } else{
+ getPreferenceStore().setValue(DISTRIBUTION_VOCABULARIES,
+ saveCheckedElements);
+ preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
+ setPreferenceToDB(preference);
+
+
+ }
+ } else{
+ preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
+ setPreferenceToDB(preference);
+ getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS,
+ saveCheckedElements);
+
+ }
+ }
+
+
+
+}
+
+/**
+ * @param saveCheckedElements
+ * @param saveCheckedElements2
+ * @param b
+ */
+public static String getPreferredVocabulariesForDistributionEditor(boolean local) {
+ if (local){
+ IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
+ String pref = preferenceStore.getString(DISTRIBUTION_VOCABULARIES);
+ return pref;
+
+ }
+ else{
+
+ CdmPreference preference = null;
+
+ preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
+
+ if (preference == null){
+ return null;
+ } else{
+ return preference.getValue();
+ }
+
+ }
+
+
+
+}
+
+/**
+ *
+ */
+public static void updateDBPreferences() {
+ CdmPreference preference = null;
+ IPreferenceStore prefStore = getPreferenceStore();
+
+ //ABCD Configurator
+
+ updateAbcdImportConfigurationPreference();
+
+ //Specimen Details
+ preference = getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
+ if (preference != null){
+ if(!prefStore.getBoolean(SHOW_TAXON_ASSOCIATIONS_OVERRIDE) || !preference.isAllowOverride()){
+ prefStore.setValue(SHOW_TAXON_ASSOCIATIONS, preference.getValue());
+ }
+ }
+ preference = getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
+ if (preference != null){
+ if(!prefStore.getBoolean(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION_OVERRIDE) || !preference.isAllowOverride()){
+ prefStore.setValue(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION, preference.getValue());
+ }
+ }
+ preference = getPreferenceFromDB(PreferencePredicate.ShowLifeForm);
+ if (preference != null){
+ if(!prefStore.getBoolean(SHOW_LIFE_FORM_OVERRIDE) || !preference.isAllowOverride()){
+ prefStore.setValue(SHOW_LIFE_FORM, preference.getValue());
+ }
+ }
+ preference = getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
+ if (preference != null){
+ if(!prefStore.getBoolean(DETERMINATION_ONLY_FOR_FIELD_UNITS_OVERRIDE) || !preference.isAllowOverride()){
+ prefStore.setValue(DETERMINATION_ONLY_FOR_FIELD_UNITS, preference.getValue());
+ }
+ }
+
+
+ //Name Details
+ NameDetailsConfigurator config = getPreferredNameDetailsConfiguration(false);
+ if (config != null ){
+ if (!prefStore.getBoolean(OVERRIDE_NAME_DETAILS) || !prefStore.getBoolean(ALLOW_OVERRIDE_NAME_DETAILS)){
+ setPreferredNameDetailsConfiguration(config, false);
+ }
+ }
+
+ //Distribution Editor
+ preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
+ if (preference != null){
+ if (!prefStore.getBoolean(DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE) || !preference.isAllowOverride()){
+ prefStore.setValue(DISTRIBUTION_VOCABULARIES, preference.getValue());
+ }
+ }
+
+ preference = getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
+ if (preference != null){
+ if (!prefStore.getBoolean(DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE) || !preference.isAllowOverride()){
+ prefStore.setValue(DISTRIBUTION_AREA_PREFRENCES_ACTIVE, preference.getValue());
+ }
+ }
+
+}
+
+
+
+
+
}