Ticket #9186 (inprogress)

Opened 7 years ago

Last modified 5 years ago

Refactor shared catalog functionality to a helper class

Reported by: Jay Rainey Owned by: Karl Palmen
Priority: major Milestone: Backlog
Component: Framework Keywords: ICAT,maintenance
Cc: Blocked By: #8538, #9208
Blocking: Tester:

Description (last modified by Jay Rainey) (diff)

When working on #9112 I noticed that ICat4Catalog and ICat3Catalog have several duplicate methods. These should be re-factored into a helper class (ICatHelper).

Templates will need to be used as several of the methods take ICatPortBindingProxy as a paramter, for example:

  void throwErrorMessage(ICat4::ICATPortBindingProxy& icat);
  void setSSLContext(ICat4::ICATPortBindingProxy& icat);
  void saveInvestigations(std::vector<ICat4::xsd__anyType*> response, API::ITableWorkspace_sptr& outputws);
  void saveDataFiles(std::vector<ICat4::xsd__anyType*> response, API::ITableWorkspace_sptr& outputws);
  void saveDataSets(std::vector<ICat4::xsd__anyType*> response, API::ITableWorkspace_sptr& outputws);
  std::string bytesToString(int64_t &fileSize);
  std::string formatDateTime(const time_t &timestamp, const std::string &format);
  void setICATProxySettings(ICat4::ICATPortBindingProxy& icat);
  savetoTableWorkspace()

These methods need to be made consistent in order for different catalogs to work together, for example, I have updated the attributes added to the workspace in ICat3Catalog here in #9112 to allow searches for ICat3 and ICat4 to work together.

If a future catalog was added, which did not output the same contents to a workspace then it would not be possible to search through it and previously catalogs. That is why these shared consistencies need to be put into place.

Change History

comment:1 Changed 7 years ago by Jay Rainey

  • Description modified (diff)

comment:2 Changed 7 years ago by Jay Rainey

  • Description modified (diff)

comment:3 Changed 7 years ago by Nick Draper

  • Status changed from new to assigned

comment:4 Changed 7 years ago by Jay Rainey

  • Blocked By 9208 added

comment:5 Changed 6 years ago by Jay Rainey

