Skip to content

Commit

Permalink
Merge 64de1e1 into fa77f5d
Browse files Browse the repository at this point in the history
  • Loading branch information
wwelling committed Aug 21, 2019
2 parents fa77f5d + 64de1e1 commit ade8f61
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
@@ -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
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
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
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
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
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
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
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
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
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
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
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
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
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 @@ -295,7 +286,8 @@ public static <U extends ValidatingEntity> ValidationResults validateBusiness(Bu

if (!invalid) {

// check if relationships from params(columns) will cause foreign key constraints!!
// check if relationships from params(columns) will cause foreign key
// constraints!!

U modelToDelete = (U) queryResults.get(0);

Expand Down Expand Up @@ -422,14 +414,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 +438,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
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 ade8f61

Please sign in to comment.