W3C home > Mailing lists > Public > public-esw-thes@w3.org > December 2005

Re: DREFT SKOS Thesaurus API Demonstrator

From: NJ Rogers, Learning and Research Technology <Nikki.Rogers@bristol.ac.uk>
Date: Wed, 07 Dec 2005 10:51:57 -0000
To: Frank Wang <fwang@maketechnologies.com>, a.j.miles@rl.ac.uk, public-esw-thes@w3.org
Message-ID: <10140000.1133952717@ilrt-corellia.ilrt.bris.ac.uk>

Hi Frank

Yes, I knew about the bug that causes the IndexOutOfBoundsException. 
However I don't remember uri's causing MalformedQueryExceptions which is 
what I think you are saying. You seem to understand the code well so can I 
suggest that if you want to submit a bug fix then I'll update the 
sourceforge code. If not, then I have promised (myself!) that I will 
reinstate the DREFT demo on my machine by Christmas, in which case I'll be 
reinstalling everything myself and will aim to follow up your queries and 
get back to you. That's about all I can say for now. We do not currently 
have funding to maintain the DREFT software in-house.

By the way, are you able to describe what you are using DREFT for? If I put 
the demo up again on our website it would be nice for us to be able to link 
to what others are doing/developing/testing with the software.

Many thanks
Nikki Rogers

--On Monday, December 05, 2005 02:12:59 PM -0800 Frank Wang 
<fwang@maketechnologies.com> wrote:

