예제 #1
0
파일: mapping.py 프로젝트: agromsl/mediatum
def editMapping_mask(req, id, err=0):
    if err == 0 and id == "":
        # new mapping
        mapping = tree.Node("", type="mapping")
    elif id != "":
        # edit mapping
        mapping = getMapping(id)
    else:
        # error while filling values
        mapping = tree.Node("", type="mapping")
        mapping.setName(req.params.get("name", ""))
        mapping.setDescription(req.params.get("description", ""))
        mapping.setNamespace(req.params.get("namespace", ""))
        mapping.setNamespaceUrl(req.params.get("namespaceurl", ""))
        mapping.setHeader(req.params.get("header"))
        mapping.setFooter(req.params.get("footer"))
        mapping.setSeparator(req.params.get("separator"))
        mapping.setStandardFormat(req.params.get("standardformat"))

    v = getAdminStdVars(req)
    v["error"] = err
    v["mapping"] = mapping
    v["id"] = id
    v["actpage"] = req.params.get("actpage")
    v["mappingtypes"] = getMappingTypes()
    return req.getTAL("web/admin/modules/mapping.html", v, macro="modify")
예제 #2
0
파일: medmarc.py 프로젝트: agromsl/mediatum
def find_marc_mapping(schema_name):
    """
    Look up the MARC21 mapping configuration in the node tree.

    The ``schema_name`` is used to find the mapping configuration
    based on a naming convention, specifically ``marc21_XYZ`` for a
    schema name ``XYZ``.

    Each entry in the mapping has a name 'field$subfield'
    (e.g. '240$a') that indicates the MARC field and subfield the
    value is mapped to.  The 'description' attribute provides the
    template string that maps the node data to the specific field
    content.

    Returns a list of tuples:
    [ ((field, subfield), field_template), ... ]
    """
    marc_mapping = mapping.getMapping('marc21_' + schema_name)
    if marc_mapping is None:  # FIXME: or not marc_mapping.isActive():
        return None

    mapping_fields = [(tuple(mask_item.getName().split('$', 1)),
                       Template(mask_item.getDescription()))
                      for mask_item in marc_mapping.getFields()
                      if '$' in mask_item.getName()]
    return mapping_fields
예제 #3
0
파일: medmarc.py 프로젝트: hibozzy/mediatum
def find_marc_mapping(schema_name):
    """
    Look up the MARC21 mapping configuration in the node tree.

    The ``schema_name`` is used to find the mapping configuration
    based on a naming convention, specifically ``marc21_XYZ`` for a
    schema name ``XYZ``.

    Each entry in the mapping has a name 'field$subfield'
    (e.g. '240$a') that indicates the MARC field and subfield the
    value is mapped to.  The 'description' attribute provides the
    template string that maps the node data to the specific field
    content.

    Returns a list of tuples:
    [ ((field, subfield), field_template), ... ]
    """
    marc_mapping = mapping.getMapping('marc21_' + schema_name)
    if marc_mapping is None:  # FIXME: or not marc_mapping.isActive():
        return None

    mapping_fields = [(tuple(mask_item.getName().split('$', 1)),
                       Template(mask_item.getDescription()))
                      for mask_item in marc_mapping.getFields()
                      if '$' in mask_item.getName()]
    return mapping_fields
예제 #4
0
파일: mapping.py 프로젝트: hibozzy/mediatum
def editMapping_mask(req, id, err=0):
    if err == 0 and id == "":
        # new mapping
        mapping = tree.Node("", type="mapping")
    elif id != "":
        # edit mapping
        mapping = getMapping(id)
    else:
        # error while filling values
        mapping = tree.Node("", type="mapping")
        mapping.setName(req.params.get("name", ""))
        mapping.setDescription(req.params.get("description", ""))
        mapping.setNamespace(req.params.get("namespace", ""))
        mapping.setNamespaceUrl(req.params.get("namespaceurl", ""))
        mapping.setHeader(req.params.get("header"))
        mapping.setFooter(req.params.get("footer"))
        mapping.setSeparator(req.params.get("separator"))
        mapping.setStandardFormat(req.params.get("standardformat"))

    v = getAdminStdVars(req)
    v["error"] = err
    v["mapping"] = mapping
    v["id"] = id
    v["actpage"] = req.params.get("actpage")
    v["mappingtypes"] = getMappingTypes()
    return req.getTAL("web/admin/modules/mapping.html", v, macro="modify")
