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

add Experimenter.config and lengthen Session.userIP #4762

Merged
merged 8 commits into from
Aug 2, 2016
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/dsl/resources/ome/dsl/psql-footer.vm
Original file line number Diff line number Diff line change
Expand Up @@ -797,8 +797,8 @@ create unique index originalfile_repo_path_index on originalfile (repo, path, na
--


-- ticket:11591 Shrink the userIP column as IP expected only
alter table session alter column userIP TYPE varchar(15);
-- ticket:11591 Shrink the userIP column down to maximum (IPv4-mapped IPv6)
alter table session alter column userIP TYPE varchar(45);


-- Indices. See #1640, #2573, etc.
Expand Down
3 changes: 2 additions & 1 deletion components/model/resources/mappings/meta.ome.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright 2006-2014 University of Dundee. All rights reserved.
# Copyright 2006-2016 University of Dundee. All rights reserved.
# Use is subject to license terms supplied in LICENSE.txt
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -37,6 +37,7 @@
<optional name="email" type="string"/>
</component>
<!-- TODO: ## add to dsl [email/] -->
<map name="config" type="string"/>
</properties>
</type>
<link id="ome.model.meta.GroupExperimenterMap" global="true">
Expand Down
10 changes: 7 additions & 3 deletions components/tools/OmeroPy/test/integration/test_isession.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,11 @@ def testManageMySessions(self):
finally:
c1.__del__()

def testSessionWithIP(self):
@pytest.mark.parametrize("client_ip", [
"127.0.0.1",
"2400:cb00:2048:1::6814:55",
"1234:5678:1234:5678:1234:5678:121.212.121.212"])
Copy link
Member Author

@mtbc mtbc Jul 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the curious reviewer, this imitates an IPv4-mapped IPv6 address from a dual-stack node

def testSessionWithIP(self, client_ip):
c1 = omero.client(
pmap=['--Ice.Config='+(os.environ.get("ICE_CONFIG"))])
try:
Expand All @@ -301,7 +305,7 @@ def testSessionWithIP(self):
c = omero.client(host=host, port=port)
try:
c.setAgent("OMERO.py.root_test")
c.setIP("127.0.0.1")
c.setIP(client_ip)
s = c.createSession("root", rootpass)

p = omero.sys.ParametersI()
Expand All @@ -311,7 +315,7 @@ def testSessionWithIP(self):
res = s.getQueryService().findByQuery(
"from Session where uuid=:uuid", p)

assert "127.0.0.1" == res.getUserIP().val
assert client_ip == res.getUserIP().val

s.closeOnDestroy()
c.closeSession()
Expand Down
2 changes: 1 addition & 1 deletion etc/omero.properties
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ omero.db.version=OMERO5.3DEV
# server that is is being used with. Any changes by
# developers to the database schema will result in
# a bump to this value.
omero.db.patch=7
omero.db.patch=8

# The string that will be used as the base for LSIDs
# in all exported OME objects including OME-XML and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
--

---
--- OMERO5 readiness check for upgrade from OMERO5.2__0 to OMERO5.3DEV__7.
--- OMERO5 readiness check for upgrade from OMERO5.2__0 to OMERO5.3DEV__8.
---

BEGIN;
Expand Down Expand Up @@ -245,6 +245,6 @@ DROP FUNCTION parse_transform(TEXT);
-- FINISHED
--

SELECT CHR(10)||CHR(10)||CHR(10)||'YOUR DATABASE IS READY FOR UPGRADE TO VERSION OMERO5.3DEV__7'||CHR(10)||CHR(10)||CHR(10) AS Status;
SELECT CHR(10)||CHR(10)||CHR(10)||'YOUR DATABASE IS READY FOR UPGRADE TO VERSION OMERO5.3DEV__8'||CHR(10)||CHR(10)||CHR(10) AS Status;

ROLLBACK;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
--

---
--- OMERO5 development release upgrade from OMERO5.2__0 to OMERO5.3DEV__7.
--- OMERO5 development release upgrade from OMERO5.2__0 to OMERO5.3DEV__8.
---

BEGIN;
Expand Down Expand Up @@ -95,7 +95,7 @@ DROP FUNCTION db_pretty_version(INTEGER);
--

INSERT INTO dbpatch (currentVersion, currentPatch, previousVersion, previousPatch)
VALUES ('OMERO5.3DEV', 7, 'OMERO5.2', 0);
VALUES ('OMERO5.3DEV', 8, 'OMERO5.2', 0);

-- ... up to patch 0:

Expand Down Expand Up @@ -1832,17 +1832,49 @@ CREATE INDEX i_projectiondef_renderingdef ON projectiondef(renderingdef);
CREATE INDEX i_projectiondef_axis ON projectiondef(axis);
CREATE INDEX i_projectiondef_type ON projectiondef(type);

-- ... up to patch 8:

INSERT INTO dbpatch (currentVersion, currentPatch, previousVersion, previousPatch)
VALUES ('OMERO5.3DEV', 8, 'OMERO5.3DEV', 7);

ALTER TABLE session ALTER COLUMN userip TYPE VARCHAR(45);

CREATE TABLE experimenter_config (
experimenter_id BIGINT NOT NULL,
name TEXT NOT NULL,
value TEXT NOT NULL,
index INTEGER NOT NULL,
PRIMARY KEY (experimenter_id, index),
CONSTRAINT FKexperimenter_config_map
FOREIGN KEY (experimenter_id) REFERENCES experimenter);

CREATE FUNCTION experimenter_config_map_entry_delete_trigger_function() RETURNS "trigger" AS '
BEGIN
DELETE FROM experimenter_config
WHERE experimenter_id = OLD.id;
RETURN OLD;
END;'
LANGUAGE plpgsql;

CREATE TRIGGER experimenter_config_map_entry_delete_trigger
BEFORE DELETE ON experimenter
FOR EACH ROW
EXECUTE PROCEDURE experimenter_config_map_entry_delete_trigger_function();

CREATE INDEX experimenter_config_name ON experimenter_config(name);
CREATE INDEX experimenter_config_value ON experimenter_config(value);


--
-- FINISHED
--

UPDATE dbpatch SET message = 'Database updated.', finished = clock_timestamp()
WHERE currentVersion = 'OMERO5.3DEV' AND
currentPatch = 7 AND
currentPatch = 8 AND
previousVersion = 'OMERO5.2' AND
previousPatch = 0;

SELECT CHR(10)||CHR(10)||CHR(10)||'YOU HAVE SUCCESSFULLY UPGRADED YOUR DATABASE TO VERSION OMERO5.3DEV__7'||CHR(10)||CHR(10)||CHR(10) AS Status;
SELECT CHR(10)||CHR(10)||CHR(10)||'YOU HAVE SUCCESSFULLY UPGRADED YOUR DATABASE TO VERSION OMERO5.3DEV__8'||CHR(10)||CHR(10)||CHR(10) AS Status;

COMMIT;
97 changes: 97 additions & 0 deletions sql/psql/OMERO5.3DEV__8/OMERO5.3DEV__7.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
-- Copyright (C) 2012-4 Glencoe Software, Inc. All rights reserved.
-- Use is subject to license terms supplied in LICENSE.txt
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--

---
--- OMERO5 development release upgrade from OMERO5.3DEV__7 to OMERO5.3DEV__8.
---

BEGIN;


--
-- check OMERO database version
--

CREATE OR REPLACE FUNCTION omero_assert_db_version(expected_version VARCHAR, expected_patch INTEGER) RETURNS void AS $$

DECLARE
current_version VARCHAR;
current_patch INTEGER;

BEGIN
SELECT currentversion, currentpatch INTO STRICT current_version, current_patch
FROM dbpatch ORDER BY id DESC LIMIT 1;

IF current_version <> expected_version OR current_patch <> expected_patch THEN
RAISE EXCEPTION 'wrong OMERO database version for this upgrade script';
END IF;

END;$$ LANGUAGE plpgsql;

SELECT omero_assert_db_version('OMERO5.3DEV', 7);
DROP FUNCTION omero_assert_db_version(varchar, int);


--
-- Actual upgrade
--

INSERT INTO dbpatch (currentVersion, currentPatch, previousVersion, previousPatch)
VALUES ('OMERO5.3DEV', 8, 'OMERO5.3DEV', 7);

ALTER TABLE session ALTER COLUMN userip TYPE VARCHAR(45);

CREATE TABLE experimenter_config (
experimenter_id BIGINT NOT NULL,
name TEXT NOT NULL,
value TEXT NOT NULL,
index INTEGER NOT NULL,
PRIMARY KEY (experimenter_id, index),
CONSTRAINT FKexperimenter_config_map
FOREIGN KEY (experimenter_id) REFERENCES experimenter);

CREATE FUNCTION experimenter_config_map_entry_delete_trigger_function() RETURNS "trigger" AS '
BEGIN
DELETE FROM experimenter_config
WHERE experimenter_id = OLD.id;
RETURN OLD;
END;'
LANGUAGE plpgsql;

CREATE TRIGGER experimenter_config_map_entry_delete_trigger
BEFORE DELETE ON experimenter
FOR EACH ROW
EXECUTE PROCEDURE experimenter_config_map_entry_delete_trigger_function();

CREATE INDEX experimenter_config_name ON experimenter_config(name);
CREATE INDEX experimenter_config_value ON experimenter_config(value);


--
-- FINISHED
--

UPDATE dbpatch SET message = 'Database updated.', finished = clock_timestamp()
WHERE currentVersion = 'OMERO5.3DEV' AND
currentPatch = 8 AND
previousVersion = 'OMERO5.3DEV' AND
previousPatch = 7;

SELECT CHR(10)||CHR(10)||CHR(10)||'YOU HAVE SUCCESSFULLY UPGRADED YOUR DATABASE TO VERSION OMERO5.3DEV__8'||CHR(10)||CHR(10)||CHR(10) AS Status;

COMMIT;
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,19 @@ CREATE TRIGGER roi_delete_trigger
-- #12317 -- delete map property values along with their holders
--

CREATE FUNCTION experimenter_config_map_entry_delete_trigger_function() RETURNS "trigger" AS '
BEGIN
DELETE FROM experimenter_config
WHERE experimenter_id = OLD.id;
RETURN OLD;
END;'
LANGUAGE plpgsql;

CREATE TRIGGER experimenter_config_map_entry_delete_trigger
BEFORE DELETE ON experimenter
FOR EACH ROW
EXECUTE PROCEDURE experimenter_config_map_entry_delete_trigger_function();

CREATE FUNCTION experimentergroup_config_map_entry_delete_trigger_function() RETURNS "trigger" AS '
BEGIN
DELETE FROM experimentergroup_config
Expand Down Expand Up @@ -2029,7 +2042,7 @@ alter table dbpatch alter message set default 'Updating';
-- running so that if anything goes wrong, we'll have some record.
--
insert into dbpatch (currentVersion, currentPatch, previousVersion, previousPatch, message)
values ('OMERO5.3DEV', 7, 'OMERO5.3DEV', 0, 'Initializing');
values ('OMERO5.3DEV', 8, 'OMERO5.3DEV', 0, 'Initializing');

--
-- Temporarily make event columns nullable; restored below.
Expand Down Expand Up @@ -2880,8 +2893,8 @@ create unique index originalfile_repo_path_index on originalfile (repo, path, na
--


-- ticket:11591 Shrink the userIP column as IP expected only
alter table session alter column userIP TYPE varchar(15);
-- ticket:11591 Shrink the userIP column down to maximum (IPv4-mapped IPv6)
alter table session alter column userIP TYPE varchar(45);


-- Indices. See #1640, #2573, etc.
Expand All @@ -2893,6 +2906,8 @@ create index eventlog_action on eventlog(action);
create index annotation_discriminator on annotation(discriminator);
create index annotation_ns on annotation(ns);

CREATE INDEX experimenter_config_name ON experimenter_config(name);
CREATE INDEX experimenter_config_value ON experimenter_config(value);
CREATE INDEX experimentergroup_config_name ON experimentergroup_config(name);
CREATE INDEX experimentergroup_config_value ON experimentergroup_config(value);
CREATE INDEX genericexcitationsource_map_name ON genericexcitationsource_map(name);
Expand Down Expand Up @@ -3329,6 +3344,8 @@ ALTER TABLE wellsample ADD CONSTRAINT posY_unitpair

-- Temporary workaround for the width of map types

ALTER TABLE experimenter_config ALTER COLUMN name TYPE TEXT;
ALTER TABLE experimenter_config ALTER COLUMN value TYPE TEXT;
ALTER TABLE experimentergroup_config ALTER COLUMN name TYPE TEXT;
ALTER TABLE experimentergroup_config ALTER COLUMN value TYPE TEXT;
ALTER TABLE genericexcitationsource_map ALTER COLUMN name TYPE TEXT;
Expand Down Expand Up @@ -3371,7 +3388,7 @@ CREATE TRIGGER preserve_folder_tree
-- Here we have finished initializing this database.
update dbpatch set message = 'Database ready.', finished = clock_timestamp()
where currentVersion = 'OMERO5.3DEV' and
currentPatch = 7 and
currentPatch = 8 and
previousVersion = 'OMERO5.3DEV' and
previousPatch = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,14 @@
primary key (id)
);;

create table experimenter_config (
experimenter_id int8 not null,
name varchar(255) not null,
value varchar(255) not null,
index int4 not null,
primary key (experimenter_id, index)
);;

create table experimenterannotationlink (
id int8 not null,
permissions int8 not null,
Expand Down Expand Up @@ -3351,6 +3359,11 @@
foreign key (external_id)
references externalinfo ;;

alter table experimenter_config
add constraint FKexperimenter_config_map
foreign key (experimenter_id)
references experimenter ;;

alter table experimenterannotationlink
add constraint FKexperimenterannotationlink_creation_id_event
foreign key (creation_id)
Expand Down
File renamed without changes.