Package com.socrata.api

Examples of com.socrata.api.SodaDdl


     */
    @Test
    public void testSimpleQuery4x4() throws LongRunningQueryException, SodaError, InterruptedException, IOException
    {
        final HttpLowLevel  connection = connect();
        final SodaDdl       sodaDdl= new SodaDdl(connection);

        final SearchResults results =  sodaDdl.searchViews(new SearchClause.NameSearch("Test Data"));
        final String id = results.getResults().get(0).getDataset().getId();
        executeSimpleQuery(connection, id);
    }
View Full Code Here


    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(),
View Full Code Here

    if(validationStatus.isError()) {
      runStatus = validationStatus;
    } else {

      final SodaDdl updater = SodaDdl.newDdl(connectionInfo.getUrl(), connectionInfo.getUser(),
          connectionInfo.getPassword(), connectionInfo.getToken());
      final SodaWorkflow workflower = SodaWorkflow.newWorkflow(connectionInfo.getUrl(), connectionInfo.getUser(),
          connectionInfo.getPassword(), connectionInfo.getToken());

      boolean noExceptions = false;
      try {
        DatasetInfo datasetInfo = updater.loadDatasetInfo(datasetID);

        if (datasetInfo == null) {
          runErrorMessage = "Dataset with that ID does not exist or you do not have permission to publish to it";
          runStatus = JobStatus.PUBLISH_ERROR;
        }
        else {
          if (datasetInfo.PUBLISHED.equals(datasetInfo.getPublicationStage())) {
            DatasetInfo workingCopyDatasetInfo = workflower.createWorkingCopy(datasetInfo.getId());
            datasetInfo = updater.loadDatasetInfo(workingCopyDatasetInfo.getId());
            workingCopyDatasetId = datasetInfo.getId();
          }

          datasetInfo.setName(title);
          datasetInfo.setDescription(description);
          datasetInfo.setCategory(category);
          if (keywords != null && !keywords.isEmpty()) {
            datasetInfo.setTags(keywords);
          }
          else {
            datasetInfo.setTags(new ArrayList<String>());
          }
          if (licenseType != null) {
            //TODO: Once issue with setting no license via api is resolved, update below to handle
            if (licenseType == LicenseType.no_license) {
              datasetInfo.setLicenseId(""); //null, "", "''", "\"\"", Tried all of these, no luck, validation errors on all, so
            }
            else {
              datasetInfo.setLicenseId(licenseType.getValue());
            }
          }
          datasetInfo.setAttribution(dataProvidedBy);
          datasetInfo.setAttributionLink(sourceLink);
          Map<String, Object> privateMetadata = datasetInfo.getPrivateMetadata();
          if (privateMetadata == null) {
            privateMetadata = new HashMap<String, Object>();
          }
          privateMetadata.put("contactEmail", contactInfo);

          updater.updateDatasetInfo(datasetInfo);

          if (!StringUtils.isBlank(workingCopyDatasetId)) {
            workflower.publish(datasetInfo.getId());
            workingCopyDatasetId = null;
          }
View Full Code Here

  }

  public String loadCurrentMetadata() {
    try {
      SocrataConnectionInfo connectionInfo = userPrefs.getConnectionInfo();
      final SodaDdl sodaDdl = SodaDdl.newDdl(connectionInfo.getUrl(), connectionInfo.getUser(),
          connectionInfo.getPassword(), connectionInfo.getToken());
      readDatasetInfo(sodaDdl.loadDatasetInfo(datasetID));
      return "";
    }
    catch(Exception e) {
      return e.getMessage();
    }
View Full Code Here

public class IntegrationUtilityTest extends TestBase {

    @Test
    public void testReplaceNew() throws LongRunningQueryException, SodaError, IOException, InterruptedException {
        final Soda2Producer producer = createProducer();
        final SodaDdl ddl = createSodaDdl();

        File twoRowsFile = new File("src/test/resources/datasync_unit_test_two_rows.csv");
        UpsertResult result = Soda2Publisher.replaceNew(producer, ddl, UNITTEST_DATASET_ID, twoRowsFile, true);

        TestCase.assertEquals(0, result.errorCount());
View Full Code Here

    }

    @Test
    public void testReplaceNewNoHeader() throws LongRunningQueryException, SodaError, IOException, InterruptedException {
        final Soda2Producer producer = createProducer();
        final SodaDdl ddl = createSodaDdl();

        File twoRowsFile = new File("src/test/resources/datasync_unit_test_three_rows_no_header.csv");
        UpsertResult result = Soda2Publisher.replaceNew(producer, ddl, UNITTEST_DATASET_ID, twoRowsFile, false);

        TestCase.assertEquals(0, result.errorCount());
View Full Code Here

    }

    @Test
    public void testReplaceNewTSVFile() throws LongRunningQueryException, SodaError, IOException, InterruptedException {
        final Soda2Producer producer = createProducer();
        final SodaDdl ddl = createSodaDdl();

        File threeRowsFile = new File("src/test/resources/datasync_unit_test_three_rows.tsv");
        UpsertResult result = Soda2Publisher.replaceNew(producer, ddl, UNITTEST_DATASET_ID, threeRowsFile, true);

        TestCase.assertEquals(0, result.errorCount());
View Full Code Here

    }

    @Test
    public void testReplaceNewTSVFileNoHeader() throws LongRunningQueryException, SodaError, IOException, InterruptedException {
        final Soda2Producer producer = createProducer();
        final SodaDdl ddl = createSodaDdl();

        File threeRowsFile = new File("src/test/resources/datasync_unit_test_three_rows_no_header.tsv");
        UpsertResult result = Soda2Publisher.replaceNew(producer, ddl, UNITTEST_DATASET_ID, threeRowsFile, false);

        TestCase.assertEquals(0, result.errorCount());
View Full Code Here

    }

    @Test
    public void testUpsertZeroRows() throws IOException, SodaError, InterruptedException, LongRunningQueryException {
        final Soda2Producer producer = createProducer();
        final SodaDdl ddl = createSodaDdl();

        int numRowsBegin = getTotalRows(UNITTEST_DATASET_ID);

        File zeroRowsFile = new File("src/test/resources/datasync_unit_test_zero_rows.csv");
        UpsertResult result = Soda2Publisher.appendUpsert(producer, ddl, UNITTEST_DATASET_ID, zeroRowsFile, 0, true);
View Full Code Here

    }

    @Test
    public void testUpsertNoChunking() throws IOException, SodaError, InterruptedException, LongRunningQueryException {
        final Soda2Producer producer = createProducer();
        final SodaDdl ddl = createSodaDdl();

        // Ensures dataset is in known state (2 rows)
        File twoRowsFile = new File("src/test/resources/datasync_unit_test_two_rows.csv");
        Soda2Publisher.replaceNew(producer, ddl, UNITTEST_DATASET_ID, twoRowsFile, true);
View Full Code Here

TOP

Related Classes of com.socrata.api.SodaDdl

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.