icatproject / icat.server

The ICAT server offering both SOAP and "RESTlike" interfaces to a metadata catalog.
Other
1 stars 5 forks source link

getEntityInfo: id attribute wrongly declared as nullable #258

Closed RKrahl closed 7 months ago

RKrahl commented 3 years ago

The getEntityInfo call at the SOAP interface provides information on the entity classes and their attributes. python-icat heavily relies on that information. Now I noticed that the id attribute is wrongly declared as nullable for all entity classes:

>>> client.apiversion
StrictVersion ('4.11.1')
>>> for t in client.typemap:                                    
...     c = client.typemap[t]
...     if c.BeanName is None:
...         continue
...     id_info = c.getAttrInfo(client, 'id')                    
...     print("%s: notNullable = %r" % (t, id_info.notNullable))
... 
Application: id notNullable = False
DataCollection: id notNullable = False
DataCollectionDatafile: id notNullable = False
DataCollectionDataset: id notNullable = False
DataCollectionParameter: id notNullable = False
Datafile: id notNullable = False
DatafileFormat: id notNullable = False
DatafileParameter: id notNullable = False
Dataset: id notNullable = False
DatasetParameter: id notNullable = False
DatasetType: id notNullable = False
Facility: id notNullable = False
FacilityCycle: id notNullable = False
Grouping: id notNullable = False
Instrument: id notNullable = False
InstrumentScientist: id notNullable = False
Investigation: id notNullable = False
InvestigationGroup: id notNullable = False
InvestigationInstrument: id notNullable = False
InvestigationParameter: id notNullable = False
InvestigationType: id notNullable = False
InvestigationUser: id notNullable = False
Job: id notNullable = False
Keyword: id notNullable = False
ParameterType: id notNullable = False
PermissibleStringValue: id notNullable = False
PublicStep: id notNullable = False
Publication: id notNullable = False
RelatedDatafile: id notNullable = False
Rule: id notNullable = False
Sample: id notNullable = False
SampleParameter: id notNullable = False
SampleType: id notNullable = False
Shift: id notNullable = False
Study: id notNullable = False
StudyInvestigation: id notNullable = False
User: id notNullable = False
UserGroup: id notNullable = False

But obviuosly, the id attribute must be not nullable. This is confirmed by checking the SQL database:

MariaDB [icat]> describe DATAFILE;
+--------------------+--------------+------+-----+---------+----------------+
| Field              | Type         | Null | Key | Default | Extra          |
+--------------------+--------------+------+-----+---------+----------------+
| ID                 | bigint(20)   | NO   | PRI | NULL    | auto_increment |
| CHECKSUM           | varchar(255) | YES  |     | NULL    |                |
| CREATE_ID          | varchar(255) | NO   |     | NULL    |                |
| CREATE_TIME        | datetime     | NO   |     | NULL    |                |
| DATAFILECREATETIME | datetime     | YES  |     | NULL    |                |
| DATAFILEMODTIME    | datetime     | YES  |     | NULL    |                |
| DESCRIPTION        | varchar(255) | YES  |     | NULL    |                |
| DOI                | varchar(255) | YES  |     | NULL    |                |
| FILESIZE           | bigint(20)   | YES  |     | NULL    |                |
| LOCATION           | varchar(255) | YES  | MUL | NULL    |                |
| MOD_ID             | varchar(255) | NO   |     | NULL    |                |
| MOD_TIME           | datetime     | NO   |     | NULL    |                |
| NAME               | varchar(255) | NO   |     | NULL    |                |
| DATAFILEFORMAT_ID  | bigint(20)   | YES  | MUL | NULL    |                |
| DATASET_ID         | bigint(20)   | NO   | MUL | NULL    |                |
+--------------------+--------------+------+-----+---------+----------------+
15 rows in set (0.001 sec)
ajkyffin commented 7 months ago

For creating a new instance of an entity, the id field should be null because it is auto-generated. This appears to be the logic in the code: https://github.com/icatproject/icat.server/blob/6053c5863b099fe49f2945c5081d4b20d48b2f7d/src/main/java/org/icatproject/core/manager/EntityInfoHandler.java#L440

RKrahl commented 7 months ago

Yes, I guess, you are right. Happy to close as invalid.