<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.boot.model.naming.impl;

import java.util.regex.Pattern;

import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
import org.hibernate.boot.model.source.spi.AttributePath;

/**
 * An {@link ImplicitNamingStrategy} which exposes component property names via their full path (e.g. "newsId.author")
 * rather than only the actual property name (e.g. "author").
 *
 * @author <NAME>
 */
public class OgmImplicitNamingStrategy extends ImplicitNamingStrategyJpaCompliantImpl {

	/**
	 * A pattern common to all property names used in element collections.
	 */
	private static final Pattern ELEMENT_COLLECTION_NAME_PATTERN = Pattern.compile( "collection&&element\\." );

	@Override
	protected String transformAttributePath(AttributePath attributePath) {
		// for element collections just use the simple name
		String[] parts = ELEMENT_COLLECTION_NAME_PATTERN.split( attributePath.getFullPath() );

		// for element collections just use the simple name
		if ( parts.length == 2 ) {
			return parts[1];
		}
		else {
			return attributePath.getFullPath();
		}
	}
}<commit_msg>OGM-982 Remove reference to collection&&element in OgmImplicitNamingStrategy<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.boot.model.naming.impl;

import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
import org.hibernate.boot.model.source.spi.AttributePath;

/**
 * An {@link ImplicitNamingStrategy} which exposes component property names via their full path (e.g. "newsId.author")
 * rather than only the actual property name (e.g. "author").
 *
 * @author <NAME>
 * @author <NAME>
 */
public class OgmImplicitNamingStrategy extends ImplicitNamingStrategyJpaCompliantImpl {

	@Override
	protected String transformAttributePath(AttributePath attributePath) {
		if ( attributePath.isPartOfCollectionElement() ) {
			return componentPath( attributePath );
		}
		return attributePath.getFullPath();
	}

	private String componentPath(AttributePath attributePath) {
		AttributePath parentAttributePath = attributePath;
		StringBuilder builder = new StringBuilder( parentAttributePath.getProperty() );
		while ( !attributePath.getParent().isCollectionElement() ) {
			attributePath = attributePath.getParent();
			builder.insert( 0, "." );
			builder.insert( 0, attributePath.getProperty() );
		}
		String componentPath = builder.toString();
		return componentPath;
	}
}
{'fraction_non_alphanumeric': 0.10270805812417437, 'fraction_numerical': 0.004953764861294584, 'mean_word_length': 4.90448343079922, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '4560035', 'n_tokens_mistral': 934, 'n_tokens_neox': 864, 'n_words': 235}