Package net.datacrow.core.services.plugin

Examples of net.datacrow.core.services.plugin.IServer


    private synchronized void initialize() {
        ServiceClassLoader scl = new ServiceClassLoader(DataCrow.servicesDir);
        registered.clear();
        for (Class<?> clazz : scl.getClasses()) {
           
            IServer server = null;
            try {
                server = (IServer) clazz.newInstance();
            } catch (Exception ignore) {}   
           
            if (server != null) {
                try {
                    Collection<IServer> servers = registered.get(Integer.valueOf(server.getModule()));
                    servers = servers == null ? new ArrayList<IServer>() : servers;
                    servers.add(server);
                   
                    registered.put(Integer.valueOf(server.getModule()), servers);
                   
                    String name = server.getClass().getName();
                    name = name.substring(name.lastIndexOf(".") + 1);
                    logger.info("Registered online server " + name);
                } catch (Exception e) {
                    logger.error(e, e);
                }
View Full Code Here


     * Uses the services URL as stored in the item (see {@link DcObject#_SYS_SERVICEURL}).
     * @param item
     * @return The supplied item. Either updated or not.
     */
    public DcObject query(DcObject item) {
        IServer server = getServer();
        Region region = getRegion(server);
       
        task = server.getSearchTask(this, getSearchMode(server), region, null, item);
        task.setItemMode(SearchTask._ITEM_MODE_FULL);
       
        try {
            return task.getItem(new URL((String) item.getValue(DcObject._SYS_SERVICEURL)));
        } catch (Exception e) {
View Full Code Here

     * @param query The query to base the search on.
     * @param matcherFieldIdx The field indices used to check for similarity.
     * @return The most similar result or null.
     */
    public DcObject query(DcObject base, String query, int[] matcherFieldIdx) {
        IServer server = getServer();
        Region region = getRegion(server);
       
        task = server.getSearchTask(this, getSearchMode(server), region, query, base);
        task.setItemMode(itemMode);
        task.setMaximum(maximum);
        task.run();
       
        return getMatchingItem(base, matcherFieldIdx);
View Full Code Here

     * Searches for items based on the provided query string.
     * @param query
     * @return Collection of results.
     */
    public List<DcObject> query(String query, DcObject client) {
        IServer server = getServer();
        Region region = getRegion(server);
       
        task = server.getSearchTask(this, getSearchMode(server), region, query, client);
        task.setItemMode(itemMode);
        task.setMaximum(maximum);
        task.run();
       
        return new ArrayList<DcObject>(result);
View Full Code Here

     * will be used. If no default server is available it will be selected at random.
     * @return The server to be used.
     */
    private IServer getServer() {
        OnlineServices os = DcModules.get(module).getOnlineServices();
        IServer defaultSrv =
            os.getServer(DcModules.get(module).getSettings().getString(DcRepository.ModuleSettings.stOnlineSearchDefaultServer));
       
        IServer server = this.server != null ? this.server : defaultSrv;
        return server == null ? (IServer) os.getServers().toArray()[0] : server;
    }
View Full Code Here

     * Retrieves the region for the given code.
     * @see Region
     * @return The region for the given code or null if not found.
     */   
    private Region getRegion(String code) {
        IServer server = getDefaultServer();
       
        if (server != null && server.getRegions() != null) {
            for (Region region : server.getRegions()) {
                if (region.getCode().equals(code))
                    return region;
            }
        }
        return null;
View Full Code Here

     * Retrieves the search mode for the display name.
     * @see SearchMode
     * @return The search mode for the given display name or null if not found.
     */      
    private SearchMode getMode(String diplayName) {
        IServer server = getDefaultServer();
        if (server != null && server.getSearchModes() != null) {
            for (SearchMode mode : server.getSearchModes()) {
                if (mode.getDisplayName().equals(diplayName))
                    return mode;
            }
        }
        return null;       
View Full Code Here

     * @param dco The item on which the search is based.
     * @return The retrieved item (a new instance) or null if no information could be found.
     * @throws Exception
     */
    public DcObject query(DcObject dco) throws Exception {
        IServer server = getServer(dco);
        Region region = getRegion(dco);
       
        if (server != null) {
            SearchTask task = server.getSearchTask(null, null, region, null, dco);
            return task.query(dco);
        }
       
        return null;
    }   
View Full Code Here

        return checkUseOnlineService.isSelected() && modeSelectionAllowed ?
                (SearchMode) comboModes.getSelectedItem() : null;
    }
   
    public void setServer(String name) {
        IServer server;
        for (int idx = 0; idx < comboServers.getItemCount(); idx++) {
            server = (IServer) comboServers.getItemAt(idx);
            if (server.getName().equals(name))
                comboServers.setSelectedItem(server);
        }
    }
View Full Code Here

                comboModes.setSelectedItem(mode);
        }
    }   
   
    private void applyServer() {
        IServer server = getServer();
        comboRegions.removeAllItems();
        comboModes.removeAllItems();

        if (server != null) {
          for (Region region : server.getRegions())
            comboRegions.addItem(region);
         
          if (server.getSearchModes() != null) {
              for (SearchMode mode : server.getSearchModes())
                  comboModes.addItem(mode);
          }
         
          comboModes.setVisible(comboModes.getItemCount() > 0);
        }
View Full Code Here

TOP

Related Classes of net.datacrow.core.services.plugin.IServer

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.