package org.zoneproject.extractor.plugin.wikimeta;

/*
 * #%L
 * ZONE-plugin-WikiMeta
 * %%
 * Copyright (C) 2012 ZONE-project
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * #L%
 */

import java.util.ArrayList;
import org.zoneproject.extractor.utils.Database;
import org.zoneproject.extractor.utils.Item;
import org.zoneproject.extractor.utils.Prop;
import org.zoneproject.extractor.utils.ZoneOntology;

/**
 *
 * @author Desclaux Christophe <christophe@zouig.org>
 */

public class App 
{
    private static final org.apache.log4j.Logger  logger = org.apache.log4j.Logger.getLogger(App.class);
    public static String PLUGIN_URI = ZoneOntology.PLUGIN_WIKIMETA;
    public static int SIM_DOWNLOADS = 20;
    
    public App(){
        String [] tmp = {};
        App.main(tmp);
    }
    
    public static void main(String[] args) {
        Item[] items = null;
        String [] deps = {ZoneOntology.PLUGIN_EXTRACT_ARTICLES_CONTENT};
        WikiMetaRequestThread[] th = new WikiMetaRequestThread[SIM_DOWNLOADS];
        do{
            items = Database.getItemsNotAnotatedForPluginsWithDeps(PLUGIN_URI,deps,SIM_DOWNLOADS);
            logger.info("WikiMeta has "+items.length+" items to annotate");
            for(int i=0; i < items.length; i++){
                th[i] = new WikiMetaRequestThread(items[i]);
                th[i].start();
            }
            
            for(int i=0; i < items.length; i++){
                try {
                    th[i].join();
                } catch (InterruptedException ex) {
                    logger.warn(ex);
                }
            }
        }while(items.length > 0);
    }
}

@@ -1840,131 +1840,113 @@
 for(
-int i=0; i %3C items.length; i++)%7B%0A                th%5Bi%5D = new WikiMetaRequestThread(items%5Bi%5D);%0A                th%5Bi%5D.star
+Item item : items)%7B%0A                ArrayList%3CProp%3E content= WikiMetaRequest.getProperties(item.conca
 t()
+)
 ;%0A  
@@ -1959,234 +1959,148 @@
     
-%7D%0A
     
-        %0A            for(int i=0; i %3C items.length; i++)%7B%0A                try %7B%0A                    th%5Bi%5D.join();%0A                %7D catch (InterruptedException ex) %7B%0A                    logger.warn(ex);%0A                %7D
+Database.addAnnotations(item.getUri(), content);%0A                Database.addAnnotation(item.getUri(), new Prop(App.PLUGIN_URI,%22true%22));
 %0A   

remove the multithread extraction entities from wikimeta