public String generateSelectSql ( String namespace , Requirement minimumRequirement ) { String fieldsString ; String tableName = String . join ( "." , namespace , name ) ; String fieldPrefix = tableName + "." ; if ( minimumRequirement . equals ( EDITOR ) ) { fieldsString = commaSeparatedNames ( editorFields ( ) , fieldPrefix , true ) ; } else if ( minimumRequirement . equals ( OPTIONAL ) ) { fieldsString = commaSeparatedNames ( specFields ( ) , fieldPrefix , true ) ; } else if ( minimumRequirement . equals ( REQUIRED ) ) { fieldsString = commaSeparatedNames ( requiredFields ( ) , fieldPrefix , true ) ; } else fieldsString = "*" ; return String . format ( "select %s from %s" , fieldsString , tableName ) ; }
Generate select all SQL string . The minimum requirement parameter is used to determine which fields ought to be included in the select statement . For example if OPTIONAL is passed in both optional and required fields are included in the select . If EDITOR is the minimum requirement editor optional and required fields will all be included .