Commit 670c4c87 authored by Thomas Huster's avatar Thomas Huster

[20852] changed user config access from core hub to config service

parent 729aa0e7
Pipeline #16282 passed with stages
in 4 minutes and 46 seconds
......@@ -153,8 +153,8 @@ public class Rechnung extends PersistentObject {
else {
List<Verrechnet> lstg = b.getLeistungen();
for (Verrechnet l : lstg) {
if (l.getNettoPreis().isZero() && CoreHub.userCfg
.get(Preferences.LEISTUNGSCODES_BILLING_ZERO_CHECK, false)) {
if (l.getNettoPreis().isZero() && ConfigServiceHolder
.getUser(Preferences.LEISTUNGSCODES_BILLING_ZERO_CHECK, false)) {
Patient pat = b.getFall().getPatient();
String msg = "Eine Konsultation vom " + b.getDatum().toString()
+ " für\nPatient Nr. " + pat.getPatCode() + ", " + pat.getName() + ", "
......
......@@ -37,6 +37,7 @@ import ch.elexis.core.model.issue.Priority;
import ch.elexis.core.model.issue.ProcessStatus;
import ch.elexis.core.model.issue.Type;
import ch.elexis.core.model.issue.Visibility;
import ch.elexis.core.services.holder.ConfigServiceHolder;
import ch.rgw.tools.ExHandler;
import ch.rgw.tools.JdbcLink;
import ch.rgw.tools.StringTool;
......@@ -219,9 +220,9 @@ public class Reminder extends PersistentObject implements Comparable<Reminder> {
private String getConfiguredKontaktLabel(Kontakt k, boolean isPatientRelatedReminder){
if (isPatientRelatedReminder) {
StringBuilder sb = new StringBuilder();
String[] configLabel = CoreHub.userCfg
.get(Preferences.USR_REMINDER_PAT_LABEL_CHOOSEN, LabelFields.LASTNAME.toString())
.split(",");
String[] configLabel =
ConfigServiceHolder.getUser(Preferences.USR_REMINDER_PAT_LABEL_CHOOSEN,
LabelFields.LASTNAME.toString()).split(",");
String[] values = k.get(true, configLabel);
for (int i = 0; i < values.length; i++) {
......
......@@ -8,7 +8,6 @@ import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.data.events.ElexisEvent;
import ch.elexis.core.data.events.ElexisEventDispatcher;
import ch.elexis.core.data.events.ElexisEventListenerImpl;
......@@ -72,7 +71,6 @@ public class VerrechenbarFavorites {
sb.append(";");
}
ConfigServiceHolder.setUser(USER_CFG_FAVORITES, sb.toString());
CoreHub.userCfg.flush();
ElexisEventDispatcher.reload(Favorite.class);
}
......
......@@ -4,16 +4,16 @@ import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.findings.templates.ui.composite.CodesSystemsComposite;
import ch.elexis.core.ui.preferences.SettingsPreferenceStore;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore.Scope;
public class CodeSystemSettings extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {
public CodeSystemSettings(){
super(GRID);
setPreferenceStore(new SettingsPreferenceStore(CoreHub.userCfg));
setPreferenceStore(new ConfigServicePreferenceStore(Scope.USER));
}
@Override
......
......@@ -6,12 +6,12 @@ import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.findings.templates.model.FindingsTemplates;
import ch.elexis.core.findings.templates.ui.composite.FindingsComposite;
import ch.elexis.core.findings.templates.ui.composite.FindingsDetailComposite;
import ch.elexis.core.findings.templates.ui.util.FindingsServiceHolder;
import ch.elexis.core.ui.preferences.SettingsPreferenceStore;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore.Scope;
public class FindingsTemplateSettings extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {
......@@ -20,7 +20,7 @@ public class FindingsTemplateSettings extends FieldEditorPreferencePage
public FindingsTemplateSettings(){
super(GRID);
setPreferenceStore(new SettingsPreferenceStore(CoreHub.userCfg));
setPreferenceStore(new ConfigServicePreferenceStore(Scope.USER));
}
@Override
......
......@@ -117,6 +117,17 @@ public class ConfigServiceHolder {
return configService.setActiveUserContact(key, value);
}
public static List<String> getUserAsList(String key){
String string = getUser(key, (String) null);
if (string != null) {
String[] split = string.split(",");
if (split != null && split.length > 0) {
return Arrays.asList(split);
}
}
return Collections.emptyList();
}
public static void setUserAsList(String key, List<String> values){
Optional<String> value =
values.stream().map(o -> o.toString()).reduce((u, t) -> u + "," + t);
......
......@@ -26,11 +26,11 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import ch.elexis.core.constants.Preferences;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.ui.constants.UiResourceConstants;
import ch.elexis.core.ui.contacts.views.Patientenblatt2;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore.Scope;
import ch.elexis.core.ui.preferences.Messages;
import ch.elexis.core.ui.preferences.SettingsPreferenceStore;
import ch.elexis.core.ui.preferences.inputs.ComboFieldEditor;
import ch.elexis.core.ui.preferences.inputs.MultilineFieldEditor;
import ch.elexis.core.ui.util.SWTHelper;
......@@ -42,7 +42,7 @@ public class UserSettings2 extends FieldEditorPreferencePage implements IWorkben
public static final String ALWAYS_CLOSED = Messages.UserSettings2_AlwaysClosed;
public static final String ALWAYS_OPEN = Messages.UserSettings2_AlwaysOpen;
private SettingsPreferenceStore prefs = new SettingsPreferenceStore(CoreHub.userCfg);
private ConfigServicePreferenceStore prefs = new ConfigServicePreferenceStore(Scope.USER);
private static final String[] patlistFocusFields = {
Patient.FLD_PATID, Patient.FLD_NAME, Patient.FLD_FIRSTNAME, Patient.BIRTHDATE,
......@@ -102,8 +102,6 @@ public class UserSettings2 extends FieldEditorPreferencePage implements IWorkben
@Override
public boolean performOk(){
prefs.flush();
CoreHub.userCfg.flush();
SWTHelper.reloadViewPart(UiResourceConstants.PatientenListeView_ID);
return super.performOk();
}
......
......@@ -41,8 +41,9 @@ import ch.elexis.core.constants.Preferences;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.services.holder.ConfigServiceHolder;
import ch.elexis.core.ui.UiDesk;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore.Scope;
import ch.elexis.core.ui.preferences.Messages;
import ch.elexis.core.ui.preferences.SettingsPreferenceStore;
import ch.elexis.core.ui.preferences.inputs.PrefAccessDenied;
import ch.elexis.data.LabMapping;
import ch.elexis.data.Query;
......@@ -55,7 +56,7 @@ public class LabSettings extends FieldEditorPreferencePage implements IWorkbench
public LabSettings(){
super(GRID);
setPreferenceStore(new SettingsPreferenceStore(CoreHub.userCfg));
setPreferenceStore(new ConfigServicePreferenceStore(Scope.USER));
// make sure default value is correct, in case no value is set yet
getPreferenceStore().setDefault(Preferences.LABSETTINGS_CFG_LOCAL_REFVALUES, true);
}
......@@ -152,7 +153,6 @@ public class LabSettings extends FieldEditorPreferencePage implements IWorkbench
ConfigServiceHolder.setGlobal(Preferences.LABSETTINGS_CFG_KEEP_UNSEEN_LAB_RESULTS,
txtKeepUnseen.getText());
}
CoreHub.userCfg.flush();
return super.performOk();
}
......
......@@ -43,6 +43,7 @@ import ch.elexis.core.data.events.ElexisEventDispatcher;
import ch.elexis.core.data.events.Heartbeat;
import ch.elexis.core.data.events.Heartbeat.HeartListener;
import ch.elexis.core.model.LabResultConstants;
import ch.elexis.core.services.holder.ConfigServiceHolder;
import ch.elexis.core.ui.UiDesk;
import ch.elexis.core.ui.actions.RestrictedAction;
import ch.elexis.core.ui.icons.Images;
......@@ -132,8 +133,8 @@ public class LabNotSeenView extends ViewPart implements HeartListener {
ViewMenus menu = new ViewMenus(getViewSite());
menu.createToolbar(markPersonAction, markAllAction);
heartbeat();
CoreHub.heart.addListener(this, CoreHub.userCfg
.get(Preferences.LABSETTINGS_CFG_LABNEW_HEARTRATE, Heartbeat.FREQUENCY_HIGH));
CoreHub.heart.addListener(this, ConfigServiceHolder
.getUser(Preferences.LABSETTINGS_CFG_LABNEW_HEARTRATE, Heartbeat.FREQUENCY_HIGH));
tv.setInput(this);
}
......
......@@ -8,12 +8,12 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
import ch.elexis.core.constants.Preferences;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.preferences.Messages;
import ch.elexis.core.ui.medication.property.MedicationUiTester;
import ch.elexis.core.ui.medication.views.MedicationView;
import ch.elexis.core.ui.medication.views.ViewerSortOrder;
import ch.elexis.core.ui.preferences.SettingsPreferenceStore;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore.Scope;
import ch.elexis.core.ui.preferences.inputs.MultilineFieldEditor;
import ch.elexis.core.ui.util.CreatePrescriptionHelper;
......@@ -24,7 +24,7 @@ public class MedicationSettings extends FieldEditorPreferencePage
public MedicationSettings(){
super(GRID);
setPreferenceStore(new SettingsPreferenceStore(CoreHub.userCfg));
setPreferenceStore(new ConfigServicePreferenceStore(Scope.USER));
getPreferenceStore().setDefault(Preferences.MEDICATION_SETTINGS_EMEDIPLAN_HEADER_COMMENT, Messages.Medication_headerComment);
}
......
......@@ -33,8 +33,8 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.widgets.FormToolkit;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.ui.preferences.SettingsPreferenceStore;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore.Scope;
import ch.rgw.tools.ExHandler;
import ch.rgw.tools.StringTool;
......@@ -127,7 +127,7 @@ public class UiDesk {
public static void updateFont(String cfgName){
FontRegistry fr = JFaceResources.getFontRegistry();
FontData[] fd =
PreferenceConverter.getFontDataArray(new SettingsPreferenceStore(CoreHub.userCfg),
PreferenceConverter.getFontDataArray(new ConfigServicePreferenceStore(Scope.USER),
cfgName);
fr.put(cfgName, fd);
}
......@@ -136,7 +136,7 @@ public class UiDesk {
FontRegistry fr = JFaceResources.getFontRegistry();
if (!fr.hasValueFor(cfgName)) {
FontData[] fd =
PreferenceConverter.getFontDataArray(new SettingsPreferenceStore(CoreHub.userCfg),
PreferenceConverter.getFontDataArray(new ConfigServicePreferenceStore(Scope.USER),
cfgName);
fr.put(cfgName, fd);
}
......
......@@ -196,7 +196,7 @@ public class ReminderDetailDialog extends TitleAreaDialog {
if (!defaultResponsibleSelf) {
ConfigServiceHolder.setUserAsList(Preferences.USR_REMINDER_SELECTED_RESPONSIBLES_DEFAULT,
persist);
CoreHub.userCfg.flush();
}
});
List<Object> inputList = new ArrayList<Object>();
......@@ -450,8 +450,8 @@ public class ReminderDetailDialog extends TitleAreaDialog {
if (defaultResponsibleSelf) {
responsibles = Collections.singletonList(CoreHub.getLoggedInContact());
} else {
List<String> defResponsibles = CoreHub.userCfg
.getAsList(Preferences.USR_REMINDER_SELECTED_RESPONSIBLES_DEFAULT);
List<String> defResponsibles = ConfigServiceHolder
.getUserAsList(Preferences.USR_REMINDER_SELECTED_RESPONSIBLES_DEFAULT);
if (defResponsibles.isEmpty()) {
responsibles = Collections.singletonList(TX_ALL);
} else {
......
......@@ -21,13 +21,14 @@ import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.data.events.ElexisEvent;
import ch.elexis.core.data.events.ElexisEventDispatcher;
import ch.elexis.core.ui.UiDesk;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore.Scope;
import ch.elexis.data.Anwender;
public class FontPreference extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
public FontPreference(){
super(Messages.FontPreference_schriftarten, GRID);
setPreferenceStore(new SettingsPreferenceStore(CoreHub.userCfg));
setPreferenceStore(new ConfigServicePreferenceStore(Scope.USER));
}
@Override
......
......@@ -20,7 +20,7 @@ import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import ch.elexis.core.constants.Preferences;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.services.holder.ConfigServiceHolder;
import ch.elexis.core.ui.UiDesk;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore.Scope;
......@@ -52,8 +52,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
FontData[] small = new FontData[] {
new FontData("Helvetica", 7, SWT.NORMAL)}; //$NON-NLS-1$
CoreHub.userCfg
.set(
ConfigServiceHolder.setUser(
Preferences.USR_SMALLFONT + "_default", PreferenceConverter.getStoredRepresentation(small)); //$NON-NLS-1$
}
......
......@@ -29,7 +29,6 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import ch.elexis.core.constants.Preferences;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.model.issue.ProcessStatus;
import ch.elexis.core.services.holder.ConfigServiceHolder;
import ch.elexis.core.ui.icons.Images;
......@@ -67,8 +66,8 @@ public class ReminderPrefences extends PreferencePage implements IWorkbenchPrefe
} else {
String defValue = Reminder.LabelFields.PAT_ID.toString() + ","
+ Reminder.LabelFields.FIRSTNAME.toString();
availableFields = CoreHub.userCfg
.get(Preferences.USR_REMINDER_PAT_LABEL_AVAILABLE, defValue).split(",");
availableFields = ConfigServiceHolder
.getUser(Preferences.USR_REMINDER_PAT_LABEL_AVAILABLE, defValue).split(",");
}
}
......@@ -221,7 +220,6 @@ public class ReminderPrefences extends PreferencePage implements IWorkbenchPrefe
ConfigServiceHolder.setUser(Preferences.USR_REMINDER_PAT_LABEL_AVAILABLE,
getListAsString(lViewerAvailable.getList().getItems()));
CoreHub.userCfg.flush();
return super.performOk();
}
......
......@@ -39,7 +39,6 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import ch.elexis.core.constants.Preferences;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.data.status.ElexisStatus;
import ch.elexis.core.data.util.Extensions;
import ch.elexis.core.services.holder.ConfigServiceHolder;
......@@ -206,8 +205,8 @@ public class ServiceDiagnosePrefs extends PreferencePage implements IWorkbenchPr
aInput.add(FAVORITES);
settings =
CoreHub.userCfg
.get(Preferences.USR_SERVICES_DIAGNOSES_SRV, getListAsString(aInput))
ConfigServiceHolder
.getUser(Preferences.USR_SERVICES_DIAGNOSES_SRV, getListAsString(aInput))
.split(",");
break;
case Diagnose:
......
......@@ -22,10 +22,10 @@ import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.data.util.Extensions;
import ch.elexis.core.services.holder.ConfigServiceHolder;
import ch.elexis.core.ui.constants.ExtensionPointConstantsUi;
import ch.elexis.core.ui.preferences.ConfigServicePreferenceStore.Scope;
import ch.elexis.core.ui.text.EnhancedTextField;
/**
......@@ -47,7 +47,7 @@ public class UserTextPref extends FieldEditorPreferencePage implements IWorkbenc
public UserTextPref(){
super(GRID);
setPreferenceStore(new SettingsPreferenceStore(CoreHub.userCfg));
setPreferenceStore(new ConfigServicePreferenceStore(Scope.USER));
setDescription(Messages.UserTextPref_UserPreferences);
}
......
......@@ -54,7 +54,6 @@ import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
import ch.elexis.core.constants.Preferences;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.data.events.ElexisEvent;
import ch.elexis.core.data.events.ElexisEventDispatcher;
import ch.elexis.core.data.events.ElexisEventListener;
......@@ -235,7 +234,6 @@ public class EnhancedTextField extends Composite implements IRichTextDisplay {
StringBuilder name = new StringBuilder(in.getValue());
name.reverse();
ConfigServiceHolder.setUser("makros/" + name, tx); //$NON-NLS-1$
CoreHub.userCfg.flush();
}
}
......
......@@ -223,9 +223,11 @@ public class DefaultControlFieldProvider implements ControlFieldProvider {
* DB-Namen des Feldes
*/
public void setFocusField(String name){
for (int i = 0; i < dbFields.length; i++) {
if (dbFields[i].equals(name))
for (int i = 0; i < fields.length; i++) {
if (fields[i].equals(name)) {
focusField = i;
break;
}
}
}
......
......@@ -30,10 +30,10 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.model.IArticle;
import ch.elexis.core.model.IArticleDefaultSignature;
import ch.elexis.core.model.prescription.EntryType;
import ch.elexis.core.services.holder.ConfigServiceHolder;
import ch.elexis.core.services.holder.CoreModelServiceHolder;
import ch.elexis.core.services.holder.MedicationServiceHolder;
import ch.elexis.core.ui.dialogs.ArticleDefaultSignatureTitleAreaDialog;
......@@ -509,8 +509,9 @@ public class ArticleDefaultSignatureComposite extends Composite {
} else if (modelDisposalType == EntryType.SELF_DISPENSED) {
btnDispensation.setSelection(true);
} else {
if(CoreHub.userCfg
.get(CreatePrescriptionHelper.MEDICATION_SETTINGS_SIGNATURE_STD_DISPENSATION, false)) {
if (ConfigServiceHolder.getUser(
CreatePrescriptionHelper.MEDICATION_SETTINGS_SIGNATURE_STD_DISPENSATION,
false)) {
btnDispensation.setSelection(true);
} else {
btnNoDisposal.setSelection(true);
......
......@@ -18,7 +18,6 @@ import org.junit.BeforeClass;
import org.junit.Test;
import ch.elexis.core.constants.Preferences;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.data.service.ContextServiceHolder;
import ch.elexis.core.importer.div.importers.HL7Parser;
import ch.elexis.core.model.LabResultConstants;
......@@ -64,7 +63,6 @@ public class TestPathologicDescription {
removeAllLaboWerte();
// set the use local config to true
ConfigServiceHolder.setUser(Preferences.LABSETTINGS_CFG_LOCAL_REFVALUES, true);
CoreHub.userCfg.flush();
parseOneHL7file(new File(workDir.toString(), "Analytica/01TEST5005.hl7"), false, true);
Query<LabResult> qr = new Query<LabResult>(LabResult.class);
......@@ -123,7 +121,6 @@ public class TestPathologicDescription {
removeAllLaboWerte();
// set the use local config to true
ConfigServiceHolder.setUser(Preferences.LABSETTINGS_CFG_LOCAL_REFVALUES, true);
CoreHub.userCfg.flush();
parseOneHL7file(new File(workDir.toString(), "Analytica/0216370074_6417526401671.hl7"),
false, true);
......@@ -163,7 +160,6 @@ public class TestPathologicDescription {
removeAllLaboWerte();
// set the use local config to false
ConfigServiceHolder.setUser(Preferences.LABSETTINGS_CFG_LOCAL_REFVALUES, false);
CoreHub.userCfg.flush();
// test if parser will read correct value
assertFalse(ConfigServiceHolder.get().get(
ContextServiceHolder.get().getActiveUserContact().get(),
......@@ -335,7 +331,6 @@ public class TestPathologicDescription {
removeAllLaboWerte();
// set the use local config to false
ConfigServiceHolder.setUser(Preferences.LABSETTINGS_CFG_LOCAL_REFVALUES, false);
CoreHub.userCfg.flush();
parseOneHL7file(new File(workDir.toString(),
"LabCube/5083_LabCube_DriChem7000_20180314131140_288107.hl7"), false, true);
......
......@@ -22,7 +22,6 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import ch.elexis.core.constants.Preferences;
import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.importer.div.importers.HL7Parser;
import ch.elexis.core.services.holder.ConfigServiceHolder;
import ch.elexis.core.types.LabItemTyp;
......@@ -82,7 +81,6 @@ public class Test_HL7Import_MPFRule {
// set the use local config to false
ConfigServiceHolder.setUser(Preferences.LABSETTINGS_CFG_LOCAL_REFVALUES, true);
CoreHub.userCfg.flush();
LabItem liKrus = new LabItem("KRUS", "Kreatinin im Urin", AllTests.testLab, "> 60", "> 60",
"mmol/l", LabItemTyp.NUMERIC, "Urin", "42");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment