removing duplicate userId from entity UserRoleAssignment

(it comes implicitly through the relationship)
This commit is contained in:
Michael Hoennig 2019-04-30 18:04:25 +02:00
commit 4529527e3b
23 changed files with 42 additions and 180 deletions

View File

@ -49,7 +49,7 @@
"otherEntityField": "admissionDocumentDate"
}
],
"changelogDate": "20190430152139",
"changelogDate": "20190430154657",
"entityTableName": "asset",
"dto": "mapstruct",
"pagination": "infinite-scroll",

View File

@ -142,7 +142,7 @@
"relationshipName": "sepamandate"
}
],
"changelogDate": "20190430152136",
"changelogDate": "20190430154654",
"entityTableName": "customer",
"dto": "mapstruct",
"pagination": "infinite-scroll",

View File

@ -54,7 +54,7 @@
"otherEntityField": "prefix"
}
],
"changelogDate": "20190430152137",
"changelogDate": "20190430154655",
"entityTableName": "membership",
"dto": "mapstruct",
"pagination": "infinite-scroll",

View File

@ -72,7 +72,7 @@
"otherEntityField": "prefix"
}
],
"changelogDate": "20190430152140",
"changelogDate": "20190430154658",
"entityTableName": "sepa_mandate",
"dto": "mapstruct",
"pagination": "infinite-scroll",

View File

@ -49,7 +49,7 @@
"otherEntityField": "admissionDocumentDate"
}
],
"changelogDate": "20190430152138",
"changelogDate": "20190430154656",
"entityTableName": "share",
"dto": "mapstruct",
"pagination": "infinite-scroll",

View File

@ -9,13 +9,6 @@
"fieldName": "entityObjectId",
"fieldType": "Long"
},
{
"fieldName": "userId",
"fieldType": "Long",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "assignedRole",
"fieldType": "UserRole",
@ -34,7 +27,7 @@
"otherEntityField": "login"
}
],
"changelogDate": "20190430152204",
"changelogDate": "20190430154711",
"entityTableName": "user_role_assignment",
"dto": "no",
"pagination": "infinite-scroll",

View File

@ -0,0 +1,31 @@
git checkout jhipster-generated
git pull
git tag REAL-HEAD
git reset --hard jdl-base
git clean -f -d
git cherry-pick -n spotless
git reset --soft REAL-HEAD
git checkout REAL-HEAD src/main/jdl/customer.jdl # AND OTHERS!
git tag -d REAL-HEAD
# MANUAL STEP: Apply changes to the jdl file!
# (Re-) Importing
jhipster import-jdl src/main/jdl/customer.jdl
jhipster import-jdl src/main/jdl/accessrights.jdl
# AND OTHERS!
# add @formatter:off to src/main/java/org/hostsharing/hsadminng/config/SecurityConfiguration.java
# I will add this change to the commit with the spotless commit to get rid of this.
gw spotlessApply
git add .
git commit -m"..."
# MANUAL STEP:
# - if you've renamed any identifiers, use refactoring to rename in master as well BEFORE MERGING!
# Merge changeset into master branch
git checkout master
git merge jhipster-generated

View File

@ -35,8 +35,6 @@ apply plugin: 'java'
apply plugin: 'org.owasp.dependencycheck'
sourceCompatibility=1.8
targetCompatibility=1.8
// Until JHipster supports JDK 9
assert System.properties['java.specification.version'] == '1.8'
apply plugin: 'maven'
apply plugin: 'org.springframework.boot'

View File

