001 package org.hackystat.telemetry.analyzer.configuration; 002 003 import org.hackystat.telemetry.analyzer.language.TelemetryLanguageException; 004 import org.hackystat.telemetry.analyzer.language.ast.TelemetryReportDefinition; 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 Report, including its name, its type (Report), and 010 * the definition. 011 * 012 * @author (Cedric) Qin Zhang 013 */ 014 public class TelemetryReportDefinitionInfo extends TelemetryDefinitionInfo { 015 016 private TelemetryReportDefinition reportDefinition; 017 018 /** 019 * Constructs this instance. 020 * 021 * @param fullDefinitionString The defintion string. 022 * @param owner The owner of this definition. 023 * @param shareScope The share scope of this definition. 024 * 025 * @throws TelemetryConfigurationException If the definition string cannot be parsed. 026 */ 027 public TelemetryReportDefinitionInfo(String fullDefinitionString, User owner, 028 ShareScope shareScope) throws TelemetryConfigurationException { 029 super(fullDefinitionString, owner, shareScope); 030 try { 031 this.reportDefinition = TelemetryLanguageParser.parseReportDef(fullDefinitionString); 032 } 033 catch (TelemetryLanguageException ex) { 034 throw new TelemetryConfigurationException(ex); 035 } 036 //TODO: though the definition is syntatically correct, need to perform semantic validation! 037 } 038 039 /** 040 * Constructs this instance. 041 * 042 * @param reportDefinition The telemetry report definition object. 043 * @param owner The owner of this definition. 044 * @param shareScope The share scope of this definition. 045 * 046 * @throws TelemetryConfigurationException If the definition string cannot be parsed. 047 */ 048 public TelemetryReportDefinitionInfo(TelemetryReportDefinition reportDefinition, User owner, 049 ShareScope shareScope) throws TelemetryConfigurationException { 050 super(reportDefinition.getDefinitionString(), owner, shareScope); 051 this.reportDefinition = reportDefinition; 052 } 053 054 /** 055 * Gets the name of this telemetry definition. 056 * 057 * @return The name. 058 */ 059 @Override 060 public String getName() { 061 return this.getReportDefinitionObject().getName(); 062 } 063 064 /** 065 * Gets telemetry definition type. 066 * 067 * @return Telemetry definition type. 068 */ 069 @Override 070 public TelemetryDefinitionType getType() { 071 return TelemetryDefinitionType.REPORT; 072 } 073 074 /** 075 * Gets the abstract syntax tree representation of this telemetry report. 076 * 077 * @return The abstract syntax tree representation. 078 */ 079 public TelemetryReportDefinition getReportDefinitionObject() { 080 return this.reportDefinition; 081 } 082 }