Beispiel #1
0
 /**
  *
  * @author Patrick Plichart, patrick@taotesting.com
  * @param string $uri            
  * @throws common_exception_InvalidArgumentType
  * @return boolean
  */
 public function isInScope($uri)
 {
     if (!common_Utils::isUri($uri)) {
         throw new common_exception_InvalidArgumentType();
     }
     $resource = new core_kernel_classes_Resource($uri);
     return $resource->hasType($this->getRootClass());
 }
 /**
  * @param \core_kernel_classes_Triple $triple
  * @return bool
  */
 public static function isFileReference(\core_kernel_classes_Triple $triple)
 {
     $prop = new \core_kernel_classes_Property($triple->predicate);
     $range = $prop->getRange();
     $rangeUri = is_null($range) ? '' : $range->getUri();
     switch ($rangeUri) {
         case CLASS_GENERIS_FILE:
             return true;
         case RDFS_RESOURCE:
             $object = new \core_kernel_classes_Resource($triple->object);
             return $object->hasType(new \core_kernel_classes_Class(CLASS_GENERIS_FILE));
         default:
             return false;
     }
 }
 public function __construct()
 {
     parent::__construct();
     $this->processDefinitionService = wfEngine_models_classes_ProcessDefinitionService::singleton();
     $processDefinitionUri = urldecode($this->getRequestParameter('processDefinitionUri'));
     if (!empty($processDefinitionUri) && common_Utils::isUri($processDefinitionUri)) {
         $process = new core_kernel_classes_Resource($processDefinitionUri);
         if ($process->hasType(new core_kernel_classes_Class(CLASS_PROCESS))) {
             $this->processDefinition = $process;
         } else {
             $this->setErrorMessage(__('The resource is not a process definition'));
         }
     } else {
         $this->setErrorMessage(__('No process definition uri given'));
     }
 }
 /**
  * Short description of method attachResource
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @param  core_kernel_classes_Property $targetProperty
  * @param  core_kernel_classes_Resource $targetResource
  * @param  string $value
  * @return mixed
  */
 public function attachResource(core_kernel_classes_Property $targetProperty, core_kernel_classes_Resource $targetResource, $value)
 {
     // We have to check if the resource identified by value exists in the Ontology.
     $resource = new core_kernel_classes_Resource($value);
     if ($resource->exists()) {
         // Is the range correct ?
         $targetPropertyRanges = $targetProperty->getPropertyValuesCollection(new core_kernel_classes_Property(RDFS_RANGE));
         $rangeCompliance = true;
         // If $targetPropertyRange->count = 0, we consider that the resouce
         // may be attached because $rangeCompliance = true.
         foreach ($targetPropertyRanges->getIterator() as $range) {
             // Check all classes in target property's range.
             if ($resource->hasType(new core_kernel_classes_Class($range))) {
                 $rangeCompliance = false;
                 break;
             }
         }
         if (true == $rangeCompliance) {
             $targetResource->setPropertyValue($targetProperty, $resource->getUri());
         }
     }
 }
 /**
  * Short description of method isTransitionRule
  *
  * @access public
  * @author Lionel Lecaque, <*****@*****.**>
  * @param  Resource rule
  * @return boolean
  */
 public function isTransitionRule(core_kernel_classes_Resource $rule)
 {
     $returnValue = (bool) false;
     $returnValue = $rule->hasType(new core_kernel_classes_Class(CLASS_TRANSITIONRULES));
     return (bool) $returnValue;
 }
 /**
  * Short description of method deleteProcessExecution
  *
  * @access public
  * @author Somsack Sipasseuth, <*****@*****.**>
  * @param  Resource processExecution
  * @param  boolean finishedOnly
  * @return boolean
  */
 public function deleteProcessExecution(core_kernel_classes_Resource $processExecution, $finishedOnly = false)
 {
     $returnValue = (bool) false;
     if ($processExecution->hasType($this->processInstancesClass)) {
         if ($finishedOnly) {
             if (!$this->isFinished($processExecution)) {
                 return $returnValue;
             }
         }
         $allActivityExecutions = $processExecution->getPropertyValues($this->processInstancesActivityExecutionsProp);
         $count = count($allActivityExecutions);
         for ($i = 0; $i < $count; $i++) {
             $uri = $allActivityExecutions[$i];
             if (common_Utils::isUri($uri)) {
                 $activityExecution = new core_kernel_classes_Resource($uri);
                 $activityExecution->delete();
                 //no need for the second param to "true" since all the related resources are going to be deleted in this method
             }
         }
         $returnValue = $processExecution->delete();
     }
     return (bool) $returnValue;
 }
 /**
  * Short description of method removeType
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Resource resource
  * @param  Class class
  * @return boolean
  */
 public function removeType(\core_kernel_classes_Resource $resource, \core_kernel_classes_Class $class)
 {
     $returnValue = (bool) false;
     $dbWrapper = \core_kernel_classes_DbWrapper::singleton();
     $referencer = ResourceReferencer::singleton();
     if ($resource->hasType($class)) {
         $resourceId = intval(Utils::getResourceToTableId($resource));
         $classInfo = Utils::getClassInfo($class);
         $triples = $resource->getRdfTriples();
         if (!empty($resourceId)) {
             $resource->delete(false);
             $referencer->unReferenceResource($resource);
             $query = 'INSERT INTO "statements" ("modelid", "subject", "predicate", "object", "l_language") VALUES  (?, ?, ?, ?, ?);';
             foreach ($triples as $t) {
                 $dbWrapper->exec($query, array(99999, $t->subject, $t->predicate, $t->object, $t->lg));
             }
         }
     }
     $returnValue = true;
     return (bool) $returnValue;
 }
 /**
  * Short description of method setAcl
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Resource processDefinition
  * @param  Resource mode
  * @param  Resource target
  * @return core_kernel_classes_Resource
  */
 public function setAcl(core_kernel_classes_Resource $processDefinition, core_kernel_classes_Resource $mode, core_kernel_classes_Resource $target = null)
 {
     $returnValue = null;
     if (!$processDefinition->hasType(new core_kernel_classes_Class(CLASS_PROCESS))) {
         throw new Exception("Process must be an instance of the class Process");
     }
     if (!in_array($mode->getUri(), array_keys($this->getAclModes()))) {
         throw new Exception("Unknow acl mode");
     }
     //set the ACL mode
     $properties = array(PROPERTY_PROCESS_INIT_ACL_MODE => $mode->getUri());
     switch ($mode->getUri()) {
         case INSTANCE_ACL_ROLE:
             if (is_null($target)) {
                 throw new Exception("Target must reference a role resource");
             }
             $properties[PROPERTY_PROCESS_INIT_RESTRICTED_ROLE] = $target->getUri();
             break;
         case INSTANCE_ACL_USER:
             if (is_null($target)) {
                 throw new Exception("Target must reference a user resource");
             }
             $properties[PROPERTY_PROCESS_INIT_RESTRICTED_USER] = $target->getUri();
             break;
     }
     //bind the mode and the target (user or role) to the activity
     $returnValue = $this->bindProperties($processDefinition, $properties);
     return $returnValue;
 }
