Skip to content

Commit

Permalink
Fix broken merge. Refs #8126.
Browse files Browse the repository at this point in the history
- I had a problem with code being on develop that shouldn't have been. As a quick fix I have indented the related method in order to overwrite all changes.
  • Loading branch information
jawrainey committed Oct 22, 2013
1 parent 4e300dc commit 98fa154
Showing 1 changed file with 101 additions and 101 deletions.
202 changes: 101 additions & 101 deletions Code/Mantid/Framework/ICat/src/ICat4/ICat4Catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,131 +115,131 @@ namespace Mantid
*/
std::string ICat4Catalog::getSearchQuery(const CatalogSearchParam& inputs)
{
// This will hold strings for each table of the query. Each segment will be joined together (<->).
std::vector<std::string> querySegments;
// This will hold strings for each table of the query. Each segment will be joined together (<->).
std::vector<std::string> querySegments;

// The investigation segment will be stored here as it makes up for several inputs.
// It will be converted to a string, joined and then added to the querySegments.
std::vector<std::string> investigationWhere;
// The investigation segment will be stored here as it makes up for several inputs.
// It will be converted to a string, joined and then added to the querySegments.
std::vector<std::string> investigationWhere;

// In ICat4.2 `Dataset` and `Sample` cannot be in the same query (due to restriction with join).
// As such, we will query for sample only when dataset inputs are not used.
bool queryDataset = false;
// In ICat4.2 `Dataset` and `Sample` cannot be in the same query (due to restriction with join).
// As such, we will query for sample only when dataset inputs are not used.
bool queryDataset = false;

// Format the timestamps in order to compare them.
std::string startDate = formatDateTime(inputs.getStartDate());
std::string endDate = formatDateTime(inputs.getEndDate());
// Format the timestamps in order to compare them.
std::string startDate = formatDateTime(inputs.getStartDate());
std::string endDate = formatDateTime(inputs.getEndDate());

// Investigation startDate if endDate is not selected
if (inputs.getStartDate() != 0 && inputs.getEndDate() == 0)
{
investigationWhere.push_back("startDate >= '" + startDate + "'");
}

// Investigation endDate if startdate is not selected
if (inputs.getEndDate() != 0 && inputs.getStartDate() == 0)
{
investigationWhere.push_back("endDate <= '" + endDate + "'");
}

// Investigation Start and end date if both selected
if(inputs.getStartDate() != 0 && inputs.getEndDate() != 0)
{
investigationWhere.push_back("startDate BETWEEN '" + startDate + "' AND '" + endDate + "'");
}

// Investigation name (title)
if(!inputs.getInvestigationName().empty())
{
investigationWhere.push_back("title LIKE '%" + inputs.getInvestigationName() + "%' ");
}
// Investigation startDate if endDate is not selected
if (inputs.getStartDate() != 0 && inputs.getEndDate() == 0)
{
investigationWhere.push_back("startDate >= '" + startDate + "'");
}

// Investigation abstract
if(!inputs.getInvestigationAbstract().empty())
{
investigationWhere.push_back("summary = '" + inputs.getInvestigationAbstract() + "' ");
}
// Investigation endDate if startdate is not selected
if (inputs.getEndDate() != 0 && inputs.getStartDate() == 0)
{
investigationWhere.push_back("endDate <= '" + endDate + "'");
}

// Iterate over query vector and append AND between inputs.
std::string investigationResult = Strings::join(investigationWhere.begin(), investigationWhere.end(), " AND ");
// Investigation Start and end date if both selected
if(inputs.getStartDate() != 0 && inputs.getEndDate() != 0)
{
investigationWhere.push_back("startDate BETWEEN '" + startDate + "' AND '" + endDate + "'");
}

// Add the investigation result to the query if it exists.
if (!investigationResult.empty())
{
querySegments.push_back("Investigation[" + investigationResult + "]");
}
// Investigation name (title)
if(!inputs.getInvestigationName().empty())
{
investigationWhere.push_back("title LIKE '%" + inputs.getInvestigationName() + "%' ");
}

// Investigation type
if(!inputs.getInvestigationType().empty())
{
querySegments.push_back("InvestigationType[name IN ('" + inputs.getInvestigationType() + "')]");
}
// Investigation abstract
if(!inputs.getInvestigationAbstract().empty())
{
investigationWhere.push_back("summary = '" + inputs.getInvestigationAbstract() + "' ");
}

// Investigator's surname
if(!inputs.getInvestigatorSurName().empty())
{
querySegments.push_back("InvestigationUser <-> User[name LIKE '%" + inputs.getInvestigatorSurName() + "%']");
}
// Iterate over query vector and append AND between inputs.
std::string investigationResult = Strings::join(investigationWhere.begin(), investigationWhere.end(), " AND ");

// Datafile name
if(!inputs.getDatafileName().empty())
{
querySegments.push_back("Dataset <-> Datafile[name = '" + inputs.getDatafileName() + "']");
queryDataset = true;
}
// Add the investigation result to the query if it exists.
if (!investigationResult.empty())
{
querySegments.push_back("Investigation[" + investigationResult + "]");
}

// Run start and end
if(inputs.getRunStart() > 0 && inputs.getRunEnd() > 0)
{
// Convert the start and end runs to string.
std::string runStart = Strings::toString(inputs.getRunStart());
std::string runEnd = Strings::toString(inputs.getRunEnd());
// Investigation type
if(!inputs.getInvestigationType().empty())
{
querySegments.push_back("InvestigationType[name IN ('" + inputs.getInvestigationType() + "')]");
}

// To be able to use DatafileParameter we need to have access to Dataset and Datafile.
// If queryDataset is true, then we can rest assured that the relevant access is possible.
if (queryDataset)
// Investigator's surname
if(!inputs.getInvestigatorSurName().empty())
{
querySegments.push_back("DatafileParameter[type.name ='run_number' AND numericValue BETWEEN " + runStart + " AND " + runEnd + "]");
querySegments.push_back("InvestigationUser <-> User[name LIKE '%" + inputs.getInvestigatorSurName() + "%']");
}
else

// Datafile name
if(!inputs.getDatafileName().empty())
{
// Otherwise we directly include them ourselves.
querySegments.push_back("Dataset <-> Datafile <-> DatafileParameter[type.name ='run_number' AND numericValue BETWEEN " + runStart + " AND " + runEnd + "]");
// We then set queryDataset to true since Sample can not be included if a dataset is.
querySegments.push_back("Dataset <-> Datafile[name = '" + inputs.getDatafileName() + "']");
queryDataset = true;
}
}

// Instrument name
if(!inputs.getInstrument().empty())
{
querySegments.push_back("InvestigationInstrument <-> Instrument[name = '" + inputs.getInstrument() + "']");
}
// Run start and end
if(inputs.getRunStart() > 0 && inputs.getRunEnd() > 0)
{
// Convert the start and end runs to string.
std::string runStart = Strings::toString(inputs.getRunStart());
std::string runEnd = Strings::toString(inputs.getRunEnd());

// Keywords
if(!inputs.getKeywords().empty())
{
querySegments.push_back("Keyword[name IN ('" + inputs.getKeywords() + "')]");
}
// To be able to use DatafileParameter we need to have access to Dataset and Datafile.
// If queryDataset is true, then we can rest assured that the relevant access is possible.
if (queryDataset)
{
querySegments.push_back("DatafileParameter[type.name ='run_number' AND numericValue BETWEEN " + runStart + " AND " + runEnd + "]");
}
else
{
// Otherwise we directly include them ourselves.
querySegments.push_back("Dataset <-> Datafile <-> DatafileParameter[type.name ='run_number' AND numericValue BETWEEN " + runStart + " AND " + runEnd + "]");
// We then set queryDataset to true since Sample can not be included if a dataset is.
queryDataset = true;
}
}

// Sample name
if(!inputs.getSampleName().empty() && !queryDataset)
{
querySegments.push_back("Sample[name = '" + inputs.getSampleName() + "']");
}
// Instrument name
if(!inputs.getInstrument().empty())
{
querySegments.push_back("InvestigationInstrument <-> Instrument[name = '" + inputs.getInstrument() + "']");
}

// Keywords
if(!inputs.getKeywords().empty())
{
querySegments.push_back("Keyword[name IN ('" + inputs.getKeywords() + "')]");
}

// Now we build the query from the segments. For each segment, we append a join ("<->").
std::string query = Strings::join(querySegments.begin(), querySegments.end(), " <-> ");
// Sample name
if(!inputs.getSampleName().empty() && !queryDataset)
{
querySegments.push_back("Sample[name = '" + inputs.getSampleName() + "']");
}

// We then append the required includes to output related data, such as instrument name and run parameters.
if (!query.empty())
{
query.insert(0, "DISTINCT Investigation INCLUDE InvestigationInstrument, Instrument, InvestigationParameter <-> ");
}
// Now we build the query from the segments. For each segment, we append a join ("<->").
std::string query = Strings::join(querySegments.begin(), querySegments.end(), " <-> ");

// We then append the required includes to output related data, such as instrument name and run parameters.
if (!query.empty())
{
query.insert(0, "DISTINCT Investigation INCLUDE InvestigationInstrument, Instrument, InvestigationParameter <-> ");
}

g_log.debug() << "Query: { " << query << " }" << std::endl;
g_log.debug() << "Query: { " << query << " }" << std::endl;

return (query);
return (query);
}

/**
Expand Down

0 comments on commit 98fa154

Please sign in to comment.