org.dspace.content.Bundle类的使用及代码示例

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

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

Bundle介绍

[英]Class representing bundles of bitstreams stored in the DSpace system

The corresponding Bitstream objects are loaded into memory. At present, there is no metadata associated with bundles - they are simple containers. Thus, the update method doesn't do much yet. Creating, adding or removing bitstreams has instant effect in the database.
[中]类,表示存储在DSpace系统中的比特流束
相应的位流对象被加载到内存中。目前,没有与捆绑包关联的元数据-它们是简单的容器。因此,update方法还没有做很多工作。创建、添加或删除位流在数据库中具有即时效果。

代码示例

代码示例来源: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: DSpace/DSpace

@Override
public void delete(Context context, Bundle bundle) throws SQLException, AuthorizeException, IOException {
  log.info(LogManager.getHeader(context, "delete_bundle", "bundle_id="
    + bundle.getID()));
  authorizeService.authorizeAction(context, bundle, Constants.DELETE);
  context.addEvent(new Event(Event.DELETE, Constants.BUNDLE, bundle.getID(),
                bundle.getName(), getIdentifiers(context, bundle)));
  // Remove bitstreams
  List<Bitstream> bitstreams = bundle.getBitstreams();
  bundle.clearBitstreams();
  for (Bitstream bitstream : bitstreams) {
    removeBitstream(context, bundle, bitstream);
  }
  List<Item> items = new LinkedList<>(bundle.getItems());
  bundle.getItems().clear();
  for (Item item : items) {
    item.removeBundle(bundle);
  }
  // Remove ourself
  bundleDAO.delete(context, bundle);
}

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

@Override
public int hashCode() {
  int hash = 5;
  hash += 71 * hash + getType();
  hash += 71 * hash + getID().hashCode();
  return hash;
}

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

@Override
public void update(Context context, Bundle bundle) throws SQLException, AuthorizeException {
  // Check authorisation
  //AuthorizeManager.authorizeAction(ourContext, this, Constants.WRITE);
  log.info(LogManager.getHeader(context, "update_bundle", "bundle_id="
    + bundle.getID()));
  super.update(context, bundle);
  bundleDAO.save(context, bundle);
  if (bundle.isModified() || bundle.isMetadataModified()) {
    if (bundle.isMetadataModified()) {
      context.addEvent(new Event(Event.MODIFY_METADATA, bundle.getType(), bundle.getID(), bundle.getDetails(),
                    getIdentifiers(context, bundle)));
    }
    context.addEvent(new Event(Event.MODIFY, Constants.BUNDLE, bundle.getID(),
                  null, getIdentifiers(context, bundle)));
    bundle.clearModified();
    bundle.clearDetails();
  }
}

代码示例来源: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: org.dspace/dspace-xmlui-api

validityKey.append(bundle.getID());
validityKey.append(bundle.getName());
validityKey.append(bundle.getPrimaryBitstreamID());
for(Bitstream bitstream : bundle.getBitstreams())

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

int bitstreamID = Integer.parseInt(st.nextToken());
Bundle bundle = Bundle.find(context, bundleID);
Bitstream bitstream = Bitstream.find(context, bitstreamID);
  bundle.removeBitstream(bitstream);
  if (bundle.getBitstreams().length == 0)
    bundle.setPrimaryBitstreamID(primaryBitstreamID);
  bundle.update();