Beispiel #9
0
 /**
  * Short description of method isFile
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @param  Resource resource
  * @return boolean
  */
 public static function isFile(core_kernel_classes_Resource $resource)
 {
     return $resource->hasType(new core_kernel_classes_Class(CLASS_GENERIS_FILE));
 }
 /**
  * Short description of method setActualParameter
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Resource callOfService
  * @param  Resource formalParam
  * @param  string value
  * @param  string parameterInOrOut
  * @param  string actualParameterType
  * @return boolean
  */
 public function setActualParameter(core_kernel_classes_Resource $callOfService, core_kernel_classes_Resource $formalParam, $value, $parameterInOrOut = PROPERTY_CALLOFSERVICES_ACTUALPARAMETERIN, $actualParameterType = PROPERTY_ACTUALPARAMETER_CONSTANTVALUE)
 {
     $returnValue = (bool) false;
     //must exist:
     if ($formalParam->hasType(new core_kernel_classes_Class(CLASS_FORMALPARAMETER))) {
         if (in_array($parameterInOrOut, array(PROPERTY_CALLOFSERVICES_ACTUALPARAMETERIN, PROPERTY_CALLOFSERVICES_ACTUALPARAMETEROUT)) && in_array($actualParameterType, array(PROPERTY_ACTUALPARAMETER_CONSTANTVALUE, PROPERTY_ACTUALPARAMETER_PROCESSVARIABLE))) {
             //create new resource for the property value of the current call of service PROPERTY_CALLOFSERVICES_ACTUALPARAMETERIN or PROPERTY_CALLOFSERVICES_ACTUALPARAMETEROUT
             $actualParameterClass = new core_kernel_classes_Class(CLASS_ACTUALPARAMETER);
             $newActualParameter = $actualParameterClass->createInstance($formalParam->getLabel(), "actual parameter created by Process Authoring Service");
             $newActualParameter->setPropertyValue(new core_kernel_classes_Property(PROPERTY_ACTUALPARAMETER_FORMALPARAMETER), $formalParam->getUri());
             $newActualParameter->setPropertyValue(new core_kernel_classes_Property($actualParameterType), $value);
             $returnValue = $callOfService->setPropertyValue(new core_kernel_classes_Property($parameterInOrOut), $newActualParameter->getUri());
         }
     } else {
         throw new Exception('the formal parameter ' . $formalParam->getUri() . ' does not exist');
     }
     return (bool) $returnValue;
 }
 /**
  * Short description of method isProcessVariable
  *
  * @access public
  * @author Somsack Sipasseuth, <*****@*****.**>
  * @param  Resource variable
  * @return boolean
  */
 public function isProcessVariable(core_kernel_classes_Resource $variable)
 {
     $returnValue = (bool) false;
     $returnValue = $variable->hasType(new core_kernel_classes_Class(CLASS_PROCESSVARIABLES));
     return (bool) $returnValue;
 }
