<commit_before>/**
 * @license
 * Copyright 2019 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */
foam.CLASS({
  package: 'foam.nanos.crunch',
  name: 'DisableDeprecatedCapabilityOnPut',

  documentation: 'Set enabled to false on deprecated capabilities',

  implements: [
    'foam.nanos.ruler.RuleAction'
  ],

  javaImports: [
    'foam.core.ContextAgent',
    'foam.core.X',
    'foam.dao.DAO',
    'foam.nanos.crunch.Capability',
    'foam.nanos.crunch.CapabilityCapabilityJunction'
  ],

  methods: [
    {
      name: 'applyAction',
      javaCode: `
      DAO capabilityDAO = (DAO) x.get("capabilityDAO");
      String deprecatedId = ((CapabilityCapabilityJunction) obj).getSourceId();
      final Capability deprecated = (Capability) ((capabilityDAO.find(deprecatedId)).fclone());
      deprecated.setEnabled(false);

      agency.submit(x, new ContextAgent() {
        @Override
        public void execute(X x) {
          ((DAO) x.get("capabilityDAO")).put(deprecated);
        }
      }); 
      `
    }
  ]
});<commit_msg>#comment remove fclone<commit_after>/**
 * @license
 * Copyright 2019 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */
foam.CLASS({
  package: 'foam.nanos.crunch',
  name: 'DisableDeprecatedCapabilityOnPut',

  documentation: 'Set enabled to false on deprecated capabilities',

  implements: [
    'foam.nanos.ruler.RuleAction'
  ],

  javaImports: [
    'foam.core.ContextAgent',
    'foam.core.X',
    'foam.dao.DAO',
    'foam.nanos.crunch.Capability',
    'foam.nanos.crunch.CapabilityCapabilityJunction'
  ],

  methods: [
    {
      name: 'applyAction',
      javaCode: `
      DAO capabilityDAO = (DAO) x.get("capabilityDAO");
      String deprecatedId = ((CapabilityCapabilityJunction) obj).getSourceId();
      final Capability deprecated = (Capability) (capabilityDAO.find(deprecatedId));
      deprecated.setEnabled(false);

      agency.submit(x, new ContextAgent() {
        @Override
        public void execute(X x) {
          ((DAO) x.get("capabilityDAO")).put(deprecated);
        }
      }); 
      `
    }
  ]
});
{'fraction_non_alphanumeric': 0.14418604651162792, 'fraction_numerical': 0.005581395348837209, 'mean_word_length': 3.013059701492537, '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': '6343086', 'n_tokens_mistral': 732, 'n_tokens_neox': 711, 'n_words': 122}