This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • development/sharing/codeability-sharing-platform
1 result
Show changes
Showing
with 432 additions and 188 deletions
......@@ -16,6 +16,7 @@ import org.springframework.util.Assert;
*/
public class GitSearchOAuth2AuthorizationRequestRepository implements AuthorizationRequestRepository<OAuth2AuthorizationRequest> {
private static final String REQUEST_CANNOT_BE_NULL = "request cannot be null";
public static final String REFERER_ATTRIBUTE = "referer";
/**
* TODO this should be persisted in the database!
......@@ -24,12 +25,11 @@ public class GitSearchOAuth2AuthorizationRequestRepository implements Authorizat
@Override
public OAuth2AuthorizationRequest loadAuthorizationRequest(HttpServletRequest request) {
Assert.notNull(request, "request cannot be null");
Assert.notNull(request, REQUEST_CANNOT_BE_NULL);
String stateParameter = this.getStateParameter(request);
if (stateParameter == null) {
return null;
}
// Map<String, OAuth2AuthorizationRequest> authorizationRequests = this.getAuthorizationRequests(request);
return authorizationRequests.get(stateParameter);
}
......@@ -39,7 +39,7 @@ public class GitSearchOAuth2AuthorizationRequestRepository implements Authorizat
HttpServletRequest request,
HttpServletResponse response
) {
Assert.notNull(request, "request cannot be null");
Assert.notNull(request, REQUEST_CANNOT_BE_NULL);
Assert.notNull(response, "response cannot be null");
if (authorizationRequest == null) {
this.removeAuthorizationRequest(request, response);
......@@ -57,20 +57,16 @@ public class GitSearchOAuth2AuthorizationRequestRepository implements Authorizat
.from(authorizationRequest)
.attributes(requestAttributes)
.build();
// authorizationRequest.getAttributes().put("referer", referrer);
// Map<String, OAuth2AuthorizationRequest> authorizationRequests = this.getAuthorizationRequests(request);
authorizationRequests.put(state, extendedAuthorizationRequest);
// request.getSession().setAttribute(this.sessionAttributeName, authorizationRequests);
}
@Override
public OAuth2AuthorizationRequest removeAuthorizationRequest(HttpServletRequest request) {
Assert.notNull(request, "request cannot be null");
Assert.notNull(request, REQUEST_CANNOT_BE_NULL);
String stateParameter = this.getStateParameter(request);
if (stateParameter == null) {
return null;
}
// Map<String, OAuth2AuthorizationRequest> authorizationRequests = this.getAuthorizationRequests(request);
return authorizationRequests.remove(stateParameter);
}
......
......@@ -48,7 +48,7 @@ public class SavedRequestAwareAuthenticationSuccessHandlerWithJWTSupport extends
List<GrantedAuthority> roles = new ArrayList<>();
roles.addAll(authentication.getAuthorities());
if (gitLabGroups != null) {
roles.addAll(gitLabGroups.stream().map(g -> new SimpleGrantedAuthority(g)).collect(Collectors.toList()));
roles.addAll(gitLabGroups.stream().map(SimpleGrantedAuthority::new).collect(Collectors.toList()));
}
DefaultOidcUser emailUser = new DefaultOidcUser(roles, principal.getIdToken(), principal.getUserInfo(), "email");
......@@ -105,9 +105,9 @@ public class SavedRequestAwareAuthenticationSuccessHandlerWithJWTSupport extends
*/
private static final long serialVersionUID = -791646857551363545L;
private final Principal principal;
private final transient Principal principal;
Collection<? extends GrantedAuthority> authorities;
private final transient Collection<? extends GrantedAuthority> authorities;
private boolean authenticated = false;
......
......@@ -2,7 +2,6 @@ package at.ac.uibk.gitsearch.service;
import at.ac.uibk.gitsearch.domain.User;
import at.ac.uibk.gitsearch.repository.jpa.AuthorityRepository;
import at.ac.uibk.gitsearch.repository.jpa.UserRepository;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -21,9 +20,10 @@ public class AuthorityService {
this.authorityRepository = authorityRepository;
}
// Get all users with authority ROLE_REVIEW_MANAGER
List<User> findAllUsersWithAuthority(String authority) {
log.info("Request to get all users with authority: {}", authority);
return authorityRepository.findAllUsersWithAuthority(authority);
log.info("Finding all users with authority: {}", authority);
List<User> users = authorityRepository.findAllUsersWithAuthority(authority);
log.info("Found {} users with authority: {}", users.size(), authority);
return users;
}
}
......@@ -26,7 +26,7 @@ public class EditorialPagesService {
public static final String PAGES_CACHE = "pages";
private static final String editorialProject = "infrastructure/GitSearchEditorialPages";
private static final String EDITORIAL_PROJECT_NAME = "infrastructure/GitSearchEditorialPages";
@Autowired
@SuppressWarnings("PMD.ImmutableField")
......@@ -36,7 +36,7 @@ public class EditorialPagesService {
public EditorialPageDTO getContent(String path) throws GitLabApiException {
String encodedPath;
encodedPath = URLEncoder.encode(path, StandardCharsets.UTF_8);
final WikiPage page = gitLabRepository.getAdminGitLabApi().getWikisApi().getPage(editorialProject, encodedPath);
final WikiPage page = gitLabRepository.getAdminGitLabApi().getWikisApi().getPage(EDITORIAL_PROJECT_NAME, encodedPath);
return new EditorialPageDTO(path, page.getContent());
}
......
......@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@Service
@SuppressWarnings({ "PMD.GodClass", "PMD.CognitiveComplexity", "PMD.CyclomaticComplexity", "PMD.NPathComplexity" })
@SuppressWarnings({ "PMD.GodClass", "PMD.CognitiveComplexity", "PMD.CyclomaticComplexity", "PMD.NPathComplexity", "PMD.TooManyMethods" })
public class ExerciseImportService {
private static final String DIFFICULTY = "difficulty";
......@@ -320,8 +320,8 @@ public class ExerciseImportService {
* @param exerciseInfo of the imported exercise
*/
private void sanitizeExerciseInfo(ArtemisExerciseInfo exerciseInfo) {
exerciseInfo.setMetadataVersion(exerciseInfo.getMetadataVersion());
exerciseInfo.setTitle(replaceTagCharacters(exerciseInfo.getTitle()));
exerciseInfo.setMetadataVersion(sanitize(exerciseInfo.getMetadataVersion()));
exerciseInfo.setTitle(replaceTagCharacters(sanitize(exerciseInfo.getTitle())));
exerciseInfo.setDescription(replaceTagCharacters(exerciseInfo.getDescription()));
if (exerciseInfo.getKeyword() != null) {
exerciseInfo.setKeyword(exerciseInfo.getKeyword().stream().map(this::replaceTagCharacters).collect(Collectors.toList()));
......@@ -344,6 +344,20 @@ public class ExerciseImportService {
exerciseInfo.setLearningResourceType(replaceTagCharacters(exerciseInfo.getLearningResourceType()));
}
/**
* this is a very poor sanitazion script. Better would be to use the OWASP
* sanitizer.
*
* @param s
* @return
*/
private String sanitize(String s) {
if (s.contains("<script")) {
return "tainted HTML not accepted";
}
return s;
}
/**
* Method used to validate the exercise information of the imported exercise
*
......
......@@ -12,7 +12,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.stream.Collectors;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import org.codeability.sharing.plugins.api.search.SearchResultDTO;
import org.slf4j.Logger;
......@@ -22,7 +21,6 @@ import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.mail.MailException;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.mail.javamail.MimeMessageHelper;
......@@ -124,7 +122,7 @@ public class MailService {
javaMailSender.send(mimeMessage);
log.debug("Sent email to User '{}'", to);
return true;
} catch (MailException | MessagingException e) {
} catch (Exception e) {
log.warn("Email could not be sent to user '{}'", to, e);
return false;
}
......
......@@ -95,9 +95,9 @@ public class ReviewRatingQueryService extends QueryService<ReviewRating> {
if (criteria.getId() != null) {
specification = specification.and(buildRangeSpecification(criteria.getId(), ReviewRating_.id));
}
if (criteria.getComment() != null) {
specification = specification.and(buildStringSpecification(criteria.getComment(), ReviewRating_.comment));
}
// if (criteria.getComment() != null) {
// specification = specification.and(buildStringSpecification(criteria.getComment(), ReviewRating_.comment));
// }
if (criteria.getStatus() != null) {
specification = specification.and(buildSpecification(criteria.getStatus(), ReviewRating_.status));
}
......
package at.ac.uibk.gitsearch.service;
import at.ac.uibk.gitsearch.domain.Review;
import at.ac.uibk.gitsearch.domain.ReviewComment;
import at.ac.uibk.gitsearch.domain.ReviewHistoryEntry;
import at.ac.uibk.gitsearch.domain.ReviewRating;
import at.ac.uibk.gitsearch.domain.User;
......@@ -20,6 +21,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import javax.transaction.Transactional;
import org.slf4j.Logger;
......@@ -74,19 +76,19 @@ public class ReviewService {
review.setRequestedBy(loggedInUser.getId());
Set<ReviewRating> reviewRatings = new HashSet<>();
ReviewComment comment = new ReviewComment();
reviewRequest
.getUsers()
.stream()
.map(email -> {
return userService
.getUserByEmail(email)
.orElseThrow(() -> new UsernameNotFoundException("Cannot find user with email " + email));
})
.map(email ->
userService.getUserByEmail(email).orElseThrow(() -> new UsernameNotFoundException("Cannot find user with email " + email))
)
.forEach(user -> {
ReviewRating reviewRating = new ReviewRating();
reviewRating.setReview(review);
reviewRating.setUser(user);
reviewRating.setComment("");
reviewRating.setComment(comment);
reviewRating.setStatus(ReviewStatus.REVIEW_IN_PROGRESS);
reviewRatings.add(reviewRating);
review.setComments(reviewRatings);
......@@ -115,15 +117,14 @@ public class ReviewService {
}
Review review = reviewO.get();
review
.getComments()
.stream()
.forEach(reviewRating -> {
reviewRating.setStatus(status);
addHistoryEntry(review, reviewRating, userService.getUserWithAuthorities(), status, "");
List<ReviewRating> reviewRatings = review.getComments().stream().collect(Collectors.toList());
reviewRatingRepository.save(reviewRating);
});
for (ReviewRating reviewRating : reviewRatings) {
reviewRating.setStatus(status);
addHistoryEntry(review, reviewRating, userService.getUserWithAuthorities(), status, "");
reviewRatingRepository.save(reviewRating);
}
}
public void updateReview(ReviewDTO review) {
......@@ -142,6 +143,26 @@ public class ReviewService {
reviewEntity.setResource(review.getResource());
reviewEntity.setLink(review.getLink());
ReviewComment comment = new ReviewComment();
comment.setDescriptionIsClear(false);
comment.setRequirementsAreClear(false);
comment.setDescriptionComment("");
comment.setInformationRequiredComplete(false);
comment.setAllMaterialsAvailable(false);
comment.setInformationRequiredComment("");
comment.setIsStructured(false);
comment.setSubExercisesAreClear(false);
comment.setStructuredComment("");
comment.setSolutionIsCorrect(false);
comment.setSolutionComment("");
comment.setMetadataIsComplete(false);
comment.setMetadataIsCorrect(false);
comment.setMetadataComment("");
review
.getUsers()
.stream()
......@@ -150,13 +171,13 @@ public class ReviewService {
ReviewRating reviewRating = new ReviewRating();
reviewRating.setReview(reviewEntity);
reviewRating.setUser(userService.getUserByEmail(email).get());
reviewRating.setComment("");
reviewRating.setComment(comment);
reviewRating.setStatus(ReviewStatus.REVIEW_IN_PROGRESS);
Optional<User> userO = userService.getUserWithAuthorities();
addHistoryEntry(reviewEntity, reviewRating, userO, ReviewStatus.REVIEW_IN_PROGRESS, "Reviewer(s) assigned");
reviewRatingRepository.save(reviewRating);
});
reviewEntity.setComments(new HashSet<>(reviewRatingRepository.findByReview(reviewEntity.getId())));
reviewRepository.save(reviewEntity);
notifyReviewers(
......@@ -206,6 +227,7 @@ public class ReviewService {
return new ArrayList<>();
}
List<ReviewRating> reviewRating = reviewRatingRepository.findAllByUserId(user.getId());
AtomicInteger reviewerCount = new AtomicInteger(1);
List<ReviewDTO> reviewRatingDTOs = reviewRating
.stream()
......@@ -217,7 +239,7 @@ public class ReviewService {
Arrays.asList(user.getEmail()),
Arrays.asList(reviewRating1.getStatus().name()),
Arrays.asList(reviewRating1.getComment()),
"ANONYMIZED"
"Reviewer " + reviewerCount.getAndIncrement()
);
StatisticsDTO stats = statisticsService.findOneByExerciseID(reviewRating1.getReview().getResourceID()).orElse(null);
if (stats == null) {
......@@ -248,7 +270,9 @@ public class ReviewService {
.stream()
.forEach(review -> {
review.setRequestedBy(user.getEmail());
review.setUsers(review.getUsers().stream().map(x -> "ANONYMIZED").collect(Collectors.toList()));
review.setUsers(
review.getUsers().stream().map(x -> "Reviewer " + reviewerCount.getAndIncrement()).collect(Collectors.toList())
);
});
reviewDTOs.addAll(reviewRatingDTOs);
return reviewDTOs;
......@@ -275,17 +299,17 @@ public class ReviewService {
* @return
*/
public ReviewRatingDTO.ReviewStatisticsDTO getReviewStatusCountsByUser(User user) {
List<StatusAndCount> counts = reviewRatingRepository.countReviewsForUserByStatus(user);
List<StatusAndCount> counts = reviewRatingRepository.countReviewsForUserByStatus(user.getId());
ReviewRatingDTO.ReviewStatisticsDTO result = new ReviewRatingDTO.ReviewStatisticsDTO();
counts.forEach(entry -> result.put(entry.getStatus(), entry.getStatusCount()));
List<StatusAndCount> countsForRequestingUser = reviewRatingRepository.countReviewsForRequestingUserByStatus(user.getId());
countsForRequestingUser.forEach(entry -> result.putByUser(entry.getStatus(), entry.getStatusCount()));
List<StatusAndCount> countsForRequestingUser = reviewRatingRepository.countReviewsTasksForUserByStatus(user);
countsForRequestingUser.forEach(entry -> result.putByReviewer(entry.getStatus(), entry.getStatusCount()));
Integer badgeCount = reviewRatingRepository.countBadgesForRequestingUser(user.getId());
if (badgeCount != null) {
result.setBadgesRewarded(badgeCount);
result.setReviewsRequestedByUser(reviewRatingRepository.countReviewsRequestedByUser(user.getId()) - badgeCount);
result.setReviewsAssignedToReviewer(reviewRatingRepository.countreviewsRequestedByReviewer(user.getId()) - badgeCount);
}
return result;
}
......@@ -293,6 +317,10 @@ public class ReviewService {
@SuppressWarnings("PMD.PrematureDeclaration") // false positive
public void updateReviewRatingByUser(ReviewDTO reviewDTO) throws IllegalAccessException {
LOGGER.debug("REST request to update a review by user");
if (reviewDTO.getId() == null) {
LOGGER.warn("Review ID is null, terminating update");
return;
}
User user = userService
.getUserWithAuthorities()
.orElseThrow(() -> new UsernameNotFoundException("User not found, unable to update ReviewRating"));
......@@ -384,11 +412,29 @@ public class ReviewService {
);
}
public void requestReviewForExercise(ReviewRequest request) {
public void removeBadge(Long id) {
Review review = reviewRepository.findById(id).orElseThrow();
updateStatus(review.getId(), ReviewStatus.REVIEW_IN_PROGRESS);
statisticsService.removeBadgeForStatisticsByExerciseID(review.getResourceID());
notifyReviewers(
review.getId(),
EMAIL_START +
review.getResource() +
" has been removed from the badge list and is no longer displayed when people search for it."
);
notifyRequester(
review.getId(),
EMAIL_START +
review.getResource() +
" has been removed from the badge list and is no longer displayed when people search for it."
);
}
public boolean requestReviewForExercise(ReviewRequest request) {
String id = request.getResource();
if (reviewRepository.findOneByResource(id).isPresent()) {
LOGGER.warn("Review already exists for exercise: {}", id);
return;
return false;
}
Review review = new Review();
......@@ -401,7 +447,7 @@ public class ReviewService {
review.setRequestedBy(userO.get().getId());
} else {
LOGGER.error("User not found");
return;
return false;
}
Set<ReviewRating> reviewRatings = new HashSet<>();
review.setComments(reviewRatings);
......@@ -417,6 +463,7 @@ public class ReviewService {
false
);
}
return true;
}
private void addHistoryEntry(
......
......@@ -2,7 +2,6 @@ package at.ac.uibk.gitsearch.service;
import at.ac.uibk.gitsearch.domain.SavedSearches;
import at.ac.uibk.gitsearch.repository.jpa.SavedSearchesRepository;
import at.ac.uibk.gitsearch.repository.search.SavedSearchesSearchRepository;
import at.ac.uibk.gitsearch.service.dto.SavedSearchesDTO;
import at.ac.uibk.gitsearch.service.mapper.SavedSearchesMapper;
import java.util.Optional;
......@@ -26,16 +25,9 @@ public class SavedSearchesService {
private final SavedSearchesMapper savedSearchesMapper;
private final SavedSearchesSearchRepository savedSearchesSearchRepository;
public SavedSearchesService(
SavedSearchesRepository savedSearchesRepository,
SavedSearchesMapper savedSearchesMapper,
SavedSearchesSearchRepository savedSearchesSearchRepository
) {
public SavedSearchesService(SavedSearchesRepository savedSearchesRepository, SavedSearchesMapper savedSearchesMapper) {
this.savedSearchesRepository = savedSearchesRepository;
this.savedSearchesMapper = savedSearchesMapper;
this.savedSearchesSearchRepository = savedSearchesSearchRepository;
}
/**
......@@ -48,9 +40,20 @@ public class SavedSearchesService {
log.debug("Request to save SavedSearches : {}", savedSearchesDTO);
SavedSearches savedSearches = savedSearchesMapper.toEntity(savedSearchesDTO);
savedSearches = savedSearchesRepository.save(savedSearches);
SavedSearchesDTO result = savedSearchesMapper.toDto(savedSearches);
savedSearchesSearchRepository.save(savedSearches);
return result;
return savedSearchesMapper.toDto(savedSearches);
}
/**
* Update a savedSearches.
*
* @param savedSearchesDTO the entity to save.
* @return the persisted entity.
*/
public SavedSearchesDTO update(SavedSearchesDTO savedSearchesDTO) {
log.debug("Request to update SavedSearches : {}", savedSearchesDTO);
SavedSearches savedSearches = savedSearchesMapper.toEntity(savedSearchesDTO);
savedSearches = savedSearchesRepository.save(savedSearches);
return savedSearchesMapper.toDto(savedSearches);
}
/**
......@@ -70,11 +73,6 @@ public class SavedSearchesService {
return existingSavedSearches;
})
.map(savedSearchesRepository::save)
.map(savedSavedSearches -> {
savedSearchesSearchRepository.save(savedSavedSearches);
return savedSavedSearches;
})
.map(savedSearchesMapper::toDto);
}
......@@ -110,19 +108,17 @@ public class SavedSearchesService {
public void delete(Long id) {
log.debug("Request to delete SavedSearches : {}", id);
savedSearchesRepository.deleteById(id);
savedSearchesSearchRepository.deleteById(id);
}
/**
* Search for the savedSearches corresponding to the query.
*
* @param query the query of the search.
* @param pageable the pagination information.
* @return the list of entities.
*/
@Transactional(readOnly = true)
public Page<SavedSearchesDTO> search(String query, Pageable pageable) {
log.debug("Request to search for a page of SavedSearches for query {}", query);
return savedSearchesSearchRepository.search(query, pageable).map(savedSearchesMapper::toDto);
}
// /**
// * Search for the savedSearches corresponding to the query.
// *
// * @param query the query of the search.
// * @param pageable the pagination information.
// * @return the list of entities.
// */
// @Transactional(readOnly = true)
// public Page<SavedSearchesDTO> search(String query, Pageable pageable) {
// log.debug("Request to search for a page of SavedSearches for query {}", query);
// return savedSearchesSearchRepository.search(query, pageable).map(savedSearchesMapper::toDto);
// }
}
......@@ -219,7 +219,6 @@ public class SearchService {
metaData.getMetadata().setImage(baseUrl + "/content/img/python.png");
return;
}
// metaData.getMetadata().setImage(baseUrl + "/content/img/gitLab.png");
metaData.getMetadata().setImage(baseUrl + "/content/images/Logo_codeAbility_4c_300dpi_RGB3.gif");
return;
} catch (URISyntaxException e) {
......@@ -347,24 +346,4 @@ public class SearchService {
return metaDataRepository.streamResults(emptySearchQuery, Optional.empty(), false).getSearchStream();
}
/**
* Method to search for all public exercises.
* Searches all public exercises with an empty search query and without a
* specified user.
*
* @return the search result page DTO
* @throws IOException
* @deprecated not really reliable, because it does only return the first page
* of results.
*/
@Deprecated
public SearchResultsDTO searchAllPublicResults() throws IOException {
log.debug("Search request to find all public exercises");
final SearchInputMetadataDTO emptySearchMetadata = new SearchInputMetadataDTO(null, null, null, null, null, null);
SearchInputDTO emptySearchQuery = new SearchInputDTO(null, emptySearchMetadata, null, null, null, 0);
return metaDataRepository.pageDetailsWithJavaApi(emptySearchQuery, Optional.empty());
}
}
......@@ -2,7 +2,6 @@ package at.ac.uibk.gitsearch.service;
import at.ac.uibk.gitsearch.domain.Statistics;
import at.ac.uibk.gitsearch.repository.jpa.StatisticsRepository;
import at.ac.uibk.gitsearch.repository.search.StatisticsSearchRepository;
import at.ac.uibk.gitsearch.service.dto.StatisticsDTO;
import java.util.List;
import java.util.Optional;
......@@ -24,9 +23,6 @@ public class StatisticsService {
@Autowired
private StatisticsRepository statisticsRepository;
@Autowired
private StatisticsSearchRepository statisticsSearchRepository;
/**
* Save a statistics.
*
......@@ -88,6 +84,24 @@ public class StatisticsService {
}
}
public void removeBadgeForStatisticsByExerciseID(String exerciseID) {
Optional<Statistics> statistics = statisticsRepository.findByExerciseID(exerciseID);
if (statistics.isPresent()) {
Statistics statistics1 = statistics.get();
statistics1.setBadgeRewarded(false);
statisticsRepository.save(statistics1);
log.debug("Badge removed for exercise: {}", exerciseID);
} else {
log.debug("No statistics found for exercise: {}", exerciseID);
Statistics statistics1 = new Statistics();
statistics1.setExerciseID(exerciseID);
statistics1.setBadgeRewarded(false);
statistics1.setDownloads(0);
statistics1.setViews(0);
statisticsRepository.save(statistics1);
}
}
/**
* Delete the "id" statistics.
*
......@@ -96,7 +110,6 @@ public class StatisticsService {
public void delete(Long id) {
log.debug("Request to delete Statistics : {}", id);
statisticsRepository.deleteById(id);
statisticsSearchRepository.deleteById(id);
}
/**
......
......@@ -12,7 +12,6 @@ import at.ac.uibk.gitsearch.service.dto.AdminUserDTO;
import at.ac.uibk.gitsearch.service.dto.UserDTO;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
......@@ -239,7 +238,6 @@ public class UserService {
userAuthorities.stream().filter(auth -> !allAuthorities.contains(auth)).forEach(authorityRepository::save);
user.setAuthorities(userAuthorities);
userRepository.save(user);
// userSearchRepository.save(user);
this.clearUserCaches(user);
log.debug("Changed Information for User: {}", user);
......
......@@ -2,7 +2,6 @@ package at.ac.uibk.gitsearch.service;
import at.ac.uibk.gitsearch.domain.WatchListEntry;
import at.ac.uibk.gitsearch.repository.jpa.WatchListEntryRepository;
import at.ac.uibk.gitsearch.repository.search.WatchListEntrySearchRepository;
import at.ac.uibk.gitsearch.service.dto.WatchListEntryDTO;
import at.ac.uibk.gitsearch.service.mapper.WatchListEntryMapper;
import java.util.List;
......@@ -27,16 +26,9 @@ public class WatchListEntryService {
private final WatchListEntryMapper watchListEntryMapper;
private final WatchListEntrySearchRepository watchListEntrySearchRepository;
public WatchListEntryService(
WatchListEntryRepository watchListEntryRepository,
WatchListEntryMapper watchListEntryMapper,
WatchListEntrySearchRepository watchListEntrySearchRepository
) {
public WatchListEntryService(WatchListEntryRepository watchListEntryRepository, WatchListEntryMapper watchListEntryMapper) {
this.watchListEntryRepository = watchListEntryRepository;
this.watchListEntryMapper = watchListEntryMapper;
this.watchListEntrySearchRepository = watchListEntrySearchRepository;
}
/**
......@@ -49,9 +41,7 @@ public class WatchListEntryService {
log.debug("Request to save WatchListEntry : {}", watchListEntryDTO);
WatchListEntry watchListEntry = watchListEntryMapper.toEntity(watchListEntryDTO);
watchListEntry = watchListEntryRepository.save(watchListEntry);
WatchListEntryDTO result = watchListEntryMapper.toDto(watchListEntry);
watchListEntrySearchRepository.save(watchListEntry);
return result;
return watchListEntryMapper.toDto(watchListEntry);
}
/**
......@@ -86,7 +76,6 @@ public class WatchListEntryService {
public void delete(Long id) {
log.debug("Request to delete WatchListEntry : {}", id);
watchListEntryRepository.deleteById(id);
watchListEntrySearchRepository.deleteById(id);
}
/**
......
......@@ -33,6 +33,8 @@ public class ReviewRatingCriteria implements Serializable, Criteria {
*/
public static class ReviewStatusFilter extends Filter<ReviewStatus> {
private static final long serialVersionUID = -921625240809457753L;
public ReviewStatusFilter() {
super();
}
......
package at.ac.uibk.gitsearch.service.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Objects;
import java.util.regex.Pattern;
......@@ -61,6 +62,7 @@ public class MetadataUserDTO {
return "MetadataUserDTO{" + "name='" + name + '\'' + ", affiliation='" + affiliation + '\'' + ", email='" + email + '\'' + '}';
}
@JsonIgnore // hope, this is also valid for YAML :-(
public boolean isValid() {
String emailRegex = "^[A-Za-z0-9+_.-]+@(.+)$";
......
package at.ac.uibk.gitsearch.service.dto;
import java.io.Serializable;
public class ReviewCommentDTO implements Serializable {
private static final long serialVersionUID = -6905288704011546610L;
private Long id;
private Boolean descriptionIsClear;
private Boolean requirementsAreClear;
private String descriptionComment;
private Boolean informationRequiredComplete;
private Boolean allMaterialsAvailable;
private String informationRequiredComment;
private Boolean isStructured;
private Boolean subExercisesAreClear;
private String structuredComment;
private Boolean solutionIsCorrect;
private String solutionComment;
private Boolean metadataIsComplete;
private Boolean metadataIsCorrect;
private String metadataComment;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Boolean getDescriptionIsClear() {
return descriptionIsClear;
}
public void setDescriptionIsClear(Boolean descriptionIsClear) {
this.descriptionIsClear = descriptionIsClear;
}
public Boolean getRequirementsAreClear() {
return requirementsAreClear;
}
public void setRequirementsAreClear(Boolean requirementsAreClear) {
this.requirementsAreClear = requirementsAreClear;
}
public String getDescriptionComment() {
return descriptionComment;
}
public void setDescriptionComment(String descriptionComment) {
this.descriptionComment = descriptionComment;
}
public Boolean getInformationRequiredComplete() {
return informationRequiredComplete;
}
public void setInformationRequiredComplete(Boolean informationRequiredComplete) {
this.informationRequiredComplete = informationRequiredComplete;
}
public Boolean getAllMaterialsAvailable() {
return allMaterialsAvailable;
}
public void setAllMaterialsAvailable(Boolean allMaterialsAvailable) {
this.allMaterialsAvailable = allMaterialsAvailable;
}
public String getInformationRequiredComment() {
return informationRequiredComment;
}
public void setInformationRequiredComment(String informationRequiredComment) {
this.informationRequiredComment = informationRequiredComment;
}
public Boolean getIsStructured() {
return isStructured;
}
public void setIsStructured(Boolean isStructured) {
this.isStructured = isStructured;
}
public Boolean getSubExercisesAreClear() {
return subExercisesAreClear;
}
public void setSubExercisesAreClear(Boolean subExercisesAreClear) {
this.subExercisesAreClear = subExercisesAreClear;
}
public String getStructuredComment() {
return structuredComment;
}
public void setStructuredComment(String structuredComment) {
this.structuredComment = structuredComment;
}
public Boolean getSolutionIsCorrect() {
return solutionIsCorrect;
}
public void setSolutionIsCorrect(Boolean solutionIsCorrect) {
this.solutionIsCorrect = solutionIsCorrect;
}
public String getSolutionComment() {
return solutionComment;
}
public void setSolutionComment(String solutionComment) {
this.solutionComment = solutionComment;
}
public Boolean getMetadataIsComplete() {
return metadataIsComplete;
}
public void setMetadataIsComplete(Boolean metadataIsComplete) {
this.metadataIsComplete = metadataIsComplete;
}
public Boolean getMetadataIsCorrect() {
return metadataIsCorrect;
}
public void setMetadataIsCorrect(Boolean metadataIsCorrect) {
this.metadataIsCorrect = metadataIsCorrect;
}
public String getMetadataComment() {
return metadataComment;
}
public void setMetadataComment(String metadataComment) {
this.metadataComment = metadataComment;
}
}
package at.ac.uibk.gitsearch.service.dto;
import at.ac.uibk.gitsearch.domain.ReviewComment;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
......@@ -25,13 +26,13 @@ public class ReviewDTO implements Serializable {
private Long id;
private List<String> users;
private List<String> status;
private List<String> comments;
private List<ReviewComment> comments;
private String requestedBy;
private Boolean badgeRewarded;
public ReviewDTO() {}
public ReviewDTO(Long id, String resource, List<String> users, List<String> status, List<String> comments) {
public ReviewDTO(Long id, String resource, List<String> users, List<String> status, List<ReviewComment> comments) {
this.id = id;
this.resource = resource;
this.users = users;
......@@ -39,7 +40,7 @@ public class ReviewDTO implements Serializable {
this.comments = comments;
}
public ReviewDTO(Long id, String resource, List<String> users, List<String> status, List<String> comments, String requestedBy) {
public ReviewDTO(Long id, String resource, List<String> users, List<String> status, List<ReviewComment> comments, String requestedBy) {
this.id = id;
this.resource = resource;
this.users = users;
......@@ -54,7 +55,7 @@ public class ReviewDTO implements Serializable {
String link,
List<String> users,
List<String> status,
List<String> comments,
List<ReviewComment> comments,
String requestedBy
) {
this.id = id;
......@@ -73,7 +74,7 @@ public class ReviewDTO implements Serializable {
String link,
List<String> users,
List<String> status,
List<String> comments,
List<ReviewComment> comments,
String requestedBy,
Boolean badgeRewarded
) {
......@@ -93,7 +94,7 @@ public class ReviewDTO implements Serializable {
String link,
List<String> users,
List<String> status,
List<String> comments,
List<ReviewComment> comments,
String requestedBy,
Boolean badgeRewarded,
String resourceID
......@@ -198,11 +199,11 @@ public class ReviewDTO implements Serializable {
this.status = status;
}
public List<String> getComments() {
public List<ReviewComment> getComments() {
return comments;
}
public void setComments(List<String> comments) {
public void setComments(List<ReviewComment> comments) {
this.comments = comments;
}
......
package at.ac.uibk.gitsearch.service.dto;
import at.ac.uibk.gitsearch.domain.ReviewComment;
import at.ac.uibk.gitsearch.domain.enumeration.ReviewStatus;
import java.io.Serializable;
import java.util.Objects;
......@@ -15,7 +16,7 @@ public class ReviewRatingDTO implements Serializable {
private Long id;
private String comment;
private ReviewCommentDTO comment;
private ReviewStatus status;
......@@ -31,11 +32,11 @@ public class ReviewRatingDTO implements Serializable {
this.id = id;
}
public String getComment() {
public ReviewCommentDTO getComment() {
return comment;
}
public void setComment(String comment) {
public void setComment(ReviewCommentDTO comment) {
this.comment = comment;
}
......@@ -116,15 +117,19 @@ public class ReviewRatingDTO implements Serializable {
* Review completed
*/
private int reviewInProgress = 0;
private int reviewImprovementRequested = 0;
private int reviewImproved = 0;
private int reviewCompleted = 0;
private int reviewRequested = 0;
private int unknownStats = 0;
private int reviewsRequestedByUser = 0;
private int reviewInProgressByUser = 0;
private int reviewImprovementRequestedByUser = 0;
private int reviewCompletedByUser = 0;
private int unknownStatsByUser = 0;
private int reviewsAssignedToReviewer = 0;
private int reviewImprovedForReviewer = 0;
private int reviewRejectedByReviewer = 0;
private int reviewInProgressByReviewer = 0;
private int reviewImprovementRequestedByReviewer = 0;
private int reviewCompletedByReviewer = 0;
private int unkownStatsByReviewer = 0;
private int badgesRewarded = 0;
......@@ -161,83 +166,91 @@ public class ReviewRatingDTO implements Serializable {
}
public void put(ReviewStatus status, int count) {
switch (status) {
case REVIEW_IN_PROGRESS:
reviewInProgress = count;
break;
case REVIEW_IMPROVED:
reviewImproved = count;
break;
case REVIEW_COMPLETED:
reviewCompleted = count;
break;
default:
LOGGER.error("status {} not yet supported!", status);
unknownStats += count;
break;
if (status == null) {
reviewRequested = count;
} else {
switch (status) {
case REVIEW_IN_PROGRESS:
setReviewInProgress(count);
break;
case REVIEW_IMPROVED:
setReviewImproved(count);
break;
case REVIEW_COMPLETED:
setReviewCompleted(count);
break;
case REVIEW_REJECTED:
setReviewCompleted(count);
break;
case IMPROVEMENTS_REQUESTED:
setReviewImprovementRequested(count);
break;
default:
LOGGER.error("status {} not yet supported!", status);
setUnknownStats(getUnknownStats() + count);
break;
}
}
}
public void putByUser(ReviewStatus status, int count) {
if (status == null) {
reviewsRequestedByUser = count;
public void putByReviewer(ReviewStatus status, int count) {
if (status == null) { // this should never happen
LOGGER.error("Empty status for Reviewer?");
return;
}
switch (status) {
case REVIEW_IMPROVED:
setReviewImprovedForReviewer(count);
break;
case REVIEW_REJECTED:
setReviewRejectedByReviewer(count);
break;
case REVIEW_IN_PROGRESS:
reviewInProgressByUser = count;
setReviewInProgressByReviewer(count);
break;
case IMPROVEMENTS_REQUESTED:
reviewImprovementRequestedByUser = count;
setReviewImprovementRequestedByReviewer(count);
break;
case REVIEW_COMPLETED:
reviewCompletedByUser = count;
setReviewCompletedByReviewer(count);
break;
default:
LOGGER.error("status {} not yet supported!", status);
unknownStats += count;
setUnkownStatsByReviewer(getUnkownStatsByReviewer() + count);
break;
}
}
public int getReviewsRequestedByUser() {
return reviewsRequestedByUser;
public int getReviewInProgressByReviewer() {
return reviewInProgressByReviewer;
}
public void setReviewsRequestedByUser(int reviewsRequestedByUser) {
this.reviewsRequestedByUser = reviewsRequestedByUser;
public void setReviewInProgressByReviewer(int reviewInProgressByReviewer) {
this.reviewInProgressByReviewer = reviewInProgressByReviewer;
}
public int getReviewInProgressByUser() {
return reviewInProgressByUser;
public int getReviewCompletedByReviewer() {
return reviewCompletedByReviewer;
}
public void setReviewInProgressByUser(int reviewInProgressByUser) {
this.reviewInProgressByUser = reviewInProgressByUser;
public void setReviewCompletedByReviewer(int reviewCompletedByReviewer) {
this.reviewCompletedByReviewer = reviewCompletedByReviewer;
}
public int getReviewCompletedByUser() {
return reviewCompletedByUser;
public int getUnkownStatsByReviewer() {
return unkownStatsByReviewer;
}
public void setReviewCompletedByUser(int reviewCompletedByUser) {
this.reviewCompletedByUser = reviewCompletedByUser;
public void setUnkownStatsByReviewer(int unkownStatsByReviewer) {
this.unkownStatsByReviewer = unkownStatsByReviewer;
}
public int getUnknownStatsByUser() {
return unknownStatsByUser;
public int getReviewImprovementRequestedByReviewer() {
return reviewImprovementRequestedByReviewer;
}
public void setUnknownStatsByUser(int unknownStatsByUser) {
this.unknownStatsByUser = unknownStatsByUser;
}
public int getReviewImprovementRequestedByUser() {
return reviewImprovementRequestedByUser;
}
public void setReviewImprovementRequestedByUser(int reviewImprovementRequestedByUser) {
this.reviewImprovementRequestedByUser = reviewImprovementRequestedByUser;
public void setReviewImprovementRequestedByReviewer(int reviewImprovementRequestedByReviewer) {
this.reviewImprovementRequestedByReviewer = reviewImprovementRequestedByReviewer;
}
public int getBadgesRewarded() {
......@@ -247,5 +260,45 @@ public class ReviewRatingDTO implements Serializable {
public void setBadgesRewarded(int badgedRewarded) {
this.badgesRewarded = badgedRewarded;
}
public int getReviewRequested() {
return reviewRequested;
}
public void setReviewRequested(int reviewRequested) {
this.reviewRequested = reviewRequested;
}
public int getReviewRejectedByReviewer() {
return reviewRejectedByReviewer;
}
public void setReviewRejectedByReviewer(int reviewRejectedByReviewer) {
this.reviewRejectedByReviewer = reviewRejectedByReviewer;
}
public int getReviewImprovedForReviewer() {
return reviewImprovedForReviewer;
}
public void setReviewImprovedForReviewer(int reviewImprovedByReviewer) {
this.reviewImprovedForReviewer = reviewImprovedByReviewer;
}
public int getReviewsAssignedToReviewer() {
return reviewsAssignedToReviewer;
}
public void setReviewsAssignedToReviewer(int reviewsAssignedToReviewer) {
this.reviewsAssignedToReviewer = reviewsAssignedToReviewer;
}
public int getReviewImprovementRequested() {
return reviewImprovementRequested;
}
public void setReviewImprovementRequested(int reviewImprovementRequested) {
this.reviewImprovementRequested = reviewImprovementRequested;
}
}
}
......@@ -7,10 +7,10 @@ public class ReviewRequest implements Serializable {
private static final long serialVersionUID = 6273672415826123481L;
String resource;
String link;
String resourceID;
List<String> users;
private String resource;
private String link;
private String resourceID;
private List<String> users;
public ReviewRequest() {}
......
package at.ac.uibk.gitsearch.service.mapper;
import at.ac.uibk.gitsearch.domain.ReviewComment;
import at.ac.uibk.gitsearch.service.dto.ReviewCommentDTO;
import org.mapstruct.Mapper;
@Mapper(componentModel = "spring")
public interface ReviewCommentMapper {
ReviewComment toEntity(ReviewCommentDTO dto);
ReviewCommentDTO toDto(ReviewComment entity);
}