0

I have the following code, in which I find a resource by its e-mail.

val varn = "x"
val query = createQuery("""SELECT ?${varn}
                    WHERE { ?x  <http://www.w3.org/2001/vcard-rdf/3.0#EMAIL>  "${email}" }""")
val qexec = createQueryExecution(ds, query)
val rs = qexec.execSelect()
if (rs.hasNext()) {
    val solution = rs.nextSolution()
    val rec = solution[varn]
    // Here I need to find the value of the property FirstContactTime
}

Now I want to find out whether rec has a property FirstContactTime and if yes, its value.

I tried rec.model.listObjectsOfProperty(ds.defaultModel.createProperty(FirstContactTime)) but it doesn't return anything. The debugger says rec does have a property FirstContactTime.

Debugger

How can I get the value of FirstContactTime (2017-03-03T10:35:00Z) in my code?

Glory to Russia
  • 17,289
  • 56
  • 182
  • 325
  • Screenshots are very difficult to work with. Please replace the screenshot with the text. The highlight isn't necessary. – TallTed Feb 08 '17 at 22:25

1 Answers1

1

Note that the property in the data is FirstContactDateTime not FirstContactTime.

The SPARQL you're looking for is something like this --

PREFIX  vcard:  <http://www.w3.org/2001/vcard-rdf/3.0#>
PREFIX     ex:  <http://example.com/schema/person/>

SELECT ?user ?email ?firstcontact
 WHERE
   {               ?x  vcard:EMAIL              ?email         .
      OPTIONAL  {  ?x  ex:firstContactDateTime  ?firstcontact  }
   }
TallTed
  • 9,069
  • 2
  • 22
  • 37