mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 10:48:46 +00:00
Make shared info avlaible for lists
This commit is contained in:
parent
2cce80ffbd
commit
9c9da446ef
@ -8,13 +8,15 @@ public class List {
|
|||||||
String owner;
|
String owner;
|
||||||
long lastUpdated;
|
long lastUpdated;
|
||||||
ArrayList<ItemEntry> entries;
|
ArrayList<ItemEntry> entries;
|
||||||
|
boolean shared;
|
||||||
|
|
||||||
public List(ResultSet listRow) throws SQLException {
|
public List(ResultSet listRow, boolean shared) throws SQLException {
|
||||||
itemID = listRow.getInt("listID");
|
itemID = listRow.getInt("listID");
|
||||||
name = listRow.getString("name");
|
name = listRow.getString("name");
|
||||||
owner = listRow.getString("owner");
|
owner = listRow.getString("owner");
|
||||||
lastUpdated = listRow.getTimestamp("lastUpdated").toInstant().toEpochMilli();
|
lastUpdated = listRow.getTimestamp("lastUpdated").toInstant().toEpochMilli();
|
||||||
entries = new ArrayList<>();
|
entries = new ArrayList<>();
|
||||||
|
this.shared = shared;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItemEntry(ItemEntry entry) {
|
public void addItemEntry(ItemEntry entry) {
|
||||||
@ -67,4 +69,12 @@ public class List {
|
|||||||
public void setLastUpdated(long lastUpdated) {
|
public void setLastUpdated(long lastUpdated) {
|
||||||
this.lastUpdated = lastUpdated;
|
this.lastUpdated = lastUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getShared() {
|
||||||
|
return shared;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShared(boolean shared) {
|
||||||
|
this.shared = shared;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ public class ListGetter implements CallHandler{
|
|||||||
|
|
||||||
private final String GET_LIST = "SELECT * FROM List WHERE listID = ?;";
|
private final String GET_LIST = "SELECT * FROM List WHERE listID = ?;";
|
||||||
private final String GET_LISTS = "SELECT listID FROM ListSharee WHERE userID = ?;";
|
private final String GET_LISTS = "SELECT listID FROM ListSharee WHERE userID = ?;";
|
||||||
|
private final String SHARE_CHECK = "SELECT * FROM ListSharee WHERE listID = ?;";
|
||||||
private final String GET_ENTRIES = "SELECT * FROM ListProduct WHERE listID = ?;";
|
private final String GET_ENTRIES = "SELECT * FROM ListProduct WHERE listID = ?;";
|
||||||
|
|
||||||
public ListGetter(Connection connection, String cognitoID) {
|
public ListGetter(Connection connection, String cognitoID) {
|
||||||
@ -34,13 +35,25 @@ public class ListGetter implements CallHandler{
|
|||||||
}
|
}
|
||||||
return listIds;
|
return listIds;
|
||||||
}
|
}
|
||||||
|
PreparedStatement checkAccess = connection.prepareStatement(SHARE_CHECK);
|
||||||
|
checkAccess.setInt(1, id);
|
||||||
|
System.out.println(checkAccess);
|
||||||
|
ResultSet accessResults = checkAccess.executeQuery();
|
||||||
|
int sharees = 0;
|
||||||
|
while (sharees < 2 && accessResults.next()) {
|
||||||
|
sharees++;
|
||||||
|
}
|
||||||
|
boolean shared = false;
|
||||||
|
if (sharees > 1) {
|
||||||
|
shared = true;
|
||||||
|
}
|
||||||
PreparedStatement getList = connection.prepareStatement(GET_LIST);
|
PreparedStatement getList = connection.prepareStatement(GET_LIST);
|
||||||
getList.setInt(1, id);
|
getList.setInt(1, id);
|
||||||
System.out.println(getList);
|
System.out.println(getList);
|
||||||
ResultSet getListResults = getList.executeQuery();
|
ResultSet getListResults = getList.executeQuery();
|
||||||
getListResults.first();
|
getListResults.first();
|
||||||
System.out.println(getListResults);
|
System.out.println(getListResults);
|
||||||
List retrievedList = new List(getListResults);
|
List retrievedList = new List(getListResults, shared);
|
||||||
System.out.println(retrievedList);
|
System.out.println(retrievedList);
|
||||||
PreparedStatement getListEntries = connection.prepareStatement(GET_ENTRIES);
|
PreparedStatement getListEntries = connection.prepareStatement(GET_ENTRIES);
|
||||||
getListEntries.setInt(1, id);
|
getListEntries.setInt(1, id);
|
||||||
|
|||||||
@ -8,17 +8,19 @@ public class List {
|
|||||||
String owner;
|
String owner;
|
||||||
long lastUpdated;
|
long lastUpdated;
|
||||||
final ListEntry[] entries;
|
final ListEntry[] entries;
|
||||||
|
boolean shared;
|
||||||
|
|
||||||
public List(Integer itemID, String name, String owner, long lastUpdated, ListEntry[] entries) {
|
public List(Integer itemID, String name, String owner, long lastUpdated, ListEntry[] entries, boolean shared) {
|
||||||
this.itemID = itemID;
|
this.itemID = itemID;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.lastUpdated = lastUpdated;
|
this.lastUpdated = lastUpdated;
|
||||||
this.entries = entries;
|
this.entries = entries;
|
||||||
|
this.shared = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List(Integer itemID, String name, String owner, long lastUpdated) {
|
public List(Integer itemID, String name, String owner, long lastUpdated) {
|
||||||
this(itemID, name, owner, lastUpdated, null);
|
this(itemID, name, owner, lastUpdated, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -29,6 +31,7 @@ public class List {
|
|||||||
", owner='" + owner + '\'' +
|
", owner='" + owner + '\'' +
|
||||||
", lastUpdated=" + lastUpdated +
|
", lastUpdated=" + lastUpdated +
|
||||||
", entries=" + Arrays.toString(entries) +
|
", entries=" + Arrays.toString(entries) +
|
||||||
|
", shared=" + shared +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,4 +70,12 @@ public class List {
|
|||||||
public ListEntry[] getEntries() {
|
public ListEntry[] getEntries() {
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isShared() {
|
||||||
|
return shared;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShared(boolean shared) {
|
||||||
|
this.shared = shared;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user