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
Branches
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 @@
"clientRootFolder": "",
"relationships": [
{
"relationshipName": "watchlistId",
"relationshipName": "watchlist",
"otherEntityName": "userWatchList",
"relationshipType": "many-to-one",
"relationshipValidateRules": ["required"],
......
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.CacheConcurrencyStrategy;
import javax.persistence.*;
import javax.validation.constraints.*;
import org.springframework.data.elasticsearch.annotations.FieldType;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
/**
* A WatchListEntry.
......@@ -33,9 +39,9 @@ public class WatchListEntry implements Serializable {
private String exerciseName;
@ManyToOne(optional = false)
@NotNull
// @NotNull
@JsonIgnoreProperties(value = "watchListEntries", allowSetters = true)
private UserWatchList watchlistId;
private UserWatchList watchlist;
// jhipster-needle-entity-add-field - JHipster will add fields here
public Long getId() {
......@@ -72,17 +78,17 @@ public class WatchListEntry implements Serializable {
this.exerciseName = exerciseName;
}
public UserWatchList getWatchlistId() {
return watchlistId;
public UserWatchList getWatchlist() {
return watchlist;
}
public WatchListEntry watchlistId(UserWatchList userWatchList) {
this.watchlistId = userWatchList;
public WatchListEntry watchlist(UserWatchList userWatchList) {
this.watchlist = userWatchList;
return this;
}
public void setWatchlistId(UserWatchList userWatchList) {
this.watchlistId = userWatchList;
public void setWatchlist(UserWatchList userWatchList) {
this.watchlist = userWatchList;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here
......
......@@ -16,7 +16,7 @@ public class WatchListEntryDTO implements Serializable {
private String exerciseName;
private Long watchlistIdId;
private Long watchlistId;
public Long getId() {
return id;
......@@ -42,12 +42,12 @@ public class WatchListEntryDTO implements Serializable {
this.exerciseName = exerciseName;
}
public Long getWatchlistIdId() {
return watchlistIdId;
public Long getWatchlistId() {
return watchlistId;
}
public void setWatchlistIdId(Long userWatchListId) {
this.watchlistIdId = userWatchListId;
public void setWatchlistId(Long userWatchListId) {
this.watchlistId = userWatchListId;
}
@Override
......@@ -74,7 +74,7 @@ public class WatchListEntryDTO implements Serializable {
"id=" + getId() +
", exerciseId='" + getExerciseId() + "'" +
", exerciseName='" + getExerciseName() + "'" +
", watchlistIdId=" + getWatchlistIdId() +
", watchlistIdId=" + getWatchlistId() +
"}";
}
}
......@@ -12,10 +12,10 @@ import org.mapstruct.*;
@Mapper(componentModel = "spring", uses = {UserWatchListMapper.class})
public interface WatchListEntryMapper extends EntityMapper<WatchListEntryDTO, WatchListEntry> {
@Mapping(source = "watchlistId.id", target = "watchlistIdId")
@Mapping(source = "watchlist.id", target = "watchlistId")
WatchListEntryDTO toDto(WatchListEntry watchListEntry);
@Mapping(source = "watchlistIdId", target = "watchlistId")
@Mapping(source = "watchlistId", target = "watchlistId")
WatchListEntry toEntity(WatchListEntryDTO watchListEntryDTO);
default WatchListEntry fromId(Long id) {
......
......@@ -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">
<changeSet author="Michael Breu (generated)" id="20210419144638-1">
<addColumn tableName="watch_list_entry">
<column name="watchlist_id_id" type="bigint">
<column name="watchlist_id" type="bigint">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
<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 id="20210419144638-2-data" author="jhipster" context="faker">
<loadData
......@@ -17,7 +17,7 @@
<column name="id" type="numeric" />
<column name="exercise_id" 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)
can add load columns here -->
</loadData>
......
id;exercise_id;exercise_name;watchlist_id_id
id;exercise_id;exercise_name;watchlist_id
1;Gloves;Checking Account Hat Small;1
2;transmitting array;indexing Health;2
3;Points Awesome;secondary;3
4;Bosnia and Herzegovina;quantifying Berkshire;4
5;Applications;Personal Loan Account Architect;5
6;Implemented override Intuitive;Branding Syrian Pound Keyboard;6
7;Denar;Intelligent Specialist;7
8;Table redundant;Designer;8
9;Customer Ergonomic Togo;National attitude-oriented Movies;9
10;Dynamic;real-time;10
2;transmitting array;indexing Health;1
3;Points Awesome;secondary;2
4;Bosnia and Herzegovina;quantifying Berkshire;2
5;Applications;Personal Loan Account Architect;2
6;Implemented override Intuitive;Branding Syrian Pound Keyboard;4
7;Denar;Intelligent Specialist;4
8;Table redundant;Designer;4
9;Customer Ergonomic Togo;National attitude-oriented Movies;4
10;Dynamic;real-time;4
......@@ -18,8 +18,8 @@
</dd>
<dt><span jhiTranslate="gitsearchApp.watchListEntry.watchlistId">Watchlist Id</span></dt>
<dd>
<div *ngIf="watchListEntry.watchlistIdId">
<a [routerLink]="['/user-watch-list', watchListEntry.watchlistIdId, 'view']">{{ watchListEntry.watchlistIdId }}</a>
<div *ngIf="watchListEntry.watchlistId">
<a [routerLink]="['/user-watch-list', watchListEntry.watchlistId, 'view']">{{ watchListEntry.watchlistId }}</a>
</div>
</dd>
</dl>
......
......@@ -31,14 +31,14 @@
<div class="form-group">
<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">
<option *ngIf="!editForm.get('watchlistIdId')!.value" [ngValue]="null" selected></option>
<select class="form-control" id="field_watchlistId" name="watchlistId" formControlName="watchlistId">
<option *ngIf="!editForm.get('watchlistId')!.value" [ngValue]="null" selected></option>
<option [ngValue]="userWatchListOption.id" *ngFor="let userWatchListOption of userwatchlists; trackBy: trackById">{{ userWatchListOption.id }}</option>
</select>
</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"
*ngIf="editForm.get('watchlistIdId')?.errors?.required" jhiTranslate="entity.validation.required">
*ngIf="editForm.get('watchlistId')?.errors?.required" jhiTranslate="entity.validation.required">
This field is required.
</small>
</div>
......
......@@ -22,7 +22,7 @@ export class WatchListEntryUpdateComponent implements OnInit {
id: [],
exerciseId: [null, [Validators.required]],
exerciseName: [],
watchlistIdId: [null, Validators.required],
watchlistId: [null, Validators.required],
});
constructor(
......@@ -45,7 +45,7 @@ export class WatchListEntryUpdateComponent implements OnInit {
id: watchListEntry.id,
exerciseId: watchListEntry.exerciseId,
exerciseName: watchListEntry.exerciseName,
watchlistIdId: watchListEntry.watchlistIdId,
watchlistId: watchListEntry.watchlistId,
});
}
......@@ -69,7 +69,7 @@ export class WatchListEntryUpdateComponent implements OnInit {
id: this.editForm.get(['id'])!.value,
exerciseId: this.editForm.get(['exerciseId'])!.value,
exerciseName: this.editForm.get(['exerciseName'])!.value,
watchlistIdId: this.editForm.get(['watchlistIdId'])!.value,
watchlistId: this.editForm.get(['watchlistId'])!.value,
};
}
......
......@@ -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="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="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>
</tr>
</thead>
......@@ -53,8 +53,8 @@
<td>{{ watchListEntry.exerciseId }}</td>
<td>{{ watchListEntry.exerciseName }}</td>
<td>
<div *ngIf="watchListEntry.watchlistIdId">
<a [routerLink]="['/user-watch-list', watchListEntry.watchlistIdId , 'view']" >{{ watchListEntry.watchlistIdId }}</a>
<div *ngIf="watchListEntry.watchlistId">
<a [routerLink]="['/user-watch-list', watchListEntry.watchlistId , 'view']" >{{ watchListEntry.watchlistId }}</a>
</div>
</td>
<td class="text-right">
......
......@@ -2,9 +2,9 @@ export interface IWatchListEntry {
id?: number;
exerciseId?: string;
exerciseName?: string;
watchlistIdId?: number;
watchlistId?: number;
}
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;
import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.BeforeEach;
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;
public class WatchListEntryMapperTest {
......@@ -19,4 +27,24 @@ public class WatchListEntryMapperTest {
assertThat(watchListEntryMapper.fromId(id).getId()).isEqualTo(id);
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 {
} else {
userWatchList = TestUtil.findAll(em, UserWatchList.class).get(0);
}
watchListEntry.setWatchlistId(userWatchList);
watchListEntry.setWatchlist(userWatchList);
return watchListEntry;
}
/**
......@@ -124,7 +124,7 @@ public class WatchListEntryResourceIT {
} else {
userWatchList = TestUtil.findAll(em, UserWatchList.class).get(0);
}
watchListEntry.setWatchlistId(userWatchList);
watchListEntry.setWatchlist(userWatchList);
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