-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'releases/release-0.7.0' into master
- Loading branch information
Showing
21 changed files
with
751 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
CREATE VIEW riha.main_resource_view AS | ||
SELECT DISTINCT ON (json_content ->> 'uuid') * | ||
FROM riha.main_resource | ||
CREATE OR REPLACE VIEW riha.main_resource_view AS | ||
SELECT DISTINCT ON (json_content ->> 'uuid') *, | ||
((main_resource.json_content #>> '{meta,creation_timestamp}'::text[]))::timestamp AS j_creation_timestamp | ||
FROM riha.main_resource as main_resource | ||
ORDER BY json_content ->> 'uuid', | ||
creation_date DESC, | ||
main_resource_id DESC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
CREATE SEQUENCE riha.large_object_seq | ||
INCREMENT 1 | ||
START 1 | ||
MINVALUE 1 | ||
MAXVALUE 9223372036854775807 | ||
CACHE 1; | ||
GRANT SELECT, USAGE ON SEQUENCE riha.large_object_seq TO riha; | ||
|
||
-- Table: riha.large_object | ||
|
||
-- DROP TABLE riha.large_object; | ||
|
||
CREATE TABLE riha.large_object | ||
( | ||
id integer NOT NULL, | ||
creation_date timestamp without time zone, | ||
data oid, | ||
hash character varying(255), | ||
CONSTRAINT large_object_pkey PRIMARY KEY (id) | ||
) | ||
WITH ( | ||
OIDS = FALSE | ||
); | ||
|
||
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE riha.large_object TO riha; | ||
|
||
-- Table: riha.file_resource | ||
|
||
-- DROP TABLE riha.file_resource; | ||
|
||
CREATE TABLE riha.file_resource | ||
( | ||
uuid uuid NOT NULL, | ||
content_type character varying(255), | ||
creation_date timestamp without time zone, | ||
name character varying(255), | ||
large_object_id integer NOT NULL, | ||
CONSTRAINT file_resource_pkey PRIMARY KEY (uuid), | ||
CONSTRAINT fk_file_resource_large_object FOREIGN KEY (large_object_id) | ||
REFERENCES riha.large_object (id) MATCH SIMPLE | ||
ON UPDATE NO ACTION | ||
ON DELETE NO ACTION | ||
) | ||
WITH ( | ||
OIDS = FALSE | ||
); | ||
|
||
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE riha.file_resource TO riha; |
2 changes: 2 additions & 0 deletions
2
sql/update/update_20171012_add_large_object_length_column.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE riha.large_object | ||
ADD COLUMN length BIGINT; |
7 changes: 7 additions & 0 deletions
7
sql/update/update_20171013_add_info_system_creation_date_to_view.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE OR REPLACE VIEW riha.main_resource_view AS | ||
SELECT DISTINCT ON (json_content ->> 'uuid') *, | ||
((main_resource.json_content #>> '{meta,creation_timestamp}'::text[]))::timestamp AS j_creation_timestamp | ||
FROM riha.main_resource as main_resource | ||
ORDER BY json_content ->> 'uuid', | ||
creation_date DESC, | ||
main_resource_id DESC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package ee.eesti.riha.rest.dao; | ||
|
||
import ee.eesti.riha.rest.model.FileResource; | ||
import org.hibernate.SessionFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.transaction.Transactional; | ||
import java.util.Date; | ||
import java.util.UUID; | ||
|
||
@Component | ||
@Transactional | ||
public class FileResourceDAO { | ||
|
||
@Autowired | ||
private SessionFactory sessionFactory; | ||
|
||
/** | ||
* Creates single {@link FileResource} entity. | ||
* | ||
* @param entity persisted entity | ||
* @return UUID of persisted {@link FileResource} | ||
*/ | ||
public UUID create(FileResource entity) { | ||
entity.setCreationDate(new Date()); | ||
return (UUID) sessionFactory.getCurrentSession().save(entity); | ||
} | ||
|
||
/** | ||
* Retrieves single {@link FileResource} entity by its UUID. | ||
* | ||
* @param uuid entity UUID | ||
* @return loaded entity or null if not found | ||
*/ | ||
public FileResource get(UUID uuid) { | ||
return (FileResource) sessionFactory.getCurrentSession().get(FileResource.class, uuid); | ||
} | ||
} |
Oops, something went wrong.