Search in sources :

Example 16 with ModerationRequest

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

the class ProjectModerationRequestGenerator method setAdditionsAndDeletions.

@Override
public ModerationRequest setAdditionsAndDeletions(ModerationRequest request, Project updateProject, Project actualProject) {
    updateDocument = updateProject;
    actualDocument = actualProject;
    documentAdditions = new Project();
    documentDeletions = new Project();
    // required fields:
    documentAdditions.setName(updateProject.getName());
    documentAdditions.setId(actualProject.getId());
    documentDeletions.setName(actualProject.getName());
    documentDeletions.setId(actualProject.getId());
    for (Project._Fields field : Project._Fields.values()) {
        if (Project.metaDataMap.get(field).valueMetaData.type == TType.BOOL || Project.metaDataMap.get(field).valueMetaData.type == TType.I32) {
            if (actualDocument.getFieldValue(field) != updateDocument.getFieldValue(field)) {
                documentAdditions.setFieldValue(field, updateDocument.getFieldValue(field));
                documentDeletions.setFieldValue(field, actualDocument.getFieldValue(field));
            }
        } else if (actualProject.getFieldValue(field) == null) {
            documentAdditions.setFieldValue(field, updateProject.getFieldValue(field));
        } else if (updateProject.getFieldValue(field) == null) {
            documentDeletions.setFieldValue(field, actualProject.getFieldValue(field));
        } else if (!actualProject.getFieldValue(field).equals(updateProject.getFieldValue(field))) {
            switch(field) {
                // ignored fields and concluded fields
                case PERMISSIONS:
                case DOCUMENT_STATE:
                case RELEASE_CLEARING_STATE_SUMMARY:
                    break;
                case ATTACHMENTS:
                    dealWithAttachments(Project._Fields.ATTACHMENTS);
                    break;
                case LINKED_PROJECTS:
                    dealWithEnumMap(Project._Fields.LINKED_PROJECTS, ProjectRelationship.class);
                    break;
                case RELEASE_ID_TO_USAGE:
                    dealWithStringKeyedMap(Project._Fields.RELEASE_ID_TO_USAGE);
                    break;
                case ROLES:
                    dealWithCustomMap(Project._Fields.ROLES);
                    break;
                default:
                    dealWithBaseTypes(field, Project.metaDataMap.get(field));
            }
        }
    }
    request.setProjectAdditions(documentAdditions);
    request.setProjectDeletions(documentDeletions);
    return request;
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) ProjectRelationship(org.eclipse.sw360.datahandler.thrift.projects.ProjectRelationship)

Example 17 with ModerationRequest

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

the class LicenseDatabaseHandler method getLicenseForOrganisationWithOwnModerationRequests.

public License getLicenseForOrganisationWithOwnModerationRequests(String id, String organisation, User user) throws SW360Exception {
    List<ModerationRequest> moderationRequestsForDocumentId = moderator.getModerationRequestsForDocumentId(id);
    License license = getLicenseForOrganisation(id, organisation);
    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();
            license = moderator.updateLicenseFromModerationRequest(license, moderationRequest.getLicenseAdditions(), moderationRequest.getLicenseDeletions(), organisation);
            for (Todo todo : license.getTodos()) {
                // remove other organisations from whitelist of todo
                todo.setWhitelist(SW360Utils.filterBUSet(organisation, todo.whitelist));
            }
            documentState = CommonUtils.getModeratedDocumentState(moderationRequest);
        } else {
            documentState = new DocumentState().setIsOriginalDocument(true).setModerationState(moderationRequestsForDocumentId.get(0).getModerationState());
        }
    }
    license.setPermissions(makePermission(license, user).getPermissionMap());
    license.setDocumentState(documentState);
    return license;
}
Also used : CommonUtils.isTemporaryTodo(org.eclipse.sw360.datahandler.common.CommonUtils.isTemporaryTodo) ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Example 18 with ModerationRequest

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

the class ModerationHandler method setInProgress.

@Override
public void setInProgress(String requestId, User user) throws TException {
    ModerationRequest request = handler.getRequest(requestId);
    request.setModerationState(ModerationState.INPROGRESS);
    request.setReviewer(user.getEmail());
    handler.updateModerationRequest(request);
}
Also used : ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Example 19 with ModerationRequest

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

the class ModerationHandler method removeUserFromAssignees.

@Override
public RemoveModeratorRequestStatus removeUserFromAssignees(String requestId, User user) throws TException {
    ModerationRequest request = handler.getRequest(requestId);
    if (request.getModerators().size() == 1) {
        return RemoveModeratorRequestStatus.LAST_MODERATOR;
    }
    request.getModerators().remove(user.getEmail());
    request.setModerationState(ModerationState.PENDING);
    request.unsetReviewer();
    handler.updateModerationRequest(request);
    return RemoveModeratorRequestStatus.SUCCESS;
}
Also used : ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Example 20 with ModerationRequest

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

the class CommonUtils method getModeratedDocumentState.

@NotNull
public static DocumentState getModeratedDocumentState(ModerationRequest moderationRequest) {
    DocumentState documentState = new DocumentState().setIsOriginalDocument(false);
    documentState.setModerationState(moderationRequest.getModerationState());
    return documentState;
}
Also used : DocumentState(org.eclipse.sw360.datahandler.thrift.DocumentState) NotNull(org.jetbrains.annotations.NotNull)

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