Store username/password in session cache

Compute UTM region before import wizard is displayed
p4#: 22351
This commit is contained in:
Magne Sjaastad
2013-09-08 10:53:25 +02:00
parent 00d9560885
commit f9112c458c
8 changed files with 81 additions and 49 deletions

View File

@@ -1654,3 +1654,26 @@ void RiaApplication::slotUpdateScheduledDisplayModels()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::setCacheDataObject(const QString& key, const QVariant& dataObject)
{
m_sessionCache[key] = dataObject;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QVariant RiaApplication::cacheDataObject(const QString& key) const
{
QMap<QString, QVariant>::const_iterator it = m_sessionCache.find(key);
if (it != m_sessionCache.end())
{
return it.value();
}
return QVariant();
}

View File

@@ -130,6 +130,9 @@ public:
QString commandLineParameterHelp() const;
void showFormattedTextInMessageBox(const QString& text);
void setCacheDataObject(const QString& key, const QVariant& dataObject);
QVariant cacheDataObject(const QString& key) const;
private:
void onProjectOpenedOrClosed();
void setWindowCaptionFromAppState();
@@ -163,4 +166,6 @@ private:
QString m_startupDefaultDirectory;
cvf::ref<cvf::Font> m_standardFont;
QMap<QString, QVariant> m_sessionCache; // Session cache used to store username/passwords per session
};

View File

@@ -435,9 +435,8 @@ RimOilField* RimProject::activeOilField()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::computeUtmAreaOfInterest(double* north, double* south, double* east, double* west)
void RimProject::computeUtmAreaOfInterest()
{
CVF_ASSERT(north && south && east && west);
std::vector<RimCase*> cases;
allCases(cases);
@@ -460,11 +459,18 @@ void RimProject::computeUtmAreaOfInterest(double* north, double* south, double*
if (projectBB.isValid())
{
*north = projectBB.max().y();
*south = projectBB.min().y();
double north, south, east, west;
*west = projectBB.min().x();
*east = projectBB.max().x();
north = projectBB.max().y();
south = projectBB.min().y();
west = projectBB.min().x();
east = projectBB.max().x();
wellPathImport->north = north;
wellPathImport->south = south;
wellPathImport->east = east;
wellPathImport->west = west;
}
}

View File

@@ -64,7 +64,7 @@ public:
void allCases(std::vector<RimCase*>& cases); // VL endre impl
void createDisplayModelAndRedrawAllViews(); // VL endre impl
void computeUtmAreaOfInterest(double* north, double* south, double* east, double* west);
void computeUtmAreaOfInterest();
RimOilField* activeOilField();

View File

@@ -1609,6 +1609,9 @@ void RiuMainWindow::slotImportWellPathsFromSSIHub()
return;
}
// Update the UTM bounding box from the reservoir
app->project()->computeUtmAreaOfInterest();
QString wellPathsFolderPath;
QString projectFileName = app->project()->fileName();
QFileInfo fileInfo(projectFileName);
@@ -1624,6 +1627,15 @@ void RiuMainWindow::slotImportWellPathsFromSSIHub()
RimWellPathImport* copyOfWellPathImport = dynamic_cast<RimWellPathImport*>(app->project()->wellPathImport->deepCopy());
RiuWellImportWizard wellImportwizard(app->preferences()->ssihubAddress, wellPathsFolderPath, copyOfWellPathImport, this);
// Get password/username from application cache
{
QString ssihubUsername = app->cacheDataObject("ssihub_username").toString();
QString ssihubPassword = app->cacheDataObject("ssihub_password").toString();
wellImportwizard.setCredentials(ssihubUsername, ssihubPassword);
}
if (QDialog::Accepted == wellImportwizard.exec())
{
QStringList wellPaths = wellImportwizard.absoluteFilePathsToWellPaths();
@@ -1634,6 +1646,9 @@ void RiuMainWindow::slotImportWellPathsFromSSIHub()
}
app->project()->wellPathImport = copyOfWellPathImport;
app->setCacheDataObject("ssihub_username", wellImportwizard.field("username"));
app->setCacheDataObject("ssihub_password", wellImportwizard.field("password"));
}
}

View File

