#####################################################################
#####################################################################
## Copyright 2005 Steven R. Newcomb                                ##
##                                                                 ##
## This software is licensed under the Apache License, Version 2.0 ##
## (the "License"); you may not use this file except in compliance ##
## with the License.  Copies of the License are available at       ##
##        http://www.apache.org/licenses/LICENSE-2.0               ##
##                                                                 ##
## Unless required by applicable law or agreed to in writing,      ##
## software distributed under the License is distributed on an "AS ##
## IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either ##
## express or implied.  See the License for the specific language  ##
## governing permissions and limitations under the License.        ##
##                                                                 ##
## Copies of the source code and the license are available at      ##
##        http://www.versavant.org                                 ##
#####################################################################
#####################################################################

####################################
cvsRevision = "$Revision: 1.6 $" ##
####################################

import versavant, sys

tmName = "Jacks Topic Map"
tmDesc = "Reifies everything in sight about Joe."

#######################################################
def main():
    vsv = versavant.Versavant( suppressLicenseMessage=True)
    vsv.newTopicMap( tmName, tmDesc)

        ## Remember: the TMA load order will be the order in which
        ## merging and conferral operations will be done.  The 'Roles'
        ## TMA must be loaded before the 'A_assert' TMA, because A_assert's conferral rule
        ## can't reify r-proxies whose SIPs don't already exist.
    vsv.loadTMA( tmName, 'Roles',      '${VSVEXECDIR}/Lib/ROLENAME/tmaconf.xml')
    vsv.loadTMA( tmName, 'BigAssert',  '${VSVEXECDIR}/Lib/BIGASSERT/tmaconf.xml')
    vsv.loadTMA( tmName, 'TRA_assert', '${VSVEXECDIR}/Lib/TRA_assert/tmaconf.xml')
    vsv.loadTMA( tmName, 'A_assert',   '${VSVEXECDIR}/Lib/A_assert/tmaconf.xml')
    vsv.loadTMA( tmName, 'U_assert',   '${VSVEXECDIR}/Lib/U_assert/tmaconf.xml')
    vsv.loadTMA( tmName, 'JacksTMA',   'JacksTMA/tmaconf.xml')

    OPT = vsv.registerOriginalPopulationTask( tmName, 'opt.py',
	    'OPTJoeStuff', 'OPTJoeStuff', 'just fooling around')

    vsv.populate( OPT)

    OPT = vsv.registerOriginalPopulationTask( tmName, 'opt.py',
	    'OPTHarryStuff', 'OPTHarryStuff', 'just fooling around')

    vsv.populate( OPT)

    OPT = vsv.registerOriginalPopulationTask( tmName, 'opt.py',
	    'OPTBartholomewStuff', 'OPTBartholomewStuff', 'just fooling around')

    vsv.populate( OPT)

    OPT = vsv.registerOriginalPopulationTask( tmName, 'opt.py',
	    'OPTUrsulaStuff', 'OPTUrsulaStuff', 'just fooling around')

    vsv.populate( OPT)

    print "\nBEFORE MERGING:"

    print vsv.showLiveNonSystemProxies( tmName)

    vsv.merge( tmName)

    print "\nAFTER MERGING:"
    print vsv.showLiveNonSystemProxies( tmName)

    exportXMLFileName = '%s.xml' % ( tmName)
    vsv.exportXMLTopicMap( tmName, exportXMLFileName)

    newTMName = '%s Reloaded' % ( tmName)
    vsv.newTopicMap( newTMName, tmDesc)
    vsv.importXMLTopicMap( newTMName, exportXMLFileName, 'reloading %s' % ( tmName))

    vsv.inspect( showProxies='liveNonSystem', topicMapName = tmName, showThumbnails=True, showSamples=True)

#######################################################
if __name__ == "__main__":
    ## If this script has been invoked directly, as opposed to being
    ## imported by another script...

    main()  ## ...execute function main()
    ## (This is a Python convention.)

