Skip to content

Commit

Permalink
Merge branch 'releases/release-0.8.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
valesu committed Oct 18, 2017
2 parents b802ab9 + 742de03 commit 1e48c78
Show file tree
Hide file tree
Showing 54 changed files with 1,074 additions and 178 deletions.
11 changes: 0 additions & 11 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@ variables:
ARTIFACT_NAME: "ROOT.war"

stages:
- test
- build
- deploy

test:
stage: test
before_script:
- node -v
- npm -v
script:
- ./test.sh
tags:
- riha

build:
stage: build
script:
Expand Down
18 changes: 16 additions & 2 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>ee.ria.riha</groupId>
<artifactId>browser</artifactId>
<version>0.7.0</version>
<version>0.8.0</version>
</parent>

<dependencies>
Expand Down Expand Up @@ -48,6 +48,12 @@
<groupId>com.github.fge</groupId>
<artifactId>json-schema-validator</artifactId>
<version>2.2.6</version>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mailapi</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -69,10 +75,18 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>ee.ria.riha</groupId>
<artifactId>storage-client</artifactId>
<version>0.4.0</version>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package ee.ria.riha.conf;

import com.github.fge.jackson.JsonLoader;
import ee.ria.riha.domain.InfoSystemRepository;
import ee.ria.riha.domain.RihaStorageInfoSystemRepository;
import ee.ria.riha.service.JsonValidationService;
import ee.ria.riha.storage.client.StorageClient;
import ee.ria.riha.storage.domain.CommentRepository;
import ee.ria.riha.storage.domain.MainResourceRepository;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;