@ -31,10 +31,6 @@ public class UserRoleAssignment implements Serializable {
@Column(name = "entity_object_id")
private Long entityObjectId;
@NotNull
@Column(name = "user_id", nullable = false)
private Long userId;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "assigned_role", nullable = false)
@ -79,19 +75,6 @@ public class UserRoleAssignment implements Serializable {
this.entityObjectId = entityObjectId;
}
public Long getUserId() {
return userId;
}
public UserRoleAssignment userId(Long userId) {
this.userId = userId;
return this;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public UserRole getAssignedRole() {
return assignedRole;
}
@ -145,7 +128,6 @@ public class UserRoleAssignment implements Serializable {
"id=" + getId() +
", entityTypeId='" + getEntityTypeId() + "'" +
", entityObjectId=" + getEntityObjectId() +
", userId=" + getUserId() +
", assignedRole='" + getAssignedRole() + "'" +
"}";
}

View File

@ -96,9 +96,6 @@ public class UserRoleAssignmentQueryService extends QueryService<UserRoleAssignm
specification = specification
.and(buildRangeSpecification(criteria.getEntityObjectId(), UserRoleAssignment_.entityObjectId));
}
if (criteria.getUserId() != null) {
specification = specification.and(buildRangeSpecification(criteria.getUserId(), UserRoleAssignment_.userId));
}
if (criteria.getAssignedRole() != null) {
specification = specification
.and(buildSpecification(criteria.getAssignedRole(), UserRoleAssignment_.assignedRole));

View File

@ -34,8 +34,6 @@ public class UserRoleAssignmentCriteria implements Serializable {
private LongFilter entityObjectId;
private LongFilter userId;
private UserRoleFilter assignedRole;
private LongFilter userId;
@ -64,14 +62,6 @@ public class UserRoleAssignmentCriteria implements Serializable {
this.entityObjectId = entityObjectId;
}
public LongFilter getUserId() {
return userId;
}
public void setUserId(LongFilter userId) {
this.userId = userId;
}
public UserRoleFilter getAssignedRole() {
return assignedRole;
}
@ -100,7 +90,6 @@ public class UserRoleAssignmentCriteria implements Serializable {
return Objects.equals(id, that.id) &&
Objects.equals(entityTypeId, that.entityTypeId) &&
Objects.equals(entityObjectId, that.entityObjectId) &&
Objects.equals(userId, that.userId) &&
Objects.equals(assignedRole, that.assignedRole) &&
Objects.equals(userId, that.userId);
}
@ -111,7 +100,6 @@ public class UserRoleAssignmentCriteria implements Serializable {
id,
entityTypeId,
entityObjectId,
userId,
assignedRole,
userId);
}
@ -122,7 +110,6 @@ public class UserRoleAssignmentCriteria implements Serializable {
(id != null ? "id=" + id + ", " : "") +
(entityTypeId != null ? "entityTypeId=" + entityTypeId + ", " : "") +
(entityObjectId != null ? "entityObjectId=" + entityObjectId + ", " : "") +
(userId != null ? "userId=" + userId + ", " : "") +
(assignedRole != null ? "assignedRole=" + assignedRole + ", " : "") +
(userId != null ? "userId=" + userId + ", " : "") +
"}";

View File

@ -14,7 +14,6 @@ enum UserRole {
entity UserRoleAssignment {
entityTypeId String,
entityObjectId Long,
userId Long required,
assignedRole UserRole required
}

View File

@ -16,7 +16,7 @@
<!--
Added the entity UserRoleAssignment.
-->
<changeSet id="20190430152204-1" author="jhipster">
<changeSet id="20190430154711-1" author="jhipster">
<createTable tableName="user_role_assignment">
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
<constraints primaryKey="true" nullable="false"/>
@ -29,10 +29,6 @@
<constraints nullable="true" />
</column>
<column name="user_id" type="bigint">
<constraints nullable="false" />
</column>
<column name="assigned_role" type="varchar(255)">
<constraints nullable="false" />
</column>

View File

@ -6,7 +6,7 @@
<!--
Added the constraints for entity UserRoleAssignment.
-->
<changeSet id="20190430152204-2" author="jhipster">
<changeSet id="20190430154711-2" author="jhipster">
<addForeignKeyConstraint baseColumnNames="user_id"
baseTableName="user_role_assignment"

View File

@ -10,13 +10,13 @@
<include file="config/liquibase/changelog/20190430152138_added_entity_Share.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430152139_added_entity_Asset.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430152140_added_entity_SepaMandate.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430152204_added_entity_UserRoleAssignment.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430154711_added_entity_UserRoleAssignment.xml" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here -->
<include file="config/liquibase/changelog/20190430152137_added_entity_constraints_Membership.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430152138_added_entity_constraints_Share.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430152139_added_entity_constraints_Asset.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430152140_added_entity_constraints_SepaMandate.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430152204_added_entity_constraints_UserRoleAssignment.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430154711_added_entity_constraints_UserRoleAssignment.xml" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
<!-- sample data -->

View File

@ -13,10 +13,6 @@
<dd>
<span>{{userRoleAssignment.entityObjectId}}</span>
</dd>
<dt><span jhiTranslate="hsadminNgApp.userRoleAssignment.userId">User Id</span></dt>
<dd>
<span>{{userRoleAssignment.userId}}</span>
</dd>
<dt><span jhiTranslate="hsadminNgApp.userRoleAssignment.assignedRole">Assigned Role</span></dt>
<dd>
<span jhiTranslate="{{'hsadminNgApp.UserRole.' + userRoleAssignment.assignedRole}}">{{userRoleAssignment.assignedRole}}</span>

View File

@ -19,21 +19,6 @@
<input type="number" class="form-control" name="entityObjectId" id="field_entityObjectId"
[(ngModel)]="userRoleAssignment.entityObjectId" />
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.userRoleAssignment.userId" for="field_userId">User Id</label>
<input type="number" class="form-control" name="userId" id="field_userId"
[(ngModel)]="userRoleAssignment.userId" required/>
<div [hidden]="!(editForm.controls.userId?.dirty && editForm.controls.userId?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.userId?.errors?.required" jhiTranslate="entity.validation.required">
This field is required.
</small>
<small class="form-text text-danger"
[hidden]="!editForm.controls.userId?.errors?.number" jhiTranslate="entity.validation.number">
This field should be a number.
</small>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.userRoleAssignment.assignedRole" for="field_assignedRole">Assigned Role</label>
<select class="form-control" name="assignedRole" [(ngModel)]="userRoleAssignment.assignedRole" id="field_assignedRole" required>

View File

@ -17,7 +17,6 @@
<th jhiSortBy="id"><span jhiTranslate="global.field.id">ID</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="entityTypeId"><span jhiTranslate="hsadminNgApp.userRoleAssignment.entityTypeId">Entity Type Id</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="entityObjectId"><span jhiTranslate="hsadminNgApp.userRoleAssignment.entityObjectId">Entity Object Id</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="userId"><span jhiTranslate="hsadminNgApp.userRoleAssignment.userId">User Id</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="assignedRole"><span jhiTranslate="hsadminNgApp.userRoleAssignment.assignedRole">Assigned Role</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="user.login"><span jhiTranslate="hsadminNgApp.userRoleAssignment.user">User</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th></th>
@ -28,7 +27,6 @@
<td><a [routerLink]="['/user-role-assignment', userRoleAssignment.id, 'view' ]">{{userRoleAssignment.id}}</a></td>
<td>{{userRoleAssignment.entityTypeId}}</td>
<td>{{userRoleAssignment.entityObjectId}}</td>
<td>{{userRoleAssignment.userId}}</td>
<td jhiTranslate="{{'hsadminNgApp.UserRole.' + userRoleAssignment.assignedRole}}">{{userRoleAssignment.assignedRole}}</td>
<td>
{{userRoleAssignment.user?.login}}

View File

@ -14,7 +14,6 @@ export interface IUserRoleAssignment {
id?: number;
entityTypeId?: string;
entityObjectId?: number;
userId?: number;
assignedRole?: UserRole;
user?: IUser;
}
@ -24,7 +23,6 @@ export class UserRoleAssignment implements IUserRoleAssignment {
public id?: number,
public entityTypeId?: string,
public entityObjectId?: number,
public userId?: number,
public assignedRole?: UserRole,
public user?: IUser
) {}

View File

@ -17,7 +17,6 @@
},
"entityTypeId": "Entity Type Id",
"entityObjectId": "Entity Object Id",
"userId": "User Id",
"assignedRole": "Assigned Role",
"user": "User"
}

View File

@ -17,7 +17,6 @@
},
"entityTypeId": "Entity Type Id",
"entityObjectId": "Entity Object Id",
"userId": "User Id",
"assignedRole": "Assigned Role",
"user": "User"
}

