Skip to content
Snippets Groups Projects
Commit 4ed597fb authored by srosse's avatar srosse
Browse files

OO-44: make group management robust to concurrent view/edit/delete

parent 88a1e737
No related branches found
No related tags found
No related merge requests found
......@@ -91,5 +91,8 @@ public class BusinessGroupTableModel extends DefaultTableDataModel {
public BusinessGroup getBusinessGroupAt(int row) {
return (BusinessGroup) objects.get(row);
}
public void removeBusinessGroup(BusinessGroup businessGroup) {
objects.remove(businessGroup);
}
}
\ No newline at end of file
......@@ -318,7 +318,15 @@ public class BGMainController extends MainLayoutBasicController implements Activ
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
int rowid = te.getRowId();
currBusinessGroup = groupListModel.getBusinessGroupAt(rowid);
BusinessGroup selectedBusinessGroup = groupListModel.getBusinessGroupAt(rowid);
//reload the group
currBusinessGroup = BusinessGroupManagerImpl.getInstance().loadBusinessGroup(selectedBusinessGroup.getKey(), false);
if(currBusinessGroup == null) {
groupListModel.removeBusinessGroup(selectedBusinessGroup);
groupListCtr.modelChanged();
return;
}
String trnslP = currBusinessGroup.getName();
if (actionid.equals(TABLE_ACTION_LAUNCH)) {
......
......@@ -119,4 +119,14 @@ public class BusinessGroupTableModelWithType extends DefaultTableDataModel imple
BGTableItem wrapped = (BGTableItem)objects.get(row);
return wrapped.getBusinessGroup();
}
public void removeBusinessGroup(BusinessGroup bg) {
for(int i=objects.size(); i-->0; ) {
BGTableItem wrapped = (BGTableItem)objects.get(i);
if(bg.equals(wrapped.getBusinessGroup())) {
objects.remove(i);
return;
}
}
}
}
\ No newline at end of file
......@@ -572,8 +572,12 @@ public class BGManagementController extends MainLayoutBasicController implements
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
int rowid = te.getRowId();
this.currentGroup = groupListModel.getBusinessGroupAt(rowid);
if (actionid.equals(CMD_GROUP_EDIT)) {
BusinessGroup selectedGroup = groupListModel.getBusinessGroupAt(rowid);
currentGroup = BusinessGroupManagerImpl.getInstance().loadBusinessGroup(selectedGroup.getKey(), false);
if(currentGroup == null) {
groupListModel.removeBusinessGroup(selectedGroup);
groupListCtr.modelChanged();
} else if (actionid.equals(CMD_GROUP_EDIT)) {
doGroupEdit(ureq);
} else if (actionid.equals(CMD_GROUP_RUN)) {
doGroupRun(ureq);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment