add: reset Solr schema filed selection to default button in IndexSchema_p

pull/1/head
reger 12 years ago
parent a725a4242f
commit d57b221921

@ -47,7 +47,10 @@
</table>
</div>
</fieldset>
<div>
<input type="submit" name="set" value="Set" />
<input style="float:right" type="submit" name="resetselectiontodefault" value="reset selection to default" />
</div>
</form>
#%env/templates/footer.template%#

@ -18,14 +18,17 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import net.yacy.cora.federate.solr.SchemaConfiguration;
import net.yacy.cora.federate.solr.SchemaDeclaration;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.kelondro.logging.Log;
import net.yacy.search.Switchboard;
import net.yacy.search.schema.CollectionSchema;
import net.yacy.search.schema.WebgraphConfiguration;
import net.yacy.search.schema.WebgraphSchema;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
@ -74,6 +77,27 @@ public class IndexSchema_p {
}
}
if (post != null && post.containsKey("resetselectiontodefault")) {
// reset Solr field selection to default configuration
File solrInitFile;
if (cs instanceof WebgraphConfiguration) { // get default configuration for webgraph
solrInitFile = new File(sb.getAppPath(), "defaults/" + Switchboard.SOLR_WEBGRAPH_CONFIGURATION_NAME);
} else { // or get default configuration for collection1
solrInitFile = new File(sb.getAppPath(), "defaults/" + Switchboard.SOLR_COLLECTION_CONFIGURATION_NAME);
}
try {
SchemaConfiguration solrConfigurationInit = new SchemaConfiguration(solrInitFile);
Iterator<SchemaConfiguration.Entry> it = cs.entryIterator(); // get current configuration
while (it.hasNext()) { // iterate over entries and enable/disable according to default
SchemaConfiguration.Entry etr = it.next();
etr.setEnable(solrConfigurationInit.contains(etr.key()));
}
cs.commit();
} catch (IOException ex) {
Log.logWarning("IndexSchema", "file " + solrInitFile.getAbsolutePath() + " not found");
}
}
int c = 0;
boolean dark = false;
// use enum SolrField to keep defined order

@ -206,8 +206,8 @@ import com.google.common.io.Files;
public final class Switchboard extends serverSwitch {
final static String SOLR_COLLECTION_CONFIGURATION_NAME_OLD = "solr.keys.default.list";
final static String SOLR_COLLECTION_CONFIGURATION_NAME = "solr.collection.schema";
final static String SOLR_WEBGRAPH_CONFIGURATION_NAME = "solr.webgraph.schema";
public final static String SOLR_COLLECTION_CONFIGURATION_NAME = "solr.collection.schema";
public final static String SOLR_WEBGRAPH_CONFIGURATION_NAME = "solr.webgraph.schema";
// load slots
public static int xstackCrawlSlots = 2000;

Loading…
Cancel
Save