Package com.socrata.datasync

Examples of com.socrata.datasync.SocrataConnectionInfo


    }



  public JobStatus run() {
    SocrataConnectionInfo connectionInfo = userPrefs.getConnectionInfo();

    JobStatus runStatus;
    JobStatus validationStatus = PortJobValidity.validateJobParams(connectionInfo, this);
    if (validationStatus.isError()) {
      runStatus = validationStatus;
    } else {
      // loader "loads" the source dataset metadata and schema
      final SodaDdl loader = SodaDdl.newDdl(sourceSiteDomain,
          connectionInfo.getUser(), connectionInfo.getPassword(),
          connectionInfo.getToken());

            // special feature to enable porting datasets to Staging (where app token is different)
            String portDestinationDomainAppToken = connectionInfo.getToken();
            if(userPrefs.getPortDestinationDomainAppToken() != null && !userPrefs.getPortDestinationDomainAppToken().equals("")) {
                portDestinationDomainAppToken = userPrefs.getPortDestinationDomainAppToken();
            }

      // creator "creates" a new dataset on the sink site (and publishes if applicable)
            final SodaDdl creator = SodaDdl.newDdl(sinkSiteDomain,
          connectionInfo.getUser(), connectionInfo.getPassword(),
                    portDestinationDomainAppToken);
      // streamExporter "exports" the source dataset rows
      final Soda2Consumer streamExporter = Soda2Consumer.newConsumer(
          sourceSiteDomain, connectionInfo.getUser(),
          connectionInfo.getPassword(), connectionInfo.getToken());
      // streamUpserter "upserts" the rows exported to the created dataset
      final Soda2Producer streamUpserter = Soda2Producer.newProducer(
          sinkSiteDomain, connectionInfo.getUser(),
          connectionInfo.getPassword(), portDestinationDomainAppToken);
      String errorMessage = "";
      boolean noPortExceptions = false;
      try {
        if (portMethod.equals(PortMethod.copy_schema)) {
          sinkSetID = PortUtility.portSchema(loader, creator,
View Full Code Here


            return null;
        }
    }

    public SocrataConnectionInfo getConnectionInfo() {
        return new SocrataConnectionInfo(
                this.getDomain(), this.getUsername(), this.getPassword(), this.getAPIKey());
    }
View Full Code Here

            return null;
        }
    }

    public SocrataConnectionInfo getConnectionInfo() {
        return new SocrataConnectionInfo(
                this.getDomain(), this.getUsername(), this.getPassword(), this.getAPIKey());
    }
View Full Code Here

            jobPanel.add(publishMethodContainerLeft);
            jobPanel.add(publishMethodContainerRight);
            publishMethodComboBox.setEnabled(true);
        }
        UserPreferences userPrefs = new UserPreferencesJava();
        SocrataConnectionInfo connectionInfo = userPrefs.getConnectionInfo();
        if (job.getSourceSiteDomain().equals("https://") &&
                !connectionInfo.getUrl().equals("https://")) {
            sourceSiteDomainTextField.setText(connectionInfo.getUrl());
        } else {
            sourceSiteDomainTextField.setText(job.getSourceSiteDomain());
        }
        sourceSetIDTextField.setText(job.getSourceSetID());
        if (job.getSinkSiteDomain().equals("https://") &&
                !connectionInfo.getUrl().equals("https://")) {
            sinkSiteDomainTextField.setText(connectionInfo.getUrl());
        } else {
            sinkSiteDomainTextField.setText(job.getSinkSiteDomain());
        }
        if (job.getSinkSetID().equals("") && !sinkSetIDTextField.isEditable()){
            sinkSetIDTextField.setText(DEFAULT_DESTINATION_SET_ID);
View Full Code Here

     * Runs an integration job. It is expected that 'configure' was run beforehand.
     * @return
     * @throws IOException
     */
    public JobStatus run() {
    SocrataConnectionInfo connectionInfo = userPrefs.getConnectionInfo();
    UpsertResult result = null;
        String publishExceptions = "";
        JobStatus runStatus = JobStatus.SUCCESS;

        JobStatus controlDeserialization = deserializeControlFile();
        if (controlDeserialization.isError() && (publishViaDi2Http || publishViaFTP)) {
            runStatus = controlDeserialization;
        } else {
            JobStatus validationStatus = IntegrationJobValidity.validateJobParams(connectionInfo, this);
            if (validationStatus.isError()) {
                runStatus = validationStatus;
            } else {
                Soda2Producer producer = null;
                try {
                    File fileToPublishFile = new File(fileToPublish);
                    if (publishViaDi2Http) {
                        try (DeltaImporter2Publisher publisher = new DeltaImporter2Publisher(userPrefs)) {
                            // "upsert" == "append" in di2
                            if ("upsert".equalsIgnoreCase(controlFile.action))
                                controlFile.action = "Append";
                            // TODO: remove the next line when di2 is updated to accept lowercase variants
                            controlFile.action = Utils.capitalizeFirstLetter(controlFile.action);
                            runStatus = publisher.publishWithDi2OverHttp(datasetID, fileToPublishFile, controlFile);
                        }
                    } else if (publishViaFTP) {
                        runStatus = doPublishViaFTPv2(fileToPublishFile);
                    } else {
                        // attach a requestId to all Producer API calls (for error tracking purposes)
                        String jobRequestId = Utils.generateRequestId();
                        producer = Soda2Producer.newProducerWithRequestId(
                                connectionInfo.getUrl(), connectionInfo.getUser(), connectionInfo.getPassword(), connectionInfo.getToken(), jobRequestId);
                        final SodaImporter importer = SodaImporter.newImporter(connectionInfo.getUrl(), connectionInfo.getUser(), connectionInfo.getPassword(), connectionInfo.getToken());
                        int filesizeChunkingCutoffBytes = userPrefs.getFilesizeChunkingCutoffMB() == null ? 10 * NUM_BYTES_PER_MB :
                                Integer.parseInt(userPrefs.getFilesizeChunkingCutoffMB()) * NUM_BYTES_PER_MB;
                        int numRowsPerChunk = userPrefs.getNumRowsPerChunk() == null ? 10000 :
                                Integer.parseInt(userPrefs.getNumRowsPerChunk());
                        switch (publishMethod) {
View Full Code Here

    }

    private String logRunResults(JobStatus runStatus, UpsertResult result) {
        String logDatasetID = userPrefs.getLogDatasetID();
        String logPublishingErrorMessage = null;
        SocrataConnectionInfo connectionInfo = userPrefs.getConnectionInfo();

        if (logDatasetID != null && !logDatasetID.equals("")) {
            String logDatasetUrl = userPrefs.getDomain() + "/d/" + userPrefs.getLogDatasetID();
            System.out.println("Publishing results to logging dataset (" + logDatasetUrl + ")...");
            logPublishingErrorMessage = addLogEntry(
View Full Code Here

    }

    private void emailAdmin(JobStatus status, String logPublishingErrorMessage) {
        String adminEmail = userPrefs.getAdminEmail();
        String logDatasetID = userPrefs.getLogDatasetID();
        SocrataConnectionInfo connectionInfo = userPrefs.getConnectionInfo();

        if(userPrefs.emailUponError() && adminEmail != null && !adminEmail.equals("")) {
            sendErrorNotificationEmail(
                    adminEmail, connectionInfo, status, status.getMessage(), logDatasetID, logPublishingErrorMessage);
        }
View Full Code Here

    public String getPortDestinationDomainAppToken() {
        return portDestinationDomainAppToken;
    }

    public SocrataConnectionInfo getConnectionInfo() {
        return new SocrataConnectionInfo(
                this.getDomain(), this.getUsername(), this.getPassword(), this.getAPIKey());
    }
View Full Code Here

        File oneRowFile = new File("src/test/resources/log_dataset_one_row.csv");
        Soda2Publisher.replaceNew(producer, ddl, UNITTEST_LOG_DATASET_ID, oneRowFile, true);

        IntegrationJob job = new IntegrationJob();
        UpsertResult result = new UpsertResult(1, 1, 1, new ArrayList<UpsertError>());
        SocrataConnectionInfo connectionInfo = new SocrataConnectionInfo(DOMAIN, USERNAME, PASSWORD, API_KEY);
        String logPublishingErrorMessage = job.addLogEntry(
                UNITTEST_LOG_DATASET_ID, connectionInfo, job, JobStatus.INVALID_DATASET_ID, result);

        TestCase.assertEquals(null, logPublishingErrorMessage);
        TestCase.assertEquals(2, getTotalRows(UNITTEST_LOG_DATASET_ID));
View Full Code Here

    @Test
    public void testAddLogEntryInvalidLogDatasetId() {
        IntegrationJob job = new IntegrationJob();
        UpsertResult result = new UpsertResult(1, 1, 1, new ArrayList<UpsertError>());
        SocrataConnectionInfo connectionInfo = new SocrataConnectionInfo(DOMAIN, USERNAME, PASSWORD, API_KEY);
        String logPublishingErrorMessage = job.addLogEntry(
                "xxxx-xxxx", connectionInfo, job, JobStatus.SUCCESS, result);

        TestCase.assertEquals("Not found", logPublishingErrorMessage);
    }
View Full Code Here

TOP

Related Classes of com.socrata.datasync.SocrataConnectionInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.