Subversion Repositories SmartDukaan

Rev

Rev 1362 | Rev 2657 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

def contentModel2Struct(expslide) :
    struct = {}
    
    # Set children slide structures
    if expslide.hasChildrenSlides() :
        expchildrenslides = expslide.getExpandedChildrenSlides()
        childrenstructs = {}
        for expchildslide in expchildrenslides :
            childstruct = contentModel2Struct(expchildslide) 
            
            # REVISIT - ID in place to label
            slidelabel = expchildslide.getSlideDefinition().getLabel() 
            #print "slidelabel=" + slidelabel
            childrenstructs[slidelabel] = childstruct
            
        struct['childrenslides'] = childrenstructs
    
    # Set feature structures
    if expslide.hasFeatures() :
        expfeatures = expslide.getExpandedFeatures()
        featurestructs = {}
        for expfeature in expfeatures :
            
            # REVISIT - ID in place to label
            featurelabel = expfeature.getFeatureDefinition().getLabel()
            #print "featurelabel=" + featurelabel 
            if expfeature.hasBullets() :
                bulletsstruct = []
                expbullets = expfeature.getExpandedBullets()
                for expbullet in expbullets :
                    if expbullet.isComposite() :
                        primitivedataobjects = expbullet.getDataObject().getPrimitiveDataObjects()
                        unit = expbullet.getUnit()
                        for primitivedataobject in primitivedataobjects :
                            bulletvalue = primitivedataobject.getValue()
                            print "unit is" + `unit`
                            if unit is not None:
                                print "unit is not none"
                                if unit.getShortForm() == "GB":
                                    print "GB is" + `bulletvalue`
                                    #if(bulletvalue.endswith('L')):
                                    #    bulletvalue=bulletvalue[0:len(bulletvalue)-2]
                                    #bulletvalue = bulletvalue * 1024 * 1024
                                    #print "KB is" + `bulletvalue`
                                    #convert to kb
                                if unit.getShortForm() == "MB":
                                    print "GB is" + `bulletvalue`
                                    #if(bulletvalue.endswith('L')):
                                    #    bulletvalue=bulletvalue[0:len(bulletvalue)-2]
                                    #bulletvalue = bulletvalue * 1024
                                    #print "KB is" + `bulletvalue`
                                    #convert to kb
                            
                            #print "bulletvalue=" + bulletvalue
                            bulletsstruct.append(bulletvalue)
                         
                    elif expbullet.isEnumerated() :
                        bulletvalue = expbullet.getExpandedEnumDataObject().getEnumValue().getValue()
                        #print "bulletvalue=" + bulletvalue
                        bulletsstruct.append(bulletvalue)
                    
                    else :
                        bulletvalue = expbullet.getDataObject().getValue()
                        #print "bulletvalue=" + bulletvalue
                        unit = expbullet.getUnit()
                        print "unit is" + `unit`
                        if unit is not None:
                            print "unit is not none"
                            if unit.getShortForm() == "GB":
                                print "GB is" + `bulletvalue`
                                value = float(bulletvalue)
                                #if(bulletvalue.endswith('L')):
                                 #   bulletvalue=bulletvalue[0:len(bulletvalue)-2]
                                newvalue = value * 1024 * 1024
                                print "KB is" + `newvalue`
                                bulletvalue = str(newvalue)
                                #convert to kb
                            if unit.getShortForm() == "MB":
                                print "MB is" + `bulletvalue`
                                value = float(bulletvalue)
                                #if(bulletvalue.endswith('L')):
                                    #bulletvalue=bulletvalue[0:len(bulletvalue)-2]
                                newvalue = value * 1024
                                print "KB is" + `newvalue`
                                bulletvalue = str(newvalue)
                                #convert to kb
                        bulletsstruct.append(bulletvalue)
                        
                featurestructs[featurelabel] = bulletsstruct
            else :
                # Set to empty list, this is to accomodate bullet-less features
                featurestructs[featurelabel] = []
    
        struct['features'] = featurestructs
    
    return struct