import * as vscode from 'vscode' ; import { ALReportWizardData } from "../wizards/alReportWizardData" ; import { ALSyntaxWriter } from "../../allanguage/alSyntaxWriter" ; import { ALSyntaxHelper } from '../../allanguage/alSyntaxHelper' ; export class ALReportSyntaxBuilder { constructor ( ) { } buildFromReportWizardData ( destUri , data ) { let settings = vscode . workspace . getConfiguration ( 'alOutline' , destUri ) ; let addDataItemName = settings . get < boolean > ( 'addDataItemToReportColumnName' ) ; let writer = new ALSyntaxWriter ( destUri ) ; writer . writeStartObject ( "report" , data . objectId , data . objectName ) ; writer . addProperty ( "Caption" , writer . encodeString ( ALSyntaxHelper . removePrefixSuffix ( data . objectName , data . projectSettings ) ) ) ; if ( data . rdlcLayout != "" ) writer . addProperty ( "RDLCLayout" , writer . encodeString ( data . rdlcLayout ) ) ; if ( data . wordLayout != "" ) writer . addProperty ( "WordLayout" , writer . encodeString ( data . wordLayout ) ) ; if ( ( data . usageCategory ) && ( data . usageCategory !== "" ) && ( data . usageCategory !== "None" ) ) { if ( ( data . applicationArea ) && ( data . applicationArea !== "" ) ) writer . addProperty ( "ApplicationArea" , data . applicationArea ) ; writer . addProperty ( "UsageCategory" , data . usageCategory ) ; } writer . writeProperties ( ) ; this . writeDataSet ( writer , data , addDataItemName ) ; if ( data . createRequestPage ) this . writeRequestPage ( writer ) ; writer . writeEndObject ( ) ; return writer . toWizardGeneratedString ( ) ; } private writeDataSet ( writer , data , addDataItemName ) { let dataSetName = writer . createName ( data . selectedTable ) ; writer . writeStartNamedBlock ( "dataset" ) ; writer . writeStartNameSourceBlock ( "dataitem" , dataSetName , writer . encodeName ( data . selectedTable ) ) ; if ( data . selectedFieldList ) { for ( let i = 0 ; i < data . selectedFieldList . length ; i ++ ) { let columnName = writer . createName ( data . selectedFieldList [ i ] . name ! ) ; if ( addDataItemName ) columnName = columnName + "_" + dataSetName ; writer . writeNameSourceBlock ( "column" , columnName , writer . encodeName ( data . selectedFieldList [ i ] . name ! ) ) ; } } writer . writeEndBlock ( ) ; writer . writeEndBlock ( ) ; } private writeRequestPage ( writer ) { writer . writeStartNamedBlock ( "requestpage" ) ; writer . writeStartLayout ( ) ; writer . writeStartGroup ( "area" , "content" ) ; writer . writeStartGroup ( "group" , "GroupName" ) ; writer . writeEndBlock ( ) ; writer . writeEndBlock ( ) ; writer . writeEndLayout ( ) ; writer . writeStartNamedBlock ( "actions" ) ; writer . writeStartGroup ( "area" , "processing" ) ; writer . writeEndBlock ( ) ; writer . writeEndBlock ( ) ; writer . writeEndBlock ( ) ; } }