return DbFile::insertDataObjectToModel(mi);
}*/
+/* Stores a list of media images to the database.
+ Returns a list of media image id corresponding to the given list of media
+ images inserted to the database or already in the database.
+*/
QList<int> DbMediaImage::storeMediaImages(QList<MediaImage *> images)
{
qDebug() << "Storing media images to database.";
{
qDebug() << "This media image already exists with id " << id;
// this media image is already in the database
- // TODO: what if the name differs?
+ // TODO: what if the name differs? (cannot update to database, since the same media image
+ // might be inside another container
}
else if (id < 0)
{
qDebug() << "Failed inserting media image" << mi->getName();
}
}
- ids.append(id);
+ if (id > 0)
+ ids.append(id);
}
return ids;
}
return -1;
}
+
+/**
+* Stores media image containers, including the media images included
+* to database.
+*/
void DbMediaImageContainer::storeContainers(QList<MediaImageContainer *> lst)
{
qDebug() << "Storing media image containers to database.";
{
qDebug() << "Media image container " << mic->getName();
QList<MediaImage*> images = mic->getMediaImages();
+
+ /* If media image container is already in the db, continue */
if (getMediaImageContainer(mic->getCheckSum()) >= 0)
continue;
+
// this is a new media image container, lets build a list
// of media image id's for this container
QList<int> ids = dbMediaImage->storeMediaImages(images);
if (ids.count() > 0)
{
- // store media image to id
+ // store media image to db
// get last insert id of stored media image
- // link all the ids in ids-list to media image id
+ // link all the media image ids in list to media image container id
}
}
}