package org.sli.orient.importer.importers;

import java.util.logging.Level;

import com.mongodb.DB;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.tinkerpop.blueprints.Graph;

public class EdOrgImporter extends BaseImporter {
    
    public EdOrgImporter(DB m, Graph g) {
        super(m, g);
    }
    public void importCollection() {
        DBCursor cursor = mongo.getCollection("educationOrganization").find();
        cursor.batchSize(100);
        while (cursor.hasNext()) {

            DBObject edOrg = cursor.next();
            logger.log(Level.INFO, "Adding edOrg#" + edOrg.get("_id") + " to the graph");

        }
    }
    
}

@@ -37,16 +37,38 @@
 rters;%0A%0A
+import java.util.Map;%0A
 import j
@@ -211,16 +211,56 @@
 s.Graph;
+%0Aimport com.tinkerpop.blueprints.Vertex;
 %0A%0Apublic
@@ -317,71 +317,487 @@
    p
-ublic EdOrgImporter(DB m, Graph g) %7B%0A        super(m, g);%0A    %7D
+rivate static final String EDUCATION_ORGANIZATION = %22educationOrganization%22;%0A    private static final String EDUCATION_ORGANIZATION_ASSOCIATION = %22educationOrganizationAssociation%22;%0A    %0A    public EdOrgImporter(DB m, Graph g) %7B%0A        super(m, g);%0A    %7D%0A    %0A    /**%0A     * Imports education organizations into the graph structure. Then coalesces hierarchy by%0A     * 'parentEducationAgencyReference' contained in the 'body' of each education organization.%0A     */%0A    @Override
 %0A   
@@ -880,69 +880,37 @@
 ion(
-%22educationOrganization%22).find();%0A        cursor.batchSize(100
+EDUCATION_ORGANIZATION).find(
 );%0A 
@@ -943,17 +943,16 @@
 xt()) %7B%0A
-%0A
         
@@ -1003,95 +1003,1067 @@
     
-logger.log(Level.INFO, %22Adding edOrg#%22 + edOrg.get(%22_id%22) + %22 to the graph%22);%0A%0A
+String currentEdOrgId = (String) edOrg.get(%22_id%22);%0A            %0A            Vertex v = graph.addVertex(null);%0A            logger.log(Level.INFO, %22Adding vertex for %7B0%7D#%7B1%7D %5Ct %7B2%7D%22, new String%5B%5D %7B EDUCATION_ORGANIZATION,%0A                    currentEdOrgId, v.getId().toString() %7D);%0A            %0A            v.setProperty(%22mongoid%22, currentEdOrgId);%0A            %0A            @SuppressWarnings(%22unchecked%22)%0A            Map%3CString, Object%3E body = (Map%3CString, Object%3E) edOrg.get(%22body%22);%0A            if (body.containsKey(%22parentEducationAgencyReference%22)) %7B%0A                String parentId = (String) body.get(%22parentEducationAgencyReference%22);%0A                for (Vertex child : graph.getVertices(%22mongoid%22, currentEdOrgId)) %7B%0A                    for (Vertex parent : graph.getVertices(%22mongoid%22, parentId)) %7B%0A                        graph.addEdge(null, parent, child, EDUCATION_ORGANIZATION_ASSOCIATION);%0A                        logger.log(Level.INFO, %22Adding an edge between ed org: %22 + parentId + %22 --%3E %22 + currentEdOrgId);%0A                    %7D%0A    
         
 %7D%0A  
@@ -2062,19 +2062,42 @@
     
+    
 %7D%0A    
-%7D%0A
     
+    %7D%0A        %7D%0A    %7D
 %0A%7D%0A

update logic for creating education organization vertices and edges between associated SEAs/LEAs/schools