package gw.plugin.lookup uses gw.api.productmodel.SystemTableLookup uses gw.entity.IColumnPropertyInfo uses gw.entity.IEntityPropertyInfo uses gw.entity.IEntityType uses gw.entity.ITypekeyPropertyInfo uses gw.lang.reflect.TypeSystem uses gw.lookup.LookupColumnDTO uses gw.lookup.LookupDefinitionDTO uses java.math.BigDecimal @Export class SystemTableSourceLookupMethods implements SourceLookupMethods { override property get AvailableLookupSourceNames(): List { return SystemTableLookup.SystemTableEntityNames() } override function getLookupSourceColumns(lookupDefDTO: LookupSourceDefinitionDTO): List { if(not lookupDefDTO.EntityBackedLookupTable) { throw new IllegalStateException("SystemTableLookupCreationPlugin should only be used for entity backed lookups.") } var entityType = TypeSystem.getByRelativeName(lookupDefDTO.SourceTable) as IEntityType var allProperties = entityType.EntityProperties.toList() .where(\ep -> (ep typeis IColumnPropertyInfo or ep typeis ITypekeyPropertyInfo) and ep.ColumnInDb and not ep.Autogenerated) var columns = allProperties.map(\propertyInfo -> { var column = new LookupColumnDTO() column.ColumnName = propertyInfo.Name column.ColumnLabel = propertyInfo.DisplayName column.DataType = propertyInfo.Type column.Input = true return column }) return columns } }