Author: andreas
Date: 2005-06-19 21:39:42 +0100 (Sun, 19 Jun 2005)
New Revision: 4318

Modified:
   trunk/pgadmin3/CHANGELOG.txt
   trunk/pgadmin3/src/agent/dlgSchedule.cpp
   trunk/pgadmin3/src/agent/dlgStep.cpp
   trunk/pgadmin3/src/agent/include/pgaJob.h
   trunk/pgadmin3/src/agent/pgaJob.cpp
   trunk/pgadmin3/src/agent/pgaSchedule.cpp
   trunk/pgadmin3/src/agent/pgaStep.cpp
   trunk/pgadmin3/src/dlg/dlgDatabase.cpp
   trunk/pgadmin3/src/dlg/dlgProperty.cpp
   trunk/pgadmin3/src/schema/pgCollection.cpp
   trunk/pgadmin3/src/schema/pgDatabase.cpp
   trunk/pgadmin3/src/schema/pgObject.cpp
   trunk/pgadmin3/src/schema/pgServer.cpp
Log:
pgAgent moved under server, some more fixes

Modified: trunk/pgadmin3/CHANGELOG.txt
===================================================================
--- trunk/pgadmin3/CHANGELOG.txt        2005-06-19 12:25:24 UTC (rev 4317)
+++ trunk/pgadmin3/CHANGELOG.txt        2005-06-19 20:39:42 UTC (rev 4318)
@@ -17,6 +17,7 @@
 </ul>
 <br>
 <ul>
+    <li>2005-06-19 AP        pgAgent moved under server, some more fixes
     <li>2005-06-19 AP        further translation issues
     <li>2005-06-17 AP        reduce translation nightmare
     <li>2005-06-17 AP        use wxDatePickCtrl for wxCalendarBox

Modified: trunk/pgadmin3/src/agent/dlgSchedule.cpp
===================================================================
--- trunk/pgadmin3/src/agent/dlgSchedule.cpp    2005-06-19 12:25:24 UTC (rev 
4317)
+++ trunk/pgadmin3/src/agent/dlgSchedule.cpp    2005-06-19 20:39:42 UTC (rev 
4318)
@@ -588,7 +588,7 @@
                                newTime = wxT("'") + 
tmpDateTime.FormatISOTime() + wxT("'");
                        }
 
