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)

// in main DB
concept Slice {
  GlobalID globalID = aGlobalIDObject();
  S caseID;
  S name;
  long sliceDumped; // wall time, set before dump starts
  bool indexed = true;
  
  S defaultCaseID() {
    ret uniqueFileNameUsingMD5_80_v2(name + " " + globalID);
  }
}

// in any DB
concept Page {
  S globalID = aGlobalID();
  S url, q;
}

abstract concept AbstractEntry {
  new Ref<Page> page;
  int count;
  S key;
  S ip;
  new Ref<Signer> signer;
}

concept Entry > AbstractEntry {
  S globalID = aGlobalID(); // TODO: migrate to object
  S value;
}

concept MultiLineEntry > AbstractEntry {
  GlobalID globalID = aGlobalIDObject();
  S value;
}

concept BlobEntry > AbstractEntry {
  GlobalID globalID = aGlobalIDObject();
  long length;
  S md5;
}

// in main DB?
concept Signer {
  S globalID = aGlobalID();
  S publicKey;
  bool trusted;
  S approvedBy;
}

// in main DB
concept Session {
  S cookie;
  S selectedSlice; // global ID
  Page slicePage; // phasing out
  
  long googleLogInDate;
  S googleEmail, googleFirstName, googleLastName;
  bool googleEmailVerified;
}

// singleton concept in every DB
concept SliceInfo {
  GlobalID globalID;
  LS mandatoryBotVMBusIDs;
}

sclass CentralIndexEntry {
  Set<Slice> slices = synchroLinkedHashSet();
}

// global constants

sclass LoadedSlice { // non-persistent class
  S caseID;
  Concepts cc;
  Slice sliceConcept;
  long lastAccess = sysNow();
  
  ConceptFieldIndexDesc idx_latestEntries, idx_latestCreatedPages, idx_latestChangedPages;
  
  *(S *caseID, Concepts *cc) {
    indexThings();
    
    // forward changes to Slice concept
    onConceptsChange(cc, r {
      cset(sliceConcept, _modified := now())
    });
    
    if (makeAllValuesPages && legacy)
      for (Entry e : list(cc, Entry))
        pageFromQ(e.value);
  }
  
  void initialSetup(GlobalID globalID) {
    SliceInfo info = uniq(cc, SliceInfo);
    cset(info, +globalID);
  }
  
  // create if not there
  Page pageFromQ(S q) {
    ret main.pageFromQ(cc, q);
  }

  void indexThings() {
    indexConceptFieldsCI(cc, Page, 'url, Page, 'q, Entry, 'key, Entry, 'value);
    indexConceptFields(cc, Signer, 'publicKey);
    indexConceptFields(cc, Session, 'cookie);
    indexSingletonConcept(cc, SliceInfo);
    idx_latestCreatedPages = new ConceptFieldIndexDesc(cc, Page, 'created);
    idx_latestChangedPages = new ConceptFieldIndexDesc(cc, Page, '_modified);
    idx_latestEntries = new ConceptFieldIndexDesc(cc, Entry, 'created);
  }
  
  bool isMainSlice() { ret empty(caseID); }
  GlobalID globalID() { ret sliceConcept.globalID; }
}

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: 285 / 282
Version history: 1 change(s)
Referenced in: [show references]