Commit accae382 authored by Valentin Suhnjov's avatar Valentin Suhnjov

RIHAKB-206. Add more columns to comment table

parent 341b084a
......@@ -315,21 +315,17 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE riha.document TO riha;
CREATE TABLE riha.comment
(
comment_id integer NOT NULL, -- Kommentaari unikaalne ID.
uri character varying(50), -- Kommentaari unikaalne URI. See on ühine kogu ühe kommentaari hierarhiale
comment_parent_id integer, -- Kui on tegemist hierarhilise kommentaariumiga, siis viitab vanemale
organization character varying(50), -- Kommentaari loonud ettevõtte kood
json_content jsonb, -- Kommentaari väljade esitus json formaadis.
main_resource_uri character varying(150), -- Potentsiaalne viide põhiressursi URI-le
data_object_uri character varying(150), -- Potentsiaalne viide andmeobjekti URI-le
document_uri character varying(150), -- Potentsiaalne viide dokumendi URI-le
comment_uri character varying(150), -- Potentsiaalne viide kommentaari URI-le
state character(1), -- Kommentaari staatus (A-active, D-deleted jne)
creator character varying(150), -- Kirje tekitanud isiku isikukood või muu identifikaator
modifier character varying(150), -- Kirjet viimati muutnud isiku isikukood või muu identifikaator
creation_date timestamp without time zone, -- Kirje tekitamise ajamoment.
modified_date timestamp without time zone, -- Kirje viimase muutmise ajamoment.
kind character varying(150),
infosystem_uuid UUID NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
comment varchar(1000),
author_name VARCHAR(255),
author_personal_code VARCHAR(11),
organization_name VARCHAR(255),
organization_code VARCHAR(50),
status VARCHAR(150),
CONSTRAINT pk_comment PRIMARY KEY (comment_id),
CONSTRAINT fk_comment_comment FOREIGN KEY (comment_parent_id)
REFERENCES riha.comment (comment_id) MATCH SIMPLE
......@@ -341,20 +337,18 @@ OIDS=FALSE
COMMENT ON TABLE riha.comment
IS 'Tabelis hoitakse põhiressursside või andmeobjektide kohta esitatud kommentaare. Kommentaarid pole ühegi ressursi ega andmeobjekti ametlik kirjelduse koosseisu kuuluv info, vaid aitab kirjeldada ja lahti seletada ametlikku infot. Muuhulgas esitatakse ka kommentaaridena näiteks kooskõlastajate poolt tehtud märkused infosüsteemi kirjelduse kohta ja ka infosüsteemi omaniku endapoolsed kommentaarid kooskõlastajatele.';
COMMENT ON COLUMN riha.comment.comment_id IS 'Kommentaari unikaalne ID.';
COMMENT ON COLUMN riha.comment.uri IS 'Kommentaari unikaalne URI. See on ühine kogu ühe kommentaari hierarhiale';
COMMENT ON COLUMN riha.comment.comment_parent_id IS 'Kui on tegemist hierarhilise kommentaariumiga, siis viitab vanemale';
COMMENT ON COLUMN riha.comment.organization IS 'Kommentaari loonud ettevõtte kood ';
COMMENT ON COLUMN riha.comment.json_content IS 'Kommentaari väljade esitus json formaadis.';
COMMENT ON COLUMN riha.comment.main_resource_uri IS 'Potentsiaalne viide põhiressursi URI-le';
COMMENT ON COLUMN riha.comment.data_object_uri IS 'Potentsiaalne viide andmeobjekti URI-le';
COMMENT ON COLUMN riha.comment.document_uri IS 'Potentsiaalne viide dokumendi URI-le';
COMMENT ON COLUMN riha.comment.comment_uri IS 'Potentsiaalne viide kommentaari URI-le';
COMMENT ON COLUMN riha.comment.state IS 'Kommentaari staatus (A-active, D-deleted jne)';
COMMENT ON COLUMN riha.comment.creator IS 'Kirje tekitanud isiku isikukood või muu identifikaator';
COMMENT ON COLUMN riha.comment.modifier IS 'Kirjet viimati muutnud isiku isikukood või muu identifikaator';
COMMENT ON COLUMN riha.comment.creation_date IS 'Kirje tekitamise ajamoment.';
COMMENT ON COLUMN riha.comment.modified_date IS 'Kirje viimase muutmise ajamoment.';
COMMENT ON COLUMN riha.comment.infosystem_uuid IS 'InfoSystem uuid';
COMMENT ON COLUMN riha.comment.comment IS 'Hinnangu või kommentaari sisu';
COMMENT ON COLUMN riha.comment.author_name IS 'Hinnangu/kommentaari kasutaja nimi või muu identifikaator';
COMMENT ON COLUMN riha.comment.author_personal_code IS 'Hinnangu/kommentaari kasutaja isikukood';
COMMENT ON COLUMN riha.comment.organization_name IS 'Hinnangu/kommentaari kasutaja asutuse numetus';
COMMENT ON COLUMN riha.comment.organization_code IS 'Hinnangu/kommentaari kasutaja asutuse kood';
COMMENT ON COLUMN riha.comment.status IS 'Hinnangu staatus';
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE riha.comment TO riha;
......
-- Comment table refactoring for approval support
-- Remove unused columns
ALTER TABLE riha.comment DROP uri;
ALTER TABLE riha.comment DROP organization;
ALTER TABLE riha.comment DROP state;
ALTER TABLE riha.comment DROP main_resource_uri;
ALTER TABLE riha.comment DROP data_object_uri;
ALTER TABLE riha.comment DROP document_uri;
ALTER TABLE riha.comment DROP comment_uri;
ALTER TABLE riha.comment DROP creator;
ALTER TABLE riha.comment DROP modifier;
ALTER TABLE riha.comment DROP kind;
ALTER TABLE riha.comment DROP json_content;
-- Add new approval columns
ALTER TABLE riha.comment ADD author_name VARCHAR(255) NULL;
ALTER TABLE riha.comment ADD author_personal_code VARCHAR(11) NULL;
ALTER TABLE riha.comment ADD organization_name VARCHAR(255) NULL;
ALTER TABLE riha.comment ADD organization_code VARCHAR(50) NULL;
ALTER TABLE riha.comment ADD status VARCHAR(150) NULL;
ALTER TABLE riha.comment ADD title VARCHAR(255) NULL;
-- Remove limit from comment
ALTER TABLE riha.comment ALTER COLUMN comment TYPE VARCHAR USING comment::VARCHAR;
\ No newline at end of file
package ee.eesti.riha.rest.model;
import java.util.Date;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import org.springframework.transaction.annotation.Transactional;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonRawValue;
import com.google.gson.JsonObject;
import ee.eesti.riha.rest.logic.Finals;
import ee.eesti.riha.rest.model.hibernate.JsonObjectUserType;
import ee.eesti.riha.rest.model.util.DisallowUseMethodForUpdate;
import ee.eesti.riha.rest.model.util.FieldIsPK;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.*;
import java.util.Date;
import java.util.UUID;
// TODO: Auto-generated Javadoc
/**
......@@ -42,25 +33,7 @@ public class Comment implements BaseModel {
@Id
@Column(updatable = false)
private Integer comment_id;
private String uri;
private Integer comment_parent_id;
private String organization;
// http://stackoverflow.com/questions/15974474/mapping-postgresql-json-column-to-hibernate-value-type
// @Type(type = "StringJsonObject")
@JsonRawValue
// otherwise mapping exception
@Type(type = "JsonObject")
private JsonObject json_content;
private String main_resource_uri;
private String data_object_uri;
private String document_uri;
private String comment_uri;
private Character state;
private String creator;
private String modifier;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = Finals.DATE_FORMAT)
@Temporal(TemporalType.TIMESTAMP)
......@@ -70,9 +43,30 @@ public class Comment implements BaseModel {
@Temporal(TemporalType.TIMESTAMP)
private Date modified_date;
private String kind;
@Type(type="pg-uuid")
private UUID infosystem_uuid;
@Column(name = "title")
private String title;
@Column(name = "comment")
private String comment;
@Column(name = "author_name")
private String author_name;
@Column(name = "author_personal_code")
private String author_personal_code;
@Column(name = "organization_name")
private String organization_name;
@Column(name = "organization_code")
private String organization_code;
@Column(name = "status")
private String status;
/*
* (non-Javadoc)
*
......@@ -93,6 +87,26 @@ public class Comment implements BaseModel {
setComment_id(id);
}
/**
* @return null
* @deprecated not used anymore and will be removed in the future
*/
@Override
@Deprecated
@Transient
public String getUri() {
return null;
}
/**
* @deprecated not used anymore and will be removed in the future
*/
@Override
@Deprecated
@Transient
public void setUri(String uri) {
}
/**
* Gets the comment_id.
*
......@@ -112,27 +126,6 @@ public class Comment implements BaseModel {
comment_id = aComment_id;
}
/*
* (non-Javadoc)
*
* @see ee.eesti.riha.rest.model.BaseModel#getUri()
*/
@Override
public String getUri() {
return uri;
}
/*
* (non-Javadoc)
*
* @see ee.eesti.riha.rest.model.BaseModel#setUri(java.lang.String)
*/
@Override
@DisallowUseMethodForUpdate
public void setUri(String aUri) {
uri = aUri;
}
/**
* Gets the comment_parent_id.
*
......@@ -152,172 +145,63 @@ public class Comment implements BaseModel {
}
/**
* Gets the organization.
*
* @return the organization
*/
public String getOrganization() {
return organization;
}
/**
* Sets the organization.
*
* @param aOrganization the new organization
*/
public void setOrganization(String aOrganization) {
organization = aOrganization;
}
/*
* (non-Javadoc)
*
* @see ee.eesti.riha.rest.model.BaseModel#getJson_content()
* @return null
* @deprecated not used anymore and will be removed in the future
*/
@Override
@Deprecated
@Transient
public JsonObject getJson_content() {
return json_content;
return null;
}
/*
* (non-Javadoc)
*
* @see ee.eesti.riha.rest.model.BaseModel#setJson_content(com.google.gson.JsonObject)
/**
* @deprecated not used anymore and will be removed in the future
*/
@Override
@Deprecated
@Transient
public void setJson_content(JsonObject aJson_content) {
json_content = aJson_content;
}
/**
* Gets the main_resource_uri.
*
* @return the main_resource_uri
*/
public String getMain_resource_uri() {
return main_resource_uri;
}
/**
* Sets the main_resource_uri.
*
* @param aMain_resource_uri the new main_resource_uri
*/
public void setMain_resource_uri(String aMain_resource_uri) {
main_resource_uri = aMain_resource_uri;
}
/**
* Gets the data_object_uri.
*
* @return the data_object_uri
*/
public String getData_object_uri() {
return data_object_uri;
}
/**
* Sets the data_object_uri.
*
* @param aData_object_uri the new data_object_uri
*/
public void setData_object_uri(String aData_object_uri) {
data_object_uri = aData_object_uri;
}
/**
* Gets the document_uri.
*
* @return the document_uri
*/
public String getDocument_uri() {
return document_uri;
}
/**
* Sets the document_uri.
*
* @param aDocument_uri the new document_uri
*/
public void setDocument_uri(String aDocument_uri) {
document_uri = aDocument_uri;
}
/**
* Gets the comment_uri.
*
* @return the comment_uri
*/
public String getComment_uri() {
return comment_uri;
}
/**
* Sets the comment_uri.
*
* @param aComment_uri the new comment_uri
*/
public void setComment_uri(String aComment_uri) {
comment_uri = aComment_uri;
}
/**
* Gets the state.
*
* @return the state
*/
public Character getState() {
return state;
}
/**
* Sets the state.
*
* @param aState the new state
*/
public void setState(Character aState) {
state = aState;
}
/*
* (non-Javadoc)
*
* @see ee.eesti.riha.rest.model.BaseModel#getCreator()
* @return null
* @deprecated not used anymore and will be removed in the future
*/
@Override
@Deprecated
@Transient
public String getCreator() {
return creator;
return null;
}
/*
* (non-Javadoc)
*
* @see ee.eesti.riha.rest.model.BaseModel#setCreator(java.lang.String)
/**
* @deprecated not used anymore and will be removed in the future
*/
@Override
@DisallowUseMethodForUpdate
public void setCreator(String aCreator) {
creator = aCreator;
@Deprecated
@Transient
public void setCreator(String creator) {
}
/*
* (non-Javadoc)
*
* @see ee.eesti.riha.rest.model.BaseModel#getModifier()
/**
* @return null
* @deprecated not used anymore and will be removed in the future
*/
@Override
@Deprecated
@Transient
public String getModifier() {
return modifier;
return null;
}
/*
* (non-Javadoc)
*
* @see ee.eesti.riha.rest.model.BaseModel#setModifier(java.lang.String)
/**
* @deprecated not used anymore and will be removed in the future
*/
@Override
public void setModifier(String aModifier) {
modifier = aModifier;
@Deprecated
@Transient
public void setModifier(String modifier) {
}
/*
......@@ -361,25 +245,25 @@ public class Comment implements BaseModel {
modified_date = aModified_date;
}
/*
* (non-Javadoc)
*
* @see ee.eesti.riha.rest.model.BaseModel#getKind()
/**
* @return null
* @deprecated not used anymore and will be removed in the future
*/
@Override
@Deprecated
@Transient
public String getKind() {
return kind;
return null;
}
/*
* (non-Javadoc)
*
* @see ee.eesti.riha.rest.model.BaseModel#setKind(java.lang.String)
/**
* @deprecated not used anymore and will be removed in the future
*/
@Override
@Deprecated
@Transient
@DisallowUseMethodForUpdate
public void setKind(String aKind) {
kind = aKind;
}
public UUID getInfosystem_uuid() {
......@@ -390,4 +274,61 @@ public class Comment implements BaseModel {
public void setInfosystem_uuid(UUID infosystem_uuid) {
this.infosystem_uuid = infosystem_uuid;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getAuthor_name() {
return author_name;
}
public void setAuthor_name(String author_name) {
this.author_name = author_name;
}
public String getAuthor_personal_code() {
return author_personal_code;
}
public void setAuthor_personal_code(String author_personal_code) {
this.author_personal_code = author_personal_code;
}
public String getOrganization_name() {
return organization_name;
}
public void setOrganization_name(String organization_name) {
this.organization_name = organization_name;
}
public String getOrganization_code() {
return organization_code;
}
public void setOrganization_code(String organization_code) {
this.organization_code = organization_code;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
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