Ignore:
Timestamp:
03/13/13 16:25:07 (11 years ago)
Author:
yana
Message:

preparation to integrate map;
support for both resource and resource=root as initial query to the endpoint;
foreign endpoint removed (commented);
support on Enter key event for search term textbox (to execute search)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/app/Aggregator.java

    r2599 r2694  
    33import com.google.gson.Gson;
    44import com.google.gson.reflect.TypeToken;
     5import com.sun.jersey.api.client.Client;
    56import eu.clarin.sru.client.SRUVersion;
    67import eu.clarin.sru.fcs.aggregator.data.CenterRegistry;
     
    1516import java.util.Set;
    1617import java.util.logging.*;
     18import org.zkoss.util.media.AMedia;
     19import org.zkoss.util.media.Media;
    1720import org.zkoss.zk.ui.Component;
    1821import org.zkoss.zk.ui.Executions;
     
    3538import org.zkoss.zul.Window;
    3639import org.zkoss.zul.event.ZulEvents;
     40import com.sun.jersey.api.client.WebResource;
     41import com.sun.jersey.api.client.config.ClientConfig;
     42import com.sun.jersey.api.client.config.DefaultClientConfig;
     43import eu.clarin.weblicht.wlfxb.tc.api.GeoLongLatFormat;
     44import eu.clarin.weblicht.wlfxb.tc.api.Token;
     45import eu.clarin.weblicht.wlfxb.tc.xb.TextCorpusStored;
     46import eu.clarin.weblicht.wlfxb.xb.WLData;
     47import javax.ws.rs.core.MediaType;
    3748
    3849/**
     
    7788    @Wire
    7889    private Label searchResultsProgress;
     90
     91    private WebResource mapGenerator;
     92    public static final String MAPS_SERVICE_URL = "http://weblicht.sfs.uni-tuebingen.de/rws/service-geolocationconsumer/resources/geoloc/";
    7993   
    8094    private Map<String, List<String>> xAggregationContext;
     
    105119        tree.setItemRenderer(new CorpusTreeNodeRenderer());
    106120        tree.setMultiple(true);
     121       
     122       
     123        //tempMap();
    107124
    108125    }
     
    139156        int maxRecords = Integer.parseInt(maximumRecordsSelect.getValue());
    140157        searchResultsController.executeSearch(tree.getSelectedItems(), maxRecords, searchString.getText(), version);
     158    }
     159   
     160    @Listen("onOK = #searchString")
     161    public void onEnterSearchString(Event ev) {
     162        onExecuteSearch(ev);
    141163    }
    142164 
     
    231253
    232254    }
     255
     256    private void tempMap() {
     257        ClientConfig config = new DefaultClientConfig();
     258        Client client = Client.create(config);
     259        mapGenerator = client.resource(MAPS_SERVICE_URL);
     260        TextCorpusStored tc = new TextCorpusStored("en");
     261        Token t1 = tc.createTokensLayer().addToken("Virginia");
     262        List<Token> s1 = new ArrayList<Token>(); s1.add(t1);
     263        tc.createSentencesLayer().addSentence(s1);
     264        tc.createGeoLayer("unknown", GeoLongLatFormat.DegDec);
     265        //tc.getGeoLayer().addPoint("138.56027", "-34.6663", 15.0, null, null, null, t1);
     266        WLData data = new WLData(tc);
     267       
     268        Iframe resultsPic = (Iframe) resultsBox.getFellow("resultsPic");
     269       
     270        try {
     271                    String output = mapGenerator.path("3").accept(MediaType.TEXT_HTML).type("text/tcf+xml").post(String.class, data);
     272                    Media media = new AMedia("map-" + 4 + ".html", null, "text/html", output);
     273                    resultsPic.setContent(media);
     274                } catch (Exception e) {
     275                    Logger.getLogger(Aggregator.class.getName()).log(Level.SEVERE, "ERROR accessing the maps generator service", e);
     276                    Messagebox.show("ERROR accessing the maps generator service \n" + e.getMessage(), "FCS", 0, Messagebox.INFORMATION);
     277                }
     278    }
    233279}
Note: See TracChangeset for help on using the changeset viewer.