public function execute(&$value, &$error)
 {
     $property = $this->getContext()->getRequest()->getParameter('concept_property');
     $propertyId = $this->getContext()->getRequest()->getParameter('id');
     $conceptId = $this->getContext()->getRequest()->getParameter('concept_id');
     $vocabId = $this->getContext()->getUser()->getAttribute('vocabulary')->getId();
     //if it's not a prefLabel then we just check for uniqueness in the context of the Concept
     if ((int) $property['skos_property_id'] !== 19) {
         $c = new Criteria();
         $c->add(ConceptPropertyPeer::CONCEPT_ID, $conceptId);
         $c->add(ConceptPropertyPeer::LANGUAGE, $property['language']);
         $c->add(ConceptPropertyPeer::STATUS_ID, $property['status_id']);
         $c->add(ConceptPropertyPeer::OBJECT, $value);
         $object = ConceptPropertyPeer::doSelectOne($c);
         if ($object) {
             //check to see if the retrieved object has the same id
             if ($propertyId && $object->getId() == $propertyId) {
                 return true;
             } else {
                 if ($property['skos_property_id'] != $object->getSkosPropertyId()) {
                     $error = "This Concept already has this label applied to the " . $object->getSkosPropertyName() . " property.";
                 } else {
                     $error = "This Concept already has this exact property.";
                 }
                 return false;
             }
         } else {
             if (!in_array($property['skos_property_id'], array('3', '16', '21', 32, 33, 34, 35, 36, 37))) {
                 $property['related_concept_id'] = null;
                 $property['scheme_id'] = null;
                 //save the array back to the request parameter
                 //         $this->requestParameterHolder->set('concept_property', $concept_property);
             }
         }
     } else {
         //check for no duplicate prefLable in the entire vocabulary
         $c = new Criteria();
         $c->add(ConceptPeer::VOCABULARY_ID, $vocabId);
         $c->add(ConceptPropertyPeer::LANGUAGE, $property['language']);
         $c->add(ConceptPropertyPeer::STATUS_ID, $property['status_id']);
         $c->add(ConceptPropertyPeer::SKOS_PROPERTY_ID, 19);
         $c->add(ConceptPropertyPeer::OBJECT, $value);
         $c->addJoin(ConceptPropertyPeer::CONCEPT_ID, ConceptPeer::ID);
         $object = ConceptPropertyPeer::doSelectOne($c);
         if ($object) {
             //check to see if the retrieved object has the same id
             if ($propertyId && $object->getId() == $propertyId) {
                 return true;
             } else {
                 $error = "This Vocabulary already has a Concept with a prefLabel with this status and language.";
                 return false;
             }
         }
         $c = new Criteria();
         $c->add(ConceptPropertyPeer::CONCEPT_ID, $conceptId);
         $c->add(ConceptPropertyPeer::LANGUAGE, $property['language']);
         $c->add(ConceptPropertyPeer::STATUS_ID, $property['status_id']);
         $c->add(ConceptPropertyPeer::SKOS_PROPERTY_ID, 19);
         $objects = ConceptPropertyPeer::doSelect($c);
         if ($objects && ($propertyId && count($objects) > 1 or !$propertyId && count($objects))) {
             $error = "This Concept already has a prefLabel with this status and language.";
             return false;
         }
     }
     return true;
 }
コード例 #2
0
 /**
  * checks for replated property and deletes if found
  *
  * @return return_type
  * @param  var_type $var
  */
 private function deleteReciprocalProperty($propertyId, $relatedIdFromRequest = '')
 {
     //retrieve the existing property
     if (isset($propertyId)) {
         /* @var ConceptProperty */
         $currentProperty = ConceptPropertyPeer::retrieveByPk($propertyId);
     }
     if (isset($currentProperty)) {
         //check to see if it defines a relationship
         $currentRelatedSchemeId = $currentProperty->getSchemeId();
         $currentRelatedConceptId = $currentProperty->getRelatedConceptId();
         $currentRelatedConceptInverseSkosId = $currentProperty->getProfileProperty()->getInverseProfilePropertyId();
         //if it does and it doesn't match the current relationship
         if (isset($currentRelatedConceptId) && $currentRelatedConceptId != $relatedIdFromRequest) {
             //retrieve the related property
             $c = new Criteria();
             $c->add(ConceptPropertyPeer::CONCEPT_ID, $currentRelatedConceptId);
             $c->add(ConceptPropertyPeer::SKOS_PROPERTY_ID, $currentRelatedConceptInverseSkosId);
             /* @var ConceptProperty */
             $relatedProperty = ConceptPropertyPeer::doSelectOne($c);
             if (isset($relatedProperty)) {
                 //then delete it
                 try {
                     $relatedProperty->delete();
                 } catch (PropelException $e) {
                     $this->getRequest()->setError('delete', 'Could not delete the related Concept Property.');
                 }
             }
         }
     }
     return;
 }