Search in sources :

Example 6 with ReleaseLink

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);
}
Also used : WrappedTException(org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException) TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor) ReleaseLink(org.eclipse.sw360.datahandler.thrift.components.ReleaseLink) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Example 7 with ReleaseLink

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);
}
Also used : Release(org.eclipse.sw360.datahandler.thrift.components.Release) Link(org.springframework.hateoas.Link)

Example 8 with ReleaseLink

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);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProjectReleaseRelationship(org.eclipse.sw360.datahandler.thrift.ProjectReleaseRelationship) HashMap(java.util.HashMap) Map(java.util.Map) ProjectController(org.eclipse.sw360.rest.resourceserver.project.ProjectController)

Aggregations

ReleaseLink (org.eclipse.sw360.datahandler.thrift.components.ReleaseLink)3 TException (org.apache.thrift.TException)2 Release (org.eclipse.sw360.datahandler.thrift.components.Release)2 ProjectLink (org.eclipse.sw360.datahandler.thrift.projects.ProjectLink)2 User (org.eclipse.sw360.datahandler.thrift.users.User)2 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)2 Link (org.springframework.hateoas.Link)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ExecutorService (java.util.concurrent.ExecutorService)1 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)1 ProjectReleaseRelationship (org.eclipse.sw360.datahandler.thrift.ProjectReleaseRelationship)1 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)1 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)1 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)1 HalResource (org.eclipse.sw360.rest.resourceserver.core.HalResource)1 ProjectController (org.eclipse.sw360.rest.resourceserver.project.ProjectController)1 Test (org.junit.Test)1