Bitstream[] bitstreams = bundle.getBitstreams();
int[] newBitstreamOrder = new int[bitstreams.length];
if (button.equals("submit_update_order")) {
  if(inputKey.startsWith(bundle.getID() + "_")){
    String[] vals = request.getParameter(inputKey).split(",");
    for (int i = 0; i < vals.length; i++) {
  bundle.setOrder(newBitstreamOrder);
  bundle.update();

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

public void deleteBitstream(Context context, Bitstream bitstream)
  throws SwordError, DSpaceSwordException {
  // this is equivalent to asking whether the media resource in the item can be deleted
  try {
    List<Bundle> bundles = bitstream.getBundles();
    for (Bundle bundle : bundles) {
      // is the bitstream in the ORIGINAL bundle?  If not, it can't be worked on
      if (!Constants.CONTENT_BUNDLE_NAME
        .equals(bundle.getName())) {
        throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED,
                   "The file is not in a bundle which can be modified");
      }
      List<Item> items = bundle.getItems();
      for (Item item : items) {
        this.deleteMediaResource(context, item);
      }
    }
  } catch (SQLException e) {
    throw new DSpaceSwordException(e);
  }
}

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

/**
 * Set the item this bundle appears in
 *
 * @return array of <code>Item</code> s this bundle appears in
 */
void addItem(Item item) {
  getItems().add(item);
}

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

bundlePolicies.put(Integer.valueOf(myBundle.getID()), myPolicies);
Bitstream[] bitstreams = myBundle.getBitstreams();

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

throw new DSpaceSWORDException("Orphaned bitstream discovered");
Item[] items = bundles[0].getItems();
if (items.length == 0)
  log.error("Found orphaned bundle: " + bundles[0].getID());
  throw new DSpaceSWORDException("Orphaned bundle discovered");
for (int i = 0; i < lbundles.length; i++)
  Bitstream[] bss = lbundles[i].getBitstreams();
  for (int j = 0; j < bss.length; j++)

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

protected void createBundlesAndAddBitstreams(Context c, Item itemNew, Item nativeItem)
  throws SQLException, AuthorizeException, IOException {
  for (Bundle nativeBundle : nativeItem.getBundles()) {
    Bundle bundleNew = bundleService.create(c, itemNew, nativeBundle.getName());
    authorizeService.addPolicies(c, bundlePolicies, bundleNew);
    for (Bitstream nativeBitstream : nativeBundle.getBitstreams()) {
      authorizeService.addPolicies(c, bitstreamPolicies, bitstreamNew);
      if (nativeBundle.getPrimaryBitstream() != null && nativeBundle.getPrimaryBitstream()
                                     .equals(nativeBitstream)) {
        bundleNew.setPrimaryBitstreamID(bitstreamNew);

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

/**
 * Predicate, does this bundle container meta-information.  I.e.
 * does this bundle contain descriptive metadata or other metadata
 * such as license bitstreams?  If so we probably don't want to put
 * it into the "content" section of a package; hence this predicate.
 *
 * @param bn -- the bundle
 * @return true if this bundle name indicates it is a meta-info bundle.
 */
public static boolean isMetaInfoBundle(Bundle bn) {
  return (bn.getName().equals(Constants.LICENSE_BUNDLE_NAME) ||
    bn.getName().equals(CreativeCommonsService.CC_BUNDLE_NAME) ||
    bn.getName().equals(Constants.METADATA_BUNDLE_NAME));
}

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

protected void deleteBundle(Context context, Item item, Bundle b)
  throws AuthorizeException, SQLException, IOException {
  // Check authorisation
  authorizeService.authorizeAction(context, item, Constants.REMOVE);
  bundleService.delete(context, b);
  log.info(LogManager.getHeader(context, "remove_bundle", "item_id="
    + item.getID() + ",bundle_id=" + b.getID()));
  context
    .addEvent(new Event(Event.REMOVE, Constants.ITEM, item.getID(), Constants.BUNDLE, b.getID(), b.getName()));
}

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

subheader.addCell(null, null, 1, 4, "indent").addHighlight("bold").addContent(T_subhead_bundle.parameterize(bundle.getName(),bundle.getID()));
subheader.addCell().addHighlight("bold").addXref(baseURL + "&submit_add_bundle_" + bundle.getID(), T_add_bundlePolicy_link);
this.rowBuilder(baseURL, table, bundlePolicies, bundle.getID(), Constants.BUNDLE, highlightID);
bitstreams = bundle.getBitstreams();
for (Bitstream bitstream : bitstreams) {
  subheader = table.addRow(null,Row.ROLE_HEADER,"subheader");

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

Bitstream[] bitstreams = bundle.getBitstreams();
  if(inputKey.startsWith(bundle.getID() + "_")){
    String[] vals = request.getParameter(inputKey).split(",");
    for (int i = 0; i < vals.length; i++) {
  bundle.setOrder(newBitstreamOrder);
  bundle.update();

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

authorizeService.authorizeAction(context, bundle, Constants.WRITE);
List<Bitstream> currentBitstreams = bundle.getBitstreams();
List<Bitstream> updatedBitstreams = new ArrayList<Bitstream>();
                   "Bundle: " + bundle.getID() + ", bitstream id: " + bitstreamId));
    continue;
                   "Encountered a bitstream not in this bundle while changing bitstream " +
                     "order. Bitstream order will not be changed.",
                   "Bundle: " + bundle.getID() + ", bitstream id: " + bitstreamId));
    return;
                 "Size of old list and new list do not match. Bitstream order will not be " +
                   "changed.",
                 "Bundle: " + bundle.getID()));
  return;
  bundle.clearBitstreams();
    bundle.addBitstream(bitstream);
    bitstream.getBundles().add(bundle);
    bitstreamService.update(context, bitstream);

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

@Override
public Bundle create(Context context, Item item, String name) throws SQLException, AuthorizeException {
  if (StringUtils.isBlank(name)) {
    throw new SQLException("Bundle must be created with non-null name");
  }
  authorizeService.authorizeAction(context, item, Constants.ADD);
  // Create a table row
  Bundle bundle = bundleDAO.create(context, new Bundle());
  bundle.setName(context, name);
  itemService.addBundle(context, item, bundle);
  if (!bundle.getItems().contains(item)) {
    bundle.addItem(item);
  }
  log.info(LogManager.getHeader(context, "create_bundle", "bundle_id="
    + bundle.getID()));
  // if we ever use the identifier service for bundles, we should
  // create the bundle before we create the Event and should add all
  // identifiers to it.
  context.addEvent(new Event(Event.CREATE, Constants.BUNDLE, bundle.getID(), null));
  return bundle;
}

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

@Override
public void addBundle(Context context, Item item, Bundle bundle) throws SQLException, AuthorizeException {
  // Check authorisation
  authorizeService.authorizeAction(context, item, Constants.ADD);
  log.info(LogManager.getHeader(context, "add_bundle", "item_id="
    + item.getID() + ",bundle_id=" + bundle.getID()));
  // Check it's not already there
  if (item.getBundles().contains(bundle)) {
    // Bundle is already there; no change
    return;
  }
  // now add authorization policies from owning item
  // hmm, not very "multiple-inclusion" friendly
  authorizeService.inheritPolicies(context, item, bundle);
  // Add the bundle to in-memory list
  item.addBundle(bundle);
  bundle.addItem(item);
  context.addEvent(new Event(Event.ADD, Constants.ITEM, item.getID(),
                Constants.BUNDLE, bundle.getID(), bundle.getName(),
                getIdentifiers(context, item)));
}

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

+ bundle.getID() + ",bitstream_id=" + bitstream.getID()));
List<Bitstream> bitstreams = bundle.getBitstreams();
int topOrder = 0;
bundle.addBitstream(bitstream);
bitstream.getBundles().add(bundle);
context.addEvent(new Event(Event.ADD, Constants.BUNDLE, bundle.getID(),
              Constants.BITSTREAM, bitstream.getID(), String.valueOf(bitstream.getSequenceID()),
              getIdentifiers(context, bundle)));

相关文章