# This Source Code Form of OSSEval is subject to the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE, v. 3.0. If a copy of the AGPL was not
# distributed with this file, You can obtain one at http://www.gnu.org/licenses/agpl.txt
#
# OSSeval is powered by the SOS Open Source AGPL edition.
# The AGPL requires that you do not remove the SOS Open Source attribution and copyright
# notices from the user interface (see section 5.d below).
# Commercial licenses are available and do not require any SOS Open Source attributions
# or visible copyright notices but they are not permitted under this license.
# OSSEval Copyright 2014 Bitergium SLL
# SOS Open Source Copyright 2012 Roberto Galoppini
# Author: Davide Galletti
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