<commit_before>package com.cedarsoftware.util

import com.cedarsoftware.ncube.ApplicationID
import com.cedarsoftware.ncube.NCube
import com.cedarsoftware.ncube.NCubeManager
import com.cedarsoftware.ncube.util.LongHashSet
import groovy.transform.CompileStatic

import static com.cedarsoftware.util.VisualizerConstants.*

/**
 * Provides information to visualize a source cube, a target cube
 * and their relationship.
 */

@CompileStatic
class VisualizerRelInfo
{
	ApplicationID appId

	Set<String> notes = []
	Map<String, Object> scope

	long targetId
	NCube targetCube
	Map<String, Object> targetScope
	long targetLevel
	String nodeLabelPrefix = ''

	long sourceId
	NCube sourceCube
	Map<String, Object> sourceScope
	String sourceFieldName

	boolean cellValuesLoaded
	boolean showCellValuesLink
	boolean showCellValues

	List<VisualizerCellInfo> cellInfo

	List<String> typesToAdd

	protected VisualizerHelper helper = new VisualizerHelper()

	VisualizerRelInfo() {}

	VisualizerRelInfo(ApplicationID applicationId, Map node)
	{
		appId  = applicationId
		targetCube = NCubeManager.getCube(appId, node.cubeName as String)
		String sourceCubeName = node.sourceCubeName as String
		sourceCube = sourceCubeName ? NCubeManager.getCube(appId, sourceCubeName) : null
		sourceFieldName = node.fromFieldName
		targetId = Long.valueOf(node.id as String)
		targetLevel = Long.valueOf(node.level as String)
		targetScope = node.scope as CaseInsensitiveMap
		scope = node.availableScope as CaseInsensitiveMap
		showCellValuesLink = node.showCellValuesLink as boolean
		showCellValues = node.showCellValues as boolean
		cellValuesLoaded = node.cellValuesLoaded as boolean
		typesToAdd = node.typesToAdd as List
	}

	boolean loadCellValues(VisualizerInfo visInfo)
	{
		cellInfo = []
		cellValuesLoaded = true
		if (showCellValues)
		{
			Map<LongHashSet, Object> cellMap = targetCube.cellMap
			cellMap.each { LongHashSet ids, Object noExecuteCell ->
				Map<String, Object> coordinate = scope as CaseInsensitiveMap ?: new CaseInsensitiveMap()
				coordinate.putAll(targetCube.getCoordinateFromIds(ids))
				VisualizerCellInfo visCellInfo = new VisualizerCellInfo(String.valueOf(targetId), coordinate)
				try
				{
					visCellInfo.cell = targetCube.getCell(coordinate)
				}
				catch (Exception e)
				{
					visCellInfo.exception = e
				}
				visCellInfo.noExecuteCell = noExecuteCell
				cellInfo << visCellInfo
			}
			cellInfo.sort { VisualizerCellInfo cellInfo ->
				cellInfo.coordinate.toString()
			}
		}
		return true
	}

	Set<String> getRequiredScope()
	{
		return targetCube.getRequiredScope(scope, [:] as Map)
	}

	String getDetails(VisualizerInfo visInfo)
	{
		StringBuilder sb = new StringBuilder()
		String targetCubeName = targetCube.name

		getDetailsMap(sb, 'Scope', targetScope)
		getDetailsMap(sb, 'Available scope', scope)
		getDetailsSet(sb, 'Required scope keys', visInfo.requiredScopeKeys[targetCubeName])
		getDetailsSet(sb, 'Optional scope keys', visInfo.optionalScopeKeys[targetCubeName])<commit_msg>Change HashMap to CaseInsensitiveMap<commit_after>package com.cedarsoftware.util

import com.cedarsoftware.ncube.ApplicationID
import com.cedarsoftware.ncube.NCube
import com.cedarsoftware.ncube.NCubeManager
import com.cedarsoftware.ncube.util.LongHashSet
import groovy.transform.CompileStatic

import static com.cedarsoftware.util.VisualizerConstants.*

/**
 * Provides information to visualize a source cube, a target cube
 * and their relationship.
 */

@CompileStatic
class VisualizerRelInfo
{
	ApplicationID appId

	Set<String> notes = []
	Map<String, Object> scope

	long targetId
	NCube targetCube
	Map<String, Object> targetScope
	long targetLevel
	String nodeLabelPrefix = ''

	long sourceId
	NCube sourceCube
	Map<String, Object> sourceScope
	String sourceFieldName

	boolean cellValuesLoaded
	boolean showCellValuesLink
	boolean showCellValues

	List<VisualizerCellInfo> cellInfo

	List<String> typesToAdd

	protected VisualizerHelper helper = new VisualizerHelper()

	VisualizerRelInfo() {}

	VisualizerRelInfo(ApplicationID applicationId, Map node)
	{
		appId  = applicationId
		targetCube = NCubeManager.getCube(appId, node.cubeName as String)
		String sourceCubeName = node.sourceCubeName as String
		sourceCube = sourceCubeName ? NCubeManager.getCube(appId, sourceCubeName) : null
		sourceFieldName = node.fromFieldName
		targetId = Long.valueOf(node.id as String)
		targetLevel = Long.valueOf(node.level as String)
		targetScope = node.scope as CaseInsensitiveMap
		scope = node.availableScope as CaseInsensitiveMap
		showCellValuesLink = node.showCellValuesLink as boolean
		showCellValues = node.showCellValues as boolean
		cellValuesLoaded = node.cellValuesLoaded as boolean
		typesToAdd = node.typesToAdd as List
	}

	boolean loadCellValues(VisualizerInfo visInfo)
	{
		cellInfo = []
		cellValuesLoaded = true
		if (showCellValues)
		{
			Map<LongHashSet, Object> cellMap = targetCube.cellMap
			cellMap.each { LongHashSet ids, Object noExecuteCell ->
				Map<String, Object> coordinate = scope as CaseInsensitiveMap ?: new CaseInsensitiveMap()
				coordinate.putAll(targetCube.getCoordinateFromIds(ids))
				VisualizerCellInfo visCellInfo = new VisualizerCellInfo(String.valueOf(targetId), coordinate)
				try
				{
					visCellInfo.cell = targetCube.getCell(coordinate)
				}
				catch (Exception e)
				{
					visCellInfo.exception = e
				}
				visCellInfo.noExecuteCell = noExecuteCell
				cellInfo << visCellInfo
			}
			cellInfo.sort { VisualizerCellInfo cellInfo ->
				cellInfo.coordinate.toString()
			}
		}
		return true
	}

	Set<String> getRequiredScope()
	{
		return targetCube.getRequiredScope(scope, new CaseInsensitiveMap())
	}

	String getDetails(VisualizerInfo visInfo)
	{
		StringBuilder sb = new StringBuilder()
		String targetCubeName = targetCube.name

		getDetailsMap(sb, 'Scope', targetScope)
		getDetailsMap(sb, 'Available scope', scope)
		getDetailsSet(sb, 'Required scope keys', visInfo.requiredScopeKeys[targetCubeName])
		getDetailsSet(sb, 'Optional scope keys', visInfo.optionalScopeKeys[targetCubeName])
{'fraction_non_alphanumeric': 0.07558043800428124, 'fraction_numerical': 0.0, 'mean_word_length': 5.031777557100298, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5106569', 'n_tokens_mistral': 2029, 'n_tokens_neox': 1815, 'n_words': 424}