Commit 005a3b91 authored by Marco Descher's avatar Marco Descher
Browse files

[23092] Medication delete should only mark as deleted, not remove

parent b4cd399a
Pipeline #22327 passed with stages
in 4 minutes and 27 seconds
......@@ -12,8 +12,10 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
import ch.elexis.core.ac.AccessControlDefaults;
import ch.elexis.core.common.ElexisEventTopics;
import ch.elexis.core.model.IPrescription;
import ch.elexis.core.services.holder.AccessControlServiceHolder;
import ch.elexis.core.services.holder.ContextServiceHolder;
import ch.elexis.core.services.holder.CoreModelServiceHolder;
import ch.elexis.core.ui.locks.AcquireLockUi;
......@@ -44,22 +46,28 @@ public class DeleteHandler extends AbstractHandler {
IStructuredSelection strucSelection = (IStructuredSelection) selection;
Iterator<MedicationTableViewerItem> selectionList = strucSelection.iterator();
while (selectionList.hasNext()) {
MedicationTableViewerItem item = selectionList.next();
IPrescription prescription = item.getPrescription();
AcquireLockUi.aquireAndRun(prescription, new ILockHandler() {
boolean hasRight = AccessControlServiceHolder.get().request(AccessControlDefaults.DELETE_MEDICATION);
if(hasRight) {
@Override
public void lockFailed(){
// do nothing
}
MedicationTableViewerItem item = selectionList.next();
IPrescription prescription = item.getPrescription();
AcquireLockUi.aquireAndRun(prescription, new ILockHandler() {
@Override
public void lockFailed(){
// do nothing
}
@Override
public void lockAcquired(){
CoreModelServiceHolder.get().delete(prescription);
ContextServiceHolder.get().postEvent(ElexisEventTopics.EVENT_UPDATE,
prescription);
}
});
@Override
public void lockAcquired(){
CoreModelServiceHolder.get().remove(prescription);
ContextServiceHolder.get().postEvent(ElexisEventTopics.EVENT_UPDATE,
prescription);
}
});
}
}
}
}
......
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