// Path: disambiguation-author/disambiguation-author-logic/src/main/java/pl/edu/icm/coansys/disambiguation/model/ContributorWithExtractedFeatures.java
// public class ContributorWithExtractedFeatures implements Serializable{
//     String docKey;
//     String contributorId;
//     Map<String,Collection<Integer>> metadata;
//     Integer surnameInt;
//     String surnameString;
//     boolean surnameNotNull;
// 
//     public ContributorWithExtractedFeatures(String docKey, String contributorId, Map<String, Collection<Integer>> metadata, Integer surnameInt, String surnameString, boolean surnameNotNull) {
//         this.docKey = docKey;
//         this.contributorId = contributorId;
//         this.metadata = metadata;
//         this.surnameInt = surnameInt;
//         this.surnameString = surnameString;
//         this.surnameNotNull = surnameNotNull;
//     }
// 
//     public String getDocKey() {
//         return docKey;
//     }
// 
//     public String getContributorId() {
//         return contributorId;
//     }
// 
//     public Map<String, Collection<Integer>> getMetadata() {
//         return metadata;
//     }
// 
//     public Integer getSurnameInt() {
//         return surnameInt;
//     }
// 
//     public String getSurnameString() {
//         return surnameString;
//     }
// 
//     public boolean isSurnameNotNull() {
//         return surnameNotNull;
//     }
//     
//     public Tuple asTuple(){
//         Object[] to = new Object[] { docKey, contributorId, surnameInt,
// 						hashMapToDataBag(), surnameString, isSurnameNotNull() };
// 		return  TupleFactory.getInstance()
// 						.newTuple(Arrays.asList(to));
//     }
//     
//     private HashMap<Object,DataBag> hashMapToDataBag(){
//         TupleFactory tf=TupleFactory.getInstance();
//         HashMap<Object,DataBag> ret=new HashMap<>();
//         for (Map.Entry<String,Collection<Integer>> entry:metadata.entrySet()){
//            DataBag db = new DefaultDataBag();
//            for (Integer i:entry.getValue()) {
//                db.add(tf.newTuple((Object) i));
//            }
//            ret.put(entry.getKey(), db);
//         }
//         return ret;
//         
//     }
//     
//     
// }


import pl.edu.icm.coansys.disambiguation.model.ContributorWithExtractedFeatures;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.apache.pig.EvalFunc;
import org.apache.pig.data.DataBag;
import org.apache.pig.data.Tuple;
import pl.edu.icm.coansys.disambiguation.idgenerators.IdGenerator;
import pl.edu.icm.coansys.disambiguation.idgenerators.UuIdGenerator;
/*
 * This file is part of CoAnSys project.
 * Copyright (c) 2012-2015 ICM-UW
 * 
 * CoAnSys 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.

 * CoAnSys 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 Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with CoAnSys. If not, see <http://www.gnu.org/licenses/>.
 */

package pl.edu.icm.coansys.disambiguation.author.pig;




/**
 * @author pdendek
 * @author mwos
 */
public class GenUUID extends EvalFunc< String> {

    private IdGenerator idgenerator = new UuIdGenerator();

    
// Path: disambiguation-author/disambiguation-author-logic/src/main/java/pl/edu/icm/coansys/disambiguation/model/ContributorWithExtractedFeatures.java
// public class ContributorWithExtractedFeatures implements Serializable{
//     String docKey;
//     String contributorId;
//     Map<String,Collection<Integer>> metadata;
//     Integer surnameInt;
//     String surnameString;
//     boolean surnameNotNull;
// 
//     public ContributorWithExtractedFeatures(String docKey, String contributorId, Map<String, Collection<Integer>> metadata, Integer surnameInt, String surnameString, boolean surnameNotNull) {
//         this.docKey = docKey;
//         this.contributorId = contributorId;
//         this.metadata = metadata;
//         this.surnameInt = surnameInt;
//         this.surnameString = surnameString;
//         this.surnameNotNull = surnameNotNull;
//     }
// 
//     public String getDocKey() {
//         return docKey;
//     }
// 
//     public String getContributorId() {
//         return contributorId;
//     }
// 
//     public Map<String, Collection<Integer>> getMetadata() {
//         return metadata;
//     }
// 
//     public Integer getSurnameInt() {
//         return surnameInt;
//     }
// 
//     public String getSurnameString() {
//         return surnameString;
//     }
// 
//     public boolean isSurnameNotNull() {
//         return surnameNotNull;
//     }
//     
//     public Tuple asTuple(){
//         Object[] to = new Object[] { docKey, contributorId, surnameInt,
// 						hashMapToDataBag(), surnameString, isSurnameNotNull() };
// 		return  TupleFactory.getInstance()
// 						.newTuple(Arrays.asList(to));
//     }
//     
//     private HashMap<Object,DataBag> hashMapToDataBag(){
//         TupleFactory tf=TupleFactory.getInstance();
//         HashMap<Object,DataBag> ret=new HashMap<>();
//         for (Map.Entry<String,Collection<Integer>> entry:metadata.entrySet()){
//            DataBag db = new DefaultDataBag();
//            for (Integer i:entry.getValue()) {
//                db.add(tf.newTuple((Object) i));
//            }
//            ret.put(entry.getKey(), db);
//         }
//         return ret;
//         
//     }
//     
//     
// }


// Path: disambiguation-author/disambiguation-author-logic/src/main/java/pl/edu/icm/coansys/disambiguation/author/pig/GenUUID.java
import pl.edu.icm.coansys.disambiguation.model.ContributorWithExtractedFeatures;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.apache.pig.EvalFunc;
import org.apache.pig.data.DataBag;
import org.apache.pig.data.Tuple;
import pl.edu.icm.coansys.disambiguation.idgenerators.IdGenerator;
import pl.edu.icm.coansys.disambiguation.idgenerators.UuIdGenerator;

/*
 * This file is part of CoAnSys project.
 * Copyright (c) 2012-2015 ICM-UW
 * 
 * CoAnSys 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.

 * CoAnSys 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 Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with CoAnSys. If not, see <http://www.gnu.org/licenses/>.
 */

package pl.edu.icm.coansys.disambiguation.author.pig;




/**
 * @author pdendek
 * @author mwos
 */
public class GenUUID extends EvalFunc< String> {

    private IdGenerator idgenerator = new UuIdGenerator();

    
    public String exec(Collection<ContributorWithExtractedFeatures> cwe) {