# AIKIF_project.py      written by Duncan Murray 1st-Mar-2015

import os
import aikif.project as mod_prj
import aikif.dataTools.cls_datatable as mod_dt

def main():
    """
    This is an example of project documentation using AIKIF
    It documents the project itself, including requirements, 
    design, test, goals, 
    
    """
    print('Initialising AIKIF Project...')
    name = 'AIKIF'
    type = 'Software'
    desc = """
     Artificial Intelligence Knowledge Information Framework - Project Overview
       
     This document was autogenerated via aikif/examples/AIKIF_project.py  
"""
    desc += '\n     Last updated ' + mod_dt.TodayAsString()	

        
    fldr = os.getcwd() # 'T:\\user\\dev\\src\\python\\AIKIF\\aikif\\examples\\AIKIF_project'
    report_file_base = fldr + os.sep + 'aikif_report'
    p = mod_prj.Project(name, type, desc, fldr)
    project_setup(p)


    requirements = mod_dt.DataTable('requirements.csv', ',', col_names=['id', 'dep_id', 'name', 'details'])
    p.log_table(requirements)
    p.record(requirements, '', ['a', '', 'process data', 'automatically process source files to tables based on rules'])
    p.record(requirements, '', ['b', '', 'define structures', 'use mappings and ontology to specify what to do'])
    p.record(requirements, '', ['c', '', 'log intent', 'log key events'])
    p.record(requirements, '', ['d', '', 'methods toolbox', 'implement a set of programs that can be used generically'])
    p.record(requirements, '', ['e', '', 'Command Line Interface', 'CLI to query and update datasets and control processes'])
    p.record(requirements, '', ['a01', 'a', 'download CSV', 'download CSV file from website'])
    p.record(requirements, '', ['a02', 'a', 'load CSV to table', 'import CSV file to Database table'])
    p.record(requirements, '', ['a03', 'a', 'find blank rows in CSV', 'read CSV file and count DQ issues'])
    p.record(requirements, '', ['a04', 'a', 'aggregate table', 'summarise Database table by col(n)'])
    p.record(requirements, '', ['e01', 'e', 'CLI commands', 'CLI to manage commands and modes of operation'])
    p.record(requirements, '', ['e02', 'e', 'CLI query', 'query functions of datasets in AIKIF using basic fixed commands'])
    p.record(requirements, '', ['e03', 'e', 'CLI NLP', 'integrate NLP to allow english questions and data addition in add/query mode'])
    p.record(requirements, '', ['e04', 'e', 'CLI add', 'allows user to add data to general or specific datasets'])
    p.record(requirements, '', ['e05', 'e', 'CLI process', 'allows managing of all processes in AIKIF'])

    progress = mod_dt.DataTable('progress.csv', ',', col_names=['program', 'percent', 'details'])
    p.log_table(progress)
    p.record(progress, '', ['knowledge', '1%',  'class to manage raw data to information'])
    p.record(progress, '', ['mapper', '20%', 'mapping columns to data structures, with business rules'])
    p.record(progress, '', ['sql_code_generator', '90%', 'generates SQL to transform data external to AIKIF'])
    
    issues = mod_dt.DataTable('issues.csv', ',', col_names=['id', 'name', 'details'])
    p.log_table(issues)
    p.record(issues, '', ['01', 'In Progress', 'implement AIKIF project logging'])
    p.record(issues, '', ['02', 'todo', 'implement Knowledge mapping'])
    p.record(issues, '', ['03', 'Testing', 'data mapping of columns'])
    
    
  #  p.build_report(report_file_base + '.md', type='md')
    p.build_report(report_file_base + '.rst', type='rst')
    print('Done...')


def project_setup(p):
    """
    Define the project and add details
    """
    p.add_detail('website', 'http://www.acutesoftware.com.au')
    p.add_detail('email', 'djmurray@acutesoftware.com.au')

 
 
"""
Utility Functions (may be moved to project)
"""
    
    
def read_table():
    """
    
    """
    pass

if __name__ == '__main__': 
    main()