Esempio n. 1
0
def create_annotation_textual_body(creator: str,
                                   value: str,
                                   format_: str = None,
                                   language: str = None):
    """Return a mutation for making an AnnotationTextualBody.
    An AnnotationTextualBody is the main written body of a
    web Annotation (https://www.w3.org/TR/annotation-model).

    Arguments:
        creator: a URI to the identity of the user who created this AnnotationTextualBody
        value: the text for the body of the annotation
        format_: the mimetype that value is formatted in
        language: the language that value is written in

    Returns:
        A GraphQL Mutation to create an AnnotationTextualBody in the Trompa CE
    """

    check_required_args(creator=creator, value=value)

    if language and language.lower() not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(language)

    params = {"creator": creator, "value": value, "format": format_}

    if language is not None:
        params["language"] = StringConstant(language.lower())

    return format_mutation(mutationname="CreateAnnotationTextualBody",
                           args=params)
Esempio n. 2
0
def mutation_update_audioobject(identifier: str,
                                *,
                                name: str = None,
                                title: str = None,
                                description: str = None,
                                date: str = None,
                                creator: str = None,
                                contributor: str = None,
                                format_: str = None,
                                encodingformat: str = None,
                                source: str = None,
                                license: str = None,
                                subject: str = None,
                                contenturl: str = None,
                                language: str = None,
                                inlanguage: str = None):
    """Returns a mutation for updating a AudioObject.

    Arguments:
        identifier: The identifier of the AudioObject in the CE to be updated.
        {audioobject_args}

    Returns:
        The string for the mutation for updating the AudioObject.

    Raises:
        Assertion error if the input language or inlanguage is not one of the supported languages.
    """
    if format_ is not None and "/" not in format_:
        raise NotAMimeTypeException(format_)

    if encodingformat is not None and "/" not in encodingformat:
        raise NotAMimeTypeException(encodingformat)

    if language is not None and language not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(language)

    args = {
        "identifier": identifier,
        "name": name,
        "title": title,
        "description": description,
        "creator": creator,
        "contributor": contributor,
        "format": format_,
        "encodingFormat": encodingformat,
        "source": source,
        "subject": subject,
        "contentUrl": contenturl,
        "license": license,
        "inLanguage": inlanguage,
    }
    if date:
        args["date"] = _Neo4jDate(date)
    if language:
        args["language"] = StringConstant(language.lower())

    args = filter_none_args(args)

    return format_mutation("UpdateAudioObject", args)
Esempio n. 3
0
def mutation_create_entry_point(*,
                                name: str,
                                contributor: str,
                                subject: str,
                                creator: str,
                                source: str,
                                language: str,
                                actionPlatform: str,
                                contentType: List,
                                encodingType: list,
                                formatin="text/html",
                                identifier=None,
                                description: str = None):
    """Returns a mutation for creating an entry point object
    Arguments:
        name: The name of the entry point.
        contributor: A person, an organization, or a service responsible for contributing the aentry point to the web resource. This can be either a name or a base URL.
        creator: The person, organization or service who created the thing the entry point is about.
        source: The URL of the web resource to be represented by the node.
        description: An account of the entry point..
        language: The language the metadata is written in. Currently supported languages are en,es,ca,nl,de,fr.
        actionPlatform: The action platform.
        contentType: The content type associated with the entry point, should be a mimetype.
        encodingType: The encoding type associated with the entry point, should be a mimetype.
    Returns:
        The string for the mutation for creating the artist.
    Raises:
        Assertion error if the input language is not one of the supported languages.
    """
    if language not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(language)
    if "/" not in formatin:
        raise NotAMimeTypeException(formatin)
    if not all("/" in x for x in contentType):
        missing_list = [x for x in contentType if "/" not in x]
        raise NotAMimeTypeException(missing_list)
    if not all("/" in x for x in encodingType):
        missing_list = [x for x in encodingType if "/" not in x]
        raise NotAMimeTypeException(missing_list)

    args = {
        "title": name,
        "name": name,
        "contributor": contributor,
        "creator": creator,
        "source": source,
        "subject": subject,
        "description": description,
        "format": formatin,
        "language": StringConstant(language.lower()),
        "actionPlatform": actionPlatform,
        "contentType": contentType,
        "encodingType": encodingType
    }
    if identifier:
        args["identifier"] = identifier
    return mutation_create(args, CREATE_ENTRYPOINT)
