<commit_before>/**
 * @license
 * Copyright 2018 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

foam.CLASS({
  package: 'foam.dao.java',
  name: 'JDAO',
  extends: 'foam.dao.ProxyDAO',
  flags: ['java'],

  axioms: [
    {
      name: 'javaExtras',
      buildJavaClass: function (cls) {
        cls.extras.push(`
          // TODO: These convenience constructors should be removed and done using the facade pattern.
          public JDAO(foam.core.X x, foam.core.ClassInfo classInfo, String filename) {
            this(x, new foam.dao.MDAO(classInfo), filename);
          }

          public JDAO(foam.core.X x, foam.core.ClassInfo classInfo, String filename, boolean outputDiff) {
            this(x, new foam.dao.MDAO(classInfo), filename, outputDiff);
          }

          public JDAO(foam.core.X x, foam.dao.DAO delegate, String filename) {
            this(x, delegate, filename, false);
          }

          public JDAO(foam.core.X x, foam.dao.DAO delegate, String filename, boolean outputDiff) {
            setX(x);
            setOf(delegate.getOf());
            setDelegate(delegate);

            // create journal
            setJournal(new foam.dao.FileJournal.Builder(x)
              .setDao(delegate)
              .setFilename(filename)
              .setCreateFile(true)
              .setOutputDiff(outputDiff)
              .build());

            // create a composite journal of repo journal
            // and runtime journal and load them all
            new foam.dao.CompositeJournal.Builder(x)
              .setDelegates(new foam.dao.Journal[]{
                new foam.dao.FileJournal.Builder(x)
                  .setFilename(filename + ".0")
                  .build(),
                new foam.dao.FileJournal.Builder(x)
                  .setFilename(filename)
                  .build()
              })
              .build().replay(x, delegate);
          }
        `);
      }
    }
  ],

  properties: [
    {
      class: 'FObjectProperty',
      of: 'foam.dao.FileJournal',
      name: 'journal'
    }
  ],

  methods: [
    {
      name: 'put_',
      synchronized: true,
      javaCode: `
        foam.core.FObject result = super.put_(x, obj);
        getJournal().put(x, result);
        return result;
      `
    },
    {
      name: 'remove_',
      synchronized: true,
      javaCode: `
        foam.core.FObject result = super.remove_(x, obj);
        getJournal().remove(x, result);
        return result;
      `
    },
    {
      name: 'removeAll_',
      javaCode: `
        super.select_(x, new foam.dao.RemoveSink(x, this), skip, limit, order, predicate);
      `
    }
  ]
});
<commit_msg>Modified JDAO journal property to just be a Journal and not a FileJournal<commit_after>/**
 * @license
 * Copyright 2018 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

foam.CLASS({
  package: 'foam.dao.java',
  name: 'JDAO',
  extends: 'foam.dao.ProxyDAO',
  flags: ['java'],

  axioms: [
    {
      name: 'javaExtras',
      buildJavaClass: function (cls) {
        cls.extras.push(`
          // TODO: These convenience constructors should be removed and done using the facade pattern.
          public JDAO(foam.core.X x, foam.core.ClassInfo classInfo, String filename) {
            this(x, new foam.dao.MDAO(classInfo), filename);
          }

          public JDAO(foam.core.X x, foam.core.ClassInfo classInfo, String filename, boolean outputDiff) {
            this(x, new foam.dao.MDAO(classInfo), filename, outputDiff);
          }

          public JDAO(foam.core.X x, foam.dao.DAO delegate, String filename) {
            this(x, delegate, filename, false);
          }

          public JDAO(foam.core.X x, foam.dao.DAO delegate, String filename, boolean outputDiff) {
            setX(x);
            setOf(delegate.getOf());
            setDelegate(delegate);

            // create journal
            setJournal(new foam.dao.FileJournal.Builder(x)
              .setDao(delegate)
              .setFilename(filename)
              .setCreateFile(true)
              .setOutputDiff(outputDiff)
              .build());

            // create a composite journal of repo journal
            // and runtime journal and load them all
            new foam.dao.CompositeJournal.Builder(x)
              .setDelegates(new foam.dao.Journal[]{
                new foam.dao.FileJournal.Builder(x)
                  .setFilename(filename + ".0")
                  .build(),
                new foam.dao.FileJournal.Builder(x)
                  .setFilename(filename)
                  .build()
              })
              .build().replay(x, delegate);
          }
        `);
      }
    }
  ],

  properties: [
    {
      class: 'FObjectProperty',
      of: 'foam.dao.Journal',
      name: 'journal'
    }
  ],

  methods: [
    {
      name: 'put_',
      synchronized: true,
      javaCode: `
        foam.core.FObject result = super.put_(x, obj);
        getJournal().put(x, result);
        return result;
      `
    },
    {
      name: 'remove_',
      synchronized: true,
      javaCode: `
        foam.core.FObject result = super.remove_(x, obj);
        getJournal().remove(x, result);
        return result;
      `
    },
    {
      name: 'removeAll_',
      javaCode: `
        super.select_(x, new foam.dao.RemoveSink(x, this), skip, limit, order, predicate);
      `
    }
  ]
});

{'fraction_non_alphanumeric': 0.12302607418288652, 'fraction_numerical': 0.002570694087403599, 'mean_word_length': 1.730325814536341, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '891733', 'n_tokens_mistral': 1635, 'n_tokens_neox': 1640, 'n_words': 354}