com.cedarsoftware.visualizer.RpmVisualizerRelInfo.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of n-cube Show documentation
Show all versions of n-cube Show documentation
Multi-dimensional Rule Engine
package com.cedarsoftware.visualizer
import com.cedarsoftware.ncube.ApplicationID
import com.cedarsoftware.ncube.NCube
import com.cedarsoftware.ncube.NCubeRuntimeClient
import com.cedarsoftware.ncube.RuleInfo
import com.cedarsoftware.ncube.exception.CoordinateNotFoundException
import com.cedarsoftware.ncube.exception.InvalidCoordinateException
import com.cedarsoftware.util.CaseInsensitiveSet
import com.cedarsoftware.util.CompactCILinkedMap
import com.cedarsoftware.util.SafeSimpleDateFormat
import com.google.common.base.Splitter
import groovy.transform.CompileStatic
import static com.cedarsoftware.util.ExceptionUtilities.getDeepestException
/**
* Provides information to visualize a source rpm class, a target rpm class
* and their relationship.
*/
@CompileStatic
class RpmVisualizerRelInfo extends VisualizerRelInfo implements RpmVisualizerConstants
{
protected RpmVisualizerHelper helper = new RpmVisualizerHelper(runtimeClient, appId)
protected String sourceFieldRpmType
protected Map> sourceTraits
protected Map> targetTraits
static final SafeSimpleDateFormat DATE_TIME_FORMAT = new SafeSimpleDateFormat('yyyy-MM-dd')
protected RpmVisualizerRelInfo(){}
protected RpmVisualizerRelInfo(NCubeRuntimeClient runtimeClient, ApplicationID appId)
{
super(runtimeClient, appId)
}
@Override
protected Set getRequiredScope()
{
Set requiredScope = super.requiredScope
requiredScope.remove(AXIS_FIELD)
requiredScope.remove(AXIS_NAME)
requiredScope.remove(AXIS_TRAIT)
return requiredScope
}
@Override
protected initSelectedNode(VisualizerInfo visInfo, Map selectedNode)
{
super.initSelectedNode(visInfo, selectedNode)
targetScope = new CompactCILinkedMap()
sourceTraits = selectedNode.sourceTraits as Map
sourceFieldRpmType = selectedNode.sourceFieldRpmType as String
}
@Override
protected String getDetails(VisualizerInfo visInfo)
{
StringBuilder sb = new StringBuilder()
//Scope messages
sb.append(createNodeDetailsScopeMessage(visInfo))
//Scope
if (cubeLoaded)
{
String heading
String title
if (showCellValues)
{
heading = 'Utilized scope with traits'
title = 'The scope keys used to load the class with all available traits. A sub-set of available scope.'
}
else
{
heading = 'Utilized scope with no traits'
title = 'The scope keys used to load the class with the minimal set of traits needed for visualization. A sub-set of available scope.'
}
getDetailsMap(sb, heading, targetScope.sort(), title)
}
//Fields
if (cubeLoaded)
{
if (showCellValues)
{
addClassTraits(sb)
}
addFieldDetails(sb)
}
return sb.toString()
}
private void addFieldDetails(StringBuilder sb)
{
if (showCellValues)
{
sb.append("Fields and traits")
}
else
{
sb.append("Fields")
}
sb.append("")
targetTraits.each { String fieldName, v ->
if (CLASS_TRAITS != fieldName)
{
if (showCellValues)
{
sb.append("- ${fieldName}
")
addTraits(sb, fieldName)
}
else
{
sb.append("- ${fieldName}
")
}
}
}
sb.append("
")
}
private void addTraits(StringBuilder sb, String fieldName)
{
Map- ")
traits.each { String traitName, Object traitValue ->
if (traitValue != null)
{
String traitString = traitValue.toString()
if (traitString.startsWith(HTTP) || traitString.startsWith(HTTPS) || traitString.startsWith(FILE))
{
sb.append("""
- ${traitName}: ${traitString} """) } else { sb.append("
- ${traitName}: ${traitValue} ") } } } sb.append("
© 2015 - 2024 Weber Informatics LLC | Privacy Policy