Пример #1
0
vector<attribs_map> Catalog::getMultipleAttributes(ObjectType obj_type, attribs_map extra_attribs)
{
    try
    {
        ResultSet res;
        attribs_map tuple;
        vector<attribs_map> obj_attribs;

        executeCatalogQuery(QUERY_ATTRIBS, obj_type, res, false, extra_attribs);
        if(res.accessTuple(ResultSet::FIRST_TUPLE))
        {
            do
            {
                tuple=changeAttributeNames(res.getTupleValues());

                /* Insert the object type as an attribute of the query result to facilitate the
                import process on the classes that uses the Catalog */
                tuple[ParsersAttributes::OBJECT_TYPE]=QString("%1").arg(obj_type);

                obj_attribs.push_back(tuple);
                tuple.clear();
            }
            while(res.accessTuple(ResultSet::NEXT_TUPLE));
        }

        return(obj_attribs);
    }
    catch(Exception &e)
    {
        throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
    }
}
Пример #2
0
attribs_map Catalog::getAttributes(const QString &obj_name, ObjectType obj_type, attribs_map extra_attribs)
{
    try
    {
        ResultSet res;
        attribs_map obj_attribs;

        //Add the name of the object as extra attrib in order to retrieve the data only for it
        extra_attribs[ParsersAttributes::NAME]=obj_name;
        executeCatalogQuery(QUERY_ATTRIBS, obj_type, res, true, extra_attribs);

        if(res.accessTuple(ResultSet::FIRST_TUPLE))
            obj_attribs=changeAttributeNames(res.getTupleValues());

        /* Insert the object type as an attribute of the query result to facilitate the
        import process on the classes that uses the Catalog */
        obj_attribs[ParsersAttributes::OBJECT_TYPE]=QString("%1").arg(obj_type);

        return(obj_attribs);
    }
    catch(Exception &e)
    {
        throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
    }
}
Пример #3
0
void Catalog::setConnection(Connection &conn)
{
    try
    {
        ResultSet res;
        QStringList ext_obj;

        this->connection=conn;
        this->connection.connect();

        //Retrieving the last system oid
        executeCatalogQuery(QUERY_LIST, OBJ_DATABASE, res, true,
        {{ParsersAttributes::NAME, conn.getConnectionParam(Connection::PARAM_DB_NAME)}});

        if(res.accessTuple(ResultSet::FIRST_TUPLE))
        {
            attribs_map attribs=changeAttributeNames(res.getTupleValues());
            last_sys_oid=attribs[ParsersAttributes::LAST_SYS_OID].toUInt();
        }

        //Retrieving the list of objects created by extensions
        this->connection.executeDMLCommand("SELECT objid AS oid FROM pg_depend WHERE objid > 0 AND refobjid > 0 AND deptype='e'", res);
        if(res.accessTuple(ResultSet::FIRST_TUPLE))
        {
            do
            {
                ext_obj.push_back(res.getColumnValue("oid"));
            }
            while(res.accessTuple(ResultSet::NEXT_TUPLE));

            ext_obj_oids=ext_obj.join(",");
        }
    }
    catch(Exception &e)
    {
        throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
    }
}