Converter problem when using RDF.ID/asString.set

3 views
Skip to first unread message

Mauricio Banduk

unread,
Feb 24, 2012, 8:03:27 AM2/24/12
to sca...@googlegroups.com
Hi guys,

  I'm facing a problem which I believe is simple to solve, maybe I just have not understood how it works..

I have a Vocabulary that looks like this:

object MyVocabulary extends Vocabulary("http://myvocabulary.com#") {
  val Computer       = uriref("Car")
  val ConsumptionEvt = uriref("ConsumtionEvt")
  val consumption    = prop("consumption")
  val timeStamp      = prop("timeStamp")
}

Then I create nodes this way: 

def buildEvent(subjId : String, prop : Property[Int], obj : Node, ts : TypedLiteral) : Graph = {
       Graph(MyVocabulary(subjId) - (
    RDF.Type -> MyVocabulary.Computer,
    RDF.ID   -> objId,
    MyVocabulary.ConsumptionEvt -> Branch(
      consumption -> obj,
      MyVocabulary.timeStamp -> ts
    )
  ))
}

and then add them into the graph using graph = graph ++buildEvent(....)

The problem is that when I try to select all the distinct computers from my graph, I try the following code
val pcs = graph /-/ having(RDF.Type ->MyVocabulary.Computer) / RDF.ID / asString.set

I get the following error:
overloaded method value / with alternatives:
[T](nc: org.scardf.NodeToValueConverter[T])T <and> 
[T](bc: org.scardf.NodeBagConverter[T])T <and> 
(predicate: org.scardf.UriRef)org.scardf.NodeBag cannot be applied to (net.croz.scardf.NodeBagConverter[Set[String]])

I managed with the following code, but I'm sure there's a way to use the scardf lib to do this:

val pcs = graph /-/ having(RDF.Type ->MyVocabulary.Computer) / RDF.ID
for (id <- pcs) yield id.rend

Could anyone give me a hint on it??

Thank you,
Cheers,
Banduk

Hrvoje Šimić

unread,
Feb 24, 2012, 12:56:33 PM2/24/12
to sca...@googlegroups.com
The expression

graph /-/ having(RDF.Type ->MyVocabulary.Computer) / RDF.ID / asString.set

should work as expected.

You should post a complete and minimised version of your code that doesn't work.

Hrvoje

Mauricio Banduk

unread,
Feb 27, 2012, 7:21:03 AM2/27/12
to sca...@googlegroups.com
Hi,

So, I tested and it really doesn't work.

But if I create a property  val id = propStr("id") on my vocabulary and then do  

graph /-/ having(RDF.Type -> MyVocabulary.Computer) / MyVocabulary.id.set

it works!

I've put almost all my cote in the first e-mail, but if yoiu think it would help to send all the code, I can do it.

Thank you,
Banduk



2012/2/24 Hrvoje Šimić <hrvoj...@gmail.com>

Hrvoje Šimić

unread,
Feb 28, 2012, 2:09:05 AM2/28/12
to sca...@googlegroups.com
Have you tested it with the version from the trunk?

Please put the minimal code which exhibits this behaviour in a single
.scala file that can be executed (main or test). And state your exact
versions of Scardf, Scala and Java.

Hrvoje

Mauricio Banduk

unread,
Mar 9, 2012, 10:12:06 AM3/9/12
to sca...@googlegroups.com
Hi,

Sorry about the delay, I had to do other things and to left it for later..
So, I found my problem. I was using the old api converters cause Eclipse was not proposing the import of the new one. 
This is probably because it's an implicit declaration and not a method definition.

You show this import at http://code.google.com/p/scardf/wiki/Converters (in the properties section) but I haven't  noticed...

Cheers,
Banduk


2012/2/28 Hrvoje Šimić <hrvoj...@gmail.com>



--
Maurício Banduk

Reply all
Reply to author
Forward
0 new messages