Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
73 naveen 1
def contentModel2Struct(expslide) :
2
    struct = {}
69 naveen 3
 
73 naveen 4
    # Set children slide structures
5
    if expslide.hasChildrenSlides() :
6
        expchildrenslides = expslide.getExpandedChildrenSlides()
7
        childrenstructs = {}
8
        for expchildslide in expchildrenslides :
9
            childstruct = contentModel2Struct(expchildslide) 
10
 
11
            # REVISIT - ID in place to label
12
            slidelabel = expchildslide.getSlideDefinition().getLabel() 
1362 rajveer 13
            #print "slidelabel=" + slidelabel
73 naveen 14
            childrenstructs[slidelabel] = childstruct
15
 
16
        struct['childrenslides'] = childrenstructs
17
 
18
    # Set feature structures
19
    if expslide.hasFeatures() :
20
        expfeatures = expslide.getExpandedFeatures()
21
        featurestructs = {}
22
        for expfeature in expfeatures :
23
 
24
            # REVISIT - ID in place to label
25
            featurelabel = expfeature.getFeatureDefinition().getLabel()
1362 rajveer 26
            #print "featurelabel=" + featurelabel 
73 naveen 27
            if expfeature.hasBullets() :
28
                bulletsstruct = []
29
                expbullets = expfeature.getExpandedBullets()
30
                for expbullet in expbullets :
31
                    if expbullet.isComposite() :
32
                        primitivedataobjects = expbullet.getDataObject().getPrimitiveDataObjects()
1936 rajveer 33
                        unit = expbullet.getUnit()
73 naveen 34
                        for primitivedataobject in primitivedataobjects :
35
                            bulletvalue = primitivedataobject.getValue()
1936 rajveer 36
                            print "unit is" + `unit`
37
                            if unit is not None:
38
                                print "unit is not none"
39
                                if unit.getShortForm() == "GB":
40
                                    print "GB is" + `bulletvalue`
41
                                    #if(bulletvalue.endswith('L')):
42
                                    #    bulletvalue=bulletvalue[0:len(bulletvalue)-2]
43
                                    #bulletvalue = bulletvalue * 1024 * 1024
44
                                    #print "KB is" + `bulletvalue`
45
                                    #convert to kb
46
                                if unit.getShortForm() == "MB":
47
                                    print "GB is" + `bulletvalue`
48
                                    #if(bulletvalue.endswith('L')):
49
                                    #    bulletvalue=bulletvalue[0:len(bulletvalue)-2]
50
                                    #bulletvalue = bulletvalue * 1024
51
                                    #print "KB is" + `bulletvalue`
52
                                    #convert to kb
53
 
1362 rajveer 54
                            #print "bulletvalue=" + bulletvalue
73 naveen 55
                            bulletsstruct.append(bulletvalue)
56
 
57
                    elif expbullet.isEnumerated() :
58
                        bulletvalue = expbullet.getExpandedEnumDataObject().getEnumValue().getValue()
1362 rajveer 59
                        #print "bulletvalue=" + bulletvalue
73 naveen 60
                        bulletsstruct.append(bulletvalue)
61
 
62
                    else :
63
                        bulletvalue = expbullet.getDataObject().getValue()
1362 rajveer 64
                        #print "bulletvalue=" + bulletvalue
1936 rajveer 65
                        unit = expbullet.getUnit()
66
                        print "unit is" + `unit`
67
                        if unit is not None:
68
                            print "unit is not none"
69
                            if unit.getShortForm() == "GB":
70
                                print "GB is" + `bulletvalue`
71
                                value = float(bulletvalue)
72
                                #if(bulletvalue.endswith('L')):
73
                                 #   bulletvalue=bulletvalue[0:len(bulletvalue)-2]
74
                                newvalue = value * 1024 * 1024
75
                                print "KB is" + `newvalue`
76
                                bulletvalue = str(newvalue)
77
                                #convert to kb
78
                            if unit.getShortForm() == "MB":
79
                                print "MB is" + `bulletvalue`
80
                                value = float(bulletvalue)
81
                                #if(bulletvalue.endswith('L')):
82
                                    #bulletvalue=bulletvalue[0:len(bulletvalue)-2]
83
                                newvalue = value * 1024
84
                                print "KB is" + `newvalue`
85
                                bulletvalue = str(newvalue)
86
                                #convert to kb
73 naveen 87
                        bulletsstruct.append(bulletvalue)
88
 
89
                featurestructs[featurelabel] = bulletsstruct
90
            else :
91
                # Set to empty list, this is to accomodate bullet-less features
92
                featurestructs[featurelabel] = []
93
 
94
        struct['features'] = featurestructs
95
 
96
    return struct
97
 
98