Пример #1
0
def get_session_for_user(creator: str):
    return format_query(
        "ItemList", {
            "creator": creator,
            "filter": {
                "additionalType_contains":
                "https://vocab.trompamusic.eu/vocab#AnnotationSession"
            }
        }, SESSION_INCLUDES)
Пример #2
0
def get_annotation_toolkits_for_user(creator: str):
    return format_query(
        "ItemList", {
            "creator": creator,
            "filter": {
                "additionalType_contains":
                "https://vocab.trompamusic.eu/vocab#AnnotationToolkit"
            }
        }, TOOLKIT_INCLUDES)
Пример #3
0
def get_annotations_for_target_node(identifier: str):
    """Get all annotations whose target node is given by the identifier"""
    return format_query(
        "Annotation",
        {"filter": {
            "targetNode": {
                "target_in": {
                    "identifier": identifier
                }
            }
        }}, ANNOTATION_INCLUDES)
Пример #4
0
def query_controlaction_filter(filter: str,
                               return_items_list: list = [
                                   "identifier", "name"
                               ]):
    """Returns a query for querying the database for a controlaction object given a specific filter.
    Arguments:
        identifier: The identifier of the control action in the CE.
    Returns:
        The string for the quereing the control action.
    """
    query_ca = format_query("ControlAction", filter, return_items_list)
    return query_ca
def query_musiccomposition(identifier: str = None, title: str = None, contributor: str = None, creator: str = None,
                           source: str = None, inlanguage: str = None, name: str = None, position: int = None,
                           filter_: dict = None, return_items: Union[list, str] = None):
    """Returns a query for querying the database for a music composition.
    Arguments:
        identifier: The identifier of the music composition in the CE.
        title: The title of the resource indicated by `source`
        creator: The person, organization or service who created the thing the web resource is about.
        contributor: A person, an organization, or a service responsible for contributing\
                  the music composition to the web resource. This can be either a name or a base URL.
        source: The source URL that an item comes from
        inlanguage: The language of the music composition. Currently supported languages are en,es,ca,nl,de,fr
        name: The name of the music composition.
        position: In the case that this is a movement of a larger work (e.g. a Symphony), the position of this
                  MusicComposition in the larger one.
        filter_: return nodes with this custom filter
        return_items: return these items in the response
    Returns:
        The string for the quereing the music composition.
    Raises:
        UnsupportedLanguageException if the input language is not one of the supported languages.
    """

    if return_items is None:
        return_items = ["identifier", "title", "source"]

    if inlanguage and inlanguage not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(inlanguage)

    args = {
        "identifier": identifier,
        "title": title,
        "source": source,
        "contributor": contributor,
        "creator": creator,
        "inLanguage": inlanguage,
        "name": name,
        "position": position
    }
    if filter_:
        args["filter"] = StringConstant(make_filter(filter_))

    args = filter_none_args(args)

    return format_query("MusicComposition", args, return_items)
Пример #6
0
def query_mediaobject(identifier: str = None,
                      creator: str = None,
                      contributor: str = None,
                      encodingformat: str = None,
                      source: str = None,
                      contenturl: str = None,
                      inlanguage: str = None,
                      filter_: dict = None,
                      return_items: Union[list, str] = None):
    """Returns a query for querying the database for a media object.
    Arguments:
        identifier: The identifier of the media object in the CE.
        creator: The person, organization or service who created the thing the web resource is about.
        contributor: A person, an organization, or a service responsible for contributing\
         the media object to the web resource. This can be either a name or a base URL.
        encodingformat: A MimeType of the format of object encoded by the media object.
        source: The URL of the web resource to be represented by the node.
        contenturl: The URL of the content encoded by the media object.
        inlanguage: The language of the media object. Currently supported languages are en,es,ca,nl,de,fr.
        filter_: return nodes with this custom filter
        return_items: return these items in the response
    Returns:
        The string for the quereing the media object.
    Raises:
        UnsupportedLanguageException if the input language is not one of the supported languages.
    """

    if return_items is None:
        return_items = ["identifier", "name"]

    args = {
        "identifier": identifier,
        "creator": creator,
        "contributor": contributor,
        "encodingFormat": encodingformat,
        "source": source,
        "contentUrl": contenturl,
        "inLanguage": inlanguage
    }
    if filter_:
        args["filter"] = StringConstant(make_filter(filter_))

    args = filter_none_args(args)

    return format_query("MediaObject", args, return_items)
Пример #7
0
def query_softwareapplication(identifier: str = None,
                              title: str = None,
                              contributor: str = None,
                              creator: str = None,
                              source: str = None,
                              name: str = None,
                              language: str = None,
                              softwareversion: str = None,
                              filter_: dict = None,
                              return_items: list = None):
    """Returns a query for reading an SoftwareApplication from the CE.
    Arguments:
        identifier: return nodes with this identifier
        title: return nodes with this title
        contributor: return nodes with this contributor
        creator: return nodes with this creator
        source: return nodes with this source
        name: return nodes with this name
        language: return nodes with this language
        softwareversion: return nodes with this softwareversion
        filter_: return nodes with this custom filter
        return_items: return these items in the response
    Returns:
        The string for the querying the SoftwareApplication.
    """

    if return_items is None:
        return_items = ["identifier", "creator", "title", "source"]

    args = {
        "identifier": identifier,
        "title": title,
        "contributor": contributor,
        "creator": creator,
        "source": source,
        "name": name,
        "language": language,
        "softwareVersion": softwareversion
    }
    if filter_:
        args["filter"] = make_filter(filter_)

    args = filter_none_args(args)

    return format_query("SoftwareApplication", args, return_items)
