public function testHardModel() { $this->hardify(); $referencer = ResourceReferencer::singleton(); $propertyProxy = PropertyProxy::singleton(); $proxy = ResourceProxy::singleton(); $domainProperty = new core_kernel_classes_Property(RDFS_DOMAIN); $rangeProperty = new core_kernel_classes_Property(RDFS_RANGE); $literalClass = new core_kernel_classes_Class(RDFS_LITERAL); $subClassOfProperty = new core_kernel_classes_Property(RDFS_SUBCLASSOF); $this->assertTrue($this->targetActorsProperty->exists()); $this->assertTrue($this->targetMovieClass->exists()); $this->assertTrue($this->targetWorkClass->isSubclassOf($this->taoClass)); $this->assertTrue($this->targetWorkClass->getOnePropertyValue($subClassOfProperty)->getUri() == $this->taoClass->getUri()); $this->assertTrue($referencer->isClassReferenced($this->targetWorkClass)); $this->assertFalse(is_a($proxy->getImpToDelegateTo($this->targetWorkClass), 'core_kernel_persistence_smoothsql_Class')); $this->assertFalse(is_a($proxy->getImpToDelegateTo($this->targetMovieClass), 'core_kernel_persistence_smoothsql_Class')); $this->assertTrue($this->targetAuthorProperty->getOnePropertyValue($domainProperty)->getUri() == $this->targetWorkClass->getUri()); $this->assertTrue($this->targetAuthorProperty->getOnePropertyValue($rangeProperty)->getUri() == RDFS_LITERAL); $this->assertTrue($this->targetMovieClass->isSubclassOf($this->targetWorkClass)); $this->assertTrue($this->targetMovieClass->getOnePropertyValue($subClassOfProperty)->getUri() == $this->targetWorkClass->getUri()); $this->assertTrue($referencer->isClassReferenced($this->targetMovieClass)); $this->assertTrue($this->targetProducerProperty->getOnePropertyValue($domainProperty)->getUri() == $this->targetMovieClass->getUri()); $this->assertTrue($this->targetProducerProperty->getOnePropertyValue($rangeProperty)->getUri() == RDFS_LITERAL); $this->assertTrue($this->targetActorsProperty->getOnePropertyValue($domainProperty)->getUri() == $this->targetMovieClass->getUri()); $this->assertTrue($this->targetActorsProperty->getOnePropertyValue($rangeProperty)->getUri() == RDFS_LITERAL); $this->assertTrue($this->targetRelatedMoviesProperty->getOnePropertyValue($domainProperty)->getUri() == $this->targetMovieClass->getUri()); $this->assertTrue($this->targetRelatedMoviesProperty->getOnePropertyValue($rangeProperty)->getUri() == $this->targetMovieClass->getUri()); $parentClasses = $this->targetMovieClass->getParentClasses(); $this->assertEquals(1, count($parentClasses)); $this->assertTrue(array_key_exists($this->targetWorkClass->getUri(), $parentClasses)); $prop = new core_kernel_classes_Property($this->targetRelatedMoviesProperty); $this->assertTrue($prop->isMultiple()); }
/** * Add column to export * Check if core_kernel_classes_Property exists into $config * * @param $column * @param array $config * @throws ExtractorException * @return Extractor $this */ public function addColumn($column, array $config) { if (!isset($config['property'])) { throw new ExtractorException('Property config is missing.'); } $property = new \core_kernel_classes_Property($config['property']); if (!$property->exists()) { throw new ExtractorException('Property config is not a valid property uri.'); } $config['property'] = $property; $this->columns[$column] = $config; return $this; }
public function createTranslationProperty($type, $countryCode = '', $langCode = '', $class = null) { $property = null; if (is_null($class) && !is_null($this->itemClass)) { $class = $this->itemClass; } if (!is_null($class)) { $label = TranslationProcessHelper::getPropertyName($type, $countryCode, $langCode); $uri = LOCAL_NAMESPACE . '#' . $label; $property = new core_kernel_classes_Property($uri); if (!$property->exists()) { $propertyClass = new core_kernel_classes_Class(RDF_PROPERTY, __METHOD__); $propertyInstance = $propertyClass->createInstance($label, '', $uri); $property = new core_kernel_classes_Property($propertyInstance->getUri(), __METHOD__); } if (!$class->setProperty($property)) { throw new common_Exception('problem creating property : cannot set property to class'); } $this->properties[$label] = $property; } else { throw new common_Exception('problem creating property : no target class given'); } return $property; }