@@ -142,6 +142,8 @@ void RimWellPathImport::updateRegions(const QStringList& regionStrings, const QS
oilRegionEntry->fields.push_back(oilFieldEntry);
}
}
updateFieldVisibility();
}
//--------------------------------------------------------------------------------------------------
@@ -157,20 +159,20 @@ void RimWellPathImport::initAfterRead()
//--------------------------------------------------------------------------------------------------
void RimWellPathImport::updateFieldVisibility()
{
if (utmFilterMode == UTM_FILTER_OFF)
{
north.setUiReadOnly(true);
south.setUiReadOnly(true);
east.setUiReadOnly(true);
west.setUiReadOnly(true);
}
else
if (utmFilterMode == UTM_FILTER_CUSTOM)
{
north.setUiReadOnly(false);
south.setUiReadOnly(false);
east.setUiReadOnly(false);
west.setUiReadOnly(false);
}
else
{
north.setUiReadOnly(true);
south.setUiReadOnly(true);
east.setUiReadOnly(true);
west.setUiReadOnly(true);
}
}
//--------------------------------------------------------------------------------------------------

View File

@@ -68,30 +68,6 @@ RiuWellImportWizard::RiuWellImportWizard(const QString& webServiceAddress, const
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellImportWizard::setWebServiceAddress(const QString& wsAddress)
{
m_webServiceAddress = wsAddress;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellImportWizard::setJsonDestinationFolder(const QString& folder)
{
m_destinationFolder = folder;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellImportWizard::setWellPathImportObject(RimWellPathImport* wellPathImportObject)
{
m_wellPathImportObject = wellPathImportObject;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -722,6 +698,16 @@ void RiuWellImportWizard::parseWellsResponse(RimOilFieldEntry* oilFieldEntry)
wellSelectionPage->expandAllTreeNodes();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellImportWizard::setCredentials(const QString& username, const QString& password)
{
// Set the initial value of the fields defined in the Authorization page
setField("username", username);
setField("password", password);
}
@@ -747,8 +733,8 @@ AuthenticationPage::AuthenticationPage(const QString& webServiceAddress, QWidget
QFormLayout* formLayout = new QFormLayout;
layout->addLayout(formLayout);
QLineEdit* usernameLineEdit = new QLineEdit("admin", this);
QLineEdit* passwordlLineEdit = new QLineEdit("resinsight", this);
QLineEdit* usernameLineEdit = new QLineEdit("", this);
QLineEdit* passwordlLineEdit = new QLineEdit("", this);
passwordlLineEdit->setEchoMode(QLineEdit::Password);
formLayout->addRow("&Username:", usernameLineEdit);
@@ -953,7 +939,7 @@ void WellSummaryPage::updateSummaryPage()
}
else
{
errorString += QString("Failed to get file %1 from well %2\n").arg(oilField->wells[wIdx]->wellPathFilePath).arg(oilField->wells[wIdx]->name);
errorString += QString("Failed to get file '%1' from well '%2'\n").arg(oilField->wells[wIdx]->wellPathFilePath).arg(oilField->wells[wIdx]->name);
}
m_objectGroup->objects.push_back(wellPathEntry);
@@ -964,7 +950,7 @@ void WellSummaryPage::updateSummaryPage()
}
m_textEdit->setText(QString("Downloaded successfully %1 well paths. Please push 'Finish' button to import well paths into ResInsight.\n\n").arg(wellPathCount));
m_textEdit->setText(QString("Downloaded successfully %1 well paths.\nPlease push 'Finish' button to import well paths into ResInsight.\n\n").arg(wellPathCount));
if (!errorString.isEmpty())
{
m_textEdit->append("Detected following errors during well path download. See details below.");

View File

@@ -143,13 +143,9 @@ public:
public:
RiuWellImportWizard(const QString& webServiceAddress, const QString& downloadFolder, RimWellPathImport* wellPathImportObject, QWidget *parent = 0);
void setWebServiceAddress(const QString& wsAdress);
void setJsonDestinationFolder(const QString& folder);
void setWellPathImportObject(RimWellPathImport* wellPathImportObject);
void setCredentials(const QString& username, const QString& password);
QStringList absoluteFilePathsToWellPaths() const;
// Methods used from the wizard pages
caf::PdmObjectGroup* wellCollection();
void resetAuthenticationCount();
@@ -192,7 +188,6 @@ private:
QString getValue(const QString& key, const QString& stringContent);
private:
QString m_webServiceAddress;
QString m_destinationFolder;