org.dspace.content.Bundle.getBitstreams()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中org.dspace.content.Bundle.getBitstreams()方法的一些代码示例,展示了Bundle.getBitstreams()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.getBitstreams()方法的具体详情如下:
包路径:org.dspace.content.Bundle
类名称:Bundle
方法名:getBitstreams

Bundle.getBitstreams介绍

[英]Get a copy of the bitstream list of this bundle Note that this is a copy and if you wish to manipulate the bistream list, you should use Bundle.addBitstream, Bundle.removeBitstream or Bundle.clearBitstreams
[中]获取此捆绑包的位流列表的副本请注意,这是一个副本,如果希望操作双流列表,则应使用捆绑包。addBitstream,Bundle。移除比特流或绑定。clearBitstreams

代码示例

代码示例来源:origin: DSpace/DSpace

@Override
public boolean hasUploadedFiles(Item item) throws SQLException {
  List<Bundle> bundles = getBundles(item, "ORIGINAL");
  for (Bundle bundle : bundles) {
    if (CollectionUtils.isNotEmpty(bundle.getBitstreams())) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: DSpace/DSpace

@Override
public Bitstream getFirstBitstream(Item item, String bundleName) throws SQLException {
  List<Bundle> bundles = itemService.getBundles(item, bundleName);
  if (CollectionUtils.isNotEmpty(bundles)) {
    List<Bitstream> bitstreams = bundles.get(0).getBitstreams();
    if (CollectionUtils.isNotEmpty(bitstreams)) {
      return bitstreams.get(0);
    }
  }
  return null;
}

代码示例来源:origin: DSpace/DSpace

@Override
public List<ResourcePolicy> getBitstreamPolicies(Context context, Bundle bundle) throws SQLException {
  List<ResourcePolicy> list = new ArrayList<ResourcePolicy>();
  List<Bitstream> bitstreams = bundle.getBitstreams();
  if (CollectionUtils.isNotEmpty(bitstreams)) {
    for (Bitstream bs : bitstreams) {
      list.addAll(authorizeService.getPolicies(context, bs));
    }
  }
  return list;
}

代码示例来源:origin: DSpace/DSpace

@Override
public Bitstream getBitstreamByName(Bundle bundle, String name) {
  Bitstream target = null;
  for (Bitstream bitstream : bundle.getBitstreams()) {
    if (name.equals(bitstream.getName())) {
      target = bitstream;
      break;
    }
  }
  return target;
}

代码示例来源:origin: DSpace/DSpace

@Override
public Bitstream getBitstreamByName(Item item, String bundleName, String bitstreamName) throws SQLException {
  List<Bundle> bundles = itemService.getBundles(item, bundleName);
  for (int i = 0; i < bundles.size(); i++) {
    Bundle bundle = bundles.get(i);
    List<Bitstream> bitstreams = bundle.getBitstreams();
    for (int j = 0; j < bitstreams.size(); j++) {
      Bitstream bitstream = bitstreams.get(j);
      if (StringUtils.equals(bitstream.getName(), bitstreamName)) {
        return bitstream;
      }
    }
  }
  return null;
}

代码示例来源:origin: DSpace/DSpace

private void archiveBundle(Context context, Item item, Bundle source)
  throws SQLException, AuthorizeException, IOException {
  // get the datestamped root bundle name
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  String oldName = "VER" + sdf.format(new Date());
  oldName = this.getNumberedName(item, oldName, 0);
  Bundle old = bundleService.create(context, item, oldName);
  List<Bitstream> bitstreams = source.getBitstreams();
  for (Bitstream bitstream : bitstreams) {
    bundleService
      .addBitstream(context, old, bitstream);
  }
}

代码示例来源:origin: DSpace/DSpace

static int countBitstream(BundleName bundleName, Item item) {
  int count = 0;
  for (Bundle bundle : item.getBundles()) {
    if (!bundle.getName().equals(bundleName.name())) {
      continue;
    }
    count += bundle.getBitstreams().size();
  }
  return count;
}

代码示例来源:origin: org.dspace/dspace-jspui-api

private static Bitstream getItemBitstreamByName(Item item, String bsName)
            throws SQLException
{
  Bundle[] bundles = item.getBundles();
  for (int i = 0; i < bundles.length; i++)
  {
    Bitstream[] bitstreams = bundles[i].getBitstreams();
    for (int k = 0; k < bitstreams.length; k++)
    {
      if (bsName.equals(bitstreams[k].getName()))
      {
        return bitstreams[k];
      }
    }
  }
  return null;
}

代码示例来源:origin: DSpace/DSpace

static List<String> getBitstreamNames(BundleName bundleName, Item item) {
  ArrayList<String> names = new ArrayList<String>();
  for (Bundle bundle : item.getBundles()) {
    if (!bundle.getName().equals(bundleName.name())) {
      continue;
    }
    for (Bitstream bit : bundle.getBitstreams()) {
      names.add(bit.getName());
    }
  }
  return names;
}

代码示例来源:origin: DSpace/DSpace

@Override
public boolean filterItem(Context context, Item myItem) throws Exception {
  // get 'original' bundles
  List<Bundle> myBundles = itemService.getBundles(myItem, "ORIGINAL");
  boolean done = false;
  for (Bundle myBundle : myBundles) {
    // now look at all of the bitstreams
    List<Bitstream> myBitstreams = myBundle.getBitstreams();
    for (Bitstream myBitstream : myBitstreams) {
      done |= filterBitstream(context, myItem, myBitstream);
    }
  }
  return done;
}

代码示例来源:origin: DSpace/DSpace

private List<String> getFileFormats(Item item) {
  List<String> formats = new ArrayList<>();
  try {
    for (Bundle b : itemService.getBundles(item, "ORIGINAL")) {
      for (Bitstream bs : b.getBitstreams()) {
        if (!formats.contains(bs.getFormat(context).getMIMEType())) {
          formats.add(bs.getFormat(context).getMIMEType());
        }
      }
    }
  } catch (SQLException ex) {
    log.error(ex.getMessage(), ex);
  }
  return formats;
}

代码示例来源:origin: DSpace/DSpace

@Override
public List<Bitstream> getNonInternalBitstreams(Context context, Item item) throws SQLException {
  List<Bitstream> bitstreamList = new ArrayList<>();
  // Go through the bundles and bitstreams picking out ones which aren't
  // of internal formats
  List<Bundle> bunds = item.getBundles();
  for (Bundle bund : bunds) {
    List<Bitstream> bitstreams = bund.getBitstreams();
    for (Bitstream bitstream : bitstreams) {
      if (!bitstream.getFormat(context).isInternal()) {
        // Bitstream is not of an internal format
        bitstreamList.add(bitstream);
      }
    }
  }
  return bitstreamList;
}

代码示例来源:origin: DSpace/DSpace

@Override
protected void performItem(Item item) throws SQLException, IOException {
  for (Bundle bundle : item.getBundles()) {
    for (Bitstream bs : bundle.getBitstreams()) {
      String fmt = bs.getFormat(Curator.curationContext()).getShortDescription();
      Integer count = fmtTable.get(fmt);
      if (count == null) {
        count = 1;
      } else {
        count += 1;
      }
      fmtTable.put(fmt, count);
    }
  }
}

代码示例来源:origin: DSpace/DSpace

@Override
public void replaceAllBitstreamPolicies(Context context, Bundle bundle, List<ResourcePolicy> newpolicies)
  throws SQLException, AuthorizeException {
  List<Bitstream> bitstreams = bundle.getBitstreams();
  if (CollectionUtils.isNotEmpty(bitstreams)) {
    for (Bitstream bs : bitstreams) {
      // change bitstream policies
      authorizeService.removeAllPolicies(context, bs);
      authorizeService.addPolicies(context, newpolicies, bs);
    }
  }
  // change bundle policies
  authorizeService.removeAllPolicies(context, bundle);
  authorizeService.addPolicies(context, newpolicies, bundle);
}

代码示例来源:origin: DSpace/DSpace

static int countBitstreamMimeStartsWith(Context context, BundleName bundleName, Item item, String prefix) {
  int count = 0;
  try {
    for (Bundle bundle : item.getBundles()) {
      if (!bundle.getName().equals(bundleName.name())) {
        continue;
      }
      for (Bitstream bit : bundle.getBitstreams()) {
        if (bit.getFormat(context).getMIMEType().startsWith(prefix)) {
          count++;
        }
      }
    }
  } catch (SQLException e) {
    // ignore
  }
  return count;
}

代码示例来源:origin: DSpace/DSpace

protected void addPolicyToItem(Context context, Item item, int type, EPerson epa, String policyType)
  throws AuthorizeException, SQLException {
  if (epa != null) {
    authorizeService.addPolicy(context, item, type, epa, policyType);
    List<Bundle> bundles = item.getBundles();
    for (Bundle bundle : bundles) {
      authorizeService.addPolicy(context, bundle, type, epa, policyType);
      List<Bitstream> bits = bundle.getBitstreams();
      for (Bitstream bit : bits) {
        authorizeService.addPolicy(context, bit, type, epa, policyType);
      }
    }
  }
}

代码示例来源:origin: DSpace/DSpace

protected void addGroupPolicyToItem(Context context, Item item, int type, Group group)
  throws AuthorizeException, SQLException {
  if (group != null) {
    authorizeService.addPolicy(context, item, type, group);
    List<Bundle> bundles = item.getBundles();
    for (Bundle bundle : bundles) {
      authorizeService.addPolicy(context, bundle, type, group);
      List<Bitstream> bits = bundle.getBitstreams();
      for (Bitstream bit : bits) {
        authorizeService.addPolicy(context, bit, type, group);
      }
    }
  }
}

代码示例来源:origin: DSpace/DSpace

protected void removeGroupItemPolicies(Context context, Item item, Group e)
  throws SQLException, AuthorizeException {
  if (e != null) {
    //Also remove any lingering authorizations from this user
    authorizeService.removeGroupPolicies(context, item, e);
    //Remove the bundle rights
    List<Bundle> bundles = item.getBundles();
    for (Bundle bundle : bundles) {
      authorizeService.removeGroupPolicies(context, bundle, e);
      List<Bitstream> bitstreams = bundle.getBitstreams();
      for (Bitstream bitstream : bitstreams) {
        authorizeService.removeGroupPolicies(context, bitstream, e);
      }
    }
  }
}

代码示例来源:origin: DSpace/DSpace

@Override
public void removeGroupPolicies(Context context, Item item, Group group) throws SQLException, AuthorizeException {
  // remove Group's policies from Item
  authorizeService.removeGroupPolicies(context, item, group);
  // remove all policies from bundles
  List<Bundle> bunds = item.getBundles();
  for (Bundle mybundle : bunds) {
    List<Bitstream> bs = mybundle.getBitstreams();
    for (Bitstream bitstream : bs) {
      // remove bitstream policies
      authorizeService.removeGroupPolicies(context, bitstream, group);
    }
    // change bundle policies
    authorizeService.removeGroupPolicies(context, mybundle, group);
  }
}

代码示例来源:origin: DSpace/DSpace

private void buildFullTextList(Item parentItem) {
  // now get full text of any bitstreams in the TEXT bundle
  // trundle through the bundles
  List<Bundle> myBundles = parentItem.getBundles();
  for (Bundle myBundle : emptyIfNull(myBundles)) {
    if (StringUtils.equals(FULLTEXT_BUNDLE, myBundle.getName())) {
      // a-ha! grab the text out of the bitstreams
      List<Bitstream> bitstreams = myBundle.getBitstreams();
      for (Bitstream fulltextBitstream : emptyIfNull(bitstreams)) {
        fullTextStreams.add(new FullTextBitstream(sourceInfo, fulltextBitstream));
        log.debug("Added BitStream: "
               + fulltextBitstream.getStoreNumber() + " "
               + fulltextBitstream.getSequenceID() + " "
               + fulltextBitstream.getName());
      }
    }
  }
}

相关文章