Пример #8
0
def query_person(identifier: str = None,
                 contributor: str = None,
                 creator: str = None,
                 source: str = None,
                 language: str = None,
                 format_: str = None,
                 name: str = None,
                 family_name: str = None,
                 given_name: str = None,
                 return_items_list: list = ["identifier", "name"]):
    """Returns a query for retrieving a person or people.

    Arguments:
        identifier: The identifier of the person in the CE.
        contributor: The main URL of the site where the information about the Person was taken from
        creator: The person, organization or service who is creating this Person (e.g. URL of the software)
        source: The URL of the web resource where information about this Person is taken from
        language: The language the metadata is written in.
        format_: The mimetype of the resource indicated by `source`
        name: The name of the person
        family_name: The family name of the person
        given_name: The given name of the person
        return_items_list: A list of item fields that the query must return.

    Returns:
        The string for a person query.
    """

    args = {
        "identifier": identifier,
        "contributor": contributor,
        "creator": creator,
        "source": source,
        "language": language,
        "format": format_,
        "name": name,
        "familyName": family_name,
        "givenName": given_name,
    }

    args = filter_none_args(args)

    return format_query("Person", args, return_items_list)
Пример #9
0
def query_place(identifier: str = None,
                title: str = None,
                contributor: str = None,
                creator: str = None,
                source: str = None,
                format_: str = None,
                name: str = None,
                return_items_list: list = ["identifier", "name"]):
    """Returns a query for retrieving a place or places.

    Arguments:
        identifier: The identifier of the place in the CE.
        title: The title of the resource indicated by `source`
        contributor: The main URL of the site where the information about the Place was taken from
        creator: The person, organization or service who is creating this Place (e.g. URL of the software)
        source: The URL of the web resource where information about this Place is taken from
        format_: The format of ``source``
        name: The name of the place
        return_items_list: A list of fields to return in the query.

    Returns:
        The string for a place query.
    """

    args = {
        "identifier": identifier,
        "title": title,
        "contributor": contributor,
        "creator": creator,
        "source": source,
        "format": format_,
        "name": name,
    }

    args = filter_none_args(args)

    return format_query("Place", args, return_items_list)
Пример #10
0
def query_audioobject(identifier: str = None,
                      title: str = None,
                      contributor: str = None,
                      creator: str = None,
                      source: str = None,
                      format_: str = None,
                      name: str = None,
                      date: str = None,
                      encodingformat: str = None,
                      embedurl: str = None,
                      url: str = None,
                      contenturl: str = None,
                      language: str = None,
                      inlanguage: str = None,
                      license_: str = None,
                      filter_: dict = None,
                      return_items: list = None):
    """Returns a query for reading an AudioObject from the CE.
    Arguments:
        identifier: return nodes with this identifier
        title: return nodes with this title
        contributor: return nodes with this contributor
        creator: return nodes with this creator
        source: return nodes with this source
        format_: return nodes with this format
        name: return nodes with this name
        date: return nodes with this date
        encodingformat: return nodes with this encodingFormat
        embedurl: return nodes with this embedUrl
        url: return nodes with this url
        contenturl: return nodes with this contentUrl
        language: return nodes with this language
        inlanguage: return nodes with this inLanguage
        license_: return nodes with this license
        filter_: return nodes with this custom filter
        return_items: return these items in the response
    Returns:
        The string for the querying the media object.
    """

    if return_items is None:
        return_items = ["identifier", "creator", "title", "source"]

    args = {
        "identifier": identifier,
        "title": title,
        "contributor": contributor,
        "creator": creator,
        "source": source,
        "format": format_,
        "name": name,
        "date": date,
        "encodingFormat": encodingformat,
        "embedUrl": embedurl,
        "url": url,
        "contentUrl": contenturl,
        "language": language,
        "inLanguage": inlanguage,
        "license": license_
    }
    if filter_:
        args["filter"] = make_filter(filter_)

    args = filter_none_args(args)

    return format_query("AudioObject", args, return_items)
Пример #11
0
def get_annotation_toolkit(identifier: str):
    return format_query("ItemList", {"identifier": identifier},
                        TOOLKIT_INCLUDES)
Пример #12
0
def get_annotations_for_user(creator: str):
    return format_query("Annotation", {"creator": creator},
                        ANNOTATION_INCLUDES)
Пример #13
0
def get_annotation(identifier: str):
    return format_query("Annotation", {"identifier": identifier},
                        ANNOTATION_INCLUDES)