Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.cedarsoftware.visualizer
import com.cedarsoftware.ncube.ApplicationID
import com.cedarsoftware.ncube.Axis
import com.cedarsoftware.ncube.Column
import com.cedarsoftware.ncube.NCube
import com.cedarsoftware.ncube.NCubeRuntimeClient
import com.cedarsoftware.util.CaseInsensitiveSet
import com.cedarsoftware.util.CompactCILinkedMap
import groovy.transform.CompileStatic
import static com.cedarsoftware.visualizer.VisualizerConstants.*
/**
* Provides information to visualize a source cube, a target cube
* and their relationship.
*/
@CompileStatic
class VisualizerRelInfo
{
protected static NCubeRuntimeClient runtimeClient
protected ApplicationID appId
protected List nodeDetailsMessages = []
protected Map availableTargetScope = new CompactCILinkedMap()
protected Map> availableScopeValues = new CompactCILinkedMap()
protected Map> scopeCubeNames = new CompactCILinkedMap()
protected boolean showingHidingCellValues
protected long targetId
protected NCube targetCube
protected Map targetScope = new CompactCILinkedMap()
protected long targetLevel
protected String nodeLabelPrefix = ''
protected long sourceId
protected NCube sourceCube
protected Map sourceScope
protected String sourceFieldName
protected List sourceTrail = []
protected boolean cubeLoaded
protected boolean showCellValuesLink
protected boolean showCellValues
protected boolean loadAgain
protected List cellInfo
protected List typesToAdd
VisualizerRelInfo() {}
VisualizerRelInfo(NCubeRuntimeClient runtimeClient, ApplicationID applicationId)
{
this.runtimeClient = runtimeClient
this.appId = applicationId
}
protected init(Map options, VisualizerInfo visInfo)
{
targetId = 1
targetLevel = 1
targetCube = runtimeClient.getCube(appId, options.startCubeName as String)
addRequiredScopeKeys(visInfo)
showCellValuesLink = true
populateScopeDefaults(visInfo)
}
protected initSelectedNode(VisualizerInfo visInfo, Map selectedNode)
{
targetCube = runtimeClient.getCube(appId, selectedNode.cubeName as String)
String sourceCubeName = selectedNode.sourceCubeName as String
sourceCube = sourceCubeName ? runtimeClient.getCube(appId, sourceCubeName) : null
sourceFieldName = selectedNode.fromFieldName as String
sourceScope = selectedNode.sourceScope as CompactCILinkedMap
sourceTrail = selectedNode.sourceTrail as List
sourceId = selectedNode.sourceId as Long
targetId = Long.valueOf(selectedNode.id as String)
targetLevel = Long.valueOf(selectedNode.level as String)
showCellValues = selectedNode.showCellValues as boolean
showCellValuesLink = selectedNode.showCellValuesLink as boolean
cubeLoaded = selectedNode.cubeLoaded as boolean
typesToAdd = selectedNode.typesToAdd as List
visInfo.inputScope = new CompactCILinkedMap(selectedNode.availableScope as Map)
targetScope = selectedNode.scope as CompactCILinkedMap ?: new CompactCILinkedMap()
availableTargetScope = selectedNode.availableScope as CompactCILinkedMap ?: new CompactCILinkedMap()
availableScopeValues = selectedNode.availableScopeValues as CompactCILinkedMap ?: new CompactCILinkedMap()
showingHidingCellValues = selectedNode.showingHidingCellValues as boolean
//If in the process of showing/hiding cell values, then the supplied scope, available scope values and scope
//cube names are used to load cell values.
if (showingHidingCellValues)
{
scopeCubeNames = selectedNode.scopeCubeNames as CompactCILinkedMap ?: new CompactCILinkedMap()
}
//Else, node details are being loaded for the node or a scope change is being applied to the node. In this case,
//clear out any available target scope that is derived scope. This will result in the node being
//reloaded with updated available scope values for the removed scope.
else
{
Set scopeKeys = (Set)new CaseInsensitiveSet(availableTargetScope.keySet())
scopeKeys.each {String scopeKey ->
if (!isDerivedScopeKey(visInfo, scopeKey))
{
availableTargetScope.remove(scopeKey)
}
}
availableScopeValues = new CompactCILinkedMap()
scopeCubeNames = new CompactCILinkedMap()
}
populateScopeDefaults(visInfo)
}
protected boolean loadCube(VisualizerInfo visInfo)
{
cellInfo = []
cubeLoaded = true
if (showCellValues)
{
Map, Object> cellMap = (Map, Object>) targetCube.cellMap
cellMap.each { Set ids, Object noExecuteCell ->
Map coordinate = availableTargetScope as CompactCILinkedMap ?: new CompactCILinkedMap()
coordinate.putAll(targetCube.getCoordinateFromIds(ids))
VisualizerCellInfo visCellInfo = new VisualizerCellInfo(runtimeClient, appId, 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
}
protected Set getRequiredScope()
{
return targetCube.getRequiredScope(availableTargetScope, new CompactCILinkedMap())
}
protected String getDetails(VisualizerInfo visInfo)
{
StringBuilder sb = new StringBuilder()
getDetailsMap(sb, 'Scope', targetScope.sort(), 'The scope keys used to load the cube. A sub-set of available scope.')
getDetailsMap(sb, 'Available scope', availableTargetScope.sort(), 'The scope keys available as the cube was loaded in the visualization.')
getDetailsSet(sb, 'Axes', targetCube.axisNames)
//Cell values
if (cubeLoaded && showCellValues)
{
addCellValueSection(visInfo, sb)
}
return sb.toString()
}
private void addCellValueSection(VisualizerInfo visInfo, StringBuilder sb)
{
StringBuilder cellValuesBuilder = new StringBuilder()
StringBuilder linkBuilder = new StringBuilder()
sb.append("Cell values")
getCellValues(visInfo, cellValuesBuilder, linkBuilder )
sb.append(linkBuilder.toString())
sb.append("""