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

36
LINES

< > BotCompany Repo | #1027555 // Concept Undo Classes [UndoCreateConcept, UndoDeleteConcept, UndoSetConceptField]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (12826L/86K).

srecord UndoCreateConcept(long conceptID) implements UndoableWithAnswer {
  transient Concepts cc = db_mainConcepts();
  
  toString { ret "Create " + getConcept(conceptID); }
  
  public S undo() {
    Concept c = getConcept(cc, conceptID);
    S result = "Deleted " + c + " again";
    deleteConcept(conceptID);
    ret result;
  }
}

srecord UndoDeleteConcept(Concept concept) implements UndoableWithAnswer {
  transient Concepts cc = db_mainConcepts();
  
  toString { ret "Delete " + concept; }
  
  public S undo() {
    registerConcept(cc, concept);
    ret "Restored " + concept;
  }
}

srecord UndoSetConceptField(long conceptID, S field, O value, O newValue) implements UndoableWithAnswer {
  transient Concepts cc = db_mainConcepts();
  
  toString { ret "Set " + field + " of " + getConcept(conceptID) + " to " + newValue; }
  
  public S undo() {
    Concept c = getConcept(cc, conceptID);
    S result = "Reset " + field + " of " + c + " to " + value;
    cset(c, field, value);
    ret result;
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1027555
Snippet name: Concept Undo Classes [UndoCreateConcept, UndoDeleteConcept, UndoSetConceptField]
Eternal ID of this version: #1027555/6
Text MD5: 6f5926436214b8096362bdc59a8c96e4
Transpilation MD5: f6bfe7209ef32e91aceb0e0050535a82
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-23 22:29:36
Source code size: 1049 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 288 / 626
Version history: 5 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)