예제 #5
0
파일: mapping.py 프로젝트: hibozzy/mediatum
def viewlist(req, id):
    mapping = getMapping(id)

    fields = list(mapping.getFields())
    order = getSortCol(req)
    actfilter = getFilter(req)

    # filter
    if actfilter != "":
        if actfilter in ("all", "*", (lang(req), "admin_filter_all")):
            None  # all mappings
        elif actfilter == "0-9":
            num = re.compile(r'([0-9])')
            fields = filter(lambda x: num.match(x.getName()), fields)

        elif actfilter == "else" or actfilter == t(lang(req),
                                                   "admin_filter_else"):
            all = re.compile(r'([a-z]|[A-Z]|[0-9])')
            fields = filter(lambda x: not all.match(x.getName()), fields)

        else:
            fields = filter(
                lambda x: x.getName().lower().startswith(actfilter), fields)

    pages = Overview(req, fields)

    # sorting
    if order != "":
        if int(order[0:1]) == 0:
            fields.sort(lambda x, y: cmp(x.getName().lower(),
                                         y.getName().lower()))
        elif int(order[0:1]) == 1:
            fields.sort(lambda x, y: cmp(x.getDescription().lower(),
                                         y.getDescription().lower()))
        elif int(order[0:1]) == 2:
            fields.sort(lambda x, y: cmp(x.getMandatory(), y.getMandatory()))

        if int(order[1:]) == 1:
            fields.reverse()
    else:
        fields.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower()))

    v = getAdminStdVars(req)
    v["sortcol"] = pages.OrderColHeader([
        t(lang(req), "admin_mappingfield_col_1"),
        t(lang(req), "admin_mappingfield_col_2"),
        t(lang(req), "admin_mappingfield_col_3")
    ],
                                        addparams="&detailof=" +
                                        str(mapping.id))
    v["fields"] = fields
    v["mapping"] = mapping
    v["options"] = []
    v["pages"] = pages
    v["actfilter"] = actfilter
    return req.getTAL("web/admin/modules/mapping.html", v, macro="viewlist")
예제 #6
0
def viewlist(req, id):
    mapping = getMapping(id)

    fields = list(mapping.getFields())
    order = getSortCol(req)
    actfilter = getFilter(req)

    # filter
    if actfilter != "":
        if actfilter in ("all", "*", (lang(req), "admin_filter_all")):
            None  # all mappings
        elif actfilter == "0-9":
            num = re.compile(r'([0-9])')
            fields = filter(lambda x: num.match(x.name), fields)

        elif actfilter == "else" or actfilter == t(lang(req), "admin_filter_else"):
            all = re.compile(r'([a-z]|[A-Z]|[0-9])')
            fields = filter(lambda x: not all.match(x.name), fields)

        else:
            fields = filter(lambda x: x.name.lower().startswith(actfilter), fields)

    pages = Overview(req, fields)

    # sorting
    if order != "":
        if int(order[0:1]) == 0:
            fields.sort(lambda x, y: cmp(x.name.lower(), y.name.lower()))
        elif int(order[0:1]) == 1:
            fields.sort(lambda x, y: cmp(x.getDescription().lower(), y.getDescription().lower()))
        elif int(order[0:1]) == 2:
            fields.sort(lambda x, y: cmp(x.getMandatory(), y.getMandatory()))

        if int(order[1:]) == 1:
            fields.reverse()
    else:
        fields.sort(lambda x, y: cmp(x.name.lower(), y.name.lower()))

    v = getAdminStdVars(req)
    v["sortcol"] = pages.OrderColHeader([t(lang(req), "admin_mappingfield_col_1"), t(lang(req), "admin_mappingfield_col_2"), t(
        lang(req), "admin_mappingfield_col_3")], addparams="&detailof=" + unicode(mapping.id))
    v["fields"] = fields
    v["mapping"] = mapping
    v["options"] = []
    v["pages"] = pages
    v["actfilter"] = actfilter
    v["csrf"] = req.csrf_token.current_token
    return req.getTAL("web/admin/modules/mapping.html", v, macro="viewlist")