Re: [SMW-devel] Problem with storing semantic attributes in a parserhook
) it fetches the data again from the external DB and now uses SMWWriter to write/update the #set statements on the 'cache sub-page' which keeps the properties 'permanently' stored. This procedure seems to work so far quite well. Gu On Tue, 21 Dec 2010 18:08:19 -0500, Laurent Alquier laur...@alquier.org mailto:laur...@alquier.org wrote: I have been playing with ideas from this thread to do the same thing - add predefined properties from an extension. I came down to this basic code to add user defined properties (based on a predefined string $propertyName and a calculated value from my extension $value) $property = SMWPropertyValue::makeUserProperty( $propertyName ); $dv = SMWDataValueFactory::newPropertyObjectValue( $property, $value ); SMWParseData::getSMWData( $parser )-addPropertyObjectValue( $property, $dv ); I am also using the 'ParserAfterTidy' hook since it seems more appropriate to my extension is doing (add semantic annotations for authors of a page). At this point, my problem is this : 1- If I use this code as-is, no value seems to be saved for this page 2- If I use SMWParseData::storeData as indicated above, I lose some properties since storeData assumes parsing has been done when it is called. 3- If I use a direct access to the store by replacing : SMWParseData::getSMWData( $parser ) by : smwfGetStore()-getSemanticData($wgTitle) , values are saved but they get wiped out at the next refresh job. My question (and I assume, the original question as well) : How do I go from this user property code to saved values that will persist after a refresh ? Based on Markus recommendation, I did check the custom properties added by SME_ParseData and it seems that nothing more is needed than what I have above. Any insight ? code sample ? nudge in any direction ? :) - Laurent On Thu, Nov 4, 2010 at 4:51 AM, Harwarth, Stefan (Bundeswehr) stefan.harwa...@cassidian.com mailto:stefan.harwa...@cassidian.com wrote: Using SMWParseData::storeData at the end of my parserhook solves the problem with the data that I generate, but now any other semantic data contained in the rest of the article is discarded... I guess it's because of what the documentation for storeData says, that the parsing is assumed to be complete. So this is not the fix for my problem :( Stefan -Original Message- From: zehetner [mailto:zehet...@molgen.mpg.de mailto:zehet...@molgen.mpg.de] Sent: Monday, November 01, 2010 10:24 AM To: Harwarth, Stefan (Bundeswehr) Cc: semediawiki-devel@lists.sourceforge.net mailto:semediawiki-devel@lists.sourceforge.net Subject: Re: [SMW-devel] Problem with storing semantic attributes in a parserhook I use SMWParseData::addProperty( $property, $prop_val, false, $wgParser, true ); SMWParseData::storeData( $wgParser-getOutput(), $title, false ); which seems to work so far ok to store properties generated within an extension (although it might not be the correct or official way to do it) $property is a string with the property name, $prop_value the value of the property (in case of multi-valued properties a string like e.g. 'p1;p2;;p3') and $title a title object. Cheers, Gu On Fri, 29 Oct 2010 16:21:03 +0200, Harwarth, Stefan (Bundeswehr) stefan.harwa...@cassidian.com mailto:stefan.harwa...@cassidian.com wrote: Hi, I'm working on an Mediawiki extension that uses the SMWData::addProperty function to store semantic data inside a parser hook function, which is working perfectly when saving a page. But when I use the ApprovedRevs extension to approve the revision of an article, my semantic data isn't stored, even though
Re: [SMW-devel] Problem with storing semantic attributes in a parserhook
Hi, I used initially also the addProperty/storeData method and run into the same problem. But SMW updates its store and as no property declarations are on the page the stored properties get lost during the update. I therefore switched to using the SMWWriter extension to store property values retrieved by my parser function from an external DB 'permanently' on a 'cache sub-page' of the actual page (which always includes this subpage). If the cache has expired the values are fetched again from the external DB and SMWWriter updates the #set statements on the 'cache sub-page'. Only during the initial creation of the pages (via a script) I initially store the properties via the SMWParseData::addProperty and SMWParseData::storeData method in order to have the property values immediatly available for statistical SMW queries. The page itself contains a call to the parser function (which retrieves the external data) and the also created 'cache subpage' is left empty. (Note as the page also contains some Category declarations I have also to manually update the SMW tables to store the category information as otherwise MW knows about them but not SMW and #ask queries don't work as expected). When the page is actually shown in the wiki the parser function checks the content of the 'cache-subpage' and if it's empty (or the cache time is expired) it fetches the data again from the external DB and now uses SMWWriter to write/update the #set statements on the 'cache sub-page' which keeps the properties 'permanently' stored. This procedure seems to work so far quite well. Gu On Tue, 21 Dec 2010 18:08:19 -0500, Laurent Alquier laur...@alquier.org wrote: I have been playing with ideas from this thread to do the same thing - add predefined properties from an extension. I came down to this basic code to add user defined properties (based on a predefined string $propertyName and a calculated value from my extension $value) $property = SMWPropertyValue::makeUserProperty( $propertyName ); $dv = SMWDataValueFactory::newPropertyObjectValue( $property, $value ); SMWParseData::getSMWData( $parser )-addPropertyObjectValue( $property, $dv ); I am also using the 'ParserAfterTidy' hook since it seems more appropriate to my extension is doing (add semantic annotations for authors of a page). At this point, my problem is this : 1- If I use this code as-is, no value seems to be saved for this page 2- If I use SMWParseData::storeData as indicated above, I lose some properties since storeData assumes parsing has been done when it is called. 3- If I use a direct access to the store by replacing : SMWParseData::getSMWData( $parser ) by : smwfGetStore()-getSemanticData($wgTitle) , values are saved but they get wiped out at the next refresh job. My question (and I assume, the original question as well) : How do I go from this user property code to saved values that will persist after a refresh ? Based on Markus recommendation, I did check the custom properties added by SME_ParseData and it seems that nothing more is needed than what I have above. Any insight ? code sample ? nudge in any direction ? :) - Laurent On Thu, Nov 4, 2010 at 4:51 AM, Harwarth, Stefan (Bundeswehr) stefan.harwa...@cassidian.com wrote: Using SMWParseData::storeData at the end of my parserhook solves the problem with the data that I generate, but now any other semantic data contained in the rest of the article is discarded... I guess it's because of what the documentation for storeData says, that the parsing is assumed to be complete. So this is not the fix for my problem :( Stefan -Original Message- From: zehetner [mailto:zehet...@molgen.mpg.de] Sent: Monday, November 01, 2010 10:24 AM To: Harwarth, Stefan (Bundeswehr) Cc: semediawiki-devel@lists.sourceforge.net Subject: Re: [SMW-devel] Problem with storing semantic attributes in a parserhook I use SMWParseData::addProperty( $property, $prop_val, false, $wgParser, true ); SMWParseData::storeData( $wgParser-getOutput(), $title, false ); which seems to work so far ok to store properties generated within an extension (although it might not be the correct or official way to do it) $property is a string with the property name, $prop_value the value of the property (in case of multi-valued properties a string like e.g. 'p1;p2;;p3') and $title a title object. Cheers, Gu On Fri, 29 Oct 2010 16:21:03 +0200, Harwarth, Stefan (Bundeswehr) stefan.harwa...@cassidian.com wrote: Hi, I'm working on an Mediawiki extension that uses the SMWData::addProperty function to store semantic data inside a parser hook function, which is working perfectly when saving a page. But when I use the ApprovedRevs extension to approve the revision of an article, my semantic data isn't stored, even though the call to addProperty is executed and a valid DataValue
Re: [SMW-devel] Problem with storing semantic attributes in a parserhook
Thanks for the reply. I still can't believe there isn't a more straightforward way to do this. Special properties such as Category and Last modified date are also not included in the page and yet, they manage to be updated on refresh and during jobs. The approach I am taking is to use a special tag to trigger the update of my special properties. I can get it to work when the tag is declared directly in the page, but I am running into issues when I have that tag inside a template (which is necessary in order to avoid having to manually add the tag everywhere I want to have the properties calculated. I will keep looking and let you know if I find a simpler way. - Laurent On Wed, Dec 22, 2010 at 5:45 AM, zehetner zehet...@molgen.mpg.de wrote: Hi, I used initially also the addProperty/storeData method and run into the same problem. But SMW updates its store and as no property declarations are on the page the stored properties get lost during the update. I therefore switched to using the SMWWriter extension to store property values retrieved by my parser function from an external DB 'permanently' on a 'cache sub-page' of the actual page (which always includes this subpage). If the cache has expired the values are fetched again from the external DB and SMWWriter updates the #set statements on the 'cache sub-page'. Only during the initial creation of the pages (via a script) I initially store the properties via the SMWParseData::addProperty and SMWParseData::storeData method in order to have the property values immediatly available for statistical SMW queries. The page itself contains a call to the parser function (which retrieves the external data) and the also created 'cache subpage' is left empty. (Note as the page also contains some Category declarations I have also to manually update the SMW tables to store the category information as otherwise MW knows about them but not SMW and #ask queries don't work as expected). When the page is actually shown in the wiki the parser function checks the content of the 'cache-subpage' and if it's empty (or the cache time is expired) it fetches the data again from the external DB and now uses SMWWriter to write/update the #set statements on the 'cache sub-page' which keeps the properties 'permanently' stored. This procedure seems to work so far quite well. Gu On Tue, 21 Dec 2010 18:08:19 -0500, Laurent Alquier laur...@alquier.org wrote: I have been playing with ideas from this thread to do the same thing - add predefined properties from an extension. I came down to this basic code to add user defined properties (based on a predefined string $propertyName and a calculated value from my extension $value) $property = SMWPropertyValue::makeUserProperty( $propertyName ); $dv = SMWDataValueFactory::newPropertyObjectValue( $property, $value ); SMWParseData::getSMWData( $parser )-addPropertyObjectValue( $property, $dv ); I am also using the 'ParserAfterTidy' hook since it seems more appropriate to my extension is doing (add semantic annotations for authors of a page). At this point, my problem is this : 1- If I use this code as-is, no value seems to be saved for this page 2- If I use SMWParseData::storeData as indicated above, I lose some properties since storeData assumes parsing has been done when it is called. 3- If I use a direct access to the store by replacing : SMWParseData::getSMWData( $parser ) by : smwfGetStore()-getSemanticData($wgTitle) , values are saved but they get wiped out at the next refresh job. My question (and I assume, the original question as well) : How do I go from this user property code to saved values that will persist after a refresh ? Based on Markus recommendation, I did check the custom properties added by SME_ParseData and it seems that nothing more is needed than what I have above. Any insight ? code sample ? nudge in any direction ? :) - Laurent On Thu, Nov 4, 2010 at 4:51 AM, Harwarth, Stefan (Bundeswehr) stefan.harwa...@cassidian.com wrote: Using SMWParseData::storeData at the end of my parserhook solves the problem with the data that I generate, but now any other semantic data contained in the rest of the article is discarded... I guess it's because of what the documentation for storeData says, that the parsing is assumed to be complete. So this is not the fix for my problem :( Stefan -Original Message- From: zehetner [mailto:zehet...@molgen.mpg.de] Sent: Monday, November 01, 2010 10:24 AM To: Harwarth, Stefan (Bundeswehr) Cc: semediawiki-devel@lists.sourceforge.net Subject: Re: [SMW-devel] Problem with storing semantic attributes in a parserhook I use SMWParseData::addProperty( $property, $prop_val, false, $wgParser, true ); SMWParseData::storeData( $wgParser-getOutput(), $title, false ); which seems
Re: [SMW-devel] Problem with storing semantic attributes in a parserhook
the documentation for storeData says, that the parsing is assumed to be complete. So this is not the fix for my problem :( Stefan -Original Message- From: zehetner [mailto:zehet...@molgen.mpg.de] Sent: Monday, November 01, 2010 10:24 AM To: Harwarth, Stefan (Bundeswehr) Cc: semediawiki-devel@lists.sourceforge.net Subject: Re: [SMW-devel] Problem with storing semantic attributes in a parserhook I use SMWParseData::addProperty( $property, $prop_val, false, $wgParser, true ); SMWParseData::storeData( $wgParser-getOutput(), $title, false ); which seems to work so far ok to store properties generated within an extension (although it might not be the correct or official way to do it) $property is a string with the property name, $prop_value the value of the property (in case of multi-valued properties a string like e.g. 'p1;p2;;p3') and $title a title object. Cheers, Gu On Fri, 29 Oct 2010 16:21:03 +0200, Harwarth, Stefan (Bundeswehr) stefan.harwa...@cassidian.com wrote: Hi, I'm working on an Mediawiki extension that uses the SMWData::addProperty function to store semantic data inside a parser hook function, which is working perfectly when saving a page. But when I use the ApprovedRevs extension to approve the revision of an article, my semantic data isn't stored, even though the call to addProperty is executed and a valid DataValue object is returned. For debugging reasons I added regular semantic markup, so that my page looks like the following: [[Property1::Value1]] {{#set:Property2=Value2}} mystuffSome text/mystuff The first two property values are stored when I approve a revision of this article and my parserhook is called, only that the properties that I create via addProperty() don't appear in the factbox and in queries :( Do I need to call any other functions besides addProperty? I tried SMWOuputs::commitToParser, but that didn't help.. Regards, Stefan -- The Next 800 Companies to Lead America's Growth: New Video Whitepaper David G. Thomson, author of the best-selling book Blueprint to a Billion shares his insights and actions to help propel your business during the next growth cycle. Listen Now! http://p.sf.net/sfu/SAP-dev2dev ___ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel -- - Laurent Alquier http://www.linfa.net -- - Laurent Alquier http://www.linfa.net -- Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl___ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
Re: [SMW-devel] Problem with storing semantic attributes in a parserhook
I have been playing with ideas from this thread to do the same thing - add predefined properties from an extension. I came down to this basic code to add user defined properties (based on a predefined string $propertyName and a calculated value from my extension $value) $property = SMWPropertyValue::makeUserProperty( $propertyName ); $dv = SMWDataValueFactory::newPropertyObjectValue( $property, $value ); SMWParseData::getSMWData( $parser )-addPropertyObjectValue( $property, $dv ); I am also using the 'ParserAfterTidy' hook since it seems more appropriate to my extension is doing (add semantic annotations for authors of a page). At this point, my problem is this : 1- If I use this code as-is, no value seems to be saved for this page 2- If I use SMWParseData::storeData as indicated above, I lose some properties since storeData assumes parsing has been done when it is called. 3- If I use a direct access to the store by replacing : SMWParseData::getSMWData( $parser ) by : smwfGetStore()-getSemanticData($wgTitle) , values are saved but they get wiped out at the next refresh job. My question (and I assume, the original question as well) : How do I go from this user property code to saved values that will persist after a refresh ? Based on Markus recommendation, I did check the custom properties added by SME_ParseData and it seems that nothing more is needed than what I have above. Any insight ? code sample ? nudge in any direction ? :) - Laurent On Thu, Nov 4, 2010 at 4:51 AM, Harwarth, Stefan (Bundeswehr) stefan.harwa...@cassidian.com wrote: Using SMWParseData::storeData at the end of my parserhook solves the problem with the data that I generate, but now any other semantic data contained in the rest of the article is discarded... I guess it's because of what the documentation for storeData says, that the parsing is assumed to be complete. So this is not the fix for my problem :( Stefan -Original Message- From: zehetner [mailto:zehet...@molgen.mpg.de] Sent: Monday, November 01, 2010 10:24 AM To: Harwarth, Stefan (Bundeswehr) Cc: semediawiki-devel@lists.sourceforge.net Subject: Re: [SMW-devel] Problem with storing semantic attributes in a parserhook I use SMWParseData::addProperty( $property, $prop_val, false, $wgParser, true ); SMWParseData::storeData( $wgParser-getOutput(), $title, false ); which seems to work so far ok to store properties generated within an extension (although it might not be the correct or official way to do it) $property is a string with the property name, $prop_value the value of the property (in case of multi-valued properties a string like e.g. 'p1;p2;;p3') and $title a title object. Cheers, Gu On Fri, 29 Oct 2010 16:21:03 +0200, Harwarth, Stefan (Bundeswehr) stefan.harwa...@cassidian.com wrote: Hi, I'm working on an Mediawiki extension that uses the SMWData::addProperty function to store semantic data inside a parser hook function, which is working perfectly when saving a page. But when I use the ApprovedRevs extension to approve the revision of an article, my semantic data isn't stored, even though the call to addProperty is executed and a valid DataValue object is returned. For debugging reasons I added regular semantic markup, so that my page looks like the following: [[Property1::Value1]] {{#set:Property2=Value2}} mystuffSome text/mystuff The first two property values are stored when I approve a revision of this article and my parserhook is called, only that the properties that I create via addProperty() don't appear in the factbox and in queries :( Do I need to call any other functions besides addProperty? I tried SMWOuputs::commitToParser, but that didn't help.. Regards, Stefan -- The Next 800 Companies to Lead America's Growth: New Video Whitepaper David G. Thomson, author of the best-selling book Blueprint to a Billion shares his insights and actions to help propel your business during the next growth cycle. Listen Now! http://p.sf.net/sfu/SAP-dev2dev ___ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel -- - Laurent Alquier http://www.linfa.net -- Forrester recently released a report on the Return on Investment (ROI) of Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even within 7 months. Over 3 million businesses have gone Google with Google Apps: an online email calendar, and document program that's accessible from your browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew___ Semediawiki-devel mailing list
Re: [SMW-devel] Problem with storing semantic attributes in a parserhook
Using SMWParseData::storeData at the end of my parserhook solves the problem with the data that I generate, but now any other semantic data contained in the rest of the article is discarded... I guess it's because of what the documentation for storeData says, that the parsing is assumed to be complete. So this is not the fix for my problem :( Stefan -Original Message- From: zehetner [mailto:zehet...@molgen.mpg.de] Sent: Monday, November 01, 2010 10:24 AM To: Harwarth, Stefan (Bundeswehr) Cc: semediawiki-devel@lists.sourceforge.net Subject: Re: [SMW-devel] Problem with storing semantic attributes in a parserhook I use SMWParseData::addProperty( $property, $prop_val, false, $wgParser, true ); SMWParseData::storeData( $wgParser-getOutput(), $title, false ); which seems to work so far ok to store properties generated within an extension (although it might not be the correct or official way to do it) $property is a string with the property name, $prop_value the value of the property (in case of multi-valued properties a string like e.g. 'p1;p2;;p3') and $title a title object. Cheers, Gu On Fri, 29 Oct 2010 16:21:03 +0200, Harwarth, Stefan (Bundeswehr) stefan.harwa...@cassidian.com wrote: Hi, I'm working on an Mediawiki extension that uses the SMWData::addProperty function to store semantic data inside a parser hook function, which is working perfectly when saving a page. But when I use the ApprovedRevs extension to approve the revision of an article, my semantic data isn't stored, even though the call to addProperty is executed and a valid DataValue object is returned. For debugging reasons I added regular semantic markup, so that my page looks like the following: [[Property1::Value1]] {{#set:Property2=Value2}} mystuffSome text/mystuff The first two property values are stored when I approve a revision of this article and my parserhook is called, only that the properties that I create via addProperty() don't appear in the factbox and in queries :( Do I need to call any other functions besides addProperty? I tried SMWOuputs::commitToParser, but that didn't help.. Regards, Stefan -- The Next 800 Companies to Lead America's Growth: New Video Whitepaper David G. Thomson, author of the best-selling book Blueprint to a Billion shares his insights and actions to help propel your business during the next growth cycle. Listen Now! http://p.sf.net/sfu/SAP-dev2dev ___ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
[SMW-devel] Problem with storing semantic attributes in a parserhook
Hi, I'm working on an Mediawiki extension that uses the SMWData::addProperty function to store semantic data inside a parser hook function, which is working perfectly when saving a page. But when I use the ApprovedRevs extension to approve the revision of an article, my semantic data isn't stored, even though the call to addProperty is executed and a valid DataValue object is returned. For debugging reasons I added regular semantic markup, so that my page looks like the following: [[Property1::Value1]] {{#set:Property2=Value2}} mystuffSome text/mystuff The first two property values are stored when I approve a revision of this article and my parserhook is called, only that the properties that I create via addProperty() don't appear in the factbox and in queries :( Do I need to call any other functions besides addProperty? I tried SMWOuputs::commitToParser, but that didn't help.. Regards, Stefan -- Nokia and ATT present the 2010 Calling All Innovators-North America contest Create new apps games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev___ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel