According to your data it is in fact stored as RDFList. You could try to call
obj.as( RDFList.class ) since RDFList is a subinterface of Resource. But I can't tell anymore without seeing method findStatement() > Hello! > > I have a Jena-based database with an individual batch in it. A batch is a > structure, which has (among other things) a list companyIds (elements are > strings). In this particular example the batch number 1 has a list with > following company IDs: > > 136648473 > 136648520 > 136648577 > > My goal is to retrieve this list. For this, I execute the following code: > > open fun batchStatusLogic(ds: Dataset, batchId: Int): > FailableOperationResult<Bp2BatchStatus> { > val sparql = """SELECT ?x > WHERE { ?x <$Bp2BatchNumber> $batchId }""" > val query = createQuery(sparql) > val qexec = createQueryExecution(ds, query) > val rs = qexec.execSelect() > if (!rs.hasNext()) { > return FailableOperationResult<Bp2BatchStatus>( > false, > "Batch not found.", > null > ) > } > val sol = rs.nextSolution() > val rec = sol["x"] > val prop = findStatement(Bp2BatchCompanyIds, rec as Resource) > if (prop == null) { > return FailableOperationResult<Bp2BatchStatus>( > false, > "Company list not found.", > null > ) > } > val obj = prop.`object` > if (!(obj is RDFList)) { > return FailableOperationResult<Bp2BatchStatus>(false, "Internal > logic error.", null) > } > > obj is not RDFList, but ResourceImpl with obj.enhGraph being displayed as the > XML given below. > > How can I read all elements of the list (136648473, 136648520, 136648577) ? > > If there is a problem with the way the list is stored, please also tell. > > Thanks in advance > > Dmitri Pisarenko > > obj.enhGraph contents: > > <ModelCom {http://mycompany.com/data/p-7cc217a5-4d35-495c-880c-3d0a512eaaf7 > @http://www.w3.org/2001/vcard-rdf/3.0#EMAIL "d.a.pisare...@bk.ru"; > http://mycompany.com/data/p-7cc217a5-4d35-495c-880c-3d0a512eaaf7 > @http://www.w3.org/2001/vcard-rdf/3.0#N -1bac0f47:15a5c92e655:-7fff; > http://mycompany.com/data/p-7cc217a5-4d35-495c-880c-3d0a512eaaf7 > @http://mycompany.com/data/person/firstContactDateTime > "2017-02-20T17:30:15.515Z"^^http://www.w3.org/2001/XMLSchema#dateTime; > http://mycompany.com/data/p-7cc217a5-4d35-495c-880c-3d0a512eaaf7 > @http://mycompany.com/data/person/telegramUserId > "338329909"^^http://www.w3.org/2001/XMLSchema#integer; > http://mycompany.com/data/p-7cc217a5-4d35-495c-880c-3d0a512eaaf7 @/bp1add > "true"^^http://www.w3.org/2001/XMLSchema#boolean; -1bac0f47:15a5c92e655:-7fff > @http://www.w3.org/2001/vcard-rdf/3.0#NICKNAME "mw"; > http://mycompany.com/data/bp-2/b-7406478b-9c33-4b51-bb46-3b854fc633cd > @http://mycompany.com/data/bp-2/batch/batchNumber > "1"^^http://www.w3.org/2001/XMLSchema#integer; > http://mycompany.com/data/bp-2/b-7406478b-9c33-4b51-bb46-3b854fc633cd > @http://mycompany.com/data/bp-2/batch/persona "FD"; > http://mycompany.com/data/bp-2/b-7406478b-9c33-4b51-bb46-3b854fc633cd > @http://mycompany.com/data/bp-2/batch/companyIds 1d387ae6:15b01db5f1f:-7fff; > 1d387ae6:15b01db5f1f:-7fff @http://www.w3.org/1999/02/22-rdf-syntax-ns#first > "136648473"^^http://www.w3.org/2001/XMLSchema#integer; > 1d387ae6:15b01db5f1f:-7fff @http://www.w3.org/1999/02/22-rdf-syntax-ns#rest > 1d387ae6:15b01db5f1f:-7ffe; 1d387ae6:15b01db5f1f:-7ffe > @http://www.w3.org/1999/02/22-rdf-syntax-ns#first > "136648520"^^http://www.w3.org/2001/XMLSchema#integer; > 1d387ae6:15b01db5f1f:-7ffe @http://www.w3.org/1999/02/22-rdf-syntax-ns#rest > 1d387ae6:15b01db5f1f:-7ffd; 1d387ae6:15b01db5f1f:-7ffd > @http://www.w3.org/1999/02/22-rdf-syntax-ns#first > "136648577"^^http://www.w3.org/2001/XMLSchema#integer; > 1d387ae6:15b01db5f1f:-7ffd @http://www.w3.org/1999/02/22-rdf-syntax-ns#rest > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil} | > [http://mycompany.com/data/p-7cc217a5 > -4d35-495c-880c-3d0a512eaaf7, http://www.w3.org/2001/vcard-rdf/3.0#EMAIL, > "d.a.pisare...@bk.ru"] > [http://mycompany.com/data/p-7cc217a5-4d35-495c-880c-3d0a512eaaf7, > http://www.w3.org/2001/vcard-rdf/3.0#N, -1bac0f47:15a5c92e655:-7fff] > [http://mycompany.com/data/p-7cc217a5-4d35-495c-880c-3d0a512eaaf7, > http://mycompany.com/data/person/firstContactDateTime, > "2017-02-20T17:30:15.515Z"^^http://www.w3.org/2001/XMLSchema#dateTime] > [http://mycompany.com/data/p-7cc217a5-4d35-495c-880c-3d0a512eaaf7, > http://mycompany.com/data/person/telegramUserId, > "338329909"^^http://www.w3.org/2001/XMLSchema#integer] > [http://mycompany.com/data/p-7cc217a5-4d35-495c-880c-3d0a512eaaf7, /bp1add, > "true"^^http://www.w3.org/2001/XMLSchema#boolean] > [-1bac0f47:15a5c92e655:-7fff, http://www.w3.org/2001/vcard-rdf/3.0#NICKNAME, > "mw"] [http://mycompany.com/data/bp-2/b-7406478b-9c33-4b51-bb46-3b854fc633cd, > http://mycompany.com/data/bp-2/batch/batchNumber, > "1"^^http://www.w3.org/2001/XMLSchema#integer] > [http://mycompany.com/data/bp-2/b-7406478b-9c33-4b51-bb46-3b854fc633cd, > http://mycompany.com/data/bp-2/batch/persona, "FD"] > [http://mycompany.com/data/bp-2/b-7406478b-9c33-4b51-bb46-3b854fc633cd, > http://mycompany.com/data/bp-2/batch/companyIds, 1d387ae6:15b01db5f1f:-7fff] > [1d387ae6:15b01db5f1f:-7fff, > http://www.w3.org/1999/02/22-rdf-syntax-ns#first, > "136648473"^^http://www.w3.org/2001/XMLSchema#integer] > [1d387ae6:15b01db5f1f:-7fff, http://www.w3.org/1999/02/22-rdf-syntax-ns#rest, > 1d387ae6:15b01db5f1f:-7ffe] [1d387ae6:15b01db5f1f:-7ffe, > http://www.w3.org/1999/02/22-rdf-syntax-ns#first, > "136648520"^^http://www.w3.org/2001/XMLSchema#integer] > [1d387ae6:15b01db5f1f:-7ffe, http://www.w3.org/1999/02/22-rdf-syntax-ns#rest, > 1d387ae6:15b01db5f1f:-7ffd] [1d387ae6:15b01db5f1f:-7ffd, > http://www.w3.org/1999/02/22-rdf-syntax-ns#first, > "136648577"^^http://www.w3.org/2001/XMLSchema#integer] > [1d387ae6:15b01db5f1f:-7ffd, http://www.w3.org/1999/02/22-rdf-syntax-ns#rest, > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil]> > > -- Lorenz Bühmann AKSW group, University of Leipzig Group: http://aksw.org - semantic web research center