Ejemplo n.º 1
0
    def toXML(self):
        e1 = XMLElement("status")
        e1.set("reference", self.reference)

        if self.category != "":
            e1.set("category", self.category)

        if self.type == "automated_processing":
            e1.set("type", self.type)

        if self.editScreen != "":
            e1.set("edit_screen", self.editScreen)

        if self.viewScreen != "":
            e1.set("view_screen", self.viewScreen)

        e2 = XMLElement("name")
        e2.text = self.name 
        e1.append(e2)

        if self.description != "":
            e3 = XMLElement("description")
            e3.text = self.description 
            e1.append(e3)

        return e1 
Ejemplo n.º 2
0
    def toXML(self):
        e1 = XMLElement("role")
        e1.set("reference", self.reference)

        e2 = XMLElement("name")
        e2.text = self.name
        e1.append(e2)

        e3 = XMLElement("description")
        e3.text = self.description
        e1.append(e3)

        return e1
Ejemplo n.º 3
0
    def toXML(self):
        e1 = XMLElement("action")
        e1.set("taken_at", self.takenAt.strftime(DATETIME_FORMAT))
        e1.set("taken_by", self.takenBy)
        e1.set("type", self.type)

        return e1
Ejemplo n.º 4
0
def newElement(tag, text=None, attrib={}, tail=None):
    """ newElement(tag, text, attrib, tail)
       returns a new element with values set
 
       Inputs:
          tag:   element tag name
          text:  element text (defaults to None)
          attrib:  dictionary of attributes (defaults to {})
          text:  element tail (defaults to None)

       Return Value:  new element
  
   """
    #
    # Note: element.attrib can't be set with
    # if attrib:
    #    element.attrib = attrib
    #
    # however, element.attrib['foo'] = 11
    # is perfectly fine later.
    #
    # Put in the empty dict for later expansion
    #
    element = XMLElement(tag, attrib)
    if text:  # None is default but '' is None too
        element.text = text
    if tail:  # None is default but '' is None too
        element.tail = tail
    return element
Ejemplo n.º 5
0
    def toXML(self):
        e1 = XMLElement("roles")

        for role in self.roles:
            e1.append(role.toXML())

        return e1
Ejemplo n.º 6
0
    def toXML(self):
        e1 = XMLElement("developer")
        e1.set("workflow", self.workflowReference)
        e1.set("role", self.role)
        e1.text = self.emailAddress

        return e1
Ejemplo n.º 7
0
    def toXML(self):
        e1 = XMLElement("attribution")
        e1.set("source_id", self.sourceId)

        if self.pages != "":
            e1.set("pages", self.pages)

        return e1 
Ejemplo n.º 8
0
    def toXML(self):
        e1 = XMLElement("language")

        if self.name != "":
            e1.set("name", self.name)

        if self.code != "":
            e1.set("code", self.code)

        return e1 
Ejemplo n.º 9
0
    def toXML(self):
        e1 = XMLElement("unit_system")

        if self.name != "":
            e1.set("name", self.name)

        if self.code != "":
            e1.set("code", self.code)

        return e1 
Ejemplo n.º 10
0
    def toXML(self):
        e1 = XMLElement("response_format")
        e1.set("type", "choices")

        e2 = XMLSubelement(e1, "choices")

        for choice in self.choices:
            e2.append(choice.toXML())

        return e1
Ejemplo n.º 11
0
    def toXML(self):
        e1 = XMLElement("currency")

        if self.name != "":
            e1.set("name", self.name)

        if self.code != "":
            e1.set("code", self.code)

        return e1 
Ejemplo n.º 12
0
    def toXML(self):
        e1 = XMLElement("developer")
        e1.set("role", self.role)

        e2 = XMLSubelement(e1, "name")
        e2.text = self.name 

        e3 = XMLSubelement(e1, "email_address")
        e3.text = self.emailAddress 

        return e1
Ejemplo n.º 13
0
    def toXML(self):
        e1 = XMLElement("choice")
        e1.set("reference", self.reference)

        if self.isCorrectAnswer == True:
            e1.set("is_correct_answer", "true")

        if self.orderIndex >= 0:
            e1.set("order_index", self.orderIndex)

        return e1
Ejemplo n.º 14
0
    def toXML(self):
        e1 = XMLElement("question")
        e1.set("id", self.id)
        e1.set("version", str(self.version))
        
        e10 = XMLSubelement(e1, "upload_date")
        e10.text = self.uploadDate.strftime(DATETIME_FORMAT) if self.uploadDate != None else ""

        e11 = XMLSubelement(e1, "last_modification_date")
        e11.text = self.lastModificationDate.strftime(DATETIME_FORMAT) if self.lastModificationDate != None else ""

        e1.append(self.attribution.toXML())

        e3 = XMLSubelement(e1, "developers")

        for developer in self.developers:
            e3.append(developer.toXML())

        e1.append(self.language.toXML())

        e4 = XMLSubelement(e1, "dialects")

        for dialect in self.dialects:
            e4.append(dialect.toXML())

        e5 = XMLSubelement(e1, "calendars")

        for calendar in self.calendars:
            e5.append(calendar.toXML())

        e6 = XMLSubelement(e1, "currencies")

        for currency in self.currencies:
            e6.append(currency.toXML())

        e7 = XMLSubelement(e1, "unit_systems")

        for unitSystem in self.unitSystems:
            e7.append(unitSystem.toXML())

        e2 = XMLSubelement(e1, "title")
        e2.text = self.title

        e8 = XMLSubelement(e1, "parameters")

        for parameterSet in self.parameters:
            e8.append(parameterSet.toXML())

        e9 = XMLSubelement(e1, "parts")

        for part in self.parts:
            e9.append(part.toXML())

        return e1 
