Hi Greet,

I already checked no documents outside the spwan function all are within the 
spwan only.


Thanks & Regards,
Siva



-----Original Message-----
From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of 
general-requ...@developer.marklogic.com
Sent: Wednesday, May 25, 2016 11:17 AM
To: general@developer.marklogic.com
Subject: General Digest, Vol 143, Issue 36

Send General mailing list submissions to
        general@developer.marklogic.com

To subscribe or unsubscribe via the World Wide Web, visit
        http://developer.marklogic.com/mailman/listinfo/general
or, via email, send a message with subject or body 'help' to
        general-requ...@developer.marklogic.com

You can reach the person managing the list at
        general-ow...@developer.marklogic.com

When replying, please edit your Subject line so it is more specific than "Re: 
Contents of General digest..."


Today's Topics:

   1. Regarding spwan function (Mani, Sivasubramani (ELS))
   2. Re: Regarding spwan function (Geert Josten)


----------------------------------------------------------------------

Message: 1
Date: Wed, 25 May 2016 10:01:50 +0000
From: "Mani, Sivasubramani (ELS)" <s.m...@elsevier.com>
Subject: [MarkLogic Dev General] Regarding spwan function
To: "general@developer.marklogic.com"
        <general@developer.marklogic.com>
Message-ID:
        
<cy1pr0801mb10199a9b76d3fc26f2b8deeff4...@cy1pr0801mb1019.namprd08.prod.outlook.com>
        
Content-Type: text/plain; charset="us-ascii"

Hi All,

I am new marklogic I writed a spwan function to update the documents and I use 
xdmp:node-replace and xdmp:node-insert-child inside the spwan function but 
there is no update is happen inside the cod.
My code is below

