Add project models
This commit is contained in:
parent
93d4da03df
commit
2a51f5fffc
12
src/main/java/ru/ulstu/fc/config/Constants.java
Normal file
12
src/main/java/ru/ulstu/fc/config/Constants.java
Normal file
@ -0,0 +1,12 @@
|
||||
package ru.ulstu.fc.config;
|
||||
|
||||
public class Constants {
|
||||
public static final int MIN_PASSWORD_LENGTH = 6;
|
||||
|
||||
public static final String LOGIN_REGEX = "^[_'.@A-Za-z0-9-]*$";
|
||||
|
||||
public static final String COOKIES_NAME = "JSESSIONID";
|
||||
public static final String LOGOUT_URL = "/login?logout";
|
||||
public static final String SESSION_ID_ATTR = "sessionId";
|
||||
public static final int SESSION_TIMEOUT_SECONDS = 30 * 60;
|
||||
}
|
84
src/main/java/ru/ulstu/fc/core/model/BaseEntity.java
Normal file
84
src/main/java/ru/ulstu/fc/core/model/BaseEntity.java
Normal file
@ -0,0 +1,84 @@
|
||||
package ru.ulstu.fc.core.model;
|
||||
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import jakarta.persistence.Version;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@MappedSuperclass
|
||||
public abstract class BaseEntity implements Serializable, Comparable<BaseEntity> {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.TABLE)
|
||||
private Integer id;
|
||||
|
||||
@Version
|
||||
private Integer version;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Integer version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!getClass().isAssignableFrom(obj.getClass())) {
|
||||
return false;
|
||||
}
|
||||
BaseEntity other = (BaseEntity) obj;
|
||||
if (id == null) {
|
||||
if (other.id != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!id.equals(other.id)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (id == null ? 0 : id.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "{" +
|
||||
"id=" + id +
|
||||
", version=" + version +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull BaseEntity o) {
|
||||
return id != null ? id.compareTo(o.getId()) : -1;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.id = null;
|
||||
this.version = null;
|
||||
}
|
||||
}
|
119
src/main/java/ru/ulstu/fc/core/model/OffsetablePageRequest.java
Normal file
119
src/main/java/ru/ulstu/fc/core/model/OffsetablePageRequest.java
Normal file
@ -0,0 +1,119 @@
|
||||
package ru.ulstu.fc.core.model;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Optional;
|
||||
|
||||
public class OffsetablePageRequest implements Pageable, Serializable {
|
||||
private final int offset;
|
||||
private final int count;
|
||||
private final Sort sort;
|
||||
|
||||
public OffsetablePageRequest(int page, long pageSize) {
|
||||
this(pageSize * page, pageSize, Sort.by("id"));
|
||||
}
|
||||
|
||||
public OffsetablePageRequest(long offset, long count, Sort sort) {
|
||||
if (offset < 0) {
|
||||
throw new IllegalArgumentException("Offset value must not be less than zero!");
|
||||
}
|
||||
if (count < 1) {
|
||||
throw new IllegalArgumentException("Count value must not be less than one!");
|
||||
}
|
||||
this.offset = (int) offset;
|
||||
this.count = (int) count;
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sort getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sort getSortOr(Sort sort) {
|
||||
return Pageable.super.getSortOr(sort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPageSize() {
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPaged() {
|
||||
return Pageable.super.isPaged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnpaged() {
|
||||
return Pageable.super.isUnpaged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPageNumber() {
|
||||
return offset / count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPrevious() {
|
||||
return offset > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Pageable> toOptional() {
|
||||
return Pageable.super.toOptional();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pageable next() {
|
||||
return new OffsetablePageRequest(getOffset() + getPageSize(), getPageSize(), getSort());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pageable previousOrFirst() {
|
||||
return hasPrevious() ? previous() : first();
|
||||
}
|
||||
|
||||
public Pageable previous() {
|
||||
return getOffset() == 0 ? this : new OffsetablePageRequest(getOffset() - getPageSize(), getPageSize(), getSort());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pageable first() {
|
||||
return new OffsetablePageRequest(0, getPageSize(), getSort());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pageable withPage(int pageNumber) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final OffsetablePageRequest other = (OffsetablePageRequest) obj;
|
||||
return this.offset == other.offset && this.count == other.count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + offset;
|
||||
result = prime * result + count;
|
||||
return result;
|
||||
}
|
||||
}
|
32
src/main/java/ru/ulstu/fc/project/model/Project.java
Normal file
32
src/main/java/ru/ulstu/fc/project/model/Project.java
Normal file
@ -0,0 +1,32 @@
|
||||
package ru.ulstu.fc.project.model;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import ru.ulstu.fc.core.model.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
public class Project extends BaseEntity {
|
||||
private String name;
|
||||
private Date createDate = new Date();
|
||||
|
||||
public Project(ProjectForm projectForm) {
|
||||
this.name = projectForm.getName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
}
|
22
src/main/java/ru/ulstu/fc/project/model/ProjectForm.java
Normal file
22
src/main/java/ru/ulstu/fc/project/model/ProjectForm.java
Normal file
@ -0,0 +1,22 @@
|
||||
package ru.ulstu.fc.project.model;
|
||||
|
||||
public class ProjectForm {
|
||||
private Integer id;
|
||||
private String name;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ import ru.ulstu.fc.rule.service.FuzzyInferenceService;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("rest")
|
||||
@RequestMapping("inferenceRest")
|
||||
public class InferenceRestController {
|
||||
private final FuzzyInferenceService fuzzyInferenceService;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user