Ejemplo n.º 15
0
    def toXML(self):
        e1 = XMLElement("workflow")
        e1.set("reference", self.reference)

        if self.type != "":
            e1.set("type", self.type)

        if self.limitToEntityTypes:
            e1.set("limit_to_entity_types", ", ".join(self.limitToEntityTypes))

        if self.limitToSubjects:
            e1.set("limit_to_subjects", ", ".join(self.limitToSubjects))

        e2 = XMLElement("name")
        e2.text = self.name 
        e1.append(e2)

        if self.description != "":
            e3 = XMLElement("description")
            e3.text = self.description 
            e1.append(e3)

        e4 = XMLElement("statuses")
        e4.set("initial", self.initialStatus.reference)
        e4.set("final", self.finalStatus.reference)
        e4.set("default_edit_screen", self.defaultEditScreen)
        e4.set("default_view_screen", self.defaultViewScreen)
        
        for status in self.statuses:
            e4.append(status.toXML())

        e1.append(e4)

        e5 = XMLElement("transitions")

        for transition in self.transitions:
            e5.append(transition.toXML())

        e1.append(e5)

        return e1 
Ejemplo n.º 16
0
    def toXML(self):
        e1 = XMLElement("history")
        e1.set("for_entity", "{}/{}".format(self.contentEntityType,
                                            self.contentEntityId))

        e1.append(self.state.toXML())

        e2 = XMLSubelement(e1, "actions")

        for action in self.actions:
            e2.append(action.toXML())

        return e1
Ejemplo n.º 17
0
    def toXML(self):
        e1 = XMLElement("part")

        e1.set("type", self.type)
        e1.set("reference", self.reference)

        e2 = XMLSubelement(e1, "layout")

        e3 = XMLSubelement(e1, "response_formats")

        for responseFormat in self.responseFormats:
            e3.append(responseFormat.toXML())

        return e1
Ejemplo n.º 18
0
    def toXML(self):
        e1 = XMLElement("transition")
        e1.set("reference", self.reference)
        e1.set("from", self._from.reference)
        e1.set("to", self._to.reference)
        e1.set("type", self.type)

        if self.commentRequired:
            e1.set("comment_required", "true")

        if self.autoAssignTo != "":
            e1.set("auto_assign_to", self.autoAssignTo)

        e2 = XMLElement("name")
        e2.text = self.name 
        e1.append(e2)

        if self.buttonText != "":
            e3 = XMLElement("button_text")
            e3.text = self.buttonText 
            e1.append(e3)

        if self.description != "":
            e4 = XMLElement("description")
            e4.text = self.description 
            e1.append(e4)

        if self.rules:
            e5 = XMLElement("rules")

            for rule in self.rules:
                e5.append(rule.toXML())

            e1.append(e5)

        return e1 
Ejemplo n.º 19
0
    def toXML(self):
        e1 = XMLElement("state")

        e2 = XMLSubelement(e1, "workflow")
        e2.text = self.workflowReference

        e3 = XMLSubelement(e1, "workflow_status")
        e3.text = self.workflowStatusReference

        e4 = XMLSubelement(e1, "developers")

        for developer in self.developers:
            e4.append(developer.toXML())

        e5 = XMLSubelement(e1, "assignee")
        e5.text = self.assignee

        e6 = XMLSubelement(e1, "priority")
        e6.text = self.priority

        e7 = XMLSubelement(e1, "labels")

        for label in self.labels:
            e8 = XMLSubelement(e7, "label")
            e8.text = label

        e9 = XMLSubelement(e1, "watchers")

        for watcher in self.watchers:
            e10 = XMLSubelement(e9, "watcher")
            e10.text = watcher

        e11 = XMLSubelement(e1, "versions")

        for version in self.versions:
            e11.append(version.toXML())

        return e1
Ejemplo n.º 20
0
    def toXML(self):
        e1 = XMLElement("rule")
        e1.set("allow_if", "role in {}".format(self.roles))

        return e1 
Ejemplo n.º 21
0
    def toXML(self):
        e1 = XMLElement("response_format")
        e1.set("type", "input_text")

        return e1
Ejemplo n.º 22
0
    def toXML(self):
        e1 = XMLElement("rule")
        e1.set("allow_if", "'{}' in pastTransitions".format(self.transition.reference))

        return e1 
Ejemplo n.º 23
0
    def toXML(self):
        e1 = XMLElement("rule")
        e1.set("allow_if", "")

        return e1 
Ejemplo n.º 24
0
    def toXML(self):
        e1 = XMLElement("version")
        e1.set("file_name", self.fileName)
        e1.text = self.reference

        return e1
Ejemplo n.º 25
0
    def toXML(self):
        e1 = XMLElement("rule")
        e1.set("allow_if", "'{}' in pastStatuses".format(self.status.reference))

        return e1