Make ListShareGET work

Fix absolute functionality-breaking bugs. There is still a fair amount of funkiness and lack of polish (such as having other and entried in the Lambda return).

In addition, the NULL uiPositions that got put in the database may need cleaning up manually.
This commit is contained in:
NMerz 2020-11-29 15:45:08 -05:00
parent 70195632f8
commit 8ecee59da9
2 changed files with 48 additions and 1 deletions

View File

@ -5,14 +5,53 @@ import java.util.ArrayList;
public class ListShare { public class ListShare {
Integer listID; Integer listID;
String shareWithEmail; String shareWithEmail;
Integer permissionLevel;
Integer uiPosition;
ArrayList<ListShare> other; ArrayList<ListShare> other;
public ListShare(ResultSet listRow) throws SQLException { public ListShare(ResultSet listRow) throws SQLException {
this.listID = listRow.getInt("listID"); this.listID = listRow.getInt("listID");
this.shareWithEmail = listRow.getString("userID"); this.shareWithEmail = listRow.getString("userID");
this.permissionLevel = listRow.getInt("permissionLevel");
this.uiPosition = listRow.getInt("uiPosition");
other = new ArrayList<>(); other = new ArrayList<>();
} }
@Override
public String toString() {
return "ListShare{" +
"listID=" + listID +
", shareWithEmail='" + shareWithEmail + '\'' +
", permissionLevel=" + permissionLevel +
", uiPosition=" + uiPosition +
", other=" + other +
'}';
}
public Integer getPermissionLevel() {
return permissionLevel;
}
public void setPermissionLevel(Integer permissionLevel) {
this.permissionLevel = permissionLevel;
}
public Integer getUiPosition() {
return uiPosition;
}
public void setUiPosition(Integer uiPosition) {
this.uiPosition = uiPosition;
}
public ArrayList<ListShare> getOther() {
return other;
}
public void setOther(ArrayList<ListShare> other) {
this.other = other;
}
public Integer getListID() { public Integer getListID() {
return listID; return listID;
} }

View File

@ -11,6 +11,7 @@ public class ListShare {
String shareWithEmail; String shareWithEmail;
final ListShare[] other; final ListShare[] other;
Integer permissionLevel; Integer permissionLevel;
Integer uiPosition;
private static final Map<Integer, String> keysToPerms; private static final Map<Integer, String> keysToPerms;
static { static {
@ -24,11 +25,17 @@ public class ListShare {
keysToPerms = Collections.unmodifiableMap(keysToPermsTemp); keysToPerms = Collections.unmodifiableMap(keysToPermsTemp);
} }
public ListShare(Integer listID, String shareWithEmail, Integer permissionLevel, ListShare[] other) { public ListShare(Integer listID, String shareWithEmail, Integer permissionLevel, Integer uiPosition, ListShare[] other) {
this.listID = listID; this.listID = listID;
this.shareWithEmail = shareWithEmail; this.shareWithEmail = shareWithEmail;
this.permissionLevel = permissionLevel; this.permissionLevel = permissionLevel;
this.other = other; this.other = other;
this.uiPosition = uiPosition;
}
public ListShare(Integer listID, String shareWithEmail, String permissionsRaw, Integer uiPosition, ListShare[] other) {
this(listID, shareWithEmail, permissionsRaw, other);
this.uiPosition = uiPosition;
} }
public ListShare(Integer listID, String shareWithEmail, String permissionsRaw, ListShare[] other) { public ListShare(Integer listID, String shareWithEmail, String permissionsRaw, ListShare[] other) {
@ -42,6 +49,7 @@ public class ListShare {
permissionLevel *= keytoPermEntry.getKey(); permissionLevel *= keytoPermEntry.getKey();
} }
} }
this.uiPosition = -1;
} }
@Override @Override