use of org.eclipse.sw360.datahandler.thrift.components.ReleaseLink in project sw360portal by sw360.
the class ProjectPortlet method serveNewTableRowLinkedRelease.
@SuppressWarnings("Duplicates")
private void serveNewTableRowLinkedRelease(ResourceRequest request, ResourceResponse response, String[] linkedIds) throws IOException, PortletException {
final User user = UserCacheHolder.getUserFromRequest(request);
List<ReleaseLink> linkedReleases = new ArrayList<>();
try {
ComponentService.Iface client = thriftClients.makeComponentClient();
for (Release release : client.getReleasesById(new HashSet<>(Arrays.asList(linkedIds)), user)) {
final Vendor vendor = release.getVendor();
final String vendorName = vendor != null ? vendor.getShortname() : "";
ReleaseLink linkedRelease = new ReleaseLink(release.getId(), vendorName, release.getName(), release.getVersion(), SW360Utils.printFullname(release), !nullToEmptyMap(release.getReleaseIdToRelationship()).isEmpty());
linkedReleases.add(linkedRelease);
}
} catch (TException e) {
log.error("Error getting releases!", e);
throw new PortletException("cannot get releases " + Arrays.toString(linkedIds), e);
}
request.setAttribute(RELEASE_LIST, linkedReleases);
include("/html/utils/ajax/linkedReleasesAjax.jsp", request, response, PortletRequest.RESOURCE_PHASE);
}
use of org.eclipse.sw360.datahandler.thrift.components.ReleaseLink in project sw360portal by sw360.
the class RestControllerHelper method addEmbeddedRelease.
public void addEmbeddedRelease(HalResource halResource, Release release) {
Release embeddedRelease = convertToEmbeddedRelease(release);
HalResource<Release> halRelease = new HalResource<>(embeddedRelease);
Link releaseLink = linkTo(ReleaseController.class).slash("api/releases/" + release.getId()).withSelfRel();
halRelease.add(releaseLink);
halResource.addEmbeddedResource("sw360:releases", halRelease);
}
use of org.eclipse.sw360.datahandler.thrift.components.ReleaseLink in project sw360portal by sw360.
the class JsonReleaseRelationSerializer method serialize.
@Override
public void serialize(Map<String, ProjectReleaseRelationship> releaseRelationMap, JsonGenerator gen, SerializerProvider provider) throws IOException, JsonProcessingException {
List<Map<String, String>> linkedReleases = new ArrayList<>();
for (Map.Entry<String, ProjectReleaseRelationship> releaseRelation : releaseRelationMap.entrySet()) {
String releaseLink = linkTo(ProjectController.class).slash("api" + ReleaseController.RELEASES_URL + "/" + releaseRelation.getKey()).withSelfRel().getHref();
Map<String, String> linkedRelease = new HashMap<>();
ProjectReleaseRelationship projectReleaseRelationship = releaseRelation.getValue();
linkedRelease.put("relation", projectReleaseRelationship.getReleaseRelation().name());
linkedRelease.put("mainlineState", projectReleaseRelationship.getMainlineState().name());
linkedRelease.put("release", releaseLink);
linkedReleases.add(linkedRelease);
}
gen.writeObject(linkedReleases);
}
Aggregations