You are here

private function GLExchange::_createSubmissionInfo in GlobalLink Connect for Drupal 7.7

1 call to GLExchange::_createSubmissionInfo()
GLExchange::startSubmission in gl_ws/glc/GLExchange.php
* * Start Submission * *

File

gl_ws/glc/GLExchange.php, line 115

Class

GLExchange

Code

private function _createSubmissionInfo() {
  $submissionInfo = new SubmissionInfo();
  $submissionInfo->projectTicket = $this->submission->project->ticket;
  $submissionInfo->name = $this->submission->name;
  if (isset($this->submission->pmNotes)) {
    $submissionInfo->internalNotes = $this->submission->pmNotes;
  }
  if (isset($this->submission->dueDate)) {
    $dateRequested = new Date();
    $dateRequested->date = $this->submission->dueDate;
    $dateRequested->critical = false;
    $submissionInfo->dateRequested = $dateRequested;
  }
  if (isset($this->submission->metadata)) {
    $i = 0;
    $metadatas = array();
    foreach ($this->submission->metadata as $k => $v) {
      $metadata = new Metadata();
      $metadata->key = substr($k, 0, 255);
      $metadata->value = substr($v, 0, 1024);
      $metadatas[$i++] = $metadata;
    }
    $submissionInfo->metadata = $metadatas;
  }
  if (isset($this->submission->submitter)) {
    $submissionInfo->submitters = array(
      $this->submission->submitter,
    );
  }
  if (isset($this->submission->isUrgent) && $this->submission->isUrgent == TRUE) {
    $priority = new Priority();
    $priority->value = 2;
    $submissionInfo->priority = $priority;
  }
  if (isset($this->submission->customAttributes)) {
    $attributes = array();
    foreach ($this->submission->customAttributes as $k => $v) {
      $submissionCustomField = new SubmissionCustomFields();
      $submissionCustomField->fieldName = $k;
      $submissionCustomField->fieldValue = $v;
      $attributes[] = $submissionCustomField;
    }
    $submissionInfo->submissionCustomFields = $attributes;
  }
  if (isset($this->submission->workflow) && $this->submission->workflow->ticket != "") {
    $submissionInfo->workflowDefinitionTicket = $this->submission->workflow->ticket;
  }
  return $submissionInfo;
}