private boolean isTargetEmpty(ViewDataMigrationContext migrationContext) {
    if (migrationContext.getCurrentInstanceDataByUser().size() > 0) {
      return false;
    }

    try {
      for (Class entity : migrationContext.getCurrentEntityClasses().values()) {
        if (migrationContext.getCurrentDataStore().findAll(entity, null).size() > 0) {
          return false;
        }
      }
    } catch (PersistenceException e) {
      ViewInstanceDefinition current = migrationContext.getCurrentInstanceDefinition();
      LOG.error("Persistence exception while check if instance is empty: " +
          current.getViewDefinition().getViewName() + "{" + current.getViewDefinition().getVersion() + "}/" +
          current.getInstanceName(), e);
    }

    return true;
  }
Migrates data from source to target instance
@param targetInstanceDefinition target instance entity
@param sourceInstanceDefinition source instance entity
@param migrateOnce cancel if previously migrated

@throws ViewDataMigrationException when view does not support migration or an error during migration occurs.
ambari-server/src/main/java/org/apache/ambari/server/view/ViewDataMigrationUtility.java