Esempio n. 1
0
def attr_parse(parent: UMLClass, element, root, stereotypes) -> UMLAttribute:
    value = element.get("value").strip("<div>").strip("</div>").strip("<br")
    # height = int(element.find("mxGeometry").get("y"))

    dq = []
    if "{dq_even}" in value:
        dq.append('even')
        value = value.replace("{dq_even}", "").strip()

    is_id = False
    if "{id}" in value:
        is_id = True
        value = value.replace("{id}", "").strip()

    visibility: bool = False
    if value.startswith("+"):
        visibility = True
    value = value.strip("+").strip("-").strip()

    name, attr_type = value.split(":")

    attr = UMLAttribute(parent, name, element.get('id'))
    if is_id:
        attr.is_id = is_id
        parent.id_attribute = attr
    attr.visibility = visibility

    attr.validations = dq

    attr.set_type(attr_type.strip())

    return attr
Esempio n. 2
0
def attr_parse(parent: UMLClass, element, root, stereotypes) -> UMLAttribute:
    value = element.get("value").strip("<div>").strip("</div>").strip("<br")
    # height = int(element.find("mxGeometry").get("y"))

    dq = []
    if "{dq_even}" in value:
        dq.append('even')
        value = value.replace("{dq_even}", "").strip()

    is_id = False
    if "{id}" in value:
        is_id = True
        value = value.replace("{id}", "").strip()

    visibility: bool = False
    if value.startswith("+"):
        visibility = True
    value = value.strip("+").strip("-").strip()

    name, attr_type = value.split(":")
    attr_type = attr_type.strip()

    attr = UMLAttribute(parent, name, element.get('id'))
    if is_id:
        attr.is_id = is_id
        parent.id_attribute = attr
    attr.visibility = visibility

    attr.validations = dq

    attr.type = attr_type
    if attr.type == 'string':
        attr.length = 100

    if attr_type in generation_fields[settings['generation_type']].keys():
        attr.dest_type = generation_fields[
            settings['generation_type']][attr_type]
    else:
        attr.dest_type = attr_type

    return attr