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

118
LINES

< > BotCompany Repo | #1024354 // agi.blue concepts & core classes [Include]

JavaX fragment (include)

1  
// in main DB
2  
concept Slice {
3  
  GlobalID globalID = aGlobalIDObject();
4  
  S caseID;
5  
  S name;
6  
  long sliceDumped; // wall time, set before dump starts
7  
  bool indexed = true;
8  
  
9  
  S defaultCaseID() {
10  
    ret uniqueFileNameUsingMD5_80_v2(name + " " + globalID);
11  
  }
12  
}
13  
14  
// in any DB
15  
concept Page {
16  
  S globalID = aGlobalID();
17  
  S url, q;
18  
}
19  
20  
abstract concept AbstractEntry {
21  
  new Ref<Page> page;
22  
  int count;
23  
  S key;
24  
  S ip;
25  
  new Ref<Signer> signer;
26  
}
27  
28  
concept Entry > AbstractEntry {
29  
  S globalID = aGlobalID(); // TODO: migrate to object
30  
  S value;
31  
}
32  
33  
concept MultiLineEntry > AbstractEntry {
34  
  GlobalID globalID = aGlobalIDObject();
35  
  S value;
36  
}
37  
38  
concept BlobEntry > AbstractEntry {
39  
  GlobalID globalID = aGlobalIDObject();
40  
  long length;
41  
  S md5;
42  
}
43  
44  
// in main DB?
45  
concept Signer {
46  
  S globalID = aGlobalID();
47  
  S publicKey;
48  
  bool trusted;
49  
  S approvedBy;
50  
}
51  
52  
// in main DB
53  
concept Session {
54  
  S cookie;
55  
  S selectedSlice; // global ID
56  
  Page slicePage; // phasing out
57  
  
58  
  long googleLogInDate;
59  
  S googleEmail, googleFirstName, googleLastName;
60  
  bool googleEmailVerified;
61  
}
62  
63  
// singleton concept in every DB
64  
concept SliceInfo {
65  
  GlobalID globalID;
66  
  LS mandatoryBotVMBusIDs;
67  
}
68  
69  
sclass CentralIndexEntry {
70  
  Set<Slice> slices = synchroLinkedHashSet();
71  
}
72  
73  
// global constants
74  
75  
sclass LoadedSlice { // non-persistent class
76  
  S caseID;
77  
  Concepts cc;
78  
  Slice sliceConcept;
79  
  long lastAccess = sysNow();
80  
  
81  
  ConceptFieldIndexDesc idx_latestEntries, idx_latestCreatedPages, idx_latestChangedPages;
82  
  
83  
  *(S *caseID, Concepts *cc) {
84  
    indexThings();
85  
    
86  
    // forward changes to Slice concept
87  
    onConceptsChange(cc, r {
88  
      cset(sliceConcept, _modified := now())
89  
    });
90  
    
91  
    if (makeAllValuesPages && legacy)
92  
      for (Entry e : list(cc, Entry))
93  
        pageFromQ(e.value);
94  
  }
95  
  
96  
  void initialSetup(GlobalID globalID) {
97  
    SliceInfo info = uniq(cc, SliceInfo);
98  
    cset(info, +globalID);
99  
  }
100  
  
101  
  // create if not there
102  
  Page pageFromQ(S q) {
103  
    ret main.pageFromQ(cc, q);
104  
  }
105  
106  
  void indexThings() {
107  
    indexConceptFieldsCI(cc, Page, 'url, Page, 'q, Entry, 'key, Entry, 'value);
108  
    indexConceptFields(cc, Signer, 'publicKey);
109  
    indexConceptFields(cc, Session, 'cookie);
110  
    indexSingletonConcept(cc, SliceInfo);
111  
    idx_latestCreatedPages = new ConceptFieldIndexDesc(cc, Page, 'created);
112  
    idx_latestChangedPages = new ConceptFieldIndexDesc(cc, Page, '_modified);
113  
    idx_latestEntries = new ConceptFieldIndexDesc(cc, Entry, 'created);
114  
  }
115  
  
116  
  bool isMainSlice() { ret empty(caseID); }
117  
  GlobalID globalID() { ret sliceConcept.globalID; }
118  
}

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: #1024354
Snippet name: agi.blue concepts & core classes [Include]
Eternal ID of this version: #1024354/2
Text MD5: 176512a37a2f8c541200f3967511c32b
Author: stefan
Category: javax / agi.blue
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-05 12:48:29
Source code size: 2685 bytes / 118 lines
Pitched / IR pitched: No / No
Views / Downloads: 287 / 285
Version history: 1 change(s)
Referenced in: [show references]