Hi Andrea,
 thank you for putting me on the right track. In DSpace 6 metadata values 
can be accessed via itemService property:

from org.dspace.curate import ScriptedTask
from java.lang import Class
from org.dspace.content import DSpaceObject

class MyTask(ScriptedTask):
    def init(self, curator, taskName):
        print "initializing with Jython"

    def performDso(self, dso):
        print "perform on dso"
        a = dso.itemService.getMetadataByMetadataString(dso,"dc.title")
        if a.size() > 0:
            print (a.get(0).getValue())
        return 0

    def performId(self, context, id):
        print "perform on id %s" % (id)
        return 0




On Wednesday, 13 July 2016 09:07:46 UTC+3, Ari wrote:
>
> Hi,
> I just found that one can write curator tasks with Jython. This seems to 
> be an ideal way for us to do some task without need to code in Java. 
> However, I'm not a java programmer and haven't used Jython before and I'm 
> completely stuck with it and there is very little examples around (I have 
> found one).
>
> How do I access methods of DSpaceObject in Jython, like getMetadata()?
>  
> from org.dspace.curate import ScriptedTask
> from java.lang import Class
> from org.dspace.content import DSpaceObject
>
> class MyTask(ScriptedTask):
>     def init(self, curator, taskName):
>         print "initializing with Jython"
>
>     def performDso(self, dso):
>         print "perform on dso"
>         print dso.class
>         print (dir(dso))
>         o = super(DSpaceObject, dso).getMetadata("dc.publisher") # 
> desperate attempt 
>         return 0
>
>     def performId(self, context, id):
>         print "perform on id %s" % (id)
>         return 0
>
>
> When I call this from command line like this with item handle 
> 123456789/39434:
>
>  /dspace/bin/dspace curate -t mytask -i 123456789/39434 -r -
>
> It gives me an Item object, which doesn't have getMetadata method.
> Any examples lying around?
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dspace-tech+unsubscr...@googlegroups.com.
To post to this group, send email to dspace-tech@googlegroups.com.
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.

Reply via email to