let $start := 225001
let $end := 226000
return xdmp:spawn-function(function() {
let $log := xdmp:log(concat("Running update for chunk", $start, " to ",$end)) 
for $uri in 
cts:uris((),(),cts:and-query((cts:element-query(xs:QName("dp:document-properties"),
 "*"))))[$start to $end] let $itemPii := (tokenize($uri, "/")[last()-1]) let 
$uri := 
replace("https://acc.vtw.elsevier.com/property/pii/itempii?category=cs:consyn";, 
"itempii", $itemPii)
        let $psResponse :=
            json:transform-from-json(xdmp:quote(
                xdmp:http-get($uri,
                    <options xmlns="xdmp:http">
                       <authentication method="digest">
                         <username>{xs:string("")}</username>
                         <password>{xs:string("")}</password>
                       </authentication>
                       <verify-cert>false</verify-cert>
                     </options>)[2]))
let $copyright_info := 
eninglib:construct-copyright-notice-element($itemPii,$psResponse)
let $license_info := 
eninglib:construct-copyright-licenseLine-element($itemPii,$psResponse)
return
(
if(exists($copyright_info) or exists($license_info)) then ( let $log := 
xdmp:log(concat("Copyright update-", $itemPii, "Copyright Info - 
",$copyright_info,"License Info -",$license_info)) let $node :=  
doc($uri)//dp:document-properties/dp:copyrightInformation

let $cp := if (exists($node))
then 
(xdmp:node-replace($node,<dp:copyrightInformation>{$copyright_info,$license_info}</dp:copyrightInformation>))
else 
(xdmp:node-insert-child(doc($uri)//dp:document-properties,<dp:copyrightInformation>{$copyright_info,$license_info}</dp:copyrightInformation>))


let $oanode := doc($uri)//cps:consyn-properties/cps:oa-last-updated-timestamp
let $oa := if(exists($oanode))
then(xdmp:node-replace($oanode,<cps:oa-last-updated-timestamp>{current-dateTime()}</cps:oa-last-updated-timestamp>))
else(xdmp:node-insert-child(doc($uri)//cps:consyn-properties,<cps:oa-last-updated-timestamp>{current-dateTime()}</cps:oa-last-updated-timestamp>))
return ()
)
else()
)
},<options xmlns="xdmp:eval">

            <transaction-mode>update-auto-commit
</transaction-mode>
        </options>)

Kindly do needful.

Thanks & Regards,
Siva

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://developer.marklogic.com/pipermail/general/attachments/20160525/a62dc7ae/attachment-0001.html
 

------------------------------

Message: 2
Date: Wed, 25 May 2016 10:16:37 +0000
From: Geert Josten <geert.jos...@marklogic.com>
Subject: Re: [MarkLogic Dev General] Regarding spwan function
To: MarkLogic Developer Discussion <general@developer.marklogic.com>
Message-ID: <d36b480c.dbfad%geert.jos...@marklogic.com>
Content-Type: text/plain; charset="us-ascii"

Did you check your code outside a spawn on a few documents?

Cheers,
Geert

From: 
<general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>>
 on behalf of "Mani, Sivasubramani (ELS)" 
<s.m...@elsevier.com<mailto:s.m...@elsevier.com>>
Reply-To: MarkLogic Developer Discussion 
<general@developer.marklogic.com<mailto:general@developer.marklogic.com>>
Date: Wednesday, May 25, 2016 at 12:01 PM
To: "general@developer.marklogic.com<mailto:general@developer.marklogic.com>" 
<general@developer.marklogic.com<mailto:general@developer.marklogic.com>>
Subject: [MarkLogic Dev General] Regarding spwan function

Hi All,

I am new marklogic I writed a spwan function to update the documents and I use 
xdmp:node-replace and xdmp:node-insert-child inside the spwan function but 
there is no update is happen inside the cod.
My code is below

let $start := 225001
let $end := 226000
return xdmp:spawn-function(function() {
let $log := xdmp:log(concat("Running update for chunk", $start, " to ",$end)) 
for $uri in 
cts:uris((),(),cts:and-query((cts:element-query(xs:QName("dp:document-properties"),
 "*"))))[$start to $end] let $itemPii := (tokenize($uri, "/")[last()-1]) let 
$uri := 
replace("https://acc.vtw.elsevier.com/property/pii/itempii?category=cs:consyn";, 
"itempii", $itemPii)
        let $psResponse :=
            json:transform-from-json(xdmp:quote(
                xdmp:http-get($uri,
                    <options xmlns="xdmp:http">
                       <authentication method="digest">
                         <username>{xs:string("")}</username>
                         <password>{xs:string("")}</password>
                       </authentication>
                       <verify-cert>false</verify-cert>
                     </options>)[2]))
let $copyright_info := 
eninglib:construct-copyright-notice-element($itemPii,$psResponse)
let $license_info := 
eninglib:construct-copyright-licenseLine-element($itemPii,$psResponse)
return
(
if(exists($copyright_info) or exists($license_info)) then ( let $log := 
xdmp:log(concat("Copyright update-", $itemPii, "Copyright Info - 
",$copyright_info,"License Info -",$license_info)) let $node :=  
doc($uri)//dp:document-properties/dp:copyrightInformation

let $cp := if (exists($node))
then 
(xdmp:node-replace($node,<dp:copyrightInformation>{$copyright_info,$license_info}</dp:copyrightInformation>))
else 
(xdmp:node-insert-child(doc($uri)//dp:document-properties,<dp:copyrightInformation>{$copyright_info,$license_info}</dp:copyrightInformation>))


let $oanode := doc($uri)//cps:consyn-properties/cps:oa-last-updated-timestamp
let $oa := if(exists($oanode))
then(xdmp:node-replace($oanode,<cps:oa-last-updated-timestamp>{current-dateTime()}</cps:oa-last-updated-timestamp>))
else(xdmp:node-insert-child(doc($uri)//cps:consyn-properties,<cps:oa-last-updated-timestamp>{current-dateTime()}</cps:oa-last-updated-timestamp>))
return ()
)
else()
)
},<options xmlns="xdmp:eval">

            <transaction-mode>update-auto-commit
</transaction-mode>
        </options>)

Kindly do needful.

Thanks & Regards,
Siva

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://developer.marklogic.com/pipermail/general/attachments/20160525/a78ec4d6/attachment.html
 

------------------------------

_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


End of General Digest, Vol 143, Issue 36
****************************************
_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to