Skip to content

Commit

Permalink
Merge pull request #12 from mskcc/develop
Browse files Browse the repository at this point in the history
Merged.
  • Loading branch information
mattkoch614 authored Apr 1, 2018
2 parents 9f8d23b + db6960f commit 39068a6
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 16 deletions.
68 changes: 68 additions & 0 deletions Medidata.RWS.NET/Core/Requests/Datasets/VersionDatasetRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Medidata.RWS.Core.Requests;

namespace Medidata.RWS.Core.Requests.Datasets
{
public class VersionDatasetRequest : OdmDatasetBase
{
public VersionDatasetRequest(

string project_name,
string environment_name,
string version_oid,
string dataset_type = "regular",
string formOid = default(string),
string versionitem = default(string),
string rawsuffix = default(string),
string codelistsuffix = default(string),
string decodesuffix = default(string),
string stdsuffix = default(string),
string start = default(string)) : base(dataset_type, versionitem, rawsuffix, codelistsuffix, decodesuffix, stdsuffix, start)
{

ProjectName = project_name;
EnvironmentName = environment_name;
VersionOid = version_oid;
FormOid = formOid;
Verify();
}

public string VersionOid { get; set; }

public string FormOid { get; set; }

public string EnvironmentName { get; set; }

public string ProjectName { get; set; }

/// <summary>
/// Get the Study and Environment names in a format RWS expects.
/// If no environment name is provided, it is left out of the return string.
/// </summary>
/// <returns></returns>
private string StudyNameAndEnvironment()
{
return string.IsNullOrWhiteSpace(EnvironmentName) ? $"{ProjectName}" : $"{ProjectName}({EnvironmentName})";
}


/// <summary>
/// The URL path of the resource being requested.
/// </summary>
/// <returns></returns>
public override string UrlPath()
{

var queryParams = new List<string> { "studies", StudyNameAndEnvironment(), "versions", VersionOid, "datasets", dataset_type };

if (!string.IsNullOrEmpty(FormOid)) queryParams.Add(FormOid);

return RequestHelpers.MakeUrl("/", QueryString(), queryParams.ToArray());

}
}
}
1 change: 1 addition & 0 deletions Medidata.RWS.NET/Medidata.RWS.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<Compile Include="Core\Requests\CacheFlushRequest.cs" />
<Compile Include="Core\Requests\Datasets\StudyDatasetRequest.cs" />
<Compile Include="Core\Requests\Datasets\SubjectDatasetRequest.cs" />
<Compile Include="Core\Requests\Datasets\VersionDatasetRequest.cs" />
<Compile Include="Core\Requests\Implementations\ClinicalStudiesRequest.cs" />
<Compile Include="Core\Requests\Implementations\MetadataStudiesRequest.cs" />
<Compile Include="Core\Requests\Implementations\PostDataRequest.cs" />
Expand Down
80 changes: 70 additions & 10 deletions Medidata.RWS.NET/docs/core_resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ or, to filter the data by form:

.. code-block:: c#
using Medidata.RWS.Core.Requests.Implementations;
using Medidata.RWS.Core.Requests
using Medidata.RWS.Core.Requests.Datasets;
//Create a connection
var connection = new RwsConnection("innovate", "username", "password"); // authentication required
Expand All @@ -122,7 +123,7 @@ or, to filter the data by form:
var response = connection.SendRequest(new StudyDatasetRequest("Mediflex", "Prod", dataset_type: "regular")) as RWSResponse;
//Write the XML response to the console (see XML below)
Console.Write(response.xmlString);
Console.Write(response.RawXMLString());
.. code-block:: xml
Expand Down Expand Up @@ -184,16 +185,17 @@ or, to filter the data by form:

.. code-block:: c#
using Medidata.RWS.Core.Requests.Implementations;
using Medidata.RWS.Core.Requests
using Medidata.RWS.Core.Requests.Datasets;
//Create a connection
var connection = new RwsConnection("innovate", "username", "password"); // authentication required
//Create a connection
var connection = new RwsConnection("innovate", "username", "password"); // authentication required
//Send the request / get a response
var response = connection.SendRequest(new SubjectDatasetRequest("Mediflex", "Prod", subject_key: "1", dataset_type: "regular")) as RWSResponse;
//Send the request / get a response
var response = connection.SendRequest(new SubjectDatasetRequest("Mediflex", "Prod", subject_key: "1", dataset_type: "regular")) as RWSResponse;
//Write the XML response to the console (see XML below)
Console.Write(response.xmlString);
//Write the XML response to the console (see XML below)
Console.Write(response.RawXMLString());
.. code-block:: xml
Expand Down Expand Up @@ -256,4 +258,62 @@ This is the equivalent of calling:
or, to filter the data by form:
``https://{subdomain}.mdsol.com/studies/{project}({environment})/versions/{ version_id }/datasets/{ regular|raw }/{ formoid }?{options}``

*TBA*

.. code-block:: c#
using Medidata.RWS.Core.Requests
using Medidata.RWS.Core.Requests.Datasets;
//Create a connection
var connection = new RwsConnection("innovate", "username", "password"); // authentication required
//Send the request / get a response
var response = connection.SendRequest(new VersionDatasetRequest(project_name: "Mediflex", environment_name: "Dev", version_oid: "999")) as RWSResponse;
//Write the XML response to the console (see XML below)
Console.Write(response.RawXMLString());
*Note the **MetaDataVersionOID** value in the XML response.*

