PHP Classes

File: test_bouml_component_reader.php

Recommend this page to a friend!
  Classes of Juan Carlos Gonzalez  >  BoUML File Parser  >  test_bouml_component_reader.php  >  Download  
File: test_bouml_component_reader.php
Role: Example script
Content type: text/plain
Description: Implementation example file
Class: BoUML File Parser
Extract information from UML artifact files
Author: By
Last change:
Date: 6 years ago
Size: 2,477 bytes


Class file image Download
 * Script that intends to read from a BoUML ( file set its artifacts
 * Completly open license; don't worry, use it as you want!
 * Plenty of work need to be done like:
 * 1. Add up all uml artifacts supported by boUML within UML_Parser_Configuration_BoUML class
 * 2. Manage error better with more exceptions
 * This is not meant to be a 'final' version or tool; only to embed in whatever you need to understand with BoUML files
 * We at use this code to be sure that all components designed in bouml are actually implemented in code :)
 * @author
 * Browse down in this script for a step by step classes configuration procedure





 * Ths the source class configuration that handles how raw data from files is read
 * @author jgonzalez
class UML_Data_Source_BoUML extends UML_Data_Source_Abstract {
    public function
getSource($source = NULL) {
$complete_file_name = $this->configuration->getProjectPath()."/".$this->getArtifactName();
$source = NULL;
        if (
is_readable($complete_file_name)) {
$source = utf8_encode(file_get_contents($complete_file_name));
        } else {
            throw new
Exception("BoUML::getSource() -> Unable to read file [$complete_file_name]");

 * Script
 * Version .1alpha
 * todos:
 * a) Add in all artifact types to UML_Parser_Configuration_BoUML

// 1. Create configuration manager class
$configuration = new UML_Parser_Configuration_BoUML();

// 2. Configure the root folder for project files

// 3. Select main file
$bouml_data_source = new UML_Data_Source_BoUML('Karmaki-Diseno_global.prj');

// 4. Create project from main source assigning configuration class
$bouml_project = UML_Project::createFromSource($bouml_data_source, $configuration);

// 5. Finally user can browse
foreach($bouml_project->getPackages() as $package) {
$package->getArtifactsByType($configuration->getArtifactNameForComponent()) as $component) {