/**
  * Short description of method isProcessClass
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Class clazz
  * @return boolean
  */
 public function isProcessClass(core_kernel_classes_Class $clazz)
 {
     $returnValue = (bool) false;
     if ($clazz->getUri() == $this->processClass->getUri()) {
         $returnValue = true;
     } else {
         foreach ($this->processClass->getSubClasses() as $subclass) {
             if ($clazz->getUri() == $subclass->getUri()) {
                 $returnValue = true;
                 break;
             }
         }
     }
     return (bool) $returnValue;
 }
Exemplo n.º 2
0
 /**
  * Test the setting of the resource URI manually
  */
 public function testResourceSetUriManual()
 {
     $uri = '/test';
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $resource = new Resource($uri);
     $this->assertEquals($uri, $resource->getUri());
 }
 /**
  * Short description of method connectorNode
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Resource connector
  * @param  string nodeClass
  * @param  boolean recursive
  * @return array
  */
 public function connectorNode(core_kernel_classes_Resource $connector, $nodeClass = '', $recursive = false)
 {
     $returnValue = array();
     $connectorData = array();
     $connectorService = wfEngine_models_classes_ConnectorService::singleton();
     //		$activityService = wfEngine_models_classes_ActivityService::singleton();
     //type of connector:
     //if not null, get the information on the next activities. Otherwise, return an "empty" connector node, indicating that the node has just been created, i.e. at the same time as an activity
     $connectorType = $connector->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_CONNECTORS_TYPE), false);
     if (is_null($connectorType)) {
         //create default connector node:
         $returnValue = $this->addNodePrefix($this->defaultConnectorNode($connector), $nodeClass);
         return $returnValue;
     } else {
         //if it is a conditional type
         if ($connectorType->getUri() == INSTANCE_TYPEOFCONNECTORS_CONDITIONAL) {
             //get the rule
             $connectorRule = $connector->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_CONNECTORS_TRANSITIONRULE), false);
             if (!is_null($connectorRule)) {
                 //continue getting connector data:
                 $connectorData[] = $this->conditionNode($connectorRule);
                 //get the "THEN"
                 $then = $connectorRule->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_TRANSITIONRULES_THEN), false);
                 if (!is_null($then)) {
                     $portData = array('id' => 0, 'label' => 'then', 'multiplicity' => 1);
                     if ($connectorService->isConnector($then)) {
                         $connectorActivityReference = $then->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_CONNECTORS_ACTIVITYREFERENCE))->getUri();
                         if ($connectorActivityReference == $this->currentActivity->getUri() && !in_array($then->getUri(), $this->addedConnectors)) {
                             if ($recursive) {
                                 $connectorData[] = $this->connectorNode($then, 'then', true, $portData);
                             } else {
                                 $connectorData[] = $this->activityNode($then, 'then', false, $portData);
                             }
                         } else {
                             $connectorData[] = $this->activityNode($then, 'then', true, $portData);
                         }
                     } else {
                         $connectorData[] = $this->activityNode($then, 'then', true, $portData);
                     }
                 }
                 //same for the "ELSE"
                 $else = $connectorRule->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_TRANSITIONRULES_ELSE), false);
                 if (!is_null($else)) {
                     $portData = array('id' => 1, 'label' => 'else', 'multiplicity' => 1);
                     if ($connectorService->isConnector($else)) {
                         $connectorActivityReference = $else->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_CONNECTORS_ACTIVITYREFERENCE))->getUri();
                         if ($connectorActivityReference == $this->currentActivity->getUri() && !in_array($else->getUri(), $this->addedConnectors)) {
                             if ($recursive) {
                                 $connectorData[] = $this->connectorNode($else, 'else', true, $portData);
                             } else {
                                 $connectorData[] = $this->activityNode($else, 'else', false, $portData);
                             }
                         } else {
                             $connectorData[] = $this->activityNode($else, 'else', true, $portData);
                         }
                     } else {
                         $connectorData[] = $this->activityNode($else, 'else', true, $portData);
                     }
                 }
             }
         } elseif ($connectorType->getUri() == INSTANCE_TYPEOFCONNECTORS_SEQUENCE) {
             $next = $connector->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_STEP_NEXT), false);
             if (!is_null($next)) {
                 $connectorData[] = $this->activityNode($next, 'next', true);
                 //the default portData array will do
             }
         } elseif ($connectorType->getUri() == INSTANCE_TYPEOFCONNECTORS_PARALLEL) {
             $cardinalityService = wfEngine_models_classes_ActivityCardinalityService::singleton();
             $variableService = wfEngine_models_classes_VariableService::singleton();
             $nextActivitiesCollection = $connector->getPropertyValuesCollection(new core_kernel_classes_Property(PROPERTY_STEP_NEXT));
             $portId = 0;
             foreach ($nextActivitiesCollection->getIterator() as $nextActivity) {
                 if ($cardinalityService->isCardinality($nextActivity)) {
                     $activity = $cardinalityService->getDestination($nextActivity);
                     $cardinality = $cardinalityService->getCardinality($nextActivity);
                     $number = $cardinality instanceof core_kernel_classes_Resource ? '^' . $variableService->getCode($cardinality) : $cardinality;
                     $connectorData[] = $this->activityNode($activity, 'next', true, array('id' => $portId, 'multiplicity' => $number, 'label' => $activity->getLabel()), "(count : {$number})");
                     $portId++;
                 }
             }
         } elseif ($connectorType->getUri() == INSTANCE_TYPEOFCONNECTORS_JOIN) {
             $next = $connector->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_STEP_NEXT), false);
             if (!is_null($next)) {
                 $connectorData[] = $this->activityNode($next, 'next', true);
                 //the default portData array will do
             }
         } else {
             throw new Exception("unknown connector type: {$connectorType->getLabel()} for connector {$connector->getUri()}");
         }
         if (empty($portInfo)) {
             $portInfo = array('id' => 0, 'label' => 'next', 'multiplicity' => 1);
         } else {
             if (!isset($portInfo['id'])) {
                 $portInfo['id'] = 0;
             }
             if (!isset($portInfo['id'])) {
                 $portInfo['label'] = 'next';
             }
             if (!isset($portInfo['id'])) {
                 $portInfo['multiplicity'] = 1;
             }
         }
         //add to data
         $returnValue = array('data' => $connectorType->getLabel() . ":" . $connector->getLabel(), 'attributes' => array('id' => tao_helpers_Uri::encode($connector->getUri()), 'class' => 'node-connector'), 'type' => trim(strtolower($connectorType->getLabel())), 'port' => $nodeClass, 'portData' => $portInfo);
         $returnValue = self::addNodePrefix($returnValue, $nodeClass);
         if (!empty($connectorData)) {
             $returnValue['children'] = $connectorData;
         }
         $this->addedConnectors[] = $connector->getUri();
     }
     return (array) $returnValue;
 }
Exemplo n.º 4
0
 /**
  * Add a resource
  *
  * @param self $resource
  */
 public function addResource(Resource $resource)
 {
     $this->subResources[$resource->getUri()] = $resource;
 }
Exemplo n.º 5
0
 protected function renderLink($rel, Resource $link)
 {
     $xml = '<link';
     $xml .= ' rel="' . $rel . '"';
     $xml .= ' href="' . $link->getUri() . '"';
     if ($link->isTemplated()) {
         $xml .= ' templated="true"';
     }
     $xml .= ' />';
     return $xml;
 }
 /**
  * Short description of method getDefaultFilePath
  *
  * @access public
  * @author Somsack Sipasseuth, <*****@*****.**>
  * @return string
  */
 public function getDefaultFilePath()
 {
     $returnValue = (string) '';
     $returnValue = tao_helpers_Uri::getUniqueId($this->ownerInstance->getUri()) . '/' . tao_helpers_Uri::getUniqueId($this->property->getUri());
     return (string) $returnValue;
 }