예제 #1
0
def mutation_create_itemlist(
        name: str,
        creator: str,
        itemlistorder: ItemListOrderType = ItemListOrderType.ItemListUnordered,
        description: str = None,
        contributor: str = None,
        additionaltype: List[str] = None):
    """Returns a mutation for creating an ItemList object.
    (https://schema.org/ItemList)

    Arguments:
        {itemlist_args}

    Returns:
        The string for the mutation for creating the ItemList.
    """
    if not isinstance(itemlistorder, ItemListOrderType):
        raise trompace.exceptions.InvalidItemListOrderTypeException(
            itemlistorder)
    check_required_args(name=name, creator=creator)
    additionaltype = _verify_additional_type(additionaltype)

    args = {
        "creator": creator,
        "name": name,
        "contributor": contributor,
        "description": description,
        "additionalType": additionaltype
    }
    if itemlistorder:
        args["itemListOrder"] = StringConstant(itemlistorder)

    args = filter_none_args(args)

    return format_mutation("CreateItemList", args)
예제 #2
0
def update_defined_term_set(identifier: str, *, creator: str = None, name: str = None,
                            additionaltype: List[str] = None, broader_url: str = None,
                            broader_schema: annotation.AnnotationSchemaMotivation = None,
                            image: str = None):
    """Return a mutation for updating a DefinedTermSet.

    Arguments:
        identifier: The identifier of the DefinedTermSet in the CE to be updated (:dcterms:`identifier`).
        {definedtermset_args}

    Returns:
        A GraphQL Mutation to update a DefinedTermSet in the Trompa CE
    """

    additionaltype = _verify_additional_type(additionaltype)
    params = {"identifier": identifier,
              "creator": creator,
              "name": name,
              "additionalType": additionaltype,
              "broaderUrl": broader_url,
              "image": image}
    if broader_schema is not None:
        params["broaderMotivation"] = StringConstant(broader_schema.name)
    params = filter_none_args(params)

    return format_mutation(mutationname="UpdateDefinedTermSet", args=params)
예제 #3
0
def mutation_create_listitem(creator: str,
                             name: str = None,
                             contributor: str = None,
                             description: str = None,
                             itemurl: str = None,
                             position: Optional[int] = None):
    """Returns a mutation for creating a ListItem object.
    (https://schema.org/ListItem)

    Arguments:
        {listitem_args}

    Returns:
        The string for the mutation for creating the ListItem.
    """
    check_required_args(creator=creator)
    args = {
        "contributor": contributor,
        "name": name,
        "creator": creator,
        "description": description,
        "itemUrl": itemurl,
        "position": position,
    }

    args = filter_none_args(args)

    return format_mutation("CreateListItem", args)
예제 #4
0
def mutation_update_listitem(identifier: str,
                             creator: str = None,
                             name: str = None,
                             contributor: str = None,
                             description: str = None,
                             itemurl: str = None,
                             position: int = None):
    """Returns a mutation for updating a ListItem object.
    (https://schema.org/ListItem)

    Arguments:
        identifier: The identifier of the ListItem in the CE to be updated.
        {listitem_args}

    Returns:
        The string for the mutation for updating the ListItem.
    """
    args = {
        "identifier": identifier,
        "creator": creator,
        "name": name,
        "contributor": contributor,
        "description": description,
        "itemUrl": itemurl,
        "position": position,
    }

    args = filter_none_args(args)

    return format_mutation("UpdateListItem", args)
