Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/prerna/collaboration/BrainTopicBrief.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ private static String topic(User user, String ownerId, String ownerType, String
classLogger.warn("Could not count the threads of topic {} for the brief", topicId, e);
}
out.append(BrainTopicFiles.brief(ownerId, ownerType, topicId));
out.append(linkedFoldersBrief(ownerId, ownerType, topicId));
// the topic's work items, each with the owner's next step or who they wait on
List<Map<String, Object>> items = new ArrayList<>();
for (Object o : (List<?>) WorkTaskUtils.listMyWork(user, Map.of("topicId", topicId)).get("workItems")) {
Expand Down Expand Up @@ -245,4 +246,37 @@ static List<Map<String, Object>> openWork(String ownerId, String ownerType, Stri
private static String clip(String text, int max) {
return text.length() <= max ? text : text.substring(0, max - 3) + "...";
}

private static String linkedFoldersBrief(String ownerId, String ownerType, String topicId) {
List<Map<String, Object>> links = BrainTopicLinks.ofTopic(ownerId, ownerType, topicId);
if (links.isEmpty()) {
return "";
}
StringBuilder out = new StringBuilder(
"\nLinked Microsoft 365 folders: the owner linked these to this topic because they contain "
+ "relevant files for this topic's work. The agent lists and reads files from these by default. "
+ "To list files, call ListDriveFiles for a OneDrive link, or ListChannelFiles for Teams. "
+ "Availability is marked 'ok' or 'unavailable' (access lost):");
for (Map<String, Object> link : links.subList(0, Math.min(links.size(), MAX_ITEMS))) {
out.append("\n- ").append(BrainThreadBrief.neutral(String.valueOf(link.get("displayName"))))
.append(" (");
String state = String.valueOf(link.get("state"));
out.append(state);
if ("ok".equals(state)) {
String kind = String.valueOf(link.get("kind"));
if ("drive_folder".equals(kind)) {
out.append(", driveId ").append(link.get("driveId")).append(", itemId ")
.append(link.get("itemId"));
} else if ("channel_files".equals(kind)) {
out.append(", teamId ").append(link.get("teamId")).append(", channelId ")
.append(link.get("channelId"));
}
}
out.append(")");
}
if (links.size() > MAX_ITEMS) {
out.append("\nAnd ").append(links.size() - MAX_ITEMS).append(" more, listed on the topic's page.");
}
return out.toString();
}
}
10 changes: 9 additions & 1 deletion src/prerna/collaboration/BrainTopicChangeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public final class BrainTopicChangeUtils {
private static final String FOLDER_TOPIC = "BRAIN_TOPIC_FOLDER";
// OneDrive and Teams files linked to the topics; likewise only when there are some
private static final String FILE_TOPIC = "BRAIN_TOPIC_FILE";
// OneDrive, Teams and SharePoint folders linked to the topics
private static final String LINK_TOPIC = "BRAIN_TOPIC_LINK";
// work items linked to the topics; likewise only when there are some
private static final String TASK_TOPIC = "WORK_TASK_TOPIC";
// memories linked to the topics, keyed by memory: the rows and every link they have
Expand Down Expand Up @@ -255,7 +257,7 @@ private static Map<String, Object> undoInReview(User user, String changeId) {
+ CollaborationDbUtils.placeholders(topicIds.size()) + ")",
params(ownerId, ownerType, topicIds));
}
for (String table : List.of(ROOM_TOPIC, FOLDER_TOPIC, TASK_TOPIC, FILE_TOPIC)) {
for (String table : List.of(ROOM_TOPIC, FOLDER_TOPIC, TASK_TOPIC, FILE_TOPIC, LINK_TOPIC)) {
CollaborationDbUtils.update(conn,
"DELETE FROM " + table + OWNED + " AND TOPIC_ID IN ("
+ CollaborationDbUtils.placeholders(topicIds.size()) + ")",
Expand Down Expand Up @@ -355,6 +357,12 @@ private static Map<String, List<Map<String, Object>>> scopeRows(Connection conn,
if (!files.isEmpty()) {
rows.put(FILE_TOPIC, files);
}
List<Map<String, Object>> links = readRows(conn, "SELECT * FROM " + LINK_TOPIC + OWNED
+ " AND TOPIC_ID IN (" + CollaborationDbUtils.placeholders(topicIds.size())
+ ") ORDER BY TOPIC_ID, LINK_ID", params(ownerId, ownerType, topicIds));
if (!links.isEmpty()) {
rows.put(LINK_TOPIC, links);
}
if (!memoryIds.isEmpty()) {
String inMemories = " AND MEMORY_ID IN (" + CollaborationDbUtils.placeholders(memoryIds.size()) + ")";
rows.put(MEMORY, readRows(conn, "SELECT * FROM " + MEMORY + OWNED + inMemories + " ORDER BY MEMORY_ID",
Expand Down
Loading
Loading