public function addPropertyIndex()
    {
        if(!$this->isXmlHttpRequest()){
            throw new common_exception_BadRequest('wrong request mode');
        }
        if(!$this->hasRequestParameter('uri')){
            throw new Exception("wrong request Parameter");
        }
        $uri = $this->getRequestParameter('uri');

        $clazz = $this->getCurrentClass();

        $index = 1;
        if($this->hasRequestParameter('index')){
            $index = $this->getRequestParameter('index');
        }

        $propertyIndex = 1;
        if($this->hasRequestParameter('propertyIndex')){
            $propertyIndex = $this->getRequestParameter('propertyIndex');
        }

        //create and attach the new index property to the property
        $property = $this->getProperty(tao_helpers_Uri::decode($uri));
        $class = $this->getClass("http://www.tao.lu/Ontologies/TAO.rdf#Index");

        //get property range to select a default tokenizer
        /** @var core_kernel_classes_Class $range */
        $range = $property->getRange();
        //range is empty select item content
        $tokenizer = null;
        if (is_null($range)) {
            $tokenizer = $this->getResource('http://www.tao.lu/Ontologies/TAO.rdf#RawValueTokenizer');
        } else {
            $tokenizer = $range->getUri() === OntologyRdfs::RDFS_LITERAL
                ? $this->getResource('http://www.tao.lu/Ontologies/TAO.rdf#RawValueTokenizer')
                : $this->getResource('http://www.tao.lu/Ontologies/TAO.rdf#LabelTokenizer');
        }

        $indexClass = $this->getClass('http://www.tao.lu/Ontologies/TAO.rdf#Index');
        $i = 0;
        $indexIdentifierBackup = preg_replace('/[^a-z_0-9]/','_',strtolower($property->getLabel()));
        $indexIdentifierBackup = ltrim(trim($indexIdentifierBackup, '_'),'0..9');
        $indexIdentifier = $indexIdentifierBackup;
        do{
            if($i !== 0){
                $indexIdentifier = $indexIdentifierBackup.'_'.$i;
            }
            $resources = $indexClass->searchInstances(array(OntologyIndex::PROPERTY_INDEX_IDENTIFIER => $indexIdentifier), array('like' => false));
            $count = count($resources);
            $i++;
        }while($count !== 0);

        $indexProperty = $class->createInstanceWithProperties(array(
                OntologyRdfs::RDFS_LABEL => preg_replace('/_/',' ',ucfirst($indexIdentifier)),
                OntologyIndex::PROPERTY_INDEX_IDENTIFIER => $indexIdentifier,
                OntologyIndex::PROPERTY_INDEX_TOKENIZER => $tokenizer,
                OntologyIndex::PROPERTY_INDEX_FUZZY_MATCHING => GenerisRdf::GENERIS_TRUE,
                OntologyIndex::PROPERTY_DEFAULT_SEARCH  => GenerisRdf::GENERIS_FALSE,
            ));

        $property->setPropertyValue($this->getProperty(OntologyIndex::PROPERTY_INDEX), $indexProperty);

        //generate form
        $indexFormContainer = new tao_actions_form_IndexProperty(new OntologyIndex($indexProperty), $propertyIndex.$index);
        $myForm = $indexFormContainer->getForm();
        $form = trim(preg_replace('/\s+/', ' ', $myForm->renderElements()));
        $this->returnJson(array('form' => $form));
    }
public function addPropertyIndex()
    {
        if(!$this->isXmlHttpRequest()){
            throw new common_exception_BadRequest('wrong request mode');
        }
        if(!$this->hasRequestParameter('uri')){
            throw new Exception("wrong request Parameter");
        }
        $uri = $this->getRequestParameter('uri');

        $clazz = $this->getCurrentClass();

        $index = 1;
        if($this->hasRequestParameter('index')){
            $index = $this->getRequestParameter('index');
        }

        $propertyIndex = 1;
        if($this->hasRequestParameter('propertyIndex')){
            $propertyIndex = $this->getRequestParameter('propertyIndex');
        }

        //create and attach the new index property to the property
        $property = $this->getProperty(tao_helpers_Uri::decode($uri));
        $class = $this->getClass("http://www.tao.lu/Ontologies/TAO.rdf#Index");

        //get property range to select a default tokenizer
        /** @var core_kernel_classes_Class $range */
        $range = $property->getRange();
        //range is empty select item content
        $tokenizer = null;
        if (is_null($range)) {
            $tokenizer = $this->getResource('http://www.tao.lu/Ontologies/TAO.rdf#RawValueTokenizer');
        } else {
            $tokenizer = $range->getUri() === OntologyRdfs::RDFS_LITERAL
                ? $this->getResource('http://www.tao.lu/Ontologies/TAO.rdf#RawValueTokenizer')
                : $this->getResource('http://www.tao.lu/Ontologies/TAO.rdf#LabelTokenizer');
        }

        $indexClass = $this->getClass('http://www.tao.lu/Ontologies/TAO.rdf#Index');
        $i = 0;
        $indexIdentifierBackup = preg_replace('/[^a-z_0-9]/','_',strtolower($property->getLabel()));
        $indexIdentifierBackup = ltrim(trim($indexIdentifierBackup, '_'),'0..9');
        $indexIdentifier = $indexIdentifierBackup;
        do{
            if($i !== 0){
                $indexIdentifier = $indexIdentifierBackup.'_'.$i;
            }
            $resources = $indexClass->searchInstances(array(OntologyIndex::PROPERTY_INDEX_IDENTIFIER => $indexIdentifier), array('like' => false));
            $count = count($resources);
            $i++;
        }while($count !== 0);

        $indexProperty = $class->createInstanceWithProperties(array(
                OntologyRdfs::RDFS_LABEL => preg_replace('/_/',' ',ucfirst($indexIdentifier)),
                OntologyIndex::PROPERTY_INDEX_IDENTIFIER => $indexIdentifier,
                OntologyIndex::PROPERTY_INDEX_TOKENIZER => $tokenizer,
                OntologyIndex::PROPERTY_INDEX_FUZZY_MATCHING => GenerisRdf::GENERIS_TRUE,
                OntologyIndex::PROPERTY_DEFAULT_SEARCH  => GenerisRdf::GENERIS_FALSE,
            ));

        $property->setPropertyValue($this->getProperty(OntologyIndex::PROPERTY_INDEX), $indexProperty);

        //generate form
        $indexFormContainer = new tao_actions_form_IndexProperty(new OntologyIndex($indexProperty), $propertyIndex.$index);
        $myForm = $indexFormContainer->getForm();
        $form = trim(preg_replace('/\s+/', ' ', $myForm->renderElements()));
        $this->returnJson(array('form' => $form));
    }
