Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial import of the project

  • Loading branch information...
commit a867b6db2f0d6a23db1c156f7c183018cf878ba1 1 parent 0acc54f
@johmue authored
Showing with 3,781 additions and 0 deletions.
  1. +21 −0 LICENSE
  2. BIN  example/data/test.mwb
  3. +72 −0 example/index.php
  4. +86 −0 lib/MwbExporter/Core/DatatypeConverter.php
  5. +41 −0 lib/MwbExporter/Core/IFormatter.php
  6. +47 −0 lib/MwbExporter/Core/Model/Catalog.php
  7. +87 −0 lib/MwbExporter/Core/Model/Column.php
  8. +49 −0 lib/MwbExporter/Core/Model/Columns.php
  9. +80 −0 lib/MwbExporter/Core/Model/ForeignKey.php
  10. +45 −0 lib/MwbExporter/Core/Model/ForeignKeys.php
  11. +74 −0 lib/MwbExporter/Core/Model/Index.php
  12. +45 −0 lib/MwbExporter/Core/Model/Indices.php
  13. +52 −0 lib/MwbExporter/Core/Model/Schema.php
  14. +49 −0 lib/MwbExporter/Core/Model/Schemas.php
  15. +112 −0 lib/MwbExporter/Core/Model/Table.php
  16. +69 −0 lib/MwbExporter/Core/Model/Tables.php
  17. +74 −0 lib/MwbExporter/Core/Model/View.php
  18. +51 −0 lib/MwbExporter/Core/Model/Views.php
  19. +39 −0 lib/MwbExporter/Core/Registry.php
  20. +66 −0 lib/MwbExporter/Core/Workbench/Document.php
  21. +52 −0 lib/MwbExporter/Core/Workbench/Physical/Model.php
  22. +59 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/DatatypeConverter.php
  23. +84 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/Loader.php
  24. +37 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Catalog.php
  25. +70 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Column.php
  26. +44 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Columns.php
  27. +56 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/ForeignKey.php
  28. +32 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/ForeignKeys.php
  29. +45 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Index.php
  30. +32 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Indices.php
  31. +41 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Schema.php
  32. +43 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Schemas.php
  33. +71 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Table.php
  34. +43 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Tables.php
  35. +42 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/View.php
  36. +43 −0 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Views.php
  37. +79 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/DatatypeConverter.php
  38. +84 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/Loader.php
  39. +37 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/Model/Catalog.php
  40. +117 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/Model/Column.php
  41. +49 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/Model/Columns.php
  42. +56 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/Model/ForeignKey.php
  43. +32 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/Model/ForeignKeys.php
  44. +45 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/Model/Index.php
  45. +32 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/Model/Indices.php
  46. +41 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/Model/Schema.php
  47. +43 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/Model/Schemas.php
  48. +66 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/Model/Table.php
  49. +43 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/Model/Tables.php
  50. +42 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/Model/View.php
  51. +43 −0 lib/MwbExporter/Formatter/Doctrine2/Annotation/Model/Views.php
  52. +59 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/DatatypeConverter.php
  53. +84 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/Loader.php
  54. +37 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/Model/Catalog.php
  55. +70 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/Model/Column.php
  56. +44 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/Model/Columns.php
  57. +56 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/Model/ForeignKey.php
  58. +32 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/Model/ForeignKeys.php
  59. +45 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/Model/Index.php
  60. +32 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/Model/Indices.php
  61. +41 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/Model/Schema.php
  62. +43 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/Model/Schemas.php
  63. +73 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/Model/Table.php
  64. +43 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/Model/Tables.php
  65. +42 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/Model/View.php
  66. +43 −0 lib/MwbExporter/Formatter/Doctrine2/Yaml/Model/Views.php
  67. +41 −0 lib/MwbExporter/Helper/Mwb.php
  68. +79 −0 lib/MwbExporter/Helper/Pluralizer.php
  69. +85 −0 lib/MwbExporter/Helper/Singularizer.php
  70. +70 −0 lib/MwbExporter/Helper/SpecialWordList.php
