Skip to content

Commit

Permalink
Merge pull request #114 from TAMULib/product-sprint6-staging
Browse files Browse the repository at this point in the history
Product sprint6 staging
  • Loading branch information
jcreel committed Sep 18, 2020
2 parents e9fd033 + b2effd6 commit 5dbc87e
Show file tree
Hide file tree
Showing 28 changed files with 298 additions and 339 deletions.
8 changes: 8 additions & 0 deletions pom.xml
Expand Up @@ -162,6 +162,9 @@
<ignore>java.util.logging.*</ignore>
<ignore>edu.tamu.app.config.AppEmailConfig</ignore>
</ignores>
<excludes>
<exclude>**/ProjectInitialization.class</exclude>
</excludes>
</instrumentation>
<formats>
<format>html</format>
Expand All @@ -173,6 +176,11 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/ProjectInitialization.class</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/edu/tamu/app/ProjectInitialization.java
Expand Up @@ -2,6 +2,7 @@

import java.util.Arrays;
import java.util.HashSet;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
Expand Down Expand Up @@ -29,6 +30,14 @@ public class ProjectInitialization implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
remoteProjectManagerRepo.findAll().forEach(versionManagementSoftware -> {
if (Optional.ofNullable( versionManagementSoftware.getUrl()).isPresent()) {
return;
}

if (Optional.ofNullable( versionManagementSoftware.getToken()).isPresent()) {
return;
}

managementBeanRegistry.register(versionManagementSoftware);
});
CardType type = cardTypeRepo.findByIdentifier("Feature");
Expand Down
Expand Up @@ -10,7 +10,7 @@ public class StatusMappingService extends AbstractRepoMappingService<String, Str

@Override
public String handleUnmapped(String rawData) {
return rawData == null ? "None" : rawData;
return rawData == null ? "None" : "In Progress";
}

}
61 changes: 26 additions & 35 deletions src/main/java/edu/tamu/app/model/ManagementService.java
@@ -1,20 +1,12 @@
package edu.tamu.app.model;

import static javax.persistence.FetchType.EAGER;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.ElementCollection;
import javax.persistence.Enumerated;
import javax.persistence.MappedSuperclass;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonView;

