text:
package uk.nhs.careconnect.ri.database.entity.valueSet;

import uk.nhs.careconnect.ri.database.entity.codeSystem.CodeSystemEntity;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Entity
@Table(name="ValueSetInclude", uniqueConstraints= @UniqueConstraint(name="PK_VALUESET_INCLUDE", columnNames={"VALUESET_INCLUDE_ID"}))
public class ValueSetInclude {

	private static final int MAX_DESC_LENGTH = 400;

	public ValueSetInclude() {

	}

	public ValueSetInclude(ValueSetEntity valueSetEntity) {
		this.valueSetEntity = valueSetEntity;
	}
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name= "VALUESET_INCLUDE_ID")
	private Integer contentId;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CODESYSTEM_PID",referencedColumnName = "CODESYSTEM_ID", foreignKey = @ForeignKey(name = "FK_VALUESET_INCLUDE_CODESYSTEM_ID"))
	private CodeSystemEntity myCodeSystem;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn (name = "VALUESET_ID",foreignKey= @ForeignKey(name="FK_VALUESET_VALUESET_INLCUDE"))
	private ValueSetEntity valueSetEntity;

    @OneToMany(mappedBy="include", targetEntity=ValueSetIncludeConcept.class)
    private List<ValueSetIncludeConcept> concepts;

	@OneToMany(mappedBy="include", targetEntity=ValueSetIncludeFilter.class)
	private List<ValueSetIncludeFilter> filters;

	// Don't allow access to CodeSystem. This is not the place
	public String getSystem() {
		return this.myCodeSystem.getCodeSystemUri();
	}
	public void setCodeSystem(CodeSystemEntity codeSystem) {
		this.myCodeSystem = codeSystem;
	}

	public Integer getId() { return contentId; }
	public void setId(Integer contentId) { this.contentId = contentId; }

	public ValueSetEntity getValueSetEntity() {
	        return this.valueSetEntity;
	}
	public void setValueSetEntity(ValueSetEntity valueSetEntity) {
	        this.valueSetEntity = valueSetEntity;
	}

    public List<ValueSetIncludeConcept> getConcepts() {
	    if (concepts == null) {
	        concepts = new ArrayList<>() ;

        }
        return concepts;
    }

    public void setConcepts(List<ValueSetIncludeConcept> concepts) {
        this.concepts = concepts;
    }

	public List<ValueSetIncludeFilter> getFilters() {
		if (filters == null) {
			filters = new ArrayList<>() ;

		}
		return filters;
	}

	public void setFilters(List<ValueSetIncludeFilter> filters) {
		this.filters = filters;
	}
}


text:
require 'set'

module MongoMapper
  module Plugins
    module IdentityMap
      extend ActiveSupport::Concern

      def self.enabled=(flag)
        Thread.current[:mongo_mapper_identity_map_enabled] = flag
      end

      def self.enabled
        Thread.current[:mongo_mapper_identity_map_enabled]
      end

      def self.enabled?
        enabled == true
      end

      def self.repository
        Thread.current[:mongo_mapper_identity_map] ||= {}
      end

      def self.clear
        repository.clear
      end

      def self.include?(document)
        repository.key?(IdentityMap.key(document.class, document._id))
      end

      def self.key(model, id)
        "#{model.single_collection_root.name}:#{id}"
      end

      def self.use
        old, self.enabled = enabled, true

        yield if block_given?
      ensure
        self.enabled = old
        clear
      end

      def self.without
        old, self.enabled = enabled, false

        yield if block_given?
      ensure
        self.enabled = old
      end

      module ClassMethods
        # Private - Looks for a document in the identity map
        def get_from_identity_map(id)
          IdentityMap.repository[IdentityMap.key(self, id)]
        end

        def query(opts={})
          super.tap do |query|
            query.identity_map = self if Thread.current[:mongo_mapper_identity_map_enabled]
          end
        end

        def remove_documents_from_map(*documents)
          documents.flatten.compact.each do |document|
            document.remove_from_identity_map
          end
        end

        def load(attrs, with_cast = false)
          return super unless Thread.current[:mongo_mapper_identity_map_enabled]
          return nil unless attrs
          document = get_from_identity_map(attrs['_id'])

          if !document
            document = super
            document.add_to_identity_map
          end

          document
        end
      end

      def save(*args)
        super.tap { |result| add_to_identity_map if result }
      end

      def delete
        super.tap { remove_from_identity_map }
      end

      def add_to_identity_map
        if IdentityMap.enabled?
          key = IdentityMap.key(self.class, _id)
          IdentityMap.repository[key] = self
        end
      end

      def remove_from_identity_map
        if IdentityMap.enabled?
          key = IdentityMap.key(self.class, _id)
          IdentityMap.repository.delete(key)
        end
      end
    end
  end
end

module PluckyMethods
  module ClassMethods
    extend ActiveSupport::Concern

    included do
      attr_accessor :identity_map

      # Ensure that these aliased methods in plucky also get overridden.
      alias_method :first, :find_one
      alias_method :each, :find_each
    end

    def find_one(opts={})
      query = clone.amend(opts)

      if identity_map && query.simple? && (document = identity_map.get_from_identity_map(query[:_id]))
        document
      else
        super.tap do |doc|
          doc.remove_from_identity_map if doc && query.fields?
        end
      end
    end

    def find_each(opts={})
      return super if !block_given?

      query = clone.amend(opts)
      super(opts) do |doc|
        doc.remove_from_identity_map if doc && query.fields?
        yield doc
      end
    end
  end
end

::MongoMapper::Plugins::Querying::DecoratedPluckyQuery.send :include, ::PluckyMethods::ClassMethods

redpajama_set_name: RedPajamaGithub