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

42
LINES

< > BotCompany Repo | #1016872 // Snippets DB v2 [Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (30264L/196K).

!7

!include #1016871 // main is not run

module SnippetsDB {
  bool withText, quickUpdate;
  transient ReliableSingleThread rst = new(r updateMe);

  start {
    updateInterval = quickUpdate ? 60 : 3600;
    autoDownloadText = withText;
    useDBOf(#1016871);
    addDirToDontBackupList(dbDir());
    onConceptsChange(rst);
    fullUpdateAtStart = false;
    snippetsDB_init();
    indexConceptField(CSnippet, 'type);
  }
  
  visualize {
    ret centerBoldLabel(jLiveValueLabel(dm_calculatedLiveValue(this, S,
      func -> S { n2(countConcepts(CSnippet), "snippet") })));
  }
  
  enhanceFrame {
    addTitlePopupMenuItem(f, "Full download", r-thread enter { fullDownload(); });
    dm_boolFieldMenuItem(f, 'withText, onSet := r { autoDownloadText = withText });
    dm_boolFieldMenuItem(f, 'quickUpdate);
  }
  
  // API for other modules
  
  L<CSnippet> snippetsOfType(S type) {
    ret sortedByFieldDesc('snippetID, conceptsWhere(CSnippet, +type));
  }
  
  L<CSnippet> allSnippets() { ret list(CSnippet); }
  
  S getSnippetText(S snippetID) enter {
    ret main.getSnippetText(snippetID);
  }
}

Author comment

Began life as a copy of #1016026

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, hpgrupgrauku, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1016872
Snippet name: Snippets DB v2 [Dyn Module]
Eternal ID of this version: #1016872/31
Text MD5: de70eed6fd6a1b66a0ba1404cdb84c0b
Transpilation MD5: 29ebab24365d22c714f840ade9acaa54
Author: stefan
Category: javax / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-12 23:57:48
Source code size: 1144 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 669 / 617460
Version history: 30 change(s)
Referenced in: #1016478 - Stefan's OS v6
#1017075 - dm_snippetsDB - returns module ID
#1020212 - Stack Trace showing unnoticed deadlock in old version of setField()
#1022257 - dm_snippetIDsWhereTextMatches
#1022729 - Stefan's OS v6 - copy for transpiler test
#1024932 - Stefan's OS v7 [LIVE]
#1031320 - Stefan's OS v7 [backup before allowing dynamic main classes]