Having looked into this, methods such as saveDataFiles, saveDatasets & saveInvestigations cannot be shared because they obtain properties from the response (for example, investigation->startDate, which is named differently between catalogs (ICat3 & ICat4).

comment:6 Changed 6 years ago by Jay Rainey

  • Blocked By 8538 added

comment:7 Changed 6 years ago by Jay Rainey

  • Owner changed from Jay Rainey to Karl Palmen
  • Keywords ICAT,maintenance added; ICAT removed
  • Milestone changed from Release 3.2 to Release 3.3

comment:8 Changed 6 years ago by Jay Rainey

  • Status changed from assigned to inprogress

Add initial CatalogHelper. Refs #9186.

Changeset: 40411cf0b514aba4165d8d15f91ebf29ca027d23

comment:9 Changed 6 years ago by Jay Rainey

Added templated throwErrorMessage to helper. Refs #9186.

Changeset: ad4586c7f21c0afbb13691dc7772603ec8e52ddd

comment:10 Changed 6 years ago by Jay Rainey

Add and use catalogHelper. Refs #9186.

  • Removed throwErrorMessage from ICat4Catalog.
  • Call throwErrorMessage from helper.

Changeset: 345e736cd13887797a08b0564924ad9e95e4b364

comment:11 Changed 6 years ago by Jay Rainey

Remove ICAT3 specific error class and use helper instead. Refs #9186.

Changeset: 01be35b2a5d36ce0895262abb3dde8d764c04ef2

comment:12 Changed 6 years ago by Jay Rainey

Added workspace helper to CatalogHelper. Refs #9186.

Changeset: e362b0dcb6220b903982a2a5e681ee9a4e01a483

comment:13 Changed 6 years ago by Jay Rainey

Added private methods to helper. Refs #9186.

  • These will be used in methods that write data to workspaces from catalog responses.

Changeset: 1130d8ce71bf86eb5a0c5a375e74930286b98216

comment:14 Changed 6 years ago by Jay Rainey

Add saveDataFiles template. Refs #9186.

  • Removed casting from previously implementation (e.g. anyType to dataset) in order to force the client to pass the correct vector type.

Changeset: 92744a22ecaaf0ddbf7c59c6a0ecb1856a44f5ac

comment:15 Changed 6 years ago by Jay Rainey

Add method to cast a container's type from A to B. Refs #9186.

  • This enables casting from the automatically generated container object (anyType) to the desired parent type (datafiles, investigation etc)

Changeset: 6b814e33c8b5a20c5e4dd32b1f2d9a311494e7b1

comment:16 Changed 6 years ago by Jay Rainey

Use catalogHelper and remove ICAT4 specific methods. Refs #9186.

Changeset: 17000d95b6a02052f7f084089993e2c3e0d9d343

comment:17 Changed 6 years ago by Jay Rainey

Move session class to helper and use in catalog. Refs #9186.

Changeset: 982b38bac9171541ffa7ad3af7a247a66dc2f295

comment:18 Changed 6 years ago by Jay Rainey

Add generic saveInvestigations method to helper. Refs #9186.

Changeset: fa950568fdc64e2e944123678bea233a91eb2051

comment:19 Changed 6 years ago by Jay Rainey

Use helper saveInvestigations method. Refs #9186.

Changeset: 5268726a0401801571aa2a6671493021dc658d28

comment:20 Changed 6 years ago by Jay Rainey

Remove unused methods from ICat4Catalog. Refs #9186.

  • Made formatDateTime public to use when building the ICAT4 search query.

Changeset: 7d535bd6fa64313ea5aa8b08fb53da1490af5f78

comment:21 Changed 6 years ago by Jay Rainey

Add spacing for inherited methods for easier reading. Refs #9186.

Changeset: ffcc031fe5d1ee6d7d79cfbbc52296854d2e9ae7

comment:22 Changed 6 years ago by Jay Rainey

Move saveDataSets to helper. Refs #9186.

Changeset: c04b36ee082c2d8b8fd76984ef8c76975eddb5c8

comment:23 Changed 6 years ago by Jay Rainey

Improve formatting of helper. Refs #9186.

Changeset: feb03f788d2e1f0c8e6aa44131da0bcf33ffdcc6

comment:24 Changed 6 years ago by Jay Rainey

Remove unused template method from catalog. Refs #9186.

Changeset: a963fb53cc15e262bb3cae917887d18d72483a38

comment:25 Changed 6 years ago by Jay Rainey

Added better documentation. Refs #9186.

Changeset: ff5c4e593feaa9ebc6a1e41842ff03b32e6f580d

comment:26 Changed 6 years ago by Jay Rainey

Reorganise methods in ICat4Catalog. Refs #9186.

Changeset: 022fba3d9d400893b1d24594c885f6cbc44da2e6

comment:27 Changed 6 years ago by Jay Rainey

Added initial unit test for helper. Refs #9186.

Changeset: 8e5504cca9bf6e776846154adf1211a4cae00c9b

comment:28 Changed 6 years ago by Jay Rainey

I published the above to give an idea of what I had in mind for solving this ticket. The above changes took place before I started #8538. I made the above changes before I said comment:5. As such, there are some notable issues in the above commits, e.g. that of comment:22, which in reality won't work (I did not realise this until after trying different catalogs).

I believe that it would be best to create a new branch, and begin from scratch, while looking at the above branch for 'inspiration' when refactoring.

Last edited 6 years ago by Jay Rainey (previous) (diff)

comment:29 Changed 6 years ago by Nick Draper

Moved to the backlog at the code freeze of R3.3

comment:30 Changed 6 years ago by Nick Draper

  • Milestone changed from Release 3.3 to Backlog

comment:31 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 10029

Note: See TracTickets for help on using tickets.