View
21 LICENSE
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
BIN  example/data/test.mwb
Binary file not shown
View
72 example/index.php
@@ -0,0 +1,72 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+// show errors
+error_reporting(E_ALL);
+
+// lets stop the time
+$start = microtime(true);
+
+
+// enable autoloading of classes
+function mySimpleAutoloadFunction($className){
+ require_once dirname(__FILE__)
+ . DIRECTORY_SEPARATOR
+ . '..'
+ . DIRECTORY_SEPARATOR
+ . 'lib'
+ . DIRECTORY_SEPARATOR
+ . str_replace('_', DIRECTORY_SEPARATOR, $className )
+ . '.php';
+}
+spl_autoload_register('mySimpleAutoloadFunction');
+
+
+// show a simple text box with the output
+echo '<textarea cols="100" rows="50">';
+
+ // create a formatter
+ $formatter = new MwbExporter_Formatter_Doctrine1_Yaml_Loader();
+
+ // alternative formatter example
+ //$formatter = new MwbExporter_Formatter_Doctrine2_Annotation_Loader();
+ //$formatter = new MwbExporter_Formatter_Doctrine2_Yaml_Loader();
+
+ // parse the mwb file
+ $mwb = new MwbExporter_Core_Workbench_Document('data/test.mwb', $formatter);
+
+ // show the export output of the mwb file
+ echo $mwb->display();
+
+echo "</textarea>";
+
+// show some information about used memory
+echo "<br><br>";
+echo (memory_get_peak_usage(true) / 1024 / 1024) . " MB used";
+echo "<br>";
+
+// show the time needed to parse the mwb file
+$end = microtime(true);
+echo sprintf('%0.3f', $end-$start) . " sec needed";
View
86 lib/MwbExporter/Core/DatatypeConverter.php
@@ -0,0 +1,86 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+abstract class MwbExporter_Core_DatatypeConverter
+{
+ protected static $datatypes = array(
+ // simple datatypes
+ 'com.mysql.rdbms.mysql.datatype.tinyint' => 'integer(1)',
+ 'com.mysql.rdbms.mysql.datatype.smallint' => 'integer(2)',
+ 'com.mysql.rdbms.mysql.datatype.mediumint' => 'integer(3)',
+ 'com.mysql.rdbms.mysql.datatype.int' => 'integer(4)',
+ 'com.mysql.rdbms.mysql.datatype.bigint' => 'integer(8)',
+ 'com.mysql.rdbms.mysql.datatype.float' => 'float',
+ 'com.mysql.rdbms.mysql.datatype.double' => 'double',
+ 'com.mysql.rdbms.mysql.datatype.decimal' => 'decimal',
+ 'com.mysql.rdbms.mysql.datatype.char' => 'char',
+ 'com.mysql.rdbms.mysql.datatype.varchar' => 'string',
+ 'com.mysql.rdbms.mysql.datatype.binary' => 'binary',
+ 'com.mysql.rdbms.mysql.datatype.varbinary' => 'varbinary',
+ 'com.mysql.rdbms.mysql.datatype.tinytext' => 'clob(255)',
+ 'com.mysql.rdbms.mysql.datatype.text' => 'clob(65535)',
+ 'com.mysql.rdbms.mysql.datatype.mediumtext' => 'clob(16777215)',
+ 'com.mysql.rdbms.mysql.datatype.longtext' => 'clob',
+ 'com.mysql.rdbms.mysql.datatype.tinyblob' => 'blob(255)',
+ 'com.mysql.rdbms.mysql.datatype.blob' => 'blob(65535)',
+ 'com.mysql.rdbms.mysql.datatype.mediumblob' => 'blob(16777215)',
+ 'com.mysql.rdbms.mysql.datatype.longblob' => 'blob',
+ 'com.mysql.rdbms.mysql.datatype.datetime' => 'timestamp',
+ 'com.mysql.rdbms.mysql.datatype.date' => 'date',
+ 'com.mysql.rdbms.mysql.datatype.time' => 'time',
+ 'com.mysql.rdbms.mysql.datatype.year' => 'integer(2)',
+ 'com.mysql.rdbms.mysql.datatype.timestamp' => 'timestamp',
+ 'com.mysql.rdbms.mysql.datatype.geometry' => 'geometry',
+ 'com.mysql.rdbms.mysql.datatype.linestring' => 'linestring',
+ 'com.mysql.rdbms.mysql.datatype.polygon' => 'polygon',
+ 'com.mysql.rdbms.mysql.datatype.multipoint' => 'multipoint',
+ 'com.mysql.rdbms.mysql.datatype.multilinestring' => 'multilinestring',
+ 'com.mysql.rdbms.mysql.datatype.multipolygon' => 'multipolygon',
+ 'com.mysql.rdbms.mysql.datatype.geometrycollection' => 'geometrycollection',
+ 'com.mysql.rdbms.mysql.datatype.bit' => 'bit',
+ 'com.mysql.rdbms.mysql.datatype.enum' => 'enum',
+ 'com.mysql.rdbms.mysql.datatype.set' => 'set',
+
+ // userdazatypes
+ 'com.mysql.rdbms.mysql.userdatatype.boolean' => 'boolean',
+ 'com.mysql.rdbms.mysql.userdatatype.bool' => 'boolean',
+ 'com.mysql.rdbms.mysql.userdatatype.fixed' => 'decimal',
+ 'com.mysql.rdbms.mysql.userdatatype.float4' => 'float',
+ 'com.mysql.rdbms.mysql.userdatatype.float8' => 'double',
+ 'com.mysql.rdbms.mysql.userdatatype.int1' => 'integer(1)',
+ 'com.mysql.rdbms.mysql.userdatatype.int2' => 'integer(2)',
+ 'com.mysql.rdbms.mysql.userdatatype.int3' => 'integer(3)',
+ 'com.mysql.rdbms.mysql.userdatatype.int4' => 'integer(4)',
+ 'com.mysql.rdbms.mysql.userdatatype.int8' => 'integer(8)',
+ 'com.mysql.rdbms.mysql.userdatatype.integer' => 'integer(4)',
+ 'com.mysql.rdbms.mysql.userdatatype.longvarbinary' => 'blob(16777215)',
+ 'com.mysql.rdbms.mysql.userdatatype.longvarchar' => 'clob(16777215)',
+ 'com.mysql.rdbms.mysql.userdatatype.long' => 'clob(16777215)',
+ 'com.mysql.rdbms.mysql.userdatatype.middleint' => 'integer(3)',
+ 'com.mysql.rdbms.mysql.userdatatype.numeric' => 'decimal',
+ 'com.mysql.rdbms.mysql.userdatatype.dec' => 'decimal',
+ 'com.mysql.rdbms.mysql.userdatatype.character' => 'char'
+ );
+}
View
41 lib/MwbExporter/Core/IFormatter.php
@@ -0,0 +1,41 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+interface MwbExporter_Core_IFormatter {
+ public function createCatalog($parameter);
+ public function createColumn($parameter);
+ public function createColumns($parameter);
+ public function createForeignKey($parameter);
+ public function createForeignKeys($parameter);
+ public function createIndex($parameter);
+ public function createIndices($parameter);
+ public function createSchema($parameter);
+ public function createSchemas($parameter);
+ public function createTable($parameter);
+ public function createTables($parameter);
+ public function createView($parameter);
+ public function createViews($parameter);
+ public function useDatatypeConverter($type, MwbExporter_Core_Model_Column $column);
+}
View
47 lib/MwbExporter/Core/Model/Catalog.php
@@ -0,0 +1,47 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+abstract class MwbExporter_Core_Model_Catalog
+{
+ protected $data = null;
+ protected $attributes = null;
+
+ protected $id = null;
+
+ protected $schemas = null;
+
+ public function __construct($data)
+ {
+ $this->attributes = $data->attributes();
+ $this->data = $data;
+
+ $this->id = (string) $this->attributes['id'];
+
+ $tmp = $this->data->xpath("value[@key='schemata']");
+ $this->schemas = MwbExporter_Core_Registry::get('formatter')->createSchemas($tmp[0]);
+
+ MwbExporter_Core_Registry::set($this->id, $this);
+ }
+}
View
87 lib/MwbExporter/Core/Model/Column.php
@@ -0,0 +1,87 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+abstract class MwbExporter_Core_Model_Column
+{
+ protected $data = null;
+ protected $attributes = null;
+
+ protected $id = null;
+
+ protected $config = array();
+ protected $link = array();
+ protected $isPrimary = false;
+
+ public function __construct($data)
+ {
+ $this->attributes = $data->attributes();
+ $this->data = $data;
+
+ $this->id = (string) $this->attributes['id'];
+
+ /**
+ * iterate on column configuration
+ */
+ foreach($this->data->xpath("value") as $key => $node){
+ $attributes = $node->attributes(); // read attributes
+
+ $key = (string) $attributes['key']; // assign key
+ $this->config[$key] = (string) $node[0]; // assign value
+ }
+
+ /**
+ * iterate on links to other wb objects
+ */
+ foreach($this->data->xpath("link") as $key => $node){
+ $attributes = $node->attributes();
+
+ $key = (string) $attributes['key'];
+ $this->link[$key] = (string) $node[0];
+ }
+
+ MwbExporter_Core_Registry::set($this->id, $this);
+ }
+
+ public function getConfig()
+ {
+ return $this->config;
+ }
+
+ public function getData()
+ {
+ return $this->data;
+ }
+
+ public function markAsPrimary()
+ {
+ $this->isPrimary = true;
+ }
+
+ public function getColumnName()
+ {
+ return $this->config['name'];
+ }
+
+}
View
49 lib/MwbExporter/Core/Model/Columns.php
@@ -0,0 +1,49 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+abstract class MwbExporter_Core_Model_Columns
+{
+ protected $data = null;
+ protected $attributes = null;
+
+ protected $id = null;
+
+ protected $columns = array();
+
+ public function __construct($data)
+ {
+ $this->attributes = $data->attributes();
+ $this->data = $data;
+
+ $this->id = (string) $this->attributes['id'];
+
+ foreach($this->data as $key => $node){
+ $this->columns[] = MwbExporter_Core_Registry::get('formatter')->createColumn($node);
+ }
+
+ MwbExporter_Core_Registry::set($this->id, $this);
+ }
+
+}
View
80 lib/MwbExporter/Core/Model/ForeignKey.php
@@ -0,0 +1,80 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+abstract class MwbExporter_Core_Model_ForeignKey
+{
+ protected $data = null;
+ protected $attributes = null;
+
+ protected $config = null;
+
+ protected $referencedTable = null;
+ protected $owningTable = null;
+
+ protected $id = null;
+
+ public function __construct($data)
+ {
+ $this->attributes = $data->attributes();
+ $this->data = $data;
+
+ $this->id = (string) $this->attributes['id'];
+
+ /**
+ * iterate on foreign key configuration
+ */
+ foreach($this->data->value as $key => $node){
+ $attributes = $node->attributes(); // read attributes
+
+ $key = (string) $attributes['key']; // assign key
+ $this->config[$key] = (string) $node[0]; // assign value
+ }
+
+ /**
+ * follow references to tables
+ */
+ foreach($this->data->link as $key => $node){
+ $attributes = $node->attributes(); // read attributes
+ $key = (string) $attributes['key']; // assign key
+
+ if($key == 'referencedTable'){
+ $referencedTableId = (string) $node;
+ $this->referencedTable = MwbExporter_Core_Registry::get($referencedTableId);
+ }
+
+ if($key == 'owner'){
+ $owningTableId = (string) $node;
+ $this->owningTable = MwbExporter_Core_Registry::get($owningTableId);
+ $this->owningTable->injectRelation($this);
+ }
+ }
+
+ //print_r($this->data->asXML());
+ //die();
+
+ MwbExporter_Core_Registry::set($this->id, $this);
+ }
+
+}
View
45 lib/MwbExporter/Core/Model/ForeignKeys.php
@@ -0,0 +1,45 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+abstract class MwbExporter_Core_Model_ForeignKeys
+{
+ protected $data = null;
+ protected $attributes = null;
+
+ protected $id = null;
+ protected $foreignKeys = array();
+
+ public function __construct($data)
+ {
+ $this->attributes = $data->attributes();
+ $this->data = $data;
+
+ $this->id = (string) $this->attributes['id'];
+
+ foreach($data->value as $key => $node){
+ $this->foreignKeys[] = MwbExporter_Core_Registry::get('formatter')->createForeignKey($node);
+ }
+ }
+}
View
74 lib/MwbExporter/Core/Model/Index.php
@@ -0,0 +1,74 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+abstract class MwbExporter_Core_Model_Index
+{
+ protected $data = null;
+ protected $attributes = null;
+
+ protected $id = null;
+ protected $referencedColumn = array();
+
+ public function __construct($data)
+ {
+ $this->attributes = $data->attributes();
+ $this->data = $data;
+ $this->id = (string) $this->attributes['id'];
+
+ /**
+ * iterate on column configuration
+ */
+ foreach($this->data->value as $key => $node){
+ $attributes = $node->attributes(); // read attributes
+ $key = (string) $attributes['key']; // assign key
+ $this->config[$key] = (string) $node[0]; // assign value
+ }
+
+ /**
+ * iterate on links to other wb objects
+ */
+ foreach($this->data->link as $key => $node){
+ $attributes = $node->attributes();
+ $key = (string) $attributes['key'];
+ }
+
+ foreach($this->data->xpath("value[@key='columns']/value") as $indexColumn){
+ foreach($indexColumn->link as $node){
+ if( (string) $node['key'] === 'referencedColumn' ){
+ // for primary indexes ignore external index
+ // definition and set column to primary instead
+ if($this->config['name'] == 'PRIMARY'){
+ MwbExporter_Core_Registry::get((string) $node)->markAsPrimary();
+ return;
+ }
+ $this->referencedColumn[] = MwbExporter_Core_Registry::get((string) $node);
+ }
+ }
+ }
+
+ MwbExporter_Core_Registry::get((string)$this->data->link)->injectIndex($this);
+ }
+
+}
View
45 lib/MwbExporter/Core/Model/Indices.php
@@ -0,0 +1,45 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+abstract class MwbExporter_Core_Model_Indices
+{
+ protected $data = null;
+ protected $attributes = null;
+
+ protected $id = null;
+ protected $indices = array();
+
+ public function __construct($data)
+ {
+ $this->attributes = $data->attributes();
+ $this->data = $data;
+
+ $this->id = (string) $this->attributes['id'];
+
+ foreach($data->value as $key => $node){
+ $this->indices[] = MwbExporter_Core_Registry::get('formatter')->createIndex($node);
+ }
+ }
+}
View
52 lib/MwbExporter/Core/Model/Schema.php
@@ -0,0 +1,52 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+abstract class MwbExporter_Core_Model_Schema
+{
+ protected $data = null;
+ protected $attributes = null;
+
+ protected $id = null;
+
+ protected $tables = null;
+ protected $views = null;
+
+ public function __construct($data)
+ {
+ $this->attributes = $data->attributes();
+ $this->data = $data;
+
+ $this->id = (string) $this->attributes['id'];
+
+ $tmp = $this->data->xpath("value[@key='tables']");
+ $this->tables = MwbExporter_Core_Registry::get('formatter')->createTables($tmp[0]);
+
+ $tmp = $this->data->xpath("value[@key='views']");
+ $this->views = MwbExporter_Core_Registry::get('formatter')->createViews($tmp[0]);
+
+ MwbExporter_Core_Registry::set($this->id, $this);
+ }
+
+}
View
49 lib/MwbExporter/Core/Model/Schemas.php
@@ -0,0 +1,49 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+abstract class MwbExporter_Core_Model_Schemas
+{
+ protected $data = null;
+ protected $attributes = null;
+
+ protected $id = null;
+
+ protected $schemas = array();
+
+ public function __construct($data)
+ {
+ $this->attributes = $data->attributes();
+ $this->data = $data;
+
+ $this->id = (string) $this->attributes['id'];
+
+ foreach($this->data->xpath("value") as $key => $node){
+ $this->schemas[] = MwbExporter_Core_Registry::get('formatter')->createSchema($node);
+ }
+
+ MwbExporter_Core_Registry::set($this->id, $this);
+ }
+
+}
View
112 lib/MwbExporter/Core/Model/Table.php
@@ -0,0 +1,112 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+abstract class MwbExporter_Core_Model_Table
+{
+ protected $data = null;
+ protected $attributes = null;
+ protected $config = null;
+
+ protected $id = null;
+
+ protected $columns = null; // workbench object
+ protected $indices = null; // workbench object
+ protected $foreignKeys = null; // workbench object
+ protected $indexes = array(); // collection of indexes
+ protected $relations = array(); // collection of relations
+
+
+ public function __construct($data)
+ {
+ $this->attributes = $data->attributes();
+ $this->data = $data;
+
+ $this->id = (string) $this->attributes['id'];
+
+ $tmp = $this->data->xpath("value[@key='columns']");
+ $this->columns = MwbExporter_Core_Registry::get('formatter')->createColumns($tmp[0]);
+
+ /**
+ * iterate on column configuration
+ */
+ foreach($this->data->value as $key => $node){
+ $attributes = $node->attributes(); // read attributes
+
+ $key = (string) $attributes['key']; // assign key
+ $this->config[$key] = (string) $node[0]; // assign value
+ }
+
+ MwbExporter_Core_Registry::set($this->id, $this);
+ }
+
+ public function checkForIndices()
+ {
+ foreach($this->data->xpath("value[@key='indices']") as $key => $node){
+ $this->indices = MwbExporter_Core_Registry::get('formatter')->createIndices($node);
+ }
+ }
+
+ public function checkForForeignKeys()
+ {
+ foreach($this->data->xpath("value[@key='foreignKeys']") as $key => $node){
+ $this->foreignKeys = MwbExporter_Core_Registry::get('formatter')->createForeignKeys($node);
+ }
+ }
+
+ public function isTranslationTable()
+ {
+ $return = preg_match('@^(.*)\_translation$@', $this->getRawTableName(), $matches);
+ if($return){
+ $return = $matches[1];
+ }
+ return $return;
+ }
+
+ public function getRawTableName()
+ {
+ return $this->config['name'];
+ }
+
+ public function getModelName()
+ {
+ // camleCase under scores for model names
+ return ucfirst(preg_replace('@\_(\w)@e', 'ucfirst("$1")', $this->getRawTableName()));
+ }
+
+ public function getModelNameInPlural()
+ {
+ return Helper_Pluralizer::pluralize($this->getModelName());
+ }
+
+ public function injectIndex(MwbExporter_Core_Model_Index $index)
+ {
+ $this->indexes[] = $index;
+ }
+
+ public function injectRelation(MwbExporter_Core_Model_ForeignKey $foreignKey)
+ {
+ $this->relations[] = $foreignKey;
+ }
+}
View
69 lib/MwbExporter/Core/Model/Tables.php
@@ -0,0 +1,69 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+abstract class MwbExporter_Core_Model_Tables
+{
+ protected $data = null;
+ protected $attributes = null;
+
+ protected $id = null;
+
+ protected $tables = array();
+
+ public function __construct($data)
+ {
+ $this->attributes = $data->attributes();
+ $this->data = $data;
+
+ $this->id = (string) $this->attributes['id'];
+
+ /**
+ * collect tables
+ */
+ foreach($this->data->xpath("value") as $key => $node){
+ $tmp = MwbExporter_Core_Registry::get('formatter')->createTable($node);
+
+ if($tmp->isTranslationTable()){
+ // skip translation tables
+ continue;
+ }
+
+ $this->tables[] = $tmp;
+ }
+
+ /**
+ * before you can check for foreign keys
+ * you have to store all tables in the
+ * object registry first
+ */
+ foreach($this->tables as $table){
+ $table->checkForIndices();
+ $table->checkForForeignKeys();
+ }
+
+ MwbExporter_Core_Registry::set($this->id, $this);
+ }
+
+}
View
74 lib/MwbExporter/Core/Model/View.php
@@ -0,0 +1,74 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+abstract class MwbExporter_Core_Model_View
+{
+ protected $data = null;
+ protected $attributes = null;
+ protected $config = null;
+
+ protected $id = null;
+
+ protected $columns = null;
+
+ public function __construct($data)
+ {
+ $this->attributes = $data->attributes();
+ $this->data = $data;
+
+ $this->id = (string) $this->attributes['id'];
+
+ $tmp = $this->data->xpath("value[@key='columns']");
+ $this->columns = MwbExporter_Core_Registry::get('formatter')->createColumns($tmp[0]);
+
+ /**
+ * iterate on column configuration
+ */
+ foreach($this->data->value as $key => $node){
+ $attributes = $node->attributes(); // read attributes
+
+ $key = (string) $attributes['key']; // assign key
+ $this->config[$key] = (string) $node[0]; // assign value
+ }
+
+ MwbExporter_Core_Registry::set($this->id, $this);
+ }
+
+ public function getRawTableName()
+ {
+ return $this->config['name'];
+ }
+
+ public function getModelName()
+ {
+ return ucfirst(preg_replace('@\_(\w)@e', 'ucfirst("$1")', $this->getRawTableName()));
+ }
+
+ public function getModelNameInPlural()
+ {
+ return Helper_Pluralizer::pluralize($this->getModelName());
+ }
+
+}
View
51 lib/MwbExporter/Core/Model/Views.php
@@ -0,0 +1,51 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+abstract class MwbExporter_Core_Model_Views
+{
+ protected $data = null;
+ protected $attributes = null;
+
+ protected $id = null;
+
+ protected $views = array();
+
+ public function __construct($data)
+ {
+ $this->attributes = $data->attributes();
+ $this->data = $data;
+
+ $this->id = (string) $this->attributes['id'];
+
+ /**
+ * iterate on views
+ */
+ foreach($data->value as $key => $node){
+ $this->views[] = MwbExporter_Core_Registry::get('formatter')->createView($node);
+ }
+
+ MwbExporter_Core_Registry::set($this->id, $this);
+ }
+}
View
39 lib/MwbExporter/Core/Registry.php
@@ -0,0 +1,39 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Core_Registry
+{
+ protected static $register = array();
+
+ public static function set($key, $obj)
+ {
+ self::$register[$key] = $obj;
+ }
+
+ public static function get($key)
+ {
+ return isset(self::$register[$key]) ? self::$register[$key] : false;
+ }
+}
View
66 lib/MwbExporter/Core/Workbench/Document.php
@@ -0,0 +1,66 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Core_Workbench_Document
+{
+ protected $data = null;
+ protected $attributes = null;
+
+ protected $id = null;
+
+ protected $physicalModel = null;
+
+ public function __construct($mwbFile, MwbExporter_Core_IFormatter $formatter)
+ {
+ // load mxb xml file
+ $this->data = simplexml_load_string(MwbExporter_Helper_Mwb::read($mwbFile));
+
+ // save formatter in registry
+ MwbExporter_Core_Registry::set('formatter', $formatter);
+
+ // save document in registry
+ MwbExporter_Core_Registry::set('document', $this);
+ $this->parse();
+
+ // save this object in registry by workebench id
+ MwbExporter_Core_Registry::set($this->id, $this);
+ }
+
+ protected function parse()
+ {
+ $this->attributes = $this->data->value->attributes();
+ $this->data = $this->data->value;
+
+ $this->id = (string) $this->attributes['id'];
+
+ $tmp = $this->data->xpath("value[@key='physicalModels']/value");
+ $this->physicalModel = new MwbExporter_Core_Workbench_Physical_Model($tmp[0]);
+ }
+
+ public function display()
+ {
+ return $this->physicalModel->display();
+ }
+}
View
52 lib/MwbExporter/Core/Workbench/Physical/Model.php
@@ -0,0 +1,52 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Core_Workbench_Physical_Model
+{
+ protected $data = null;
+ protected $attributes = null;
+
+ protected $id = null;
+
+ protected $catalog = null;
+
+ public function __construct($data)
+ {
+ $this->attributes = $data->attributes();
+ $this->data = $data;
+
+ $this->id = (string) $this->attributes['id'];
+
+ $tmp = $this->data->xpath("value[@key='catalog']");
+ $this->catalog = MwbExporter_Core_Registry::get('formatter')->createCatalog($tmp[0]);
+
+ MwbExporter_Core_Registry::set($this->id, $this);
+ }
+
+ public function display()
+ {
+ return $this->catalog->display();
+ }
+}
View
59 lib/MwbExporter/Formatter/Doctrine1/Yaml/DatatypeConverter.php
@@ -0,0 +1,59 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_DatatypeConverter extends MwbExporter_Core_DatatypeConverter
+{
+ public static function getType($key, MwbExporter_Core_Model_Column $column)
+ {
+ $return = isset(self::$datatypes[$key]) ? self::$datatypes[$key] : 'unknown';
+ $config = $column->getConfig();
+ if ( isset($config['scale'])
+ && $config['scale'] != -1
+ && isset($config['precision'])
+ && $config['precision'] != -1 ){
+
+ $return = $return . '(' . $config['scale'] . ',' . $config['precision'] . ')';
+ }
+
+ if( isset($config['length']) && $config['length'] != -1 ){
+ $return = $return . '(' . $config['length'] . ')';
+ }
+
+ // handle enums
+ if($key === 'com.mysql.rdbms.mysql.datatype.enum'){
+ $return .= "\n";
+ $return .= " values: " . str_replace(array('(',')'), array('[',']'), $config['datatypeExplicitParams']);
+ }
+
+ // handle sets
+ // @TODO sets are not supported by doctrine
+ if($key === 'com.mysql.rdbms.mysql.datatype.set'){
+ $return .= "\n";
+ $return .= " values: " . str_replace(array('(',')'), array('[',']'), $config['datatypeExplicitParams']);
+ }
+
+ return $return;
+ }
+}
View
84 lib/MwbExporter/Formatter/Doctrine1/Yaml/Loader.php
@@ -0,0 +1,84 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_Loader implements MwbExporter_Core_IFormatter
+{
+
+ public function createCatalog($parameter){
+ return new MwbExporter_Formatter_Doctrine1_Yaml_Model_Catalog($parameter);
+ }
+
+ public function createColumn($parameter){
+ return new MwbExporter_Formatter_Doctrine1_Yaml_Model_Column($parameter);
+ }
+
+ public function createColumns($parameter){
+ return new MwbExporter_Formatter_Doctrine1_Yaml_Model_Columns($parameter);
+ }
+
+ public function createForeignKey($parameter){
+ return new MwbExporter_Formatter_Doctrine1_Yaml_Model_ForeignKey($parameter);
+ }
+
+ public function createForeignKeys($parameter){
+ return new MwbExporter_Formatter_Doctrine1_Yaml_Model_ForeignKeys($parameter);
+ }
+
+ public function createIndex($parameter){
+ return new MwbExporter_Formatter_Doctrine1_Yaml_Model_Index($parameter);
+ }
+
+ public function createIndices($parameter){
+ return new MwbExporter_Formatter_Doctrine1_Yaml_Model_Indices($parameter);
+ }
+
+ public function createSchema($parameter){
+ return new MwbExporter_Formatter_Doctrine1_Yaml_Model_Schema($parameter);
+ }
+
+ public function createSchemas($parameter){
+ return new MwbExporter_Formatter_Doctrine1_Yaml_Model_Schemas($parameter);
+ }
+
+ public function createTable($parameter){
+ return new MwbExporter_Formatter_Doctrine1_Yaml_Model_Table($parameter);
+ }
+
+ public function createTables($parameter){
+ return new MwbExporter_Formatter_Doctrine1_Yaml_Model_Tables($parameter);
+ }
+
+ public function createView($parameter){
+ return new MwbExporter_Formatter_Doctrine1_Yaml_Model_View($parameter);
+ }
+
+ public function createViews($parameter){
+ return new MwbExporter_Formatter_Doctrine1_Yaml_Model_Views($parameter);
+ }
+
+ public function useDatatypeConverter($type, MwbExporter_Core_Model_Column $column){
+ return MwbExporter_Formatter_Doctrine1_Yaml_DatatypeConverter::getType($type, $column);
+ }
+}
View
37 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Catalog.php
@@ -0,0 +1,37 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_Model_Catalog extends MwbExporter_Core_Model_Catalog
+{
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ }
+
+ public function display()
+ {
+ return $this->schemas->display();
+ }
+}
View
70 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Column.php
@@ -0,0 +1,70 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_Model_Column extends MwbExporter_Core_Model_Column
+{
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ }
+
+ public function display()
+ {
+ $return = array();
+
+ // set name of column
+ $return[] = ' ' . $this->config['name'] . ':';
+
+ // set datatype of column
+ $return[] = ' type: ' . MwbExporter_Core_Registry::get('formatter')->useDatatypeConverter((isset($this->link['simpleType']) ? $this->link['simpleType'] : $this->link['userType']), $this);
+
+ if($this->isPrimary){
+ $return[] = ' primary: true';
+ }
+
+ // check for auto increment column
+ if(isset($this->config['autoIncrement']) && $this->config['autoIncrement'] == 1){
+ $return[] = ' autoincrement: true';
+ }
+
+ // set default value
+ if(isset($this->config['defaultValue']) && $this->config['defaultValue'] != '' && $this->config['defaultValue'] != 'NULL'){
+ $return[] = ' default: ' . $this->config['defaultValue'];
+ }
+
+ // check for not null column
+ if(isset($this->config['isNotNull']) && $this->config['isNotNull'] == 1){
+ $return[] = ' notnull: true';
+ }
+
+ // iterate on column flags
+ foreach($this->data->xpath("value[@key='flags']/value") as $flag){
+ $return[] = ' ' . strtolower($flag) . ': true';
+ }
+
+ // return yaml representation of column
+ return implode("\n", $return);
+ }
+}
View
44 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Columns.php
@@ -0,0 +1,44 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_Model_Columns extends MwbExporter_Core_Model_Columns
+{
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ }
+
+ public function display()
+ {
+ $return = array();
+
+ $return[] = ' columns: ';
+ foreach($this->columns as $column){
+ $return[] = $column->display();
+ }
+
+ return implode("\n", $return);
+ }
+}
View
56 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/ForeignKey.php
@@ -0,0 +1,56 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_Model_ForeignKey extends MwbExporter_Core_Model_ForeignKey
+{
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ }
+
+ public function display()
+ {
+ $return = array();
+ $return[] = ' ' . $this->referencedTable->getModelName() . ':';
+ $return[] = ' class: ' . $this->referencedTable->getModelName();
+
+ $referencedColumn = $this->data->xpath("value[@key='referencedColumns']");
+ $return[] = ' local: ' . MwbExporter_Core_Registry::get((string) $referencedColumn[0]->link)->getColumnName();
+
+ $ownerColumn = $this->data->xpath("value[@key='columns']");
+ $return[] = ' foreign: ' . MwbExporter_Core_Registry::get((string) $ownerColumn[0]->link)->getColumnName();
+
+ if((int)$this->config['many'] === 1){
+ $return[] = ' foreignAlias: ' . MwbExporter_Helper_Pluralizer::pluralize($this->owningTable->getModelName());
+ } else {
+ $return[] = ' foreignAlias: ' . $this->owningTable->getModelName();
+ }
+
+ $return[] = ' onDelete: ' . strtolower($this->config['deleteRule']);
+ $return[] = ' onUpdate: ' . strtolower($this->config['updateRule']);
+
+ return implode("\n", $return);
+ }
+}
View
32 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/ForeignKeys.php
@@ -0,0 +1,32 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_Model_ForeignKeys extends MwbExporter_Core_Model_ForeignKeys
+{
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ }
+}
View
45 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Index.php
@@ -0,0 +1,45 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_Model_Index extends MwbExporter_Core_Model_Index
+{
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ }
+
+ public function display()
+ {
+ $return = array();
+ $return[] = ' ' . $this->config['name'] . ':';
+ $tmp = ' fields: [';
+ foreach($this->referencedColumn as $refColumn){
+ $tmp .= $refColumn->getColumnName() . ',';
+ }
+ $return[] = substr($tmp, 0, -1) . ']';
+ $return[] = ' type: ' . strtolower($this->config['indexType']);
+ return implode("\n", $return);
+ }
+}
View
32 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Indices.php
@@ -0,0 +1,32 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_Model_Indices extends MwbExporter_Core_Model_Indices
+{
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ }
+}
View
41 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Schema.php
@@ -0,0 +1,41 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_Model_Schema extends MwbExporter_Core_Model_Schema
+{
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ }
+
+ public function display()
+ {
+ $return = array();
+ $return[] = $this->tables->display();
+ //$return[] = $this->views->display();
+
+ return implode("\n", $return);
+ }
+}
View
43 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Schemas.php
@@ -0,0 +1,43 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_Model_Schemas extends MwbExporter_Core_Model_Schemas
+{
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ }
+
+ public function display()
+ {
+ $return = array();
+
+ foreach($this->schemas as $schema){
+ $return[] = $schema->display();
+ }
+
+ return implode("\n", $return);
+ }
+}
View
71 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Table.php
@@ -0,0 +1,71 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_Model_Table extends MwbExporter_Core_Model_Table
+{
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ }
+
+ public function display()
+ {
+ $return = array();
+ $return[] = $this->getModelName() . ':';
+
+ if($this->getModelName() !== ucfirst($this->getRawTableName())){
+ $return[] = ' table_name: ' . $this->getRawTableName();
+ }
+
+ $return[] = $this->columns->display();
+
+ // add relations
+ if(count($this->relations) > 0){
+ $return[] = ' relations:';
+
+ foreach($this->relations as $relation){
+ $return[] = $relation->display();
+ }
+ }
+
+ // add indices
+ if(count($this->indexes) > 0){
+ $return[] = ' indexes:';
+
+ foreach($this->indexes as $index){
+ $return[] = $index->display();
+ }
+ }
+
+ $return[] = ' options:';
+ $return[] = ' charset: ' . $this->config['defaultCharacterSetName'];
+ $return[] = ' type: ' . $this->config['tableEngine'];
+
+ // add empty line behind table
+ $return[] = '';
+
+ return implode("\n", $return);
+ }
+}
View
43 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Tables.php
@@ -0,0 +1,43 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_Model_Tables extends MwbExporter_Core_Model_Tables
+{
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ }
+
+ public function display()
+ {
+ $return = array();
+
+ foreach($this->tables as $table){
+ $return[] = $table->display();
+ }
+
+ return implode("\n", $return);
+ }
+}
View
42 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/View.php
@@ -0,0 +1,42 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_Model_View extends MwbExporter_Core_Model_View
+{
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ }
+
+ public function display()
+ {
+ $return = array();
+ $return[] = $this->getModelName() . ':';
+ $return[] = $this->columns->display();
+ $return[] = '';
+
+ return implode("\n", $return);
+ }
+}
View
43 lib/MwbExporter/Formatter/Doctrine1/Yaml/Model/Views.php
@@ -0,0 +1,43 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class MwbExporter_Formatter_Doctrine1_Yaml_Model_Views extends MwbExporter_Core_Model_Views
+{
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ }
+
+ public function display()
+ {
+ $return = array();
+
+ foreach($this->views as $view){
+ $return[] = $view->display();
+ }
+
+ return implode("\n", $return);
+ }
+}
View
79 lib/MwbExporter/Formatter/Doctrine2/Annotation/DatatypeConverter.php
@@ -0,0 +1,79 @@
+<?php
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Johannes Mueller <circus2(at)web.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy