Switch to unified view

a/OSSEval/entity/models.py b/OSSEval/entity/models.py
...
...
13
13
14
from django.db import models
14
from django.db import models
15
from OSSEval.utils import xmlMinidom
15
from OSSEval.utils import xmlMinidom
16
16
17
class Entity(models.Model):
17
class Entity(models.Model):
18
    '''
19
    An Entity is the Open Source Project or the IMDB Movie; each
20
    entity comes with a module/app
21
    The class Instance (from analysis.models) will be related 1 to 1
22
    with the class defined in the module/app; e.g. OSProject and IMDBMovie: see
23
    actual_instance_accessor below
24
    '''
18
    name = models.CharField(max_length=200)
25
    name = models.CharField(max_length=200)
19
    actual_entity_class = models.CharField(max_length=200) #the class that implements the actual entity instance
26
    #the class that implements the actual entity instance
27
    actual_entity_class = models.CharField(max_length=200)
28
    #the module/app where the above class is
20
    actual_entity_app = models.CharField(max_length=200) #the app where the above classes are
29
    actual_entity_app = models.CharField(max_length=200)
30
    # the name of the accessor (related_name) to go from analysis.Instance
31
    # to the actual_instance e.g. the OSProject or IMDBMovie instance.
32
    actual_instance_accessor = models.CharField(max_length=200)
33
    
21
    def from_xml(self, xmldoc, insert = True):
34
    def from_xml(self, xmldoc, insert = True):
22
        if not insert:
35
        if not insert:
23
            self.id = xmlMinidom.getNaturalAttribute(xmldoc, 'Id')
36
            self.id = xmlMinidom.getNaturalAttribute(xmldoc, 'Id')
24
        self.name = xmlMinidom.getStringAttribute(xmldoc, 'Name')
37
        self.name = xmlMinidom.getStringAttribute(xmldoc, 'Name')
25
        self.actual_entity_class = xmlMinidom.getStringAttribute(xmldoc, 'ActualEntityClass')
38
        self.actual_entity_class = xmlMinidom.getStringAttribute(xmldoc, 'ActualEntityClass')
26
        self.actual_entity_app = xmlMinidom.getStringAttribute(xmldoc, 'ActualEntityApp')
39
        self.actual_entity_app = xmlMinidom.getStringAttribute(xmldoc, 'ActualEntityApp')
40
        self.actual_instance_accessor = xmlMinidom.getStringAttribute(xmldoc, 'ActualInstanceAccessor')
27
        # I save so I get the ID (if insert == True)
41
        # I save so I get the ID (if insert == True)
28
        self.save()
42
        self.save()
29
    def to_xml(self):
43
    def to_xml(self):
30
        return '<Entity Id="' + str(self.id) + '" Name="' + self.name + '" ActualEntityClass="' + self.actual_entity_class + '" ActualEntityApp="' + self.actual_entity_app + '"/>'
44
        return '<Entity Id="' + str(self.id) + '" Name="' + self.name + '" ActualEntityClass="' + self.actual_entity_class + '" ActualEntityApp="' + self.actual_entity_app + '" ActualInstanceAccessor="' + self.actual_instance_accessor + '"/>'
31
    
45
    
32
    def __str__(self):
46
    def __str__(self):
33
        return self.name
47
        return self.name
34
48
35
49