Switch to unified view

a/OSSEval/analysis/models.py b/OSSEval/analysis/models.py
1
# This Source Code Form of OSSEval is subject to the terms of the GNU AFFERO
2
# GENERAL PUBLIC LICENSE, v. 3.0. If a copy of the AGPL was not
3
# distributed with this file, You can obtain one at http://www.gnu.org/licenses/agpl.txt
4
#
5
# OSSeval is powered by the SOS Open Source AGPL edition.
6
#  The AGPL requires that you do not remove the SOS Open Source attribution and copyright 
7
#  notices from the user interface (see section 5.d below).
8
#  Commercial licenses are available and do not require any SOS Open Source attributions
9
#  or visible copyright notices but they are not permitted under this license.
10
11
# OSSEval Copyright 2014 Bitergium SLL
12
# SOS Open Source Copyright 2012 Roberto Galoppini
13
# Author: Davide Galletti 
14
15
1
import importlib
16
import importlib
2
from django.db import models
17
from django.db import models
3
from datetime import datetime
18
from datetime import datetime
4
from random import randrange
19
from random import randrange
5
from pygal import Radar, Bar
20
from pygal import Radar, Bar
...
...
23
        if not insert:
38
        if not insert:
24
            self.id = xmlMinidom.getNaturalAttribute(xmldoc, 'Id')
39
            self.id = xmlMinidom.getNaturalAttribute(xmldoc, 'Id')
25
        self.name = xmlMinidom.getStringAttribute(xmldoc, 'Name')
40
        self.name = xmlMinidom.getStringAttribute(xmldoc, 'Name')
26
        self.description = xmlMinidom.getString(xmldoc, 'Description')
41
        self.description = xmlMinidom.getString(xmldoc, 'Description')
27
        self.documentation = xmlMinidom.getString(xmldoc, 'Documentation')
42
        self.documentation = xmlMinidom.getString(xmldoc, 'Documentation')
28
        self.active = xmlMinidom.getStringAttribute(xmldoc, 'Active')
43
        self.active = (xmlMinidom.getStringAttribute(xmldoc, 'Active') == "True")
29
        e = Entity()
44
        e = Entity()
30
        xml_entity = xmldoc.getElementsByTagName('Entity')[0]
45
        xml_entity = xmldoc.getElementsByTagName('Entity')[0]
31
        e.from_xml(xml_entity, insert)
46
        e.from_xml(xml_entity, insert)
32
        self.entity = e
47
        self.entity = e
33
        # I save so I get the ID (in case insert == True)
48
        # I save so I get the ID (in case insert == True)
...
...
113
        for xml_page in xml_pages.childNodes:
128
        for xml_page in xml_pages.childNodes:
114
            if xml_page.nodeType == Node.ELEMENT_NODE and xml_page.tagName == 'Page':
129
            if xml_page.nodeType == Node.ELEMENT_NODE and xml_page.tagName == 'Page':
115
                p = Page()
130
                p = Page()
116
                p.from_xml(xml_page, self, None, insert)
131
                p.from_xml(xml_page, self, None, insert)
117
        #WeightScenarios
132
        #WeightScenarios
118
        xml_weight_scenarios = xmldoc.getElementsByTagName('WeightScenarios')
133
        xml_weight_scenarios = xmldoc.getElementsByTagName('WeightScenario')
119
        for xml_weight_scenario in xml_weight_scenarios:
134
        for xml_weight_scenario in xml_weight_scenarios:
120
            ws = WeightScenario()
135
            ws = WeightScenario()
121
            ws.from_xml(xml_weight_scenario, self, insert)
136
            ws.from_xml(xml_weight_scenario, self, insert)
122
        
137
        
123
    def to_xml(self):
138
    def to_xml(self):
...
...
367
    def from_xml(self, xmldoc, methodology_version, insert = True):
382
    def from_xml(self, xmldoc, methodology_version, insert = True):
368
        if not insert:
383
        if not insert:
369
            self.id = xmlMinidom.getNaturalAttribute(xmldoc, 'Id')
384
            self.id = xmlMinidom.getNaturalAttribute(xmldoc, 'Id')
370
        self.methodology_version = methodology_version
385
        self.methodology_version = methodology_version
371
        self.name = xmlMinidom.getStringAttribute(xmldoc, 'Name')
386
        self.name = xmlMinidom.getStringAttribute(xmldoc, 'Name')
372
        self.active = xmlMinidom.getStringAttribute(xmldoc, 'Active')
387
        self.active = (xmlMinidom.getStringAttribute(xmldoc, 'Active') == "True")
373
        self.save()
388
        self.save()
374
        #Weights
389
        #Weights
375
        xml_weights = xmldoc.getElementsByTagName('Weight')
390
        xml_weights = xmldoc.getElementsByTagName('Weight')
376
        for xml_weight in xml_weights:
391
        for xml_weight in xml_weights:
377
            w = Weight()
392
            w = Weight()