Commit c6fb463c authored by Matija Obreza's avatar Matija Obreza

Merge branch '400-remove-auditedmodel-class' into 'master'

Resolve "Remove AuditedModel class"

Closes #400

See merge request genesys-pgr/genesys-server!324
parents f1ac09ae 444ddf80
/**
* Copyright 2014 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.genesys2.server.model;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import org.genesys.blocks.model.BasicModel;
import org.genesys.blocks.util.JsonSidConverter;
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.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldIndex;
import org.springframework.data.elasticsearch.annotations.FieldType;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@MappedSuperclass
public abstract class AuditedModel extends BasicModel {
private static final long serialVersionUID = -5927214471682331909L;
@CreatedBy
@JsonSerialize(converter = JsonSidConverter.class)
@Field(type = FieldType.String, index = FieldIndex.not_analyzed)
@JsonProperty(access = Access.READ_ONLY)
private Long createdBy;
@CreatedDate
@Column(name = "createdDate")
private Date createdDate;
@LastModifiedBy
@JsonSerialize(converter = JsonSidConverter.class)
@Field(type = FieldType.String, index = FieldIndex.not_analyzed)
@JsonProperty(access = Access.READ_ONLY)
private Long lastModifiedBy;
@LastModifiedDate
@Column(name = "lastModifiedDate")
private Date lastModifiedDate;
public Long getCreatedBy() {
return createdBy;
}
public void setCreatedBy(Long createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public Long getLastModifiedBy() {
return lastModifiedBy;
}
public void setLastModifiedBy(Long lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}
public Date getLastModifiedDate() {
return lastModifiedDate;
}
public void setLastModifiedDate(Date lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}
}
/**
* Copyright 2014 Global Crop Diversity Trust
/*
* Copyright 2019 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -12,7 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
*/
package org.genesys2.server.model.impl;
......@@ -29,13 +29,13 @@ import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.genesys.blocks.model.AuditedVersionedModel;
import org.genesys.blocks.model.ClassPK;
import org.genesys2.server.model.AuditedModel;
import org.hibernate.annotations.Type;
@Entity
@Table(name = "article")
public class Article extends AuditedModel {
public class Article extends AuditedVersionedModel {
private static final long serialVersionUID = 8690395020204070378L;
......
/**
* Copyright 2014 Global Crop Diversity Trust
/*
* Copyright 2019 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -12,7 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
*/
package org.genesys2.server.model.impl;
......@@ -23,14 +23,14 @@ import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.genesys2.server.model.AuditedModel;
import org.genesys.blocks.model.AuditedVersionedModel;
/**
* Current country status in the ITPGRFA.
*/
@Entity
@Table(name = "itpgrfa", uniqueConstraints = { @UniqueConstraint(name = "ITPGRFA_Country", columnNames = { "countryId" }) })
public class ITPGRFAStatus extends AuditedModel {
public class ITPGRFAStatus extends AuditedVersionedModel {
private static final long serialVersionUID = 2766536505832914090L;
......
/**
* Copyright 2014 Global Crop Diversity Trust
/*
* Copyright 2019 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -12,7 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
*/
package org.genesys2.server.model.impl;
......@@ -29,14 +29,14 @@ import javax.persistence.ManyToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import org.genesys2.server.model.AuditedModel;
import org.genesys.blocks.model.AuditedVersionedModel;
import org.hibernate.annotations.Type;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity
@Table(name = "organization")
public class Organization extends AuditedModel {
public class Organization extends AuditedVersionedModel {
private static final long serialVersionUID = 2710908645431936666L;
......
/**
* Copyright 2014 Global Crop Diversity Trust
/*
* Copyright 2019 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -12,7 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
*/
package org.genesys2.server.model.impl;
......@@ -24,14 +24,14 @@ import javax.persistence.Entity;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import org.genesys2.server.model.AuditedModel;
import org.genesys.blocks.model.AuditedVersionedModel;
/**
*
*/
@Entity
@Table(name = "verificationtoken")
public class VerificationToken extends AuditedModel {
public class VerificationToken extends AuditedVersionedModel {
private static final long serialVersionUID = 5031164157223780739L;
......
......@@ -23,7 +23,7 @@ import java.util.Set;
import com.hazelcast.util.CollectionUtil;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Predicate;
import org.genesys.blocks.model.filters.BasicModelFilter;
import org.genesys.blocks.model.filters.AuditedVersionedModelFilter;
import org.genesys.blocks.model.filters.StringFilter;
import org.genesys2.server.model.impl.Article;
import org.genesys2.server.model.impl.QArticle;
......@@ -31,7 +31,7 @@ import org.genesys2.server.model.impl.QArticle;
/**
* Filters for {@link Article}
*/
public class ArticleFilter extends BasicModelFilter<ArticleFilter, Article> {
public class ArticleFilter extends AuditedVersionedModelFilter<ArticleFilter, Article> {
/** The language. */
public Set<String> lang;
......@@ -57,7 +57,7 @@ public class ArticleFilter extends BasicModelFilter<ArticleFilter, Article> {
*/
public Predicate buildQuery(QArticle article) {
final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(article, article._super._super, and);
super.buildQuery(article, article._super._super._super, and);
if (CollectionUtil.isNotEmpty(lang)) {
and.and(article.lang.in(lang));
......
......@@ -4644,3 +4644,99 @@ databaseChangeLog:
- sql:
comment: Assign activitypost.version
sql: update activitypost set version = 1 where version = 0;
- changeSet:
id: 1547202185383-1
author: mborodenko
comment: Add `active` and `version` to Article
changes:
- addColumn:
tableName: article
columns:
- column:
constraints:
nullable: false
defaultValue: 0
name: version
type: INT
- column:
constraints:
nullable: false
defaultValue: true
name: active
type: BIT(1)
- sql:
comment: Assign article.version
sql: update article set version = 1 where version = 0;
- changeSet:
id: 1547202185383-2
author: mborodenko
comment: Add `active` and `version` to ITPGRFAStatus
changes:
- addColumn:
tableName: itpgrfa
columns:
- column:
constraints:
nullable: false
defaultValue: 0
name: version
type: INT
- column:
constraints:
nullable: false
defaultValue: true
name: active
type: BIT(1)
- sql:
comment: Assign itpgrfa.version
sql: update itpgrfa set version = 1 where version = 0;
- changeSet:
id: 1547202185383-3
author: mborodenko
comment: Add `active` and `version` to VerificationToken
changes:
- addColumn:
tableName: verificationtoken
columns:
- column:
constraints:
nullable: false
defaultValue: 0
name: version
type: INT
- column:
constraints:
nullable: false
defaultValue: true
name: active
type: BIT(1)
- sql:
comment: Assign verificationtoken.version
sql: update verificationtoken set version = 1 where version = 0;
- changeSet:
id: 1547202185383-4
author: mborodenko
comment: Add `active` and `version` to Organization
changes:
- addColumn:
tableName: organization
columns:
- column:
constraints:
nullable: false
defaultValue: 0
name: version
type: INT
- column:
constraints:
nullable: false
defaultValue: true
name: active
type: BIT(1)
- sql:
comment: Assign organization.version
sql: update organization set version = 1 where version = 0;
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