Esempio n. 4
0
def mutation_create_musicrecording(*,
                                   name: str = None,
                                   title: str,
                                   description: str,
                                   contributor: str,
                                   creator: str,
                                   source: str,
                                   format_: str,
                                   encodingformat: str = None,
                                   subject: str = None,
                                   language: str = None,
                                   date: str = None):
    """Returns a mutation for creating a MusicRecording object.
    https://schema.org/MusicRecording

    Arguments:
        {musicrecording_args}

    Returns:
        The string for the mutation for creating the MusicRecording.
    """
    check_required_args(title=title,
                        contributor=contributor,
                        creator=creator,
                        source=source,
                        format_=format_)

    if "/" not in format_:
        raise NotAMimeTypeException(format_)

    if language is not None and language not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(language)

    args = {
        "name": name,
        "title": title,
        "description": description,
        "contributor": contributor,
        "creator": creator,
        "source": source,
        "format": format_,
        "encodingFormat": encodingformat,
        "subject": subject
    }

    if language is not None:
        args["language"] = StringConstant(language.lower())
    if date is not None:
        args["date"] = _Neo4jDate(date)

    args = filter_none_args(args)

    return format_mutation("CreateMusicRecording", args)
Esempio n. 5
0
def mutation_create_music_composition(*,
                                      title: str,
                                      contributor: str,
                                      creator: str,
                                      source: str,
                                      format_: str,
                                      subject: str = None,
                                      language: str = None,
                                      inlanguage: str = None,
                                      name: str = None,
                                      description: str = None,
                                      position: int = None):
    """Returns a mutation for creating a music composition object

    Args:
        {musiccomposition_args}

    Returns:
        The string for the mutation for creating the music composition.

    Raises:
        UnsupportedLanguageException: if ``language`` is not one of the supported languages.
        NotAMimeTypeException: if ``format_`` is not a valid mimetype
    """
    check_required_args(title=title,
                        contributor=contributor,
                        creator=creator,
                        source=source,
                        format_=format_)
    if language and language not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(language)

    if "/" not in format_:
        raise NotAMimeTypeException(format_)

    args = {
        "title": title,
        "contributor": contributor,
        "creator": creator,
        "format": format_,
        "subject": subject,
        "source": source,
        "inLanguage": inlanguage,
        "name": name,
        "description": description,
        "position": position
    }
    if language is not None:
        args["language"] = StringConstant(language.lower())

    args = filter_none_args(args)

    return format_mutation("CreateMusicComposition", args)
Esempio n. 6
0
def mutation_update_music_composition(identifier: str,
                                      *,
                                      title: str = None,
                                      contributor: str = None,
                                      creator: str = None,
                                      source: str = None,
                                      format_: str = None,
                                      subject: str = None,
                                      language: str = None,
                                      inlanguage: str = None,
                                      name: str = None,
                                      description: str = None,
                                      position: int = None):
    """Returns a mutation for updating a MusicComposition object.
    
    Args:
        identifier: The identifier of the MusicComposition in the CE to be updated
        {musiccomposition_args}

    Returns:
        The string for the mutation for updating the music composition.
    Raises:
        UnsupportedLanguageException: if ``language`` is not one of the supported languages.
        NotAMimeTypeException: if ``format_`` is not a valid mimetype
    """

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

    if format_ and "/" not in format_:
        raise NotAMimeTypeException(format_)

    args = {
        "identifier": identifier,
        "title": title,
        "contributor": contributor,
        "creator": creator,
        "subject": subject,
        "source": source,
        "inLanguage": inlanguage,
        "format": format_,
        "name": name,
        "description": description,
        "position": position
    }
    if language is not None:
        args["language"] = StringConstant(language.lower())

    args = filter_none_args(args)

    return format_mutation("UpdateMusicComposition", args)
