Remove Information from a Project
Last updated
Was this helpful?
Was this helpful?
// Determine project list's URI
String projectsListURI = "http://${hostname}/api/v2/projects"
def builder = new StreamingMarkupBuilder()
builder.encoding = "UTF-8"
openDate = "2017-08-24"
// Build a new project using Markup Builder
def projectDoc = builder.bind {
mkp.xmlDeclaration()
mkp.declareNamespace(prj: 'http://genologics.com/ri/project')
mkp.declareNamespace(udf: 'http://genologics.com/ri/userdefined')
'prj:project'{
'name'(projectName)
'open-date'(openDate)
'researcher'(uri:"http://${hostname}/api/v2/researchers/1")
'udf:field'(name:"Objective","To test httpPOST")
}
}
// Post the new project
def projectNode = GLSRestApiUtils.xmlStringToNode(projectDoc.toString())
projectNode = GLSRestApiUtils.httpPOST(projectNode, projectsListURI, username, password)
println GLSRestApiUtils.nodeToXmlString(projectNode)<prj:project xmlns:prj="http://genologics.com/ri/project" uri="http://yourIPaddress/api/v2/projects/WOR512" limsid="WOR512">
<name>httpPOST Project then remove nodes</name>
<open-date>2017-08-24</open-date>
<researcher uri="http://yourIPaddress/api/v2/researchers/1"/>
<udf:field xmlns:udf="http://genologics.com/ri/userdefined" type="String" name="Objective">To test httpPOST</udf:field>
<permissions uri="http://yourIPaddress/api/v2/permissions/projects/WOR512"/>
</prj:project>// If projectNode is parentNode, remove the child udf:field
projectNode?.children()?.remove(projectNode.'udf:field'[0])
// Print the node that will be updated
println GLSRestApiUtils.nodeToXmlString(projectNode)