Package com.socrata.api

Examples of com.socrata.api.SodaWorkflow


      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;
          }
          noExceptions = true;
        }
      }
      catch (SodaError sodaError) {
                runErrorMessage = sodaError.getMessage();
                runStatus = JobStatus.PUBLISH_ERROR;
      }
      catch (InterruptedException intrruptException) {
        runErrorMessage = intrruptException.getMessage();
        runStatus = JobStatus.PUBLISH_ERROR;
      }
      catch (Exception other) {
        runErrorMessage = other.toString() + ": " + other.getMessage() + " \r\n " + ExceptionUtils.getStackTrace(other);
        runStatus = JobStatus.PUBLISH_ERROR;
      }
      finally {
        try {
          if (!StringUtils.isBlank(workingCopyDatasetId))  {
            workflower.publish(workingCopyDatasetId);
          }
        }
        catch(Exception e) {
          runErrorMessage += " | Unable to publish dataset after updates";
          runStatus = JobStatus.PUBLISH_ERROR;
View Full Code Here

TOP

Related Classes of com.socrata.api.SodaWorkflow

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.