001/** 002 * Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ 003 * 004 * This file is part of Dicoogle/dicoogle. 005 * 006 * Dicoogle/dicoogle is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Dicoogle/dicoogle is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package pt.ua.dicoogle.plugins; 020 021import java.net.URI; 022import java.util.Collection; 023import java.util.List; 024import pt.ua.dicoogle.core.ServerSettings; 025 026import pt.ua.dicoogle.sdk.IndexerInterface; 027import pt.ua.dicoogle.sdk.QueryInterface; 028import pt.ua.dicoogle.sdk.StorageInputStream; 029import pt.ua.dicoogle.sdk.StorageInterface; 030import pt.ua.dicoogle.sdk.core.DicooglePlatformInterface; 031import pt.ua.dicoogle.sdk.core.ServerSettingsReader; 032import pt.ua.dicoogle.sdk.datastructs.Report; 033import pt.ua.dicoogle.sdk.datastructs.SearchResult; 034import pt.ua.dicoogle.sdk.task.JointQueryTask; 035import pt.ua.dicoogle.sdk.task.Task; 036 037/** 038 * A proxy to the implementations of Plugin Controller. 039 * 040 * @author psytek 041 * @author Luís A. Bastião Silva <bastiao@ua.pt> 042 */ 043public class DicooglePlatformProxy implements DicooglePlatformInterface { 044 045 private final PluginController pluginController; 046 047 public DicooglePlatformProxy(PluginController pluginController){ 048 this.pluginController = pluginController; 049 } 050 051 @Override 052 public IndexerInterface requestIndexPlugin(String name) { 053 Collection<IndexerInterface> indexers = pluginController.getIndexingPlugins(true); 054 for(IndexerInterface index : indexers){ 055 if(index.getName().equals(name)) return index; 056 } 057 return null; 058 } 059 060 @Override 061 public QueryInterface requestQueryPlugin(String name) { 062 Collection<QueryInterface> queriers = pluginController.getQueryPlugins(true); 063 for(QueryInterface querier : queriers){ 064 if(querier.getName().equals(name)) return querier; 065 } 066 067 return null; 068 } 069 070 @Override 071 public Collection<IndexerInterface> getAllIndexPlugins() { 072 return pluginController.getIndexingPlugins(false); 073 } 074 075 @Override 076 public Collection<QueryInterface> getAllQueryPlugins() { 077 return pluginController.getQueryPlugins(false); 078 } 079 080 @Override 081 public StorageInterface getStoragePluginForSchema(String storage) { 082 return pluginController.getStorageForSchema(storage); 083 } 084 085 @Override 086 public StorageInterface getStorageForSchema(URI location) { 087 return pluginController.getStorageForSchema(location); 088 } 089 090 @Override 091 public Iterable<StorageInputStream> resolveURI(URI location, Object ...args) { 092 return pluginController.resolveURI(location, args); 093 } 094 095 @Override 096 public Collection<StorageInterface> getStoragePlugins(boolean onlyEnabled) { 097 return pluginController.getStoragePlugins(onlyEnabled); 098 } 099 100 @Override 101 public StorageInterface getStorageForSchema(String schema) { 102 return pluginController.getStorageForSchema(schema); 103 } 104 105 @Override 106 public Collection<QueryInterface> getQueryPlugins(boolean onlyEnabled) { 107 return pluginController.getQueryPlugins(onlyEnabled); 108 } 109 110 @Override 111 public List<String> getQueryProvidersName(boolean enabled) { 112 return pluginController.getQueryProvidersName(enabled); 113 } 114 115 @Override 116 public QueryInterface getQueryProviderByName(String name, 117 boolean onlyEnabled) { 118 return pluginController.getQueryProviderByName(name, onlyEnabled); 119 } 120 121 @Override 122 public JointQueryTask queryAll(JointQueryTask holder, String query, 123 Object... parameters) { 124 return pluginController.queryAll(holder, query, parameters); 125 } 126 127 @Override 128 public Task<Iterable<SearchResult>> query(String querySource, String query, 129 Object... parameters) { 130 return pluginController.query(querySource, query, parameters); 131 } 132 133 @Override 134 public JointQueryTask query(JointQueryTask holder, 135 List<String> querySources, String query, Object... parameters) { 136 return pluginController.query(holder, querySources, query, parameters); 137 } 138 139 @Override 140 public List<Task<Report>> index(URI path) { 141 return pluginController.index(path); 142 } 143 144 @Override 145 public List<Report> indexBlocking(URI path) { 146 return pluginController.indexBlocking(path); 147 } 148 149 @Override 150 public ServerSettingsReader getSettings() { 151 return ServerSettings.getInstance(); 152 } 153 154}