public function addPropertyIndex ( ) { if ( ! $ this -> isXmlHttpRequest ( ) ) { throw new common_exception_BadRequest ( 'wrong request mode' ) ; } if ( ! $ this -> hasRequestParameter ( 'uri' ) ) { throw new Exception ( "wrong request Parameter" ) ; } $ uri = $ this -> getRequestParameter ( 'uri' ) ; $ clazz = $ this -> getCurrentClass ( ) ; $ index = 1 ; if ( $ this -> hasRequestParameter ( 'index' ) ) { $ index = $ this -> getRequestParameter ( 'index' ) ; } $ propertyIndex = 1 ; if ( $ this -> hasRequestParameter ( 'propertyIndex' ) ) { $ propertyIndex = $ this -> getRequestParameter ( 'propertyIndex' ) ; } //create and attach the new index property to the property $ property = $ this -> getProperty ( tao_helpers_Uri :: decode ( $ uri ) ) ; $ class = $ this -> getClass ( "http://www.tao.lu/Ontologies/TAO.rdf#Index" ) ; //get property range to select a default tokenizer /** @var core_kernel_classes_Class $range */ $ range = $ property -> getRange ( ) ; //range is empty select item content $ tokenizer = null ; if ( is_null ( $ range ) ) { $ tokenizer = $ this -> getResource ( 'http://www.tao.lu/Ontologies/TAO.rdf#RawValueTokenizer' ) ; } else { $ tokenizer = $ range -> getUri ( ) === OntologyRdfs :: RDFS_LITERAL ? $ this -> getResource ( 'http://www.tao.lu/Ontologies/TAO.rdf#RawValueTokenizer' ) : $ this -> getResource ( 'http://www.tao.lu/Ontologies/TAO.rdf#LabelTokenizer' ) ; } $ indexClass = $ this -> getClass ( 'http://www.tao.lu/Ontologies/TAO.rdf#Index' ) ; $ i = 0 ; $ indexIdentifierBackup = preg_replace ( '/[^a-z_0-9]/' , '_' , strtolower ( $ property -> getLabel ( ) ) ) ; $ indexIdentifierBackup = ltrim ( trim ( $ indexIdentifierBackup , '_' ) , '0..9' ) ; $ indexIdentifier = $ indexIdentifierBackup ; do { if ( $ i !== 0 ) { $ indexIdentifier = $ indexIdentifierBackup . '_' . $ i ; } $ resources = $ indexClass -> searchInstances ( array ( OntologyIndex :: PROPERTY_INDEX_IDENTIFIER => $ indexIdentifier ) , array ( 'like' => false ) ) ; $ count = count ( $ resources ) ; $ i ++ ; } while ( $ count !== 0 ) ; $ indexProperty = $ class -> createInstanceWithProperties ( array ( OntologyRdfs :: RDFS_LABEL => preg_replace ( '/_/' , ' ' , ucfirst ( $ indexIdentifier ) ) , OntologyIndex :: PROPERTY_INDEX_IDENTIFIER => $ indexIdentifier , OntologyIndex :: PROPERTY_INDEX_TOKENIZER => $ tokenizer , OntologyIndex :: PROPERTY_INDEX_FUZZY_MATCHING => GenerisRdf :: GENERIS_TRUE , OntologyIndex :: PROPERTY_DEFAULT_SEARCH => GenerisRdf :: GENERIS_FALSE , ) ) ; $ property -> setPropertyValue ( $ this -> getProperty ( OntologyIndex :: PROPERTY_INDEX ) , $ indexProperty ) ; //generate form $ indexFormContainer = new tao_actions_form_IndexProperty ( new OntologyIndex ( $ indexProperty ) , $ propertyIndex . $ index ) ; $ myForm = $ indexFormContainer -> getForm ( ) ; $ form = trim ( preg_replace ( '/\s+/' , ' ' , $ myForm -> renderElements ( ) ) ) ; $ this -> returnJson ( array ( 'form' => $ form ) ) ; }
Render the add index sub form.
@throws Exception
@throws common_exception_BadRequest
@return void
Render the add index sub form .