Package org.jzkit.search

Examples of org.jzkit.search.ExplainInformationDTO


    // has to be called first. Other methods
    //checkMandatoryParams(params, mandatoryEXPL);


    SearchSessionFactory search_session_factory = getSearchSession(context);
    ExplainInformationDTO explain = search_session_factory.explain();


    Hashtable<String, Boolean> seenContextSets = new Hashtable<String, Boolean>();

    Element response = new Element(Jeeves.Elem.RESPONSE);

    String myop = "explain";
    if (params.containsKey("operation")) {
      myop=params.get("operation");
    }
   
    Element diagnostics = processDiag(params,myop);
    if (diagnostics != null ) response.addContent(diagnostics);

    response.setAttribute(new Attribute("servername",  context.getIpAddress() ));
    //response.setAttribute(new Attribute("port", "????")); //FIXME: dont know where I should get that info from. Done in stylesheet
    response.setAttribute(new Attribute("sruuri",  context.getBaseUrl()+"/srv/"+context.getLanguage()+"/"+context.getService() )); //FIXME: can I get the query string from somewhere?
    response.setAttribute(new Attribute("records_per_page",SRU_records_per_page+""));

    Element indices = new Element("indices");
    for (Object o : explain.getDatabaseInfo()) {
      GNExplainInfoDTO ex = (GNExplainInfoDTO)o;

      Element index = new Element("index");
      index.setAttribute("id",ex.getId());
View Full Code Here


               this.appl_ctx=ctx;
       }
      
       public ExplainInformationDTO explain() {

           ExplainInformationDTO result = new ExplainInformationDTO();

           Configuration directory = (Configuration) appl_ctx.getBean("JZKitConfig");
           try {
             // Populate explain information
            
               // if we used ValidIndices we would use this code
              
               /*
              
               CollectionDescriptionDBO cd = directory.lookupCollectionDescription("Default");
               if (cd!= null ) {
                      
                       Map<String, AttrValue> mappings = cd.getSearchServiceDescription().getServiceSpecificTranslations();
                       Map<String,String> reverse_mappings = new HashMap<String, String>();
                       for (String key: mappings.keySet()) {
                               reverse_mappings.put(mappings.get(key).toString(), key);
                       }
                      
                       AttributeSetDBO attrs = cd.getSearchServiceDescription().getValidAttrs().get("AccessPoint");
                      
                      
                      
                      
                       List<GNExplainInfoDTO> list = new ArrayList<GNExplainInfoDTO>();
                       for (AttrValue val: attrs.getAttrs() ) {
                      
                               GNExplainInfoDTO exl = new GNExplainInfoDTO();
                               exl.addMapping(val.getValue(), val.getNamespaceIdentifier());
                              
                               String reverse_key = val.getNamespaceIdentifier()+":"+val.getValue();
                               if (reverse_mappings.containsKey(reverse_key)) {
                                       String[] temp = reverse_mappings.get(reverse_key).split("\\.");
                                       if (temp.length==3) exl.addMapping(temp[1]+"."+temp[2], temp[0]);
                                       if (temp.length==2) exl.addMapping(temp[1], temp[0]);
                               }
                              
                               list.add(exl);
                       }
                      
                       result.setDatabaseInfo(list);
                      
               }
              
               */
              
               // but we use Crosswalks (the info on what we actually accept is in the geo profile, but we suppose
               // that the crosswalks will eventually lead to a valid attribute)
              
               // this should really be done differently but unfortunately there is
               // no way to know if a mapping is for an attribute (can be a relation, too)
               // we take as indicator the fact that are is a "1"
               Pattern p = Pattern.compile(".*\\.1\\.([0-9]+)$" );
              
               @SuppressWarnings("unchecked")
            Iterator<CrosswalkDBO> it = directory.enumerateCrosswalks();
              
               List<GNExplainInfoDTO> list = new ArrayList<GNExplainInfoDTO>();
               while (it.hasNext()) {
              
                      
                       CrosswalkDBO cw = it.next();
                      
                       for ( String key : cw.getMappings().keySet() ) {
                              
                               AttrMappingDBO attrmaping = cw.getMappings().get(key);
                              
                               if (attrmaping.getTargetAttrs().isEmpty() ) {
                                       continue;
                               }
                              
                               // namespace is not important, just important that it is there (for the patternmatching)
                               String attrString = attrmaping.getTargetAttrs().iterator().next().getWithDefaultNamespace("geo");
                              
                               // find out which are the actual attribute mappings (this is ugly)
                               // "geo:1.4" matches, "something:1.3443", too, but not "gagh" or "geo.2.22"
                               Matcher m = p.matcher(attrString);
                              
                               if ( m.find() ) {
                                     String id = m.group(1);
                                
                                       GNExplainInfoDTO exl = new GNExplainInfoDTO(id);
                                       exl.addMapping( attrmaping.getSourceAttrValue() , cw.getSourceNamespace()  ) ;
                                      
                                       list.add(exl);
                              
                               }
                              
                       }
                      
               }
              
               result.setDatabaseInfo(list);
              
           }
           catch ( ConfigurationException ce) {
             ce.printStackTrace();
           }
View Full Code Here

TOP

Related Classes of org.jzkit.search.ExplainInformationDTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.