예제 #5
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)
예제 #6
0
def create_annotation(creator: str,
                      motivation: AnnotationSchemaMotivation,
                      target_url: str = None,
                      body_url: List[str] = None):
    """Return a mutation for making a web Annotation (https://www.w3.org/TR/annotation-model)

    Arguments:
        creator: a URI to the identity of the user who created this Annotation
        motivation: a AnnotationSchemaMotivation value, or the ID of an AnnotationCEMotivation node
        target_url: if the target is the URL of an external object, the URL
        body_url: if the body is the URL of an external object, the URL

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

    check_required_args(creator=creator, motivation=motivation)
    params = {
        "creator": creator,
        "motivation": StringConstant(motivation.name),
        "targetUrl": target_url,
        "bodyUrl": body_url,
    }
    params = filter_none_args(params)

    return format_mutation(mutationname="CreateAnnotation", args=params)
예제 #7
0
def create_rating_definition(*,
                             creator: str,
                             bestrating: int,
                             worstrating: int,
                             name: str = None):
    """Return a mutation for making a Rating definition.
    A Rating (https://schema.org/Rating) is an evaluation on a numeric scale.
    A Rating definition describes the structure that a rating can take. It is used so that an annotation
    tool can give a title and present an input according to the correct scale (e.g. 1-5 or 1-100).

    This is a helper method that requires a bestrating and worstrating value and automatically sets
    additionaltype to RATING_DEFINITION_ADDITIONAL_TYPE

    A name is recommended if multiple ratings are going to be shown on the same annotator, but isn't necessary.

    """
    check_required_args(creator=creator,
                        bestrating=bestrating,
                        worstrating=worstrating)

    params = {
        "creator": creator,
        "name": name,
        "bestRating": bestrating,
        "worstRating": worstrating,
        "additionalType": RATING_DEFINITION_ADDITIONAL_TYPE
    }

    params = filter_none_args(params)

    return format_mutation(mutationname="CreateRating", args=params)
예제 #8
0
def create_annotation_motivation(
        creator: str,
        title: str,
        description: str,
        broader_schema: AnnotationSchemaMotivation = None,
        broader_url: str = None):
    """Return a mutation for making an Annotation motivation
    A custom motivation should be a special case of one of the standard 13 motivations in
    the web annotation vocabulary (https://www.w3.org/TR/annotation-vocab/#named-individuals),
    or a URL pointing to an external motivation

    Arguments:
        creator: a URI to the identity of the user who created this Motivation
        title: a descriptive name for the motivation
        description: a detailed description of the motivation
        broader_schema: a AnnotationSchemaMotivation value describing what this motivation is
           a special case of
        broader_url: a URL to an oa:Motivation describing what this motivation is a special case of
    """
    params = {
        "creator": creator,
        "title": title,
        "description": description,
        "broaderUrl": broader_url,
    }
    if broader_schema:
        params["broaderMotivation"] = StringConstant(broader_schema.name)
    params = filter_none_args(params)
    return format_mutation(mutationname="CreateAnnotationCEMotivation",
                           args=params)
예제 #9
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)
예제 #10
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)
예제 #11
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)
예제 #12
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)
예제 #13
0
def query_itemlist(identifier: str):
    """Returns a query for querying the database for a ItemList object.
    Arguments:
        identifier: The identifier of the ItemList object in the CE.
    Returns:
        The string for the quereing the ItemList object.
    """

    args = {
        "identifier_in": identifier,
    }

    args = filter_none_args(args)

    return format_itemlist_query("ItemList", args)
예제 #14
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)
예제 #15
0
def query_listitems(identifiers: list = None,
                    return_items_list: list = ["identifier"]):
    """Returns a query for querying the database for a ThingInterface object.
    Arguments:
        identifiers: The list of identifiers of the ThingInterfaces object in the CE.
        return_items_list: A list of item fields that the query must return.
    Returns:
        The string for the quereing the ThingInterface object.
    """

    args = {
        "identifier_in": identifiers,
    }

    args = filter_none_args(args)

    return format_filter_query("ThingInterface", args, return_items_list)
예제 #16
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)
예제 #17
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)
예제 #18
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)
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)
예제 #20
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)
예제 #21
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)
예제 #22
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)
예제 #23
0
def update_annotation_ce_target(identifier: str,
                                target: str = None,
                                field: str = None,
                                fragment: str = None):
    """Return a mutation for updating an AnnotationCETarget.

    Returns:
        A GraphQL Mutation to update an AnnotationCETarget in the Trompa CE
    """
    check_required_args(identifier=identifier)
    params = {
        "identifier": identifier,
        "target": target,
        "field": field,
        "fragment": fragment
    }
    params = filter_none_args(params)

    return format_mutation(mutationname="UpdateAnnotationCETarget",
                           args=params)
예제 #24
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)
예제 #25
0
def update_rating(identifier: str,
                  *,
                  creator: str = None,
                  ratingvalue: int = None,
                  bestrating: int = None,
                  worstrating: int = None,
                  ratingexplanation: str = None,
                  additionaltype: str = None):

    params = {
        "identifier": identifier,
        "creator": creator,
        "ratingValue": ratingvalue,
        "bestRating": bestrating,
        "worstRating": worstrating,
        "ratingExplanation": ratingexplanation,
        "additionalType": additionaltype
    }

    params = filter_none_args(params)
    return format_mutation(mutationname="UpdateRating", args=params)
예제 #26
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)
예제 #27
0
def mutation_update_digitaldocument(identifier: str,
                                    *,
                                    title: str = None,
                                    contributor: str = None,
                                    creator: str = None,
                                    source: str = None,
                                    format_: str = None,
                                    subject: str = None,
                                    language: str = None,
                                    description: str = None):
    """Returns a mutation for updating a digital document object.

    Arguments:
        identifier: The identifier of the media object in the CE to be updated.
        {digitaldocument_args}

    Returns:
        The string for the mutation for creating the artist.

    Raises:
        Assertion error if the input language is not one of the supported languages.
    """

    args = {
        "identifier": identifier,
        "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("UpdateDigitalDocument", args)
예제 #28
0
def update_annotation(identifier: str,
                      target: str = None,
                      motivation: Union[AnnotationSchemaMotivation,
                                        str] = None,
                      body: str = None,
                      creator: str = None):
    """Return a mutation for updating an Annotation.

    Returns:
        A GraphQL Mutation to create an Annotation in the Trompa CE
    """
    check_required_args(identifier=identifier)
    params = {
        "identifier": identifier,
        "target": target,
        "motivation": motivation,
        "body": body,
        "creator": creator
    }
    params = filter_none_args(params)

    return format_mutation(mutationname="UpdateAnnotation", args=params)
예제 #29
0
def update_defined_term(identifier: str, *, creator: str = None, termcode: str = None,
                        additionaltype: List[str] = None, image: str = None):
    """Return a mutation for updating a DefinedTerm.

    Arguments:
        identifier: The identifier of the DefinedTerm in the CE to be updated (:dcterms:`identifier`).
        {definedterm_args}

    Returns:
        A GraphQL Mutation to update a DefinedTerm in the Trompa CE
    """

    additionaltype = _verify_additional_type(additionaltype)
    params = {"identifier": identifier,
              "creator": creator,
              "termCode": termcode,
              "additionalType": additionaltype,
              "image": image}

    params = filter_none_args(params)

    return format_mutation(mutationname="UpdateDefinedTerm", args=params)
예제 #30
0
def create_defined_term(*, creator: str, termcode: str, additionaltype: List[str], image: str = None):
    """Return a mutation for making a DefinedTerm.
    A :schema:`DefinedTerm` is a word, name, acronym, phrase, etc. with a formal definition.
    It is part of a DefinedTermSet.

    Arguments:
        {definedterm_args}

    Returns:
        A GraphQL Mutation to create a DefinedTerm in the Trompa CE
    """
    check_required_args(creator=creator, termcode=termcode, additionaltype=additionaltype)
    additionaltype = _verify_additional_type(additionaltype)

    params = {"additionalType": additionaltype,
              "creator": creator,
              "termCode": termcode,
              "image": image}

    params = filter_none_args(params)

    return format_mutation(mutationname="CreateDefinedTerm", args=params)