void toResultExtent::query(const QString &sql, const toQList ¶ms) { try { if (!handled()) return ; if (!setSQLParams(sql, params)) return ; toQList::const_iterator i = params.begin(); if (i == params.end()) return ; QString owner = (*i); i++; if (i == params.end()) return ; QString table = (*i); List->changeParams(owner, table); toQList res = toQuery::readQueryNull(connection(), SQLTableTablespace, owner, table); Graph->setTablespace(toShift(res)); Graph->highlight(owner, table, QString::null); } TOCATCH }
void toMain::displayMessage ( void ) { static bool recursive = false; if ( recursive ) return; recursive = true; for ( QString str = toShift ( StatusMessages );!str.isEmpty();str = toShift ( StatusMessages ) ) { toMessageUI dialog ( toMainWidget(), NULL, true ); dialog.Message->setText ( str ); dialog.exec(); if ( dialog.Statusbar->isChecked() ) { toTool::globalSetConfig ( CONF_MESSAGE_STATUSBAR, "Yes" ); TOMessageBox::information ( toMainWidget(), "Information", "You can enable this through the Global Settings in the Options (Edit menu)" ); toTool::saveConfig(); } } recursive = false; }
void toProfiler::changeRun(void) { QString t = Run->currentText(); int pos = t.indexOf(QString::fromLatin1("(")); if (pos < 0) pos = t.indexOf(QString::fromLatin1(":")); if (pos >= 0) CurrentRun = t.mid(0, pos).toInt(); QString run = QString::number(CurrentRun); try { toQList vals = toQuery::readQuery(connection(), SQLTotalTime, run); Units->setTotal(toShift(vals).toDouble()); Units->changeParams(run); Info->changeParams(run); } TOCATCH }
/*********************************************************************************** Purpose: Alter existing table ************************************************************************************/ QString toOracleExtract::alterTable(std::list<QString> &source, std::list<QString> &destin) const { std::list<QString> drop; // will hold table properties being removed std::list<QString> create; // will hold table properties being added toExtract::srcDst2DropCreate(source, destin, drop, create); QString statements; QString context = ""; QString table_name; QString new_table_name; QString column_name = "", column_type; QString tmp, tmp1; QString end_statements; // statements to be added to the end QString operation; // used to differentiate between add and modify column QString not_null; bool add_modify_column = false; // drop statements for (std::list<QString>::iterator i = drop.begin(); i != drop.end(); i++) { #ifdef DEBUG qDebug() << "drop>>" + *i; #endif table_name = toExtract::partDescribe(*i, 2); if (!SameContext(*i, context)) { if (context != "") { if (column_name != "") // check if property is not mentioned in create list, // if it is, this is not dropping of column but rather renaming if (!propertyMentioned(destin, "COLUMN", column_name)) statements += ("alter table " + table_name + " drop column " + column_name + ";\n"); column_name = ""; } context = toExtract::contextDescribe(*i, 5); } std::list<QString> row = toExtract::splitDescribe(*i); // read through "context" - skip general tablename information for (int j = 0; j < 3; j++) toShift(row); tmp = toShift(row); if (tmp == "COLUMN") { column_name = toShift(row); tmp = toShift(row); if (tmp.isNull()) { // nothing to be done here, column name was defined } else if (tmp == "ORDER") { // nothing to do with ORDER } else if (tmp == "COMMENT") { if (propertyMentioned(destin, "COLUMN", column_name)) // if column is not dropped... if (!propertyMentioned(destin, column_name, "COMMENT")) // ...and comment is not changed // then drop comment statements += ("comment on column " + table_name + "." + column_name + " is '';\n"); } else if (tmp == "EXTRA") { if (propertyMentioned(destin, "COLUMN", column_name)) // if column does not have to be dropped - just remove "not null" flag statements += ("alter table " + table_name + " modify (" + column_name + " null);\n"); } else { // nothing to do with column type } } else if (tmp == "PARAMETERS") { // TODO Check if anything should/could be done with parameters being dropped tmp = toExtract::partDescribe(*i, 4); #ifdef DEBUG qDebug() << "Dropping parameters is NOT currently supported (" + tmp + ")."; #endif } else if (tmp == "STORAGE") { // TODO Check if anything should/could be done with sotrage attributes being dropped tmp = toExtract::partDescribe(*i, 4); #ifdef DEBUG qDebug() << "Dropping storage attributes is NOT currently supported (" + tmp + ")."; #endif } else { throw qApp->translate("toExtract", "Unkown string %1 for drop statements").arg(tmp); } } if (column_name != "") if (!propertyMentioned(destin, "COLUMN", column_name)) statements += ("alter table " + table_name + " drop column " + column_name + ";\n"); // add/modify/rename statements column_name = ""; context = ""; for (std::list<QString>::iterator i = create.begin(); i != create.end(); i++) { #ifdef DEBUG qDebug() << "add>>" + *i; #endif table_name = toExtract::partDescribe(*i, 2); tmp = toExtract::partDescribe(*i, 5); if (!SameContext(*i, context)) { if (context != "") { if (add_modify_column) { if (propertyMentioned(source, "COLUMN", column_name)) { operation = "modify"; if (defaultValueRemoved(drop, column_name, column_type)) column_type += " default null"; // Note! It is not possible to remove default value in Oracle!!! } else { operation = "add"; } statements += ("alter table " + table_name + " " + operation + " (" + column_name + " " + column_type + not_null + ");\n"); add_modify_column = false; } column_name == ""; } context = toExtract::contextDescribe(*i, 5); not_null = ""; } std::list<QString> row = toExtract::splitDescribe(*i); // read through "context" - skip general tablename information for (int j = 0; j < 3; j++) toShift(row); tmp = toShift(row); if (tmp == "COLUMN") { column_name = toShift(row); tmp = toShift(row); // value AFTER column name if (tmp.isNull()) { column_name = tmp1; } else if (tmp == "RENAME") { tmp = toShift(row); statements += ("alter table " + table_name + " rename column " + column_name + " to " + tmp + ";\n"); } else if (tmp == "ORDER") { // nothing to do with ORDER } else if (tmp == "COMMENT") { tmp = toShift(row); end_statements += ("comment on column " + table_name + "." + column_name + " is '" + tmp + "';\n"); } else if (tmp == "EXTRA") { not_null = " NOT NULL"; // set "not null" flag on column add_modify_column = true; } else { column_type = tmp; add_modify_column = true; } } else if (tmp == "RENAME") // rename table { new_table_name = toShift(row); } else { throw qApp->translate("toExtract", "Unkown string %1 for alter/add statements.").arg(tmp); } } if (add_modify_column) { if (propertyMentioned(source, "COLUMN", column_name)) { operation = "modify"; if (defaultValueRemoved(drop, column_name, column_type)) column_type += " default null"; // Note! It is not possible to remove default value in Oracle!!! } else { operation = "add"; } statements += ("alter table " + table_name + " " + operation + " (" + column_name + " " + column_type + not_null + ");\n"); } if (!new_table_name.isNull()) statements += ("alter table " + table_name + " rename to " + new_table_name + ";"); return statements + end_statements; } // alterTable
ServicePointer Edge::getPreviousService(const AccessParameters& accessParameters, ptime arrivalMoment, const ptime& minArrivalMoment, bool checkIfTheServiceIsReachable, optional<ArrivalServiceIndex::Value>& maxPreviousServiceIndex, bool inverted, bool ignoreReservation, bool allowCanceled, bool enableTheoretical, bool enableRealTime ) const { boost::shared_lock<util::shared_recursive_mutex> sharedServicesLock( *getParentPath()->sharedServicesMutex ); const ServiceSet& services(getParentPath()->getServices()); if(services.empty()) { return ServicePointer(); } bool RTData(enableRealTime && arrivalMoment < posix_time::second_clock().local_time() + posix_time::hours(23)); ArrivalServiceIndex::Value previous(getArrivalFromIndex(RTData, arrivalMoment.time_of_day().hours())); if( maxPreviousServiceIndex && (*maxPreviousServiceIndex == services.rend() || services.value_comp()(**maxPreviousServiceIndex, *previous)) ){ previous = *maxPreviousServiceIndex; } while ( arrivalMoment >= minArrivalMoment ) // Loop over dates { if( getParentPath()->isActive(arrivalMoment.date())) { for (; previous != services.rend(); ++previous) // Loop over services { // Saving of the used service ServicePointer servicePointer( (*previous)->getFromPresenceTime( accessParameters, enableTheoretical, RTData, false, *this, arrivalMoment, checkIfTheServiceIsReachable, inverted, ignoreReservation, allowCanceled ) ); if (!servicePointer.getService()) continue; // Check of validity of departure date time if (servicePointer.getArrivalDateTime() + servicePointer.getServiceRange() < minArrivalMoment) { return ServicePointer(); } // Limitation of the continuous service range at the specified bounds if(servicePointer.getArrivalDateTime() < minArrivalMoment) { time_duration toShift(minArrivalMoment - servicePointer.getArrivalDateTime()); servicePointer.shift(toShift); servicePointer.setServiceRange(servicePointer.getServiceRange() - toShift); } // Store service rank in edge maxPreviousServiceIndex = previous; // The service is now returned return servicePointer; } } arrivalMoment = ptime(arrivalMoment.date(), -seconds(1)); previous = _arrivalIndex[INDICES_NUMBER - 1].get(RTData); } return ServicePointer(); }
toAlert::toAlert(QWidget *main, toConnection &connection) : toToolWidget(AlertTool, "alert.html", main, connection, "toAlert") , Connection(connection) { QToolBar *toolbar = toAllocBar(this, tr("Alert Messenger")); layout()->addWidget(toolbar); QString def; try { toQList lst = toQuery::readQuery(connection, SQLHost); def += toShift(lst); if (!def.isEmpty()) def += QString::fromLatin1(":"); } catch (...) {} def += connection.user(); toolbar->addWidget( new QLabel(tr("Registered") + " ", toolbar)); Registered = new QComboBox(toolbar); Registered->addItem(def); Registered->setEditable(true); Registered->setDuplicatesEnabled(false); Registered->setCurrentIndex(0); connect(Registered, SIGNAL(activated(int)), this, SLOT(add())); toolbar->addWidget(Registered); AddNames.insert(AddNames.end(), def); addAct = toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(commit_xpm))), tr("Register current"), this, SLOT(add())); addAct->setShortcut(Qt::ALT + Qt::Key_R); removeAct = toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(trash_xpm))), tr("Remove registered"), this, SLOT(remove())); removeAct->setShortcut(Qt::CTRL + Qt::Key_Backspace); toolbar->addSeparator(); toolbar->addWidget( new QLabel(tr("Name") + " ", toolbar)); toolbar->addWidget( Name = new QLineEdit(toolbar)); Name->setText(def); connect(Name, SIGNAL(returnPressed()), this, SLOT(send())); toolbar->addWidget( new QLabel(tr("Message") + " ", toolbar)); Message = new QLineEdit(toolbar); connect(Message, SIGNAL(returnPressed()), this, SLOT(send())); Message->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum)); toolbar->addWidget(Message); memoEditAct = toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(toworksheet_xpm))), tr("Edit message in memo"), this, SLOT(memo())); memoEditAct->setShortcut(Qt::CTRL + Qt::Key_M); sendAct = toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(return_xpm))), tr("Send alert"), this, SLOT(send())); sendAct->setShortcut(Qt::CTRL + Qt::Key_Return); connect(&Timer, SIGNAL(timeout()), this, SLOT(poll())); Timer.start(TIMEOUT*1000); Alerts = new toListView(this); Alerts->addColumn(tr("Time")); Alerts->addColumn(tr("Name")); Alerts->addColumn(tr("Message")); layout()->addWidget(Alerts); ToolMenu = NULL; connect(toMainWidget()->workspace(), SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(windowActivated(QMdiSubWindow *))); State = Started; try { toThread *thread = new toThread(new pollTask(*this)); thread->start(); } catch (...) { toStatusMessage(tr("Failed to start polling thread, try closing " "some other tools and restart Alert Messenger")); } setFocusProxy(Message); }