Commit 87e731a7 authored by Marco Descher's avatar Marco Descher 🏔

[14501] Update context

parent f081883f
Pipeline #10067 passed with stages
in 3 minutes and 14 seconds
......@@ -4,9 +4,6 @@ import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import ch.elexis.core.model.IContact;
import ch.elexis.core.model.ICoverage;
import ch.elexis.core.model.IMandator;
import ch.elexis.core.model.IPatient;
import ch.elexis.core.model.IUser;
import ch.elexis.core.services.IContext;
import info.elexis.server.core.SystemPropertyConstants;
......@@ -24,75 +21,6 @@ public class Context implements IContext {
return SystemPropertyConstants.getStationId();
}
@Override
public Optional<IUser> getActiveUser(){
return Optional.ofNullable((IUser) context.get(ACTIVE_USER));
}
@Override
public void setActiveUser(IUser user){
if (user == null) {
context.remove(ACTIVE_USER);
} else {
setNamed(ACTIVE_USER, user);
}
}
@Override
public Optional<IContact> getActiveUserContact(){
return Optional.ofNullable((IContact) context.get(ACTIVE_USERCONTACT));
}
@Override
public void setActiveUserContact(IContact userContact){
if (userContact == null) {
context.remove(ACTIVE_USERCONTACT);
} else {
setNamed(ACTIVE_USERCONTACT, userContact);
}
}
@Override
public Optional<ICoverage> getActiveCoverage(){
// TODO Auto-generated method stub
return null;
}
@Override
public void setActiveCoverage(ICoverage coverage){
// TODO Auto-generated method stub
}
@Override
public Optional<IPatient> getActivePatient(){
return Optional.ofNullable((IPatient) context.get(ACTIVE_PATIENT));
}
@Override
public void setActivePatient(IPatient patient){
if (patient == null) {
context.remove(ACTIVE_PATIENT);
} else {
setNamed(ACTIVE_PATIENT, patient);
}
}
@Override
public Optional<IMandator> getActiveMandator(){
return Optional.ofNullable((IMandator) context.get(ACTIVE_MANDATOR));
}
@Override
public void setActiveMandator(IMandator mandator){
if (mandator == null) {
context.remove(ACTIVE_MANDATOR);
} else {
setNamed(ACTIVE_MANDATOR, mandator);
}
}
@SuppressWarnings("unchecked")
@Override
public <T> Optional<T> getTyped(Class<T> clazz){
......@@ -102,7 +30,16 @@ public class Context implements IContext {
@Override
public void setTyped(Object object){
if (object != null) {
if (object instanceof IUser) {
// also set active user contact
IContact userContact = ((IUser) object).getAssignedContact();
setNamed(ACTIVE_USERCONTACT, userContact);
}
Optional<Class<?>> modelInterface = getModelInterface(object);
if (object.equals(context.get(modelInterface.get().getName()))) {
// object is already in the context do nothing otherwise loop happens
return;
}
if (modelInterface.isPresent()) {
context.put(modelInterface.get().getName(), object);
} else {
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
<target name="Elexis-Server" sequenceNumber="1559828158">
<target name="Elexis-Server" sequenceNumber="1560758823">
<locations>
<location includeMode="slicer" includeAllPlatforms="true" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="org.osgi.framework.system.packages.extra" version="1.0.0.20190124-1239"/>
......@@ -77,20 +77,20 @@
<unit id="com.eclipsesource.jaxrs.provider.swagger.feature.feature.group" version="1.1.1.201905211243"/>
<unit id="com.eclipsesource.jaxrs.provider.multipart.feature.feature.group" version="2.2.0.201905211243"/>
<unit id="ch.rgw.utility" version="3.8.0.20190425-1427"/>
<unit id="ch.elexis.core" version="3.8.0.20190605-1537"/>
<unit id="ch.elexis.core" version="3.8.0.20190613-1656"/>
<unit id="ch.elexis.core.l10n" version="3.8.0.20190527-1326"/>
<unit id="ch.elexis.core.importer.div" version="3.2.0.20190522-0735"/>
<unit id="ch.elexis.core.hl7.v2x" version="3.2.0.20190416-1216"/>
<unit id="ch.elexis.core.findings" version="1.0.0.20181005-0856"/>
<unit id="ch.elexis.core.findings.util" version="1.0.0.20190521-1332"/>
<unit id="ch.elexis.core.test" version="1.0.0.20190508-1245"/>
<unit id="ch.elexis.core.jpa" version="1.0.0.20190604-0809"/>
<unit id="ch.elexis.core.jpa" version="1.0.0.20190613-1656"/>
<unit id="ch.elexis.core.jpa.datasource" version="1.0.0.20190511-0953"/>
<unit id="ch.elexis.core.jpa.entities" version="1.0.0.20190604-1303"/>
<unit id="ch.elexis.core.jpa.entities" version="1.0.0.20190606-1504"/>
<unit id="ch.elexis.core.jpa.logging.slf4j" version="1.0.0.20181009-1221"/>
<unit id="ch.elexis.core.model" version="1.0.0.20190606-1014"/>
<unit id="ch.elexis.core.model" version="1.0.0.20190613-1656"/>
<unit id="ch.elexis.core.jcifs" version="2.1.2.20190509-1116"/>
<unit id="ch.elexis.core.services" version="1.0.0.20190604-1304"/>
<unit id="ch.elexis.core.services" version="1.0.0.20190615-1012"/>
<unit id="ch.elexis.core.findings.fhir.model" version="1.0.0.20190515-1510"/>
<unit id="ch.elexis.core.tasks" version="1.0.0.20190605-1146"/>
<unit id="org.postgresql.jdbc42" version="42.2.5"/>
......
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