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

Skip to content
Snippets Groups Projects
Commit 30ba1423 authored by Michael Breu's avatar Michael Breu :speech_balloon:
Browse files

Intermediate commit

parent dab6ea49
Branches
2 merge requests!188Merging Peer Reviewing et. al to Master,!164211 peer reviewing functionality
{
"fluentMethods": true,
"clientRootFolder": "",
"relationships": [],
"relationships": [
{
"relationshipName": "watchlistId",
"otherEntityName": "userWatchList",
"relationshipType": "many-to-one",
"relationshipValidateRules": ["required"],
"otherEntityField": "id",
"ownerSide": true,
"otherEntityRelationshipName": "watchListEntries"
}
],
"fields": [
{
"fieldName": "exerciseId",
......
package at.ac.uibk.gitsearch.service;
import at.ac.uibk.gitsearch.domain.WatchListEntry;
import at.ac.uibk.gitsearch.repository.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 static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
import static org.elasticsearch.index.query.QueryBuilders.*;
import at.ac.uibk.gitsearch.domain.WatchListEntry;
import at.ac.uibk.gitsearch.repository.WatchListEntryRepository;
import at.ac.uibk.gitsearch.service.dto.WatchListEntryDTO;
import at.ac.uibk.gitsearch.service.mapper.WatchListEntryMapper;
/**
* Service Implementation for managing {@link WatchListEntry}.
......@@ -30,12 +29,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,7 +45,6 @@ public class WatchListEntryService {
WatchListEntry watchListEntry = watchListEntryMapper.toEntity(watchListEntryDTO);
watchListEntry = watchListEntryRepository.save(watchListEntry);
WatchListEntryDTO result = watchListEntryMapper.toDto(watchListEntry);
watchListEntrySearchRepository.save(watchListEntry);
return result;
}
......@@ -88,20 +83,17 @@ public class WatchListEntryService {
public void delete(Long id) {
log.debug("Request to delete WatchListEntry : {}", id);
watchListEntryRepository.deleteById(id);
watchListEntrySearchRepository.deleteById(id);
}
/**
* Search for the watchListEntry corresponding to the query.
* Search for the watchListEntry for a watchlist.
*
* @param query the query of the search.
* @param pageable the pagination information.
* @param id the id of the watchlist.
* @return the list of entities.
*/
@Transactional(readOnly = true)
public Page<WatchListEntryDTO> search(String query, Pageable pageable) {
log.debug("Request to search for a page of WatchListEntries for query {}", query);
return watchListEntrySearchRepository.search(queryStringQuery(query), pageable)
.map(watchListEntryMapper::toDto);
public Page<WatchListEntryDTO> search(Long id) {
log.debug("Request to search for a page of WatchListEntries for query {}", id);
return null;
}
}
......@@ -28,7 +28,7 @@
</div>
<ng-template #helpBookmark> {{ 'exercise.comingSoon' | translate}}</ng-template>
<div class="form-check" style="float: right; padding-right: 10px;" [ngbTooltip]="helpBookmark">
<input class="form-check-input" type="checkbox" value="" id="card-defaultCheck1" disabled>
<input class="form-check-input" type="checkbox" value="" id="card-defaultCheck1" (clicked)="handleForCurrentWatchlist(exercise)">
<label class="form-check-label" for="card-defaultCheck1"></label>
</div>
</div> <!-- card bookmark end-->
......
......@@ -2,6 +2,8 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Exercise } from 'app/shared/model/exercise.model';
import { SearchService } from 'app/search/service/search-service';
import { Statistics } from 'app/shared/model/statistics.model';
import { WatchlistManager } from 'app/shared/watchlist/watchlist-manager';
import { IUserWatchList } from 'app/shared/model/user-watch-list.model';
@Component({
selector: 'jhi-exercise-card',
......@@ -13,7 +15,7 @@ export class ExerciseCardComponent implements OnInit {
@Output() exerciseSelectionEvent = new EventEmitter<Exercise>();
constructor(protected searchService: SearchService) {}
constructor(protected searchService: SearchService, private watchlistManager: WatchlistManager) {}
ngOnInit(): void {}
......@@ -31,6 +33,10 @@ export class ExerciseCardComponent implements OnInit {
}
this.exerciseSelectionEvent.emit(this.exercise);
}
handleForCurrentWatchlist(e: Exercise) {
}
/**
* correct missing image urls
......
import {IWatchListEntry} from './watch-list-entry.model';
export interface IUserWatchList {
id?: number;
name?: string;
......@@ -8,3 +10,7 @@ export interface IUserWatchList {
export class UserWatchList implements IUserWatchList {
constructor(public id?: number, public name?: string, public userIdLogin?: string, public userIdId?: number) {}
}
export class UserWatchListWithContent {
constructor(public userWatchList: UserWatchList, public exerciseIds: Array<IWatchListEntry>) {}
}
......@@ -28,5 +28,9 @@ export class WatchlistComponent {
this.watchlistManager.setCurrentWatchList(watchListName);
}
handleForCurrentWatchlist(exerciseId: string) {
}
}
......@@ -2,9 +2,9 @@ package at.ac.uibk.gitsearch.web.rest;
import at.ac.uibk.gitsearch.GitsearchApp;
import at.ac.uibk.gitsearch.domain.WatchListEntry;
import at.ac.uibk.gitsearch.domain.UserWatchList;
import at.ac.uibk.gitsearch.repository.WatchListEntryRepository;
import at.ac.uibk.gitsearch.repository.search.WatchListEntrySearchRepository;
import at.ac.uibk.gitsearch.security.AuthoritiesConstants;
import at.ac.uibk.gitsearch.service.WatchListEntryService;
import at.ac.uibk.gitsearch.service.dto.WatchListEntryDTO;
import at.ac.uibk.gitsearch.service.mapper.WatchListEntryMapper;
......@@ -31,7 +31,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
import static org.hamcrest.Matchers.hasItem;
import static org.mockito.Mockito.*;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
......@@ -41,7 +40,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@SpringBootTest(classes = GitsearchApp.class)
@ExtendWith(MockitoExtension.class)
@AutoConfigureMockMvc
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
@WithMockUser
public class WatchListEntryResourceIT {
private static final String DEFAULT_EXERCISE_ID = "AAAAAAAAAA";
......@@ -85,6 +84,15 @@ public class WatchListEntryResourceIT {
WatchListEntry watchListEntry = new WatchListEntry()
.exerciseId(DEFAULT_EXERCISE_ID)
.exerciseName(DEFAULT_EXERCISE_NAME);
// Add required entity
UserWatchList userWatchList;
if (TestUtil.findAll(em, UserWatchList.class).isEmpty()) {
userWatchList = UserWatchListResourceIT.createEntity(em);
em.persist(userWatchList);
em.flush();
} else {
userWatchList = TestUtil.findAll(em, UserWatchList.class).get(0);
}
return watchListEntry;
}
/**
......@@ -97,6 +105,15 @@ public class WatchListEntryResourceIT {
WatchListEntry watchListEntry = new WatchListEntry()
.exerciseId(UPDATED_EXERCISE_ID)
.exerciseName(UPDATED_EXERCISE_NAME);
// Add required entity
UserWatchList userWatchList;
if (TestUtil.findAll(em, UserWatchList.class).isEmpty()) {
userWatchList = UserWatchListResourceIT.createUpdatedEntity(em);
em.persist(userWatchList);
em.flush();
} else {
userWatchList = TestUtil.findAll(em, UserWatchList.class).get(0);
}
return watchListEntry;
}
......@@ -112,7 +129,6 @@ public class WatchListEntryResourceIT {
// Create the WatchListEntry
WatchListEntryDTO watchListEntryDTO = watchListEntryMapper.toDto(watchListEntry);
restWatchListEntryMockMvc.perform(post("/api/watch-list-entries")
.with(csrf().asHeader())
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(watchListEntryDTO)))
.andExpect(status().isCreated());
......@@ -139,7 +155,6 @@ public class WatchListEntryResourceIT {
// An entity with an existing ID cannot be created, so this API call must fail
restWatchListEntryMockMvc.perform(post("/api/watch-list-entries")
.with(csrf().asHeader())
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(watchListEntryDTO)))
.andExpect(status().isBadRequest());
......@@ -165,7 +180,6 @@ public class WatchListEntryResourceIT {
restWatchListEntryMockMvc.perform(post("/api/watch-list-entries")
.with(csrf().asHeader())
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(watchListEntryDTO)))
.andExpect(status().isBadRequest());
......@@ -229,7 +243,6 @@ public class WatchListEntryResourceIT {
WatchListEntryDTO watchListEntryDTO = watchListEntryMapper.toDto(updatedWatchListEntry);
restWatchListEntryMockMvc.perform(put("/api/watch-list-entries")
.with(csrf().asHeader())
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(watchListEntryDTO)))
.andExpect(status().isOk());
......@@ -255,7 +268,6 @@ public class WatchListEntryResourceIT {
// If the entity doesn't have an ID, it will throw BadRequestAlertException
restWatchListEntryMockMvc.perform(put("/api/watch-list-entries")
.with(csrf().asHeader())
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(watchListEntryDTO)))
.andExpect(status().isBadRequest());
......@@ -278,7 +290,6 @@ public class WatchListEntryResourceIT {
// Delete the watchListEntry
restWatchListEntryMockMvc.perform(delete("/api/watch-list-entries/{id}", watchListEntry.getId())
.with(csrf().asHeader())
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isNoContent());
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment