createUserProfile static method
Creates a user profile in TTL format following the ontology structure.
Implementation
static String createUserProfile(
String userWebId, {
String? apiKey,
String? dobString,
String? genderString,
List<String>? movieListIds,
}) {
final triples = <URIRef, Map<URIRef, dynamic>>{};
// Create the user resource.
final userResource = URIRef(userWebId);
triples[userResource] = {
rdfType: [owlNS.withAttr('NamedIndividual'), userType],
webId: Literal(userWebId, datatype: xsdNS.withAttr('anyURI')),
rdfsLabel: Literal('|webID=$userWebId|'),
};
// Add API key if provided.
if (apiKey != null && apiKey.isNotEmpty) {
triples[userResource]![hasApiKey] =
moviestarDataNS.withAttr('ApiKey-$apiKey');
}
// Add DOB if provided.
if (dobString != null && dobString.isNotEmpty) {
triples[userResource]![dob] =
Literal(dobString, datatype: xsdNS.withAttr('date'));
}
// Add gender if provided.
if (genderString != null && genderString.isNotEmpty) {
triples[userResource]![gender] = Literal(genderString);
}
// Add movie lists if provided.
if (movieListIds != null && movieListIds.isNotEmpty) {
final movieListRefs = movieListIds
.map((id) => moviestarDataNS.withAttr('MovieList-$id'))
.toList();
triples[userResource]![hasMovieList] = movieListRefs;
}
// Use ontology-compliant namespace bindings.
return tripleMapToTurtle(triples, bindNamespaces: _getOntologyNamespaces());
}