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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations