如何删除 DSpace 6x 中生成的比特流?

How to delete generated bitstreams in DSpace 6x?

我想删除所有由 filter-media 生成的比特流,但只有特定描述 "IM Thumbnail".

我知道我可以通过使用 -f 标志强制它重新生成缩略图来重新生成缩略图。我正在测试我的设置中的一些设置,我只想先删除具有此特定描述的生成的缩略图。

我试过通过 PgAdmin 修改数据库,但我只能选择比特流。我什至不知道如何对返回的结果进行分组或排序,也不确定我是否选择了正确的表格。

SELECT 
  * 
FROM 
  public.bitstream, 
  public.bundle, 
  public.bundle2bitstream, 
  public.metadatavalue, 
  public.item2bundle
WHERE 
  bitstream.uuid = metadatavalue.dspace_object_id AND
  bitstream.uuid = bundle2bitstream.bitstream_id AND
  bundle.uuid = item2bundle.bundle_id AND
  bundle2bitstream.bundle_id = bundle.uuid AND
  metadatavalue.text_value = 'IM Thumbnail';

任何有关如何通过数据库操作或任何其他方式执行此操作的建议,我们将不胜感激。在特定社区或集合中应用 SQL 删除也将是一个非常好的奖励!

提前致谢!

虽然问题是用 postgresql 标记的,但我使用 Jython 从 DSpace 社区邮件列表中找到了答案。感谢 Joan Caparros 提供的原始代码。可以在此处找到消息线程:Removing Thumbnails in DSpace 5. I also posted a similar query in the DSpace Technical Support Mailing List which can be found here: Batch delete bitstreams in the Bundle: THUMBNAIL where Joan posted a modified version of his code 满足我的特定需求,如果它包含描述 "IM Thumbnail",则仅删除缩略图。以下是实现我的目标的完整代码:

from org.dspace.curate import ScriptedTask
from org.dspace.curate import Curator
from org.dspace.content.service import DSpaceObjectService
from org.dspace.content.factory import ContentServiceFactory

#from org.dspace.content.service import BitstreamService

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

    def performDso(self, dso):
        #print "perform on dso "
        if dso.getType()==2:
            print "Item '" + dso.getName() + "' ("+dso.getHandle()+")"
            myBundles = dso.itemService.getBundles(dso,"THUMBNAIL")
            totalbundles = len(myBundles)
            for i in myBundles:
                myBitstreams = i.getBitstreams()
                total = len(myBitstreams)
                if len(myBitstreams)==0:
                    print "- DELETING EMPTY BUNDLE"
            dso.itemService.removeBundle(Curator.curationContext(),dso,myBundles[0])
            if len(myBitstreams)>0:
                for k in range(0,len(myBitstreams)):
                    if myBitstreams[k].getDescription() == 'IM Thumbnail':
                        print "DELETE "+myBitstreams[0].getDescription()
                        bitstreamService = ContentServiceFactory.getInstance().getBitstreamService()
                        bitstreamService.delete(Curator.curationContext(),myBitstreams[0])
                        print "- DELETING BUNDLE"
                        dso.itemService.removeBundle(Curator.curationContext(),dso,myBundles[0])
        return 0

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

请注意,上面的代码是使用 Jython 作为管理任务制作的,因此可以在此处找到有关如何设置和使用的文档:Curation tasks in Jython