Parent: [7f6519] (diff)

Child: [77df3f] (diff)

Download this file

models.py    23 lines (18 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
from django.db import models
from OSSEval.utils import xmlMinidom
class Entity(models.Model):
name = models.CharField(max_length=200)
actual_entity_class = models.CharField(max_length=200) #the class that implements the actual entity instance
actual_entity_app = models.CharField(max_length=200) #the app where the above classes are
def from_xml(self, xmldoc, insert = True):
if not insert:
self.id = xmlMinidom.getNaturalAttribute(xmldoc, 'Id')
self.name = xmlMinidom.getStringAttribute(xmldoc, 'Name')
self.actual_entity_class = xmlMinidom.getStringAttribute(xmldoc, 'ActualEntityClass')
self.actual_entity_app = xmlMinidom.getStringAttribute(xmldoc, 'ActualEntityApp')
# I save so I get the ID (if insert == True)
self.save()
def to_xml(self):
return '<Entity Id="' + str(self.id) + '" Name="' + self.name + '" ActualEntityClass="' + self.actual_entity_class + '" ActualEntityApp="' + self.actual_entity_app + '"/>'
def __str__(self):
return self.name