Extending a custom data type - XNAT 1.7.2

104 views
Skip to first unread message

Raphael Espanha

unread,
Apr 3, 2017, 11:57:14 AM4/3/17
to xnat_discussion
Hi everybody,

I'm facing some difficulties trying to extend a data type that I created via plugin (from workshop 2016 example but with updated plugin project)
After some time understanding how it works I finally got it to work: create an experiment, edit it after creating and deleting it. 

But now I want to add one more element to my schema. I just added the element (pasted a previous one and changed the name), edited the edit and report vm files.

Everything looked fine until I try to submit a new experiment (image attached).

from sql.log:
INSERT INTO nonimage_clinicalInformation (id,fever,clinicalinformation_info,session_date,weight,pulse,height) VALUES ('XNAT_E00005',0,8,'Sun Feb 17 00:00:00 CET 2002','70',56,'174') was aborted.  Call getNextException to see the cause.
2017-04-03 17:44:39,206 - 
org.postgresql.util.PSQLException: ERROR: column "pulse" of relation "nonimage_clinicalinformation" does not exist
  Position: 98
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2310)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2023)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:377)

It seems my new column was not created but....

Catalina.out log shows that it got this new element and updated the db.
...
SOURCE: /var/lib/tomcat7/webapps/ROOT/
===========================
Database out of date... updating


ALTER TABLE nonimage_clinicalInformation_history  ADD COLUMN pulse INTEGER;


ALTER TABLE nonimage_clinicalInformation  ADD COLUMN pulse INTEGER NOT NULL ;
===========================
Apr 03, 2017 5:19:55 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /var/lib/tomcat7/webapps/ROOT.war has finished in 76,183 ms
Apr 03, 2017 5:19:55 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Apr 03, 2017 5:19:55 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 76431 ms
Loaded om object (org.nrg.xdat.om.NonimageClinicalinformation) as context parameter 'om'.
Loaded subject object (org.nrg.xdat.om.XnatSubjectdata) as context parameter 'subject'.


Another other problem is that I cannot see the data I inserted before I changed the datatype
We are unable to provide the requested data. Either you have encountered a link to erroneous data, or this user account (admin) does not have access to this data.
Please login with a different account or contact the source of the data to gain access.

but...
I can access it via REST (http://localhost:5656/data/projects/UKKProjectDT/subjects/UKKSubjectDT/experiments/XNAT_E00002) and i get the the same as a report page where I have "pulse" without a value (which of course makes sense). 

creating_error.PNG
dbtable.PNG
viaREST.PNG

John Flavin

unread,
Apr 3, 2017, 12:07:29 PM4/3/17
to xnat_discussion
I can't comment directly on the way XNAT is handling the data type, but I do see a problem with the database table. It's not a good idea to add a new column as "not null" if you already have data in the table. All the existing rows will not have values for that new column, which the database will see as a violation of the table's constraint.

You should consider either setting your new "pulse" column to be nullable, or (if this is just a test XNAT) maybe destroy it and create it from scratch with the strictly non-null column.

Flavin

--
You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To post to this group, send email to xnat_di...@googlegroups.com.
Visit this group at https://groups.google.com/group/xnat_discussion.
For more options, visit https://groups.google.com/d/optout.
<creating_error.PNG><dbtable.PNG><viaREST.PNG>

Raphael Espanha

unread,
Apr 3, 2017, 4:26:40 PM4/3/17
to xnat_discussion
Flavin,

Thank you for you tip and explanation! Yes, I just tested and changed pulse from integer to string and it works. Tomorrow I´ll try some workarround with a not null integer type. 
Reply all
Reply to author
Forward
0 new messages