Switch to unified view

a/OSSEval/entity/models.py b/OSSEval/entity/models.py
1
from django.db import models
1
from django.db import models
2
from OSSEval.utils import xmlMinidom
2
3
3
class Entity(models.Model):
4
class Entity(models.Model):
4
    name = models.CharField(max_length=200)
5
    name = models.CharField(max_length=200)
5
    actual_entity_class = models.CharField(max_length=200) #the class that implements the actual entity instance
6
    actual_entity_class = models.CharField(max_length=200) #the class that implements the actual entity instance
6
    actual_entity_search_class = models.CharField(max_length=200) 
7
    actual_entity_app = models.CharField(max_length=200) #the app where the above classes are
7
    actual_entity_app = models.CharField(max_length=200) #the app where the above classes are
8
    def from_xml(self, xmldoc, insert = True):
9
        if not insert:
10
            self.id = xmldoc.getElementsByTagName('Id')[0].firstChild.data
11
        self.name = xmlMinidom.getString(xmldoc, 'Name')
12
        self.actual_entity_class = xmlMinidom.getString(xmldoc, 'ActualEntityClass')
13
        self.actual_entity_app = xmlMinidom.getString(xmldoc, 'ActualEntityApp')
14
        # I save so I get the ID (if insert == True)
15
        self.save()
16
    def to_xml(self):
17
        str_xml = "<Id>" + str(self.id) + "</Id>"
18
        str_xml += "<Name>" + self.name + "</Name>"
19
        str_xml += "<ActualEntityClass>" + self.actual_entity_class + "</ActualEntityClass>"
20
        str_xml += "<ActualEntityApp>" + self.actual_entity_app + "</ActualEntityApp>"
21
        return "<Entity>" + str_xml + "</Entity>"
8
    
22
    
9
    def __unicode__(self):
23
    def __unicode__(self):
10
        return self.name
24
        return self.name
11
25
12
    
26