>
>
> After installing, configuring and verifying tomcat5.5, axis1.3 and sesame
> 1.2.2. I have built and deployed the SKOS services which source code
> downloaded from
> http://www.w3.org/2001/sw/Europe/reports/thes/skosapi.html. I found there
> are some issues in the source code while testing this API. All query
> strings constructed using org.w3.y2001.sw.Europe.skos.query.SERQLQuery
> class is not correct. For URI or URL, the form is <! ... >, and results
> in org.openrdf.sesame.query.MalformedQueryException. The exception
> java.lang.IndexOutOfBoundsException is thrown from
> org.w3.y2001.sw.Europe.skos.repository. SesameRepo# doSearch_for_concepts
> for there are some bug in loop statement (see the variable row, col).
> This kind of exception also come from resultsTable variable for the
> resultsTable variable maybe null or empty collection.
>
>
>
>
>
> The method I reviewed as following:
>
>
>
>             public Concept[] doSearch_for_concepts(AbstractQuery query) {
>
>
>
>
>
>                         // Next, we need to actually create this
> repository.
>
>                         // We do this by creating a LocalService, handing
> it the configuration, and then retrieving
>
>                         // the repository from the service.
>
>                         LocalService service = Sesame.getService();
>
>
>
>                         AdminMsgCollector admin_info = new
> AdminMsgCollector();
>
>
>
>             try {
>
>
>
>                         service.addRepository(repo_config);
>
>
>
>                         SesameRepository myRepository =
> service.getRepository(RepoID);
>
>
>
>                        // A query to test skos:related. Without
> inferencing, this query brings back just 1 result:
>
>                         // http:/example.com/Concept/0003
>
>                         // I need it to bring back concept 0004 as well
> when transivity working - currently not working even though rule file
> read in
>
>                         // String query = "select Y from  {X :
> core:Concept } core:related {Y} where  X like
> \"http:/example.com/Concept/0002\" using namespace core =
> http://www.w3.org/2004/02/skos/core#";
>
>
>
>                         //String query = "select * from  {X} core:broader
> {Y} where  Y like \"http:/example.com/Concept/0002\" using namespace
> core = http://www.w3.org/2004/02/skos/core#";
>
>                         //String query = "select * from  {X} @P {Y}";
>
>                         //String query = "select X, @PROPERTY, VALUE from
> {X : core:Concept } core:broader {Y}, {X} @PROPERTY {VALUE} where  Y like
> \"http:/example.com/Concept/0002\" using namespace core =
> http://www.w3.org/2004/02/skos/core#";
>
>                         String query_str = query.getQuery();
>
>
>
>                         //System.out.println("Now gonna issue a query
> against the repository");
>
>                         //System.out.println("Query is:  " + query_str);
>
>
>
>                         // Ascertain what type of internal query object
> we have, (RQL, SERQL RDQL, whatever)
>
>                         // so we are able to instruct sesame
> appropriately.
>
>
>
>                         // TODO: This looks particularly dubious - using
> substrings of the class name to switch on.
>
>                         String query_type = query.getClass().getName();
>
>                         QueryLanguage query_format = null;
>
>
>
>                         if (query_type.indexOf("SERQL") != -1)
>
>                         {
>
>                                     //System.out.println("Detected SERQL
> query ");
>
>                                     logger.debug(this + "Detected a SERQL
> query '" + query_str + "'");
>
>                                     query_format = QueryLanguage.SERQL;
>
>
>
>                         }
>
>                         else if  (query_type.indexOf("RQL") != -1)  {
>
>                                     //System.out.println("Detected RQL
> query ");
>
>                                     logger.debug(this + "Detected RQL
> query '" + query_str + "'");
>
>                                     query_format = QueryLanguage.RQL;
>
>                         }
>
>                         else {
>
>                                     // default to SERQL
>
>                                     //System.out.println("Defaulting to
> SERQL query ");
>
>                                     logger.debug(this + "Defaulting to
> SERQL query '" + query_str + "'");
>
>                                     query_format = QueryLanguage.SERQL;
>
>                         }
>
>
>
>                         QueryResultsTable resultsTable =
> myRepository.performTableQuery(query_format, query_str);
>
>
>
>                         //add
>
>                         if( (resultsTable == null) ||
> (resultsTable.getRowCount() == 0) )
>
>                         {
>
>                                     return null;
>
>                         }
>
>
>
>                         /*
>
>                         // *******************debugging only
> ******************
>
>                         System.out.println("Got a results table with " +
> resultsTable.getRowCount() + " rows in it.");
>
>                         for (int row = 0; row <
> resultsTable.getRowCount(); row++) {
>
>                                                 for (int column = 0;
> column < resultsTable.getColumnCount(); column++) {
>
>                                                             Value value =
> resultsTable.getValue(row, column);
>
>
>
>
> System.out.print(value.toString());
>
>
> System.out.print(" ");
>
>
>
>                                                 }
>
>                                                 System.out.println();
>
>                                     }
>
>                         //*******************debugging only
> ******************
>
>                 */
>
>
>
>
>
>                         // instantiate an arraylist object to hold as
> many concept objects as the result set brings back
>
>                         concept_resultset  = new ArrayList();
>
>
>
>                         //                      get uri of first concept
> in the results table
>
>                         Value curr_concept = resultsTable.getValue(0,0);
>
>                         //System.out.println(curr_concept.toString());
>
>
>
>
>
>                         //                      instantiate an arraylist
> object to hold non-preferred terms as and when they arise
>
>                         non_pref_term_list = new ArrayList();
>
>
>
>                         Concept concept_bean = new Concept();
>
>                         //System.out.println("Just constructed a new bean
> ready for filling XXXXXXXXXXXXx");
>
>                         logger.debug(this + "***** Constructed a concept
> bean ready for filling *****");
>
>
>
>                         //move below tow lines to for loop
>
> //                      int row = 0;
>
> //                      int col = 0;
>
>
>
>                         for (int row_n = 0; row_n <
> (resultsTable.getRowCount() -1); row_n++) {
>
>
>
>                                     int row = 0;
>
>                                     int col = 0;
>
>
>
>                                     do {
>
>                                                 curr_concept =
> resultsTable.getValue(row,col);
>
>
>
>                                                 if (curr_concept != null)
> {
>
>
> if(curr_concept instanceof org.openrdf.model.URI) {
>
>
> URI tmp_uri = new URI();
>
>
> tmp_uri.setUri(((org.openrdf.model.URI)curr_concept).getURI());
>
>
> concept_bean.setUri(tmp_uri);
>
>
> tmp_uri = null;
>
>                                                             }
>
>
>
>                                                             // TODO
> separate out the namespace & property name for each of prefLabel etc
>
>                                                             // this can
> then be configured via intial parameters etc
>
>                                                            String
> curr_property = resultsTable.getValue(row,1).toString();
>
>
>                                                             if
> (curr_property.equals(skosNamespaceUri+"prefLabel")) {
>
>
> // System.out.println("gotta pref label for the bean: "
> +resultsTable.getValue(row,2).toString());
>
>
> concept_bean.setPreferredLabel(resultsTable.getValue(row,2).toString());
>
>                                                             } else if
> (curr_property.equals(skosNamespaceUri+"definition")) {
>
>                                                                //
> System.out.println("gotta definition for the bean: "
> +resultsTable.getValue(row,2).toString());
>
>
> concept_bean.setDefinition(resultsTable.getValue(row,2).toString());
>
>                                                             } else if
> (curr_property.equals(skosNamespaceUri+"example")) {
>
>                                                                //
> System.out.println("gotta example for the bean: "
> +resultsTable.getValue(row,2).toString());
>
>
> concept_bean.setExample(resultsTable.getValue(row,2).toString());
>
>                                                             } else if
> (curr_property.equals(skosNamespaceUri+"scopeNote")) {
>
>                                                                //
> System.out.println("gotta scopeNote for the bean: "
> +resultsTable.getValue(row,2).toString());
>
>
> concept_bean.setScopeNote(resultsTable.getValue(row,2).toString());
>
>                                                             } else if
> (curr_property.toString().equals(skosNamespaceUri+"externalID")) {
>
>
> //          System.out.println("gotta external id for the bean: "
> +resultsTable.getValue(row,2).toString());
>
>
> concept_bean.setExternalID(resultsTable.getValue(row,2).toString());
>
>                                                             } else if
> (curr_property.toString().equals(skosNamespaceUri+"inScheme")) {
>
>
> URI tmp_uri = new URI();
>
>
> tmp_uri.setUri(resultsTable.getValue(row,2).toString());
>
>
> concept_bean.setInScheme(tmp_uri);
>
>
> tmp_uri = null;
>
>                                                            } else if
> (curr_property.equals(skosNamespaceUri+"altLabel")) {
>
>                                                                        //
> System.out.println("gotta alt (non pref) for the bean: "
> +resultsTable.getValue(row,2).toString());
>
>
> add_to_nonprefLabel_array(resultsTable.getValue(row,2).toString());
>
>
>                                                             }
>
>
>                                                 } // end if
>
>
>
>                                                 logger.debug(this +
> "***** Current concept being processed is known as  *****" +
> curr_concept);
>
>
> //System.out.println("doing a bean, current concept is " + curr_concept);
>
>
> //System.out.println("Property is " + resultsTable.getValue(row,1));
>
>
> //System.out.println("Value is " + resultsTable.getValue(row,2));
>
>
>
>                                      } while ((row++ <
> (resultsTable.getRowCount()-1)) &&
> resultsTable.getValue(row,col).equals(curr_concept));
>
>                                     //  cast from array list to a string
> array because Axis software handles arrays most easily
>
>                         String[] str = (String [])
> non_pref_term_list.toArray(new String [non_pref_term_list.size()]);
>
>                         concept_bean.setNonPreferredLabels(str);
>
>
>
>                         //System.out.println("left while loop now");
>
>                         // We've finished creating the bean for that
> particular concept so add the concept bean to the concept bean result set
>
>                         add_to_concept_array(concept_bean);
>
>                         // reset the non pref term array list
>
>                         non_pref_term_list = new ArrayList();
>
>                         logger.debug(this + "***** Finished constructing
> a Concept bean *****");
>
>                         //System.out.println("Just constructed a new bean
> XXXXXXXXXXXXx");
>
>
>
>                         concept_bean = new Concept();
>
>
>
>                         } // end for loop
>
>
>
>
>
>
>
>             }
>
>             catch ( java.lang.IndexOutOfBoundsException ioobe)
>
>             {
>
>                         logger.error(ioobe);
>
>             }
>
>             catch (FileNotFoundException fnfe)
>
>             {
>
>                         logAdminMessages(admin_info);
>
>                         //System.out.println(fnfe);
>
>                         logger.error(fnfe);
>
>             }
>
>             catch (AccessDeniedException ade)
>
>             {
>
>                         logAdminMessages(admin_info);
>
>                         //System.out.println(ade);
>
>                         logger.error(ade);
>
>             }
>
>             catch (IOException ioe)
>
>             {
>
>                         logAdminMessages(admin_info);
>
>                         //System.out.println("IO exception" + ioe);
>
>                         logger.error(this + "IO exception: " + ioe);
>
>
>             }
>
>             catch (ConfigurationException cfe)
>
>             {
>
>                         logAdminMessages(admin_info);
>
>                         //System.out.println(cfe);
>
>
>                         logger.error(cfe);
>
>             }
>
>             catch (UnknownRepositoryException ure) {
>
>                         logAdminMessages(admin_info);
>
>                         //System.out.println(ure);
>
>                         logger.error(ure);
>
>             }
>
>             catch (Exception e)
>
>             {
>
>                         logAdminMessages(admin_info);
>
>                 logger.error(e);
>
>             }
>
>
>
>             // now lets get the concept results we've been storing &
> return them
>
>             return (Concept []) concept_resultset.toArray(new Concept
> [concept_resultset.size()]);
>
>
>
>             }
>
>
>
>
>
>
>
>
> __________________________________________________
>
>
> Frank Wang
>  Java Developer
>
> MAKE Technologies Inc.
>
> Email:
>
> fwang@maketechnologies.com
>
> Phone:
>
> 604.738.4999 xtn 0
>
> Fax:
>
> 604.738.4979
>
> Visit:
>
> www.maketechnologies.com
>
>



----------------------
NJ Rogers, Technical Researcher
(Senior Technical Developer and Coordinator of Web Futures)
Institute for Learning and Research Technology (ILRT)
Email:nikki.rogers@bristol.ac.uk
Tel: +44(0)117 9287113 (Direct)
Tel: +44(0)117 9287193 (Office)
Received on Wednesday, 7 December 2005 11:15:07 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:38:54 GMT