/** * Declares an association between this object and a SchemaPropertyElement object. * * @param SchemaPropertyElement $v * @return void * @throws PropelException */ public function setSchemaPropertyElement($v) { if ($v === null) { $this->setSchemaPropertyElementId(NULL); } else { $this->setSchemaPropertyElementId($v->getId()); } $this->aSchemaPropertyElement = $v; }
/** * @param $key * @param $value * @param $propertyId * @param $updateTime * @param $rowStatusId * @param $cellLanguage * @param $cellType * @param $schemaId * * @return array $results * @throws \PropelException */ private function SetPropertyElement( $key, $value, $propertyId, $updateTime, $rowStatusId, $cellLanguage, $cellType ) { $profilePropertyId = $this->prolog['columns'][$key]['id']; if (is_array($profilePropertyId)) { $profilePropertyId = $profilePropertyId[0]; } //check to see if the property already exists //note that this also checks the object value as well, so there's no way to update or delete an existing triple //the sheet would have to contain the identifier for the triple //actually there is. We look for exact matches and skip the update of an exact match, //but then we look at just the old properties that are left -- the ones where the property matches but the object doesn't //and we update those. If we have any properties left after that, we add them as new. //We need to add an instruction to the spreadsheet to treat an empty property cell as a skip or a delete //and if an empty cell means delete, then we delete those //get the language for this thing //if there's a prolog set for the language for this column, use it //use the default for the import (already set above) //fall back to the default language of the vocabulary //get the fqn if using curies if ($cellType and $this->useCuries) { $value = $this->getFqn($value); } $StatementCounter['status'] = 'skipped'; /** @var \SchemaPropertyElement[] $element */ $element = \SchemaPropertyElementPeer::lookupElement($propertyId, $profilePropertyId, $value, $cellLanguage); if ($element) { if (1 === count($element)) { $element = $element[0]; //make sure we handle the special case of subproperty and subclass if (empty( $value ) && $element->getIsSchemaProperty() && in_array($element->getProfilePropertyId(), [ 6, 9 ]) ) { return $StatementCounter; } } else { //it's ambiguous and we stop processing, logging an error to be dealt with later $error['Message'] = "Ambiguous update"; $error['PropertyId'] = $propertyId; $error['ProfilePropertyId'] = $profilePropertyId; $error['UpdateValue'] = $value; $this->results['errors'][] = $error; } } //create a new propertyelement for each unmatched column //we didn't find an existing element, make a new one if ( ! $element && ! empty( $value )) { $element = new \SchemaPropertyElement; $element->setCreatedUserId($this->userId); $element->setCreatedAt($updateTime); $element->setProfilePropertyId($profilePropertyId); $element->setSchemaPropertyId($propertyId); $StatementCounter['status'] = 'created'; } if ( ! $element) { return $StatementCounter; } if (( $value != $element->getObject() ) || ( $cellLanguage != $element->getLanguage() )) { /** * @todo We need a check here for objectproperties and handle differently * if it's a URI, and it uses namespaces, and we have the namespace, do the substitution **/ if ( ! $cellType and $cellLanguage) { if ($cellLanguage != $element->getLanguage()) { $element->setLanguage($cellLanguage); } } } if ($value != $element->getObject()) { if ( ! empty( $value )) { $element->setObject($value); } else { $element->setDeletedAt($updateTime); } } if ($element->isNew() or $element->isModified()) { $element->setUpdatedUserId($this->userId); $element->setUpdatedAt($updateTime); $element->setStatusId($rowStatusId); $element->importId = $this->importId; $element->save(); if ($StatementCounter['status'] != 'created') { $StatementCounter['status'] = 'modified'; } if (is_array($element->getProfilePropertyId())) { $profilePropertyId = $element->getProfilePropertyId()[0]; } else { $profilePropertyId = $element->getProfilePropertyId(); } /** @var \ProfileProperty $profileProperty */ $profileProperty = $this->profileProperties[$profilePropertyId]; $StatementCounter['column'] = $key; $StatementCounter['id'] = $element->getId(); $StatementCounter['propertyId'] = $element->getProfilePropertyId(); $StatementCounter['object'] = $element->getObject(); $StatementCounter['type'] = $cellType; $StatementCounter['language'] = $cellLanguage; } unset( $element ); return $StatementCounter; }