/*
 * Copyright (c) 2015-2016, Pradeeban Kathiravelu and others. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package edu.emory.bmi.datacafe.mongo;

import org.bson.Document;

import java.util.List;

/**
 * A wrapper to write from Mongo to HDFS.
 */
public class MongoHDFSIntegrator {

    /**
     * Gets all the chosen attributes of all the data sources as an array of lists.
     * @param databases the databases
     * @param collections the collections in the respective databases.
     * @param mongoConnector MongoConnector
     * @param idsArray the arrayOfIds.
     * @return an array of lists consisting of Ids.
     */
    public static List[] getAllChosenAttributes(String[] databases, String[] collections,
                                                MongoConnector mongoConnector, List[] idsArray) {
        List[] chosenAttributes = new List[collections.length];

        // Let's get all attributes except the autogenerated _id for now.
        for (int i = 0; i < collections.length; i++) {
            chosenAttributes[i] =
                    mongoConnector.getAllAttributeValuesExceptAutoGenMongoId(databases[i], collections[i], idsArray[i]);
        }
        return chosenAttributes;
    }

    /**
     * Get a list of all the Ids
     * @param databases the databases as an array
     * @param collections the collections in the respective databases.
     * @param mongoConnector the MongoConnector
     * @param documents the Document objects as an array
     * @return the list of Ids.
     */
    public static List[] getListsOfIds(String[] databases, String[] collections, MongoConnector mongoConnector,
                                       Document[] documents) {
        List[] idsArray = new List[collections.length];

        /**
         * Get the list of IDs for all the chosen sub set of collections.
         */
        for (int i = 0; i < collections.length; i++) {
            idsArray[i] = mongoConnector.getIDs(databases[i], collections[i], documents[i]);
        }
        return idsArray;
    }

}

/*
 * Copyright (c) 2015-2016, Pradeeban Kathiravelu and others. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package edu.emory.bmi.datacafe.mongo;

import org.bson.Document;

import java.util.List;

/**
 * A wrapper to write from Mongo to HDFS in a parallel manner for each of the Mongo collection.
 */
public class MongoHDFSIntegrator {

    /**
     * Gets all the chosen attributes of all the data sources as an array of lists.
     * @param databases the databases
     * @param collections the collections in the respective databases.
     * @param mongoConnector MongoConnector
     * @param idsArray the arrayOfIds.
     * @return an array of lists consisting of Ids.
     */
    public static List[] getAllChosenAttributes(String[] databases, String[] collections,
                                                MongoConnector mongoConnector, List[] idsArray) {
        List[] chosenAttributes = new List[collections.length];

        // Let's get all attributes except the autogenerated _id for now.
        for (int i = 0; i < collections.length; i++) {
            chosenAttributes[i] =
                    mongoConnector.getAllAttributeValuesExceptAutoGenMongoId(databases[i], collections[i], idsArray[i]);
        }
        return chosenAttributes;
    }

    /**
     * Get a list of all the Ids
     * @param databases the databases as an array
     * @param collections the collections in the respective databases.
     * @param mongoConnector the MongoConnector
     * @param documents the Document objects as an array
     * @return the list of Ids.
     */
    public static List[] getListsOfIds(String[] databases, String[] collections, MongoConnector mongoConnector,
                                       Document[] documents) {
        List[] idsArray = new List[collections.length];

        /**
         * Get the list of IDs for all the chosen sub set of collections.
         */
        for (int i = 0; i < collections.length; i++) {
            idsArray[i] = mongoConnector.getIDs(databases[i], collections[i], documents[i]);
        }
        return idsArray;
    }

}

Improve comment.