Parent: [a4d8c3] (diff)

Child: [2c9463] (diff)

Download this file

models.py    36 lines (29 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 = xmldoc.getElementsByTagName('Id')[0].firstChild.data
self.name = xmlMinidom.getString(xmldoc, 'Name')
self.actual_entity_class = xmlMinidom.getString(xmldoc, 'ActualEntityClass')
self.actual_entity_app = xmlMinidom.getString(xmldoc, 'ActualEntityApp')
# I save so I get the ID (if insert == True)
self.save()
def to_xml(self):
str_xml = "<Id>" + str(self.id) + "</Id>"
str_xml += "<Name>" + self.name + "</Name>"
str_xml += "<ActualEntityClass>" + self.actual_entity_class + "</ActualEntityClass>"
str_xml += "<ActualEntityApp>" + self.actual_entity_app + "</ActualEntityApp>"
return "<Entity>" + str_xml + "</Entity>"
def __unicode__(self):
return self.name
class SearchConfiguration(models.Model):
proxy_url = models.CharField(max_length=300)
proxy_port = models.CharField(max_length=10)
proxy_user = models.CharField(max_length=50)
proxy_password = models.CharField(max_length=50)
# active_search = quale classe implementa la entity corrente
# http://stackoverflow.com/questions/372042/difference-between-abstract-class-and-interface-in-python