Skip to content

Commit

Permalink
Merge pull request #1887 from wwelling/system-data-loader-refactor
Browse files Browse the repository at this point in the history
[Issue 1883,1879,1878,1877,1876,1766,1682] 1878 continued - System data loader refactor, cleanup, and additional patches
  • Loading branch information
smutniak authored Jan 16, 2024
2 parents 3ba37f3 + b440656 commit 3d959cc
Show file tree
Hide file tree
Showing 112 changed files with 4,409 additions and 3,453 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,7 @@ dist/
!**/src/test/**

*.mv.db

### Environment Specific ###
application-*.yml
logback-*.yml
2 changes: 1 addition & 1 deletion .wvr/build-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const config = {
'./node_modules/@wvr/core/app/services/alertService.js',
'./node_modules/@wvr/core/app/services/validationStore.js',
'./node_modules/@wvr/core/app/services/userService.js',
'./node_modules/@wvr/core/app/services/modalService.js',
// './node_modules/@wvr/core/app/services/modalService.js',
'./node_modules/@wvr/core/app/services/modelCache.js',
'./node_modules/@wvr/core/app/services/modelUpdateService.js',
'./node_modules/@wvr/core/app/repo/abstractRepo.js',
Expand Down
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
<parent>
<groupId>edu.tamu.weaver</groupId>
<artifactId>webservice-parent</artifactId>
<version>2.1.1-RC19</version>
<version>2.1.1</version>
<relativePath/>
</parent>

<properties>
<java.version>11</java.version>
<maven.compiler.release>${java.version}</maven.compiler.release>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -222,6 +223,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
27 changes: 16 additions & 11 deletions src/main/java/org/tdl/vireo/ApplicationInitialization.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package org.tdl.vireo;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Profile;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import org.springframework.stereotype.Component;
import org.tdl.vireo.service.EntityControlledVocabularyService;
import org.tdl.vireo.service.SystemDataLoader;

@Order(Ordered.HIGHEST_PRECEDENCE)
@Component
@Profile("!test")
public class ApplicationInitialization implements CommandLineRunner {
@Component("ApplicationInitialization")
public class ApplicationInitialization implements InitializingBean {

@Autowired
private Environment env;

@Lazy
@Autowired
Expand All @@ -24,11 +27,13 @@ public class ApplicationInitialization implements CommandLineRunner {
private EntityControlledVocabularyService entityControlledVocabularyService;

@Override
public void run(String... args) throws Exception {
// load defaults first
systemDataLoader.loadSystemData();
// assumes one language defined in defaults
entityControlledVocabularyService.scanForEntityControlledVocabularies();
public void afterPropertiesSet() throws Exception {
if (env.acceptsProfiles(Profiles.of("!isolated-test"))) {
// load defaults first
systemDataLoader.loadSystemData();
// assumes one language defined in defaults
entityControlledVocabularyService.scanForEntityControlledVocabularies();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public ApiResponse registration(@RequestBody(required = false) Map<String, Strin
content = cryptoService.validateGenericToken(token, EMAIL_VERIFICATION_TYPE);
} catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException | BadPaddingException e) {
logger.debug("Unable to validate token!");
return new ApiResponse(ERROR, "Unable to generate token!");
return new ApiResponse(ERROR, "Unable to validate token!");
}

String tokenCreateTime = content[0];
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/tdl/vireo/config/AppEmailConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import edu.tamu.weaver.email.service.EmailSender;

@Configuration
@Profile(value = { "!test" })
@Profile(value = { "!test", "!isolated-test" })
public class AppEmailConfig extends WeaverEmailConfig {

@Bean
Expand Down
22 changes: 15 additions & 7 deletions src/main/java/org/tdl/vireo/controller/OrganizationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,10 @@
import static org.springframework.beans.BeanUtils.copyProperties;
import static org.springframework.web.bind.annotation.RequestMethod.POST;

import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.tamu.weaver.response.ApiResponse;
import edu.tamu.weaver.response.ApiView;
import edu.tamu.weaver.validation.aspect.annotation.WeaverValidatedModel;
import edu.tamu.weaver.validation.aspect.annotation.WeaverValidation;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
Expand Down Expand Up @@ -47,6 +42,15 @@
import org.tdl.vireo.view.ShallowOrganizationView;
import org.tdl.vireo.view.TreeOrganizationView;

import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import edu.tamu.weaver.response.ApiResponse;
import edu.tamu.weaver.response.ApiView;
import edu.tamu.weaver.validation.aspect.annotation.WeaverValidatedModel;
import edu.tamu.weaver.validation.aspect.annotation.WeaverValidation;

@RestController
@RequestMapping("/organization")
public class OrganizationController {
Expand Down Expand Up @@ -253,6 +257,10 @@ public ApiResponse addEmailWorkflowRule(@PathVariable Long requestingOrgId, @Req
EmailWorkflowRule newEmailWorkflowRule = emailWorkflowRuleRepo.create(submissionStatus, emailRecipient, emailTemplate);
org.addEmailWorkflowRule(newEmailWorkflowRule);
organizationRepo.update(org);

HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put("id", newEmailWorkflowRule.getId());
response.setPayload(payload);
}

return response;
Expand Down
Loading

0 comments on commit 3d959cc

Please sign in to comment.