Subversion Repositories SmartDukaan

Rev

Rev 5173 | Details | Compare with Previous | Last modification | View Log | RSS feed

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