/** * exports an array of instances into an rdf string * * @param array $instances * @return string */ public function getRdfString($instances) { $api = core_kernel_impl_ApiModelOO::singleton(); $xmls = array(); foreach ($instances as $instance) { $xmls[] = $api->getResourceDescriptionXML($instance->getUri()); } if (count($xmls) == 1) { $rdf = $xmls[0]; } elseif (count($xmls) > 1) { //merge the xml of each instances... $baseDom = new DomDocument(); $baseDom->formatOutput = true; $baseDom->loadXML($xmls[0]); for ($i = 1; $i < count($xmls); $i++) { $xmlDoc = new SimpleXMLElement($xmls[$i]); foreach ($xmlDoc->getNamespaces() as $nsName => $nsUri) { if (!$baseDom->documentElement->hasAttribute('xmlns:' . $nsName)) { $baseDom->documentElement->setAttribute('xmlns:' . $nsName, $nsUri); } } $newDom = new DOMDocument(); $newDom->loadXml($xmls[$i]); foreach ($newDom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', "Description") as $desc) { $newNode = $baseDom->importNode($desc, true); $baseDom->documentElement->appendChild($newNode); } } $rdf = $baseDom->saveXml(); } return $rdf; }
/** * tests initialization */ public function setUp() { TaoPhpUnitTestRunner::initTest(); $processDefinitionClass = new core_kernel_classes_Class(CLASS_PROCESS); $processDefinition = $processDefinitionClass->createInstance('processMapTestCase', 'created for the unit test ProcessMapTestCase'); if ($processDefinition instanceof core_kernel_classes_Resource) { $this->proc = $processDefinition; } $this->apiModel = core_kernel_impl_ApiModelOO::singleton(); $this->authoringService = wfAuthoring_models_classes_ProcessService::singleton(); }
/** * tests initialization */ public function setUp() { TaoPhpUnitTestRunner::initTest(); $processDefinitionClass = new core_kernel_classes_Class(CLASS_PROCESS); $processDefinition = $processDefinitionClass->createInstance('processForUnitTest', 'created for the unit test of process authoring service'); if ($processDefinition instanceof core_kernel_classes_Resource) { $this->proc = $processDefinition; } else { $this->fail('fail to create a process definition resource'); } $this->apiModel = core_kernel_impl_ApiModelOO::singleton(); $this->variableService = wfEngine_models_classes_VariableService::singleton(); $this->authoringService = wfAuthoring_models_classes_ProcessService::singleton(); }
/** * tests initialization */ public function setUp() { TaoPhpUnitTestRunner::initTest(); $processDefinitionClass = new core_kernel_classes_Class(CLASS_PROCESS); $processDefinition = $processDefinitionClass->createInstance('process of Cloning UnitTest', 'created for the unit test of process cloner'); if ($processDefinition instanceof core_kernel_classes_Resource) { $this->proc = $processDefinition; } $this->apiModel = core_kernel_impl_ApiModelOO::singleton(); $this->authoringService = wfAuthoring_models_classes_ProcessService::singleton(); $this->activityService = wfAuthoring_models_classes_ActivityService::singleton(); $this->connectorService = wfAuthoring_models_classes_ConnectorService::singleton(); $this->processCloner = new wfAuthoring_models_classes_ProcessCloner(); }
/** * Import a XML file as is into the ontology * * @access public * @author Jerome Bogaerts, <*****@*****.**> * @param string source * @param Class destination * @param string namespace * @return boolean */ public function import($source, core_kernel_classes_Class $destination = null, $namespace = null) { $returnValue = (bool) false; $api = core_kernel_impl_ApiModelOO::singleton(); $localModel = rtrim(common_ext_NamespaceManager::singleton()->getLocalNamespace()->getUri(), '#'); if (!is_null($destination) && file_exists($source)) { $destModel = substr($destination->getUri(), 0, strpos($destination->getUri(), '#')); $returnValue = $api->importXmlRdf($destModel, $source); } else { if (file_exists($source) && !is_null($namespace)) { $returnValue = $api->importXmlRdf($namespace, $source); } else { if (file_exists($source)) { $returnValue = $api->importXmlRdf($localModel, $source); } } } return (bool) $returnValue; }
public function debugProcessInstance(core_kernel_classes_Resource $processInstance) { $apiModel = core_kernel_impl_ApiModelOO::singleton(); if (!is_null($processInstance)) { echo 'process instance:' . $this->br; $this->data_dump($processInstance); $processInstances = $processInstance->getPropertyValuesCollection(new core_kernel_classes_Property(PROPERTY_PROCESSINSTANCES_CURRENTTOKEN)); echo "tokens ({$processInstances->count()}):" . $this->br; $sortedProcessInstances = array(); foreach ($processInstances->getIterator() as $token) { $sortedProcessInstances[$token->getUri()] = $token; } krsort($sortedProcessInstances); foreach ($sortedProcessInstances as $token) { $this->data_dump($token); } $activityExecutions = $apiModel->getSubject(PROPERTY_ACTIVITY_EXECUTION_PROCESSEXECUTION, $processInstance->getUri()); echo "activity executions ({$activityExecutions->count()}):" . $this->br; $sortedActivityExecutions = array(); $timeSortingProperty = new core_kernel_classes_Property(PROPERTY_ACTIVITY_EXECUTION_CTX_RECOVERY); $i = 0; foreach ($activityExecutions->getIterator() as $activityExecution) { if (!is_null($timeSortingProperty)) { $created = $activityExecution->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_ACTIVITY_EXECUTION_TIME_CREATED)); $key = is_null($created) ? $i : (string) $created; $sortedActivityExecutions[$key] = $activityExecution; } else { $sortedActivityExecutions[$activityExecution->getUri()] = $activityExecution; } } krsort($sortedActivityExecutions); foreach ($sortedActivityExecutions as $time => $activityExecution) { echo $this->br; echo date('Y-m-d H:i:s', $time) . ":"; $this->data_dump($activityExecution); } } }
/** * Setting the Api to test * */ protected function setUp() { GenerisPhpUnitTestRunner::initTest(); $this->object = core_kernel_impl_ApiModelOO::singleton(); }
$_SERVER['argv'][2] == 'long' ? $nameMode = 'long' : ($nameMode = 'short'); } } else { //from a browser if (isset($_GET['exportDir'])) { $exportDir = $_GET['exportDir']; } if (isset($_GET['nameMode'])) { $_GET['nameMode'] == 'long' ? $nameMode = 'long' : ($nameMode = 'short'); } } if (!is_dir($exportDir)) { out("{$exportDir} is not a directory"); exit; } $api = core_kernel_impl_ApiModelOO::singleton(); $nsManager = common_ext_NamespaceManager::singleton(); $namespaces = $nsManager->getAllNamespaces(); //$namespaces = array(LOCAL_NAMESPACE); foreach ($namespaces as $namespace) { out("Exporting {$namespace}"); $rdfData = core_kernel_api_ModelExporter::exportModelByUri($namespace); if (empty($rdfData)) { out("Nothing exported!"); continue; } if ($nameMode == 'long') { $filename = str_replace('/', '_', str_replace('#', '', $namespace)); } else { $filename = str_replace('#', '', strtolower(basename($namespace))); }
/** * Short description of method singleton * * @access public * @author firstname and lastname of author, <*****@*****.**> * @return core_kernel_impl_ApiModelOO */ public static function singleton() { $returnValue = null; if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c(); } $returnValue = self::$instance; return $returnValue; }
public function __construct($debug = '') { $this->debug = $debug; $this->generisApi = core_kernel_impl_ApiModelOO::singleton(); }
/** * Short description of method run * * @access protected * @author Bertrand Chevrier, <*****@*****.**> * @return mixed */ protected function run() { if (!defined('DEBUG_PERSISTENCE')) { define('DEBUG_PERSISTENCE', false); } switch ($this->mode) { case self::MODE_SMOOTH2HARD: $this->out("Compiling triples to relational database...", array('color' => 'light_blue')); $options = array('recursive' => true, 'append' => true, 'createForeigns' => false, 'referencesAllTypes' => true, 'rmSources' => true); $switcher = new core_kernel_persistence_Switcher(array('http://www.tao.lu/middleware/wfEngine.rdf#ClassProcessVariables', 'http://www.tao.lu/Ontologies/TAOResult.rdf#GradeVariable')); $api = core_kernel_impl_ApiModelOO::singleton(); $toCompile = $api->getAllClasses()->toArray(); foreach ($toCompile as $tC) { $classLabel = $tC->getLabel(); $this->out("\nCompiling '{$classLabel}' class...", array('color' => 'light_blue')); $switcher->hardify($tC, $options); } unset($switcher); $this->out("Compilation process complete."); break; case self::MODE_HARD2SMOOTH: $this->out("Uncompiling relational database to triples...", array('color' => 'light_blue')); $options = array('recursive' => true, 'removeForeigns' => true); $switcher = new core_kernel_persistence_Switcher(array('http://www.tao.lu/middleware/wfEngine.rdf#ClassProcessVariables', 'http://www.tao.lu/Ontologies/TAOResult.rdf#GradeVariable')); $api = core_kernel_impl_ApiModelOO::singleton(); $toDecompile = $api->getAllClasses()->toArray(); foreach ($toDecompile as $tD) { $classLabel = $tD->getLabel(); $this->out("\nDecompiling '{$classLabel}' class...", array('color' => 'light_blue')); $switcher->unhardify($tD, $options); } $this->out("Decompilation process complete."); unset($switcher); break; default: $this->err('Unknow mode', true); } }