.. code-block:: xml
<?xml version="1.0" encoding="utf-8"?>
<ODM FileType="Snapshot" FileOID="9035596c-f090-4030-860a-0ed27a4e3d03" CreationDateTime="2017-06-05T13:28:39.325-00:00" ODMVersion="1.3" xmlns:mdsol="http://www.mdsol.com/ns/odm/metadata" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.cdisc.org/ns/odm/v1.3">
<ClinicalData StudyOID="Mediflex(Dev)" MetaDataVersionOID="999">
<SubjectData SubjectKey="1">
<SiteRef LocationOID="1" />
<StudyEventData StudyEventOID="SCREENING" StudyEventRepeatKey="1">
<FormData FormOID="CHEM" FormRepeatKey="1">
<ItemGroupData ItemGroupOID="CHEM_LOG_LINE">
<ItemData ItemOID="CHEM.DATECOLL" Value="2015-04-25T16:09:00" />
</ItemGroupData>
</FormData>
</StudyEventData>
</SubjectData>
</ClinicalData>
<ClinicalData StudyOID="Mediflex(Dev)" MetaDataVersionOID="999">
<SubjectData SubjectKey="2">
<SiteRef LocationOID="1" />
<StudyEventData StudyEventOID="SCREENING" StudyEventRepeatKey="1">
<FormData FormOID="CHEM" FormRepeatKey="1">
<ItemGroupData ItemGroupOID="CHEM_LOG_LINE">
<ItemData ItemOID="CHEM.DATECOLL" Value="2016-04-25T16:09:00" />
</ItemGroupData>
</FormData>
</StudyEventData>
</SubjectData>
</ClinicalData>
<ClinicalData StudyOID="Mediflex(Dev)" MetaDataVersionOID="999">
<SubjectData SubjectKey="3">
<SiteRef LocationOID="1" />
<StudyEventData StudyEventOID="SCREENING" StudyEventRepeatKey="1">
<FormData FormOID="CHEM" FormRepeatKey="1">
<ItemGroupData ItemGroupOID="CHEM_LOG_LINE">
<ItemData ItemOID="CHEM.DATECOLL" Value="2017-04-25T16:09:00" />
</ItemGroupData>
</FormData>
</StudyEventData>
</SubjectData>
</ClinicalData>
...
</ODM>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using Medidata.RWS.Core.Requests.Datasets;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Medidata.RWS.Tests.Core.Requests.Datasets
{
[TestClass]
public class VersionDatasetRequestTests
{
[TestMethod]
public void VersionDatasetRequest_default_version_path_is_correct()
{
var request = new VersionDatasetRequest(project_name: "Mediflex", environment_name: "Dev", version_oid: "001");

Assert.AreEqual("Mediflex", request.ProjectName);

Assert.AreEqual("Dev", request.EnvironmentName);

Assert.AreEqual("001", request.VersionOid);

Assert.AreEqual("studies/Mediflex(Dev)/versions/001/datasets/regular", request.UrlPath());

}

[TestMethod]
public void VersionDatasetRequest_raw_version_path_is_correct()
{
var request = new VersionDatasetRequest(project_name: "Mediflex", environment_name: "Dev", version_oid: "001", dataset_type:"raw");

Assert.AreEqual("Mediflex", request.ProjectName);

Assert.AreEqual("Dev", request.EnvironmentName);

Assert.AreEqual("001", request.VersionOid);

Assert.AreEqual("studies/Mediflex(Dev)/versions/001/datasets/raw", request.UrlPath());

}

[TestMethod]
public void VersionDatasetRequest_raw_version_path_with_form_is_correct()
{
var request = new VersionDatasetRequest(project_name: "Mediflex", environment_name: "Dev", version_oid: "001", dataset_type: "raw", formOid: "DM");

Assert.AreEqual("Mediflex", request.ProjectName);

Assert.AreEqual("Dev", request.EnvironmentName);

Assert.AreEqual("001", request.VersionOid);

Assert.AreEqual("studies/Mediflex(Dev)/versions/001/datasets/raw/DM", request.UrlPath());

}

[TestMethod]
[ExpectedException(typeof(NotSupportedException))]
public void VersionDatasetRequest_throws_with_improper_parameters()
{

var req = new VersionDatasetRequest("TESTPROJECT", "DEV", "1001", dataset_type: "newfie");

}


}
}
4 changes: 1 addition & 3 deletions Medidata.RWS.Tests/Medidata.RWS.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<Compile Include="Core\Requests\ClinicalStudiesRequestTests.cs" />
<Compile Include="Core\Requests\CoreRequestsTests.cs" />
<Compile Include="Core\Requests\Datasets\StudyDatasetRequestTests.cs" />
<Compile Include="Core\Requests\Datasets\VersionDatasetRequestTests.cs" />
<Compile Include="Core\Requests\Datasets\SubjectDatasetRequestTests.cs" />
<Compile Include="Core\Requests\MetadataStudiesRequestTests.cs" />
<Compile Include="Core\Requests\ODM Adapter\AuditRecordsRequestTests.cs" />
Expand Down Expand Up @@ -102,9 +103,6 @@
<Compile Include="RWSHelpersTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include=".env">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include=".env.example" />
<None Include="packages.config" />
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Medidata.RWS.Tests/Read_Before_Running_Tests.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
In order for tests to run successfully, the Medidata.RWS assembly must not be installed in the GAC.
In order for tests to run successfully, the Medidata.RWS.NET assembly must not be installed in the GAC.

To remove it from the GAC:

gacutil /uf Medidata.RWS
gacutil /uf Medidata.RWS.NET

After test suite is run, it can be added back:

gacutil /if Medidata.RWS.dll
gacutil /if Medidata.RWS.NET.dll

## .env file
Ensure you have a .env file in your test project root.
Expand Down

0 comments on commit 39068a6

Please sign in to comment.