import edu.tamu.app.model.converter.CryptoConverter;
Expand All @@ -25,34 +17,36 @@
@MappedSuperclass
public abstract class ManagementService extends ValidatingBaseEntity {

@Column
@Column(nullable = false)
@JsonView(ApiView.Partial.class)
@JsonInclude(Include.NON_NULL)
protected String name;

@Enumerated
@JsonView(ApiView.Partial.class)
@JsonInclude(Include.NON_NULL)
protected ServiceType type;

@ElementCollection(fetch = EAGER)
@Fetch(FetchMode.SELECT)
@Convert(attributeName = "value", converter = CryptoConverter.class)
protected Map<String, String> settings;
@Column
@JsonView(ApiView.Partial.class)
protected String url;

@Column
@JsonView(ApiView.Partial.class)
@Convert(converter = CryptoConverter.class)
protected String token;

public ManagementService() {
super();
modelValidator = new ManagementServiceValidator();
settings = new HashMap<String, String>();
}

public ManagementService(String name, ServiceType type) {
public ManagementService(String name, ServiceType type, String url, String token) {
this();
this.name = name;
this.type = type;
}

public ManagementService(String name, ServiceType type, Map<String, String> settings) {
this(name, type);
this.settings = settings;
this.url = url;
this.token = token;
}

public String getName() {
Expand All @@ -71,23 +65,20 @@ public void setType(ServiceType type) {
this.type = type;
}

public Map<String, String> getSettings() {
return settings;
public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public void setSettings(HashMap<String, String> settings) {
this.settings = settings;
public String getToken() {
return token;
}

public Optional<String> getSettingValue(String key) {
Optional<String> targetSetting = Optional.empty();
for (Map.Entry<String, String> setting : settings.entrySet()) {
if (setting.getKey().equals(key)) {
targetSetting = Optional.of(setting.getValue());
break;
}
}
return targetSetting;
public void setToken(String token) {
this.token = token;
}

}
32 changes: 30 additions & 2 deletions src/main/java/edu/tamu/app/model/Product.java
Expand Up @@ -7,9 +7,12 @@
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import com.fasterxml.jackson.annotation.JsonView;

import edu.tamu.app.model.validation.ProductValidator;
Expand Down Expand Up @@ -48,6 +51,12 @@ public class Product extends ValidatingBaseEntity {
@JsonView(ApiView.Partial.class)
private String wikiUrl;

@LazyCollection(LazyCollectionOption.FALSE)
@ElementCollection
@JsonInclude(Include.NON_NULL)
@JsonView(ApiView.Partial.class)
private List<String> otherUrls;

@ElementCollection(fetch = FetchType.EAGER)
@JsonView(ApiView.Partial.class)
private List<RemoteProjectInfo> remoteProjectInfo;
Expand All @@ -68,7 +77,7 @@ public Product(String name, List<RemoteProjectInfo> remoteProjectInfo) {
this.remoteProjectInfo = remoteProjectInfo;
}

public Product(String name, List<RemoteProjectInfo> remoteProjectInfo, String scopeId, String devUrl, String preUrl, String productionUrl, String wikiUrl) {
public Product(String name, List<RemoteProjectInfo> remoteProjectInfo, String scopeId, String devUrl, String preUrl, String productionUrl, String wikiUrl, List<String> otherUrls) {
this();
this.name = name;
this.remoteProjectInfo = remoteProjectInfo;
Expand All @@ -77,6 +86,7 @@ public Product(String name, List<RemoteProjectInfo> remoteProjectInfo, String sc
this.preUrl = preUrl;
this.productionUrl = productionUrl;
this.wikiUrl = wikiUrl;
this.otherUrls = otherUrls;
}

public String getName() {
Expand Down Expand Up @@ -127,6 +137,24 @@ public void setWikiUrl(String wikiUrl) {
this.wikiUrl = wikiUrl;
}

public List<String> getOtherUrls() {
return otherUrls;
}

public void setOtherUrls(List<String> otherUrls) {
this.otherUrls = otherUrls;
}

public void addOtherUrl(String otherUrl) {
this.otherUrls.add(otherUrl);
}

public void removeOtherUrl(String otherUrl) {
this.otherUrls = this.otherUrls.stream()
.filter(o -> !o.equals(otherUrl))
.collect(Collectors.toList());
}

public List<RemoteProjectInfo> getRemoteProjectInfo() {
return remoteProjectInfo;
}
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/edu/tamu/app/model/RemoteProjectManager.java
@@ -1,7 +1,5 @@
package edu.tamu.app.model;

import java.util.Map;

import javax.persistence.Entity;

@Entity
Expand All @@ -11,12 +9,8 @@ public RemoteProjectManager() {
super();
}

public RemoteProjectManager(String name, ServiceType type) {
super(name, type);
}

public RemoteProjectManager(String name, ServiceType type, Map<String, String> settings) {
super(name, type, settings);
public RemoteProjectManager(String name, ServiceType type, String url, String token) {
super(name, type, url, token);
}

}
3 changes: 3 additions & 0 deletions src/main/java/edu/tamu/app/model/ServiceType.java
Expand Up @@ -40,6 +40,9 @@ public List<Setting> getScaffold() {
List<Setting> scaffold = new ArrayList<Setting>();
switch (this) {
case GITHUB:
scaffold.add(new Setting("text", "url", "URL", true));
scaffold.add(new Setting("password", "token", "Token", false));
break;
case VERSION_ONE:
scaffold.add(new Setting("text", "url", "URL", true));
scaffold.add(new Setting("text", "username", "Username", false));
Expand Down
Expand Up @@ -12,5 +12,11 @@ public ManagementServiceValidator() {

String typeProperty = "type";
this.addInputValidator(new InputValidator(InputValidationType.required, "A Management service requires a type", typeProperty, true));

String urlProperty = "url";
this.addInputValidator(new InputValidator(InputValidationType.required, "A Remote Project Manager requires a URL", urlProperty, true));

String tokenProperty = "token";
this.addInputValidator(new InputValidator(InputValidationType.required, "A Remote Project Manager requires a token", tokenProperty, true));
}
}
33 changes: 0 additions & 33 deletions src/main/java/edu/tamu/app/rest/BasicAuthInterceptor.java

This file was deleted.

35 changes: 0 additions & 35 deletions src/main/java/edu/tamu/app/rest/BasicAuthRestTemplate.java

This file was deleted.

0 comments on commit 5dbc87e

Please sign in to comment.