# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# CreateOrReplaceIndexes.py
# Created on: 2013-09-16 13:19:01.00000
#   (generated by ArcGIS/ModelBuilder)
# Description:
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy
import UniqueValToDomain

# Local variables:
##targetTable = "D:\\GIS_Data\\Mexico.gdb\\MexicoNationalNetwork_BeforeSmooth"
##fieldNames = ['SourceBeforeTable_car_star_rating_smoothed', 'SourceBeforeTable_car_star_rating_smoothed_star']
##unique = False
##ascending = False
Workspace = arcpy.GetParameterAsText(0)
targetTable = arcpy.GetParameterAsText(1)
fieldNames = arcpy.GetParameterAsText(2).split(';')

arcpy.AddMessage('Field names ' + str(fieldNames))

# Process: Remove Attribute Index
for fieldName in fieldNames:
    domainName = fieldName + "_domain"
    arcpy.AddMessage('Adding domain {0} to field {1}'.format(domainName, fieldName))
    UniqueValToDomain.UniqueValueToDomain(Workspace, targetTable, fieldName, domainName)
    arcpy.AddMessage('Added domain {0} to field {1}'.format(domainName, fieldName))

arcpy.AddMessage('All done. Have a nice day!')
arcpy.SetParameterAsText(3, targetTable)

