Re: [SMW-devel] Matrix result formatter

2011-06-03 Thread Igor Lobanov
Patrick, Yaron,


Thank you for your feedback!

I can see a problem with the 'result format' approach that originally forced me 
to start thinking about separate directive. This is what I refer to as 'inner 
join syndrome', i.e. you will have only those rows and columns in a matrix that 
have at least one relation of interest. In other words there won't be any empty 
rows and columns. So initially it seems that in order to build proper 
relationship matrix one need to specify three queries: rows of interest, 
columns of interest and actual cells. Other approach is to extend query 
expression to support something like OPTIONAL operator in SPARQL, but it 
doesn't seem to be any easier. However, I'll explore this possibility once I 
build up more understanding of how query execution works, so thanks for this 
idea.

As for real world example, here it is. I use SMW as an implementation for 
architectural knowledge base and components repository. There is a lot of stuff 
going on, but in particular I have simple ontology used to relate 
enterprise-wide data and applications. There are two categories: Systems and 
Data. In addition, every System page has a set of internal records 
(form-driven) that relate the System with a particular kind of Data and has 
additional metadata such as type of dependency (create/read/update), middleware 
used to access the data, and some arbitrary comments. What I'd like to produce 
(and I did, albeit in a suboptimal way) is a 'CRUD matrix' with Systems listed 
as rows, kinds of Data as columns and a short summary of the relation. First, 
it's colour-coded: 'create' is blue, 'update' is yellow, 'read' is green. 
Second, there is a link to the middleware page and a comment displayed. All of 
these is provided by custom template that uses parser
 functions. Hope this explanation is clear enough, but I could be more specific.

 
--
Best regards,
Igor Lobanov


