DialogueScript supports working with data entity collections (lists and sets) as attributes, storing automatically their names as references into attribute values (due to technical reasons, data entities cannot be stored directly). Data class must implement NamedEntity interface to provide name property used by entity collection attribute delegate as instance reference.
Scopes turn, session and user are supported (community not yet). Following delegate functions are provided, requiring data entity collection as first and optional second namespace parameters
turnEntityListAttribute, sessionEntityListAttribute and userEntityListAttribute
turnEntitySetAttribute, sessionEntitySetAttribute and userEntitySetAttribute
val movies by loader<List<Movie>>("./resources/movies")
5
val likedMovies byuserEntityListAttribute(movies)
6
7
// functional code
8
val movie = movies.similarTo(input,{ name },0.5)
9
if(movie !=null)
10
likedMovies.add()
11
12
// response
13
You like #{likedMovies.list{ name }, subj ="movie"}.
Copied!
Name should be considered as primary key thus unique and not changing in time. If your data class define different data suitable to be used as unique name, you can provide it via getter, see following example.1