Examples of InformationFragment


Examples of com.k_int.IR.InformationFragment

        GeoSearchTask task = (GeoSearchTask) geoSource.createTask(testQuery,
                null);
        task.evaluate(2000);
        spec = new RecordFormatSpecification("sutrs", null, "B");

        InformationFragment frag = task.getFragment(1, spec);
        String result = frag.getOriginalObject().toString();
        LOGGER.fine("the result is " + result);
        assertTrue(result.equals("Water Supply Watersheds"));

        spec = new RecordFormatSpecification("html", null, "S");
View Full Code Here

Examples of org.jzkit.search.util.RecordModel.InformationFragment

                       RecordFormatSpecification spec) throws IRResultSetException {
           if(Log.isDebugEnabled(Geonet.Z3950_SERVER))
               Log.debug(Geonet.Z3950_SERVER, "Request for fragment start:"
                               + startingFragment + ", count:" + count);

               InformationFragment fragment[] = new InformationFragment[count];

               ExplicitRecordFormatSpecification rec_spec = new ExplicitRecordFormatSpecification("xml", null, "f");

               try {
                       // build fragment data
View Full Code Here

Examples of org.jzkit.search.util.RecordModel.InformationFragment

    response.add(new Document(summary));

    if (getTo() > 0)
    {
      StatelessQueryService sqs = getQueryService(srvContext);
      InformationFragment fragshtml[] = null;

      if (_html) {
        ExplicitRecordFormatSpecification htmlrfs = new ExplicitRecordFormatSpecification("html", null, "f");
        StatelessSearchResultsPageDTO res = sqs.getResultsPageFor(this.zinfo.getSetname(),this.zinfo.getQueryModel(),this.zinfo.getLandscape(),getFrom(),getTo(),def_html_request_spec,htmlrfs,null);
        fragshtml = res.records;
      }

      ExplicitRecordFormatSpecification rfs = new ExplicitRecordFormatSpecification("xml", null, "f");
      StatelessSearchResultsPageDTO res = sqs.getResultsPageFor(this.zinfo.getSetname(),this.zinfo.getQueryModel(),this.zinfo.getLandscape(),getFrom(),getTo(),def_request_spec,rfs,null);
      InformationFragment frags[] = res.records;

      // FIXME: we may not get all the records we want back sometimes!
      int fragsLength = 0;
      if (frags != null) fragsLength = frags.length;
      int theLimit = Math.min(getPageSize(),fragsLength);

      for (int i = 0; i < theLimit; i++) {
        InformationFragment fraghtml = null;
        if (_html) {
          fraghtml = fragshtml[i];
        }
        InformationFragment frag = frags[i];
        try {
          DOMBuilder builder = new DOMBuilder();
 
          org.w3c.dom.Document doc = (org.w3c.dom.Document)frag.getOriginalObject();
          Document jDoc = builder.build(doc);
          Element md = jDoc.getRootElement();

          String elementFileName = "none";
          String htmlError = "";
          if (_html) {
            Object docObj = fraghtml.getOriginalObject();
            if (docObj instanceof org.w3c.dom.Document) {
              org.w3c.dom.Document dochtml = (org.w3c.dom.Document)fraghtml.getOriginalObject()
              String fileid = UUID.randomUUID().toString();
              String filename = srvContext.getAppPath()+_searchMan.getHtmlCacheDir()+File.separator+fileid+".html";
              elementFileName = srvContext.getBaseUrl()+"/"+_searchMan.getHtmlCacheDir()+"/"+fileid+".html";
              File outHtmlFile = new File(filename);
              try {
                Transformer xformer = TransformerFactoryFactory.getTransformerFactory().newTransformer();
                xformer.setOutputProperty(OutputKeys.METHOD, "text");
                Source source = new DOMSource(dochtml);
                Result result = new StreamResult(outHtmlFile.toURI().getPath());
                xformer.transform(source,result);
              } catch (TransformerConfigurationException e) {
                e.printStackTrace();
              } catch (TransformerException e) {
                e.printStackTrace();
              }
            } else {
              htmlError = "HTML result not available. Error message: "+docObj.toString();
            }
          }
 
          Element info = new Element(Edit.RootChild.INFO, Edit.NAMESPACE);
          md.removeChild(Edit.RootChild.INFO, Edit.NAMESPACE);

          addElement(info, Edit.Info.Elem.ID,     (getFrom() + i)+"");
          addElement(info, Edit.Info.Elem.SERVER, frag.getSourceRepositoryID());
          addElement(info, Edit.Info.Elem.COLLECTION, frag.getSourceCollectionName());
          addElement(info, Edit.Info.Elem.SCHEMA, _schemaMan.autodetectSchema(md));
          if (_html) {
            Element html = new Element(Edit.Info.Elem.HTML).setText(elementFileName);
            if (!htmlError.equals("")) html.setAttribute("error", htmlError);
            info.addContent(html);
          }

          md.addContent(info);
                    if(Log.isDebugEnabled(Geonet.SEARCH_ENGINE))
                        Log.debug(Geonet.SEARCH_ENGINE, "Add info element of "+Xml.getString(info));

          response.add(jDoc);
        } catch (Exception ex) {
          ex.printStackTrace();
          Element error = new Element("error");
          error.setAttribute("server",  frag.getSourceRepositoryID());
          error.setAttribute("collection",  frag.getSourceCollectionName());
          error.setAttribute("id",      (getFrom() + i)+"");
          error.setAttribute("message", ex.getClass().getName() + ": " + ex.getMessage());
          Log.error(Geonet.SEARCH_ENGINE, "Exception raised during Z3950 search and retrieval "+" Server: "+error.getAttributeValue("server")+" id: "+error.getAttributeValue("id"));
          response.add(new Document(error));
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.