public function objectPropertyDataProvider() { $propertyType = PropertyType::cast(PropertyType::ID); $cardinality = Cardinality::cast(Cardinality::MULTI); $updatability = Updatability::cast(Updatability::ONCREATE); $choices = array($this->getMockBuilder('\\Dkd\\PhpCmis\\Definitions\\ChoiceInterface')->getMockForAbstractClass()); return array(array('propertyType', $propertyType, $propertyType), array('cardinality', $cardinality, $cardinality), array('updatability', $updatability, $updatability), array('choices', $choices, $choices)); }
/** * Copies the document manually. The content is streamed from the repository and back. * * @param ObjectIdInterface|null $targetFolderId the ID of the target folder, <code>null</code> to create an unfiled * document * @param array $properties The property values that MUST be applied to the object. This list of properties SHOULD * only contain properties whose values differ from the source document. The array key is the property name * the value is the property value. * @param VersioningState|null $versioningState An enumeration specifying what the versioning state of the * newly-created object MUST be. Valid values are: * <code>none</code> * (default, if the object-type is not versionable) The document MUST be created as a non-versionable * document. * <code>checkedout</code> * The document MUST be created in the checked-out state. The checked-out document MAY be * visible to other users. * <code>major</code> * (default, if the object-type is versionable) The document MUST be created as a major version. * <code>minor</code> * The document MUST be created as a minor version. * @param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created document * object. * @param AceInterface[] $addAces A list of ACEs that MUST be added to the newly-created document object, either * using the ACL from folderId if specified, or being applied if no folderId is specified. * @param AceInterface[] $removeAces A list of ACEs that MUST be removed from the newly-created document object, * either using the ACL from folderId if specified, or being ignored if no folderId is specified. * @return ObjectIdInterface The id of the newly-created document. * @throws CmisRuntimeException */ protected function copyViaClient(ObjectIdInterface $targetFolderId = null, array $properties = array(), VersioningState $versioningState = null, array $policies = array(), array $addAces = array(), array $removeAces = array()) { $newProperties = array(); $allPropertiesContext = $this->getSession()->createOperationContext(); $allPropertiesContext->setFilterString('*'); $allPropertiesContext->setIncludeAcls(false); $allPropertiesContext->setIncludeAllowableActions(false); $allPropertiesContext->setIncludePathSegments(false); $allPropertiesContext->setIncludePolicies(false); $allPropertiesContext->setIncludeRelationships(IncludeRelationships::cast(IncludeRelationships::NONE)); $allPropertiesContext->setRenditionFilterString(Constants::RENDITION_NONE); $allPropertiesDocument = $this->getSession()->getObject($this, $allPropertiesContext); if (!$allPropertiesDocument instanceof DocumentInterface) { throw new CmisRuntimeException('Returned object is not of expected type DocumentInterface'); } foreach ($allPropertiesDocument->getProperties() as $property) { if (Updatability::cast(Updatability::READWRITE)->equals($property->getDefinition()->getUpdatability()) || Updatability::cast(Updatability::ONCREATE)->equals($property->getDefinition()->getUpdatability())) { $newProperties[$property->getId()] = $property->isMultiValued() ? $property->getValues() : $property->getFirstValue(); } } $newProperties = array_merge($newProperties, $properties); $contentStream = $allPropertiesDocument->getContentStream(); return $this->getSession()->createDocument($newProperties, $targetFolderId, $contentStream, $versioningState, $policies, $addAces, $removeAces); }
$integer->setPropertyType(\Dkd\PhpCmis\Enum\PropertyType::cast(\Dkd\PhpCmis\Enum\PropertyType::INTEGER)); $integer->setLocalName('cmis:integerValue'); $integer->setQueryName('cmis:integerValue'); $integer->setIsInherited(true); $integer->setIsOpenChoice(true); $integer->setIsOrderable(false); $integer->setDescription('This is a integer property.'); $integer->setUpdatability(\Dkd\PhpCmis\Enum\Updatability::cast(\Dkd\PhpCmis\Enum\Updatability::READWRITE)); $integer->setLocalNamespace('namespace'); $integer->setDisplayName('Integer property'); $integer->setIsRequired(false); $integer->setCardinality(\Dkd\PhpCmis\Enum\Cardinality::cast(\Dkd\PhpCmis\Enum\Cardinality::MULTI)); $integer->setIsQueryable(true); $integer->setMinValue(5); $integer->setMaxValue(100); $datetime = new \Dkd\PhpCmis\DataObjects\PropertyDateTimeDefinition('cmis:datetime'); $datetime->setPropertyType(\Dkd\PhpCmis\Enum\PropertyType::cast(\Dkd\PhpCmis\Enum\PropertyType::DATETIME)); $datetime->setLocalName('cmis:datetimeValue'); $datetime->setQueryName('cmis:datetimeValue'); $datetime->setIsInherited(true); $datetime->setIsOpenChoice(true); $datetime->setIsOrderable(false); $datetime->setDescription('This is a datetime property.'); $datetime->setUpdatability(\Dkd\PhpCmis\Enum\Updatability::cast(\Dkd\PhpCmis\Enum\Updatability::READWRITE)); $datetime->setLocalNamespace('namespace'); $datetime->setDisplayName('Datetime property'); $datetime->setIsRequired(false); $datetime->setCardinality(\Dkd\PhpCmis\Enum\Cardinality::cast(\Dkd\PhpCmis\Enum\Cardinality::MULTI)); $datetime->setIsQueryable(true); $datetime->setDateTimeResolution(\Dkd\PhpCmis\Enum\DateTimeResolution::cast(\Dkd\PhpCmis\Enum\DateTimeResolution::TIME)); return array('cmis:id' => $id, 'cmis:string' => $string, 'cmis:boolean' => $boolean, 'cmis:uri' => $uri, 'cmis:decimal' => $decimal, 'cmis:html' => $html, 'cmis:integer' => $integer, 'cmis:datetime' => $datetime);
/** * Updates the provided properties. If the repository created a new object, for example a new version, * the object ID of the new object is returned. Otherwise the object ID of the current object is returned. * * @param mixed[] $properties the properties to update * @param boolean $refresh <code>true</code> if this object should be refresh after the update, * <code>false</code> if not * @return CmisObjectInterface|null the object ID of the updated object - can return <code>null</code> in case * of a repository failure */ public function updateProperties(array $properties, $refresh = true) { if (empty($properties)) { throw new CmisInvalidArgumentException('Properties must not be empty!'); } $objectId = $this->getId(); $changeToken = $this->getChangeToken(); $updatability = array(); $updatability[] = Updatability::cast(Updatability::READWRITE); if ((bool) $this->getPropertyValue(PropertyIds::IS_VERSION_SERIES_CHECKED_OUT) === true) { $updatability[] = Updatability::cast(Updatability::WHENCHECKEDOUT); } $newObjectId = $objectId; $this->getBinding()->getObjectService()->updateProperties($this->getRepositoryId(), $newObjectId, $this->getObjectFactory()->convertProperties($properties, $this->getObjectType(), (array) $this->getSecondaryTypes(), $updatability), $changeToken); // remove the object from the cache, it has been changed $this->getSession()->removeObjectFromCache($this->getSession()->createObjectId($objectId)); if ($refresh === true) { $this->refresh(); } if ($newObjectId === null) { return null; } return $this->getSession()->getObject($this->getSession()->createObjectId($newObjectId), $this->getCreationContext()); }
public function testPreparePropertyDefinitionDataConvertsValuesToExpectedValues() { $input = array(JSONConstants::JSON_PROPERTY_TYPE_PROPERTY_TYPE => 'boolean', JSONConstants::JSON_PROPERTY_TYPE_DEAULT_VALUE => true, JSONConstants::JSON_PROPERTY_TYPE_RESOLUTION => 'date', JSONConstants::JSON_PROPERTY_TYPE_PRECISION => '32', JSONConstants::JSON_PROPERTY_TYPE_CARDINALITY => 'single', JSONConstants::JSON_PROPERTY_TYPE_UPDATABILITY => 'readonly'); $expected = array(JSONConstants::JSON_PROPERTY_TYPE_PROPERTY_TYPE => PropertyType::cast('boolean'), JSONConstants::JSON_PROPERTY_TYPE_DEAULT_VALUE => array(true), JSONConstants::JSON_PROPERTY_TYPE_RESOLUTION => DateTimeResolution::cast('date'), JSONConstants::JSON_PROPERTY_TYPE_PRECISION => DecimalPrecision::cast('32'), JSONConstants::JSON_PROPERTY_TYPE_CARDINALITY => Cardinality::cast('single'), JSONConstants::JSON_PROPERTY_TYPE_UPDATABILITY => Updatability::cast('readonly')); $this->assertEquals($expected, $this->getMethod(self::CLASS_TO_TEST, 'preparePropertyDefinitionData')->invokeArgs($this->jsonConverter, array($input))); }
/** * Cast data values to the expected type * * @param array $data * @return array */ protected function preparePropertyDefinitionData(array $data) { $data[JSONConstants::JSON_PROPERTY_TYPE_PROPERTY_TYPE] = PropertyType::cast($data[JSONConstants::JSON_PROPERTY_TYPE_PROPERTY_TYPE]); if (isset($data[JSONConstants::JSON_PROPERTY_TYPE_DEAULT_VALUE])) { $data[JSONConstants::JSON_PROPERTY_TYPE_DEAULT_VALUE] = (array) $data[JSONConstants::JSON_PROPERTY_TYPE_DEAULT_VALUE]; } if (isset($data[JSONConstants::JSON_PROPERTY_TYPE_RESOLUTION])) { $data[JSONConstants::JSON_PROPERTY_TYPE_RESOLUTION] = DateTimeResolution::cast($data[JSONConstants::JSON_PROPERTY_TYPE_RESOLUTION]); } if (isset($data[JSONConstants::JSON_PROPERTY_TYPE_PRECISION])) { $data[JSONConstants::JSON_PROPERTY_TYPE_PRECISION] = DecimalPrecision::cast($data[JSONConstants::JSON_PROPERTY_TYPE_PRECISION]); } if (isset($data[JSONConstants::JSON_PROPERTY_TYPE_CARDINALITY])) { $data[JSONConstants::JSON_PROPERTY_TYPE_CARDINALITY] = Cardinality::cast($data[JSONConstants::JSON_PROPERTY_TYPE_CARDINALITY]); } if (isset($data[JSONConstants::JSON_PROPERTY_TYPE_UPDATABILITY])) { $data[JSONConstants::JSON_PROPERTY_TYPE_UPDATABILITY] = Updatability::cast($data[JSONConstants::JSON_PROPERTY_TYPE_UPDATABILITY]); } return $data; }
/** * @param array $parameters * @param ObjectFactoryInterface|null $objectFactory * @param Cache|null $cache * @param Cache|null $typeDefinitionCache * @param Cache|null $objectTypeCache * @param CmisBindingsHelper|null $cmisBindingHelper * @throws CmisInvalidArgumentException * @throws IllegalStateException */ public function __construct(array $parameters, ObjectFactoryInterface $objectFactory = null, Cache $cache = null, Cache $typeDefinitionCache = null, Cache $objectTypeCache = null, CmisBindingsHelper $cmisBindingHelper = null) { if (empty($parameters)) { throw new CmisInvalidArgumentException('No parameters provided!', 1408115280); } $this->parameters = $parameters; $this->objectFactory = $objectFactory === null ? $this->createObjectFactory() : $objectFactory; $this->cache = $cache === null ? $this->createCache() : $cache; $this->typeDefinitionCache = $typeDefinitionCache === null ? $this->createCache() : $typeDefinitionCache; $this->objectTypeCache = $objectTypeCache === null ? $this->createCache() : $objectTypeCache; $this->cmisBindingHelper = $cmisBindingHelper === null ? new CmisBindingsHelper() : $cmisBindingHelper; $this->defaultContext = new OperationContext(); $this->defaultContext->setCacheEnabled(true); $this->binding = $this->getCmisBindingHelper()->createBinding($this->parameters, $this->typeDefinitionCache); if (!isset($this->parameters[SessionParameter::REPOSITORY_ID])) { throw new IllegalStateException('Repository ID is not set!'); } $this->repositoryInfo = $this->getBinding()->getRepositoryService()->getRepositoryInfo($this->parameters[SessionParameter::REPOSITORY_ID]); self::$createUpdatability = array(Updatability::cast(Updatability::ONCREATE), Updatability::cast(Updatability::READWRITE)); self::$createAndCheckoutUpdatability = array(Updatability::cast(Updatability::ONCREATE), Updatability::cast(Updatability::READWRITE), Updatability::cast(Updatability::WHENCHECKEDOUT)); }