Beispiel #12
0
 /**
  * (non-PHPdoc)
  * @see core_kernel_persistence_ClassInterface::createInstance()
  */
 public function createInstance(core_kernel_classes_Class $resource, $label = '', $comment = '', $uri = '')
 {
     $returnValue = null;
     $subject = '';
     if ($uri == '') {
         $subject = common_Utils::getNewUri();
     } else {
         if ($uri[0] == '#') {
             //$uri should start with # and be well formed
             $modelUri = common_ext_NamespaceManager::singleton()->getLocalNamespace()->getUri();
             $subject = rtrim($modelUri, '#') . $uri;
         } else {
             $subject = $uri;
         }
     }
     $returnValue = new core_kernel_classes_Resource($subject, __METHOD__);
     if (!$returnValue->hasType($resource)) {
         $returnValue->setType($resource);
     } else {
         common_Logger::e('already had type ' . $resource);
     }
     if (!empty($label)) {
         $returnValue->setLabel($label);
     }
     if (!empty($comment)) {
         $returnValue->setComment($comment);
     }
     return $returnValue;
 }
Beispiel #13
0
 /**
  * Check if a resource is a versioned file resource
  *
  * @access public
  * @author Lionel Lecaque, <*****@*****.**>
  * @param  Resource resource
  * @return boolean
  */
 public static function isVersionedFile(core_kernel_classes_Resource $resource)
 {
     $returnValue = (bool) false;
     $returnValue = $resource->hasType(new core_kernel_classes_Class(CLASS_GENERIS_FILE));
     return (bool) $returnValue;
 }