import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
import java.util.Arrays;
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.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
+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.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.PreferencePredicate;
+import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
import eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy;
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.store.CdmStore;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
import eu.etaxonomy.taxeditor.ui.dialog.DefaultLanguageDialog;
*/
public static final String PREFERRED_TERMS_CHANGE = "preferred_terms";
+ public static final String P2_REPOSITORIES_DELIM = ",";
+ public static final String P2_REPOSITORY_FIELDS_DELIM = ";";
+
+ private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
+
/**
* <p>
* getPreferenceStore
* a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
* object.
*/
- public static void setPreferredNomenclaturalCode(
- NomenclaturalCode preferredCode) {
- getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
- getPreferenceKey(preferredCode));
+ public static CdmPreference setPreferredNomenclaturalCode(
+ NomenclaturalCode preferredCode, boolean local) {
+ if (local){
+ getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
+ getPreferenceKey(preferredCode));
+ }
+ else{
+ ICdmRepository controller;
+ controller = CdmStore.getCurrentApplicationConfiguration();
+ PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
+ CdmPreference preference = null;
+ if (controller == null){
+ return null;
+ }
+ if (preferredCode == 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);
+
+ 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());
+ controller.getPreferenceService().set(preference);
+
+ }
+ }
+ return null;
+
+
+
+ }
+
+ public static NomenclaturalCode getPreferredNomenclaturalCode(){
+ if (getPreferenceStore().getBoolean(OVERRIDE_NOMENCLATURAL_CODE_KEY)) {
+ return getPreferredNomenclaturalCode(true);
+ } else{
+ return getPreferredNomenclaturalCode(false);
+ }
}
/**
*
* @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
*/
- public static NomenclaturalCode getPreferredNomenclaturalCode() {
+ public static NomenclaturalCode getPreferredNomenclaturalCode(boolean useLocal) {
- for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
- String preferredCode = getPreferenceStore().getString(
+ CdmPreference pref = null;
+ if (!useLocal){
+ pref = getPreferenceFromDB(PreferencePredicate.NomenclaturalCode);
+ }
+
+ String preferredCode;
+ if(pref == null){
+ preferredCode = getPreferenceStore().getString(
PREFERRED_NOMENCLATURAL_CODE_KEY);
+
+ }else{
+ preferredCode = pref.getValue();
+ }
+
+ for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
if (getPreferenceKey(code).equals(preferredCode)) {
return code;
}
return null;
}
+
+ private static CdmPreference getPreferenceFromDB(PreferencePredicate predicate){
+ ICdmRepository controller;
+ CdmPreference pref = null;
+
+ try{
+ controller = CdmStore.getCurrentApplicationConfiguration();
+ PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), predicate);
+ pref = controller.getPreferenceService().find(key);
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+
+ return pref;
+
+ }
+
+
public static String getPreferredDefaultLangugae(){
String preferredLanguage = getPreferenceStore().getString(DEFAULT_LANGUAGE_EDITOR);
if(StringUtils.isNotEmpty(preferredLanguage) && StringUtils.isNotBlank(preferredLanguage)){
* @return
*/
private static String getPreferenceKey(ICdmBase cdmBase) {
- cdmBase = (ICdmBase) HibernateProxyHelper.deproxy(cdmBase);
+ cdmBase = HibernateProxyHelper.deproxy(cdmBase);
String key = cdmBase.getClass().getName().concat(".")
.concat(cdmBase.getUuid().toString());
* @return
*/
public static String getPreferenceKey(ISimpleTerm simpleTerm) {
- simpleTerm = (ISimpleTerm) HibernateProxyHelper.deproxy(simpleTerm);
+ simpleTerm = HibernateProxyHelper.deproxy(simpleTerm);
String key = simpleTerm.getClass().getName().concat(".")
.concat(simpleTerm.getUuid().toString());
if (key.contains("javassist")) {
* @return
*/
public static String getPreferenceKey(IDefinedTerm definedTerm) {
- definedTerm = (IDefinedTerm) HibernateProxyHelper.deproxy(definedTerm);
+ definedTerm = HibernateProxyHelper.deproxy(definedTerm);
String key = definedTerm.getClass().getName().concat(".")
.concat(definedTerm.getUuid().toString());
if (key.contains("javassist")) {
TAXON_SERVICE_CONFIGURATOR_NAMES));
configurator.setDoTaxaByCommonNames(getPreferenceStore().getBoolean(
TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES));
+ //configurator.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.valueOf(getPreferenceStore().getString(TAXON_SERVICE_CONFIGURATOR_MATCH_MODE)));
return configurator;
}
"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_CACHE, true);
+ getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, true);
+ getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_HYBRID, true);
+ getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_LSID, true);
+ getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, true);
+ getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAMECACHE, true);
+ getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, true);
+ getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, true);
+ getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, true);
+ getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, true);
+ getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_RANK, true);
+ getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, true);
+ getPreferenceStore().setDefault(SORT_NODES_NATURALLY, false);
+ getPreferenceStore().setDefault(SORT_NODES_ALPHABETICALLY, false);
+
}
/**
// First time Editor is opened, no nomenclatural code has been set
- if (PreferencesUtil.getPreferredNomenclaturalCode() == null) {
- PreferencesUtil.setPreferredNomenclaturalCode(NomenclaturalCode.ICNAFP);
- /*
+ 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();
+ }
+ public static void setNomenclaturalCodePreferences(){
+ ICdmRepository 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());
- // 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.");*/
- }
+ 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(){
if(PreferencesUtil.getPreferredDefaultLangugae() == null){
- Shell shell = StoreUtil.getShell();
+ Shell shell = AbstractUtility.getShell();
int open = new DefaultLanguageDialog(shell).open();
- if(open == 0){//FIXME:window performed ok. Find variable for it
+ if(open == Window.OK){
PlatformUI.getWorkbench().restart();
}
}else{
}
public static Language getGlobalLanguage() {
+
+
String languageUuidString = getPreferenceStore().getString(
GLOBAL_LANGUAGE_UUID);
+ if(!CdmStore.isActive()) {
+ MessagingUtils.noDataSourceWarningDialog(languageUuidString);
+ return null;
+ }
+
if (CdmUtils.isBlank(languageUuidString)) {
return Language.getDefaultLanguage();
}
}
public static void setGlobalLanguage(Language language) {
- getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID,
- language.getUuid().toString());
- CdmStore.setDefaultLanguage(language);
+ if(language != null) {
+ getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID,language.getUuid().toString());
+ CdmStore.setDefaultLanguage(language);
+ }
+
}
/**
private static String getMarkerTypeEditingPreferenceKey(
MarkerType markerType) {
- markerType = (MarkerType) HibernateProxyHelper.deproxy(markerType);
+ markerType = HibernateProxyHelper.deproxy(markerType);
return markerType.getClass().getName() + EDIT_MARKER_TYPE_PREFIX;
}
*/
public void writePropertyToConfigFile(int setLanguage) throws IOException {
File file = org.eclipse.core.runtime.preferences.ConfigurationScope.INSTANCE.getLocation().toFile();
+ //give warning to user if the directory has no write access
+ if(file == null){
+ throw new IOException();
+ }
Properties properties = load(file.getAbsolutePath()+"/config.ini");
switch(setLanguage){
case 0:
fos.close();
}
+ /**
+ * Saves a list of P2 Metadata Repositories as string with specified delimiters
+ *
+ * @param p2Repos
+ */
+ public static void setP2Repositories(List<MetadataRepositoryElement> p2Repos) {
+ StringBuilder sb = new StringBuilder();
+ for(MetadataRepositoryElement p2Repo : p2Repos) {
+ sb.append(P2_REPOSITORIES_DELIM);
+ if(p2Repo.getName() == null || p2Repo.getName().isEmpty()) {
+ sb.append("-");
+ } else {
+ sb.append(p2Repo.getName());
+ }
+ sb.append(P2_REPOSITORY_FIELDS_DELIM);
+ sb.append(p2Repo.getLocation().toString());
+ sb.append(P2_REPOSITORY_FIELDS_DELIM);
+ sb.append(String.valueOf(p2Repo.isEnabled()));
+ }
+ getPreferenceStore().setValue(P2_REPOSITORY_LIST, sb.toString());
+ }
+
+
+ /**
+ * Retrieves a list of previously saved P2 repositories
+ *
+ * @return
+ */
+ public static List<MetadataRepositoryElement> getP2Repositories() {
+ List<MetadataRepositoryElement> p2Repos = new ArrayList<MetadataRepositoryElement>();
+ String p2ReposPref = getPreferenceStore().getString(P2_REPOSITORY_LIST);
+ if(p2ReposPref != null && !p2ReposPref.isEmpty()) {
+ StringTokenizer p2ReposPrefST = new StringTokenizer(p2ReposPref,P2_REPOSITORIES_DELIM);
+
+ while(p2ReposPrefST.hasMoreTokens()) {
+ String p2RepoStr = p2ReposPrefST.nextToken();
+ StringTokenizer p2ReposStrST = new StringTokenizer(p2RepoStr,P2_REPOSITORY_FIELDS_DELIM);
+ if(p2ReposStrST.countTokens()==3) {
+ String nickname = p2ReposStrST.nextToken();
+ URI uri = null;
+ try {
+ uri = new URI(p2ReposStrST.nextToken());
+ } catch (URISyntaxException e) {
+ continue;
+ }
+ boolean enabled = Boolean.parseBoolean(p2ReposStrST.nextToken());
+ MetadataRepositoryElement mre = new MetadataRepositoryElement(null, uri, true);
+ mre.setNickname(nickname);
+ mre.setEnabled(enabled);
+ p2Repos.add(mre);
+ }
+ }
+ }
+
+ return p2Repos;
+ }
+
+ /**
+ * enables/disables nested composite. <br>
+ *
+ * @param ctrl - Composite to be en-/disabeld
+ * @param enabled - boolean
+ */
+ public static void recursiveSetEnabled(Control ctrl, boolean enabled) {
+ if (ctrl instanceof Composite) {
+ Composite comp = (Composite) ctrl;
+ for (Control c : comp.getChildren()) {
+ recursiveSetEnabled(c, enabled);
+ }
+ } else {
+ ctrl.setEnabled(enabled);
+ }
+ }
+
+ /**
+ * <p>
+ * getSortRanksNaturally
+ * </p>
+ *
+ * @return a boolean.
+ */
+ public static boolean getSortNodesNaturally() {
+ return getPreferenceStore().getBoolean(SORT_NODES_NATURALLY);
+ }
+
+ /**
+ * <p>
+ * setSortRanksNaturally
+ * </p>
+ *
+ * @param selection
+ * a boolean.
+ */
+ public static void setSortNodesNaturally(boolean selection) {
+ getPreferenceStore().setValue(SORT_NODES_NATURALLY, selection);
+ }
+
+
+ /**
+ * <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);
+ }
+
+ /**
+ * <p>
+ * setStoreNavigatorState
+ * </p>
+ *
+ * @param selection
+ * a boolean.
+ */
+ public static boolean isStoreNavigatorState() {
+ return getPreferenceStore().getBoolean(RESTORE_NAVIGATOR_STATE);
+
+ }
+
+ /**
+ * <p>
+ * setStoreNavigatorState
+ * </p>
+ *
+ * @param selection
+ * a boolean.
+ */
+ public static void setStoreNavigatorState(boolean selection) {
+ getPreferenceStore().setValue(RESTORE_NAVIGATOR_STATE, selection);
+
+ }
+
+ /**
+ * @return
+ */
+ public static boolean isShowUpWidgetIsDisposedMessages() {
+ return getPreferenceStore().getBoolean(IS_SHOW_UP_WIDGET_IS_DISPOSED);
+ }
+ public static void setShowUpWidgetIsDisposedMessages(boolean selection) {
+ getPreferenceStore().setValue(IS_SHOW_UP_WIDGET_IS_DISPOSED, selection);
+ }
+
+ /**
+ * @return
+ */
+ public static boolean isShowIdInVocabularyInChecklistEditor() {
+ return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_ID_IN_VOCABULARY);
+ }
+ public static void setShowIdInVocabularyInChecklistEditor(boolean selection) {
+ getPreferenceStore().setValue(CHECKLIST_ID_IN_VOCABULARY, selection);
+ }
+
+ /**
+ * @return
+ */
+ public static boolean isShowRankInChecklistEditor() {
+ return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_SHOW_RANK);
+ }
+ public static void setShowRankInChecklistEditor(boolean selection) {
+ getPreferenceStore().setValue(CHECKLIST_SHOW_RANK, selection);
+ }
+
+ /**
+ * @param object
+ * @param b
+ * @return
+ */
+ public static NameDetailsConfigurator setPreferredNameDetailsConfiguration( boolean local) {
+ NameDetailsConfigurator config = new NameDetailsConfigurator(true);
+
+ CdmPreference preference = null;
+
+ if (!local) {
+ preference = getPreferenceFromDB(PreferencePredicate.NameDetailsView);
+ }
+ if (preference == null){
+ return null;
+ }
+
+ getPreferenceStore().setValue(ALLOW_OVERRIDE_NAMEDETAILS, preference.isAllowOverride());
+
+ //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]));
+ }
+
+
+
+ getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
+ (sectionMap.get("taxon")));
+ config.setTaxonSectionActivated(sectionMap.get("taxon"));
+
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
+ (sectionMap.get("lsid")));
+ config.setLSIDActivated(sectionMap.get("lsid"));
+
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
+ (sectionMap.get("nc")));
+ config.setNomenclaturalCodeActived(sectionMap.get("nc"));
+
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
+ (sectionMap.get("ap")));
+ config.setAppendedPhraseActivated(sectionMap.get("ap"));
+
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
+ (sectionMap.get("rank")));
+ config.setRankActivated(sectionMap.get("rank"));
+
+
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
+ (sectionMap.get("atomisedEpithets")));
+ config.setAtomisedEpithetsActivated(sectionMap.get("atomisedEpithets"));
+
+ 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"));
+
+
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
+ (sectionMap.get("protologue")));
+ config.setProtologueActivated(sectionMap.get("protologue"));
+
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
+ (sectionMap.get("typeDes")));
+ config.setTypeDesignationSectionActivated(sectionMap.get("typeDes"));
+
+ getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
+ (sectionMap.get("nameRelation")));
+ config.setNameRelationsSectionActivated(sectionMap.get("nameRelation"));
+
+ return config;
+ }
+
+ public static boolean getIsDeterminiationOnlyForFieldUnit(boolean local){
+ CdmPreference preference = null;
+
+ if (!local) {
+ preference = getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
+ }
+ if (preference == null){
+ return getPreferenceStore().getBoolean(DETERMINATION_ONLY_FOR_FIELD_UNITS);
+ }
+ return Boolean.valueOf(preference.getValue());
+ }
+
+ public static boolean getIsShowCollectingAreasInGeneralSection(boolean local){
+ CdmPreference preference = null;
+
+ if (!local) {
+ preference = getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
+ }
+ if (preference == null){
+ return getPreferenceStore().getBoolean(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION);
+ }
+ return Boolean.valueOf(preference.getValue());
+ }
+
+ public static boolean getIsShowTaxonAssociations(boolean local){
+ CdmPreference preference = null;
+
+ if (!local) {
+ preference = getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
+ }
+ if (preference == null){
+ return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS);
+ }
+ return Boolean.valueOf(preference.getValue());
+ }
+
+// public static boolean getBioCaseProvider(boolean local){
+// CdmPreference preference = null;
+//
+// if (!local) {
+// preference = getPreferenceFromDB(PreferencePredicate.BioCaseProvider);
+// }
+// if (preference == null){
+// return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS);
+// }
+// return Boolean.valueOf(preference.getValue());
+// }
+
+
+ /**
+ * <p>
+ * setAbcdConfigurator
+ * </p>
+ *
+ * @param preferredConfiguration
+ * a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
+ * object.
+ */
+ public static Abcd206ImportConfigurator getAbcdImportConfigurationPreference(boolean useLocal) {
+
+ Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
+
+ if (useLocal){
+ config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS));
+
+ config.setAddMediaAsMediaSpecimen(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN));
+
+ config.setAllowReuseOtherClassifications(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS));
+ config.setDeduplicateClassifications(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS));
+ config.setDeduplicateReferences(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES));
+
+ config.setGetSiblings(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS));
+ config.setIgnoreAuthorship(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP));
+ config.setIgnoreImportOfExistingSpecimen(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN));
+ config.setMapUnitIdToAccessionNumber(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER));
+ config.setMapUnitIdToBarcode(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE));
+ config.setMapUnitIdToCatalogNumber(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER));
+ config.setMoveNewTaxaToDefaultClassification(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION));
+ config.setOverwriteExistingSpecimens(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN));
+ config.setReuseExistingDescriptiveGroups(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS));
+ config.setReuseExistingMetaData(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA));
+ config.setReuseExistingTaxaWhenPossible(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE));
+ return config;
+
+ }
+ ICdmRepository controller;
+ controller = CdmStore.getCurrentApplicationConfiguration();
+ PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), 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 = 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{
+ logger.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString);
+ }
+
+ }
+ }
+ return config;
+
+
+
+ }
+
+
+
+
+
}