Commit e0987b4c authored by Marco Descher's avatar Marco Descher

[21003] stationId and stationLabel

parent 03cfeaee
Pipeline #16078 passed with stages
in 4 minutes and 56 seconds
......@@ -3,6 +3,8 @@
<service>
<provide interface="ch.elexis.core.services.ILocalLockService"/>
</service>
<reference cardinality="1..1" field="configService" interface="ch.elexis.core.services.IConfigService" name="configService"/>
<reference cardinality="1..1" field="contextService" interface="ch.elexis.core.services.IContextService" name="contextService"/>
<reference cardinality="1..1" field="elexisServerService" interface="ch.elexis.core.services.IElexisServerService" name="elexisServerService"/>
<implementation class="ch.elexis.core.data.service.internal.LocalLockService"/>
</scr:component>
\ No newline at end of file
......@@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
import ch.elexis.core.common.InstanceStatus;
import ch.elexis.core.common.InstanceStatus.STATE;
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;
......@@ -29,6 +30,8 @@ import ch.elexis.core.lock.types.LockRequest.Type;
import ch.elexis.core.lock.types.LockResponse;
import ch.elexis.core.model.IUser;
import ch.elexis.core.model.Identifiable;
import ch.elexis.core.services.IConfigService;
import ch.elexis.core.services.IContextService;
import ch.elexis.core.services.IElexisServerService;
import ch.elexis.core.services.ILocalLockService;
import ch.elexis.data.PersistentObject;
......@@ -47,6 +50,12 @@ public class LocalLockService implements ILocalLockService {
@Reference
private IElexisServerService elexisServerService;
@Reference
private IContextService contextService;
@Reference
private IConfigService configService;
private final HashMap<String, Integer> lockCount = new HashMap<String, Integer>();
private final HashMap<String, LockInfo> locks = new HashMap<String, LockInfo>();
private Logger logger = LoggerFactory.getLogger(LocalLockService.class);
......@@ -97,7 +106,8 @@ public class LocalLockService implements ILocalLockService {
private LockResponse releaseLock(String storeToString){
IUser user = ContextServiceHolder.get().getActiveUser().orElse(null);
LockInfo lil = new LockInfo(storeToString, user.getId(),
elexisServerService.getSystemUuid().toString());
elexisServerService.getSystemUuid().toString(), contextService.getStationIdentifier(),
configService.getLocal(Preferences.STATION_IDENT_TEXT, ""));
LockRequest lockRequest = new LockRequest(LockRequest.Type.RELEASE, lil);
return acquireOrReleaseLocks(lockRequest);
}
......@@ -173,7 +183,8 @@ public class LocalLockService implements ILocalLockService {
IUser user = ContextServiceHolder.get().getActiveUser().orElse(null);
LockInfo lockInfo = new LockInfo(storeToString, user.getId(),
elexisServerService.getSystemUuid().toString());
elexisServerService.getSystemUuid().toString(), contextService.getStationIdentifier(),
configService.getLocal(Preferences.STATION_IDENT_TEXT, ""));
LockRequest lockRequest = new LockRequest(LockRequest.Type.ACQUIRE, lockInfo);
return acquireOrReleaseLocks(lockRequest);
}
......@@ -322,8 +333,10 @@ public class LocalLockService implements ILocalLockService {
logger.debug("Checking lock on [" + object + "]");
IUser user = ContextServiceHolder.get().getActiveUser().orElse(null);
LockInfo lockInfo = new LockInfo(StoreToStringServiceHolder.getStoreToString(object),
user.getId(), elexisServerService.getSystemUuid().toString());
String storeToString = StoreToStringServiceHolder.getStoreToString(object);
LockInfo lockInfo = new LockInfo(storeToString, user.getId(),
elexisServerService.getSystemUuid().toString(), contextService.getStationIdentifier(),
configService.getLocal(Preferences.STATION_IDENT_TEXT, ""));
LockRequest lockRequest = new LockRequest(LockRequest.Type.INFO, lockInfo);
return isLocked(lockRequest);
......
......@@ -27,16 +27,18 @@ public class LockInfo {
@XmlElement
private String systemUuid;
@XmlElement
private String systemLabel;
private String stationId;
@XmlElement
private String stationLabel;
public LockInfo() {
}
public LockInfo(String storeToString, String userId, String systemUuid) {
this(storeToString, userId, systemUuid, "");
this(storeToString, userId, systemUuid, "", "");
}
public LockInfo(String storeToString, String userId, String systemUuid, String systemLabel) {
public LockInfo(String storeToString, String userId, String systemUuid, String stationId, String stationLabel) {
String[] split = storeToString.split(StringConstants.DOUBLECOLON);
if (split.length == 2) {
this.elementId = split[1];
......@@ -44,7 +46,8 @@ public class LockInfo {
this.user = userId;
this.creationDate = new Date();
this.systemUuid = systemUuid;
this.systemLabel = systemLabel;
this.stationId = stationId;
this.stationLabel = stationLabel;
} else {
throw new IllegalArgumentException(storeToString);
}
......@@ -80,8 +83,12 @@ public class LockInfo {
return systemUuid;
}
public String getSystemLabel(){
return systemLabel;
public String getStationId(){
return stationId;
}
public String getStationLabel(){
return stationLabel;
}
public static String getElementId(String storeToString) {
......
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