>
>From: Yaron Koren 
>To: Patrick Nagel 
>Cc: semediawiki-devel@lists.sourceforge.net
>Sent: Thursday, 2 June 2011, 15:45
>Subject: Re: [SMW-devel] Matrix result formatter
>
>
>Hi Igor,
>
>
>Before I go further, let me note how refreshing it is to hear someone asking 
>for advice on this mailing list before creating a new SMW extension. :) It 
>happens more rarely than you might think.
>
>
>So - Patrick is right that this would ideally be created as a new SMW result 
>format, and ideally a format added to the Semantic Result Formats extension. 
>However - it depends a lot on the complexity of your implementation, whether 
>such a thing is doable.
>
>
>Could you give an example of the "traceability" you would like to illustrate, 
>as a calculation based on various properties and pages? In other words, for a 
>single cell in the matrix, how would it be determined whether to put an "x" 
>there, what color to set it to, etc.? I think that would help a lot in trying 
>to figure out the right approach.
>
>
>-Yaron
>
>
>On Wed, Jun 1, 2011 at 10:36 PM, Patrick Nagel  wrote:
>
>Hi Igor,
>>
>>
>>On 2011-06-02 07:11, Igor Lobanov wrote:
>>> I'm looking for a way to produce matrices out of relations between
>>> arbitrary types of objects/pages in SMW. Simple example would be a
>>> 'traceability matrix' between pages within such categories as 'Business
>>> Requirement' and 'System Requirement'. Constructed matrix would have
>>> business requirements and system requirements as row and column headers
>>> respectively, while actual elements would be either emply (no
>>> traceability) or flagged (traceability exists).
>>>
>>> Good example is provided in the Wikipedia article:
>>> http://en.wikipedia.org/wiki/Traceability_matrix
>>>
>>> More complex example (one that I have in mind) would be based not on a
>>> simple relationship, but on internal objects representing relationships
>>> among various objects with additional scalar properties. In this case,
>>> cell content would be more flexible and somehow derived from the
>>> properties, e.g. color, icons, formatting, etc.
>>>
>>> Next, I'm able to produce such matrices using a moderately complex
>>> incantation based on obscure things like arrays and loops, but it's
>>> O(NxM), needs to be tailored for a particular type of matrix, and look
>>> awful in general.
>>>
>>> I believe that general-purpose matrix/pivot style result formatter for
>>> inline queries would be good for SMW. Moreover, I'd like to try to blow
>>> the dust from my PHP skills and actually produce one. What I'm looking
>>> for is some informed advice on how to approach this one.
>>>
>>> My initial idea is to create an extension that introduces a
>>> {{#pivot...}} instruction that actually does underlying query and
>>> formatting. Does it make sense? Or it is something that can't be built
>>> outside the SMW core?
>>
>>That sounds indeed very useful. I'm just a user of SMW, but I think the
>>best way to implement this would be as an extension similar to Semantic
>>Result Formats, or even better

Re: [SMW-devel] SMW 1.6 entering testing phase

2011-06-03 Thread zehetner
Thanks Markus!

Sorry if I didn't make it clear, the reason why I got __err back was the
erroneous '!' in the mentioned function (although I'm now not sure why none
record properties seemed to work even with the bug?). 
Anyway in the corrected version all work fine.

Cheers,
Gu

On Wed, 01 Jun 2011 17:14:26 +0100, Markus Krötzsch
 wrote:
> On 01/06/11 10:05, zehetner wrote:
>> Hi,
>>
>> for record properties I get from $property->getPropertyTypeID() the
type
>> __err back
> 
> That should not happen. I suppose that your type declaration for such 
> properties reads "[[has type::Record]]". If this is stored correctly, 
> you should get the ID '_rec' as a result. This type is no longer handled

> in a special way in SMW. so I don't know why it would return an error.
> 
>> and this function in includes/datavalues/SMW_DV_Property.php looks
>> strange:
>>
> ...
> 
>>
>> shouldn't it rather be
>>
>>  if ( $this->isValid() ) {
>> instead of
>>  if ( !$this->isValid() ) {
> 
> Yes! Changed in SVN now.
> 
> Markus
> 
>>
>> On Tue, 31 May 2011 16:02:37 +0100, Markus Krötzsch
>>   wrote:
>>> On 30/05/11 11:48, zehetner wrote:
 Hi,

 I'm trying to change my php code to work with SMW 1.6. (MW 1.16.0,
SMW
 1.6
 alpha r89160)
 I updated the DB and data with the SMWAdmin functions. #ask queries
>> seem
 to work ok.

 I use the calls

 $property = SMWPropertyValue::makeUserProperty($propname);
 $ptype = $property->getPropertyTypeID();
 where $propname is the name of a property.

 This seems to be valid in SMW 1.6 as it is used e.g. in file
 includes/parserhooks/SMW_Declare.php
 $property = SMWPropertyValue::makeUserProperty( $propertystring );
 :
 $type = $property->getPropertyTypeID();

 As far as I can see I run into problems when
 function getPropertyTypeID() calls
 function getTypesValue() which calls
 smwfGetStore()->getPropertyValues( $this->getWikiPageValue(), new
 SMWDIProperty( '_TYPE' ) );

 $this->getWikiPageValue() returns a 'SMWWikiPageValue Object' which
in
 function
 getPropertyValues( $subject, SMWDIProperty $property, $requestoptions
=
 null ) is than passed as '$subject' argument to
 $this->getSemanticData( $subject, array(
>> $property->findPropertyTypeID()
 )
 );

 Calling getSemanticData with an 'SMWWikiPageValue Object' as $subject
 causes an empty page because it seems it expects
 a 'SMWDIWikiPage Object' instead in SMW 1.6?

 getWikiPageValue(), however, seems to return for type _wpg always a
 SMWWikiPageValue Object and doesn't know about SMWDIWikiPage
Object???

 As I only submit a property name in my code and the rest are SMW 1.6
 internal functions, I don't know what I can do to avoid this problem.
 Anything on the wiki level?
>>>
>>> Thanks for the report. The code on SVN (r89217) has now been fixed to
>>> avoid this problem.
>>>
>>> Note that SMWPropertyValue::makeUserProperty($propname) should only be
>>> used if the input $propname is indeed some (possibly messy) user
input.
>>> If the name of the property comes from a reliable source, then you can
>>> also format it as a DB key (replace ' ' by '_') and use "new
>>> SMWDIProeprty($dbkey)" to get an SMWDIProperty object right away (in
>>> this case, findPropertyTypeId() is called to get the type id). But for
>>> user input SMWPropertyValue is the right way to go.
>>>
>>> Cheers,
>>>
>>> Markus
>>>
>>>

 On Thu, 26 May 2011 07:40:32 +0100, Markus Krötzsch
wrote:
> On 25/05/11 11:20, zehetner wrote:
>> Hi,
>>
>> regarding
>>> * Type:Record declarations change:
>>> Properties of Type:Record no longer take a list of types, but a
list
 of
>>> properties as their declaration (has fields). This ensures that
 Records
>>> can use all information that is given on Property pages, not just
>> the
>>> type declarations.
>>
>> would there be a foreseeable problem to generate properties with
the
 name
>> of the existing field types e.g Property:string, Property:page,
>> Property:number etc. to keep records functioning in the new SMW
 version?
>> Otherwise having a rather large number of record properties it
would
 mean
>> a lot of typing to change those names in the 'has fields'
>> declarations.
>
> I think this is a good idea. Would it be useful to have one builtin
> property for each registered datatype? This would not be hard to do
>> but
> it would override any existing property declarations for these
labels.
>
> Generating property pages would be a more complex process that would
> need to be triggered explicitly (you cannot do this in the
background
>> on

> every request).
>
> Regards,
>
> Markus
>
>>
>> On Sun, 22 May 2011 16:10:37 +0100, Markus Krötzsch
>> wrote:
>>> Dear SMW