SchemaReverse.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// @file SchemaReverse.qm Qore user module for reverse engineering of database SQL schemas
/* SchemaReverse.qm Copyright 2016 - 2017 Qore Technologies, s.r.o.
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 FORANY 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.
*/
// this module requires Qore 0.8.13 or better
// requires the SqlUtil module
// requires the Util module
// requires the Qorize module
namespace SchemaReverse {
const TYPE_TO_CLASS = (
"sequence" : "SequenceReverse",
"table" : "TableReverse",
"type" : "TypeReverse",
"view" : "ViewReverse",
"mview" : "MViewReverse",
"function" : "FunctionReverse",
"procedure" : "ProcedureReverse",
"package" : "PackageReverse",
);
const MULTI_TO_CLASS = (
"sequences" : "SequencesReverse",
"tables" : "TablesReverse",
"types" : "TypesReverse",
"views" : "ViewsReverse",
"mviews" : "MViewsReverse",
"functions" : "FunctionsReverse",
"procedures" : "ProceduresReverse",
"packages" : "PackagesReverse",
);
const TEMPLATE = '
const GenericOptions = (
"replace": True,
);
const IndexOptions = (
"driver": (
"oracle": ("compute_statistics": False,),
),
);
const ColumnOptions = (
"driver": (
"oracle": ("character_semantics": True,),
),
);
const SEQUENCES = <SCHEMA_SEQUENCES>;
const TABLES = <SCHEMA_TABLES>;
const TYPES = <SCHEMA_TYPES>;
const VIEWS = <SCHEMA_VIEWS>;
const MATERIALIZED_VIEWS = <SCHEMA_MVIEWS>;
const FUNCTIONS = <SCHEMA_FUNCTIONS>;
const PROCEDURES = <SCHEMA_PROCEDURES>;
const PACKAGES = <SCHEMA_PACKAGES>;
class <X_SCHEMA_NAME> : public AbstractSchema {
public {
const SchemaName = "<X_SCHEMA_NAME>";
const SchemaVersion = "1.0";
}
constructor(AbstractDatasource ds, *string dts, *string its) ;
private:
string getNameImpl();
public:
private:
string getVersionImpl();
public:
private:
*hash getTablesImpl();
public:
private:
*hash getSequencesImpl();
public:
private:
*hash getTypesImpl();
public:
private:
*hash getViewsImpl();
public:
private:
*hash getMaterializedViewsImpl();
public:
private:
*hash getFunctionsImpl();
public:
private:
*hash getProceduresImpl();
public:
private:
*hash getPackagesImpl();
public:
private:
*hash getIndexOptionsImpl();
public:
private:
*hash getGenericOptionsImpl();
public:
private:
*hash getColumnOptionsImpl();
public:
} // class <X_SCHEMA_NAME>
';
class AbstractReverseObject {
public:
private :
AbstractDatasource m_ds;
Database m_db;
string m_name;
public:
constructor(AbstractDatasource ds, string name);
AbstractDatasource datasource();
Database database();
string name();
abstract any toQore();
string toString();
}; // class AbstractReverseObject
class SequenceReverse : public AbstractReverseObject {
public:
constructor(AbstractDatasource ds, string name)
: AbstractReverseObject(ds, name)
{
}
hash toQore();
}; // class SequenceReverse
class SequencesReverse : public AbstractReverseObject {
public:
constructor(AbstractDatasource ds, string mask = ".*")
: AbstractReverseObject(ds, mask)
{
}
hash toQore();
}; // class SequencesReverse
class TypeReverse : public AbstractReverseObject {
public:
constructor(AbstractDatasource ds, string name)
: AbstractReverseObject(ds, name)
{
}
hash toQore();
}; // class TypeReverse
class TypesReverse : public AbstractReverseObject {
public:
constructor(AbstractDatasource ds, string mask = ".*")
: AbstractReverseObject(ds, mask)
{
}
hash toQore();
}; // class TypesReverse
class TableReverse : public AbstractReverseObject {
public:
constructor(AbstractDatasource ds, string name)
: AbstractReverseObject(ds, name)
{
}
hash toQore();
any columnToQore(AbstractColumn c);
}; // class TableReverse
class TablesReverse : public AbstractReverseObject {
public:
constructor(AbstractDatasource ds, string mask = ".*")
: AbstractReverseObject(ds, mask)
{
}
hash toQore();
}; // class TablesReverse
class CodeBaseReverse : public AbstractReverseObject {
public:
private :
string m_object_type;
string m_function_name;
hash<string, bool> m_ignored_keys;
public:
constructor(string object_type,
AbstractDatasource ds,
string name,
string function_name,
softlist ignored_keys
)
: AbstractReverseObject(ds, name)
{
m_object_type = object_type;
m_function_name = function_name;
// make a hash of keys to ignore for fast lookups (to similate a set)
m_ignored_keys = map {$1: True}, ignored_keys;
}
hash toQore();
}; // class CodeBaseReverse
class CodesBaseReverse : public AbstractReverseObject {
public:
private :
string m_object_type;
string m_function_name;
public:
constructor(string object_type,
AbstractDatasource ds,
string mask,
string function_name,
)
: AbstractReverseObject(ds, mask)
{
if (!exists TYPE_TO_CLASS{object_type});
m_object_type = object_type;
m_function_name = function_name;
}
hash toQore();
}; // class CodeBaseReverse
class ViewReverse : public CodeBaseReverse {
public:
constructor(AbstractDatasource ds, string name)
: CodeBaseReverse("view", ds, name, "getView", ("schema", "name", ))
{
}
}; // class ViewReverse
class ViewsReverse : public CodesBaseReverse {
public:
constructor(AbstractDatasource ds, string mask = ".*")
: CodesBaseReverse("view", ds, mask, "viewIterator")
{
}
}; // class ViewsReverse
class MViewReverse : public CodeBaseReverse {
public:
constructor(AbstractDatasource ds, string name)
: CodeBaseReverse("mview", ds, name, "getMaterializedView", ("schema", "name", "type"))
{
}
}; // class MViewReverse
class MViewsReverse : public CodesBaseReverse {
public:
constructor(AbstractDatasource ds, string mask = ".*")
: CodesBaseReverse("mview", ds, mask, "materializedViewIterator")
{
}
}; // class MViewsReverse
class FunctionReverse : public AbstractReverseObject {
public:
constructor(AbstractDatasource ds, string name)
: AbstractReverseObject(ds, name)
{
}
string toQore();
}; // class FunctionReverse
class FunctionsReverse : public CodesBaseReverse {
public:
constructor(AbstractDatasource ds, string mask = ".*")
: CodesBaseReverse("function", ds, mask, "functionIterator")
{
}
}; // class FunctionsReverse
class ProcedureReverse : public AbstractReverseObject {
public:
constructor(AbstractDatasource ds, string name)
: AbstractReverseObject(ds, name)
{
}
string toQore();
}; // class ProcedureReverse
class ProceduresReverse : public CodesBaseReverse {
public:
constructor(AbstractDatasource ds, string mask = ".*")
: CodesBaseReverse("procedure", ds, mask, "procedureIterator")
{
}
}; // class ProceduresReverse
class PackageReverse : public AbstractReverseObject {
public:
constructor(AbstractDatasource ds, string name)
: AbstractReverseObject(ds, name)
{
}
hash toQore();
}; // class ProcedureReverse
class PackagesReverse : public CodesBaseReverse {
public:
constructor(AbstractDatasource ds, string mask = ".*")
: CodesBaseReverse("package", ds, mask, "packageIterator")
{
}
}; // class ProceduresReverse
class SchemaReverse {
public:
private :
AbstractDatasource m_ds;
string m_class_name;
public:
constructor(AbstractDatasource ds, string class_name);
string toString();
}; // class SchemaReverse
AbstractReverseObject get_object(string object_type);
} // namespace SchemaReverse
SchemaReverse::FunctionsReverse
Structure dump of functions.
Definition: SchemaReverse.qm.dox.h:573
SchemaReverse::ViewReverse::constructor
constructor(AbstractDatasource ds, string name)
Definition: SchemaReverse.qm.dox.h:511
SchemaReverse::CodeBaseReverse::constructor
constructor(string object_type, AbstractDatasource ds, string name, string function_name, softlist ignored_keys)
Definition: SchemaReverse.qm.dox.h:450
SchemaReverse::PackagesReverse::constructor
constructor(AbstractDatasource ds, string mask=".*")
Definition: SchemaReverse.qm.dox.h:637
SchemaReverse
this namespace contains all public definitions in the SchemaReverse module
Definition: SchemaReverse.qm.dox.h:124
SchemaReverse::CodesBaseReverse::constructor
constructor(string object_type, AbstractDatasource ds, string mask, string function_name,)
Definition: SchemaReverse.qm.dox.h:487
SchemaReverse::ProceduresReverse::constructor
constructor(AbstractDatasource ds, string mask=".*")
Definition: SchemaReverse.qm.dox.h:608
SchemaReverse::ViewsReverse::constructor
constructor(AbstractDatasource ds, string mask=".*")
Definition: SchemaReverse.qm.dox.h:524
SchemaReverse::PackageReverse
Structure dump of a package.
Definition: SchemaReverse.qm.dox.h:615
SchemaReverse::SequenceReverse::constructor
constructor(AbstractDatasource ds, string name)
Definition: SchemaReverse.qm.dox.h:334
SchemaReverse::ViewsReverse
Structure dump of views.
Definition: SchemaReverse.qm.dox.h:518
SchemaReverse::TypeReverse
Structure dump of a &#39;type&#39; or &#39;named type&#39;.
Definition: SchemaReverse.qm.dox.h:362
SchemaReverse::TypeReverse::constructor
constructor(AbstractDatasource ds, string name)
Definition: SchemaReverse.qm.dox.h:368
SchemaReverse::get_object
AbstractReverseObject get_object(string object_type)
An universal wrapper to get any of SchemaReverse::AbstractReverseObject instance. ...
True
const True
SchemaReverse::AbstractReverseObject::toQore
abstract any toQore()
Dedicated functionlity to get DB object info into the internal structure is done here.
SchemaReverse::PackageReverse::constructor
constructor(AbstractDatasource ds, string name)
Definition: SchemaReverse.qm.dox.h:621
SchemaReverse::AbstractReverseObject::constructor
constructor(AbstractDatasource ds, string name)
SchemaReverse::TableReverse::constructor
constructor(AbstractDatasource ds, string name)
Definition: SchemaReverse.qm.dox.h:400
SchemaReverse::ViewReverse
Structure dump of a view.
Definition: SchemaReverse.qm.dox.h:505
SchemaReverse::TypesReverse::constructor
constructor(AbstractDatasource ds, string mask=".*")
Definition: SchemaReverse.qm.dox.h:384
SchemaReverse::CodeBaseReverse
A basic class for all DB object classes which use SQL code as base of its content.
Definition: SchemaReverse.qm.dox.h:434
SchemaReverse::TypesReverse
Structure dump of &#39;types&#39; or &#39;named types&#39;.
Definition: SchemaReverse.qm.dox.h:378
SchemaReverse::TablesReverse
Structure dump of tables.
Definition: SchemaReverse.qm.dox.h:414
SchemaReverse::AbstractReverseObject::datasource
AbstractDatasource datasource()
SchemaReverse::CodesBaseReverse
A basic class for all DB object classes which use SQL code as base of its content.
Definition: SchemaReverse.qm.dox.h:473
SchemaReverse::MViewsReverse
Structure dump of materialized views or snapshots.
Definition: SchemaReverse.qm.dox.h:544
SchemaReverse::MViewReverse
Structure dump of a materialized view or snapshot.
Definition: SchemaReverse.qm.dox.h:531
SchemaReverse::SequencesReverse
Structure dump of sequences.
Definition: SchemaReverse.qm.dox.h:346
SchemaReverse::ProcedureReverse::constructor
constructor(AbstractDatasource ds, string name)
Definition: SchemaReverse.qm.dox.h:592
exists
bool exists(...)
SchemaReverse::ProcedureReverse
Structure dump of a procedure.
Definition: SchemaReverse.qm.dox.h:586
SchemaReverse::AbstractReverseObject::name
string name()
SchemaReverse::FunctionReverse::constructor
constructor(AbstractDatasource ds, string name)
Definition: SchemaReverse.qm.dox.h:563
SchemaReverse::FunctionReverse
Structure dump of a function.
Definition: SchemaReverse.qm.dox.h:557
SchemaReverse::SequencesReverse::constructor
constructor(AbstractDatasource ds, string mask=".*")
Definition: SchemaReverse.qm.dox.h:352
SchemaReverse::PackagesReverse
Structure dump of packages.
Definition: SchemaReverse.qm.dox.h:631
SchemaReverse::AbstractReverseObject::toString
string toString()
Make a string with Qore code from a structure prepared by AbstractReverseObject::toQore().
SchemaReverse::TablesReverse::constructor
constructor(AbstractDatasource ds, string mask=".*")
Definition: SchemaReverse.qm.dox.h:420
SchemaReverse::MULTI_TO_CLASS
const MULTI_TO_CLASS
A map translating multi DB objects name into its class.
Definition: SchemaReverse.qm.dox.h:139
SchemaReverse::SequenceReverse
Structure dump of a sequence.
Definition: SchemaReverse.qm.dox.h:328
SchemaReverse::TableReverse
Structure dump of a table.
Definition: SchemaReverse.qm.dox.h:394
SchemaReverse::AbstractReverseObject
A basic class for all SchemaReverse DB object related classes.
Definition: SchemaReverse.qm.dox.h:285
hash
hash hash(object obj)
SchemaReverse::AbstractReverseObject::database
Database database()
SchemaReverse::MViewReverse::constructor
constructor(AbstractDatasource ds, string name)
Definition: SchemaReverse.qm.dox.h:537
SchemaReverse::FunctionsReverse::constructor
constructor(AbstractDatasource ds, string mask=".*")
Definition: SchemaReverse.qm.dox.h:579
SchemaReverse::ProceduresReverse
Structure dump of procedures.
Definition: SchemaReverse.qm.dox.h:602
SchemaReverse::TYPE_TO_CLASS
const TYPE_TO_CLASS
A map translating simple DB object name into its class.
Definition: SchemaReverse.qm.dox.h:127
SchemaReverse::TEMPLATE
const TEMPLATE
A template string for full schema used in SchemaReverse::SchemaReverse class.
Definition: SchemaReverse.qm.dox.h:151
SchemaReverse::MViewsReverse::constructor
constructor(AbstractDatasource ds, string mask=".*")
Definition: SchemaReverse.qm.dox.h:550