Skip to content

Instantly share code, notes, and snippets.

@hectorcorrea
Last active April 3, 2023 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hectorcorrea/d70e0a7edf88bc97ee7f6725c13cde24 to your computer and use it in GitHub Desktop.
Save hectorcorrea/d70e0a7edf88bc97ee7f6725c13cde24 to your computer and use it in GitHub Desktop.
# =======================================================================
# tagAdd - adds a tag (term) to the dictionary
#
# Usage:
#
# script.execute :in file:/Users/correah/src/mediaflux/tagAdd.tcl :arg -name tagName "tagXX" :arg -name tagDescription "this is the tag XX"
#
# =======================================================================
set log_name "homework-2023-03-24"
if { [info exists "tagName"] && [info exists "tagDescription"]} \
{
server.log :app ${log_name} :event info :msg "Creating tag ${tagName}"
# dictionary.entry.add :term ${tagName} :definition ${tagDescription}
set exist [xvalue exists [dictionary.exists :name hector]]
if { "$exist" != "true" } \
{
dictionary.create :name hector
}
set entryExist [ xvalue exists [ dictionary.entry.exists :dictionary hector :term hello ] ]
if { "$entryExist" != "true" } \
{
dictionary.add :dictionary hector :entry < :term $tagName :definition $tagDescription >
}
} \
else \
{
server.log :app ${log_name} :event error :msg "tagAdd - tagName and/or tagDescription was not received"
error "tagAdd - tagName and/or tagDescription was not received"
}
# =======================================================================
# tagAssign - assigns an existing tag to an asset.
#
# Usage:
#
# script.execute :in file:/Users/correah/src/mediaflux/tagAssign.tcl :arg -name tagName 'tagXX' :arg -name id 1033
#
# =======================================================================
set log_name "homework-2023-03-23"
if { [info exists "tagName"] && [info exists "id"]} \
{
server.log :app ${log_name} :event info :msg "Assigning tag ${tagName} to ${id}"
asset.tag.add :id ${id} :tag < :name -dictionary hector ${tagName} >
} \
else \
{
server.log :app ${log_name} :event error :msg "tagAssign - tagName and/or id was not received"
error "tagAssign - tagName and/or id was not received"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment