Search in sources :

Example 21 with ModerationRequest

use of org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest in project sw360portal by sw360.

the class ComponentDatabaseHandler method getComponentForEdit.

public Component getComponentForEdit(String id, User user) throws SW360Exception {
    List<ModerationRequest> moderationRequestsForDocumentId = moderator.getModerationRequestsForDocumentId(id);
    Component component = getComponent(id, user);
    DocumentState documentState;
    if (moderationRequestsForDocumentId.isEmpty()) {
        documentState = CommonUtils.getOriginalDocumentState();
    } else {
        final String email = user.getEmail();
        Optional<ModerationRequest> moderationRequestOptional = CommonUtils.getFirstModerationRequestOfUser(moderationRequestsForDocumentId, email);
        if (moderationRequestOptional.isPresent() && isInProgressOrPending(moderationRequestOptional.get())) {
            ModerationRequest moderationRequest = moderationRequestOptional.get();
            component = moderator.updateComponentFromModerationRequest(component, moderationRequest.getComponentAdditions(), moderationRequest.getComponentDeletions());
            documentState = CommonUtils.getModeratedDocumentState(moderationRequest);
        } else {
            documentState = new DocumentState().setIsOriginalDocument(true).setModerationState(moderationRequestsForDocumentId.get(0).getModerationState());
        }
    }
    component.setPermissions(makePermission(component, user).getPermissionMap());
    component.setDocumentState(documentState);
    return component;
}
Also used : ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Example 22 with ModerationRequest

use of org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest in project sw360portal by sw360.

the class ComponentDatabaseHandler method getReleaseForEdit.

public Release getReleaseForEdit(String id, User user) throws SW360Exception {
    List<ModerationRequest> moderationRequestsForDocumentId = moderator.getModerationRequestsForDocumentId(id);
    Release release = getRelease(id, user);
    DocumentState documentState;
    if (moderationRequestsForDocumentId.isEmpty()) {
        documentState = CommonUtils.getOriginalDocumentState();
    } else {
        final String email = user.getEmail();
        Optional<ModerationRequest> moderationRequestOptional = CommonUtils.getFirstModerationRequestOfUser(moderationRequestsForDocumentId, email);
        if (moderationRequestOptional.isPresent() && isInProgressOrPending(moderationRequestOptional.get())) {
            ModerationRequest moderationRequest = moderationRequestOptional.get();
            release = releaseModerator.updateReleaseFromModerationRequest(release, moderationRequest.getReleaseAdditions(), moderationRequest.getReleaseDeletions());
            documentState = CommonUtils.getModeratedDocumentState(moderationRequest);
        } else {
            documentState = new DocumentState().setIsOriginalDocument(true).setModerationState(moderationRequestsForDocumentId.get(0).getModerationState());
        }
    }
    vendorRepository.fillVendor(release);
    release.setPermissions(makePermission(release, user).getPermissionMap());
    release.setDocumentState(documentState);
    ensureEccInformationIsSet(release);
    return release;
}
Also used : ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Example 23 with ModerationRequest

use of org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest in project sw360portal by sw360.

the class ProjectDatabaseHandler method getProjectForEdit.

public Project getProjectForEdit(String id, User user) throws SW360Exception {
    List<ModerationRequest> moderationRequestsForDocumentId = moderator.getModerationRequestsForDocumentId(id);
    Project project = getProjectById(id, user);
    DocumentState documentState;
    if (moderationRequestsForDocumentId.isEmpty()) {
        documentState = CommonUtils.getOriginalDocumentState();
    } else {
        final String email = user.getEmail();
        Optional<ModerationRequest> moderationRequestOptional = CommonUtils.getFirstModerationRequestOfUser(moderationRequestsForDocumentId, email);
        if (moderationRequestOptional.isPresent() && isInProgressOrPending(moderationRequestOptional.get())) {
            ModerationRequest moderationRequest = moderationRequestOptional.get();
            project = moderator.updateProjectFromModerationRequest(project, moderationRequest.getProjectAdditions(), moderationRequest.getProjectDeletions());
            documentState = CommonUtils.getModeratedDocumentState(moderationRequest);
        } else {
            documentState = new DocumentState().setIsOriginalDocument(true).setModerationState(moderationRequestsForDocumentId.get(0).getModerationState());
        }
    }
    project.setPermissions(makePermission(project, user).getPermissionMap());
    project.setDocumentState(documentState);
    return project;
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Example 24 with ModerationRequest

use of org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest in project sw360portal by sw360.

the class MyTaskAssignmentsPortlet method doView.

@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
    List<ModerationRequest> openModerations = null;
    try {
        User user = UserCacheHolder.getUserFromRequest(request);
        List<ModerationRequest> moderations = thriftClients.makeModerationClient().getRequestsByModerator(user);
        openModerations = moderations.stream().filter(ModerationPortletUtils::isOpenModerationRequest).collect(Collectors.toList());
    } catch (TException e) {
        log.error("Could not fetch your moderations from backend", e);
    }
    request.setAttribute(PortalConstants.MODERATION_REQUESTS, CommonUtils.nullToEmptyList(openModerations));
    super.doView(request, response);
}
Also used : TException(org.apache.thrift.TException) ModerationPortletUtils(org.eclipse.sw360.portal.portlets.moderation.ModerationPortletUtils) ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest) User(org.eclipse.sw360.datahandler.thrift.users.User)

Example 25 with ModerationRequest

use of org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest in project sw360portal by sw360.

the class ModerationPortlet method renderLicenseModeration.

public void renderLicenseModeration(RenderRequest request, RenderResponse response, ModerationRequest moderationRequest, User user) throws IOException, PortletException, TException {
    License actual_license = null;
    User requestingUser = UserCacheHolder.getUserFromEmail(moderationRequest.getRequestingUser());
    try {
        LicenseService.Iface client = thriftClients.makeLicenseClient();
        actual_license = client.getByID(moderationRequest.getDocumentId(), requestingUser.getDepartment());
        request.setAttribute(KEY_LICENSE_DETAIL, actual_license);
        List<Obligation> obligations = client.getObligations();
        request.setAttribute(KEY_OBLIGATION_LIST, obligations);
    } catch (TException e) {
        log.error("Could not retrieve license", e);
    }
    if (actual_license == null) {
        renderNextModeration(request, response, user, "Ignored unretrievable target", thriftClients.makeModerationClient(), moderationRequest);
        return;
    }
    include("/html/moderation/licenses/merge.jsp", request, response);
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) Obligation(org.eclipse.sw360.datahandler.thrift.licenses.Obligation) LicenseService(org.eclipse.sw360.datahandler.thrift.licenses.LicenseService) License(org.eclipse.sw360.datahandler.thrift.licenses.License)

Aggregations

ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)24 TException (org.apache.thrift.TException)11 User (org.eclipse.sw360.datahandler.thrift.users.User)8 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)5 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)4 Component (org.eclipse.sw360.datahandler.thrift.components.Component)4 ModerationService (org.eclipse.sw360.datahandler.thrift.moderation.ModerationService)4 Release (org.eclipse.sw360.datahandler.thrift.components.Release)3 License (org.eclipse.sw360.datahandler.thrift.licenses.License)3 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)2 Organization (com.liferay.portal.model.Organization)1 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)1 TProtocol (org.apache.thrift.protocol.TProtocol)1 THttpClient (org.apache.thrift.transport.THttpClient)1 CommonUtils.isTemporaryTodo (org.eclipse.sw360.datahandler.common.CommonUtils.isTemporaryTodo)1 DatabaseConnector (org.eclipse.sw360.datahandler.couchdb.DatabaseConnector)1 DocumentState (org.eclipse.sw360.datahandler.thrift.DocumentState)1 COTSDetails (org.eclipse.sw360.datahandler.thrift.components.COTSDetails)1 LicenseService (org.eclipse.sw360.datahandler.thrift.licenses.LicenseService)1 Obligation (org.eclipse.sw360.datahandler.thrift.licenses.Obligation)1