void XercesUpdateFactory::completeDeletions(DynamicContext *context) { // e. Finally, for each node marked for deletion by one of the update primitives listed above, let $N be the node that is marked // for deletion, and let $P be its parent node. The following actions are applied: // i. The parent property of $N is set to empty. // ii. If $N is an attribute node, the attributes property of $P is modified to remove $N. // iii. If $N is a non-attribute node, the children property of $P is modified to remove $N. // iv. If $N is an element, attribute, or text node, and $P is an element node, then upd:removeType($P) is invoked. for(DOMNodeSet::iterator i = forDeletion_.begin(); i != forDeletion_.end(); ++i) { DOMNode *domnode = *i; if(domnode->getNodeType() == DOMNode::ATTRIBUTE_NODE) { DOMAttr *attr = (DOMAttr*)domnode; DOMElement *owner = attr->getOwnerElement(); if(owner != 0) { owner->removeAttributeNode(attr); removeType(owner); } } else { DOMNode *parent = domnode->getParentNode(); if(parent != 0) { parent->removeChild(domnode); if(domnode->getNodeType() == DOMNode::ELEMENT_NODE || domnode->getNodeType() == DOMNode::TEXT_NODE || domnode->getNodeType() == DOMNode::CDATA_SECTION_NODE) { removeType(parent); } } } } }
void XercesUpdateFactory::removeType(DOMNode *node) { DOMNode *ancestor = node; // 1. If $N is an element node, its properties are changed as follows: if(node->getNodeType() == DOMNode::ELEMENT_NODE) { // a. If type-name is not equal to xs:untyped, then const XMLCh *typeURI, *typeName; XercesNodeImpl::typeUriAndName(node, typeURI, typeName); if(!XPath2Utils::equals(typeName, DocumentCache::g_szUntyped) || !XPath2Utils::equals(typeURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA)) { // i. type-name is set to xs:anyType XercesSequenceBuilder::setElementTypeInfo((DOMElement *)node, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, SchemaSymbols::fgATTVAL_ANYTYPE); // ii. If the parent of N is an element node, then upd:removeType(parent($N)) is invoked. DOMNode *parent = node->getParentNode(); if(parent && parent->getNodeType() == DOMNode::ELEMENT_NODE) removeType(parent); } // b. string-value is set equal to the concatenated contents of the text node descendants, in document order. // c. typed-value is set equal to the string-value property, as an instance of xs:untypedAtomic. // d. nilled, is-id, and is-idrefs are set to false. // Automatically done by changing the type } // 2. If $N is an attribute node, its properties are changed as follows: else if(node->getNodeType() == DOMNode::ATTRIBUTE_NODE) { // a. type-name is set to xs:untypedAtomic. XercesSequenceBuilder::setAttributeTypeInfo((DOMAttr *)node, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, ATUntypedAtomic::fgDT_UNTYPEDATOMIC); // b. typed-value is set equal to the string-value property, as an instance of xs:untypedAtomic. // c. is-id and is-idrefs are set to false. // Automatically done by changing the type // d. If $N has a parent, upd:removeType(parent($N)) is invoked. ancestor = ((DOMAttr*)node)->getOwnerElement(); if(ancestor) removeType(ancestor); } else return; // 3. The topmost ancestor of $N is marked for revalidation. if(ancestor) { while(ancestor->getParentNode() != 0) ancestor = ancestor->getParentNode(); forRevalidation_.insert(ancestor); } }
void XercesUpdateFactory::applyRename(const PendingUpdate &update, DynamicContext *context) { const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla); DOMNode *domnode = const_cast<DOMNode*>(nodeImpl->getDOMNode()); ATQNameOrDerived *qname = (ATQNameOrDerived*)update.getValue().first().get(); if(domnode->getNodeType() == DOMNode::PROCESSING_INSTRUCTION_NODE) { DOMProcessingInstruction *newPI = domnode->getOwnerDocument()-> createProcessingInstruction(qname->getName(), domnode->getNodeValue()); domnode->getParentNode()->replaceChild(newPI, domnode); domnode = newPI; } else { // If $newName has an implied namespace binding that conflicts with an existing namespace binding // in the namespaces property of $target, a dynamic error is raised [err:XUDY0024]. // If $target has a parent, and $newName has an implied namespace binding that conflicts with a // namespace binding in the namespaces property of parent($target), a dynamic error is raised [err:XUDY0024]. domnode->getOwnerDocument()->renameNode(domnode, qname->getURI(), qname->getName()); if(qname->getURI() != 0 && *qname->getURI() != 0) domnode->setPrefix(qname->getPrefix()); removeType(domnode); } // Deliberately create a new XercesNodeImpl, since the PI is actually // replaced, not just renamed, meaning it is no longer attached to the tree addToPutSet(nodeImpl, &update, context); }
void XercesUpdateFactory::applyReplaceElementContent(const PendingUpdate &update, DynamicContext *context) { const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla); DOMElement *domnode = (DOMElement*)nodeImpl->getDOMNode(); // 1. For each node $C that is a child of $target, the parent property of $C is set to empty. DOMNode *child = domnode->getFirstChild(); while(child != 0) { forDeletion_.insert(child); child = child->getNextSibling(); } const XMLCh *value = update.getValue().first()->asString(context); if(value != 0 && *value != 0) { // 2. The parent property of $text is set to $target. // 3a. children is set to consist exclusively of $text. If $text is an empty sequence, then $target has // no children. // 3b. typed-value and string-value are set to the content property of $text. If $text is an empty sequence, // then typed-value is an empty sequence and string-value is an empty string. domnode->appendChild(domnode->getOwnerDocument()->createTextNode(value)); } // 3c. upd:removeType($target) is invoked. removeType(domnode); addToPutSet(update.getTarget(), &update, context); }
void Player::doDeath(ObjectHolder *objHolder, GameProperties *gameProps, AudioPlayer *audioPlayer, Controller *contrlr, float delta) { Guy::doDeath(objHolder, gameProps, audioPlayer, contrlr, delta); gameProps->removePlayer(); removeType(TYP_DEAD); gameProps->getCam()->removeFollow(this); }
void APCDetailedStats::removeAPCValue(APCHandle* handle, bool expired) { removeType(handle); if (expired) { m_expValues->increment(); } else { m_delValues->increment(); } }
void printerIODestroy(PrinterIO* printerIO) { removeType(printerIO); free(printerIO); thePrinterIO = NULL; }
void APCDetailedStats::updateAPCValue(APCHandle* handle, APCHandle* oldHandle, bool expired) { removeType(oldHandle); addType(handle); if (expired) { m_expValues->increment(); } else { m_replValues->increment(); } }
void printerIoSetType(PrinterType type, const char* fileName) { thePrinterType = type; strcpy(theFileName, fileName); if (thePrinterIO == NULL) { return; } removeType(thePrinterIO); setType(thePrinterIO); }
void XercesUpdateFactory::applyReplaceValue(const PendingUpdate &update, DynamicContext *context) { const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla); DOMNode *domnode = const_cast<DOMNode*>(nodeImpl->getDOMNode()); // 2. If $target is a text, comment, or processing instruction node: content of $target is set to $string-value. domnode->setNodeValue(update.getValue().first()->asString(context)); if(domnode->getNodeType() == DOMNode::ATTRIBUTE_NODE) { // 1. If $target is an attribute node: // a. string-value of $target is set to $string-value. (done above) // b. upd:removeType($target) is invoked. removeType(domnode); } else if(domnode->getNodeType() == DOMNode::TEXT_NODE || domnode->getNodeType() == DOMNode::CDATA_SECTION_NODE) { // 3. If $target is a text node, upd:removeType(parent($target)) is invoked. if(domnode->getParentNode() != 0) removeType(domnode->getParentNode()); } addToPutSet(update.getTarget(), &update, context); }
void XercesUpdateFactory::applyReplaceAttribute(const PendingUpdate &update, DynamicContext *context) { const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla); DOMAttr *domnode = (DOMAttr*)nodeImpl->getDOMNode(); Node::Ptr parentNode = nodeImpl->dmParent(context); DOMElement *element = domnode->getOwnerElement(); DOMDocument *doc = element->getOwnerDocument(); bool untyped = parentNode->dmNodeKind() == Node::element_string && XPath2Utils::equals(parentNode->getTypeName(), DocumentCache::g_szUntyped) && XPath2Utils::equals(parentNode->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA); Result children = update.getValue(); Item::Ptr item; while((item = children->next(context)).notNull()) { const XercesNodeImpl *childImpl = (const XercesNodeImpl*)item->getInterface(Item::gXQilla); DOMNode *newChild = importNodeFix(doc, const_cast<DOMNode*>(childImpl->getDOMNode()), /*deep*/true); // 1. Error checks: // a. If the QNames of any two attribute nodes in $replacement have implied namespace bindings that conflict with // each other, a dynamic error is raised [err:XUDY0024]. // b. If the QName of any attribute node in $replacement has an implied namespace binding that conflicts with a // namespace binding in the "namespaces" property of parent($target), a dynamic error is raised [err:XUDY0024]. // Checks performed by UpdateFactory // 2b. If the type-name property of parent($target) is xs:untyped, then upd:setToUntyped() is invoked // on each element node in $replacement. if(!untyped) setTypes(newChild, childImpl->getDOMNode()); // 2a. For each node in $replacement, the parent property is set to parent($target). // 4a. If $target is an attribute node, the attributes property of parent($target) is modified by removing $target // and adding the nodes in $replacement (if any). // 4b. If $target is an attribute node, the namespaces property of parent($target) is modified to include namespace // bindings for any attribute namespace prefixes in $replacement that did not already have bindings. element->setAttributeNode((DOMAttr*)newChild); } // 3a. $target is marked for deletion. forDeletion_.insert(domnode); // 4d. upd:removeType(parent($target)) is invoked. removeType(element); // Use parentNode, since the attr replace could have removed the original attr addToPutSet(parentNode, &update, context); }
void XercesUpdateFactory::applyInsertAfter(const PendingUpdate &update, DynamicContext *context) { const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla); DOMNode *domnode = const_cast<DOMNode*>(nodeImpl->getDOMNode()); DOMNode *before = domnode->getNextSibling(); Node::Ptr parentNode = nodeImpl->dmParent(context); DOMNode *parent = domnode->getParentNode(); DOMDocument *doc = const_cast<DOMDocument*>(XPath2Utils::getOwnerDoc(domnode)); bool untyped = parentNode->dmNodeKind() == Node::element_string && XPath2Utils::equals(parentNode->getTypeName(), DocumentCache::g_szUntyped) && XPath2Utils::equals(parentNode->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA); bool containsElementOrText = false; Result children = update.getValue(); Item::Ptr item; while((item = children->next(context)).notNull()) { const XercesNodeImpl *childImpl = (const XercesNodeImpl*)item->getInterface(Item::gXQilla); DOMNode *newChild = importNodeFix(doc, const_cast<DOMNode*>(childImpl->getDOMNode()), /*deep*/true); if(childImpl->dmNodeKind() == Node::element_string || childImpl->dmNodeKind() == Node::text_string) { containsElementOrText = true; } // If the type-name property of parent($target) is xs:untyped, then upd:setToUntyped() is invoked on each // element or attribute node in $content. if(!untyped) setTypes(newChild, childImpl->getDOMNode()); // For each node in $content, the parent property is set to parent($target). // The children property of parent($target) is modified to add the nodes in $content just before $target, // preserving their order. parent->insertBefore(newChild, before); } // If at least one of the nodes in $content is an element or text node, upd:removeType(parent($target)) is invoked. if(containsElementOrText) { removeType(parent); } addToPutSet(update.getTarget(), &update, context); }
void XercesUpdateFactory::applyReplaceNode(const PendingUpdate &update, DynamicContext *context) { const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla); DOMNode *domnode = const_cast<DOMNode*>(nodeImpl->getDOMNode()); Node::Ptr parentNode = nodeImpl->dmParent(context); DOMNode *parent = domnode->getParentNode(); DOMDocument *doc = const_cast<DOMDocument*>(XPath2Utils::getOwnerDoc(domnode)); bool untyped = parentNode->dmNodeKind() == Node::element_string && XPath2Utils::equals(parentNode->getTypeName(), DocumentCache::g_szUntyped) && XPath2Utils::equals(parentNode->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA); Result children = update.getValue(); Item::Ptr item; while((item = children->next(context)).notNull()) { const XercesNodeImpl *childImpl = (const XercesNodeImpl*)item->getInterface(Item::gXQilla); DOMNode *newChild = importNodeFix(doc, const_cast<DOMNode*>(childImpl->getDOMNode()), /*deep*/true); // 1b. If the type-name property of parent($target) is xs:untyped, then upd:setToUntyped() is invoked // on each element node in $replacement. if(!untyped) setTypes(newChild, childImpl->getDOMNode()); // 1a. For each node in $replacement, the parent property is set to parent($target). // 3b. If $target is an element, text, comment, or processing instruction node, the children property // of parent($target) is modified to add the nodes in $replacement just before $target, preserving // their order. parent->insertBefore(newChild, domnode); } // 2a. $target is marked for deletion. forDeletion_.insert(domnode); // 3c. upd:removeType(parent($target)) is invoked. removeType(parent); addToPutSet(update.getTarget(), &update, context); }
void XercesUpdateFactory::applyInsertAttributes(const PendingUpdate &update, DynamicContext *context) { const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla); DOMElement *element = (DOMElement*)nodeImpl->getDOMNode(); DOMDocument *doc = const_cast<DOMDocument*>(XPath2Utils::getOwnerDoc(element)); bool untyped = nodeImpl->dmNodeKind() == Node::element_string && XPath2Utils::equals(nodeImpl->getTypeName(), DocumentCache::g_szUntyped) && XPath2Utils::equals(nodeImpl->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA); Result children = update.getValue(); Item::Ptr item; while((item = children->next(context)).notNull()) { const XercesNodeImpl *childImpl = (const XercesNodeImpl*)item->getInterface(Item::gXQilla); DOMNode *newChild = importNodeFix(doc, const_cast<DOMNode*>(childImpl->getDOMNode()), /*deep*/true); // 1. Error checks: // a. If the QNames of any two attribute nodes in $content have implied namespace bindings that conflict with each other, // a dynamic error is raised [err:XUDY0024]. // b. If the QName of any attribute node in $content has an implied namespace binding that conflicts with a namespace // binding in the "namespaces" property of $target, a dynamic error is raised [err:XUDY0024]. // Checks performed by UpdateFactory // If the type-name property of $target is xs:untyped, then upd:setToUntyped($A) is invoked. if(!untyped) setTypes(newChild, childImpl->getDOMNode()); // The parent property of $A is set to $target. // attributes: Modified to include the nodes in $content. element->setAttributeNode((DOMAttr*)newChild); } // upd:removeType($target) is invoked. removeType(element); addToPutSet(update.getTarget(), &update, context); }
void OntologyUpdater::start() { QApplication::processEvents(); Soprano::Model *m_mainModel; bool m_nepomukInited = Utilities::nepomukInited(); if (m_nepomukInited) { m_mainModel = Nepomuk2::ResourceManager::instance()->mainModel(); } else { return; } m_stopUpdate = false; MediaVocabulary mediaVocabulary; //Update audio QString queryPrefix = QString("PREFIX xesam: <%1> " "PREFIX rdf: <%2> " "PREFIX xls: <%3> " "PREFIX nmm: <http://www.semanticdesktop.org/ontologies/nmm#> " "PREFIX nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#> " "PREFIX nfo: <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#> ") .arg(Soprano::Vocabulary::Xesam::xesamNamespace().toString()) .arg(Soprano::Vocabulary::RDF::rdfNamespace().toString()) .arg(Soprano::Vocabulary::XMLSchema::xsdNamespace().toString()); QString queryStr = queryPrefix + QString("SELECT ?r " "WHERE { {?r rdf:type <http://www.semanticdesktop.org/ontologies/nfo#Audio>} " "UNION " "{?r rdf:type <http://www.semanticdesktop.org/ontologies/nmm#MusicPiece>} " "UNION " "{?r rdf:type <http://www.semanticdesktop.org/ontologies/nmm#DigitalRadio>} " "UNION " "{?r rdf:type <http://www.semanticdesktop.org/ontologies/nmm#MusicAlbum>} " "UNION " "{?r rdf:type <%1>} " "UNION " "{?r rdf:type <%2>} " "UNION " "{?r rdf:type <%3>} }") .arg(mediaVocabulary.typeAudio().toString()) .arg(mediaVocabulary.typeAudioMusic().toString()) .arg(mediaVocabulary.typeMediaStream().toString()); Soprano::QueryResultIterator it = m_mainModel->executeQuery(queryStr, Soprano::Query::QueryLanguageSparql); emit infoMessage(i18n("<b>Updating audio types and properties</b><br>0 items updated...")); QApplication::processEvents(); int i = 0; while( it.next() && !m_stopUpdate) { QApplication::processEvents(); i++; Nepomuk2::Resource resource = Nepomuk2::Resource(it.binding("r").uri()); //Update types QUrl type = QUrl("http://www.semanticdesktop.org/ontologies/nfo#Audio"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeAudio())) { resource.addType(mediaVocabulary.typeAudio()); } } type = QUrl("http://www.semanticdesktop.org/ontologies/nmm#MusicPiece"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeAudioMusic())) { resource.addType(mediaVocabulary.typeAudioMusic()); } //Update properties QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#musicAlbum"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.musicAlbum(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#trackNumber"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.musicTrackNumber(), value); } } type = QUrl("http://www.semanticdesktop.org/ontologies/nmm#DigitalRadio"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeMediaStream())) { resource.addType(mediaVocabulary.typeMediaStream()); } } type = QUrl("http://www.semanticdesktop.org/ontologies/nmm#MusicAlbum"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeMusicAlbum())) { resource.addType(mediaVocabulary.typeMusicAlbum()); } } //Update common properties QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/nfo#duration"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.duration(), value); } property = Nepomuk2::Vocabulary::NMM::artwork(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.artwork(), value); } property = Nepomuk2::Vocabulary::NIE::hasLogicalPart(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); if (value.toResource().hasType(Nepomuk2::Vocabulary::NFO::Image())) { resource.removeProperty(property); resource.setProperty(mediaVocabulary.artwork(), value); } } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#genre"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.genre(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#releaseDate"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.releaseDate(), value); } property = Soprano::Vocabulary::Xesam::useCount(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.playCount(), value); } property = Soprano::Vocabulary::Xesam::lastUsed(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.lastPlayed(), value); } emit infoMessage(i18n("<b>Updating audio types and properties</b><br>%1 audio items done...", i)); QApplication::processEvents(); } //Update video queryStr = queryPrefix + QString("SELECT ?r " "WHERE { {?r rdf:type <http://www.semanticdesktop.org/ontologies/nfo#Video>} " "UNION " "{?r rdf:type <http://www.semanticdesktop.org/ontologies/nmm#Movie>} " "UNION " "{?r rdf:type <http://www.semanticdesktop.org/ontologies/nmm#TVShow>} " "UNION " "{?r rdf:type <http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#TVSeries>} " "UNION " "{?r rdf:type <%1>} " "UNION " "{?r rdf:type <%2>} " "UNION " "{?r rdf:type <%3>} }") .arg(mediaVocabulary.typeVideo().toString()) .arg(mediaVocabulary.typeVideoMovie().toString()) .arg(mediaVocabulary.typeVideoTVShow().toString()); it = m_mainModel->executeQuery(queryStr, Soprano::Query::QueryLanguageSparql); emit infoMessage(i18n("<b>Updating audio types and properties</b><br>0 items updated...")); QApplication::processEvents(); i = 0; while( it.next() && !m_stopUpdate) { QApplication::processEvents(); i++; Nepomuk2::Resource resource = Nepomuk2::Resource(it.binding("r").uri()); //Update types QUrl type = QUrl("http://www.semanticdesktop.org/ontologies/nfo#Video"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeVideo())) { resource.addType(mediaVocabulary.typeVideo()); } } type = QUrl("http://www.semanticdesktop.org/ontologies/nmm#Movie"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeVideoMovie())) { resource.addType(mediaVocabulary.typeVideoMovie()); } //Update properties QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#synopsis"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoSynopsis(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#writer"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoWriter(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#actor"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoActor(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#director"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoDirector(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#producer"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoProducer(), value); } } type = QUrl("http://www.semanticdesktop.org/ontologies/nmm#TVShow"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeVideoTVShow())) { resource.addType(mediaVocabulary.typeVideoTVShow()); } //Update properties QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#series"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoSeries(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#synopsis"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoSynopsis(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#season"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoSeason(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#episodeNumber"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoEpisodeNumber(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#writer"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoWriter(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#actor"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoActor(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#director"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoDirector(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#producer"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoProducer(), value); } } type = QUrl("http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#TVSeries"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeTVSeries())) { resource.addType(mediaVocabulary.typeTVSeries()); } } //Update common properties QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/nfo#duration"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.duration(), value); } property = Nepomuk2::Vocabulary::NMM::artwork(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.artwork(), value); } property = Nepomuk2::Vocabulary::NIE::hasLogicalPart(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); if (value.toResource().hasType(Nepomuk2::Vocabulary::NFO::Image())) { resource.removeProperty(property); resource.setProperty(mediaVocabulary.artwork(), value); } } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#genre"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.genre(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#releaseDate"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.releaseDate(), value); } property = Soprano::Vocabulary::Xesam::useCount(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.playCount(), value); } property = Soprano::Vocabulary::Xesam::lastUsed(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.lastPlayed(), value); } emit infoMessage(i18n("<b>Updating video types and properties</b><br>%1 video items done...", i)); QApplication::processEvents(); } //Fix screwed up properties MediaQuery query; QStringList bindings; bindings.append(mediaVocabulary.mediaResourceBinding()); bindings.append(mediaVocabulary.ratingBinding()); query.select(bindings, MediaQuery::Distinct); query.startWhere(); query.addCondition(mediaVocabulary.hasTypeAnyAudio(MediaQuery::Required)); query.addCondition(mediaVocabulary.hasRating(MediaQuery::Required, 10, MediaQuery::GreaterThan)); query.endWhere(); it = m_mainModel->executeQuery(query.query(), Soprano::Query::QueryLanguageSparql); emit infoMessage(i18n("<b>Updating audio types and properties</b><br>0 items updated...")); QApplication::processEvents(); i = 0; while( it.next() && !m_stopUpdate) { QApplication::processEvents(); i++; Nepomuk2::Resource resource = Nepomuk2::Resource(it.binding("r").uri()); QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/2007/08/15/nao#numericRating"); if (resource.hasProperty(property)) { int rating = resource.property(property).toInt(); if (rating > 10) { resource.removeProperty(property); } } emit infoMessage(i18n("<b>Cleaning up erroneous audio properties</b><br>%1 audio items done...", i)); QApplication::processEvents(); } MediaQuery query1; bindings.clear(); bindings.append(mediaVocabulary.mediaResourceBinding()); bindings.append(mediaVocabulary.ratingBinding()); query1.select(bindings, MediaQuery::Distinct); query1.startWhere(); query1.addCondition(mediaVocabulary.hasTypeAnyVideo(MediaQuery::Required)); query1.addCondition(mediaVocabulary.hasRating(MediaQuery::Required, 10, MediaQuery::GreaterThan)); query1.endWhere(); it = m_mainModel->executeQuery(query.query(), Soprano::Query::QueryLanguageSparql); emit infoMessage(i18n("<b>Updating audio types and properties</b><br>0 items updated...")); QApplication::processEvents(); i = 0; while( it.next() && !m_stopUpdate) { QApplication::processEvents(); i++; Nepomuk2::Resource resource = Nepomuk2::Resource(it.binding("r").uri()); QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/2007/08/15/nao#numericRating"); if (resource.hasProperty(property)) { int rating = resource.property(property).toInt(); if (rating > 10) { resource.removeProperty(property); } } emit infoMessage(i18n("<b>Cleaning up erroneous video properties</b><br>%1 video items done...", i)); QApplication::processEvents(); } if (!m_stopUpdate) { emit infoMessage(i18n("<b>Update complete.</b>")); } else { emit infoMessage(i18n("<b>Update stopped.</b>")); } emit done(); }