View File

@ -50,9 +50,6 @@ public class UserRoleAssignmentResourceIntTest {
private static final Long DEFAULT_ENTITY_OBJECT_ID = 1L;
private static final Long UPDATED_ENTITY_OBJECT_ID = 2L;
private static final Long DEFAULT_USER_ID = 1L;
private static final Long UPDATED_USER_ID = 2L;
private static final UserRole DEFAULT_ASSIGNED_ROLE = UserRole.HOSTMASTER;
private static final UserRole UPDATED_ASSIGNED_ROLE = UserRole.ADMIN;
@ -109,7 +106,6 @@ public class UserRoleAssignmentResourceIntTest {
UserRoleAssignment userRoleAssignment = new UserRoleAssignment()
.entityTypeId(DEFAULT_ENTITY_TYPE_ID)
.entityObjectId(DEFAULT_ENTITY_OBJECT_ID)
.userId(DEFAULT_USER_ID)
.assignedRole(DEFAULT_ASSIGNED_ROLE);
return userRoleAssignment;
}
@ -137,7 +133,6 @@ public class UserRoleAssignmentResourceIntTest {
UserRoleAssignment testUserRoleAssignment = userRoleAssignmentList.get(userRoleAssignmentList.size() - 1);
assertThat(testUserRoleAssignment.getEntityTypeId()).isEqualTo(DEFAULT_ENTITY_TYPE_ID);
assertThat(testUserRoleAssignment.getEntityObjectId()).isEqualTo(DEFAULT_ENTITY_OBJECT_ID);
assertThat(testUserRoleAssignment.getUserId()).isEqualTo(DEFAULT_USER_ID);
assertThat(testUserRoleAssignment.getAssignedRole()).isEqualTo(DEFAULT_ASSIGNED_ROLE);
}
@ -161,25 +156,6 @@ public class UserRoleAssignmentResourceIntTest {
assertThat(userRoleAssignmentList).hasSize(databaseSizeBeforeCreate);
}
@Test
@Transactional
public void checkUserIdIsRequired() throws Exception {
int databaseSizeBeforeTest = userRoleAssignmentRepository.findAll().size();
// set the field null
userRoleAssignment.setUserId(null);
// Create the UserRoleAssignment, which fails.
restUserRoleAssignmentMockMvc.perform(
post("/api/user-role-assignments")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(userRoleAssignment)))
.andExpect(status().isBadRequest());
List<UserRoleAssignment> userRoleAssignmentList = userRoleAssignmentRepository.findAll();
assertThat(userRoleAssignmentList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkAssignedRoleIsRequired() throws Exception {
@ -212,7 +188,6 @@ public class UserRoleAssignmentResourceIntTest {
.andExpect(jsonPath("$.[*].id").value(hasItem(userRoleAssignment.getId().intValue())))
.andExpect(jsonPath("$.[*].entityTypeId").value(hasItem(DEFAULT_ENTITY_TYPE_ID.toString())))
.andExpect(jsonPath("$.[*].entityObjectId").value(hasItem(DEFAULT_ENTITY_OBJECT_ID.intValue())))
.andExpect(jsonPath("$.[*].userId").value(hasItem(DEFAULT_USER_ID.intValue())))
.andExpect(jsonPath("$.[*].assignedRole").value(hasItem(DEFAULT_ASSIGNED_ROLE.toString())));
}
@ -229,7 +204,6 @@ public class UserRoleAssignmentResourceIntTest {
.andExpect(jsonPath("$.id").value(userRoleAssignment.getId().intValue()))
.andExpect(jsonPath("$.entityTypeId").value(DEFAULT_ENTITY_TYPE_ID.toString()))
.andExpect(jsonPath("$.entityObjectId").value(DEFAULT_ENTITY_OBJECT_ID.intValue()))
.andExpect(jsonPath("$.userId").value(DEFAULT_USER_ID.intValue()))
.andExpect(jsonPath("$.assignedRole").value(DEFAULT_ASSIGNED_ROLE.toString()));
}
@ -338,71 +312,6 @@ public class UserRoleAssignmentResourceIntTest {
defaultUserRoleAssignmentShouldBeFound("entityObjectId.lessThan=" + UPDATED_ENTITY_OBJECT_ID);
}
@Test
@Transactional
public void getAllUserRoleAssignmentsByUserIdIsEqualToSomething() throws Exception {
// Initialize the database
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
// Get all the userRoleAssignmentList where userId equals to DEFAULT_USER_ID
defaultUserRoleAssignmentShouldBeFound("userId.equals=" + DEFAULT_USER_ID);
// Get all the userRoleAssignmentList where userId equals to UPDATED_USER_ID
defaultUserRoleAssignmentShouldNotBeFound("userId.equals=" + UPDATED_USER_ID);
}
@Test
@Transactional
public void getAllUserRoleAssignmentsByUserIdIsInShouldWork() throws Exception {
// Initialize the database
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
// Get all the userRoleAssignmentList where userId in DEFAULT_USER_ID or UPDATED_USER_ID
defaultUserRoleAssignmentShouldBeFound("userId.in=" + DEFAULT_USER_ID + "," + UPDATED_USER_ID);
// Get all the userRoleAssignmentList where userId equals to UPDATED_USER_ID
defaultUserRoleAssignmentShouldNotBeFound("userId.in=" + UPDATED_USER_ID);
}
@Test
@Transactional
public void getAllUserRoleAssignmentsByUserIdIsNullOrNotNull() throws Exception {
// Initialize the database
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
// Get all the userRoleAssignmentList where userId is not null
defaultUserRoleAssignmentShouldBeFound("userId.specified=true");
// Get all the userRoleAssignmentList where userId is null
defaultUserRoleAssignmentShouldNotBeFound("userId.specified=false");
}
@Test
@Transactional
public void getAllUserRoleAssignmentsByUserIdIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
// Get all the userRoleAssignmentList where userId greater than or equals to DEFAULT_USER_ID
defaultUserRoleAssignmentShouldBeFound("userId.greaterOrEqualThan=" + DEFAULT_USER_ID);
// Get all the userRoleAssignmentList where userId greater than or equals to UPDATED_USER_ID
defaultUserRoleAssignmentShouldNotBeFound("userId.greaterOrEqualThan=" + UPDATED_USER_ID);
}
@Test
@Transactional
public void getAllUserRoleAssignmentsByUserIdIsLessThanSomething() throws Exception {
// Initialize the database
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
// Get all the userRoleAssignmentList where userId less than or equals to DEFAULT_USER_ID
defaultUserRoleAssignmentShouldNotBeFound("userId.lessThan=" + DEFAULT_USER_ID);
// Get all the userRoleAssignmentList where userId less than or equals to UPDATED_USER_ID
defaultUserRoleAssignmentShouldBeFound("userId.lessThan=" + UPDATED_USER_ID);
}
@Test
@Transactional
public void getAllUserRoleAssignmentsByAssignedRoleIsEqualToSomething() throws Exception {
@ -470,7 +379,6 @@ public class UserRoleAssignmentResourceIntTest {
.andExpect(jsonPath("$.[*].id").value(hasItem(userRoleAssignment.getId().intValue())))
.andExpect(jsonPath("$.[*].entityTypeId").value(hasItem(DEFAULT_ENTITY_TYPE_ID)))
.andExpect(jsonPath("$.[*].entityObjectId").value(hasItem(DEFAULT_ENTITY_OBJECT_ID.intValue())))
.andExpect(jsonPath("$.[*].userId").value(hasItem(DEFAULT_USER_ID.intValue())))
.andExpect(jsonPath("$.[*].assignedRole").value(hasItem(DEFAULT_ASSIGNED_ROLE.toString())));
// Check, that the count call also returns 1
@ -520,7 +428,6 @@ public class UserRoleAssignmentResourceIntTest {
updatedUserRoleAssignment
.entityTypeId(UPDATED_ENTITY_TYPE_ID)
.entityObjectId(UPDATED_ENTITY_OBJECT_ID)
.userId(UPDATED_USER_ID)
.assignedRole(UPDATED_ASSIGNED_ROLE);
restUserRoleAssignmentMockMvc.perform(
@ -535,7 +442,6 @@ public class UserRoleAssignmentResourceIntTest {
UserRoleAssignment testUserRoleAssignment = userRoleAssignmentList.get(userRoleAssignmentList.size() - 1);
assertThat(testUserRoleAssignment.getEntityTypeId()).isEqualTo(UPDATED_ENTITY_TYPE_ID);
assertThat(testUserRoleAssignment.getEntityObjectId()).isEqualTo(UPDATED_ENTITY_OBJECT_ID);
assertThat(testUserRoleAssignment.getUserId()).isEqualTo(UPDATED_USER_ID);
assertThat(testUserRoleAssignment.getAssignedRole()).isEqualTo(UPDATED_ASSIGNED_ROLE);
}

View File

@ -21,7 +21,7 @@ describe('Service Tests', () => {
service = injector.get(UserRoleAssignmentService);
httpMock = injector.get(HttpTestingController);
elemDefault = new UserRoleAssignment(0, 'AAAAAAA', 0, 0, UserRole.HOSTMASTER);
elemDefault = new UserRoleAssignment(0, 'AAAAAAA', 0, UserRole.HOSTMASTER);
});
describe('Service methods', async () => {
@ -57,7 +57,6 @@ describe('Service Tests', () => {
{
entityTypeId: 'BBBBBB',
entityObjectId: 1,
userId: 1,
assignedRole: 'BBBBBB'
},
elemDefault
@ -77,7 +76,6 @@ describe('Service Tests', () => {
{
entityTypeId: 'BBBBBB',
entityObjectId: 1,
userId: 1,
assignedRole: 'BBBBBB'
},
elemDefault