Commit 8614f6e7 authored by femiadeyemi's avatar femiadeyemi
Browse files

add new properties to market-service enity

Motivation:

To fullfill the service metadata description defined by the
cloud management board, new properties need to be added to
the market-service entity.

Modification:

- add lombok dependency to the cerebrum project to avoid some
    boilterplate codes
- add some few new properties to the market-service entity
- enable database auditing to keep track of when an entity was
    created and when it was last modified.
- adjust the MarketServiceRepository to fit the new market-service
    properties definition

Result:

Market-service entity contain some new properties and some few name
change.

Target: master
parent cc3b010a
Pipeline #73194 failed with stages
in 7 minutes and 25 seconds
......@@ -127,6 +127,12 @@
<version>${hibernate-validator.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- api doc stuff -->
<dependency>
<groupId>org.springdoc</groupId>
......@@ -170,6 +176,14 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.owasp</groupId>
......
package de.helmholtz.marketplace.cerebrum.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.annotation.EnableNeo4jAuditing;
@Configuration(proxyBeanMethods = false)
@EnableNeo4jAuditing
public class CerebrumDataConfig
{}
package de.helmholtz.marketplace.cerebrum.entities;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PROTECTED)
public class AuditMetadata
{
@Schema(description = "Creation date of a Service", example = "2020-02-19")
@CreatedDate
private long createdDate;
@Schema(description = "Date of last modification", example = "2020-03-24")
@LastModifiedDate
private long lastModifiedDate;
}
package de.helmholtz.marketplace.cerebrum.entities;
public enum Authentication {
BASIC, OAUTH2, SHIBBOLETH,
}
package de.helmholtz.marketplace.cerebrum.entities;
public enum LifecycleStatus {
REQUESTED, PLANNED, IN_CREATION, TESTING, PRODUCTION, DEPRECATED, UNSUPPORTED, DISCONTINUED
}
......@@ -2,12 +2,17 @@ package de.helmholtz.marketplace.cerebrum.entities;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
......@@ -18,10 +23,14 @@ import de.helmholtz.marketplace.cerebrum.utils.CerebrumEntityUuidGenerator;
import static de.helmholtz.marketplace.cerebrum.utils.CerebrumEntityUuidGenerator.generate;
import static org.neo4j.ogm.annotation.Relationship.INCOMING;
public class MarketService
@Setter(AccessLevel.PUBLIC)
@Getter(AccessLevel.PUBLIC)
@NodeEntity
public class MarketService extends AuditMetadata
{
@Schema(description = "Unique identifier of the market service.",
example = "svc-01eac6d7-0d35-1812-a3ed-24aec4231940", required = true)
@Setter(AccessLevel.NONE)
@Id @GeneratedValue(strategy = CerebrumEntityUuidGenerator.class)
private String uuid;
......@@ -33,24 +42,39 @@ public class MarketService
example = "A awesome Sync+Share Service provides by Helmholtz Zentrum xy")
private String description;
@Schema(description = "Summary of the service's descriptio",
example = "A awesome Sync+Share Service provides by Helmholtz Zentrum xy")
@Schema(description = "Summary of the service's description", example = "Sync+Share Service")
private String summary;
@Schema(description = "Url to a Service", example = "serviceXy.helmholtz.de")
private String url;
private String entryPoint;
@Schema(description = "The service version number", example = "1.0.1")
private String version;
@Schema(description = "Service's email address", example = "fake-email@example.org")
@Email
private String email;
@Schema(description = "", example = "True")
private boolean multiTenancy;
@Schema(description = "")
private String enrolmentPolicy;
@Schema(description = "Creation date of a Service", example = "2020-02-19")
private Date created;
@Schema(description = "")
private String policy;
@Schema(description = "Date of last modification", example = "2020-03-24")
private Date lastModified;
@Schema(description = "")
private String documentation;
@Schema(description = "Specifies the current lifecycle")
private LifecycleStatus lifecycleStatus;
@Schema(description = "", example = "PRODUCTION")
private Phase phase;
@Schema(description = "Specifies the authentication which a user can use to log in to a service")
private Authentication authentication;
@Schema(description = "")
private List<String> targetGroup = new ArrayList<>();
@Schema(description = "")
private List<String> tags = new ArrayList<>();
@Schema(description = "List of services provided by this organisation")
@JsonIgnoreProperties({"marketService"})
......@@ -61,11 +85,6 @@ public class MarketService
@Relationship(type = "MANAGES", direction = INCOMING)
private List<Management> managementTeam;
public String getUuid()
{
return uuid;
}
public void setUuid(String uuid)
{
this.uuid = Boolean.TRUE.equals(
......@@ -73,106 +92,6 @@ public class MarketService
? uuid : generate("org");
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getDescription()
{
return description;
}
public String getSummary()
{
return summary;
}
public void setDescription(String description)
{
this.description = description;
}
public void setSummary(String summary)
{
this.summary = summary;
}
public String getUrl()
{
return url;
}
public void setUrl(String url)
{
this.url = url;
}
public Date getCreated()
{
return created;
}
public void setCreated(Date created)
{
this.created = created;
}
public Date getLastModified()
{
return lastModified;
}
public void setLastModified(Date lastModified)
{
this.lastModified = lastModified;
}
public LifecycleStatus getLifecycleStatus()
{
return lifecycleStatus;
}
public void setLifecycleStatus(LifecycleStatus lifecycleStatus)
{
this.lifecycleStatus = lifecycleStatus;
}
public Authentication getAuthentication()
{
return authentication;
}
public void setAuthentication(Authentication authentication)
{
this.authentication = authentication;
}
public List<ServiceProvider> getServiceProviders()
{
return serviceProviders;
}
public void setServiceProviders(List<ServiceProvider> serviceProviders)
{
this.serviceProviders = serviceProviders;
}
public List<Management> getManagementTeam()
{
return managementTeam;
}
public void setManagementTeam(List<Management> managementTeam)
{
this.managementTeam = managementTeam;
}
@Override
public boolean equals(Object o)
{
......@@ -180,13 +99,19 @@ public class MarketService
if (o == null || getClass() != o.getClass()) return false;
MarketService service = (MarketService) o;
return name.equals(service.name) &&
url.equals(service.url) &&
Objects.equals(created, service.created);
entryPoint.equals(service.entryPoint);
}
@Override
public int hashCode()
{
return Objects.hash(name, url, created);
return Objects.hash(name, entryPoint);
}
}
enum Phase
{
TEST,
PILOT,
PRODUCTION
}
......@@ -14,7 +14,7 @@ public interface MarketServiceRepository extends Neo4jRepository<MarketService,
Optional<MarketService> findByName(@Param("name") String name);
Optional<MarketService> findByUrl(@Param("url") String url);
Optional<MarketService> findByEntryPoint(@Param("entryPoint") String url);
@Query("MATCH (service:MarketService),(org:Organization) " +
"WHERE service.uuid = $serviceUuid AND org.uuid = $orgUuid " +
......
......@@ -174,7 +174,7 @@ class MarketServiceControllerTest
src.setUuid(uuid);
src.setName(name);
src.setDescription(description);
src.setUrl(url);
src.setEntryPoint(url);
return src;
}
......@@ -386,7 +386,7 @@ class MarketServiceControllerTest
{
//given
services.sort(Comparator.comparing(
MarketService::getUrl, Comparator.reverseOrder()));
MarketService::getEntryPoint, Comparator.reverseOrder()));
Pageable pageable = PageRequest.of(
0,20, Sort.by(Sort.Order.desc("url")));
Page<MarketService> page = new PageImpl<>(services, pageable,200L);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment