> Which programming language is this?

Kotlin.

"companyIds.head" is equivalent to "companyIds.getHead()".

> Does your code compile? I'm asking because there is just a getHead()
> method on an RDFList object. And this one returns an RDFNode object,
> thus, remove should be impossible here.

It does compile, but I haven't tested it manually yet.

Could you point me to an analog of 
org.apache.jena.rdf.model.Statement#changeLiteralObject(...) for lists?

Dmitri



16.03.2017, 12:18, "Lorenz B." <[email protected]>:
>>  Hello!
>>
>>  I have an application, which creates an individual called batch. A batch 
>> has a list of company IDs (strings). Add the property like this:
>>
>>      open fun addCompanyIdsList(
>>              batch: Resource,
>>              companyIds: List<String>,
>>              model: Model) {
>>          val prop = model.createProperty(Bp2BatchCompanyIds)
>>          val list = model.createList()
>>          companyIds
>>                  .filter { it.isNumeric() }
>>                  .map { it.toInt() }
>>                  .map { id -> model.createTypedLiteral(id) }
>>                  .forEach { literal -> list.add(literal) }
>>          batch.addProperty(prop, list)
>>      }
>>
>>  In another operation I want to remove the first element of the list so that 
>> this change is saved in Jena. For primitive data types like integers, there 
>> is the method
>>
>>  org.apache.jena.rdf.model.Statement#changeLiteralObject(boolean)
>>
>>  and its analogs.
>>
>>  How do I change the list? Is it sufficient to just remove an element from 
>> the list like in the code snippet below?
>>
>>          ds.begin(ReadWrite.WRITE)
>>          val query = createQuery("""SELECT ?x
>>                                                  WHERE { ?x $Bp2BatchNumber 
>> $batchId }""")
>>          val qexec = createQueryExecution(ds, query)
>>          val rs = qexec.execSelect()
>>          val sol = rs.nextSolution()
>>          val rec = sol["x"]
>>          val prop = findStatement(Bp2BatchCompanyIds, rec as Resource)
>>          val companyIds = prop.`object` as RDFList
>>          val head = companyIds.head
>>          companyIds.remove(result)
>>          ds.end()
>
> Which programming language is this?
> Does your code compile? I'm asking because there is just a getHead()
> method on an RDFList object. And this one returns an RDFNode object,
> thus, remove should be impossible here.
>>  Thanks in advance
>>
>>  Dmitri Pisarenko
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center

Reply via email to