def mutation_sequence_add_listitem_nextitem(listitem_ids: list): """Returns a mutation for adding a sequence of NextItem to an ListItem objects based on the identifiers. (https://schema.org/itemListElement) Arguments: listitem_ids: The list of unique identifier of the ListItems objects. Returns: The string for the mutation for adding a sequence of NextItem to an ListItem objects based on the identifiers. """ check_required_args(listitem_ids=listitem_ids) mutation_list = [] mutationname = "MergeListItemNextItem" pos = 0 while pos + 1 < len(listitem_ids): args = [listitem_ids[pos], listitem_ids[pos + 1]] mutationalias = "MergeListItemNextItemAlias{}".format(pos) mutation_list.append((mutationalias, mutationname, args)) pos += 1 return format_sequence_link_mutation(mutations=mutation_list)
def mutation_sequence_add_itemlist_itemlist_element(itemlist_id: str, element_ids: list): """Returns a mutation for adding a sequence of ThingInterface in an ItemList object based on the identifiers. (https://schema.org/itemListElement) Arguments: itemlist_id: The unique identifier of the ItemList object. element_ids: The list of unique identifiers of the ThingInterface objects. Returns: The string for the mutation for adding a sequence of ThingInterface in an ItemList object based on the identifiers. """ check_required_args(itemlist_id=itemlist_id, element_ids=element_ids) mutation_list = [] mutationname = "MergeItemListItemListElement" for pos, element_id in enumerate(element_ids): args = [itemlist_id, element_id] mutationalias = "MergeItemListItemListElementAlias{}".format(pos) mutation_list.append((mutationalias, mutationname, args)) return format_sequence_link_mutation(mutations=mutation_list)
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)
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)
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)
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)
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)
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)
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)
def mutation_remove_listitem_item(listitem_id: str, item_id: str): """Returns a mutation for removing a Item from a ListItem object based on the identifier. (https://schema.org/item) Arguments: listitem_id: The unique identifier of the ListItem object. item_id: The unique identifier of the Item object. Returns: The string for the mutation for removing a Item from a ListItem object based on the identifier. """ check_required_args(listitem_id=listitem_id, item_id=item_id) return format_link_mutation("RemoveListItemItem", listitem_id, item_id)
def mutation_add_itemlist_itemlist_element(itemlist_id: str, element_id: str): """Returns a mutation for adding a ThingInterface in an ItemList object based on the identifier. (https://schema.org/itemListElement) Arguments: itemlist_id: The unique identifier of the ItemList object. element_id: The unique identifier of the ThingInterface object. Returns: The string for the mutation for adding an ThingInterface in an ItemList object based on the identifier, """ check_required_args(itemlist_id=itemlist_id, element_id=element_id) return format_link_mutation("MergeItemListItemListElement", itemlist_id, element_id)
def mutation_add_listitem_nextitem(listitem_id: str, nextitem_id: str): """Returns a mutation for adding a NextItem to a ListItem object based on the identifier. (https://schema.org/nextItem) Arguments: listitem_id: The unique identifier of the ListItem object. nextitem_id: The unique identifier of the NextItem object. Returns: The string for the mutation for adding a NextItem to a ListItem object based on the identifier. """ check_required_args(listitem_id=listitem_id, nextitem_id=nextitem_id) return format_link_mutation("MergeListItemNextItem", listitem_id, nextitem_id)
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 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)
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)
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)
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)
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)
def create_rating(*, creator: str, bestrating: int, ratingvalue: int = None, worstrating: int = None, ratingexplanation: str = None, additionaltype: str = None): """Return a mutation for making a Rating. A Rating (https://schema.org/Rating) is an evaluation on a numeric scale. Arguments: creator: a URI to the identity of the user who created this DefinedTerm bestrating: The highest value allowed in this rating system ratingvalue: The rating for the content. worstrating (optional): The lowest value allowed in this rating system. If worstRating is omitted, 1 is assumed. ratingexplanation (optional): A freeform text box describing why this rating was given additionaltype (optional): A schema.org additionalType used to categorise this Rating Returns: A GraphQL Mutation to create a Rating in the Trompa CE """ check_required_args(creator=creator, bestrating=bestrating, ratingvalue=ratingvalue) params = { "creator": creator, "ratingValue": ratingvalue, "bestRating": bestrating, "worstRating": worstrating, "ratingExplanation": ratingexplanation, "additionalType": additionaltype } params = filter_none_args(params) return format_mutation(mutationname="CreateRating", args=params)
def mutation_update_itemlist(identifier: str, name: str = None, creator: str = None, itemlistorder: ItemListOrderType = None, description: str = None, contributor: str = None, additionaltype: List[str] = None): """Returns a mutation for updating an ItemList object. (https://schema.org/ItemList) Arguments: identifier: The identifier of the ItemList in the CE to be updated. {itemlist_args} Returns: The string for the mutation for updating the ItemList. """ if itemlistorder is not None and not isinstance(itemlistorder, ItemListOrderType): raise trompace.exceptions.InvalidItemListOrderTypeException( itemlistorder) check_required_args(identifier=identifier) additionaltype = _verify_additional_type(additionaltype) args = { "identifier": identifier, "contributor": contributor, "name": name, "description": description, "creator": creator, "additionalType": additionaltype, } if itemlistorder is not None: args["itemListOrder"] = StringConstant(itemlistorder) args = filter_none_args(args) return format_mutation("UpdateItemList", args)
def update_annotation_motivation( identifier: str, creator: str, title: str, description: str, broader_schema: AnnotationSchemaMotivation = None, broader_url: str = None): """Return a mutation for updating an Annotation motivation """ check_required_args(identifier=identifier) params = { "identifier": identifier, "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="UpdateAnnotationCEMotivation", args=params)
def create_annotation_ce_target(creator: str, field: str = None, fragment: str = None): """Return a mutation for making an AnnotationCETarget. An AnnotationCETarget is a node that can be used for a web Annotation (https://www.w3.org/TR/annotation-model) as the target field, when the target refers to a node that already exists in the CE Arguments: creator: a URI to the identity of the user who created this AnnotationCETaraget field (optional): the field of the node `target` that contains the URL to the target item fragment (optional): If the target is a fragment, the value to be appended to the URL in field Returns: A GraphQL Mutation to create an AnnotationCETarget in the Trompa CE """ check_required_args(creator=creator) params = {"creator": creator, "field": field, "fragment": fragment} params = filter_none_args(params) return format_mutation(mutationname="CreateAnnotationCETarget", args=params)
def mutation_sequence_add_listitem_item(listitem_ids: list, item_ids: list): """Returns a mutation for adding a sequence of ThingInterface in an ListItem objects based on the identifiers. (https://schema.org/itemListElement) Arguments: listitem_ids: The list of unique identifiers of the ListItem objects. item_ids: The list of unique identifiers of the ThingInterface objects. Returns: The string for the mutation for adding a sequence of ThingInterface in an ListItem objects based on the identifiers. """ check_required_args(listitem_ids=listitem_ids, item_ids=item_ids) mutation_list = [] mutationname = "MergeListItemItem" for pos, _ in enumerate(listitem_ids): args = [listitem_ids[pos], item_ids[pos]] mutationalias = "MergeListItemItemAlias{}".format(pos) mutation_list.append((mutationalias, mutationname, args)) return format_sequence_link_mutation(mutations=mutation_list)
def create_defined_term_set(*, creator: str, name: str, additionaltype: List[str], broader_url: str = None, broader_schema: annotation.AnnotationSchemaMotivation = None, image: str = None): """Return a mutation for making a DefinedTermSet. A :schema:`DefinedTermSet` is a group of defined terms, e.g. categories or labels. Arguments: {definedtermset_args} Returns: A GraphQL Mutation to create a DefinedTermSet in the Trompa CE """ check_required_args(creator=creator, name=name, additionaltype=additionaltype) additionaltype = _verify_additional_type(additionaltype) params = {"additionalType": additionaltype, "creator": creator, "name": name, "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="CreateDefinedTermSet", args=params)
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)
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)