@Override public long getCount(CommandOutput<?, ?> response) throws RecordCountException { log.info("Get source record count from salesforce"); String output; Iterator<String> itr = (Iterator<String>) response.getResults().values().iterator(); if (itr.hasNext()) { output = itr.next(); } else { throw new RecordCountException("Failed to get count from salesforce; REST response has no output"); } JsonElement element = GSON.fromJson(output, JsonObject.class); long count; try { JsonObject jsonObject = element.getAsJsonObject(); count = jsonObject.get("totalSize").getAsLong(); } catch (Exception e) { throw new RecordCountException("Failed to get record count from salesforce; error - " + e.getMessage(), e); } return count; }
@Override public long getCount(CommandOutput<?, ?> response) throws RecordCountException { this.log.debug("Extract source record count from resultset"); ResultSet resultset = null; long count = 0; Iterator<ResultSet> itr = (Iterator<ResultSet>) response.getResults().values().iterator(); if (itr.hasNext()) { resultset = itr.next(); try { if (resultset.next()) { count = resultset.getLong(1); } } catch (Exception e) { throw new RecordCountException("Failed to get source record count from database; error - " + e.getMessage(), e); } } else { throw new RuntimeException("Failed to get source record count from database - Resultset has no records"); } return count; }
@Override public long getSourceCount(String schema, String entity, WorkUnit workUnit, List<Predicate> predicateList) throws RecordCountException { log.info("Get source record count using Rest Api"); long count = 0; try { boolean success = this.connector.connect(); if (!success) { throw new RecordCountException("Failed to connect."); } log.debug("Connected successfully."); List<Command> cmds = this.getCountMetadata(schema, entity, workUnit, predicateList); CommandOutput<?, ?> response = this.connector.getResponse(cmds); count = getCount(response); log.info("Source record count:" + count); return count; } catch (Exception e) { throw new RecordCountException("Failed to get record count using rest api; error - " + e.getMessage(), e); } }
@Override public long getSourceCount(String schema, String entity, WorkUnit workUnit, List<Predicate> predicateList) throws RecordCountException { this.log.info("Get source record count using JDBC"); long count = 0; try { List<Command> cmds = this.getCountMetadata(schema, entity, workUnit, predicateList); CommandOutput<?, ?> response = this.executeSql(cmds); count = this.getCount(response); this.log.info("Source record count:" + count); return count; } catch (Exception e) { throw new RecordCountException("Failed to get source record count using JDBC; error - " + e.getMessage(), e); } }
return constructGetCommand(this.sfConnector.getFullUri(getSoqlUrl(query))); } catch (Exception e) { throw new RecordCountException("Failed to get salesforce url for record count; error - " + e.getMessage(), e);
@Override public long getCount(CommandOutput<?, ?> response) throws RecordCountException { this.log.debug("Extract source record count from resultset"); ResultSet resultset = null; long count = 0; Iterator<ResultSet> itr = (Iterator<ResultSet>) response.getResults().values().iterator(); if (itr.hasNext()) { resultset = itr.next(); try { if (resultset.next()) { count = resultset.getLong(1); } } catch (Exception e) { throw new RecordCountException("Failed to get source record count from database; error - " + e.getMessage(), e); } } else { throw new RuntimeException("Failed to get source record count from database - Resultset has no records"); } return count; }
@Override public long getSourceCount(String schema, String entity, WorkUnit workUnit, List<Predicate> predicateList) throws RecordCountException { log.info("Get source record count using Rest Api"); long count = 0; try { boolean success = this.connector.connect(); if (!success) { throw new RecordCountException("Failed to connect."); } log.debug("Connected successfully."); List<Command> cmds = this.getCountMetadata(schema, entity, workUnit, predicateList); CommandOutput<?, ?> response = this.connector.getResponse(cmds); count = getCount(response); log.info("Source record count:" + count); return count; } catch (Exception e) { throw new RecordCountException("Failed to get record count using rest api; error - " + e.getMessage(), e); } }
@Override public long getSourceCount(String schema, String entity, WorkUnit workUnit, List<Predicate> predicateList) throws RecordCountException { this.log.info("Get source record count using JDBC"); long count = 0; try { List<Command> cmds = this.getCountMetadata(schema, entity, workUnit, predicateList); CommandOutput<?, ?> response = this.executeSql(cmds); count = this.getCount(response); this.log.info("Source record count:" + count); return count; } catch (Exception e) { throw new RecordCountException("Failed to get source record count using JDBC; error - " + e.getMessage(), e); } }