Esempio n. 7
0
def mutation_update_musicrecording(identifier: str,
                                   *,
                                   title: str = None,
                                   contributor: str = None,
                                   creator: str = None,
                                   source: str = None,
                                   encodingformat: str = None,
                                   format_: str = None,
                                   name: str = None,
                                   language: str = None,
                                   description: str = None,
                                   date: str = None,
                                   subject: str = None):
    """Returns a mutation for updating a MusicRecording object.
    https://schema.org/MusicRecording

    Arguments:
        identifier: The identifier of the MusicRecording in the CE to be updated
        {musicrecording_args}

    Returns:
        The string for the mutation for updating the MusicRecording.
    """
    if format_ is not None and "/" not in format_:
        raise NotAMimeTypeException(format_)

    if language is not None and language not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(language)

    args = {
        "identifier": identifier,
        "title": title,
        "contributor": contributor,
        "creator": creator,
        "source": source,
        "format": format_,
        "name": name,
        "description": description,
        "encodingFormat": encodingformat,
        "subject": subject
    }

    if date is not None:
        args["date"] = _Neo4jDate(date)
    if language is not None:
        args["language"] = StringConstant(language.lower())

    args = filter_none_args(args)

    return format_mutation("UpdateMusicRecording", args)
Esempio n. 8
0
def mutation_create_digitaldocument(*,
                                    title: str,
                                    contributor: str,
                                    creator: str,
                                    source: str,
                                    format_: str,
                                    subject: str = None,
                                    language: str = None,
                                    description: str = None):
    """Returns a mutation for creating a digital document object.

    Arguments:
        {digitaldocument_args}

    Returns:
        The string for the mutation for creating the digital document.

    Raises:
        UnsupportedLanguageException if the input language is not one of the supported languages.
        NotAMimeTypeException: if ``format_`` is not a valid mimetype.
    """
    check_required_args(title=title,
                        contributor=contributor,
                        creator=creator,
                        source=source,
                        format_=format_)
    if language not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(language)

    if "/" not in format_:
        raise NotAMimeTypeException(format_)

    args = {
        "title": title,
        "contributor": contributor,
        "creator": creator,
        "source": source,
        "format": format_,
        "subject": subject,
        "description": description,
    }
    if language is not None:
        args["language"] = StringConstant(language.lower())

    args = filter_none_args(args)

    return format_mutation("CreateDigitalDocument", args)
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)
Esempio n. 10
0
def mutation_update_musicgroup(identifier: str, *, title: str = None, contributor: str = None, creator: str = None,
                               source: str = None, format_: str = None, language: str = None, name: str = None,
                               founding_date: str = None, disolution_date: str = None,
                               description: str = None, image: str = None, publisher: str = None):
    """Returns a mutation for updating a MusicGroup

    Args:
        identifier: The identifier of the musicgroup in the CE to be updated
        {musicgroup_args}
    Returns:
        The string for the mutation for updating the musicgroup.
    Raises:
        UnsupportedLanguageException: if ``language`` is not one of the supported languages.
        ValueError: if ``gender`` is not a value supported by the Ce
        NotAMimeTypeException: if ``format_`` is not a valid mimetype.
    """

    if language and language.lower() not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(language)

    if format_ and "/" not in format_:
        raise NotAMimeTypeException(format_)

    args = {
        "identifier": identifier,
        "title": title,
        "contributor": contributor,
        "creator": creator,
        "source": source,
        "format": format_,
        "name": name,
        "description": description,
        "image": image,
        "publisher": publisher,
    }
    if language is not None:
        args["language"] = StringConstant(language.lower())
    if founding_date is not None:
        args["foundingDate"] = _Neo4jDate(founding_date)
    if disolution_date is not None:
        args["disolutionDate"] = _Neo4jDate(disolution_date)

    args = filter_none_args(args)

    return format_mutation("UpdateMusicGroup", args)