-                       sql += wxT("INSERT INTO pgagent.pga_exception 
(jexschid, jexdate, jextime)\n  VALUES (") 
+                       sql += wxT("INSERT INTO pgagent.pga_exception (jexscid, 
jexdate, jextime)\n  VALUES (") 
                                + NumToStr(recId) + wxT(", ") + newDate + 
wxT(", ") + newTime + wxT(");\n");
 
                }

Modified: trunk/pgadmin3/src/agent/dlgStep.cpp
===================================================================
--- trunk/pgadmin3/src/agent/dlgStep.cpp        2005-06-19 12:25:24 UTC (rev 
4317)
+++ trunk/pgadmin3/src/agent/dlgStep.cpp        2005-06-19 20:39:42 UTC (rev 
4318)
@@ -174,10 +174,7 @@
         else
             jstjobid = wxT("<JobId>");
 
-        if (!cbDatabase->GetSelection())
-            db = wxT("NULL");
-        else
-            db = qtString(cbDatabase->GetValue());
+        db = qtString(cbDatabase->GetValue());
 
         sql = wxT("INSERT INTO pgagent.pga_jobstep (jstid, jstjobid, jstname, 
jstdesc, jstenabled, jstkind, jstonerror, jstcode, jstdbname)\n")
               wxT("SELECT <StpId>, ") + jstjobid + wxT(", ") + qtString(name) 
+ wxT(", ") + qtString(txtComment->GetValue()) + wxT(", ")

Modified: trunk/pgadmin3/src/agent/include/pgaJob.h
===================================================================
--- trunk/pgadmin3/src/agent/include/pgaJob.h   2005-06-19 12:25:24 UTC (rev 
4317)
+++ trunk/pgadmin3/src/agent/include/pgaJob.h   2005-06-19 20:39:42 UTC (rev 
4318)
@@ -22,7 +22,7 @@
 // Class declarations
 
 
-class pgaJob : public pgDatabaseObject
+class pgaJob : public pgServerObject
 {
 public:
     pgaJob(const wxString& newName = wxT(""));
@@ -73,7 +73,7 @@
 };
 
 
-class pgaJobObject : public pgDatabaseObject
+class pgaJobObject : public pgServerObject
 {
 public:
     pgaJobObject(pgaJob *job, int newType, const wxString& newName);

Modified: trunk/pgadmin3/src/agent/pgaJob.cpp
===================================================================
--- trunk/pgadmin3/src/agent/pgaJob.cpp 2005-06-19 12:25:24 UTC (rev 4317)
+++ trunk/pgadmin3/src/agent/pgaJob.cpp 2005-06-19 20:39:42 UTC (rev 4318)
@@ -25,7 +25,7 @@
 extern sysSettings *settings;
 
 pgaJob::pgaJob(const wxString& newName)
-: pgDatabaseObject(PGA_JOB, newName)
+: pgServerObject(PGA_JOB, newName)
 {
     wxLogInfo(wxT("Creating a pgaJob object"));
 }
@@ -50,7 +50,7 @@
 
 bool pgaJob::DropObject(wxFrame *frame, wxTreeCtrl *browser, bool cascaded)
 {
-    return GetDatabase()->ExecuteVoid(wxT("DELETE FROM pgagent.pga_job WHERE 
jobid=") + NumToStr(GetRecId()));
+    return GetConnection()->ExecuteVoid(wxT("DELETE FROM pgagent.pga_job WHERE 
jobid=") + NumToStr(GetRecId()));
 }
 
 
@@ -120,7 +120,7 @@
 {
     pgaJob *job=0;
 
-    pgSet *jobs= collection->GetDatabase()->ExecuteSet(
+    pgSet *jobs= collection->GetConnection()->ExecuteSet(
        wxT("SELECT *, ")
           wxT("(SELECT jlgstatus FROM pgagent.pga_joblog jl WHERE jl.jlgjobid 
= j.jobid ORDER BY jlgid DESC LIMIT 1) AS joblastresult ")
           wxT("FROM pgagent.pga_job j\n")
@@ -148,8 +148,8 @@
                 status = _("Unknown");
 
             job = new pgaJob(jobs->GetVal(wxT("jobname")));
+            job->iSetServer(collection->GetServer());
             job->iSetRecId(jobs->GetLong(wxT("jobid")));
-            job->iSetDatabase(collection->GetDatabase());
             job->iSetComment(jobs->GetVal(wxT("jobdesc")));
 
             job->iSetEnabled(jobs->GetBool(wxT("jobenabled")));
@@ -201,7 +201,7 @@
                statistics->AddColumn(_("End time"), 95);
                statistics->AddColumn(_("Duration"), 70);
 
-        pgSet *stats = database->ExecuteSet(sql);
+        pgSet *stats = GetConnection()->ExecuteSet(sql);
                wxString status;
                wxDateTime startTime;
                wxDateTime endTime;
@@ -239,8 +239,9 @@
 }
 
 pgaJobObject::pgaJobObject(pgaJob *_job, int newType, const wxString& newName)
-: pgDatabaseObject(newType, newName)
+: pgServerObject(newType, newName)
 {
     job=_job;
+    server=job->GetServer();
 }
 

Modified: trunk/pgadmin3/src/agent/pgaSchedule.cpp
===================================================================
--- trunk/pgadmin3/src/agent/pgaSchedule.cpp    2005-06-19 12:25:24 UTC (rev 
4317)
+++ trunk/pgadmin3/src/agent/pgaSchedule.cpp    2005-06-19 20:39:42 UTC (rev 
4318)
@@ -39,7 +39,7 @@
 
 bool pgaSchedule::DropObject(wxFrame *frame, wxTreeCtrl *browser, bool 
cascaded)
 {
-    return GetDatabase()->ExecuteVoid(wxT("DELETE FROM pgagent.pga_schedule 
WHERE jscid=") + NumToStr(GetRecId()));
+    return GetConnection()->ExecuteVoid(wxT("DELETE FROM pgagent.pga_schedule 
WHERE jscid=") + NumToStr(GetRecId()));
 }
 
 
@@ -93,7 +93,7 @@
     pgaSchedule *schedule=0;
        wxString tmp;
 
-    pgSet *schedules= collection->GetDatabase()->ExecuteSet(
+    pgSet *schedules= collection->GetConnection()->ExecuteSet(
        wxT("SELECT * FROM pgagent.pga_schedule\n")
        wxT(" WHERE jscjobid=") + NumToStr(collection->GetJob()->GetRecId()) + 
wxT("\n")
        + restriction +
@@ -106,7 +106,6 @@
 
             schedule = new pgaSchedule(collection, 
schedules->GetVal(wxT("jscname")));
             schedule->iSetRecId(schedules->GetLong(wxT("jscid")));
-            schedule->iSetDatabase(collection->GetDatabase());
             schedule->iSetStart(schedules->GetDateTime(wxT("jscstart")));
             schedule->iSetEnd(schedules->GetDateTime(wxT("jscend")));
 
@@ -142,7 +141,7 @@
 
             schedule->iSetComment(schedules->GetVal(wxT("jscdesc")));
 
-                       pgSet *exceptions =  
collection->GetDatabase()->ExecuteSet(
+                       pgSet *exceptions =  
collection->GetConnection()->ExecuteSet(
                                wxT("SELECT * FROM pgagent.pga_exception\n")
                                wxT(" WHERE jexscid=") + 
NumToStr(schedule->GetRecId()) + wxT("\n"));
        

Modified: trunk/pgadmin3/src/agent/pgaStep.cpp
===================================================================
--- trunk/pgadmin3/src/agent/pgaStep.cpp        2005-06-19 12:25:24 UTC (rev 
4317)
+++ trunk/pgadmin3/src/agent/pgaStep.cpp        2005-06-19 20:39:42 UTC (rev 
4318)
@@ -38,7 +38,7 @@
 
 bool pgaStep::DropObject(wxFrame *frame, wxTreeCtrl *browser, bool cascaded)
 {
-    return GetDatabase()->ExecuteVoid(wxT("DELETE FROM pgagent.pga_jobstep 
WHERE jstid=") + NumToStr(GetRecId()));
+    return GetConnection()->ExecuteVoid(wxT("DELETE FROM pgagent.pga_jobstep 
WHERE jstid=") + NumToStr(GetRecId()));
 }
 
 
@@ -86,7 +86,7 @@
 {
     pgaStep *step=0;
 
-    pgSet *steps= collection->GetDatabase()->ExecuteSet(
+    pgSet *steps= collection->GetConnection()->ExecuteSet(
        wxT("SELECT * FROM pgagent.pga_jobstep\n")
        wxT(" WHERE jstjobid=") + NumToStr(collection->GetJob()->GetRecId()) + 
wxT("\n")
        + restriction +
@@ -99,7 +99,6 @@
 
             step = new pgaStep(collection, steps->GetVal(wxT("jstname")));
             step->iSetRecId(steps->GetLong(wxT("jstid")));
-            step->iSetDatabase(collection->GetDatabase());
             step->iSetDbname(steps->GetVal(wxT("jstdbname")));
             step->iSetCode(steps->GetVal(wxT("jstcode")));
             step->iSetEnabled(steps->GetBool(wxT("jstenabled")));
@@ -174,7 +173,7 @@
                statistics->AddColumn(_("Duration"), 70);
                statistics->AddColumn(_("Output"), 200);
 
-        pgSet *stats = database->ExecuteSet(sql);
+        pgSet *stats = GetConnection()->ExecuteSet(sql);
                wxString status;
                wxDateTime startTime;
                wxDateTime endTime;

Modified: trunk/pgadmin3/src/dlg/dlgDatabase.cpp
===================================================================
--- trunk/pgadmin3/src/dlg/dlgDatabase.cpp      2005-06-19 12:25:24 UTC (rev 
4317)
+++ trunk/pgadmin3/src/dlg/dlgDatabase.cpp      2005-06-19 20:39:42 UTC (rev 
4318)
@@ -183,6 +183,8 @@
 
 #if wxUSE_UNICODE
         encNo=cbEncoding->FindString(wxT("UNICODE"));
+        if (encNo < 0)
+            encNo=cbEncoding->FindString(wxT("UTF8"));
 #else
         encNo=cbEncoding->FindString(wxT("SQL_ASCII"));
 #endif

Modified: trunk/pgadmin3/src/dlg/dlgProperty.cpp
===================================================================
--- trunk/pgadmin3/src/dlg/dlgProperty.cpp      2005-06-19 12:25:24 UTC (rev 
4317)
+++ trunk/pgadmin3/src/dlg/dlgProperty.cpp      2005-06-19 20:39:42 UTC (rev 
4318)
@@ -1320,33 +1320,25 @@
                long jobId=0, schId=0, stpId=0;
                if (sql.Contains(wxT("<JobId>")))
                {
-                       jobId=StrToLong(connection->ExecuteScalar(wxT("SELECT 
nextval('pgagent.pga_job_jobid_seq');")));
+                       recId = 
jobId=StrToLong(connection->ExecuteScalar(wxT("SELECT 
nextval('pgagent.pga_job_jobid_seq');")));
             while ((pos=sql.Find(wxT("<JobId>"))) >= 0)
                 sql = sql.Left(pos) + NumToStr(jobId) + sql.Mid(pos+7);
                }
                
                if (sql.Contains(wxT("<SchId>")))
                {
-                       schId=StrToLong(connection->ExecuteScalar(wxT("SELECT 
nextval('pgagent.pga_schedule_jscid_seq');")));
+                       recId = 
schId=StrToLong(connection->ExecuteScalar(wxT("SELECT 
nextval('pgagent.pga_schedule_jscid_seq');")));
                        while ((pos=sql.Find(wxT("<SchId>"))) >= 0)
                 sql = sql.Left(pos) + NumToStr(schId) + sql.Mid(pos+7);
                }
 
                if (sql.Contains(wxT("<StpId>")))
                {
-                       stpId=StrToLong(connection->ExecuteScalar(wxT("SELECT 
nextval('pgagent.pga_jobstep_jstid_seq');")));
+                       recId = 
stpId=StrToLong(connection->ExecuteScalar(wxT("SELECT 
nextval('pgagent.pga_jobstep_jstid_seq');")));
                        while ((pos=sql.Find(wxT("<StpId>"))) >= 0)
                 sql = sql.Left(pos) + NumToStr(stpId) + sql.Mid(pos+7);
                }
 
-               // OK, so what are we inserting? We need to set recId 
appropriately.
-               if (sql.StartsWith(wxT("INSERT INTO pgagent.pga_job")))
-                       recId = jobId;
-               else if (sql.StartsWith(wxT("INSERT INTO 
pgagent.pga_schedule")))
-                       recId = schId;
-               else if (sql.StartsWith(wxT("INSERT INTO pgagent.pga_jobstep")))
-                       recId = stpId;
-
         pgSet *set=connection->ExecuteSet(sql);
         if (set)
         {

Modified: trunk/pgadmin3/src/schema/pgCollection.cpp
===================================================================
--- trunk/pgadmin3/src/schema/pgCollection.cpp  2005-06-19 12:25:24 UTC (rev 
4317)
+++ trunk/pgadmin3/src/schema/pgCollection.cpp  2005-06-19 20:39:42 UTC (rev 
4318)
@@ -81,8 +81,8 @@
     wxLogInfo(wxT("Creating a pgCollection object")); 
        job = jb;
     schema=0;
-    database = job->GetDatabase();
-    server= database->GetServer();
+    server= job->GetServer();
+    database = server->GetDatabase();
 }
 
 pgCollection::~pgCollection()

Modified: trunk/pgadmin3/src/schema/pgDatabase.cpp
===================================================================
--- trunk/pgadmin3/src/schema/pgDatabase.cpp    2005-06-19 12:25:24 UTC (rev 
4317)
+++ trunk/pgadmin3/src/schema/pgDatabase.cpp    2005-06-19 20:39:42 UTC (rev 
4318)
@@ -324,18 +324,6 @@
             collection = new pgCollection(PG_SCHEMAS, this);
             AppendBrowserItem(browser, collection);
 
-            // Jobs
-                       // We only add the Jobs node if the appropriate objects 
are in this DB.
-                   wxString exists = ExecuteScalar(
-                               wxT("SELECT cl.oid FROM pg_class cl JOIN 
pg_namespace ns ON ns.oid=relnamespace\n")
-                               wxT(" WHERE relname='pga_job' AND 
nspname='pgagent'"));
-
-                       if (!exists.IsNull())
-                       {
-                               collection = new pgCollection(PGA_JOBS, this);
-                   AppendBrowserItem(browser, collection);
-                       }
-
             // Slony-I Clusters
             collection = new pgCollection(SL_CLUSTERS, this);
             AppendBrowserItem(browser, collection);

Modified: trunk/pgadmin3/src/schema/pgObject.cpp
===================================================================
--- trunk/pgadmin3/src/schema/pgObject.cpp      2005-06-19 12:25:24 UTC (rev 
4317)
+++ trunk/pgadmin3/src/schema/pgObject.cpp      2005-06-19 20:39:42 UTC (rev 
4318)
@@ -616,29 +616,41 @@
 
 pgConn *pgObject::GetConnection() const
 {
-    pgConn *conn=0;
-    pgDatabase *db;
+    // in some cases, virtualization doesn't work so we need to mimic it here
+    pgDatabase *db=GetDatabase();
+    pgServer *server=0;
     switch (type)
     {
         case PG_SERVER:
-            conn=((pgServer*)this)->connection();
+            server = (pgServer*)this;
             break;
         case PG_DATABASES:
-        case PG_USER:
+        case PG_TABLESPACES:
+        case PG_GROUPS:
         case PG_USERS:
+        case PGA_JOBS:
+        case PGA_STEPS:
+        case PGA_SCHEDULES:
+            server = ((pgCollection*)this)->GetServer();
+            break;
+        case PG_DATABASE:
+        case PG_TABLESPACE:
         case PG_GROUP:
-        case PG_GROUPS:
-        case PG_TABLESPACES:
-        case PG_TABLESPACE:
-            conn=((pgServerObject*)this)->GetServer()->connection();
+        case PG_USER:
+        case PGA_JOB:
+        case PGA_STEP:
+        case PGA_SCHEDULE:
+            server = ((pgServerObject*)this)->GetServer();
             break;
         default:
-            db=GetDatabase();
-            if (db)
-                conn=db->connection();
             break;
     }
-    return conn;    
+
+    if (db)
+        return db->connection();
+    if (server)
+        return server->connection();
+    return 0;
 }
 
 

Modified: trunk/pgadmin3/src/schema/pgServer.cpp
===================================================================
--- trunk/pgadmin3/src/schema/pgServer.cpp      2005-06-19 12:25:24 UTC (rev 
4317)
+++ trunk/pgadmin3/src/schema/pgServer.cpp      2005-06-19 20:39:42 UTC (rev 
4318)
@@ -619,6 +619,17 @@
                 collection = new pgCollection(PG_TABLESPACES, this);
                 AppendBrowserItem(browser, collection);
             }
+            // Jobs
+                       // We only add the Jobs node if the appropriate objects 
are the initial DB.
+                   wxString exists = conn->ExecuteScalar(
+                               wxT("SELECT cl.oid FROM pg_class cl JOIN 
pg_namespace ns ON ns.oid=relnamespace\n")
+                               wxT(" WHERE relname='pga_job' AND 
nspname='pgagent'"));
+
+                       if (!exists.IsNull())
+                       {
+                               collection = new pgCollection(PGA_JOBS, this);
+                   AppendBrowserItem(browser, collection);
+                       }
             // Groups
             collection = new pgCollection(PG_GROUPS, this);
             AppendBrowserItem(browser, collection);


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to