Skip to content

Commit

Permalink
Merge pull request #105 from TAMULib/2.x-remove-system-default-handling
Browse files Browse the repository at this point in the history
Remove system default handling, patch version snapshot
  • Loading branch information
jcreel authored Oct 18, 2019
2 parents fa77f5d + 58b659c commit 1843472
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: java

jdk:
- oraclejdk8
- openjdk8

install:
- mvn test-compile -DskipTests=true -Dmaven.javadoc.skip=true -B -V
Expand Down
10 changes: 5 additions & 5 deletions auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,33 @@
<parent>
<groupId>edu.tamu.weaver</groupId>
<artifactId>webservice-parent</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<dependencies>

<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>core</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>user</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>token</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>email</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>edu.tamu.weaver</groupId>
<artifactId>webservice-parent</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
<parent>
<groupId>edu.tamu.weaver</groupId>
<artifactId>webservice-parent</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<dependencies>

<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>core</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class EntityUtility {
public static final String NAME_COLUMN_NAME = "name";
public static final String PASSWORD_COLUMN_NAME = "password";
public static final String POSITION_COLUMN_NAME = "position";
public static final String SYSTEM_COLUMN_NAME = "isSystemRequired";

public static String snakeToCamelWithoutId(String value) {
int l = 0;
Expand Down Expand Up @@ -205,14 +204,6 @@ public static List<Object> queryByProperty(Class<?> clazz, String property, Obje
return entityManager.createQuery(query).getResultList();
}

public static Object createNewFromSystemDefault(Object model) {
EntityManager entityManager = SpringContext.bean(EntityManager.class);
setValueForProperty(model, SYSTEM_COLUMN_NAME, false);
setValueForProperty(model, ID_COLUMN_NAME, null);
entityManager.persist(model);
return model;
}

public static Field recursivelyFindField(Class<?> clazz, String property) {
Field field = null;
try {
Expand Down
2 changes: 1 addition & 1 deletion email/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>edu.tamu.weaver</groupId>
<artifactId>webservice-parent</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion messaging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>edu.tamu.weaver</groupId>
<artifactId>webservice-parent</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<artifactId>webservice-parent</artifactId>

<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>

<name>Weaver Webservice Parent</name>

Expand Down
6 changes: 3 additions & 3 deletions reporting/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
<parent>
<groupId>edu.tamu.weaver</groupId>
<artifactId>webservice-parent</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<dependencies>

<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>core</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>email</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
6 changes: 3 additions & 3 deletions token-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>edu.tamu.weaver</groupId>
<artifactId>webservice-parent</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<dependencies>
Expand All @@ -26,13 +26,13 @@
<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>token</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>core</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion token/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>edu.tamu.weaver</groupId>
<artifactId>webservice-parent</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
6 changes: 3 additions & 3 deletions user/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>edu.tamu.weaver</groupId>
<artifactId>webservice-parent</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<dependencies>
Expand All @@ -21,13 +21,13 @@
<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>data</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>validation</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</dependency>

</dependencies>
Expand Down
4 changes: 2 additions & 2 deletions validation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>edu.tamu.weaver</groupId>
<artifactId>webservice-parent</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<dependencies>
Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>data</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import static edu.tamu.weaver.data.utility.EntityUtility.NAME_COLUMN_NAME;
import static edu.tamu.weaver.data.utility.EntityUtility.PASSWORD_COLUMN_NAME;
import static edu.tamu.weaver.data.utility.EntityUtility.SYSTEM_COLUMN_NAME;
import static edu.tamu.weaver.data.utility.EntityUtility.createNewFromSystemDefault;
import static edu.tamu.weaver.data.utility.EntityUtility.getFieldForProperty;
import static edu.tamu.weaver.data.utility.EntityUtility.getValueForProperty;
import static edu.tamu.weaver.data.utility.EntityUtility.getValueFromPath;
import static edu.tamu.weaver.data.utility.EntityUtility.queryAllWithClass;
Expand Down Expand Up @@ -237,16 +234,10 @@ public static <U extends ValidatingEntity> ValidationResults validateBusiness(Bu

// check if unique constraints will be violated!!

Boolean isSystemRequired = (Boolean) getValueForProperty(model, SYSTEM_COLUMN_NAME);

if (isSystemRequired != null && isSystemRequired) {
model = (U) createNewFromSystemDefault(model);
} else {
if (uniqueConstraintPropertyChange(model)) {
UniqueConstraintViolation uniqueConstraintViolation = validateUniqueConstraints(model);
invalid = uniqueConstraintViolation.invalid;
message = uniqueConstraintViolation.message;
}
if (uniqueConstraintPropertyChange(model)) {
UniqueConstraintViolation uniqueConstraintViolation = validateUniqueConstraints(model);
invalid = uniqueConstraintViolation.invalid;
message = uniqueConstraintViolation.message;
}
}

Expand Down Expand Up @@ -422,14 +413,6 @@ public static <U extends ValidatingEntity> ValidationResults validateBusiness(Bu

}

if (!invalid) {
Object value = getValueForProperty(model, SYSTEM_COLUMN_NAME);
if (value != null && ((Boolean) value) == true) {
invalid = true;
message = model.getClass().getSimpleName() + " with id " + ((WeaverEntity) model).getId() + " is a system default and cannot be deleted";
}
}

if (invalid) {
results.addMessage(BUSINESS_MESSAGE_KEY, validator.getType().toString(), message);
results.setValid(false);
Expand All @@ -454,24 +437,6 @@ public static <U extends ValidatingEntity> ValidationResults validateBusiness(Bu
}
}

// check if model has a system default

if (!invalid) {
if (getFieldForProperty(model, SYSTEM_COLUMN_NAME) == null) {
invalid = true;
message = model.getClass().getSimpleName() + " is not a system default in which can be reset";
}
}

// check if model is not a system default

if (!invalid) {
if ((Boolean) getValueForProperty(model, SYSTEM_COLUMN_NAME) == true) {
invalid = true;
message = model.getClass().getSimpleName() + " is the system default";
}
}

if (invalid) {
results.addMessage(BUSINESS_MESSAGE_KEY, validator.getType().toString(), message);
results.setValid(false);
Expand Down
4 changes: 2 additions & 2 deletions wro/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>edu.tamu.weaver</groupId>
<artifactId>webservice-parent</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<dependencies>
Expand All @@ -22,7 +22,7 @@
<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>data</artifactId>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down

0 comments on commit 1843472

Please sign in to comment.