Esempio n. 11
0
def mutation_create_musicgroup(*, title: str, contributor: str, creator: str, source: str, format_: str,
                               language: str = None, name: str = None,
                               founding_date: str = None, disolution_date: str = None,
                               description: str = None, image: str = None, publisher: str = None):
    """Returns a mutation for creating a MusicGroup

    Args:
        {musicgroup_args}
    Returns:
        The string for the mutation for creating the musicgroup.
    Raises:
        UnsupportedLanguageException: if ``language`` is not one of the supported languages.
        NotAMimeTypeException: if ``format_`` is not a valid mimetype.
    """

    check_required_args(title=title, contributor=contributor, creator=creator, source=source, format_=format_)
    if language and language.lower() not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(language)

    if "/" not in format_:
        raise NotAMimeTypeException(format_)

    args = {
        "title": title,
        "contributor": contributor,
        "creator": creator,
        "source": source,
        "format": format_,
        "name": name,
        "description": description,
        "image": image,
        "publisher": publisher,
    }
    if language is not None:
        args["language"] = StringConstant(language.lower())
    if founding_date is not None:
        args["foundingDate"] = _Neo4jDate(founding_date)
    if disolution_date is not None:
        args["disolutionDate"] = _Neo4jDate(disolution_date)

    args = filter_none_args(args)

    return format_mutation("CreateMusicGroup", args)
Esempio n. 12
0
def mutation_create_application(*, name: str, contributor: str, creator: str, source: str, title: str = None,
                                subject: str = None, language: str = None, description: str = None, format_: str = None,
                                softwareversion: str = None):
    """Returns a mutation for creating a software application object
    Arguments:
        name: The name of the software application.
        title: the html title of the page at `source`
        contributor: A person, an organization, or a service responsible for adding the software application. This can be either a name or a base URL.
        creator: The person, organization or service responsible for adding the software application.
        source: The URL of the web resource to be represented by the node.
        subject: The subject associated with the application.
        description: An account of the software application.
        language: The language of the page at `source`. Currently supported languages are en,es,ca,nl,de,fr
        softwareversion: the version of the software
    Returns:
        The string for the mutation for creating the artist.
    Raises:
        UnsupportedLanguageException if the input language is not one of the supported languages.
        NotAMimeTypeException if format_ is not a valid mimetype.
    """

    if language and language not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(language)
    if format_ and "/" not in format_:
        raise NotAMimeTypeException(format_)

    args = {
        "name": name,
        "contributor": contributor,
        "creator": creator,
        "source": source,
        "title": title,
        "subject": subject,
        "description": description,
        "format": format_,
        "softwareVersion": softwareversion
    }
    if language:
        args["language"] = StringConstant(language.lower())

    args = filter_none_args(args)
    return mutation_create(args, CREATE_APPLICATION)
Esempio n. 13
0
def mutation_update_musicplaylist(identifier: str,
                                  *,
                                  title: str,
                                  contributor: str,
                                  creator: str,
                                  source: str,
                                  format_: str,
                                  name: str = None,
                                  language: str = None,
                                  num_tracks: int = None):
    """Returns a mutation for updating a MusicPlaylist object.

    Arguments:
        identifier: The identifier of the MusicPlaylist in the CE to be updated
        {musicplaylist_args}

    Returns:
        The string for the mutation for updating the MusicPlaylist.
    """
    if format_ is not None and "/" not in format_:
        raise NotAMimeTypeException(format_)

    if language is not None and language not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(language)

    args = {
        "identifier": identifier,
        "title": title,
        "contributor": contributor,
        "creator": creator,
        "source": source,
        "format": format_,
        "name": name,
        "numTracks": num_tracks
    }
    if language is not None:
        args["language"] = StringConstant(language.lower())

    args = filter_none_args(args)

    return format_mutation("UpdateMusicPlaylist", args)
