private <T extends AbstractEdmEntityImpl, G extends MongoTermList<T>> boolean migratePhaseOne(
      JacksonDBCollection<G, String> termListColl_source,
      JacksonDBCollection<MongoTerm, String> termColl_source,
      JacksonDBCollection<G, String> termListColl_target,
      JacksonDBCollection<MongoTerm, String> termColl_target,
      ContextualCategory contextualCategory,
      String termCollection)
      throws UnknownHostException {
    int skip = 0;
    int counter = 0;
    while (true) {
      try {
        DBCursor<G> curs =
            termListColl_source
                .find(new BasicDBObject("entityType", contextualCategory.getEntityClass()))
                .skip(skip);
        curs.addOption(com.mongodb.Bytes.QUERYOPTION_NOTIMEOUT);

        while (curs.hasNext()) {
          long nextSequence = nextSequence(contextualCategory);
          counter++;

          G termList = curs.next();
          String newCodeUri =
              String.format(
                  "http://data.europeana.eu/%s/base" + "/%d",
                  contextualCategory.getLabel(), nextSequence);
          String oldCodeUri = termList.getCodeUri();

          MongoCodeLookup lookup = new MongoCodeLookup();
          lookup.setCodeUri(newCodeUri);
          lookup.setOriginalCodeUri(oldCodeUri);
          lookupColl_target.insert(lookup);

          lookupCodeUri.put(newCodeUri, oldCodeUri);
          lookupOriginalCodeUri.put(oldCodeUri, newCodeUri);
        }
        curs.close();
        break;
      } catch (Exception e) {
        e.printStackTrace();
        initialiseConnections();

        skip = counter - 1;
        continue;
      }
    }
    return true;
  }
 public void addInCache(MongoCodeLookup lookup) {
   lookupCodeUri.put(lookup.getCodeUri(), lookup.getOriginalCodeUri());
   lookupOriginalCodeUri.put(lookup.getOriginalCodeUri(), lookup.getCodeUri());
 }