mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Finish GET endpoints
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
package org.dspace.app.rest.converter;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.dspace.app.rest.model.BitstreamRest;
|
||||
import org.dspace.app.rest.model.BundleRest;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BundleConverter
|
||||
extends DSpaceObjectConverter<org.dspace.content.Bundle, org.dspace.app.rest.model.BundleRest> {
|
||||
|
||||
@Autowired
|
||||
BitstreamConverter bitstreamConverter;
|
||||
|
||||
protected BundleRest newInstance() {
|
||||
return new BundleRest();
|
||||
}
|
||||
@@ -18,6 +25,17 @@ public class BundleConverter
|
||||
|
||||
public BundleRest fromModel(Bundle obj) {
|
||||
BundleRest bundle = (BundleRest) super.fromModel(obj);
|
||||
|
||||
bundle.setBitstreams(obj.getBitstreams()
|
||||
.stream()
|
||||
.map(x -> bitstreamConverter.fromModel(x))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
if (obj.getPrimaryBitstream() != null) {
|
||||
BitstreamRest primaryBitstreamRest = bitstreamConverter.fromModel(obj.getPrimaryBitstream());
|
||||
bundle.setPrimaryBitstream(primaryBitstreamRest);
|
||||
}
|
||||
|
||||
return bundle;
|
||||
}
|
||||
|
||||
|
@@ -2,8 +2,8 @@ package org.dspace.app.rest.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Item;
|
||||
|
||||
/**
|
||||
* The Bundle REST Resource
|
||||
@@ -15,9 +15,14 @@ public class BundleRest extends DSpaceObjectRest {
|
||||
public static final String NAME = "bundle";
|
||||
public static final String CATEGORY = RestAddressableModel.CORE;
|
||||
|
||||
private Bitstream primaryBitstream;
|
||||
private List<Bitstream> bitstreams;
|
||||
private List<Item> items;
|
||||
private BitstreamRest primaryBitstream;
|
||||
private List<BitstreamRest> bitstreams;
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String getId() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return CATEGORY;
|
||||
@@ -27,28 +32,25 @@ public class BundleRest extends DSpaceObjectRest {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
public Bitstream getPrimaryBitstream() {
|
||||
|
||||
@JsonIgnore
|
||||
@LinkRest(linkClass = Bitstream.class)
|
||||
public BitstreamRest getPrimaryBitstream() {
|
||||
return primaryBitstream;
|
||||
}
|
||||
|
||||
public void setPrimaryBitstream(Bitstream primaryBitstream) {
|
||||
public void setPrimaryBitstream(BitstreamRest primaryBitstream) {
|
||||
this.primaryBitstream = primaryBitstream;
|
||||
}
|
||||
|
||||
public List<Bitstream> getBitstreams() {
|
||||
@LinkRest(linkClass = Bitstream.class)
|
||||
@JsonIgnore
|
||||
public List<BitstreamRest> getBitstreams() {
|
||||
return bitstreams;
|
||||
}
|
||||
|
||||
public void setBitstreams(List<Bitstream> bitstreams) {
|
||||
public void setBitstreams(List<BitstreamRest> bitstreams) {
|
||||
this.bitstreams = bitstreams;
|
||||
}
|
||||
|
||||
public List<Item> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<Item> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ public class BundleRestRepository extends DSpaceObjectRestRepository<Bundle, Bun
|
||||
}
|
||||
|
||||
public Class<BundleRest> getDomainClass() {
|
||||
return null;
|
||||
return BundleRest.class;
|
||||
}
|
||||
|
||||
public DSpaceResource<BundleRest> wrapResource(BundleRest model, String... rels) {
|
||||
|
Reference in New Issue
Block a user