def builder = new StreamingMarkupBuilder()
builder.encoding = "UTF-8"
String openDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date())
// Create a new project using the Markup Builder
def projectDoc = builder.bind {
mkp.xmlDeclaration()
mkp.declareNamespace(prj: 'http://genologics.com/ri/project')
'prj:project' {
'name'("${projectName}")
'open-date'("${openDate}")
'researcher'(uri:researcherURI)
}
}
// Post the new project to the API
createdProjectNode = GLSRestApiUtils.xmlStringToNode(projectDoc.toString())
createdProjectNode = GLSRestApiUtils.httpPOST(createdProjectNode, "${projectListURI}", username, password)
println GLSRestApiUtils.nodeToXmlString(createdProjectNode)<prj:project xmlns:prj="http://genologics.com/ri/project" uri="http://yourIPaddress/api/v2/projects/EXA2248" limsid="EXA2248">
<name>Cookbook Project POST 8.1</name>
<open-date>2010-09-14</open-date>
<researcher uri="http://yourIPaddress/api/v2/researchers/1"/>
</prj:project>// Determine the URI of the containers list
containersListURI = "http://${hostname}/api/v2/containers"
// Create a new container using the Markup Builder
def containerDoc = builder.bind {
mkp.xmlDeclaration()
mkp.declareNamespace(con: 'http://genologics.com/ri/container')
mkp.declareNamespace(udf: 'http://genologics.com/ri/userdefined')
'con:container' {
'name'("${containerName}")
'type'(uri:"http://${hostname}/api/v2/containertypes/1", name:"96 well plate")
}
}
// Post the new container to the API
createdContainerNode = GLSRestApiUtils.xmlStringToNode(containerDoc.toString())
println GLSRestApiUtils.nodeToXmlString(createdContainerNode)
createdContainerNode = GLSRestApiUtils.httpPOST(createdContainerNode, containersListURI, username, password)
println GLSRestApiUtils.nodeToXmlString(createdContainerNode)/** NOTE: if the system has unique container name constraints enabled, change this
value every time script runs*/
<con:container xmlns:con="http://genologics.com/ri/container" uri="http://yourIPaddress/api/v2/containers/27-4075" limsid="27-4075">
<name>Example 8.1 container</name>
<type uri="http://yourIPaddress/api/v2/containertypes/1" name="96 well plate"/>
</con:container>// Determine the samples list URI
sampleListURI = "http://${hostname}/api/v2/samples"
// Create a sample using the Markup Builder
def sampleDoc = builder.bind {
mkp.xmlDeclaration()
mkp.declareNamespace(smp: 'http://genologics.com/ri/sample')
'smp:samplecreation' {
'name'("${sampleName}")
'project'(uri:"${createdProjectNode.'@uri'}")
'location' {
'container'(limsid:"${createdContainerNode.'@limsid'}", uri:"${createdContainerNode.'@uri'}")
'value'('A:1')
}
}
}
// Post the sample to the API
createdSampleNode = GLSRestApiUtils.xmlStringToNode(sampleDoc.toString())
createdSampleNode = GLSRestApiUtils.httpPOST(createdSampleNode, "${sampleListURI}", username, password)
println GLSRestApiUtils.nodeToXmlString(createdSampleNode)// Retrieve the sample
sampleURI = "http://${hostname}/api/v2/samples/${sampleLIMSID}"
sample = GLSRestApiUtils.httpGET(sampleURI, username, password)<smp:sample uri="http://yourIPaddress/api/v2/samples/HAM754A1" limsid="HAM754A1">
<name>Colon-1</name>
<date-received>2010-03-25</date-received>
<project uri="http://yourIPaddress/api/v2/projects/HAM754" limsid="HAM754"/>
<artifact uri="http://yourIPaddress/api/v2/artifacts/HAM754A1PA1?state=11822" limsid="HAM754A1PA1"/>
<udf:field type="String" name="Organism">Homo sapiens</udf:field>
<udf:field type="String" name="Gender">Unknown</udf:field>
<udf:field type="Numeric" name="Concentration (ng/uL)">200.0</udf:field>
<udf:field type="Numeric" name="Total Volume (uL)">50</udf:field>
<udf:field type="String" name="Investigator Sample Name">F3_5016</udf:field>
<udf:field type="String" name="Sample Group Phase">Pick Plate</udf:field>
<udf:field type="String" name="Date of Sample Group Phase">2010-05-19</udf:field>
<udf:field type="String" name="Sample QC">FAILED</udf:field>
<udf:field type="String" name="Sample QC Date">2010-04-12</udf:field>
<udf:field type="String" name="Sample Picked">Yes</udf:field>
<udf:field type="String" name="Sample Latest Pick Date">2010-05-19</udf:field>
<udf:field type="Numeric" name="Sample Picked Iteration">3</udf:field>
<udf:field type="String" name="Sample Library Requeue Status"/>
<udf:field type="String" name="Sample Library Requeue Date">2010-05-19</udf:field>
<udf:field type="Numeric" name="Paired End Read Sequencing Lane Iteration">2</udf:field>
<udf:field type="String" name="Paired End Read Sequencing Last Date">2010-01-15</udf:field>
<udf:field type="String" name="Investigator Last Name">Hershberger</udf:field>
<udf:field type="String" name="Cohort">Not Applicable</udf:field>
</smp:sample>// Rename the sample
nameNode = sample.name[0]
nameNode.setValue(newName)
returnNode = GLSRestApiUtils.httpPUT(sample, sample.@uri, username, password)<smp:sample uri="http://yourIPaddress/api/v2/samples/HAM754A1" limsid="HAM754A1">
<name>Colon-1 Updated</name>
<date-received>2010-03-25</date-received>
<project uri="http://yourIPaddress/api/v2/projects/HAM754" limsid="HAM754"/>
<artifact uri="http://yourIPaddress/api/v2/artifacts/HAM754A1PA1?state=11822" limsid="HAM754A1PA1"/>
<udf:field type="String" name="Organism">Homo sapiens</udf:field>
<udf:field type="String" name="Gender">Unknown</udf:field>
<udf:field type="Numeric" name="Concentration (ng/uL)">200.0</udf:field>
<udf:field type="Numeric" name="Total Volume (uL)">50</udf:field>
<udf:field type="String" name="Investigator Sample Name">F3_5016</udf:field>
<udf:field type="String" name="Sample Group Phase">Pick Plate</udf:field>
<udf:field type="String" name="Date of Sample Group Phase">2010-05-19</udf:field>
<udf:field type="String" name="Sample QC">FAILED</udf:field>
<udf:field type="String" name="Sample QC Date">2010-04-12</udf:field>
<udf:field type="String" name="Sample Picked">Yes</udf:field>
<udf:field type="String" name="Sample Latest Pick Date">2010-05-19</udf:field>
<udf:field type="Numeric" name="Sample Picked Iteration">3</udf:field>
<udf:field type="String" name="Sample Library Requeue Status"/>
<udf:field type="String" name="Sample Library Requeue Date">2010-05-19</udf:field>
<udf:field type="Numeric" name="Paired End Read Sequencing Lane Iteration">2</udf:field>
<udf:field type="String" name="Paired End Read Sequencing Last Date">2010-01-15</udf:field>
<udf:field type="String" name="Investigator Last Name">Hershberger</udf:field>
<udf:field type="String" name="Cohort">Not Applicable</udf:field>
</smp:sample>// Define the assignment endpoint URI
assignmentOrderURI = "http://${hostname}/api/v2/route/artifacts/"Â // Retrieve the samples' base artifact URIs
sampleAArtifactURI = GLSRestApiUtils.httpGET(sampleURIs[0], username, password).'artifact'.@uri
sampleBArtifactURI = GLSRestApiUtils.httpGET(sampleURIs[1], username, password).'artifact'.@uri // Gather the required workflow URIs
workflowAURI = workflowURIs[0]
workflowBURI = workflowURIs[1]Â // Create a new routing assignment using the Markup Builder
def assignmentOrder = builder.bind {
mkp.xmlDeclaration()
mkp.declareNamespace(rt: 'http://genologics.com/ri/routing')
'rt:routing' {
'assign'('workflow-uri': workflowAURI) {
'artifact'(uri: sampleAArtifactURI)
}
'assign'('workflow-uri': workflowBURI) {
'artifact'(uri: sampleBArtifactURI)
}
}
}
// Post the commands to the API
assignmentOrderNode = GLSRestApiUtils.xmlStringToNode(assignmentOrder.toString())
assignmentOrderNode = GLSRestApiUtils.httpPOST(assignmentOrderNode, assignmentOrderURI, username, password)
println GLSRestApiUtils.nodeToXmlString(assignmentOrderNode)// Determine the analyte's URI and retrieve it
arbitraryAnalyteArtifactURI = "http://${hostname}/api/v2/artifacts/${artifactLIMSID}"
arbitraryArtifactNode = GLSRestApiUtils.httpGET(arbitraryAnalyteArtifactURI, username, password)
println GLSRestApiUtils.nodeToXmlString(arbitraryArtifactNode)
// Retrieve the analyte's sample
def rootSampleURI = arbitraryArtifactNode.'sample'[0].'@uri'
rootSampleNode = GLSRestApiUtils.httpGET(rootSampleURI, username, password)
println GLSRestApiUtils.nodeToXmlString(rootSampleNode)
// Retrieve the sample's root analyte
def rootAnalyteArtifactURI = rootSampleNode.'artifact'[0].'@uri'
rootAnalyteArtifactNode = GLSRestApiUtils.httpGET(rootAnalyteArtifactURI, username, password)
println GLSRestApiUtils.nodeToXmlString(rootAnalyteArtifactNode)<art:artifact xmlns:art="http://genologics.com/ri/artifact" uri="http://yourIPaddress/api/v2/artifacts/EXA2241A1DN3?state=18882" limsid="EXA2241A1DN3">
<name>Example Analyte Artifact</name>
<type>Analyte</type>
<output-type>Analyte</output-type>
<parent-process uri="http://yourIPaddress/api/v2/processes/DNA-SA1-100914-24-1917" limsid="DNA-SA1-100914-24-1917"/>
<qc-flag>UNKNOWN</qc-flag>
<location>
<container uri="http://yourIPaddress/api/v2/containers/27-3543" limsid="27-3543"/>
<value>A:2</value>
</location>
<working-flag>false</working-flag>
<sample uri="http://yourIPaddress0/api/v2/samples/EXA2241A1" limsid="EXA2241A1"/>
</art:artifact>Â <smp:sample xmlns:smp="http://genologics.com/ri/sample" uri="http://yourIPaddress/api/v2/samples/EXA2241A1" limsid="EXA2241A1">
<name>Example Sample</name>
<project uri="http://yourIPaddress/api/v2/projects/EXA2241" limsid="EXA2241"/>
<artifact uri="http://yourIPaddress/api/v2/artifacts/EXA2241A1SAM1?state=18879" limsid="EXA2241A1SAM1"/>
<biosource/>
<udf:field xmlns:udf="http://genologics.com/ri/userdefined" type="String" name="String Type UDF">Updated String UDF Value</udf:field>
<udf:field xmlns:udf="http://genologics.com/ri/userdefined" type="Text" name="Text Type UDF">Updated Text UDF Value</udf:field>
<udf:field xmlns:udf="http://genologics.com/ri/userdefined" unit="u" type="Numeric" name="Numeric Type UDF">3.140</udf:field>
<udf:field xmlns:udf="http://genologics.com/ri/userdefined" type="Boolean" name="Boolean Type UDF">true</udf:field>
<udf:field xmlns:udf="http://genologics.com/ri/userdefined" type="Date" name="Date Type UDF">2010-09-14</udf:field>
<udf:field xmlns:udf="http://genologics.com/ri/userdefined" type="URI" name="URI Type UDF">http://www.genologics.com</udf:field>
<udf:field xmlns:udf="http://genologics.com/ri/userdefined" type="Executable" name="Executable Type UDF">/usr/bin/yes</udf:field>
</smp:sample>Â <art:artifact xmlns:art="http://genologics.com/ri/artifact" uri="http://yourIPaddress/api/v2/artifacts/EXA2241A1SAM1?state=18879" limsid="EXA2241A1SAM1">
<name>Example Analyte Artifact</name>
<type>Analyte</type>
<output-type>Analyte</output-type>
<qc-flag>UNKNOWN</qc-flag>
<location>
<container uri="http://yourIPaddress/api/v2/containers/27-3543" limsid="27-3543"/>
<value>A:1</value>
</location>
<working-flag>true</working-flag>
<sample uri="http://yourIPaddress/api/v2/samples/EXA2241A1" limsid="EXA2241A1"/>
</art:artifact>// Retrieve the sample
sampleURI = "http://${hostname}/api/v2/samples/${sampleID}"
sample = GLSRestApiUtils.httpGET(sampleURI, username, password)Â <smp:sample uri="http://yourIPaddress/api/v2/samples/ADM201A1" limsid="ADM201A1">
<name>DNA sample-1</name>
<date-received>2017-04-18</date-received>
<project uri="http://yourIPaddress/api/v2/projects/ADM201" limsid="ADM201"/>
<artifact uri="http://yourIPaddress/api/v2/artifacts/ADM201A1PA1?state=2995" limsid="ADM201A1PA1"/>
<udf:field type="String" name="Sample Type">DNA</udf:field>
<udf:field type="String" name="Phenotypic Information">Human</udf:field>
<udf:field type="String" name="Priority">High</udf:field>
</smp:sample>// Update the sample's Priority UDF value
sample = GLSRestApiUtils.setUdfValue(sample, 'Priority', 'Critical')
returnNode = GLSRestApiUtils.httpPUT(sample, sample.@uri, username, password)
println GLSRestApiUtils.nodeToXmlString(returnNode)<smp:sample uri="http://yourIPaddress/api/v2/samples/ADM201A1" limsid="ADM201A1">
<name>DNA sample-1</name>
<date-received>2017-04-18</date-received>
<project uri="http://yourIPaddress/api/v2/projects/ADM201" limsid="ADM201"/>
<artifact uri="http://yourIPaddress/api/v2/artifacts/ADM503A1PA1?state=2995" limsid="ADM201A1PA1"/>
<udf:field type="String" name="Sample Type">DNA</udf:field>
<udf:field type="String" name="Phenotypic Information">Human</udf:field>
<udf:field type="String" name="Priority">Critical</udf:field>
</smp:sample>
