Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

40
LINES

< > BotCompany Repo | #1026288 // DynMultiComm

JavaX fragment (include)

1  
!include once #1026287 // Multi-Comm Concepts
2  
3  
abstract sclass DynMultiComm > DynModule {
4  
  transient ConceptTable<Customer> ct;
5  
  transient bool considerAllActive;
6  
  
7  
  start {
8  
    dbIndexing(Customer, 'cookie, Customer, 'active, Message, 'customer);
9  
  }
10  
  
11  
  visualize {
12  
    ct = new ConceptTable(Customer);
13  
    if (!considerAllActive) ct.filter = c -> c.active();
14  
    IF1<Customer, Map> renderer = defaultConceptRendererForTable(Customer);
15  
    ct.renderer = c -> {
16  
      Map map = renderer.get(c);
17  
      map.remove("lastPing");
18  
      transformValueInPlace str(map, "botConversationID");
19  
      map.put("Last activity", iround(toSeconds(elapsedMS_timestamp(c.lastPing))));
20  
      Message msg = c.lastMessage();
21  
      map.put("Last message", msg == null ? "" : msg.text);
22  
      ret map;
23  
    };
24  
    awtEvery(ct.getTable(), 5.0, r { ct.update() });
25  
26  
    ret jhsplit(
27  
      jCenteredSection("Active Customers", ct.getTable()),
28  
      jCenteredSection("Messages", makeConceptsTable(Message)));
29  
  }
30  
31  
  // API
32  
  
33  
  L<Customer> activeCustomers() {
34  
    ret cloneList(conceptsWhere Customer(active := true));
35  
  }
36  
  
37  
  L<Message> messagesForCustomer(Customer c) {
38  
    ret cloneList(conceptsWhere Message(customer := c));
39  
  }
40  
}

Author comment

Began life as a copy of #1026276

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1026288
Snippet name: DynMultiComm
Eternal ID of this version: #1026288/5
Text MD5: 21374929de81ef9259990e92550de8f1
Author: stefan
Category: javax / comm
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-12-11 19:30:56
Source code size: 1253 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 238 / 538
Version history: 4 change(s)
Referenced in: [show references]