001 package org.hackystat.telemetry.analyzer.configuration; 002 003 import org.hackystat.telemetry.analyzer.language.TelemetryLanguageException; 004 import org.hackystat.telemetry.analyzer.language.ast.TelemetryChartDefinition; 005 import org.hackystat.telemetry.analyzer.language.parser.TelemetryLanguageParser; 006 import org.hackystat.sensorbase.resource.users.jaxb.User; 007 008 /** 009 * Provides information about a telemetry chart, including its name, type, and definition. 010 * 011 * @author (Cedric) Qin Zhang 012 */ 013 public class TelemetryChartDefinitionInfo extends TelemetryDefinitionInfo { 014 015 private TelemetryChartDefinition chartDefinition; 016 017 /** 018 * Constructs this instance. 019 * <p> 020 * Note that although this constructor checks for syntactic validity, 021 * it does not check for semantic validity. 022 * 023 * @param fullDefinitionString The definition string. 024 * @param owner The owner of this definition. 025 * @param shareScope The share scope of this definition. 026 * 027 * @throws TelemetryConfigurationException If the definition string cannot be parsed. 028 */ 029 public TelemetryChartDefinitionInfo(String fullDefinitionString, User owner, 030 ShareScope shareScope) throws TelemetryConfigurationException { 031 super(fullDefinitionString, owner, shareScope); 032 try { 033 this.chartDefinition = TelemetryLanguageParser.parseChartDef(fullDefinitionString); 034 } 035 catch (TelemetryLanguageException ex) { 036 throw new TelemetryConfigurationException(ex); 037 } 038 } 039 040 /** 041 * Constructs this instance. 042 * 043 * @param chartDefinition The telemetry chart definition object. 044 * @param owner The owner of this definition. 045 * @param shareScope The share scope of this definition. 046 * 047 * @throws TelemetryConfigurationException If the definition string cannot be parsed. 048 */ 049 public TelemetryChartDefinitionInfo(TelemetryChartDefinition chartDefinition, User owner, 050 ShareScope shareScope) throws TelemetryConfigurationException { 051 super(chartDefinition.getDefinitionString(), owner, shareScope); 052 this.chartDefinition = chartDefinition; 053 } 054 055 /** 056 * Gets the name of this telemetry definition. 057 * 058 * @return The name. 059 */ 060 @Override 061 public String getName() { 062 return this.getChartDefinitionObject().getName(); 063 } 064 065 /** 066 * Gets telemetry definition type. 067 * 068 * @return Telemetry definition type. 069 */ 070 @Override 071 public TelemetryDefinitionType getType() { 072 return TelemetryDefinitionType.CHART; 073 } 074 075 /** 076 * Gets the abstract syntax tree representation of this telemetry chart. 077 * 078 * @return The abstract syntax tree representation. 079 */ 080 public TelemetryChartDefinition getChartDefinitionObject() { 081 return this.chartDefinition; 082 } 083 }