Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibilité de gérer le placement lors de la répartition #19

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/main/java/org/esupportail/emargement/config/PlanConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.esupportail.emargement.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component @ConfigurationProperties(prefix="emargement.plans")
public class PlanConfig {

private String path;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}
26 changes: 14 additions & 12 deletions src/main/java/org/esupportail/emargement/domain/Campus.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef;
Expand All @@ -17,22 +19,22 @@
@FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "context", type = "long")})
@Filter(name = "contextFilter", condition = "context_id= :context")
public class Campus implements ContextSupport {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.AUTO)
@JsonIgnore
private Long id;
private Long id;

@ManyToOne
@JsonIgnore
private Context context;
private String site;
@Column(columnDefinition = "TEXT")
@JsonIgnore
private String description;

private String site;

@Column(columnDefinition = "TEXT")
@JsonIgnore
private String description;

public Long getId() {
return id;
}
Expand All @@ -58,5 +60,5 @@ public Context getContext() {
public void setContext(Context context) {
this.context = context;
}

}
51 changes: 32 additions & 19 deletions src/main/java/org/esupportail/emargement/domain/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

import javax.persistence.Transient;
import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.ParamDef;
Expand All @@ -16,26 +16,29 @@
@FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "context", type = "long")})
@Filter(name = "contextFilter", condition = "context_id= :context")
public class Location implements ContextSupport {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@ManyToOne
private Context context;

private String nom;

@ManyToOne
private Campus campus;

@NumberFormat
private int capacite=0;

@Column(columnDefinition = "TEXT")
private String adresse;

private Long adeClassRoomId;

private String nom;

@ManyToOne
private Campus campus;

@NumberFormat
private int capacite=0;

@Transient
private Plan plan;

@Column(columnDefinition = "TEXT")
private String adresse;

private Long adeClassRoomId;

public Long getId() {
return id;
Expand Down Expand Up @@ -67,7 +70,7 @@ public int getCapacite() {
public void setCapacite(int capacite) {
this.capacite = capacite;
}

public String getAdresse() {
return adresse;
}
Expand All @@ -91,4 +94,14 @@ public Long getAdeClassRoomId() {
public void setAdeClassRoomId(Long adeClassRoomId) {
this.adeClassRoomId = adeClassRoomId;
}

public void setPlan(Plan plan) {
this.plan = plan;
}

public Plan getPlan() { return plan; }

public boolean hasPlan() {
return plan != null;
}
}
68 changes: 68 additions & 0 deletions src/main/java/org/esupportail/emargement/domain/Plan.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.esupportail.emargement.domain;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;

import com.fasterxml.jackson.annotation.JsonIgnore;
public class Plan {

private static final byte DEFAULT_SIZE = 10, MAX_SIZE = Byte.MAX_VALUE;
private boolean hasAlphanumEnum = true;

@Min(value=1,message="Le plan a un nombre de colonnes inférieur à 1 !")
@Max(value=MAX_SIZE,message="Le plan a dépassé le maximum de colonnes !")
private byte columns = DEFAULT_SIZE;

@Min(value=1,message="Le plan a un nombre de lignes inférieur à 1 !")
@Max(value=MAX_SIZE,message="Le plan a dépassé le maximum de lignes !")
private byte rows = DEFAULT_SIZE;

private Short[] specialPlaces = new Short[0];

@NotEmpty(message="Le plan n'a pas de place !")
private Short[] standardPlaces = new Short[0];

public void setHasAlphanumEnum(boolean alphanum) {
hasAlphanumEnum = alphanum;
}

public void setColumns(byte cols) {
columns = cols;
}

public void setRows(byte rows) {
this.rows = rows;
}

public void setSpecialPlaces(Short[] places) {
this.specialPlaces = places;
}

public void setStandardPlaces(Short[] places) {
this.standardPlaces = places;
}

public boolean getHasAlphanumEnum() {
return hasAlphanumEnum;
}

public byte getColumns() {
return columns;
}

public byte getRows() {
return rows;
}

@JsonIgnore public short getCapacity() {
return (short)standardPlaces.length;
}

public Short[] getSpecialPlaces() {
return specialPlaces;
}

public Short[] getStandardPlaces() {
return standardPlaces;
}
}
42 changes: 42 additions & 0 deletions src/main/java/org/esupportail/emargement/domain/SessionType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.esupportail.emargement.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.SequenceGenerator;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.apache.commons.lang3.ArrayUtils;
import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.ParamDef;
import org.hibernate.annotations.Parameter;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity @Table(uniqueConstraints={@UniqueConstraint(columnNames={"key","context_id"})}) @FilterDef(name="filter",parameters={@ParamDef(type="short",name="context")}) @Filter(name="filter",condition="context_id = :context") public class SessionType implements ContextSupport {
private static final String[] NATIVE_KEYS = { "CM", "COL", "CONC", "CONF", "EXAM", "EXPO", "FOR", "REU", "SEM", "TD", "TP" };
@Id @GenericGenerator(name="gen",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={@Parameter(name="increment",value="1"),@Parameter(name="sequence_name",value="session_type_sequence")}) @GeneratedValue(generator="gen") @JsonIgnore private Short id;
@NotBlank(message="Le code du type de session est vide !") @Size(max=5,message="Le code du type de session comporte plus de 5 caractères !") @Column(unique=true) @JsonIgnore private String key;
@NotBlank(message="L'intitulé du type de session est vide !") @Size(max=64,message="L'intitulé du type de session comporte plus de 64 caractères !") private String title;
@Size(max=256,message="La description du type de session comporte plus de 256 caractères !") @JsonIgnore private String description;
@NotNull(message="Le contexte du type de session est inconnu !") @ManyToOne @JsonIgnore private Context context;
public void setId(short id) { this.id = id; }
public void setKey(String key) { this.key = key; }
public void setTitle(String title) { this.title = title; }
public void setDescription(String description) { this.description = description; }
public void setContext(Context context) { this.context = context; }
public boolean getNative() { return ArrayUtils.contains(NATIVE_KEYS, key); }
public Short getId() { return id; }
public String getKey() { return key; }
public String getTitle() { return title; }
public String getDescription() { return description; }
public Context getContext() { return context; }
}
13 changes: 13 additions & 0 deletions src/main/java/org/esupportail/emargement/domain/TagCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ public static enum Motif {

private Integer nbBadgeage;

private String place;

public String toString() {
return getClass().getName() + "@" + Integer.toHexString(hashCode()) + " - place : "+ place;
}

public Long getId() {
return id;
}
Expand Down Expand Up @@ -280,6 +286,13 @@ public void setIsBlacklisted(Boolean isBlacklisted) {
this.isBlacklisted = isBlacklisted;
}

public String getPlace() {
return place;
}
public void setPlace(String place) {
this.place = place;
}

public Motif getAbsence() {
return absence;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@Repository
public interface CampusRepository extends JpaRepository<Campus, Long> {
Long countBySite(String site);

List<Campus> findByContext(Context context);
Expand All @@ -22,4 +22,8 @@ public interface CampusRepository extends JpaRepository<Campus, Long> {
//STATS
@Query(value = "select key, count(*) as count from campus, context where campus.context_id=context.id group by key order by key, count desc", nativeQuery = true)
List<Object[]> countCampusesByContext();

@Query(nativeQuery=true,value="SELECT key, COUNT(*) AS count FROM campus JOIN context ON context_id = context.id GROUP BY key ORDER BY key, count DESC")
List<Object[]> countByContext();

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class EmargementRepositoryAspect {
// Attention, ne fonctionne pas sur les native query ...
// De même cf doc hibernate "Filters apply to entity queries, but not to direct fetching."
@Before(
value="(execution(public * org.springframework.data.jpa.repository.*.*(..)) || execution(public * org.esupportail.emargement.repositories.*.*(..)) || execution(public * org.esupportail.emargement.repositories.custom.*.*(..)))" +
value="(execution(public * org.esupportail.emargement.repositories.*.*(..)) || execution(public * org.esupportail.emargement.repositories.custom.*.*(..)))" +
"&& !execution(public * org.esupportail.emargement.repositories.*.findByContextKey(..)) " +
"&& !execution(public * org.esupportail.emargement.repositories.*.findByContextId(..)) " +
"&& !execution(public * org.esupportail.emargement.repositories.*.findByContext(..)) " +
Expand Down Expand Up @@ -53,7 +53,7 @@ public void enableFilterIfNeeded(JoinPoint joinPoint) throws Throwable {
}

@After(
value="(execution(public * org.springframework.data.jpa.repository.*.*(..)) || execution(public * org.esupportail.emargement.repositories.*.*(..)) || execution(public * org.esupportail.emargement.repositories.custom.*.*(..)))",
value="(execution(public * org.esupportail.emargement.repositories.*.*(..)) || execution(public * org.esupportail.emargement.repositories.custom.*.*(..)))",
argNames="joinPoint")
public void disableFilter(JoinPoint joinPoint) throws Throwable {
em.unwrap(Session.class).disableFilter("contextFilter");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.List;

import org.esupportail.emargement.domain.Context;
import org.esupportail.emargement.domain.EsupSignature;
import org.esupportail.emargement.domain.SessionEpreuve;
import org.esupportail.emargement.domain.TagCheck;
Expand All @@ -13,8 +12,6 @@

@Repository
public interface EsupSignatureRepository extends JpaRepository<EsupSignature, Long>{

List<EsupSignature> findByContext(Context context);

List<EsupSignature> findBySignRequestId(Long signRequestId);

Expand Down
Loading