Esempio n. 14
0
def update_annotation_textual_body(identifier: str,
                                   value: str = None,
                                   format_: str = None,
                                   language: str = None):
    """Return a mutation for updating an AnnotationTextualBody.

    Returns:
        A GraphQL Mutation to update an AnnotationTextualBody in the Trompa CE
    """
    check_required_args(identifier=identifier)
    if language and language.lower() not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(language)

    params = {"identifier": identifier, "value": value, "format": format_}
    params = filter_none_args(params)

    if language is not None:
        params["language"] = StringConstant(language.lower())

    return format_mutation(mutationname="UpdateAnnotationTextualBody",
                           args=params)
Esempio n. 15
0
def mutation_create_person(*,
                           title: str,
                           contributor: str,
                           creator: str,
                           source: str,
                           format_: str,
                           language: str = None,
                           name: str = None,
                           family_name: str = None,
                           given_name: str = None,
                           gender: str = None,
                           birth_date: str = None,
                           death_date: str = None,
                           description: str = None,
                           image: str = None,
                           publisher: str = None,
                           honorific_prefix: str = None,
                           honorific_suffix: str = None,
                           job_title: str = None):
    """Returns a mutation for creating a Person

    Args:
        {person_args}
    Returns:
        The string for the mutation for creating the person.
    Raises:
        UnsupportedLanguageException: if ``language`` is not one of the supported languages.
        ValueError: if ``gender`` is not a value supported by the CE
        NotAMimeTypeException: if ``format_`` is not a valid mimetype.
    """

    check_required_args(title=title,
                        contributor=contributor,
                        creator=creator,
                        source=source,
                        format_=format_)
    if language and language.lower() not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(language)

    if gender and gender.lower() not in SUPPORTED_GENDER:
        raise ValueError(f"unexpected value for gender: {gender}")

    if "/" not in format_:
        raise NotAMimeTypeException(format_)

    args = {
        "title": title,
        "contributor": contributor,
        "creator": creator,
        "source": source,
        "format": format_,
        "name": name,
        "familyName": family_name,
        "givenName": given_name,
        "description": description,
        "image": image,
        "publisher": publisher,
        "honorificPrefix": honorific_prefix,
        "honorificSuffix": honorific_suffix,
        "jobTitle": job_title
    }
    if gender is not None:
        args["gender"] = StringConstant(gender.lower())
    if language is not None:
        args["language"] = StringConstant(language.lower())
    if birth_date is not None:
        args["birthDate"] = _Neo4jDate(birth_date)
    if death_date is not None:
        args["deathDate"] = _Neo4jDate(death_date)

    args = filter_none_args(args)

    return format_mutation("CreatePerson", args)
Esempio n. 16
0
def mutation_create_media_object(*,
                                 title: str,
                                 contributor: str,
                                 creator: str,
                                 source: str,
                                 format_: str,
                                 name: str = None,
                                 description: 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):
    """Returns a mutation for creating a media object object.

    Arguments:
        {mediaobject_args}

    Returns:
        The string for the mutation for creating the media object.

    Raises:
        UnsupportedLanguageException if the input language is not one of the supported languages.
    """
    check_required_args(title=title,
                        contributor=contributor,
                        creator=creator,
                        source=source,
                        format_=format_)
    if language is not None and language not in SUPPORTED_LANGUAGES:
        raise UnsupportedLanguageException(language)

    if "/" not in format_:
        raise NotAMimeTypeException(format_)

    if encodingformat is not None and "/" not in encodingformat:
        raise NotAMimeTypeException(encodingformat)

    args = {
        "title": title,
        "contributor": contributor,
        "creator": creator,
        "source": source,
        "format": format_,
        "name": name,
        "description": description,
        "encodingFormat": encodingformat,
        "embedUrl": embedurl,
        "url": url,
        "license": license,
        "contentUrl": contenturl,
        "inLanguage": inlanguage,
    }

    if date is not None:
        args["date"] = _Neo4jDate(date)
    if language is not None:
        args["language"] = StringConstant(language.lower())

    args = filter_none_args(args)

    return format_mutation("CreateMediaObject", args)