Skip to content

Commit

Permalink
feat: update core api model
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomgrus committed Jan 24, 2022
1 parent 051ec76 commit 7d07c34
Show file tree
Hide file tree
Showing 12 changed files with 269 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.decathlon.ara.coreapi.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.AuditorAware;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

import java.util.Optional;

@Configuration
@EnableJpaAuditing(auditorAwareRef = "auditorProvider")
public class JpaAuditingConfiguration {

@Bean
public AuditorAware<String> auditorProvider() {

/*
if you are using spring security, you can get the currently logged username with following code segment.
SecurityContextHolder.getContext().getAuthentication().getName()
*/
return () -> Optional.ofNullable("Anonymous");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.decathlon.ara.coreapi.domain;

import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;

@Data
@Entity
public class AraBugTracker {
@Id
private String code;

private String name;
private String description;

@OneToOne(optional = false)
private AraProject project;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.decathlon.ara.coreapi.domain;

import lombok.Data;

import javax.persistence.*;
import java.time.LocalDateTime;

@Data
@Entity
public class AraFeature extends Auditable<String> {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ara_feature_id")
@SequenceGenerator(name = "ara_feature_id", sequenceName = "ara_feature_id", allocationSize = 1)
private Long id;

private String name;
private String description;
private String code;
private String path;
private String status;
private String comment;

@ManyToOne
private AraPriority priority;

@ManyToOne
private AraTeam team;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.decathlon.ara.coreapi.domain;

import lombok.Data;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;

@Data
@Entity
public class AraPriority {

@EmbeddedId
private CodeWithProjectId id;

private String name;
private long level;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.decathlon.ara.coreapi.domain;

import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;

@Data
@Entity
public class AraProject {

@Id
private String code;

private String name;
private String description;
private boolean enabled = true;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.decathlon.ara.coreapi.domain;

import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;

@Data
@Entity
public class AraRepository {

@EmbeddedId
private AraRepositoryId id;

private String name;
private String description;

@Data
@Embeddable
public static class AraRepositoryId implements Serializable {
@ManyToOne
private AraProject project;
private String url;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.decathlon.ara.coreapi.domain;

import lombok.Data;

import javax.persistence.*;
import java.util.Collections;
import java.util.Set;

@Data
@Entity
public class AraRule {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ara_rule_id")
@SequenceGenerator(name = "ara_rule_id", sequenceName = "ara_rule_id", allocationSize = 1)
private Long id;

@OneToOne(optional = false)
private AraProject project;

@OneToMany
private Set<AraTag> runTags = Collections.emptySet();

@OneToMany
private Set<AraTag> executionTags = Collections.emptySet();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.decathlon.ara.coreapi.domain;

import lombok.Data;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;

@Data
@Entity
public class AraSeverity {
@EmbeddedId
private CodeWithProjectId id;

private String name;
private String description;

private long level;
private double warningThreshold;
private double failureThreshold;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.decathlon.ara.coreapi.domain;

import lombok.Data;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;

@Data
@Entity
public class AraTag {

@EmbeddedId
private CodeWithProjectId id;

private String name;
private String description;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.decathlon.ara.coreapi.domain;

import lombok.Data;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

@Data
@Entity
public class AraTeam {

@EmbeddedId
private CodeWithProjectId id;

private String name;
private String description;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.decathlon.ara.coreapi.domain;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.time.LocalDateTime;

@Getter(AccessLevel.PROTECTED)
@Setter(AccessLevel.PROTECTED)
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class Auditable<U> {

@CreatedBy
private U createdBy;

@CreatedDate
private LocalDateTime createdDate;

@LastModifiedBy
private U lastModifiedBy;

@LastModifiedDate
private LocalDateTime lastModifiedDate;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.decathlon.ara.coreapi.domain;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import java.io.Serializable;

@Embeddable
public class CodeWithProjectId implements Serializable {
@ManyToOne
private AraProject project;
private String code;
}

0 comments on commit 7d07c34

Please sign in to comment.