<commit_before>/*
 * Hibernate OGM, Domain model persistence for NoSQL datastores
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
 */
package org.hibernate.ogm.datastore.neo4j.remote.http.dialect.impl;

import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.hibernate.ogm.datastore.neo4j.EmbeddedNeo4jDialect;
import org.hibernate.ogm.datastore.neo4j.remote.http.json.impl.Graph.Node;
import org.hibernate.ogm.dialect.spi.TupleTypeContext;
import org.hibernate.ogm.model.key.spi.AssociatedEntityKeyMetadata;
import org.hibernate.ogm.model.key.spi.EntityKeyMetadata;
import org.hibernate.ogm.model.spi.TupleSnapshot;

/**
 * Represents the Tuple snapshot as loaded by the Neo4j datastore.
 * <p>
 * The columns of the tuple are mapped as properties of the node.
 *
 * @author <NAME> &lt;<EMAIL>&gt;
 */
public final class HttpNeo4jTupleSnapshot implements TupleSnapshot {

	private final Node node;
	private final Map<String, AssociatedEntityKeyMetadata> associatedEntityKeyMetadata;
	private final EntityKeyMetadata entityKeyMetadata;

	private final Map<String, Node> toOneEntities;
	private final Map<String, Collection<Node>> embeddedNodes;
	private final Map<String, String> rolesByColumn;

	public HttpNeo4jTupleSnapshot(
			NodeWithEmbeddedNodes node,
			EntityKeyMetadata entityKeyMetadata,
			Map<String, Node> toOneEntities,
			TupleTypeContext tupleTypeContext
			) {
		this.node = node.getOwner();
		this.embeddedNodes = node.getEmbeddedNodes();
		this.entityKeyMetadata = entityKeyMetadata;
		this.toOneEntities = toOneEntities;
		this.associatedEntityKeyMetadata = tupleTypeContext.getAllAssociatedEntityKeyMetadata();
		this.rolesByColumn = tupleTypeContext.getAllRoles();
	}

	@Override
	public Object get(String column) {
		if ( associatedEntityKeyMetadata.containsKey( column ) ) {
			return readPropertyOnOtherNode( column );
		}
		else if ( EmbeddedNeo4jDialect.isPartOfRegularEmbedded( entityKeyMetadata.getColumnNames(), column ) ) {
			return readEmbeddedProperty( column );<commit_msg>OGM-1253 Avoid reference to Embedded dialect in HttpNeo4jTupleSnapshot<commit_after>/*
 * Hibernate OGM, Domain model persistence for NoSQL datastores
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
 */
package org.hibernate.ogm.datastore.neo4j.remote.http.dialect.impl;

import static org.hibernate.ogm.datastore.neo4j.BaseNeo4jDialect.isPartOfRegularEmbedded;

import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.hibernate.ogm.datastore.neo4j.remote.http.json.impl.Graph.Node;
import org.hibernate.ogm.dialect.spi.TupleTypeContext;
import org.hibernate.ogm.model.key.spi.AssociatedEntityKeyMetadata;
import org.hibernate.ogm.model.key.spi.EntityKeyMetadata;
import org.hibernate.ogm.model.spi.TupleSnapshot;

/**
 * Represents the Tuple snapshot as loaded by the Neo4j datastore.
 * <p>
 * The columns of the tuple are mapped as properties of the node.
 *
 * @author <NAME> &lt;<EMAIL>&gt;
 */
public final class HttpNeo4jTupleSnapshot implements TupleSnapshot {

	private final Node node;
	private final Map<String, AssociatedEntityKeyMetadata> associatedEntityKeyMetadata;
	private final EntityKeyMetadata entityKeyMetadata;

	private final Map<String, Node> toOneEntities;
	private final Map<String, Collection<Node>> embeddedNodes;
	private final Map<String, String> rolesByColumn;

	public HttpNeo4jTupleSnapshot(
			NodeWithEmbeddedNodes node,
			EntityKeyMetadata entityKeyMetadata,
			Map<String, Node> toOneEntities,
			TupleTypeContext tupleTypeContext
			) {
		this.node = node.getOwner();
		this.embeddedNodes = node.getEmbeddedNodes();
		this.entityKeyMetadata = entityKeyMetadata;
		this.toOneEntities = toOneEntities;
		this.associatedEntityKeyMetadata = tupleTypeContext.getAllAssociatedEntityKeyMetadata();
		this.rolesByColumn = tupleTypeContext.getAllRoles();
	}

	@Override
	public Object get(String column) {
		if ( associatedEntityKeyMetadata.containsKey( column ) ) {
			return readPropertyOnOtherNode( column );
		}
		else if ( isPartOfRegularEmbedded( entityKeyMetadata.getColumnNames(), column ) ) {
			return readEmbeddedProperty( column );
{'fraction_non_alphanumeric': 0.0929761368752814, 'fraction_numerical': 0.006303466906798739, 'mean_word_length': 5.467248908296943, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '6278152', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1350, 'n_words': 316}