package gw.exportimport uses java.lang.IllegalArgumentException uses java.util.HashMap uses java.util.Map uses java.util.Set uses java.util.List /** * Contains all data necessary for exporting entities to a particular format. * *
  • an EntityInfo - For column headers
  • *
  • a list of KeyableBeans - Contains all entities to be exported
  • *
  • any additional data to be included in the export
  • */ @ReadOnly class ExportData { var _entityInfo : EntityInfo var _entityRows : List as readonly Rows = {} var _additionalInfo : Map> var _language : LanguageType as Language //hash map of variables to store in excel file var _spreadsheetVariables : Map as SpreadSheetVariables = {} var _fileNameVariables : Map as FileNameVariables = {} internal construct(beans : List) { this(EntityInfo.Registry.findEntityInfo(T), beans) } internal construct(registry : EntityInfoRegistry, beans : List) { this(registry.findEntityInfo(T), beans) } construct(info : EntityInfo, beans : List) { if ( info == null ) { throw new IllegalArgumentException("Export meta-data for entity of type " + T + " is required.") } _language = ExportLocaleUtil.DefaultUserLanguage _entityInfo = info _entityRows = beans } construct(info : EntityInfo, beans : List, additionalInfo : Map>) { this(info, beans) _additionalInfo = additionalInfo } internal property get EntityInfo() : EntityInfo { return _entityInfo } /** * The type of this entity. */ property get EntityType() : Type { return T } /** * Add additional data for export registered with the specified key. * * @param key The key for the additional data. * @param data A list of beans that are the additional data. */ function addAdditionalData(key : String, data : List) { if ( _additionalInfo == null ) { // lazy init'... this._additionalInfo = new HashMap>() } this._additionalInfo.put(key, data) } /** * Return whether any additional data has been specified. */ property get HasAdditionalData() : boolean { return ( _additionalInfo != null ) and !_additionalInfo.Empty } /** * Return a set of keys for the any additional data. */ property get AdditionalDataKeys() : Set { return HasAdditionalData ? _additionalInfo.Keys : null } /** * Return a list of ColumnInfo's for the EntityInfo. * * @param template Whether the ColumnInfo's are for a template or for data. */ function getEntityColumnInfos(template : boolean) : List { var columnInfos = this.EntityInfo.Columns if ( template ) { columnInfos = columnInfos.subtract(this.EntityInfo.ExcludedFromTemplateColumns).toList() } return columnInfos } /** * Return a list of the additional data beans as specified by the key. */ function getAdditionalData(key : String) : List { return HasAdditionalData ? _additionalInfo[key] : null } /** * Return a list of ColumnInfo's for the additional data * as specified by the key. * * These will be locked copies. */ function getAdditionalDataColumnInfos(key : String) : List { if ( !HasAdditionalData or !_additionalInfo.containsKey(key) ) { throw new IllegalArgumentException( "ExportData(Unknown Additional Data Key): " + key) } return this.EntityInfo.getColumnInfoCopiesLockedFor(key) } }