import java.io.IOException;
Expand All @@ -19,28 +16,14 @@
*/
@Configuration
@EnableConfigurationProperties(ApplicationProperties.class)
@EnableScheduling
public class ApplicationConfiguration {

@Bean
public MainResourceRepository mainResourceRepository(ApplicationProperties applicationProperties) {
return new MainResourceRepository(getStorageClient(applicationProperties));
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
return restTemplateBuilder.build();
}

private StorageClient getStorageClient(ApplicationProperties applicationProperties) {
RestTemplate restTemplate = new RestTemplate();
return new StorageClient(restTemplate, applicationProperties.getStorageClient().getBaseUrl());
}

@Bean
public InfoSystemRepository infoSystemRepository(MainResourceRepository mainResourceRepository) {
return new RihaStorageInfoSystemRepository(mainResourceRepository);
}

@Bean
public CommentRepository commentRepository(ApplicationProperties applicationProperties) {
return new CommentRepository(getStorageClient(applicationProperties));
}

@Bean
public JsonValidationService jsonValidationService(ApplicationProperties applicationProperties) throws IOException {
return new JsonValidationService(
Expand Down
19 changes: 19 additions & 0 deletions backend/src/main/java/ee/ria/riha/conf/ApplicationProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public class ApplicationProperties {
private final StorageClientProperties storageClient = new StorageClientProperties();
private final AuthenticationProperties authentication = new AuthenticationProperties();
private final ValidationProperties validation = new ValidationProperties();
private final NotificationProperties notification = new NotificationProperties();

@Setter
private String baseUrl;

@Getter
@Setter
Expand All @@ -43,4 +47,19 @@ public static class AuthenticationProperties {
public static class ValidationProperties {
private String jsonSchemaUrl;
}

@Getter
@Setter
public static class NotificationProperties {
private final CreatedInfoSystemsOverview createdInfoSystemsOverview = new CreatedInfoSystemsOverview();
private String from;
}

@Getter
@Setter
public static class CreatedInfoSystemsOverview {
private String[] to;
private String[] cc;
private String[] bcc;
}
}
40 changes: 40 additions & 0 deletions backend/src/main/java/ee/ria/riha/conf/StorageConfiguration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ee.ria.riha.conf;

import ee.ria.riha.domain.InfoSystemRepository;
import ee.ria.riha.domain.RihaStorageInfoSystemRepository;
import ee.ria.riha.storage.client.StorageClient;
import ee.ria.riha.storage.domain.CommentRepository;
import ee.ria.riha.storage.domain.FileRepository;
import ee.ria.riha.storage.domain.MainResourceRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class StorageConfiguration {

@Bean
public StorageClient getStorageClient(RestTemplate restTemplate, ApplicationProperties applicationProperties) {
return new StorageClient(restTemplate, applicationProperties.getStorageClient().getBaseUrl());
}

@Bean
public MainResourceRepository mainResourceRepository(StorageClient storageClient) {
return new MainResourceRepository(storageClient);
}

@Bean
public InfoSystemRepository infoSystemRepository(MainResourceRepository mainResourceRepository) {
return new RihaStorageInfoSystemRepository(mainResourceRepository);
}

@Bean
public CommentRepository commentRepository(StorageClient storageClient) {
return new CommentRepository(storageClient);
}

@Bean
public FileRepository fileRepository(RestTemplate restTemplate, ApplicationProperties applicationProperties) {
return new FileRepository(restTemplate, applicationProperties.getStorageClient().getBaseUrl());
}
}
49 changes: 49 additions & 0 deletions backend/src/main/java/ee/ria/riha/domain/model/InfoSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public class InfoSystem {
private static final String OWNER_NAME_KEY = "name";
private static final String OWNER_CODE_KEY = "code";
private static final String SHORT_NAME_KEY = "short_name";
private static final String FULL_NAME_KEY = "name";
private static final String META_KEY = "meta";
private static final String META_CREATION_TIMESTAMP_KEY = "creation_timestamp";
private static final String META_UPDATE_TIMESTAMP_KEY = "update_timestamp";

private JSONObject jsonObject = new JSONObject();

Expand All @@ -30,6 +34,9 @@ public class InfoSystem {
private String ownerName;
private String ownerCode;
private String shortName;
private String fullName;
private String creationTimestamp;
private String updateTimestamp;

public InfoSystem() {
this("{}");
Expand All @@ -45,10 +52,14 @@ public InfoSystem(JSONObject jsonObject) {
this.uuid = hasText(uuidString) ? UUID.fromString(uuidString) : null;

this.shortName = ((String) getPath(SHORT_NAME_KEY).queryFrom(jsonObject));
this.fullName = ((String) getPath(FULL_NAME_KEY).queryFrom(jsonObject));

JSONObject owner = getOwner();
this.ownerName = ((String) getPath(OWNER_NAME_KEY).queryFrom(owner));
this.ownerCode = ((String) getPath(OWNER_CODE_KEY).queryFrom(owner));

this.creationTimestamp = (String) getPath(META_CREATION_TIMESTAMP_KEY).queryFrom(getMeta());
this.updateTimestamp = (String) getPath(META_UPDATE_TIMESTAMP_KEY).queryFrom(getMeta());
}

public InfoSystem(String json) {
Expand Down Expand Up @@ -127,4 +138,42 @@ public void setShortName(String shortName) {
this.shortName = shortName;
jsonObject.putOpt(SHORT_NAME_KEY, shortName);
}

public String getFullName() {
return fullName;
}

public void setFullName(String fullName) {
this.fullName = fullName;
jsonObject.putOpt(FULL_NAME_KEY, fullName);
}

private JSONObject getMeta() {
JSONObject meta = ((JSONObject) getPath(META_KEY).queryFrom(jsonObject));

if (meta == null) {
meta = new JSONObject();
jsonObject.put(META_KEY, meta);
}

return meta;
}

public String getCreationTimestamp() {
return this.creationTimestamp;
}

public void setCreationTimestamp(String creationTimestamp) {
this.creationTimestamp = creationTimestamp;
getMeta().putOpt(META_CREATION_TIMESTAMP_KEY, creationTimestamp);
}

public String getUpdateTimestamp() {
return updateTimestamp;
}

public void setUpdateTimestamp(String updateTimestamp) {
this.updateTimestamp = updateTimestamp;
getMeta().putOpt(META_UPDATE_TIMESTAMP_KEY, updateTimestamp);
}
}
Loading

0 comments on commit 1e48c78

Please sign in to comment.