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

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

Finally repaired watchlist :-(

parent 9612df6d
2 merge requests!188Merging Peer Reviewing et. al to Master,!164211 peer reviewing functionality
Showing
with 87 additions and 52 deletions
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"clientRootFolder": "", "clientRootFolder": "",
"relationships": [ "relationships": [
{ {
"relationshipName": "watchlistId", "relationshipName": "watchlist",
"otherEntityName": "userWatchList", "otherEntityName": "userWatchList",
"relationshipType": "many-to-one", "relationshipType": "many-to-one",
"relationshipValidateRules": ["required"], "relationshipValidateRules": ["required"],
......
package at.ac.uibk.gitsearch.domain; package at.ac.uibk.gitsearch.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import org.hibernate.annotations.Cache; import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import javax.validation.constraints.*;
import org.springframework.data.elasticsearch.annotations.FieldType;
import java.io.Serializable;
/** /**
* A WatchListEntry. * A WatchListEntry.
...@@ -33,9 +39,9 @@ public class WatchListEntry implements Serializable { ...@@ -33,9 +39,9 @@ public class WatchListEntry implements Serializable {
private String exerciseName; private String exerciseName;
@ManyToOne(optional = false) @ManyToOne(optional = false)
@NotNull // @NotNull
@JsonIgnoreProperties(value = "watchListEntries", allowSetters = true) @JsonIgnoreProperties(value = "watchListEntries", allowSetters = true)
private UserWatchList watchlistId; private UserWatchList watchlist;
// jhipster-needle-entity-add-field - JHipster will add fields here // jhipster-needle-entity-add-field - JHipster will add fields here
public Long getId() { public Long getId() {
...@@ -72,17 +78,17 @@ public class WatchListEntry implements Serializable { ...@@ -72,17 +78,17 @@ public class WatchListEntry implements Serializable {
this.exerciseName = exerciseName; this.exerciseName = exerciseName;
} }
public UserWatchList getWatchlistId() { public UserWatchList getWatchlist() {
return watchlistId; return watchlist;
} }
public WatchListEntry watchlistId(UserWatchList userWatchList) { public WatchListEntry watchlist(UserWatchList userWatchList) {
this.watchlistId = userWatchList; this.watchlist = userWatchList;
return this; return this;
} }
public void setWatchlistId(UserWatchList userWatchList) { public void setWatchlist(UserWatchList userWatchList) {
this.watchlistId = userWatchList; this.watchlist = userWatchList;
} }
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here
......
...@@ -16,7 +16,7 @@ public class WatchListEntryDTO implements Serializable { ...@@ -16,7 +16,7 @@ public class WatchListEntryDTO implements Serializable {
private String exerciseName; private String exerciseName;
private Long watchlistIdId; private Long watchlistId;
public Long getId() { public Long getId() {
return id; return id;
...@@ -42,12 +42,12 @@ public class WatchListEntryDTO implements Serializable { ...@@ -42,12 +42,12 @@ public class WatchListEntryDTO implements Serializable {
this.exerciseName = exerciseName; this.exerciseName = exerciseName;
} }
public Long getWatchlistIdId() { public Long getWatchlistId() {
return watchlistIdId; return watchlistId;
} }
public void setWatchlistIdId(Long userWatchListId) { public void setWatchlistId(Long userWatchListId) {
this.watchlistIdId = userWatchListId; this.watchlistId = userWatchListId;
} }
@Override @Override
...@@ -74,7 +74,7 @@ public class WatchListEntryDTO implements Serializable { ...@@ -74,7 +74,7 @@ public class WatchListEntryDTO implements Serializable {
"id=" + getId() + "id=" + getId() +
", exerciseId='" + getExerciseId() + "'" + ", exerciseId='" + getExerciseId() + "'" +
", exerciseName='" + getExerciseName() + "'" + ", exerciseName='" + getExerciseName() + "'" +
", watchlistIdId=" + getWatchlistIdId() + ", watchlistIdId=" + getWatchlistId() +
"}"; "}";
} }
} }
...@@ -12,10 +12,10 @@ import org.mapstruct.*; ...@@ -12,10 +12,10 @@ import org.mapstruct.*;
@Mapper(componentModel = "spring", uses = {UserWatchListMapper.class}) @Mapper(componentModel = "spring", uses = {UserWatchListMapper.class})
public interface WatchListEntryMapper extends EntityMapper<WatchListEntryDTO, WatchListEntry> { public interface WatchListEntryMapper extends EntityMapper<WatchListEntryDTO, WatchListEntry> {
@Mapping(source = "watchlistId.id", target = "watchlistIdId") @Mapping(source = "watchlist.id", target = "watchlistId")
WatchListEntryDTO toDto(WatchListEntry watchListEntry); WatchListEntryDTO toDto(WatchListEntry watchListEntry);
@Mapping(source = "watchlistIdId", target = "watchlistId") @Mapping(source = "watchlistId", target = "watchlistId")
WatchListEntry toEntity(WatchListEntryDTO watchListEntryDTO); WatchListEntry toEntity(WatchListEntryDTO watchListEntryDTO);
default WatchListEntry fromId(Long id) { default WatchListEntry fromId(Long id) {
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-3.9.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.9.xsd"> <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-3.9.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.9.xsd">
<changeSet author="Michael Breu (generated)" id="20210419144638-1"> <changeSet author="Michael Breu (generated)" id="20210419144638-1">
<addColumn tableName="watch_list_entry"> <addColumn tableName="watch_list_entry">
<column name="watchlist_id_id" type="bigint"> <column name="watchlist_id" type="bigint">
<constraints nullable="false"/> <constraints nullable="false"/>
</column> </column>
</addColumn> </addColumn>
</changeSet> </changeSet>
<changeSet author="Michael Breu (generated)" id="1618843631017-2"> <changeSet author="Michael Breu (generated)" id="1618843631017-2">
<addForeignKeyConstraint baseColumnNames="watchlist_id_id" baseTableName="watch_list_entry" constraintName="FK67mq6ohpd8j1kdai4exmombni" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="user_watch_list" validate="true"/> <addForeignKeyConstraint baseColumnNames="watchlist_id" baseTableName="watch_list_entry" constraintName="FK67mq6ohpd8j1kdai4exmombni" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="user_watch_list" validate="true"/>
</changeSet> </changeSet>
<changeSet id="20210419144638-2-data" author="jhipster" context="faker"> <changeSet id="20210419144638-2-data" author="jhipster" context="faker">
<loadData <loadData
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<column name="id" type="numeric" /> <column name="id" type="numeric" />
<column name="exercise_id" type="string" /> <column name="exercise_id" type="string" />
<column name="exercise_name" type="string" /> <column name="exercise_name" type="string" />
<column name="watchlist_id_id" type="numeric" /> <column name="watchlist_id" type="numeric" />
<!-- jhipster-needle-liquibase-add-loadcolumn - JHipster (and/or extensions) <!-- jhipster-needle-liquibase-add-loadcolumn - JHipster (and/or extensions)
can add load columns here --> can add load columns here -->
</loadData> </loadData>
......
id;exercise_id;exercise_name;watchlist_id_id id;exercise_id;exercise_name;watchlist_id
1;Gloves;Checking Account Hat Small;1 1;Gloves;Checking Account Hat Small;1
2;transmitting array;indexing Health;2 2;transmitting array;indexing Health;1
3;Points Awesome;secondary;3 3;Points Awesome;secondary;2
4;Bosnia and Herzegovina;quantifying Berkshire;4 4;Bosnia and Herzegovina;quantifying Berkshire;2
5;Applications;Personal Loan Account Architect;5 5;Applications;Personal Loan Account Architect;2
6;Implemented override Intuitive;Branding Syrian Pound Keyboard;6 6;Implemented override Intuitive;Branding Syrian Pound Keyboard;4
7;Denar;Intelligent Specialist;7 7;Denar;Intelligent Specialist;4
8;Table redundant;Designer;8 8;Table redundant;Designer;4
9;Customer Ergonomic Togo;National attitude-oriented Movies;9 9;Customer Ergonomic Togo;National attitude-oriented Movies;4
10;Dynamic;real-time;10 10;Dynamic;real-time;4
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
</dd> </dd>
<dt><span jhiTranslate="gitsearchApp.watchListEntry.watchlistId">Watchlist Id</span></dt> <dt><span jhiTranslate="gitsearchApp.watchListEntry.watchlistId">Watchlist Id</span></dt>
<dd> <dd>
<div *ngIf="watchListEntry.watchlistIdId"> <div *ngIf="watchListEntry.watchlistId">
<a [routerLink]="['/user-watch-list', watchListEntry.watchlistIdId, 'view']">{{ watchListEntry.watchlistIdId }}</a> <a [routerLink]="['/user-watch-list', watchListEntry.watchlistId, 'view']">{{ watchListEntry.watchlistId }}</a>
</div> </div>
</dd> </dd>
</dl> </dl>
......
...@@ -31,14 +31,14 @@ ...@@ -31,14 +31,14 @@
<div class="form-group"> <div class="form-group">
<label class="form-control-label" jhiTranslate="gitsearchApp.watchListEntry.watchlistId" for="field_watchlistId">Watchlist Id</label> <label class="form-control-label" jhiTranslate="gitsearchApp.watchListEntry.watchlistId" for="field_watchlistId">Watchlist Id</label>
<select class="form-control" id="field_watchlistId" name="watchlistId" formControlName="watchlistIdId"> <select class="form-control" id="field_watchlistId" name="watchlistId" formControlName="watchlistId">
<option *ngIf="!editForm.get('watchlistIdId')!.value" [ngValue]="null" selected></option> <option *ngIf="!editForm.get('watchlistId')!.value" [ngValue]="null" selected></option>
<option [ngValue]="userWatchListOption.id" *ngFor="let userWatchListOption of userwatchlists; trackBy: trackById">{{ userWatchListOption.id }}</option> <option [ngValue]="userWatchListOption.id" *ngFor="let userWatchListOption of userwatchlists; trackBy: trackById">{{ userWatchListOption.id }}</option>
</select> </select>
</div> </div>
<div *ngIf="editForm.get('watchlistIdId')!.invalid && (editForm.get('watchlistIdId')!.dirty || editForm.get('watchlistIdId')!.touched)"> <div *ngIf="editForm.get('watchlistId')!.invalid && (editForm.get('watchlistId')!.dirty || editForm.get('watchlistId')!.touched)">
<small class="form-text text-danger" <small class="form-text text-danger"
*ngIf="editForm.get('watchlistIdId')?.errors?.required" jhiTranslate="entity.validation.required"> *ngIf="editForm.get('watchlistId')?.errors?.required" jhiTranslate="entity.validation.required">
This field is required. This field is required.
</small> </small>
</div> </div>
......
...@@ -22,7 +22,7 @@ export class WatchListEntryUpdateComponent implements OnInit { ...@@ -22,7 +22,7 @@ export class WatchListEntryUpdateComponent implements OnInit {
id: [], id: [],
exerciseId: [null, [Validators.required]], exerciseId: [null, [Validators.required]],
exerciseName: [], exerciseName: [],
watchlistIdId: [null, Validators.required], watchlistId: [null, Validators.required],
}); });
constructor( constructor(
...@@ -45,7 +45,7 @@ export class WatchListEntryUpdateComponent implements OnInit { ...@@ -45,7 +45,7 @@ export class WatchListEntryUpdateComponent implements OnInit {
id: watchListEntry.id, id: watchListEntry.id,
exerciseId: watchListEntry.exerciseId, exerciseId: watchListEntry.exerciseId,
exerciseName: watchListEntry.exerciseName, exerciseName: watchListEntry.exerciseName,
watchlistIdId: watchListEntry.watchlistIdId, watchlistId: watchListEntry.watchlistId,
}); });
} }
...@@ -69,7 +69,7 @@ export class WatchListEntryUpdateComponent implements OnInit { ...@@ -69,7 +69,7 @@ export class WatchListEntryUpdateComponent implements OnInit {
id: this.editForm.get(['id'])!.value, id: this.editForm.get(['id'])!.value,
exerciseId: this.editForm.get(['exerciseId'])!.value, exerciseId: this.editForm.get(['exerciseId'])!.value,
exerciseName: this.editForm.get(['exerciseName'])!.value, exerciseName: this.editForm.get(['exerciseName'])!.value,
watchlistIdId: this.editForm.get(['watchlistIdId'])!.value, watchlistId: this.editForm.get(['watchlistId'])!.value,
}; };
} }
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<th scope="col" jhiSortBy="id"><span jhiTranslate="global.field.id">ID</span> <fa-icon icon="sort"></fa-icon></th> <th scope="col" jhiSortBy="id"><span jhiTranslate="global.field.id">ID</span> <fa-icon icon="sort"></fa-icon></th>
<th scope="col" jhiSortBy="exerciseId"><span jhiTranslate="gitsearchApp.watchListEntry.exerciseId">Exercise Id</span> <fa-icon icon="sort"></fa-icon></th> <th scope="col" jhiSortBy="exerciseId"><span jhiTranslate="gitsearchApp.watchListEntry.exerciseId">Exercise Id</span> <fa-icon icon="sort"></fa-icon></th>
<th scope="col" jhiSortBy="exerciseName"><span jhiTranslate="gitsearchApp.watchListEntry.exerciseName">Exercise Name</span> <fa-icon icon="sort"></fa-icon></th> <th scope="col" jhiSortBy="exerciseName"><span jhiTranslate="gitsearchApp.watchListEntry.exerciseName">Exercise Name</span> <fa-icon icon="sort"></fa-icon></th>
<th scope="col" jhiSortBy="watchlistIdId"><span jhiTranslate="gitsearchApp.watchListEntry.watchlistId">Watchlist Id</span> <fa-icon icon="sort"></fa-icon></th> <th scope="col" jhiSortBy="watchlistId"><span jhiTranslate="gitsearchApp.watchListEntry.watchlistId">Watchlist Id</span> <fa-icon icon="sort"></fa-icon></th>
<th scope="col"></th> <th scope="col"></th>
</tr> </tr>
</thead> </thead>
...@@ -53,8 +53,8 @@ ...@@ -53,8 +53,8 @@
<td>{{ watchListEntry.exerciseId }}</td> <td>{{ watchListEntry.exerciseId }}</td>
<td>{{ watchListEntry.exerciseName }}</td> <td>{{ watchListEntry.exerciseName }}</td>
<td> <td>
<div *ngIf="watchListEntry.watchlistIdId"> <div *ngIf="watchListEntry.watchlistId">
<a [routerLink]="['/user-watch-list', watchListEntry.watchlistIdId , 'view']" >{{ watchListEntry.watchlistIdId }}</a> <a [routerLink]="['/user-watch-list', watchListEntry.watchlistId , 'view']" >{{ watchListEntry.watchlistId }}</a>
</div> </div>
</td> </td>
<td class="text-right"> <td class="text-right">
......
...@@ -2,9 +2,9 @@ export interface IWatchListEntry { ...@@ -2,9 +2,9 @@ export interface IWatchListEntry {
id?: number; id?: number;
exerciseId?: string; exerciseId?: string;
exerciseName?: string; exerciseName?: string;
watchlistIdId?: number; watchlistId?: number;
} }
export class WatchListEntry implements IWatchListEntry { export class WatchListEntry implements IWatchListEntry {
constructor(public id?: number, public exerciseId?: string, public exerciseName?: string, public watchlistIdId?: number) {} constructor(public id?: number, public exerciseId?: string, public exerciseName?: string, public watchlistId?: number) {}
} }
package at.ac.uibk.gitsearch.service.mapper; package at.ac.uibk.gitsearch.service.mapper;
import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import at.ac.uibk.gitsearch.domain.User;
import at.ac.uibk.gitsearch.domain.UserWatchList;
import at.ac.uibk.gitsearch.domain.WatchListEntry;
import at.ac.uibk.gitsearch.service.dto.WatchListEntryDTO;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
public class WatchListEntryMapperTest { public class WatchListEntryMapperTest {
...@@ -19,4 +27,24 @@ public class WatchListEntryMapperTest { ...@@ -19,4 +27,24 @@ public class WatchListEntryMapperTest {
assertThat(watchListEntryMapper.fromId(id).getId()).isEqualTo(id); assertThat(watchListEntryMapper.fromId(id).getId()).isEqualTo(id);
assertThat(watchListEntryMapper.fromId(null)).isNull(); assertThat(watchListEntryMapper.fromId(null)).isNull();
} }
@Test
public void testWatchlistIdMapping() {
final long wlId = 25L;
final long wleId = 13L;
UserWatchList wl = new UserWatchList();
wl.setId(wlId); wl.setName("Just testing"); wl.setUserId(new User());
WatchListEntry wle = new WatchListEntry();
wle.setId(wleId); wle.setExerciseId("unusedExerciseId"); wle.setExerciseName("Test Exercise Name"); wle.setWatchlist(wl);
final WatchListEntryDTO wlAsDTO = watchListEntryMapper.toDto(wle);
assertEquals(wlAsDTO.getId(), wle.getId());
assertEquals(wlAsDTO.getExerciseId(), wle.getExerciseId());
assertEquals(wlAsDTO.getExerciseName(), wle.getExerciseName());
assertEquals(wlAsDTO.getWatchlistId(), wle.getWatchlist().getId());
}
} }
...@@ -102,7 +102,7 @@ public class WatchListEntryResourceIT { ...@@ -102,7 +102,7 @@ public class WatchListEntryResourceIT {
} else { } else {
userWatchList = TestUtil.findAll(em, UserWatchList.class).get(0); userWatchList = TestUtil.findAll(em, UserWatchList.class).get(0);
} }
watchListEntry.setWatchlistId(userWatchList); watchListEntry.setWatchlist(userWatchList);
return watchListEntry; return watchListEntry;
} }
/** /**
...@@ -124,7 +124,7 @@ public class WatchListEntryResourceIT { ...@@ -124,7 +124,7 @@ public class WatchListEntryResourceIT {
} else { } else {
userWatchList = TestUtil.findAll(em, UserWatchList.class).get(0); userWatchList = TestUtil.findAll(em, UserWatchList.class).get(0);
} }
watchListEntry.setWatchlistId(userWatchList); watchListEntry.setWatchlist(userWatchList);
return watchListEntry; return watchListEntry;
} }
......
SELECT * FROM USER_WATCH_LIST
\ No newline at end of file
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