1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
/*
# PostgreSQL Database Modeler (pgModeler)
#
# (c) Copyright 2006-2026 - Raphael Araújo e Silva <raphael@pgmodeler.io>
#
# DEVELOPMENT, MAINTENANCE AND COMMERCIAL DISTRIBUTION BY:
# Nullptr Labs Software e Tecnologia LTDA <contact@nullptrlabs.io>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# The complete text of GPLv3 is at LICENSE file on source code root directory.
# Also, you can get the complete GNU General Public License at <http://www.gnu.org/licenses/>
*/
#include "foreignserver.h"
ForeignServer::ForeignServer() : BaseObject()
{
obj_type = ObjectType::ForeignServer;
fdata_wrapper = nullptr;
attributes[Attributes::Options] = "";
attributes[Attributes::Version] = "";
attributes[Attributes::Type] = "";
attributes[Attributes::Object] = "";
}
void ForeignServer::setType(const QString &type)
{
this->type = type;
}
void ForeignServer::setVersion(const QString &version)
{
this->version = version;
}
void ForeignServer::setForeignDataWrapper(ForeignDataWrapper *fdw)
{
fdata_wrapper = fdw;
}
QString ForeignServer::getType()
{
return type;
}
QString ForeignServer::getVersion()
{
return version;
}
ForeignDataWrapper *ForeignServer::getForeignDataWrapper()
{
return fdata_wrapper;
}
QString ForeignServer::getSourceCode(SchemaParser::CodeType def_type)
{
return getSourceCode(def_type, false);
}
QString ForeignServer::getSourceCode(SchemaParser::CodeType def_type, bool reduced_form)
{
QString code_def=getCachedCode(def_type, reduced_form);
if(!code_def.isEmpty()) return code_def;
attributes[Attributes::Version] = version;
attributes[Attributes::Type] = type;
attributes[Attributes::Fdw] = "";
if(fdata_wrapper)
{
if(def_type == SchemaParser::SqlCode)
attributes[Attributes::Fdw] = fdata_wrapper->getName(true);
else
attributes[Attributes::Fdw] = fdata_wrapper->getSourceCode(def_type, true);
}
attributes[Attributes::Options] = getOptionsAttribute(def_type);
return this->BaseObject::getSourceCode(def_type, reduced_form);
}
QString ForeignServer::getAlterCode(BaseObject *object)
{
try
{
ForeignServer *server=dynamic_cast<ForeignServer *>(object);
attribs_map attribs;
attributes[Attributes::AlterCmds] = BaseObject::getAlterCode(server);
getAlteredAttributes(server, attribs);
if(this->version != server->version)
attribs[Attributes::Version] = server->version;
copyAttributes(attribs);
return BaseObject::getAlterCode(this->getSchemaName(), attributes, false, true);
}
catch(Exception &e)
{
throw Exception(e.getErrorMessage(),e.getErrorCode(),__PRETTY_FUNCTION__,__FILE__,__LINE__,&e);
}
}
void ForeignServer::updateDependencies()
{
BaseObject::updateDependencies({ fdata_wrapper });
}
|