Skip to content

Commit

Permalink
Added import without dependencies #124
Browse files Browse the repository at this point in the history
  • Loading branch information
tillias committed Jan 13, 2021
1 parent 315d0e0 commit 4881216
Show file tree
Hide file tree
Showing 34 changed files with 796 additions and 51 deletions.
3 changes: 2 additions & 1 deletion .jhipster/Microservice.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"fieldName": "name",
"fieldType": "String",
"fieldValidateRules": [
"required"
"required",
"unique"
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion .jhipster/Status.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"fieldName": "name",
"fieldType": "String",
"fieldValidateRules": [
"required"
"required",
"unique"
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion .jhipster/Team.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"fieldName": "name",
"fieldType": "String",
"fieldValidateRules": [
"required"
"required",
"unique"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions microcatalog.jdl
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// Core entities

entity Team {
name String required,
name String required unique,
teamLead String required,
productOwner String required
}

entity Status {
name String required,
name String required unique,
description String
}

entity Microservice {
name String required,
name String required unique,
description TextBlob required,
imageUrl String required,
swaggerUrl String required,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
@ConfigurationProperties(prefix = "application", ignoreUnknownFields = false)
public class ApplicationProperties {
private final ApplicationProperties.IntegrationTests integrationTests = new IntegrationTests();
private final ApplicationProperties.Imports imports = new Imports();

public IntegrationTests getIntegrationTests() {
return integrationTests;
}

public Imports getImports() {
return imports;
}

public static class IntegrationTests {

private final IntegrationTests.Jenkins jenkins = new Jenkins();
Expand Down Expand Up @@ -63,4 +68,105 @@ public void setCrumbIssuer(String crumbIssuer) {
}
}
}

public static class Imports {
private final Imports.Defaults defaults = new Defaults();

public Defaults getDefaults() {
return defaults;
}

public static class Defaults {
private String description;
private String imageUrl;
private String apiUrl;
private String gitUrl;
private String ciUrl;
private String status;
private final Defaults.Team team = new Team();


public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getImageUrl() {
return imageUrl;
}

public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}

public String getApiUrl() {
return apiUrl;
}

public void setApiUrl(String apiUrl) {
this.apiUrl = apiUrl;
}

public String getGitUrl() {
return gitUrl;
}

public void setGitUrl(String gitUrl) {
this.gitUrl = gitUrl;
}

public String getCiUrl() {
return ciUrl;
}

public void setCiUrl(String ciUrl) {
this.ciUrl = ciUrl;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}

public Team getTeam() {
return team;
}

public static class Team {
private String name;
private String po;
private String tl;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getPo() {
return po;
}

public void setPo(String po) {
this.po = po;
}

public String getTl() {
return tl;
}

public void setTl(String tl) {
this.tl = tl;
}
}
}
}
}
10 changes: 3 additions & 7 deletions src/main/java/com/github/microcatalog/domain/Microservice.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public class Microservice implements Serializable {
private Long id;

@NotNull
@Column(name = "name", nullable = false)
@Column(name = "name", nullable = false, unique = true)
private String name;


@Lob
@Type(type = "org.hibernate.type.TextType")
@Column(name = "description", nullable = false)
Expand Down Expand Up @@ -188,11 +188,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
if (id == null) {
return 31;
}

return id.intValue();
return 31;
}

// prettier-ignore
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/microcatalog/domain/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Status implements Serializable {
private Long id;

@NotNull
@Column(name = "name", nullable = false)
@Column(name = "name", nullable = false, unique = true)
private String name;

@Column(name = "description")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/microcatalog/domain/Team.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Team implements Serializable {
private Long id;

@NotNull
@Column(name = "name", nullable = false)
@Column(name = "name", nullable = false, unique = true)
private String name;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* Spring Data repository for the Microservice entity.
*/
Expand All @@ -14,5 +12,5 @@
public interface MicroserviceRepository extends JpaRepository<Microservice, Long> {
Long deleteByName(String name);

List<Microservice> findByName(String name);
Microservice findByName(String name);
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package com.github.microcatalog.repository;

import com.github.microcatalog.domain.Microservice;
import com.github.microcatalog.domain.Status;

import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* Spring Data repository for the Status entity.
*/
@SuppressWarnings("unused")
@Repository
public interface StatusRepository extends JpaRepository<Status, Long> {
Status findByName(String name);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.github.microcatalog.repository;

import com.github.microcatalog.domain.Team;

import org.springframework.data.jpa.repository.*;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

/**
Expand All @@ -11,4 +10,5 @@
@SuppressWarnings("unused")
@Repository
public interface TeamRepository extends JpaRepository<Team, Long> {
Team findByName(String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ public Dependency create(final Dependency dependency) {
* @return created dependency
*/
public DependencyDto create(final String dependencyName, final String sourceName, final String targetName) {
final Optional<Microservice> maybeSource = microserviceRepository.findByName(sourceName).stream().findFirst();
final Optional<Microservice> maybeTarget = microserviceRepository.findByName(targetName).stream().findFirst();
final Microservice source = microserviceRepository.findByName(sourceName);
final Microservice target = microserviceRepository.findByName(targetName);

if (!maybeSource.isPresent()) {
if (source == null) {
throw new IllegalArgumentException(String.format("Source microservice with name [%s] doesn't exist", sourceName));
}

if (!maybeTarget.isPresent()) {
if (target == null) {
throw new IllegalArgumentException(String.format("Target microservice with name [%s] doesn't exist", targetName));
}

final Dependency dependency = new Dependency().name(dependencyName)
.source(maybeSource.get())
.target(maybeTarget.get());
.source(source)
.target(target);
return dependencyDto(create(dependency));
}

Expand Down
Loading

0 comments on commit 4881216

Please sign in to comment.