public <T extends DcsEntity> T add(T entity) { if (entity.getId() == null) { entity.setId(PREFIX + ++counter); } else { for (DcsEntity e : getEntities()) { if (e.getId().equals(entity.getId())) { throw new IllegalArgumentException("There is already an entity with id " + e.getId()); } } } if (entity instanceof DcsCollection) { dcp.addCollection((DcsCollection) entity); } else if (entity instanceof DcsDeliverableUnit) { dcp.addDeliverableUnit((DcsDeliverableUnit) entity); } else if (entity instanceof DcsEvent) { dcp.addEvent((DcsEvent) entity); } else if (entity instanceof DcsFile) { dcp.addFile((DcsFile) entity); } else if (entity instanceof DcsManifestation) { dcp.addManifestation((DcsManifestation) entity); } else { throw new RuntimeException("unexpected entity " + entity.getClass()); } return entity; }
/** * Places the supplied entities in the backing map, keyed by their alternate identifiers. * * @param entities the entities to add in the backing map */ protected void mapAlternateIds(DcsEntity... entities) { for (DcsEntity e : entities) { for (DcsResourceIdentifier altId : e.getAlternateIds()) { Set<DcsEntity> value; if (entityMap.containsKey(altId.getIdValue())) { value = entityMap.get(altId.getIdValue()); } else { value = new HashSet<DcsEntity>(); } value.add(e); entityMap.put(altId.getIdValue(), value); } } }
HierarchicalPrettyPrinter hpp = new HierarchicalPrettyPrinter(); for (DcsEntity e : dcp) { e.toString(hpp);
HierarchicalPrettyPrinter hpp = new HierarchicalPrettyPrinter(); for (DcsEntity e : dcp) { e.toString(hpp);
/** * Places the supplied entities in the backing map, keyed by their entity identifiers. * * @param entities the entities to add in the backing map */ protected void mapEntityIds(DcsEntity... entities) { for (DcsEntity e : entities) { Set<DcsEntity> value; if (entityMap.containsKey(e.getId())) { value = entityMap.get(e.getId()); } else { value = new HashSet<DcsEntity>(); } value.add(e); entityMap.put(e.getId(), value); } }
/** * Places the supplied entities in the backing map, keyed by their alternate identifiers. * * @param entities the entities to add in the backing map */ protected void mapAlternateIds(DcsEntity... entities) { for (DcsEntity e : entities) { for (DcsResourceIdentifier altId : e.getAlternateIds()) { Set<DcsEntity> value; if (entityMap.containsKey(altId.getIdValue())) { value = entityMap.get(altId.getIdValue()); } else { value = new HashSet<DcsEntity>(); } value.add(e); entityMap.put(altId.getIdValue(), value); } } }
/** * Places the supplied entities in the backing map, keyed by their entity identifiers. * * @param entities the entities to add in the backing map */ protected void mapEntityIds(DcsEntity... entities) { for (DcsEntity e : entities) { Set<DcsEntity> value; if (entityMap.containsKey(e.getId())) { value = entityMap.get(e.getId()); } else { value = new HashSet<DcsEntity>(); } value.add(e); entityMap.put(e.getId(), value); } }
/** * Copy constructor for a DcsEntity. The state of <code>toCopy</code> is copied * to this. * * @param toCopy the dcs entity to copy, must not be <code>null</code> * @throws IllegalArgumentException if <code>toCopy</code> is <code>null</code> */ public DcsEntity(DcsEntity toCopy) { Assertion.notNull(toCopy); this.id = toCopy.getId(); }
/** * Convenience method, simply delegates to {@link #calculateDigest(java.util.List)}. If the * {@code entities} list is empty, {@code null} is returned. * * @param entities the entities * @return the MD5 digest, or {@code null} if the {@code entities List} is empty. */ public static String calculateDigestForEntities(List<DcsEntity> entities) { if (entities.isEmpty()) { return null; } List<String> ids = new ArrayList<String>(); for (DcsEntity e : entities) { ids.add(e.getId()); } return calculateDigest(ids); }
private void addEvents(Dcp dcp, DcsEntity target) { int numevents = rand.nextInt(2); for (int i = 0; i < numevents; i++) { dcp.addEvent(createEvent(target.getId())); } }
log.trace("Found candidate root DU: {}", entity.getId());
log.trace("Found candidate root DU: {}", entity.getId());
public Map<String, Map<String, String>> getOutboundLinks(DcsEntity entity) { if (entity instanceof DcsCollection) { return toEntityMap(entity.getId(), COLLECTION, getCollectionRels(entity)); } else if (entity instanceof DcsDeliverableUnit) { return toEntityMap(entity.getId(), DELIVERABLE_UNIT, getDeliverableUnitRefs(entity)); } else if (entity instanceof DcsEvent) { return toEntityMap(entity.getId(), EVENT, getEventRefs(entity)); } else if (entity instanceof DcsFile) { return toEntityMap(entity.getId(), FILE, getFileRefs(entity)); } else if (entity instanceof DcsManifestation) { return toEntityMap(entity.getId(), MANIFESTATION, getManifestationRefs(entity)); } else { throw new RuntimeException("Unknown dcs entity type " + entity.getClass()); } }
public Map<String, Map<String, String>> getOutboundLinks(DcsEntity entity) { if (entity instanceof DcsCollection) { return toEntityMap(entity.getId(), COLLECTION, getCollectionRels(entity)); } else if (entity instanceof DcsDeliverableUnit) { return toEntityMap(entity.getId(), DELIVERABLE_UNIT, getDeliverableUnitRefs(entity)); } else if (entity instanceof DcsEvent) { return toEntityMap(entity.getId(), EVENT, getEventRefs(entity)); } else if (entity instanceof DcsFile) { return toEntityMap(entity.getId(), FILE, getFileRefs(entity)); } else if (entity instanceof DcsManifestation) { return toEntityMap(entity.getId(), MANIFESTATION, getManifestationRefs(entity)); } else { throw new RuntimeException("Unknown dcs entity type " + entity.getClass()); } }
private void add_descendants(DcsEntity parent, java.util.Collection<DcsEntity> entities, Set<DcsEntity> result) { if (parent instanceof DcsCollection) { DcsCollectionRef parent_col_ref = new DcsCollectionRef(parent.getId()); DcsDeliverableUnitRef parent_du_ref = new DcsDeliverableUnitRef(parent.getId()); DcsManifestation man = (DcsManifestation) entity; if (man.getDeliverableUnit() != null && man.getDeliverableUnit().equals(parent.getId())) { result.add(entity); add_descendants(entity, entities, result); for (DcsEntity entity : entities) { if (entity instanceof DcsFile) { DcsFileRef file_ref = new DcsFileRef(entity.getId());
private void add_descendants(DcsEntity parent, java.util.Collection<DcsEntity> entities, Set<DcsEntity> result) { if (parent instanceof DcsCollection) { DcsCollectionRef parent_col_ref = new DcsCollectionRef(parent.getId()); DcsDeliverableUnitRef parent_du_ref = new DcsDeliverableUnitRef(parent.getId()); DcsManifestation man = (DcsManifestation) entity; if (man.getDeliverableUnit() != null && man.getDeliverableUnit().equals(parent.getId())) { result.add(entity); add_descendants(entity, entities, result); for (DcsEntity entity : entities) { if (entity instanceof DcsFile) { DcsFileRef file_ref = new DcsFileRef(entity.getId());