├── .codeclimate.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── Vagrantfile ├── conf ├── auConfig.xml ├── beConfig.xml ├── dkconfig.xml ├── esConfig.xml ├── intConfig.xml ├── nlConfig.xml ├── seConfig.xml ├── ukConfig.xml ├── usConfig.xml └── uyConfig.xml ├── deb └── control │ ├── control │ ├── postinst │ ├── postrm │ ├── preinst │ └── prerm ├── pom.xml ├── scripts ├── import-tc.sh ├── import.sh ├── provision.sh ├── run.sh ├── unzip-import.sh └── zipAndUpload.sh └── src └── main ├── java └── org │ └── ihtsdo │ └── json │ ├── TextUtil.java │ ├── Transformer.java │ ├── Transformer4F.java │ ├── TransformerConfig.java │ ├── TransformerDiskBased.java │ ├── model │ ├── Component.java │ ├── Concept.java │ ├── ConceptAncestor.java │ ├── ConceptDescriptor.java │ ├── Description.java │ ├── LangMembership.java │ ├── LightDescription.java │ ├── LightLangMembership.java │ ├── LightRefsetMembership.java │ ├── LightRelationship.java │ ├── RefsetDescriptor.java │ ├── RefsetMembership.java │ ├── Relationship.java │ ├── ResourceSetManifest.java │ ├── TextIndexDescription.java │ └── versioned │ │ ├── Component.java │ │ ├── Concept.java │ │ ├── Concept4F.java │ │ ├── ConceptAncestor.java │ │ ├── ConceptDescriptor.java │ │ ├── Description.java │ │ ├── LangMembership.java │ │ ├── LightDescription.java │ │ ├── LightLangMembership.java │ │ ├── LightRefsetMembership.java │ │ ├── LightRelationship.java │ │ ├── RefsetMembership.java │ │ ├── Relationship.java │ │ └── TextIndexDescription.java │ ├── runners │ ├── ConfigRunner.java │ ├── EsRunner.java │ ├── GMDNRunner.java │ └── MultiEnglishEditionRunner.java │ └── utils │ ├── ArrayComparator.java │ ├── CommonUtils.java │ ├── FileHelper.java │ ├── FileSorter.java │ └── TClosure.java └── resources ├── char_conversion_table.txt ├── greek_character_conversion_table.txt └── validation-rules.xml /.codeclimate.yml: -------------------------------------------------------------------------------- 1 | --- 2 | engines: 3 | fixme: 4 | enabled: true 5 | ratings: 6 | paths: [] 7 | exclude_paths: [] 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant* 2 | work* 3 | *-edition* 4 | 5 | *.class 6 | 7 | # Package Files # 8 | *.jar 9 | *.war 10 | *.ear 11 | 12 | target/ 13 | pom.xml.tag 14 | pom.xml.releaseBackup 15 | pom.xml.next 16 | release.properties 17 | .idea 18 | *.iml 19 | .classpath 20 | .project 21 | .settings -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RF2 to json conversion utility [![Build Status](https://travis-ci.org/IHTSDO/rf2-to-json-conversion.svg?branch=master)](https://travis-ci.org/IHTSDO/rf2-to-json-conversion) [![Code Climate](https://codeclimate.com/github/IHTSDO/rf2-to-json-conversion/badges/gpa.svg)](https://codeclimate.com/github/IHTSDO/rf2-to-json-conversion) 2 | 3 | This utility **will not work with SNOMED CT releases from the July 2019 International Edition release of SNOMED CT onwards** due to changes to how stated relationships are represented. **This utility is no longer supported ffrom the July 2019 release onwards.** 4 | 5 | Conversion of SNOMED CT RF2 files to a JSON format, including pre-computed indexes for common search strategies 6 | 7 | Please see the bottom of this readme file for instructions for users who are developing within the IHTSDO. 8 | 9 | ## Building (manual instructions) 10 | Build the project using Maven, it will generate an executable jar with embedded dependencies (i.e. "target/rf2-to-json-conversion-1.0-SNAPSHOT-jar-with-dependencies.jar"). 11 | 12 | ## Conversion configuration 13 | Create a config.xml for the conversion execution, it requires to define the location of the source RF2 Snapshot files. 14 | 15 | ``` 16 | 17 | 18 | true 19 | en 20 | 900000000000003001 21 | 900000000000509007 22 | true 23 | false 24 | International Edition 25 | en-edition 26 | 20140131 27 | 20150201 28 | /Users/alo/Downloads/Releases/en-json 29 | 30 | /Users/alo/Downloads/Releases/SnomedCT_Release_INT_20140131/RF2Release/Snapshot 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | ``` 40 | 41 | Variables: 42 | - _processInMemory_: true for processing with memory maps, really fast, but it requires 8gb of RAM for simple proyects (International Edition + 1 extension). Set to false for using disk based maps, slower but runs with less memory. 43 | - _defaultTermLangCode_: Language code for default term selection. 44 | - _defaultTermDescriptionType_: description type SCTID for the default term selection, some prefer to use the FSN as default term, other prefer to use a Synonym (the preferred synonym will be picked). 45 | - _defaultTermLanguageRefset_: language reference set used to identify the preferred acceptability. 46 | - _normalizeTextIndex_: setting this to True will normalize the text index with diacritics removal. 47 | - _createCompleteConceptsFile_: Always set to false, true provides an additional level of denormalization not implemented in any APIS today and increases significantly the size of the resulting model. 48 | - _editionName_: name for this edition. 49 | - _databaseName_: short name for the edition, used for the ongodb database. 50 | - _effectiveTime_: release date/effective time for the finl package, if it combines the International Edition and an extension use the later date, usually the extension one. 51 | - _expirationTime_: date when a warning needs to appear in the browser to announce that data may be deprecated. 52 | - _outputFolder_: folder where the resulting .json files will be stored. 53 | - _foldersBaselineLoad_: list of folders with baseline edition snapshots, usually the international edition. 54 | - _modulesToIgnoreBaselineLoad_: list of Modules SCTIDs in the baseline files to ignore during conversion. 55 | - _foldersExtensionLoad_: list of folders with extension edition files. 56 | - _modulesToIgnoreExtensionLoad_: list of Modules SCTIDs in the extension files to ignore during conversion. 57 | 58 | If the base edition and the extension are available in a single RF2 snapshot package, this folder can be used as a single baseline folder. All folders will be recursively expored and RF2 files will be indentified base on file names and headers (firs row of the file). 59 | 60 | You can find sample config files in the `config` folder. 61 | 62 | ## Executing conversion 63 | Run the executable jar file after building the repository, alternatively it can be found in the [releases]( https://github.com/IHTSDO/rf2-to-json-conversion/releases): 64 | 65 | ``` 66 | java -Xmx8g -jar rf2-to-json-conversion--SNAPSHOT-jar-with-dependencies.jar config.xml 67 | ``` 68 | 69 | The results will be a set of .json files in the output folder. 70 | 71 | ## Importing data 72 | The snapshot API requires a MongoDB database to store the denormalized representation contained in the .json files. MongoDb 2.6.x is required to leverage its latest adavances in full text search. 73 | 74 | This project includes a script file for importing the resulting .json files into MongoDB, and creating the necessary indexes. This sentence needs to be executed from the folder that contains the .json files. The script will use the `mongoimport` command provided by mongoDB, it is expected to be in the path, as well as `mongo` runtime. 75 | 76 | `./import.sh localhost en-edition 20140731` 77 | 78 | The first parameter is the hostname, the second is the edition short name, and the third is the effective time. The edition and effective time will be used to configure the Rest API that runs with this data. 79 | 80 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # All Vagrant configuration is done below. The "2" in Vagrant.configure 5 | # configures the configuration version (we support older styles for 6 | # backwards compatibility). Please don't change it unless you know what 7 | # you're doing. 8 | Vagrant.configure(2) do |config| 9 | # The most common configuration options are documented and commented below. 10 | # For a complete reference, please see the online documentation at 11 | # https://docs.vagrantup.com. 12 | 13 | # Every Vagrant development environment requires a box. You can search for 14 | # boxes at https://atlas.hashicorp.com/search. 15 | config.vm.provider :parallels do |_, override| 16 | override.vm.box = "parallels/ubuntu-14.04" 17 | end 18 | 19 | config.vm.provider :virtualbox do |_, override| 20 | override.vm.box = "ubuntu/trusty64" 21 | end 22 | 23 | # Disable automatic box update checking. If you disable this, then 24 | # boxes will only be checked for updates when the user runs 25 | # `vagrant box outdated`. This is not recommended. 26 | # config.vm.box_check_update = false 27 | 28 | # Create a forwarded port mapping which allows access to a specific port 29 | # within the machine from a port on the host machine. In the example below, 30 | # accessing "localhost:8080" will access port 80 on the guest machine. 31 | # config.vm.network "forwarded_port", guest: 80, host: 8080 32 | 33 | # Create a private network, which allows host-only access to the machine 34 | # using a specific IP. 35 | # config.vm.network "private_network", ip: "192.168.33.10" 36 | 37 | # Create a public network, which generally matched to bridged network. 38 | # Bridged networks make the machine appear as another physical device on 39 | # your network. 40 | # config.vm.network "public_network" 41 | 42 | # Share an additional folder to the guest VM. The first argument is 43 | # the path on the host to the actual folder. The second argument is 44 | # the path on the guest to mount the folder. And the optional third 45 | # argument is a set of non-required options. 46 | # config.vm.synced_folder "../data", "/vagrant_data" 47 | hostos = RbConfig::CONFIG["host_os"].downcase 48 | case hostos 49 | when 'linux-gnu' 50 | config.vm.synced_folder ".", "/vagrant", :nfs => true, 51 | :mount_options => ['rw', 'vers=3', 'tcp', 'nordirplus', 'nolock', 'local_lock=none'] 52 | else 53 | config.vm.synced_folder ".", "/vagrant", :nfs => true 54 | end 55 | 56 | # You need to have the bindfs plugin installed. 57 | # You can run this via: 58 | # 59 | # vagrant plugin install vagrant-bindfs 60 | # 61 | config.bindfs.bind_folder "/vagrant", "/nfs/host", 62 | :perms => "u=rwx:g=rwx:o=rwx", 63 | :create_as_user => true 64 | 65 | # Provider-specific configuration so you can fine-tune various 66 | # backing providers for Vagrant. These expose provider-specific options. 67 | # rf2 conversion requires a lot of resources and will fail if they 68 | # are not available. 69 | config.vm.provider :virtualbox do |vbox| 70 | # Use VBoxManage to customize the VM. For example to change memory: 71 | vbox.customize ["modifyvm", :id, "--memory", "2048"] 72 | end 73 | 74 | # if parallels provider available, set those values instead 75 | config.vm.provider :parallels do |par| 76 | par.memory = "4096" 77 | par.cpus = 2 78 | end 79 | 80 | config.vm.provision :shell, path: "scripts/provision.sh", args: ENV['SHELL_ARGS'] 81 | 82 | # View the documentation for the provider you are using for more 83 | # information on available options. 84 | 85 | # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies 86 | # such as FTP and Heroku are also available. See the documentation at 87 | # https://docs.vagrantup.com/v2/push/atlas.html for more information. 88 | # config.push.define "atlas" do |push| 89 | # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" 90 | # end 91 | 92 | # Enable provisioning with a shell script. Additional provisioners such as 93 | # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the 94 | # documentation for more information about their specific syntax and use. 95 | # config.vm.provision "shell", inline: <<-SHELL 96 | # sudo apt-get update 97 | # sudo apt-get install -y apache2 98 | # SHELL 99 | end 100 | -------------------------------------------------------------------------------- /conf/auConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | au 5 | 900000000000003001 6 | 32570271000036106 7 | true 8 | false 9 | AU Edition 10 | au-edition 11 | 20170930 12 | 20181030 13 | 20170930 14 | au-edition 15 | 16 | /Snapshot 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /conf/beConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | en 5 | 900000000000013009 6 | 21000172104 7 | true 8 | false 9 | Belgian Edition 10 | be-edition 11 | 20180315 12 | 20191201 13 | be 14 | 15 | /Snapshot 16 | /Snapshot 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /conf/dkconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | da 5 | 900000000000013009 6 | 554461000005103 7 | false 8 | false 9 | Danish Edition 10 | dk-edition 11 | 20180331 12 | 20191201 13 | dk 14 | 15 | /Snapshot 16 | /Snapshot 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /conf/esConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | es 5 | 900000000000003001 6 | 450828004 7 | true 8 | Spanish Edition 9 | false 10 | es-edition 11 | 20171031 12 | 20181201 13 | es 14 | 15 | /Snapshot 16 | /Snapshot 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /conf/intConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | en 5 | 900000000000003001 6 | 900000000000509007 7 | true 8 | false 9 | International Edition 10 | en-edition 11 | 20180131 12 | 20190901 13 | intl 14 | 15 | /Snapshot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /conf/nlConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | nl 5 | 900000000000013009 6 | 31000146106 7 | true 8 | NL Edition 9 | false 10 | nl-edition 11 | 20180331 12 | 20191002 13 | nl 14 | 15 | /Snapshot 16 | 17 | 18 | 19 | 20 | /Snapshot 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /conf/seConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | sv 5 | 900000000000013009 6 | 46011000052107 7 | false 8 | false 9 | Swedish Edition 10 | se-edition 11 | 20150531 12 | 20160601 13 | se-edition 14 | 15 | /Snapshot 16 | /Snapshot 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /conf/ukConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | en 5 | 900000000000003001 6 | 999001251000000103 7 | true 8 | false 9 | UK Edition 10 | uk-edition 11 | 20170401 12 | 20181101 13 | uk 14 | 15 | /Snapshot 16 | /Snapshot 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /conf/usConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | en 5 | 900000000000003001 6 | 900000000000509007 7 | true 8 | false 9 | US Edition 10 | us-edition 11 | 20180301 12 | 20191002 13 | us-edition 14 | 15 | /Snapshot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /conf/uyConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | es 5 | 900000000000003001 6 | 5641000179103 7 | true 8 | false 9 | UY edition 10 | uy-edition 11 | 20171215 12 | 20191002 13 | uy-edition 14 | 15 | /Snapshot 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /deb/control/control: -------------------------------------------------------------------------------- 1 | Package: [[artifactId]] 2 | Version: [[version]] 3 | Priority: optional 4 | Architecture: all 5 | Maintainer: DevOps Support 6 | Description: [[name]] 7 | Distribution: stable 8 | Section: server 9 | -------------------------------------------------------------------------------- /deb/control/postinst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IHTSDO/rf2-to-json-conversion/77ab2de09e14c675a1a9d4b17e6be818210d7c66/deb/control/postinst -------------------------------------------------------------------------------- /deb/control/postrm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IHTSDO/rf2-to-json-conversion/77ab2de09e14c675a1a9d4b17e6be818210d7c66/deb/control/postrm -------------------------------------------------------------------------------- /deb/control/preinst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IHTSDO/rf2-to-json-conversion/77ab2de09e14c675a1a9d4b17e6be818210d7c66/deb/control/preinst -------------------------------------------------------------------------------- /deb/control/prerm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IHTSDO/rf2-to-json-conversion/77ab2de09e14c675a1a9d4b17e6be818210d7c66/deb/control/prerm -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.ihtsdo 6 | rf2-to-json-conversion 7 | 1.2 8 | jar 9 | 10 | rf2-to-json-conversion 11 | http://maven.apache.org 12 | 13 | UTF-8 14 | 15 | 16 | 17 | 18 | junit 19 | junit 20 | 3.8.1 21 | test 22 | 23 | 24 | com.google.code.gson 25 | gson 26 | 2.2.4 27 | 28 | 29 | log4j 30 | log4j 31 | 1.2.16 32 | 33 | 34 | org.mapdb 35 | mapdb 36 | 1.0.5 37 | 38 | 39 | commons-configuration 40 | commons-configuration 41 | 1.6 42 | 43 | 44 | org.jdom 45 | jdom 46 | 2.0.0 47 | 48 | 49 | 50 | 51 | 52 | maven-assembly-plugin 53 | 54 | 55 | 56 | org.ihtsdo.json.runners.ConfigRunner 57 | 58 | 59 | 60 | jar-with-dependencies 61 | 62 | 63 | 64 | 65 | make-assembly 66 | package 67 | 68 | single 69 | 70 | 71 | 72 | 73 | 74 | org.vafer 75 | jdeb 76 | 1.1.1 77 | 78 | 79 | verify 80 | 81 | jdeb 82 | 83 | 84 | ${project.build.directory}/${project.artifactId}-${project.version}-all.deb 85 | ${basedir}/deb/control 86 | true 87 | BUILD_NUMBER 88 | true 89 | all 90 | false 91 | 92 | 93 | ${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar 94 | file 95 | 96 | perm 97 | /opt/${project.artifactId} 98 | 99 | 100 | 101 | ${basedir}/conf 102 | directory 103 | 104 | perm 105 | /opt/${project.artifactId}/conf 106 | 107 | 108 | 109 | ${basedir}/scripts 110 | directory 111 | 112 | perm 113 | /opt/${project.artifactId}/ 114 | 755 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | ihtsdo-public-nexus 128 | IHTSDO Public Nexus Releases 129 | https://maven.ihtsdotools.org/content/repositories/releases/ 130 | 131 | 132 | ihtsdo-public-nexus 133 | IHTSDO Public Nexus Snapshots 134 | https://maven.ihtsdotools.org/content/repositories/snapshots/ 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /scripts/import-tc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Import json data 3 | # import.sh database collection 4 | mongo --eval "db = db.getSiblingDB('server');db.resources.remove({'databaseName': '$1', 'collectionName': '$2'});" 5 | mongo --eval "db = db.getSiblingDB('$1');db.dropDatabase();" 6 | mongoimport --file concepts.json -d $1 -c v$2 7 | mongoimport --file text-index.json -d $1 -c v$2tx 8 | mongoimport --file manifest.json -d server -c resources 9 | mongoimport --file statedTransitiveClosure.json -d $1 -c v$2stc 10 | mongoimport --file inferredTransitiveClosure.json -d $1 -c v$2itc 11 | mongo --eval "db = db.getSiblingDB('$1');db.v$2.ensureIndex({'conceptId' : 1});db.v$2.ensureIndex({'relationships.target.conceptId' : 1,'relationships.type.conceptId' : 1});db.v$2.ensureIndex({'statedRelationships.target.conceptId' : 1,'statedRelationships.type.conceptId' : 1});db.v$2.ensureIndex({'memberships.refset.conceptId' :1});" 12 | mongo --eval "db = db.getSiblingDB('$1');db.v$2tx.ensureIndex({'descriptionId' : 1});db.v$2tx.ensureIndex({term: 'text'});db.v$2tx.ensureIndex({term: 1});db.v$2tx.ensureIndex({words: 1});" 13 | echo "Done!" -------------------------------------------------------------------------------- /scripts/import.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Import Snomed-CT json data 3 | # 4 | # Requires two arguments: 5 | # $ ./import.sh 6 | # e.g. ./import.sh localhost en-edition 20160131 7 | # 8 | 9 | if [[ $# -ne 3 ]]; then 10 | echo 'Import script requires three arguments' 11 | echo ' $ ./import.sh ' 12 | exit 1 13 | fi 14 | 15 | function exitIfError { 16 | local err=${1} 17 | 18 | if [ $? -ne 0 ]; then 19 | echo "An error occurred: $err" 20 | exit 1 21 | fi 22 | } 23 | 24 | mongo --host $1 --eval "db = db.getSiblingDB('server');db.resources.remove({'databaseName': '$2', 'collectionName': '$3'});" 25 | mongo --host $1 --eval "db = db.getSiblingDB('$2');db.dropDatabase();" 26 | mongoimport --host $1 --file concepts.json -d $2 -c v$3 27 | mongoimport --host $1 --file text-index.json -d $2 -c v$3tx 28 | mongoimport --host $1 --file manifest.json -d server -c resources 29 | 30 | if [ -s statedTransitiveClosure.json ]; then 31 | ERROR=$(mongoimport --file statedTransitiveClosure.json -d $2 -c v$3stc) 32 | exitIfError ${ERROR} 33 | fi 34 | 35 | if [ -s inferredTransitiveClosure.json ]; then 36 | ERROR=$(mongoimport --file inferredTransitiveClosure.json -d $2 -c v$3itc) 37 | exitIfError ${ERROR} 38 | fi 39 | 40 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({'conceptId' : 1});" 41 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({'relationships.target.conceptId' : 1,'relationships.type.conceptId' : 1});" 42 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({'statedRelationships.target.conceptId' : 1,'statedRelationships.type.conceptId' : 1});" 43 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({'additionalRelationships.target.conceptId' : 1,'additionalRelationships.type.conceptId' : 1});" 44 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({'memberships.refset.conceptId' :1});" 45 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({inferredAncestors:1});" 46 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({statedAncestors:1});" 47 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({'statedRelationships.typeInferredAncestors':1});" 48 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({'statedRelationships.typeStatedAncestors':1});" 49 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({'relationships.typeInferredAncestors':1});" 50 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({'relationships.typeStatedAncestors':1});" 51 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({'statedRelationships.targetInferredAncestors':1});" 52 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({'statedRelationships.targetStatedAncestors':1});" 53 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({'relationships.targetInferredAncestors':1});" 54 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3.ensureIndex({'relationships.targetStatedAncestors':1});" 55 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3tx.ensureIndex({'descriptionId' : 1});" 56 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3tx.ensureIndex({term: 'text'});" 57 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3tx.ensureIndex({term: 1});" 58 | mongo --host $1 --port 27017 --eval "db = db.getSiblingDB('$2');db.v$3tx.ensureIndex({words: 1});" 59 | 60 | echo "Import Completed" 61 | exit 0 62 | -------------------------------------------------------------------------------- /scripts/provision.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # the following parameters need to be collected and passed from a start script 4 | EDITION='US Edition' 5 | DATABASE='us-edition' 6 | EFF_TIME='20150901' 7 | EXP_TIME='20160301' 8 | LOGIN='' 9 | PASSW='' 10 | 11 | UMLS="http://${LOGIN}:${PASSW}@download.nlm.nih.gov/mlb/utsauth/USExt" # FIX-ME 12 | RELEASEFILE="SnomedCT_RF2Release_US1000124_${EFF_TIME}.zip" # FIX-ME 13 | HOSTDIR='/nfs/host' 14 | WORKDIR="${HOSTDIR}/work" 15 | OUTDIR="${WORKDIR}/output" 16 | INPDIR="${WORKDIR}/input" 17 | 18 | echo Provisioning Basic State Linux, Maven and Java Environment 19 | set -e # exit script on first error 20 | set -x # print commands and their arguments as executed 21 | 22 | sudo apt-get update 23 | sudo apt-get upgrade -y 24 | sudo apt-get install -y maven2 openjdk-7-jdk wget bindfs 25 | 26 | if [ ! -s ${INPDIR}/${RELEASEFILE} ]; then 27 | mkdir -p ${INPDIR} && wget ${UMLS}/${RELEASEFILE} -o ${INPDIR}/${RELEASEFILE} 28 | else 29 | cd ${INPDIR} && unzip -o ${RELEASEFILE} 30 | fi 31 | 32 | test -d ${OUTDIR} ] || mkdir -p ${OUTDIR} 33 | 34 | cd ${HOSTDIR} && mvn package 35 | 36 | cat > /tmp/config.xml < 38 | 39 | false 40 | en 41 | 900000000000003001 42 | 900000000000509007 43 | true 44 | false 45 | ${EDITION} 46 | ${DATABASE} 47 | ${EFF_TIME} 48 | ${EXP_TIME} 49 | ${OUTDIR}/${DATABASE} 50 | 51 | ${INPDIR}/SnomedCT_RF2Release_US1000124_${EFF_TIME}/Snapshot 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | EOF 61 | 62 | java -Xmx8g -jar ${HOSTDIR}/target/rf2-to-json-conversion-1.0-jar-with-dependencies.jar /tmp/config.xml 63 | 64 | if [ $? -eq 0 ]; then 65 | cd ${OUTDIR} && tar cvjf snomed-ct-json-${DATABASE}-${EFF_TIME}.tar.bz2 ${DATABASE}/ 66 | cd ${OUTDIR} && sha1sum snomed-ct-json-${DATABASE}-${EFF_TIME}.tar.bz2 | cut -f1 -d' ' > snomed-ct-json-${DATABASE}-${EFF_TIME}.tar.bz2.sha1sum 67 | fi 68 | -------------------------------------------------------------------------------- /scripts/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | java -Xmx8g -jar ./rf2-to-json-conversion-1.0-SNAPSHOT-jar-with-dependencies.jar ./conf/$CONFIG.xml -------------------------------------------------------------------------------- /scripts/unzip-import.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # a script which copies import scripts to the json dir, zips the json directory and then scp's it 4 | # to dest_url 5 | # The following variables should be set by editing this script before running it: 6 | # The json dir 7 | json_dir="./json" 8 | # The import script 9 | import_script="import.sh" 10 | # The tgz file name 11 | zip_fn="json.tgz" 12 | # The edition e.g. au-edition 13 | edition="" 14 | #The import date e.g. 20150531 15 | importDate="" 16 | 17 | # Prints a message to stdout with the current date and time. 18 | echo_date() { 19 | echo -e "[`date +\"%Y-%m-%d %H:%M:%S\"`] $@" 20 | } 21 | 22 | # Prints an error message to stderr and exits the script with a non-zero status. 23 | error_exit() { 24 | echo -e "[`date +\"%Y-%m-%d %H:%M:%S\"`] $@" >&2 25 | exit 1 26 | } 27 | 28 | # Main script starts here. 29 | main() { 30 | echo_date "----------------------------" 31 | check_arguments 32 | untargzip 33 | importmongo 34 | exit 0 35 | } 36 | 37 | check_arguments() { 38 | 39 | if [ "x$edition" = "x" ]; then 40 | error_exit "Please set the variable edition before running this script. Exiting with error." 41 | fi 42 | 43 | if [ "x$importDate" = "x" ]; then 44 | error_exit "Please set the variable importDate before running this script. Exiting with error." 45 | fi 46 | 47 | } 48 | 49 | untargzip() { 50 | echo "untar and unzipping json folder" 51 | tar -zxvf $zip_fn 52 | } 53 | 54 | importmongo() { 55 | echo "Importing into mongo with $scpvar" 56 | $json_dir/$import_script $edition $importDate 57 | } 58 | 59 | # Ensures that only a single instance is running at any time 60 | LOCKFILE="./instance.lock" 61 | 62 | ( 63 | flock -n 200 || error_exit "Another backup script is already running. Exiting with error." 64 | trap "rm $LOCKFILE" EXIT 65 | main 66 | ) 200> $LOCKFILE 67 | -------------------------------------------------------------------------------- /scripts/zipAndUpload.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # a script which copies import scripts to the json dir, zips the json directory and then scp's it 4 | # to dest_url 5 | # The following variables should be set by editing this script before running it: 6 | # The json dir 7 | json_dir="./json" 8 | # The install scripts 9 | import_scripts="import*.sh" 10 | unzip_script="unzip-import.sh" 11 | # The destination. if not just a machine name then stirng as per scp e.g. 12 | #user@machine:/target/dir where user@ & /target/dir are optional as the user running the script 13 | # will be used & that user's home dir is the default. 14 | # Make sure in advance that you can ssh to desturl as destuser. 15 | # destuser - if left blank then as current user 16 | destuser="" 17 | desturl="" 18 | destdir="~/" 19 | 20 | scpvar=$destuser@$desturl:$destdir 21 | 22 | zip_fn="json.tgz" 23 | 24 | # Prints a message to stdout with the current date and time. 25 | echo_date() { 26 | echo -e "[`date +\"%Y-%m-%d %H:%M:%S\"`] $@" 27 | } 28 | 29 | # Prints an error message to stderr and exits the script with a non-zero status. 30 | error_exit() { 31 | echo -e "[`date +\"%Y-%m-%d %H:%M:%S\"`] $@" >&2 32 | exit 1 33 | } 34 | 35 | # Main script starts here. 36 | main() { 37 | echo_date "----------------------------" 38 | check_arguments 39 | copyscripts 40 | targzip 41 | scptgz 42 | exit 0 43 | } 44 | 45 | check_arguments() { 46 | 47 | if [ "x$json_dir" = "x" ]; then 48 | error_exit "Please set the variable json_dir before running this script. Exiting with error." 49 | fi 50 | 51 | if [ "x$desturl" = "x" ]; then 52 | error_exit "Please set the variable desturl before running this script. Exiting with error." 53 | fi 54 | 55 | } 56 | 57 | copyscripts(){ 58 | echo "copying scripts to = "$json_dir; 59 | cp -vf $import_scripts $json_dir 60 | } 61 | 62 | targzip() { 63 | echo "Tar and zipping json folder" 64 | tar zcvf $zip_fn $json_dir 65 | } 66 | 67 | scptgz() { 68 | echo "Transferring to new machine using $scpvar" 69 | scp $zip_fn $scpvar 70 | scp $unzip_script $scpvar 71 | } 72 | 73 | # Ensures that only a single instance is running at any time 74 | LOCKFILE="./instance.lock" 75 | 76 | ( 77 | flock -n 200 || error_exit "Another backup script is already running. Exiting with error." 78 | trap "rm $LOCKFILE" EXIT 79 | main 80 | ) 200> $LOCKFILE 81 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/TextUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | /** 12 | * 13 | * @author alo 14 | */ 15 | public class TextUtil { 16 | 17 | public static Map rules = new HashMap(); 18 | 19 | public static void main(String[] args) { 20 | System.out.println("\u00E1"); 21 | 22 | String a = "\\u" + "00E1"; 23 | 24 | System.out.println("áéí".replaceAll(a, "a")); 25 | 26 | } 27 | 28 | 29 | 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/Transformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json; 7 | 8 | import java.io.BufferedReader; 9 | import java.io.BufferedWriter; 10 | import java.io.File; 11 | import java.io.FileInputStream; 12 | import java.io.FileNotFoundException; 13 | import java.io.FileOutputStream; 14 | import java.io.IOException; 15 | import java.io.InputStreamReader; 16 | import java.io.OutputStreamWriter; 17 | import java.io.UnsupportedEncodingException; 18 | import java.util.ArrayList; 19 | import java.util.Arrays; 20 | import java.util.HashMap; 21 | import java.util.HashSet; 22 | import java.util.List; 23 | import java.util.Map; 24 | import java.util.UUID; 25 | 26 | import org.ihtsdo.json.model.Concept; 27 | import org.ihtsdo.json.model.ConceptAncestor; 28 | import org.ihtsdo.json.model.ConceptDescriptor; 29 | import org.ihtsdo.json.model.Description; 30 | import org.ihtsdo.json.model.LangMembership; 31 | import org.ihtsdo.json.model.LightDescription; 32 | import org.ihtsdo.json.model.LightLangMembership; 33 | import org.ihtsdo.json.model.LightRefsetMembership; 34 | import org.ihtsdo.json.model.LightRelationship; 35 | import org.ihtsdo.json.model.RefsetMembership; 36 | import org.ihtsdo.json.model.Relationship; 37 | import org.ihtsdo.json.model.TextIndexDescription; 38 | import org.ihtsdo.json.utils.FileHelper; 39 | 40 | import com.google.gson.Gson; 41 | 42 | /** 43 | * 44 | * @author Alejandro Rodriguez 45 | */ 46 | public class Transformer { 47 | 48 | private String MODIFIER = "Existential restriction"; 49 | private String sep = System.getProperty("line.separator"); 50 | 51 | private Map concepts; 52 | private Map> descriptions; 53 | private Map> relationships; 54 | private Map> simpleMembers; 55 | private Map> simpleMapMembers; 56 | private Map> languageMembers; 57 | private Map langCodes; 58 | 59 | private String defaultLangCode = "en"; 60 | public String fsnType = "900000000000003001"; 61 | public String synType = "900000000000013009"; 62 | private String inferred = "900000000000011006"; 63 | private String stated = "900000000000010007"; 64 | private String isaSCTId = "116680003"; 65 | private String defaultTermType = fsnType; 66 | private HashMap> tdefMembers; 67 | private HashMap> attrMembers; 68 | private HashMap> assocMembers; 69 | private ArrayList listA; 70 | private Map charConv; 71 | private Map cptFSN; 72 | private HashSet notLeafInferred; 73 | private HashSet notLeafStated; 74 | 75 | public Transformer() { 76 | concepts = new HashMap(); 77 | descriptions = new HashMap>(); 78 | relationships = new HashMap>(); 79 | simpleMembers = new HashMap>(); 80 | assocMembers = new HashMap>(); 81 | attrMembers = new HashMap>(); 82 | tdefMembers = new HashMap>(); 83 | simpleMapMembers = new HashMap>(); 84 | languageMembers = new HashMap>(); 85 | notLeafInferred=new HashSet(); 86 | notLeafStated=new HashSet(); 87 | cptFSN = new HashMap(); 88 | 89 | langCodes = new HashMap(); 90 | langCodes.put("en", "english"); 91 | langCodes.put("es", "spanish"); 92 | langCodes.put("da", "danish"); 93 | langCodes.put("sv", "swedish"); 94 | langCodes.put("fr", "french"); 95 | langCodes.put("nl", "dutch"); 96 | } 97 | 98 | public static void main(String[] args) throws Exception { 99 | Transformer tr = new Transformer(); 100 | 101 | 102 | tr.setDefaultLangCode("en"); 103 | tr.setDefaultTermType(tr.fsnType); 104 | 105 | HashSet folders=new HashSet(); 106 | folders.add("/Volumes/Macintosh HD2/uk_sct2cl_17/SnomedCT_Release_INT_20140131/RF2Release/Snapshot"); 107 | folders.add("/Volumes/Macintosh HD2/uk_sct2cl_17/SnomedCT2_GB1000000_20140401/RF2Release/Snapshot"); 108 | folders.add("/Users/termmed/Downloads/SnomedCT_Release_US1000124_20140301/RF2Release/Snapshot"); 109 | //folders.add("/Users/termmed/Downloads/SnomedCT_Release_AU1000036_20140531/RF2 Release/Snapshot"); 110 | String valConfig= "config/validation-rules.xml"; 111 | tr.getFilesFromFolders(folders,valConfig); 112 | 113 | tr.createConceptsJsonFile("/Volumes/Macintosh HD2/Multi-english-data/concepts.json"); 114 | tr.createTextIndexFile("/Volumes/Macintosh HD2/Multi-english-data/text-index.json"); 115 | tr.freeStep1(); 116 | tr.createTClosures(folders, valConfig, "/Volumes/Macintosh HD2/Multi-english-data/tclosure-inferred.json", "/Volumes/Macintosh HD2/tclosure-stated.json"); 117 | } 118 | 119 | public void freeStep1() { 120 | descriptions = null; 121 | simpleMembers = null; 122 | assocMembers = null; 123 | attrMembers = null; 124 | tdefMembers = null; 125 | simpleMapMembers = null; 126 | languageMembers = null; 127 | notLeafInferred= null; 128 | notLeafStated= null; 129 | cptFSN = null; 130 | langCodes = null; 131 | System.gc(); 132 | } 133 | 134 | private void getFilesFromFolders(HashSet folders, String validationConfig) throws IOException, Exception { 135 | File config=new File(validationConfig); 136 | FileHelper fHelper=new FileHelper(); 137 | for (String folder:folders){ 138 | File dir=new File(folder); 139 | HashSet files=new HashSet(); 140 | fHelper.findAllFiles(dir, files); 141 | 142 | for (String file:files){ 143 | String pattern=FileHelper.getFileTypeByHeader(new File(file)); 144 | 145 | if (pattern.equals("rf2-relationships")){ 146 | loadRelationshipsFile(new File(file)); 147 | }else if(pattern.equals("rf2-textDefinition")){ 148 | loadTextDefinitionFile(new File(file)); 149 | }else if(pattern.equals("rf2-association")){ 150 | loadAssociationFile(new File(file)); 151 | }else if(pattern.equals("rf2-association-2")){ 152 | loadAssociationFile(new File(file)); 153 | }else if(pattern.equals("rf2-attributevalue")){ 154 | loadAttributeFile(new File(file)); 155 | }else if(pattern.equals("rf2-language")){ 156 | loadLanguageRefsetFile(new File(file)); 157 | }else if(pattern.equals("rf2-simple")){ 158 | loadSimpleRefsetFile(new File(file)); 159 | }else if(pattern.equals("rf2-orderRefset")){ 160 | // TODO: add process to order refset 161 | loadSimpleRefsetFile(new File(file)); 162 | }else if(pattern.equals("rf2-simplemaps")){ 163 | loadSimpleMapRefsetFile(new File(file)); 164 | }else if(pattern.equals("rf2-descriptions")){ 165 | loadDescriptionsFile(new File(file)); 166 | }else if(pattern.equals("rf2-concepts")){ 167 | loadConceptsFile(new File(file)); 168 | }else{} 169 | } 170 | } 171 | completeDefaultTerm(); 172 | 173 | } 174 | 175 | public void createTClosures(HashSet folders, String valConfig, String transitiveClosureInferredFile,String transitiveClosureStatedFile) throws Exception { 176 | if (relationships==null || relationships.size()==0){ 177 | getFilesForTransClosureProcess(folders,valConfig); 178 | } 179 | createTClosure(transitiveClosureInferredFile,inferred); 180 | createTClosure(transitiveClosureStatedFile,stated); 181 | 182 | } 183 | 184 | private void getFilesForTransClosureProcess(HashSet folders, String validationConfig) throws IOException, Exception { 185 | 186 | concepts = new HashMap(); 187 | relationships = new HashMap>(); 188 | File config=new File(validationConfig); 189 | FileHelper fHelper=new FileHelper(); 190 | for (String folder:folders){ 191 | File dir=new File(folder); 192 | HashSet files=new HashSet(); 193 | fHelper.findAllFiles(dir, files); 194 | 195 | for (String file:files){ 196 | String pattern=FileHelper.getFileTypeByHeader(new File(file)); 197 | 198 | if (pattern.equals("rf2-relationships")){ 199 | loadRelationshipsFile(new File(file)); 200 | }else if(pattern.equals("rf2-concepts")){ 201 | loadConceptsFile(new File(file)); 202 | }else{} 203 | } 204 | } 205 | 206 | } 207 | 208 | public void loadConceptsFile(File conceptsFile) throws FileNotFoundException, IOException { 209 | System.out.println("Starting Concepts: " + conceptsFile.getName()); 210 | BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(conceptsFile), "UTF8")); 211 | try { 212 | String line = br.readLine(); 213 | line = br.readLine(); // Skip header 214 | int count = 0; 215 | while (line != null) { 216 | if (line.isEmpty()) { 217 | continue; 218 | } 219 | String[] columns = line.split("\\t"); 220 | ConceptDescriptor loopConcept = new ConceptDescriptor(); 221 | String conceptId = columns[0]; 222 | loopConcept.setConceptId(conceptId); 223 | loopConcept.setActive(columns[2].equals("1")); 224 | loopConcept.setEffectiveTime(columns[1]); 225 | loopConcept.setModule(columns[3]); 226 | loopConcept.setDefinitionStatus(columns[4].equals("900000000000074008") ? "Primitive" : "Fully defined"); 227 | concepts.put(conceptId, loopConcept); 228 | line = br.readLine(); 229 | count++; 230 | if (count % 100000 == 0) { 231 | System.out.print("."); 232 | } 233 | } 234 | System.out.println("."); 235 | System.out.println("Concepts loaded = " + concepts.size()); 236 | } finally { 237 | br.close(); 238 | } 239 | 240 | } 241 | 242 | public void loadDescriptionsFile(File descriptionsFile) throws FileNotFoundException, IOException { 243 | System.out.println("Starting Descriptions: " + descriptionsFile.getName()); 244 | BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(descriptionsFile), "UTF8")); 245 | int descriptionsCount = 0; 246 | try { 247 | String line = br.readLine(); 248 | line = br.readLine(); // Skip header 249 | boolean act; 250 | while (line != null) { 251 | if (line.isEmpty()) { 252 | continue; 253 | } 254 | String[] columns = line.split("\\t"); 255 | LightDescription loopDescription = new LightDescription(); 256 | loopDescription.setDescriptionId(columns[0]); 257 | act = columns[2].equals("1"); 258 | loopDescription.setActive(act); 259 | loopDescription.setEffectiveTime(columns[1]); 260 | String sourceId = columns[4]; 261 | loopDescription.setConceptId(sourceId); 262 | loopDescription.setType(columns[6]); 263 | loopDescription.setTerm(columns[7]); 264 | loopDescription.setIcs(columns[8]); 265 | loopDescription.setModule(columns[3]); 266 | loopDescription.setLang(columns[5]); 267 | List list = descriptions.get(sourceId); 268 | if (list == null) { 269 | list = new ArrayList(); 270 | } 271 | list.add(loopDescription); 272 | descriptions.put(sourceId, list); 273 | 274 | line = br.readLine(); 275 | descriptionsCount++; 276 | if (descriptionsCount % 100000 == 0) { 277 | System.out.print("."); 278 | } 279 | } 280 | System.out.println("."); 281 | System.out.println("Descriptions loaded = " + descriptions.size()); 282 | } finally { 283 | br.close(); 284 | } 285 | } 286 | 287 | public void completeDefaultTerm(){ 288 | boolean act; 289 | String type; 290 | String lang; 291 | ConceptDescriptor cdesc; 292 | for (String sourceId:concepts.keySet()){ 293 | List lDescriptions = descriptions.get(sourceId); 294 | if (lDescriptions!=null){ 295 | for (LightDescription desc:lDescriptions){ 296 | 297 | act=desc.isActive(); 298 | type=String.valueOf(desc.getType()); 299 | lang=desc.getLang(); 300 | if (act && type.equals("900000000000003001") && lang.equals("en")) { 301 | cdesc = concepts.get(sourceId); 302 | if (cdesc != null && (cdesc.getDefaultTerm() == null || cdesc.getDefaultTerm().isEmpty())) { 303 | cdesc.setDefaultTerm(desc.getTerm()); 304 | } 305 | 306 | if (getDefaultTermType()!=fsnType){ 307 | if (!cptFSN.containsKey(sourceId)){ 308 | cptFSN.put(sourceId,desc.getTerm()); 309 | } 310 | } 311 | } else if (act && type.equals(defaultTermType) && lang.equals(defaultLangCode)) { 312 | cdesc = concepts.get(sourceId); 313 | if (cdesc != null) { 314 | cdesc.setDefaultTerm(desc.getTerm()); 315 | } 316 | } 317 | if (getDefaultTermType()!=fsnType && act && type.equals("900000000000003001") && lang.equals(defaultLangCode)){ 318 | cptFSN.put(sourceId,desc.getTerm()); 319 | } 320 | } 321 | } 322 | } 323 | } 324 | public void loadTextDefinitionFile(File textDefinitionFile) throws FileNotFoundException, IOException { 325 | System.out.println("Starting Text Definitions: " + textDefinitionFile.getName()); 326 | BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(textDefinitionFile), "UTF8")); 327 | int descriptionsCount = 0; 328 | try { 329 | String line = br.readLine(); 330 | line = br.readLine(); // Skip header 331 | boolean act; 332 | while (line != null) { 333 | if (line.isEmpty()) { 334 | continue; 335 | } 336 | String[] columns = line.split("\\t"); 337 | LightDescription loopDescription = new LightDescription(); 338 | loopDescription.setDescriptionId(columns[0]); 339 | act = columns[2].equals("1"); 340 | loopDescription.setActive(act); 341 | loopDescription.setEffectiveTime(columns[1]); 342 | String sourceId = columns[4]; 343 | loopDescription.setConceptId(sourceId); 344 | loopDescription.setType(columns[6]); 345 | loopDescription.setTerm(columns[7]); 346 | loopDescription.setIcs(columns[8]); 347 | loopDescription.setModule(columns[3]); 348 | loopDescription.setLang(columns[5]); 349 | List list = tdefMembers.get(sourceId); 350 | if (list == null) { 351 | list = new ArrayList(); 352 | } 353 | list.add(loopDescription); 354 | tdefMembers.put(sourceId, list); 355 | 356 | line = br.readLine(); 357 | descriptionsCount++; 358 | if (descriptionsCount % 100000 == 0) { 359 | System.out.print("."); 360 | } 361 | } 362 | System.out.println("."); 363 | System.out.println("Text Definitions loaded = " + tdefMembers.size()); 364 | } finally { 365 | br.close(); 366 | } 367 | } 368 | public void loadRelationshipsFile(File relationshipsFile) throws FileNotFoundException, IOException { 369 | System.out.println("Starting Relationships: " + relationshipsFile.getName()); 370 | BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(relationshipsFile), "UTF8")); 371 | try { 372 | String line = br.readLine(); 373 | line = br.readLine(); // Skip header 374 | int count = 0; 375 | while (line != null) { 376 | if (line.isEmpty()) { 377 | continue; 378 | } 379 | String[] columns = line.split("\\t"); 380 | LightRelationship loopRelationship = new LightRelationship(); 381 | 382 | loopRelationship.setActive(columns[2].equals("1")); 383 | loopRelationship.setEffectiveTime(columns[1]); 384 | loopRelationship.setModule(columns[3]); 385 | String targetId=columns[5]; 386 | loopRelationship.setTarget(targetId); 387 | String type=columns[7]; 388 | loopRelationship.setType(type); 389 | loopRelationship.setModifier(columns[9]); 390 | loopRelationship.setGroupId(Integer.parseInt(columns[6])); 391 | String sourceId = columns[4]; 392 | loopRelationship.setSourceId(sourceId); 393 | String charType=columns[8]; 394 | loopRelationship.setCharType(charType); 395 | 396 | List relList = relationships.get(sourceId); 397 | if (relList == null) { 398 | relList = new ArrayList(); 399 | } 400 | relList.add(loopRelationship); 401 | relationships.put(sourceId, relList); 402 | 403 | if (columns[2].equals("1") 404 | && type==isaSCTId){ 405 | if ( charType==inferred){ 406 | notLeafInferred.add(targetId); 407 | }else{ 408 | notLeafStated.add(targetId); 409 | } 410 | } 411 | line = br.readLine(); 412 | count++; 413 | if (count % 100000 == 0) { 414 | System.out.print("."); 415 | } 416 | } 417 | System.out.println("."); 418 | System.out.println("Relationships loaded = " + relationships.size()); 419 | } finally { 420 | br.close(); 421 | } 422 | } 423 | 424 | public void loadSimpleRefsetFile(File simpleRefsetFile) throws FileNotFoundException, IOException { 425 | System.out.println("Starting Simple Refset Members: " + simpleRefsetFile.getName()); 426 | BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(simpleRefsetFile), "UTF8")); 427 | try { 428 | String line = br.readLine(); 429 | line = br.readLine(); // Skip header 430 | int count = 0; 431 | while (line != null) { 432 | if (line.isEmpty()) { 433 | continue; 434 | } 435 | String[] columns = line.split("\\t"); 436 | if (columns[2].equals("1")) { 437 | LightRefsetMembership loopMember = new LightRefsetMembership(); 438 | loopMember.setType(LightRefsetMembership.RefsetMembershipType.SIMPLE_REFSET.name()); 439 | loopMember.setUuid(UUID.fromString(columns[0])); 440 | 441 | loopMember.setActive(columns[2].equals("1")); 442 | loopMember.setEffectiveTime(columns[1]); 443 | loopMember.setModule(columns[3]); 444 | 445 | String sourceId = columns[5]; 446 | loopMember.setReferencedComponentId(sourceId); 447 | loopMember.setRefset(columns[4]); 448 | 449 | List list = simpleMembers.get(sourceId); 450 | if (list == null) { 451 | list = new ArrayList(); 452 | } 453 | list.add(loopMember); 454 | simpleMembers.put(columns[5], list); 455 | count++; 456 | if (count % 100000 == 0) { 457 | System.out.print("."); 458 | } 459 | } 460 | line = br.readLine(); 461 | } 462 | System.out.println("."); 463 | System.out.println("SimpleRefsetMember loaded = " + simpleMembers.size()); 464 | } finally { 465 | br.close(); 466 | } 467 | } 468 | 469 | public void loadAssociationFile(File associationsFile) throws FileNotFoundException, IOException { 470 | System.out.println("Starting Association Refset Members: " + associationsFile.getName()); 471 | BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(associationsFile), "UTF8")); 472 | try { 473 | String line = br.readLine(); 474 | line = br.readLine(); // Skip header 475 | int count = 0; 476 | while (line != null) { 477 | if (line.isEmpty()) { 478 | continue; 479 | } 480 | String[] columns = line.split("\\t"); 481 | if (columns[2].equals("1")) { 482 | LightRefsetMembership loopMember = new LightRefsetMembership(); 483 | loopMember.setType(LightRefsetMembership.RefsetMembershipType.ASSOCIATION.name()); 484 | loopMember.setUuid(UUID.fromString(columns[0])); 485 | 486 | loopMember.setActive(columns[2].equals("1")); 487 | loopMember.setEffectiveTime(columns[1]); 488 | loopMember.setModule(columns[3]); 489 | 490 | String sourceId = columns[5]; 491 | loopMember.setReferencedComponentId(sourceId); 492 | loopMember.setRefset(columns[4]); 493 | loopMember.setCidValue(columns[6]); 494 | 495 | List list = assocMembers.get(sourceId); 496 | if (list == null) { 497 | list = new ArrayList(); 498 | } 499 | list.add(loopMember); 500 | assocMembers.put(columns[5], list); 501 | count++; 502 | if (count % 100000 == 0) { 503 | System.out.print("."); 504 | } 505 | } 506 | line = br.readLine(); 507 | } 508 | System.out.println("."); 509 | System.out.println("AssociationMember loaded = " + assocMembers.size()); 510 | } finally { 511 | br.close(); 512 | } 513 | } 514 | 515 | public void loadAttributeFile(File attributeFile) throws FileNotFoundException, IOException { 516 | System.out.println("Starting Attribute Refset Members: " + attributeFile.getName()); 517 | BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(attributeFile), "UTF8")); 518 | try { 519 | String line = br.readLine(); 520 | line = br.readLine(); // Skip header 521 | int count = 0; 522 | while (line != null) { 523 | if (line.isEmpty()) { 524 | continue; 525 | } 526 | String[] columns = line.split("\\t"); 527 | if (columns[2].equals("1")) { 528 | LightRefsetMembership loopMember = new LightRefsetMembership(); 529 | loopMember.setType(LightRefsetMembership.RefsetMembershipType.ATTRIBUTE_VALUE.name()); 530 | loopMember.setUuid(UUID.fromString(columns[0])); 531 | 532 | loopMember.setActive(columns[2].equals("1")); 533 | loopMember.setEffectiveTime(columns[1]); 534 | loopMember.setModule(columns[3]); 535 | 536 | String sourceId = columns[5]; 537 | loopMember.setReferencedComponentId(sourceId); 538 | loopMember.setRefset(columns[4]); 539 | loopMember.setCidValue(columns[6]); 540 | 541 | List list = attrMembers.get(sourceId); 542 | if (list == null) { 543 | list = new ArrayList(); 544 | } 545 | list.add(loopMember); 546 | attrMembers.put(columns[5], list); 547 | count++; 548 | if (count % 100000 == 0) { 549 | System.out.print("."); 550 | } 551 | } 552 | line = br.readLine(); 553 | } 554 | System.out.println("."); 555 | System.out.println("AttributeMember loaded = " + attrMembers.size()); 556 | } finally { 557 | br.close(); 558 | } 559 | } 560 | public void loadSimpleMapRefsetFile(File simpleMapRefsetFile) throws FileNotFoundException, IOException { 561 | System.out.println("Starting SimpleMap Refset Members: " + simpleMapRefsetFile.getName()); 562 | BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(simpleMapRefsetFile), "UTF8")); 563 | try { 564 | String line = br.readLine(); 565 | line = br.readLine(); // Skip header 566 | int count = 0; 567 | while (line != null) { 568 | if (line.isEmpty()) { 569 | continue; 570 | } 571 | String[] columns = line.split("\\t"); 572 | if (columns[2].equals("1")) { 573 | LightRefsetMembership loopMember = new LightRefsetMembership(); 574 | loopMember.setType(LightRefsetMembership.RefsetMembershipType.SIMPLEMAP.name()); 575 | loopMember.setUuid(UUID.fromString(columns[0])); 576 | 577 | loopMember.setActive(columns[2].equals("1")); 578 | loopMember.setEffectiveTime(columns[1]); 579 | loopMember.setModule(columns[3]); 580 | 581 | String sourceId = columns[5]; 582 | loopMember.setReferencedComponentId(sourceId); 583 | loopMember.setRefset(columns[4]); 584 | loopMember.setOtherValue(columns[6]); 585 | 586 | List list = simpleMapMembers.get(sourceId); 587 | if (list == null) { 588 | list = new ArrayList(); 589 | } 590 | list.add(loopMember); 591 | simpleMapMembers.put(sourceId, list); 592 | count++; 593 | if (count % 100000 == 0) { 594 | System.out.print("."); 595 | } 596 | } 597 | line = br.readLine(); 598 | } 599 | System.out.println("."); 600 | System.out.println("SimpleMap RefsetMember loaded = " + simpleMapMembers.size()); 601 | } finally { 602 | br.close(); 603 | } 604 | } 605 | 606 | public void loadLanguageRefsetFile(File languageRefsetFile) throws FileNotFoundException, IOException { 607 | System.out.println("Starting Language Refset Members: " + languageRefsetFile.getName()); 608 | BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(languageRefsetFile), "UTF8")); 609 | try { 610 | String line = br.readLine(); 611 | line = br.readLine(); // Skip header 612 | int count = 0; 613 | while (line != null) { 614 | if (line.isEmpty()) { 615 | continue; 616 | } 617 | String[] columns = line.split("\\t"); 618 | if (columns[2].equals("1")) { 619 | LightLangMembership loopMember = new LightLangMembership(); 620 | loopMember.setUuid(UUID.fromString(columns[0])); 621 | 622 | loopMember.setActive(columns[2].equals("1")); 623 | loopMember.setEffectiveTime(columns[1]); 624 | loopMember.setModule(columns[3]); 625 | String sourceId = columns[5]; 626 | loopMember.setDescriptionId(sourceId); 627 | loopMember.setRefset(columns[4]); 628 | loopMember.setAcceptability(columns[6]); 629 | List list = languageMembers.get(sourceId); 630 | if (list == null) { 631 | list = new ArrayList(); 632 | } 633 | list.add(loopMember); 634 | languageMembers.put(sourceId, list); 635 | count++; 636 | if (count % 100000 == 0) { 637 | System.out.print("."); 638 | } 639 | } 640 | line = br.readLine(); 641 | } 642 | System.out.println("."); 643 | System.out.println("LanguageMembers loaded = " + languageMembers.size()); 644 | } finally { 645 | br.close(); 646 | } 647 | } 648 | 649 | public void createConceptsJsonFile(String fileName) throws FileNotFoundException, UnsupportedEncodingException, IOException { 650 | System.out.println("Starting creation of " + fileName); 651 | FileOutputStream fos = new FileOutputStream(fileName); 652 | OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); 653 | BufferedWriter bw = new BufferedWriter(osw); 654 | Gson gson = new Gson(); 655 | 656 | List listLD = new ArrayList(); 657 | List listD = new ArrayList(); 658 | 659 | List listLLM = new ArrayList(); 660 | List listLM = new ArrayList(); 661 | 662 | List listLR = new ArrayList(); 663 | List listR = new ArrayList(); 664 | 665 | List listLRM = new ArrayList(); 666 | List listRM = new ArrayList(); 667 | 668 | // int count = 0; 669 | for (String cptId : concepts.keySet()) { 670 | // count++; 671 | //if (count > 10) break; 672 | Concept cpt = new Concept(); 673 | ConceptDescriptor cptdesc = concepts.get(cptId); 674 | 675 | cpt.setConceptId(cptId); 676 | cpt.setActive(cptdesc.isActive()); 677 | cpt.setDefaultTerm(cptdesc.getDefaultTerm()); 678 | cpt.setEffectiveTime(cptdesc.getEffectiveTime()); 679 | cpt.setModule(cptdesc.getModule()); 680 | cpt.setDefinitionStatus(cptdesc.getDefinitionStatus()); 681 | cpt.setLeafInferred(notLeafInferred.contains(cptId)); 682 | cpt.setLeafStated(notLeafStated.contains(cptId)); 683 | listLD = descriptions.get(cptId); 684 | listD = new ArrayList(); 685 | 686 | if (listLD != null) { 687 | String descId; 688 | for (LightDescription ldesc : listLD) { 689 | Description d = new Description(); 690 | d.setActive(ldesc.isActive()); 691 | d.setConceptId(ldesc.getConceptId()); 692 | descId = ldesc.getDescriptionId(); 693 | d.setDescriptionId(descId); 694 | d.setEffectiveTime(ldesc.getEffectiveTime()); 695 | d.setIcs(concepts.get(ldesc.getIcs())); 696 | d.setTerm(ldesc.getTerm()); 697 | d.setLength(ldesc.getTerm().length()); 698 | d.setModule(ldesc.getModule()); 699 | d.setType(concepts.get(ldesc.getType())); 700 | d.setLang(ldesc.getLang()); 701 | 702 | listLLM = languageMembers.get(descId); 703 | listLM = new ArrayList(); 704 | 705 | if (listLLM != null) { 706 | for (LightLangMembership llm : listLLM) { 707 | LangMembership lm = new LangMembership(); 708 | 709 | lm.setActive(llm.isActive()); 710 | lm.setDescriptionId(descId); 711 | lm.setEffectiveTime(llm.getEffectiveTime()); 712 | lm.setModule(llm.getModule()); 713 | lm.setAcceptability(concepts.get(llm.getAcceptability())); 714 | lm.setRefset(concepts.get(llm.getRefset())); 715 | lm.setUuid(llm.getUuid()); 716 | 717 | listLM.add(lm); 718 | 719 | } 720 | if (listLM.isEmpty()) { 721 | d.setLangMemberships(null); 722 | } else { 723 | d.setLangMemberships(listLM); 724 | } 725 | } 726 | 727 | listLRM = attrMembers.get(descId); 728 | listRM = new ArrayList(); 729 | if (listLRM != null) { 730 | for (LightRefsetMembership lrm : listLRM) { 731 | RefsetMembership rm = new RefsetMembership(); 732 | rm.setEffectiveTime(lrm.getEffectiveTime()); 733 | rm.setActive(lrm.isActive()); 734 | rm.setModule(lrm.getModule()); 735 | rm.setUuid(lrm.getUuid()); 736 | 737 | rm.setReferencedComponentId(descId); 738 | rm.setRefset(concepts.get(lrm.getRefset())); 739 | rm.setType(lrm.getType()); 740 | rm.setCidValue(concepts.get(lrm.getCidValue())); 741 | 742 | listRM.add(rm); 743 | } 744 | if (listRM.isEmpty()){ 745 | d.setRefsetMemberships(null); 746 | }else{ 747 | d.setRefsetMemberships(listRM); 748 | } 749 | }else{ 750 | d.setRefsetMemberships(null); 751 | } 752 | 753 | listD.add(d); 754 | } 755 | } 756 | 757 | listLD = tdefMembers.get(cptId); 758 | if (listLD != null) { 759 | String descId; 760 | for (LightDescription ldesc : listLD) { 761 | Description d = new Description(); 762 | d.setActive(ldesc.isActive()); 763 | d.setConceptId(ldesc.getConceptId()); 764 | descId = ldesc.getDescriptionId(); 765 | d.setDescriptionId(descId); 766 | d.setEffectiveTime(ldesc.getEffectiveTime()); 767 | d.setIcs(concepts.get(ldesc.getIcs())); 768 | d.setTerm(ldesc.getTerm()); 769 | d.setLength(ldesc.getTerm().length()); 770 | d.setModule(ldesc.getModule()); 771 | d.setType(concepts.get(ldesc.getType())); 772 | d.setLang(ldesc.getLang()); 773 | 774 | listLLM = languageMembers.get(descId); 775 | listLM = new ArrayList(); 776 | 777 | if (listLLM != null) { 778 | for (LightLangMembership llm : listLLM) { 779 | LangMembership lm = new LangMembership(); 780 | 781 | lm.setActive(llm.isActive()); 782 | lm.setDescriptionId(descId); 783 | lm.setEffectiveTime(llm.getEffectiveTime()); 784 | lm.setModule(llm.getModule()); 785 | lm.setAcceptability(concepts.get(llm.getAcceptability())); 786 | lm.setRefset(concepts.get(llm.getRefset())); 787 | lm.setUuid(llm.getUuid()); 788 | 789 | listLM.add(lm); 790 | 791 | } 792 | if (listLM.isEmpty()) { 793 | d.setLangMemberships(null); 794 | } else { 795 | d.setLangMemberships(listLM); 796 | } 797 | } 798 | listD.add(d); 799 | } 800 | } 801 | if (listD!=null && !listD.isEmpty()){ 802 | cpt.setDescriptions(listD); 803 | } else { 804 | cpt.setDescriptions(null); 805 | } 806 | listLR = relationships.get(cptId); 807 | listR = new ArrayList(); 808 | if (listLR != null) { 809 | for (LightRelationship lrel : listLR) { 810 | if (lrel.getCharType().equals(900000000000010007L)) { 811 | Relationship d = new Relationship(); 812 | d.setEffectiveTime(lrel.getEffectiveTime()); 813 | d.setActive(lrel.isActive()); 814 | d.setModule(lrel.getModule()); 815 | d.setGroupId(lrel.getGroupId()); 816 | d.setModifier(MODIFIER); 817 | d.setSourceId(cptId); 818 | 819 | d.setTarget(concepts.get(lrel.getTarget())); 820 | d.setType(concepts.get(lrel.getType())); 821 | d.setCharType(concepts.get(lrel.getCharType())); 822 | d.setTargetMemberships(getMemberships(lrel.getTarget())); 823 | listR.add(d); 824 | } 825 | } 826 | 827 | if (listR.isEmpty()) { 828 | cpt.setStatedRelationships(null); 829 | } else { 830 | cpt.setStatedRelationships(listR); 831 | } 832 | } else { 833 | cpt.setStatedRelationships(null); 834 | } 835 | 836 | listLR = relationships.get(cptId); 837 | listR = new ArrayList(); 838 | if (listLR != null) { 839 | for (LightRelationship lrel : listLR) { 840 | if (lrel.getCharType().equals(900000000000011006L)) { 841 | Relationship d = new Relationship(); 842 | d.setEffectiveTime(lrel.getEffectiveTime()); 843 | d.setActive(lrel.isActive()); 844 | d.setModule(lrel.getModule()); 845 | d.setGroupId(lrel.getGroupId()); 846 | d.setModifier(MODIFIER); 847 | d.setSourceId(cptId); 848 | 849 | d.setTarget(concepts.get(lrel.getTarget())); 850 | d.setType(concepts.get(lrel.getType())); 851 | d.setCharType(concepts.get(lrel.getCharType())); 852 | d.setTargetMemberships(getMemberships(lrel.getTarget())); 853 | listR.add(d); 854 | } 855 | } 856 | 857 | if (listR.isEmpty()) { 858 | cpt.setRelationships(null); 859 | } else { 860 | cpt.setRelationships(listR); 861 | } 862 | } else { 863 | cpt.setRelationships(null); 864 | } 865 | 866 | listLRM = simpleMembers.get(cptId); 867 | listRM = new ArrayList(); 868 | if (listLRM != null) { 869 | for (LightRefsetMembership lrm : listLRM) { 870 | RefsetMembership d = new RefsetMembership(); 871 | d.setEffectiveTime(lrm.getEffectiveTime()); 872 | d.setActive(lrm.isActive()); 873 | d.setModule(lrm.getModule()); 874 | d.setUuid(lrm.getUuid()); 875 | 876 | d.setReferencedComponentId(cptId); 877 | d.setRefset(concepts.get(lrm.getRefset())); 878 | d.setType(lrm.getType()); 879 | 880 | listRM.add(d); 881 | } 882 | } 883 | 884 | listLRM = simpleMapMembers.get(cptId); 885 | if (listLRM != null) { 886 | for (LightRefsetMembership lrm : listLRM) { 887 | RefsetMembership d = new RefsetMembership(); 888 | d.setEffectiveTime(lrm.getEffectiveTime()); 889 | d.setActive(lrm.isActive()); 890 | d.setModule(lrm.getModule()); 891 | d.setUuid(lrm.getUuid()); 892 | 893 | d.setReferencedComponentId(cptId); 894 | d.setRefset(concepts.get(lrm.getRefset())); 895 | d.setType(lrm.getType()); 896 | d.setOtherValue(lrm.getOtherValue()); 897 | 898 | listRM.add(d); 899 | } 900 | } 901 | listLRM = assocMembers.get(cptId); 902 | if (listLRM != null) { 903 | for (LightRefsetMembership lrm : listLRM) { 904 | RefsetMembership d = new RefsetMembership(); 905 | d.setEffectiveTime(lrm.getEffectiveTime()); 906 | d.setActive(lrm.isActive()); 907 | d.setModule(lrm.getModule()); 908 | d.setUuid(lrm.getUuid()); 909 | 910 | d.setReferencedComponentId(cptId); 911 | d.setRefset(concepts.get(lrm.getRefset())); 912 | d.setType(lrm.getType()); 913 | d.setCidValue(concepts.get(lrm.getCidValue())); 914 | 915 | listRM.add(d); 916 | } 917 | } 918 | listLRM = attrMembers.get(cptId); 919 | if (listLRM != null) { 920 | for (LightRefsetMembership lrm : listLRM) { 921 | RefsetMembership d = new RefsetMembership(); 922 | d.setEffectiveTime(lrm.getEffectiveTime()); 923 | d.setActive(lrm.isActive()); 924 | d.setModule(lrm.getModule()); 925 | d.setUuid(lrm.getUuid()); 926 | 927 | d.setReferencedComponentId(cptId); 928 | d.setRefset(concepts.get(lrm.getRefset())); 929 | d.setType(lrm.getType()); 930 | d.setCidValue(concepts.get(lrm.getCidValue())); 931 | 932 | listRM.add(d); 933 | } 934 | } 935 | if (listRM.isEmpty()) { 936 | cpt.setMemberships(null); 937 | } else { 938 | cpt.setMemberships(listRM); 939 | } 940 | 941 | bw.append(gson.toJson(cpt).toString()); 942 | bw.append(sep); 943 | } 944 | bw.close(); 945 | System.out.println(fileName + " Done"); 946 | } 947 | 948 | private List getMemberships(String target) { 949 | Listret; 950 | List listLRM = simpleMembers.get(target); 951 | if (listLRM != null) { 952 | ret=new ArrayList(); 953 | for (LightRefsetMembership lrm : listLRM) { 954 | ret.add(lrm.getRefset()); 955 | } 956 | if (ret.size()>0){ 957 | return ret; 958 | } 959 | } 960 | return null; 961 | } 962 | 963 | public String getDefaultLangCode() { 964 | return defaultLangCode; 965 | } 966 | 967 | public void setDefaultLangCode(String defaultLangCode) { 968 | this.defaultLangCode = defaultLangCode; 969 | } 970 | 971 | private void createTClosure(String fileName,String charType) throws IOException { 972 | 973 | System.out.println("Transitive Closure creation from " + fileName); 974 | FileOutputStream fos = new FileOutputStream(fileName); 975 | OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); 976 | BufferedWriter bw = new BufferedWriter(osw); 977 | Gson gson = new Gson(); 978 | 979 | 980 | // int count = 0; 981 | for (String cptId : concepts.keySet()) { 982 | 983 | listA = new ArrayList(); 984 | getAncestors(cptId,charType); 985 | if (!listA.isEmpty()){ 986 | ConceptAncestor ca=new ConceptAncestor(); 987 | 988 | ca.setConceptId(cptId); 989 | ca.setAncestor(listA); 990 | bw.append(gson.toJson(ca).toString()); 991 | bw.append(sep); 992 | } 993 | } 994 | bw.close(); 995 | System.out.println(fileName + " Done"); 996 | } 997 | 998 | private void getAncestors(String cptId,String charType) { 999 | 1000 | List listLR = new ArrayList(); 1001 | 1002 | listLR = relationships.get(cptId); 1003 | if (listLR != null) { 1004 | for (LightRelationship lrel : listLR) { 1005 | if (lrel.getCharType().equals(charType) && 1006 | lrel.getType().equals(isaSCTId) && 1007 | lrel.isActive()) { 1008 | String tgt=lrel.getTarget(); 1009 | if (!listA.contains(tgt)){ 1010 | listA.add(tgt); 1011 | getAncestors(tgt,charType); 1012 | } 1013 | } 1014 | } 1015 | } 1016 | return ; 1017 | } 1018 | 1019 | public void createTextIndexFile(String fileName) throws FileNotFoundException, UnsupportedEncodingException, IOException { 1020 | getCharConvTable(); 1021 | System.out.println("Starting creation of " + fileName); 1022 | FileOutputStream fos = new FileOutputStream(fileName); 1023 | OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); 1024 | BufferedWriter bw = new BufferedWriter(osw); 1025 | Gson gson = new Gson(); 1026 | // int count = 0; 1027 | for (String conceptId : descriptions.keySet()) { 1028 | // count++; 1029 | //if (count > 10) break; 1030 | for (LightDescription ldesc : descriptions.get(conceptId)) { 1031 | TextIndexDescription d = new TextIndexDescription(); 1032 | d.setActive(ldesc.isActive()); 1033 | d.setTerm(ldesc.getTerm()); 1034 | d.setLength(ldesc.getTerm().length()); 1035 | d.setTypeId(ldesc.getType()); 1036 | d.setConceptId(ldesc.getConceptId()); 1037 | d.setDescriptionId(ldesc.getDescriptionId()); 1038 | d.setModule(ldesc.getModule()); 1039 | // using String lang names for Mongo 2.4.x text indexes 1040 | d.setLang(langCodes.get(ldesc.getLang())); 1041 | ConceptDescriptor concept = concepts.get(ldesc.getConceptId()); 1042 | d.setConceptModule(concept.getModule()); 1043 | d.setConceptActive(concept.isActive()); 1044 | if (getDefaultTermType()!=fsnType){ 1045 | String fsn= cptFSN.get(ldesc.getConceptId()); 1046 | if (fsn!=null){ 1047 | d.setFsn(fsn); 1048 | } 1049 | }else{ 1050 | d.setFsn(concept.getDefaultTerm()); 1051 | } 1052 | if (d.getFsn() == null) { 1053 | System.out.println("FSN Issue..." + d.getConceptId()); 1054 | d.setFsn(d.getTerm()); 1055 | } 1056 | d.setSemanticTag(""); 1057 | if (d.getFsn().endsWith(")")) { 1058 | d.setSemanticTag(d.getFsn().substring(d.getFsn().lastIndexOf("(") + 1, d.getFsn().length() - 1)); 1059 | } 1060 | String cleanTerm = d.getTerm().replace("(", "").replace(")", "").trim().toLowerCase(); 1061 | String convertedTerm=convertTerm(cleanTerm); 1062 | String[] tokens = convertedTerm.toLowerCase().split("\\s+"); 1063 | d.setWords(Arrays.asList(tokens)); 1064 | bw.append(gson.toJson(d).toString()); 1065 | bw.append(sep); 1066 | } 1067 | } 1068 | 1069 | bw.close(); 1070 | System.out.println(fileName + " Done"); 1071 | } 1072 | 1073 | private String convertTerm(String cleanTerm) { 1074 | for (String code:charConv.keySet()){ 1075 | String test="\\u" + code; 1076 | String repl=charConv.get(code); 1077 | cleanTerm=cleanTerm.replaceAll(test, repl); 1078 | } 1079 | return cleanTerm; 1080 | } 1081 | 1082 | private void getCharConvTable() throws IOException { 1083 | 1084 | String charconvtable="src/main/resources/org/ihtsdo/util/char_conversion_table.txt"; 1085 | BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(charconvtable), "UTF8")); 1086 | br.readLine(); 1087 | String line=null; 1088 | charConv=new HashMap(); 1089 | while ((line=br.readLine())!=null){ 1090 | String[] spl=line.split("\t",-1); 1091 | String[]codes=spl[2].split(" "); 1092 | for (String code:codes){ 1093 | 1094 | charConv.put(code,spl[0]); 1095 | } 1096 | 1097 | } 1098 | br.close(); 1099 | System.gc(); 1100 | } 1101 | 1102 | public String getDefaultTermType() { 1103 | return defaultTermType; 1104 | } 1105 | 1106 | public void setDefaultTermType(String defaultTermType) { 1107 | this.defaultTermType = defaultTermType; 1108 | } 1109 | 1110 | 1111 | 1112 | } 1113 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/TransformerConfig.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashSet; 5 | 6 | /** 7 | * Created by alo on 7/31/14. 8 | */ 9 | public class TransformerConfig { 10 | 11 | private String defaultTermLangCode; 12 | private String defaultTermDescriptionType; 13 | private String defaultTermLanguageRefset; 14 | private boolean normalizeTextIndex; 15 | private String editionName; 16 | private String databaseName; 17 | private String effectiveTime; 18 | private String expirationTime; 19 | private String outputFolder; 20 | private boolean createCompleteConceptsFile; 21 | private boolean processInMemory; 22 | 23 | private HashSet foldersBaselineLoad; 24 | private ArrayList modulesToIgnoreBaselineLoad; 25 | 26 | private HashSet foldersExtensionLoad; 27 | private ArrayList modulesToIgnoreExtensionLoad; 28 | 29 | public TransformerConfig() { 30 | foldersBaselineLoad = new HashSet(); 31 | modulesToIgnoreBaselineLoad = new ArrayList(); 32 | foldersExtensionLoad = new HashSet(); 33 | modulesToIgnoreExtensionLoad = new ArrayList(); 34 | } 35 | 36 | public String getDefaultTermLangCode() { 37 | return defaultTermLangCode; 38 | } 39 | 40 | public void setDefaultTermLangCode(String defaultTermLangCode) { 41 | this.defaultTermLangCode = defaultTermLangCode; 42 | } 43 | 44 | public String getDefaultTermDescriptionType() { 45 | return defaultTermDescriptionType; 46 | } 47 | 48 | public void setDefaultTermDescriptionType(String defaultTermDescriptionType) { 49 | this.defaultTermDescriptionType = defaultTermDescriptionType; 50 | } 51 | 52 | public String getDefaultTermLanguageRefset() { 53 | return defaultTermLanguageRefset; 54 | } 55 | 56 | public void setDefaultTermLanguageRefset(String defaultTermLanguageRefset) { 57 | this.defaultTermLanguageRefset = defaultTermLanguageRefset; 58 | } 59 | 60 | public boolean isNormalizeTextIndex() { 61 | return normalizeTextIndex; 62 | } 63 | 64 | public void setNormalizeTextIndex(boolean normalizeTextIndex) { 65 | this.normalizeTextIndex = normalizeTextIndex; 66 | } 67 | 68 | public String getEditionName() { 69 | return editionName; 70 | } 71 | 72 | public void setEditionName(String editionName) { 73 | this.editionName = editionName; 74 | } 75 | 76 | public String getDatabaseName() { 77 | return databaseName; 78 | } 79 | 80 | public void setDatabaseName(String databaseName) { 81 | this.databaseName = databaseName; 82 | } 83 | 84 | public String getEffectiveTime() { 85 | return effectiveTime; 86 | } 87 | 88 | public void setEffectiveTime(String effectiveTime) { 89 | this.effectiveTime = effectiveTime; 90 | } 91 | 92 | public String getExpirationTime() { 93 | return expirationTime; 94 | } 95 | 96 | public void setExpirationTime(String expirationTime) { 97 | this.expirationTime = expirationTime; 98 | } 99 | 100 | public HashSet getFoldersBaselineLoad() { 101 | return foldersBaselineLoad; 102 | } 103 | 104 | public void setFoldersBaselineLoad(HashSet foldersBaselineLoad) { 105 | this.foldersBaselineLoad = foldersBaselineLoad; 106 | } 107 | 108 | public ArrayList getModulesToIgnoreBaselineLoad() { 109 | return modulesToIgnoreBaselineLoad; 110 | } 111 | 112 | public void setModulesToIgnoreBaselineLoad(ArrayList modulesToIgnoreBaselineLoad) { 113 | this.modulesToIgnoreBaselineLoad = modulesToIgnoreBaselineLoad; 114 | } 115 | 116 | public HashSet getFoldersExtensionLoad() { 117 | return foldersExtensionLoad; 118 | } 119 | 120 | public void setFoldersExtensionLoad(HashSet foldersExtensionLoad) { 121 | this.foldersExtensionLoad = foldersExtensionLoad; 122 | } 123 | 124 | public ArrayList getModulesToIgnoreExtensionLoad() { 125 | return modulesToIgnoreExtensionLoad; 126 | } 127 | 128 | public void setModulesToIgnoreExtensionLoad(ArrayList modulesToIgnoreExtensionLoad) { 129 | this.modulesToIgnoreExtensionLoad = modulesToIgnoreExtensionLoad; 130 | } 131 | 132 | public String getOutputFolder() { 133 | return outputFolder; 134 | } 135 | 136 | public void setOutputFolder(String outputFolder) { 137 | this.outputFolder = outputFolder; 138 | } 139 | 140 | public boolean isCreateCompleteConceptsFile() { 141 | return createCompleteConceptsFile; 142 | } 143 | 144 | public void setCreateCompleteConceptsFile(boolean createCompleteConceptsFile) { 145 | this.createCompleteConceptsFile = createCompleteConceptsFile; 146 | } 147 | 148 | public boolean isProcessInMemory() { 149 | return processInMemory; 150 | } 151 | 152 | public void setProcessInMemory(boolean processInMemory) { 153 | this.processInMemory = processInMemory; 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/Component.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model; 7 | 8 | import java.io.Serializable; 9 | import java.util.UUID; 10 | 11 | /** 12 | * 13 | * @author Alejandro Rodriguez 14 | */ 15 | public class Component implements Serializable { 16 | 17 | private UUID uuid; 18 | private Boolean active; 19 | private String effectiveTime; 20 | private String module; 21 | 22 | public Component() { 23 | } 24 | 25 | public String getEffectiveTime() { 26 | return effectiveTime; 27 | } 28 | 29 | public void setEffectiveTime(String effectiveTime) { 30 | this.effectiveTime = effectiveTime; 31 | } 32 | 33 | public Boolean isActive() { 34 | return active; 35 | } 36 | 37 | public void setActive(Boolean active) { 38 | this.active = active; 39 | } 40 | 41 | public UUID getUuid() { 42 | return uuid; 43 | } 44 | 45 | public void setUuid(UUID uuid) { 46 | this.uuid = uuid; 47 | } 48 | 49 | public String getModule() { 50 | return module; 51 | } 52 | 53 | public void setModule(String module) { 54 | this.module = module; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/Concept.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 12 | * @author Alejandro Rodriguez 13 | */ 14 | public class Concept extends ConceptDescriptor { 15 | 16 | List memberships; 17 | List descriptions; 18 | List relationships; 19 | List statedRelationships; 20 | List additionalRelationships; 21 | boolean isLeafInferred; 22 | boolean isLeafStated; 23 | String fsn; 24 | 25 | String semtag; 26 | List inferredAncestors; 27 | List statedAncestors; 28 | 29 | public Concept() { 30 | } 31 | 32 | public List getMemberships() { 33 | return memberships; 34 | } 35 | 36 | public void setMemberships(List memberships) { 37 | this.memberships = memberships; 38 | } 39 | 40 | public List getDescriptions() { 41 | return descriptions; 42 | } 43 | 44 | public void setDescriptions(List descriptions) { 45 | this.descriptions = descriptions; 46 | } 47 | 48 | public List getRelationships() { 49 | return relationships; 50 | } 51 | 52 | public void setRelationships(List relationships) { 53 | this.relationships = relationships; 54 | } 55 | 56 | public List getStatedRelationships() { 57 | return statedRelationships; 58 | } 59 | 60 | public void setStatedRelationships(List statedRelationships) { 61 | this.statedRelationships = statedRelationships; 62 | } 63 | 64 | public boolean isLeafInferred() { 65 | return isLeafInferred; 66 | } 67 | 68 | public void setLeafInferred(boolean isLeafInferred) { 69 | this.isLeafInferred = isLeafInferred; 70 | } 71 | 72 | public boolean isLeafStated() { 73 | return isLeafStated; 74 | } 75 | 76 | public void setLeafStated(boolean isLeafStated) { 77 | this.isLeafStated = isLeafStated; 78 | } 79 | 80 | public String getFsn() { 81 | return fsn; 82 | } 83 | 84 | public void setFsn(String fsn) { 85 | this.fsn = fsn; 86 | } 87 | 88 | public String getSemtag() { 89 | return semtag; 90 | } 91 | 92 | public void setSemtag(String semtag) { 93 | this.semtag = semtag; 94 | } 95 | 96 | public List getInferredAncestors() { 97 | return inferredAncestors; 98 | } 99 | 100 | public void setInferredAncestors(List inferredAncestors) { 101 | this.inferredAncestors = inferredAncestors; 102 | } 103 | 104 | public List getStatedAncestors() { 105 | return statedAncestors; 106 | } 107 | 108 | public void setStatedAncestors(List statedAncestors) { 109 | this.statedAncestors = statedAncestors; 110 | } 111 | 112 | public List getAdditionalRelationships() { 113 | return additionalRelationships; 114 | } 115 | 116 | public void setAdditionalRelationships( 117 | List additionalRelationships) { 118 | this.additionalRelationships = additionalRelationships; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/ConceptAncestor.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.model; 2 | 3 | import java.util.List; 4 | 5 | public class ConceptAncestor { 6 | 7 | private String conceptId; 8 | private List ancestor; 9 | 10 | public String getConceptId() { 11 | return conceptId; 12 | } 13 | public void setConceptId(String conceptId) { 14 | this.conceptId = conceptId; 15 | } 16 | public List getAncestor() { 17 | return ancestor; 18 | } 19 | public void setAncestor(List ancestor) { 20 | this.ancestor = ancestor; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/ConceptDescriptor.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.model; 2 | 3 | public class ConceptDescriptor extends Component{ 4 | 5 | String conceptId; 6 | String defaultTerm; 7 | String definitionStatus; 8 | int statedDescendants; 9 | int inferredDescendants; 10 | public String getConceptId() { 11 | return conceptId; 12 | } 13 | public void setConceptId(String conceptId) { 14 | this.conceptId = conceptId; 15 | } 16 | public String getDefaultTerm() { 17 | return defaultTerm; 18 | } 19 | public void setDefaultTerm(String defaultTerm) { 20 | this.defaultTerm = defaultTerm; 21 | } 22 | public String getDefinitionStatus() { 23 | return definitionStatus; 24 | } 25 | public void setDefinitionStatus(String definitionStatus) { 26 | this.definitionStatus = definitionStatus; 27 | } 28 | public int getStatedDescendants() { 29 | return statedDescendants; 30 | } 31 | public void setStatedDescendants(int statedDescendants) { 32 | this.statedDescendants = statedDescendants; 33 | } 34 | public int getInferredDescendants() { 35 | return inferredDescendants; 36 | } 37 | public void setInferredDescendants(int inferredDescendants) { 38 | this.inferredDescendants = inferredDescendants; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/Description.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 12 | * @author Alejandro Rodriguez 13 | */ 14 | public class Description extends Component { 15 | 16 | String descriptionId; 17 | String conceptId; 18 | ConceptDescriptor type; 19 | String lang; 20 | String term; 21 | Integer length; 22 | ConceptDescriptor ics; 23 | List langMemberships; 24 | List refsetMemberships; 25 | 26 | private List words; 27 | 28 | public Description() { 29 | } 30 | 31 | public String getDescriptionId() { 32 | return descriptionId; 33 | } 34 | 35 | public void setDescriptionId(String descriptionId) { 36 | this.descriptionId = descriptionId; 37 | } 38 | 39 | public String getConceptId() { 40 | return conceptId; 41 | } 42 | 43 | public void setConceptId(String conceptId) { 44 | this.conceptId = conceptId; 45 | } 46 | 47 | public ConceptDescriptor getType() { 48 | return type; 49 | } 50 | 51 | public void setType(ConceptDescriptor type) { 52 | this.type = type; 53 | } 54 | 55 | public String getTerm() { 56 | return term; 57 | } 58 | 59 | public void setTerm(String term) { 60 | this.term = term; 61 | } 62 | 63 | public Integer getLength() { 64 | return length; 65 | } 66 | 67 | public void setLength(Integer length) { 68 | this.length = length; 69 | } 70 | 71 | public ConceptDescriptor getIcs() { 72 | return ics; 73 | } 74 | 75 | public void setIcs(ConceptDescriptor ics) { 76 | this.ics = ics; 77 | } 78 | 79 | public List getLangMemberships() { 80 | return langMemberships; 81 | } 82 | 83 | public void setLangMemberships(List langMemberships) { 84 | this.langMemberships = langMemberships; 85 | } 86 | 87 | public String getLang() { 88 | return lang; 89 | } 90 | 91 | public void setLang(String lang) { 92 | this.lang = lang; 93 | } 94 | 95 | public List getRefsetMemberships() { 96 | return refsetMemberships; 97 | } 98 | 99 | public void setRefsetMemberships(List refsetMemberships) { 100 | this.refsetMemberships = refsetMemberships; 101 | } 102 | 103 | public List getWords() { 104 | return words; 105 | } 106 | 107 | public void setWords(List words) { 108 | this.words = words; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/LangMembership.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model; 7 | 8 | import java.util.UUID; 9 | 10 | /** 11 | * 12 | * @author Alejandro Rodriguez 13 | */ 14 | public class LangMembership extends Component { 15 | 16 | private String descriptionId; 17 | private ConceptDescriptor refset; 18 | private ConceptDescriptor acceptability; 19 | 20 | public ConceptDescriptor getRefset() { 21 | return refset; 22 | } 23 | 24 | public void setRefset(ConceptDescriptor refset) { 25 | this.refset = refset; 26 | } 27 | 28 | public ConceptDescriptor getAcceptability() { 29 | return acceptability; 30 | } 31 | 32 | public void setAcceptability(ConceptDescriptor acceptability) { 33 | this.acceptability = acceptability; 34 | } 35 | 36 | 37 | public LangMembership() { 38 | super(); 39 | } 40 | 41 | public String getDescriptionId() { 42 | return descriptionId; 43 | } 44 | 45 | public void setDescriptionId(String descriptionId) { 46 | this.descriptionId = descriptionId; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/LightDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model; 7 | 8 | /** 9 | * 10 | * @author Alejandro Rodriguez 11 | */ 12 | public class LightDescription extends Component { 13 | 14 | String descriptionId; 15 | String conceptId; 16 | String type; 17 | String term; 18 | String ics; 19 | String lang; 20 | 21 | public LightDescription() { 22 | } 23 | 24 | public String getDescriptionId() { 25 | return descriptionId; 26 | } 27 | 28 | public void setDescriptionId(String descriptionId) { 29 | this.descriptionId = descriptionId; 30 | } 31 | 32 | public String getConceptId() { 33 | return conceptId; 34 | } 35 | 36 | public void setConceptId(String conceptId) { 37 | this.conceptId = conceptId; 38 | } 39 | 40 | public String getType() { 41 | return type; 42 | } 43 | 44 | public void setType(String type) { 45 | this.type = type; 46 | } 47 | 48 | public String getTerm() { 49 | return term; 50 | } 51 | 52 | public void setTerm(String term) { 53 | this.term = term; 54 | } 55 | 56 | public String getIcs() { 57 | return ics; 58 | } 59 | 60 | public void setIcs(String ics) { 61 | this.ics = ics; 62 | } 63 | 64 | public String getLang() { 65 | return lang; 66 | } 67 | 68 | public void setLang(String lang) { 69 | this.lang = lang; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/LightLangMembership.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model; 7 | 8 | import java.util.UUID; 9 | 10 | /** 11 | * 12 | * @author Alejandro Rodriguez 13 | */ 14 | public class LightLangMembership extends Component { 15 | 16 | private String descriptionId; 17 | private String refset; 18 | private String acceptability; 19 | public String getDescriptionId() { 20 | return descriptionId; 21 | } 22 | public void setDescriptionId(String descriptionId) { 23 | this.descriptionId = descriptionId; 24 | } 25 | public String getRefset() { 26 | return refset; 27 | } 28 | public void setRefset(String refset) { 29 | this.refset = refset; 30 | } 31 | public String getAcceptability() { 32 | return acceptability; 33 | } 34 | public void setAcceptability(String acceptability) { 35 | this.acceptability = acceptability; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/LightRefsetMembership.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.model; 2 | 3 | /** 4 | * 5 | * @author Alejandro Rodriguez 6 | */ 7 | 8 | public class LightRefsetMembership extends Component { 9 | 10 | public enum RefsetMembershipType { 11 | SIMPLEMAP("SIMPLEMAP"), ATTRIBUTE_VALUE("ATTRIBUTE_VALUE"), ASSOCIATION("ASSOCIATION"), SIMPLE_REFSET("SIMPLE_REFSET"); 12 | private String type; 13 | 14 | RefsetMembershipType(String type) { 15 | this.type = type; 16 | } 17 | 18 | public String getType() { 19 | return this.type; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return this.type; 25 | } 26 | } 27 | private String type; 28 | private String referencedComponentId; 29 | private String refset; 30 | private String cidValue; 31 | private String otherValue; 32 | public String getType() { 33 | return type; 34 | } 35 | public void setType(String type) { 36 | this.type = type; 37 | } 38 | public String getReferencedComponentId() { 39 | return referencedComponentId; 40 | } 41 | public void setReferencedComponentId(String referencedComponentId) { 42 | this.referencedComponentId = referencedComponentId; 43 | } 44 | public String getRefset() { 45 | return refset; 46 | } 47 | public void setRefset(String refset) { 48 | this.refset = refset; 49 | } 50 | public String getCidValue() { 51 | return cidValue; 52 | } 53 | public void setCidValue(String cidValue) { 54 | this.cidValue = cidValue; 55 | } 56 | public String getOtherValue() { 57 | return otherValue; 58 | } 59 | public void setOtherValue(String otherValue) { 60 | this.otherValue = otherValue; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/LightRelationship.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.model; 2 | 3 | /** 4 | * 5 | * @author Alejandro Rodriguez 6 | */ 7 | 8 | public class LightRelationship extends Component { 9 | 10 | private String type; 11 | private String target; 12 | private String sourceId; 13 | private Integer groupId; 14 | private String charType; 15 | private String modifier; 16 | public String getType() { 17 | return type; 18 | } 19 | public void setType(String type) { 20 | this.type = type; 21 | } 22 | public String getTarget() { 23 | return target; 24 | } 25 | public void setTarget(String target) { 26 | this.target = target; 27 | } 28 | public String getSourceId() { 29 | return sourceId; 30 | } 31 | public void setSourceId(String sourceId) { 32 | this.sourceId = sourceId; 33 | } 34 | public Integer getGroupId() { 35 | return groupId; 36 | } 37 | public void setGroupId(Integer groupId) { 38 | this.groupId = groupId; 39 | } 40 | public String getCharType() { 41 | return charType; 42 | } 43 | public void setCharType(String charType) { 44 | this.charType = charType; 45 | } 46 | public String getModifier() { 47 | return modifier; 48 | } 49 | public void setModifier(String modifier) { 50 | this.modifier = modifier; 51 | } 52 | 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/RefsetDescriptor.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.model; 2 | 3 | 4 | /** 5 | * Created by alo on 9/3/14. 6 | */ 7 | public class RefsetDescriptor extends ConceptDescriptor { 8 | 9 | Integer count; 10 | String type; 11 | 12 | public RefsetDescriptor(ConceptDescriptor concept, Integer count) { 13 | this.setDefinitionStatus(concept.getDefinitionStatus()); 14 | this.setEffectiveTime(concept.getEffectiveTime()); 15 | this.setCount(count); 16 | this.setConceptId(concept.getConceptId()); 17 | this.setDefaultTerm(concept.getDefaultTerm()); 18 | this.setModule(concept.getModule()); 19 | this.setUuid(concept.getUuid()); 20 | this.setActive(concept.isActive()); 21 | } 22 | 23 | public Integer getCount() { 24 | return count; 25 | } 26 | 27 | public void setCount(Integer count) { 28 | this.count = count; 29 | } 30 | 31 | public String getType() { 32 | return type; 33 | } 34 | 35 | public void setType(String type) { 36 | this.type = type; 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/RefsetMembership.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.model; 2 | 3 | /** 4 | * 5 | * @author Alejandro Rodriguez 6 | */ 7 | 8 | public class RefsetMembership extends Component { 9 | 10 | public enum RefsetMembershipType { 11 | SIMPLEMAP("SIMPLEMAP"), ATTRIBUTE_VALUE("ATTRIBUTE_VALUE"), ASSOCIATION("ASSOCIATION"), SIMPLE_REFSET("SIMPLE_REFSET"); 12 | private String type; 13 | 14 | RefsetMembershipType(String type) { 15 | this.type = type; 16 | } 17 | 18 | public String getType() { 19 | return this.type; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return this.type; 25 | } 26 | } 27 | private String type; 28 | private String referencedComponentId; 29 | private ConceptDescriptor refset; 30 | private ConceptDescriptor cidValue; 31 | private String otherValue; 32 | 33 | public ConceptDescriptor getRefset() { 34 | return refset; 35 | } 36 | 37 | public void setRefset(ConceptDescriptor refset) { 38 | this.refset = refset; 39 | } 40 | 41 | public ConceptDescriptor getCidValue() { 42 | return cidValue; 43 | } 44 | 45 | public void setCidValue(ConceptDescriptor cidValue) { 46 | this.cidValue = cidValue; 47 | } 48 | 49 | 50 | public RefsetMembership() { 51 | } 52 | 53 | public String getType() { 54 | return type; 55 | } 56 | 57 | public void setType(String type) { 58 | this.type = type; 59 | } 60 | 61 | public String getOtherValue() { 62 | return otherValue; 63 | } 64 | 65 | public void setOtherValue(String otherValue) { 66 | this.otherValue = otherValue; 67 | } 68 | 69 | public String getReferencedComponentId() { 70 | return referencedComponentId; 71 | } 72 | 73 | public void setReferencedComponentId(String referencedComponentId) { 74 | this.referencedComponentId = referencedComponentId; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/Relationship.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.model; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 7 | * @author Alejandro Rodriguez 8 | */ 9 | 10 | public class Relationship extends Component { 11 | 12 | private ConceptDescriptor type; 13 | private List typeInferredAncestors; 14 | private List typeStatedAncestors; 15 | private ConceptDescriptor target; 16 | private List targetInferredAncestors; 17 | private List targetStatedAncestors; 18 | private String sourceId; 19 | private Integer groupId; 20 | private ConceptDescriptor charType; 21 | private String modifier; 22 | private List targetMemberships; 23 | 24 | public Relationship() { 25 | super(); 26 | } 27 | 28 | public ConceptDescriptor getType() { 29 | return type; 30 | } 31 | 32 | public void setType(ConceptDescriptor type) { 33 | this.type = type; 34 | } 35 | 36 | public ConceptDescriptor getTarget() { 37 | return target; 38 | } 39 | 40 | public void setTarget(ConceptDescriptor target) { 41 | this.target = target; 42 | } 43 | 44 | public String getSourceId() { 45 | return sourceId; 46 | } 47 | 48 | public void setSourceId(String sourceId) { 49 | this.sourceId = sourceId; 50 | } 51 | 52 | public Integer getGroupId() { 53 | return groupId; 54 | } 55 | 56 | public void setGroupId(Integer groupId) { 57 | this.groupId = groupId; 58 | } 59 | 60 | public ConceptDescriptor getCharType() { 61 | return charType; 62 | } 63 | 64 | public void setCharType(ConceptDescriptor charType) { 65 | this.charType = charType; 66 | } 67 | 68 | public String getModifier() { 69 | return modifier; 70 | } 71 | 72 | public void setModifier(String modifier) { 73 | this.modifier = modifier; 74 | } 75 | 76 | public List getTypeInferredAncestors() { 77 | return typeInferredAncestors; 78 | } 79 | 80 | public void setTypeInferredAncestors(List typeInferredAncestors) { 81 | this.typeInferredAncestors = typeInferredAncestors; 82 | } 83 | 84 | public List getTypeStatedAncestors() { 85 | return typeStatedAncestors; 86 | } 87 | 88 | public void setTypeStatedAncestors(List typeStatedAncestors) { 89 | this.typeStatedAncestors = typeStatedAncestors; 90 | } 91 | 92 | public List getTargetInferredAncestors() { 93 | return targetInferredAncestors; 94 | } 95 | 96 | public void setTargetInferredAncestors(List targetInferredAncestors) { 97 | this.targetInferredAncestors = targetInferredAncestors; 98 | } 99 | 100 | public List getTargetStatedAncestors() { 101 | return targetStatedAncestors; 102 | } 103 | 104 | public void setTargetStatedAncestors(List targetStatedAncestors) { 105 | this.targetStatedAncestors = targetStatedAncestors; 106 | } 107 | 108 | public List getTargetMemberships() { 109 | return targetMemberships; 110 | } 111 | 112 | public void setTargetMemberships(List targetMemberships) { 113 | this.targetMemberships = targetMemberships; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/ResourceSetManifest.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.model; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | /** 10 | * Created by alo on 8/4/14. 11 | */ 12 | public class ResourceSetManifest implements Serializable { 13 | 14 | private String resourceSetName; 15 | private String effectiveTime; 16 | private String databaseName; 17 | private String collectionName; 18 | private String expirationDate; 19 | private List modules; 20 | private List languageRefsets; 21 | private List refsets; 22 | private Map languageRefsetsAbbrev; 23 | private String defaultTermLangCode; 24 | private String defaultTermType; 25 | private String defaultTermLangRefset; 26 | private boolean textIndexNormalized; 27 | 28 | public ResourceSetManifest() { 29 | modules = new ArrayList(); 30 | languageRefsets = new ArrayList(); 31 | refsets = new ArrayList(); 32 | languageRefsetsAbbrev = new HashMap(); 33 | } 34 | 35 | public String getResourceSetName() { 36 | return resourceSetName; 37 | } 38 | 39 | public void setResourceSetName(String resourceSetName) { 40 | this.resourceSetName = resourceSetName; 41 | } 42 | 43 | public String getEffectiveTime() { 44 | return effectiveTime; 45 | } 46 | 47 | public void setEffectiveTime(String effectiveTime) { 48 | this.effectiveTime = effectiveTime; 49 | } 50 | 51 | public String getDatabaseName() { 52 | return databaseName; 53 | } 54 | 55 | public void setDatabaseName(String databaseName) { 56 | this.databaseName = databaseName; 57 | } 58 | 59 | public String getCollectionName() { 60 | return collectionName; 61 | } 62 | 63 | public void setCollectionName(String collectionName) { 64 | this.collectionName = collectionName; 65 | } 66 | 67 | public String getExpirationDate() { 68 | return expirationDate; 69 | } 70 | 71 | public void setExpirationDate(String expirationDate) { 72 | this.expirationDate = expirationDate; 73 | } 74 | 75 | public List getModules() { 76 | return modules; 77 | } 78 | 79 | public void setModules(List modules) { 80 | this.modules = modules; 81 | } 82 | 83 | public List getLanguageRefsets() { 84 | return languageRefsets; 85 | } 86 | 87 | public void setLanguageRefsets(List languageRefsets) { 88 | this.languageRefsets = languageRefsets; 89 | } 90 | 91 | public List getRefsets() { 92 | return refsets; 93 | } 94 | 95 | public void setRefsets(List refsets) { 96 | this.refsets = refsets; 97 | } 98 | 99 | public Map getLanguageRefsetsAbbrev() { 100 | return languageRefsetsAbbrev; 101 | } 102 | 103 | public void setLanguageRefsetsAbbrev(Map languageRefsetsAbbrev) { 104 | this.languageRefsetsAbbrev = languageRefsetsAbbrev; 105 | } 106 | 107 | public String getDefaultTermLangCode() { 108 | return defaultTermLangCode; 109 | } 110 | 111 | public void setDefaultTermLangCode(String defaultTermLangCode) { 112 | this.defaultTermLangCode = defaultTermLangCode; 113 | } 114 | 115 | public String getDefaultTermType() { 116 | return defaultTermType; 117 | } 118 | 119 | public void setDefaultTermType(String defaultTermType) { 120 | this.defaultTermType = defaultTermType; 121 | } 122 | 123 | public String getDefaultTermLangRefset() { 124 | return defaultTermLangRefset; 125 | } 126 | 127 | public void setDefaultTermLangRefset(String defaultTermLangRefset) { 128 | this.defaultTermLangRefset = defaultTermLangRefset; 129 | } 130 | 131 | public boolean isTextIndexNormalized() { 132 | return textIndexNormalized; 133 | } 134 | 135 | public void setTextIndexNormalized(boolean textIndexNormalized) { 136 | this.textIndexNormalized = textIndexNormalized; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/TextIndexDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 12 | * @author alo 13 | */ 14 | public class TextIndexDescription extends Description { 15 | 16 | private String fsn; 17 | private String semanticTag; 18 | private boolean conceptActive; 19 | private String typeId; 20 | private List refsetIds; 21 | String definitionStatus; 22 | 23 | public TextIndexDescription() { 24 | } 25 | 26 | private String conceptModule; 27 | 28 | public String getConceptModule() { 29 | return conceptModule; 30 | } 31 | 32 | public void setConceptModule(String conceptModule) { 33 | this.conceptModule = conceptModule; 34 | } 35 | public String getFsn() { 36 | return fsn; 37 | } 38 | 39 | public void setFsn(String fsn) { 40 | this.fsn = fsn; 41 | } 42 | 43 | public String getSemanticTag() { 44 | return semanticTag; 45 | } 46 | 47 | public void setSemanticTag(String semanticTag) { 48 | this.semanticTag = semanticTag; 49 | } 50 | 51 | public boolean isConceptActive() { 52 | return conceptActive; 53 | } 54 | 55 | public void setConceptActive(boolean conceptActive) { 56 | this.conceptActive = conceptActive; 57 | } 58 | 59 | public String getTypeId() { 60 | return typeId; 61 | } 62 | 63 | public void setTypeId(String typeId) { 64 | this.typeId = typeId; 65 | } 66 | 67 | public List getRefsetIds() { 68 | return refsetIds; 69 | } 70 | 71 | public void setRefsetIds(List refsetIds) { 72 | this.refsetIds = refsetIds; 73 | } 74 | 75 | public String getDefinitionStatus() { 76 | return definitionStatus; 77 | } 78 | 79 | public void setDefinitionStatus(String definitionStatus) { 80 | this.definitionStatus = definitionStatus; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/versioned/Component.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model.versioned; 7 | 8 | import java.util.UUID; 9 | 10 | /** 11 | * 12 | * @author Alejandro Rodriguez 13 | */ 14 | public class Component { 15 | 16 | private UUID uuid; 17 | private Boolean active; 18 | private String effectiveTime; 19 | private String scTime; 20 | private Long module; 21 | 22 | public Component() { 23 | } 24 | 25 | public String getEffectiveTime() { 26 | return effectiveTime; 27 | } 28 | 29 | public void setEffectiveTime(String effectiveTime) { 30 | this.effectiveTime = effectiveTime; 31 | } 32 | 33 | public Boolean getActive() { 34 | return active; 35 | } 36 | 37 | public void setActive(Boolean active) { 38 | this.active = active; 39 | } 40 | 41 | public Long getModule() { 42 | return module; 43 | } 44 | 45 | public void setModule(Long module) { 46 | this.module = module; 47 | } 48 | 49 | public UUID getUuid() { 50 | return uuid; 51 | } 52 | 53 | public void setUuid(UUID uuid) { 54 | this.uuid = uuid; 55 | } 56 | 57 | public String getScTime() { 58 | return scTime; 59 | } 60 | 61 | public void setScTime(String scTime) { 62 | this.scTime = scTime; 63 | } 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/versioned/Concept.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model.versioned; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 12 | * @author Alejandro Rodriguez 13 | */ 14 | public class Concept extends ConceptDescriptor{ 15 | 16 | List memberships; 17 | List descriptions; 18 | List relationships; 19 | List statedRelationships; 20 | 21 | public Concept() { 22 | } 23 | 24 | public List getMemberships() { 25 | return memberships; 26 | } 27 | 28 | public void setMemberships(List memberships) { 29 | this.memberships = memberships; 30 | } 31 | 32 | public List getDescriptions() { 33 | return descriptions; 34 | } 35 | 36 | public void setDescriptions(List descriptions) { 37 | this.descriptions = descriptions; 38 | } 39 | 40 | public List getRelationships() { 41 | return relationships; 42 | } 43 | 44 | public void setRelationships(List relationships) { 45 | this.relationships = relationships; 46 | } 47 | 48 | public List getStatedRelationships() { 49 | return statedRelationships; 50 | } 51 | 52 | public void setStatedRelationships(List statedRelationships) { 53 | this.statedRelationships = statedRelationships; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/versioned/Concept4F.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model.versioned; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 12 | * @author Alejandro Rodriguez 13 | */ 14 | public class Concept4F { 15 | Long conceptId; 16 | List versions; 17 | List memberships; 18 | List descriptions; 19 | List relationships; 20 | List statedRelationships; 21 | 22 | public Concept4F() { 23 | } 24 | 25 | public List getMemberships() { 26 | return memberships; 27 | } 28 | 29 | public void setMemberships(List memberships) { 30 | this.memberships = memberships; 31 | } 32 | 33 | public List getDescriptions() { 34 | return descriptions; 35 | } 36 | 37 | public void setDescriptions(List descriptions) { 38 | this.descriptions = descriptions; 39 | } 40 | 41 | public List getRelationships() { 42 | return relationships; 43 | } 44 | 45 | public void setRelationships(List relationships) { 46 | this.relationships = relationships; 47 | } 48 | 49 | public List getStatedRelationships() { 50 | return statedRelationships; 51 | } 52 | 53 | public void setStatedRelationships(List statedRelationships) { 54 | this.statedRelationships = statedRelationships; 55 | } 56 | 57 | public Long getConceptId() { 58 | return conceptId; 59 | } 60 | 61 | public void setConceptId(Long conceptId) { 62 | this.conceptId = conceptId; 63 | } 64 | 65 | public List getVersions() { 66 | return versions; 67 | } 68 | 69 | public void setVersions(List versions) { 70 | this.versions = versions; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/versioned/ConceptAncestor.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.model.versioned; 2 | 3 | import java.util.List; 4 | 5 | public class ConceptAncestor { 6 | 7 | private Long conceptId; 8 | private List ancestor; 9 | 10 | public Long getConceptId() { 11 | return conceptId; 12 | } 13 | public void setConceptId(Long conceptId) { 14 | this.conceptId = conceptId; 15 | } 16 | public List getAncestor() { 17 | return ancestor; 18 | } 19 | public void setAncestor(List ancestor) { 20 | this.ancestor = ancestor; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/versioned/ConceptDescriptor.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.model.versioned; 2 | 3 | public class ConceptDescriptor extends Component{ 4 | 5 | Long conceptId; 6 | String defaultTerm; 7 | String definitionStatus; 8 | public Long getConceptId() { 9 | return conceptId; 10 | } 11 | public void setConceptId(Long conceptId) { 12 | this.conceptId = conceptId; 13 | } 14 | public String getDefaultTerm() { 15 | return defaultTerm; 16 | } 17 | public void setDefaultTerm(String defaultTerm) { 18 | this.defaultTerm = defaultTerm; 19 | } 20 | public String getDefinitionStatus() { 21 | return definitionStatus; 22 | } 23 | public void setDefinitionStatus(String definitionStatus) { 24 | this.definitionStatus = definitionStatus; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/versioned/Description.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model.versioned; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 12 | * @author Alejandro Rodriguez 13 | */ 14 | public class Description extends Component { 15 | 16 | Long descriptionId; 17 | Long conceptId; 18 | ConceptDescriptor type; 19 | String lang; 20 | String term; 21 | Integer length; 22 | ConceptDescriptor ics; 23 | List langMemberships; 24 | List refsetMemberships; 25 | 26 | public Description() { 27 | } 28 | 29 | public Long getDescriptionId() { 30 | return descriptionId; 31 | } 32 | 33 | public void setDescriptionId(Long descriptionId) { 34 | this.descriptionId = descriptionId; 35 | } 36 | 37 | public Long getConceptId() { 38 | return conceptId; 39 | } 40 | 41 | public void setConceptId(Long conceptId) { 42 | this.conceptId = conceptId; 43 | } 44 | 45 | public ConceptDescriptor getType() { 46 | return type; 47 | } 48 | 49 | public void setType(ConceptDescriptor type) { 50 | this.type = type; 51 | } 52 | 53 | public String getTerm() { 54 | return term; 55 | } 56 | 57 | public void setTerm(String term) { 58 | this.term = term; 59 | } 60 | 61 | public Integer getLength() { 62 | return length; 63 | } 64 | 65 | public void setLength(Integer length) { 66 | this.length = length; 67 | } 68 | 69 | public ConceptDescriptor getIcs() { 70 | return ics; 71 | } 72 | 73 | public void setIcs(ConceptDescriptor ics) { 74 | this.ics = ics; 75 | } 76 | 77 | public List getLangMemberships() { 78 | return langMemberships; 79 | } 80 | 81 | public void setLangMemberships(List langMemberships) { 82 | this.langMemberships = langMemberships; 83 | } 84 | 85 | public String getLang() { 86 | return lang; 87 | } 88 | 89 | public void setLang(String lang) { 90 | this.lang = lang; 91 | } 92 | 93 | public List getRefsetMemberships() { 94 | return refsetMemberships; 95 | } 96 | 97 | public void setRefsetMemberships(List refsetMemberships) { 98 | this.refsetMemberships = refsetMemberships; 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/versioned/LangMembership.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model.versioned; 7 | 8 | import java.util.UUID; 9 | 10 | /** 11 | * 12 | * @author Alejandro Rodriguez 13 | */ 14 | public class LangMembership extends Component { 15 | 16 | private Long descriptionId; 17 | private ConceptDescriptor refset; 18 | private ConceptDescriptor acceptability; 19 | 20 | public ConceptDescriptor getRefset() { 21 | return refset; 22 | } 23 | 24 | public void setRefset(ConceptDescriptor refset) { 25 | this.refset = refset; 26 | } 27 | 28 | public ConceptDescriptor getAcceptability() { 29 | return acceptability; 30 | } 31 | 32 | public void setAcceptability(ConceptDescriptor acceptability) { 33 | this.acceptability = acceptability; 34 | } 35 | 36 | 37 | public LangMembership() { 38 | super(); 39 | } 40 | 41 | public Long getDescriptionId() { 42 | return descriptionId; 43 | } 44 | 45 | public void setDescriptionId(Long descriptionId) { 46 | this.descriptionId = descriptionId; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/versioned/LightDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model.versioned; 7 | 8 | /** 9 | * 10 | * @author Alejandro Rodriguez 11 | */ 12 | public class LightDescription extends Component { 13 | 14 | Long descriptionId; 15 | Long conceptId; 16 | Long type; 17 | String term; 18 | Long ics; 19 | String lang; 20 | 21 | public LightDescription() { 22 | } 23 | 24 | public Long getDescriptionId() { 25 | return descriptionId; 26 | } 27 | 28 | public void setDescriptionId(Long descriptionId) { 29 | this.descriptionId = descriptionId; 30 | } 31 | 32 | public Long getConceptId() { 33 | return conceptId; 34 | } 35 | 36 | public void setConceptId(Long conceptId) { 37 | this.conceptId = conceptId; 38 | } 39 | 40 | public Long getType() { 41 | return type; 42 | } 43 | 44 | public void setType(Long type) { 45 | this.type = type; 46 | } 47 | 48 | public String getTerm() { 49 | return term; 50 | } 51 | 52 | public void setTerm(String term) { 53 | this.term = term; 54 | } 55 | 56 | public Long getIcs() { 57 | return ics; 58 | } 59 | 60 | public void setIcs(Long ics) { 61 | this.ics = ics; 62 | } 63 | 64 | public String getLang() { 65 | return lang; 66 | } 67 | 68 | public void setLang(String lang) { 69 | this.lang = lang; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/versioned/LightLangMembership.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model.versioned; 7 | 8 | import java.util.UUID; 9 | 10 | /** 11 | * 12 | * @author Alejandro Rodriguez 13 | */ 14 | public class LightLangMembership extends Component { 15 | 16 | private Long descriptionId; 17 | private Long refset; 18 | private Long acceptability; 19 | public Long getDescriptionId() { 20 | return descriptionId; 21 | } 22 | public void setDescriptionId(Long descriptionId) { 23 | this.descriptionId = descriptionId; 24 | } 25 | public Long getRefset() { 26 | return refset; 27 | } 28 | public void setRefset(Long refset) { 29 | this.refset = refset; 30 | } 31 | public Long getAcceptability() { 32 | return acceptability; 33 | } 34 | public void setAcceptability(Long acceptability) { 35 | this.acceptability = acceptability; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/versioned/LightRefsetMembership.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.model.versioned; 2 | 3 | /** 4 | * 5 | * @author Alejandro Rodriguez 6 | */ 7 | 8 | public class LightRefsetMembership extends Component { 9 | 10 | public enum RefsetMembershipType { 11 | SIMPLEMAP("SIMPLEMAP"), ATTRIBUTE_VALUE("ATTRIBUTE_VALUE"), ASSOCIATION("ASSOCIATION"), SIMPLE_REFSET("SIMPLE_REFSET"); 12 | private String type; 13 | 14 | RefsetMembershipType(String type) { 15 | this.type = type; 16 | } 17 | 18 | public String getType() { 19 | return this.type; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return this.type; 25 | } 26 | } 27 | private String type; 28 | private Long referencedComponentId; 29 | private Long refset; 30 | private Long cidValue; 31 | private String otherValue; 32 | public String getType() { 33 | return type; 34 | } 35 | public void setType(String type) { 36 | this.type = type; 37 | } 38 | public Long getReferencedComponentId() { 39 | return referencedComponentId; 40 | } 41 | public void setReferencedComponentId(Long referencedComponentId) { 42 | this.referencedComponentId = referencedComponentId; 43 | } 44 | public Long getRefset() { 45 | return refset; 46 | } 47 | public void setRefset(Long refset) { 48 | this.refset = refset; 49 | } 50 | public Long getCidValue() { 51 | return cidValue; 52 | } 53 | public void setCidValue(Long cidValue) { 54 | this.cidValue = cidValue; 55 | } 56 | public String getOtherValue() { 57 | return otherValue; 58 | } 59 | public void setOtherValue(String otherValue) { 60 | this.otherValue = otherValue; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/versioned/LightRelationship.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.model.versioned; 2 | 3 | /** 4 | * 5 | * @author Alejandro Rodriguez 6 | */ 7 | 8 | public class LightRelationship extends Component { 9 | 10 | private Long type; 11 | private Long target; 12 | private Long sourceId; 13 | private Integer groupId; 14 | private Long charType; 15 | private Long modifier; 16 | public Long getType() { 17 | return type; 18 | } 19 | public void setType(Long type) { 20 | this.type = type; 21 | } 22 | public Long getTarget() { 23 | return target; 24 | } 25 | public void setTarget(Long target) { 26 | this.target = target; 27 | } 28 | public Long getSourceId() { 29 | return sourceId; 30 | } 31 | public void setSourceId(Long sourceId) { 32 | this.sourceId = sourceId; 33 | } 34 | public Integer getGroupId() { 35 | return groupId; 36 | } 37 | public void setGroupId(Integer groupId) { 38 | this.groupId = groupId; 39 | } 40 | public Long getCharType() { 41 | return charType; 42 | } 43 | public void setCharType(Long charType) { 44 | this.charType = charType; 45 | } 46 | public Long getModifier() { 47 | return modifier; 48 | } 49 | public void setModifier(Long modifier) { 50 | this.modifier = modifier; 51 | } 52 | 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/versioned/RefsetMembership.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.model.versioned; 2 | 3 | /** 4 | * 5 | * @author Alejandro Rodriguez 6 | */ 7 | 8 | public class RefsetMembership extends Component { 9 | 10 | public enum RefsetMembershipType { 11 | SIMPLEMAP("SIMPLEMAP"), ATTRIBUTE_VALUE("ATTRIBUTE_VALUE"), ASSOCIATION("ASSOCIATION"), SIMPLE_REFSET("SIMPLE_REFSET"); 12 | private String type; 13 | 14 | RefsetMembershipType(String type) { 15 | this.type = type; 16 | } 17 | 18 | public String getType() { 19 | return this.type; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return this.type; 25 | } 26 | } 27 | private String type; 28 | private Long referencedComponentId; 29 | private ConceptDescriptor refset; 30 | private ConceptDescriptor cidValue; 31 | private String otherValue; 32 | 33 | public ConceptDescriptor getRefset() { 34 | return refset; 35 | } 36 | 37 | public void setRefset(ConceptDescriptor refset) { 38 | this.refset = refset; 39 | } 40 | 41 | public ConceptDescriptor getCidValue() { 42 | return cidValue; 43 | } 44 | 45 | public void setCidValue(ConceptDescriptor cidValue) { 46 | this.cidValue = cidValue; 47 | } 48 | 49 | 50 | public RefsetMembership() { 51 | } 52 | 53 | public String getType() { 54 | return type; 55 | } 56 | 57 | public void setType(String type) { 58 | this.type = type; 59 | } 60 | 61 | public String getOtherValue() { 62 | return otherValue; 63 | } 64 | 65 | public void setOtherValue(String otherValue) { 66 | this.otherValue = otherValue; 67 | } 68 | 69 | public Long getReferencedComponentId() { 70 | return referencedComponentId; 71 | } 72 | 73 | public void setReferencedComponentId(Long referencedComponentId) { 74 | this.referencedComponentId = referencedComponentId; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/versioned/Relationship.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.model.versioned; 2 | 3 | /** 4 | * 5 | * @author Alejandro Rodriguez 6 | */ 7 | 8 | public class Relationship extends Component { 9 | 10 | private ConceptDescriptor type; 11 | private ConceptDescriptor target; 12 | private Long sourceId; 13 | private Integer groupId; 14 | private ConceptDescriptor charType; 15 | private String modifier; 16 | 17 | public Relationship() { 18 | super(); 19 | } 20 | 21 | public ConceptDescriptor getType() { 22 | return type; 23 | } 24 | 25 | public void setType(ConceptDescriptor type) { 26 | this.type = type; 27 | } 28 | 29 | public ConceptDescriptor getTarget() { 30 | return target; 31 | } 32 | 33 | public void setTarget(ConceptDescriptor target) { 34 | this.target = target; 35 | } 36 | 37 | public Long getSourceId() { 38 | return sourceId; 39 | } 40 | 41 | public void setSourceId(Long sourceId) { 42 | this.sourceId = sourceId; 43 | } 44 | 45 | public Integer getGroupId() { 46 | return groupId; 47 | } 48 | 49 | public void setGroupId(Integer groupId) { 50 | this.groupId = groupId; 51 | } 52 | 53 | public ConceptDescriptor getCharType() { 54 | return charType; 55 | } 56 | 57 | public void setCharType(ConceptDescriptor charType) { 58 | this.charType = charType; 59 | } 60 | 61 | public String getModifier() { 62 | return modifier; 63 | } 64 | 65 | public void setModifier(String modifier) { 66 | this.modifier = modifier; 67 | } 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/model/versioned/TextIndexDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.ihtsdo.json.model.versioned; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 12 | * @author alo 13 | */ 14 | public class TextIndexDescription extends Description { 15 | 16 | private String fsn; 17 | private String semanticTag; 18 | private boolean conceptActive; 19 | private Long typeId; 20 | private List words; 21 | 22 | public TextIndexDescription() { 23 | } 24 | 25 | public String getFsn() { 26 | return fsn; 27 | } 28 | 29 | public void setFsn(String fsn) { 30 | this.fsn = fsn; 31 | } 32 | 33 | public String getSemanticTag() { 34 | return semanticTag; 35 | } 36 | 37 | public void setSemanticTag(String semanticTag) { 38 | this.semanticTag = semanticTag; 39 | } 40 | 41 | public boolean isConceptActive() { 42 | return conceptActive; 43 | } 44 | 45 | public void setConceptActive(boolean conceptActive) { 46 | this.conceptActive = conceptActive; 47 | } 48 | 49 | public List getWords() { 50 | return words; 51 | } 52 | 53 | public void setWords(List words) { 54 | this.words = words; 55 | } 56 | 57 | public Long getTypeId() { 58 | return typeId; 59 | } 60 | 61 | public void setTypeId(Long typeId) { 62 | this.typeId = typeId; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/runners/ConfigRunner.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.runners; 2 | 3 | import java.util.Collection; 4 | 5 | import org.apache.commons.configuration.XMLConfiguration; 6 | import org.ihtsdo.json.TransformerConfig; 7 | import org.ihtsdo.json.TransformerDiskBased; 8 | 9 | /** 10 | * Created by alo on 8/4/14. 11 | */ 12 | public class ConfigRunner { 13 | 14 | public static void main(String[] args) throws Exception { 15 | String config = null; 16 | if (args.length > 0) { 17 | config = args[0]; 18 | } 19 | if (config == null) { 20 | config = "config/enCaConfig.xml"; 21 | // System.err.println("Error: no config provided. Usage: rf2-to-json-conversion [path/to/config.xml]"); 22 | // System.exit(-1); 23 | } 24 | System.out.println("Running with config: " + config); 25 | XMLConfiguration xmlConfig = new XMLConfiguration(config); 26 | 27 | TransformerConfig runnableConfig = new TransformerConfig(); 28 | 29 | runnableConfig.setDefaultTermLangCode(xmlConfig.getString("defaultTermLangCode")); 30 | runnableConfig.setDefaultTermDescriptionType(xmlConfig.getString("defaultTermDescriptionType")); 31 | runnableConfig.setDefaultTermLanguageRefset(xmlConfig.getString("defaultTermLanguageRefset")); 32 | runnableConfig.setNormalizeTextIndex(xmlConfig.getString("normalizeTextIndex").equals("true")); 33 | runnableConfig.setCreateCompleteConceptsFile(xmlConfig.getString("createCompleteConceptsFile").equals("true")); 34 | runnableConfig.setProcessInMemory(xmlConfig.getString("processInMemory").equals("true")); 35 | runnableConfig.setEditionName(xmlConfig.getString("editionName")); 36 | runnableConfig.setDatabaseName(xmlConfig.getString("databaseName")); 37 | runnableConfig.setEffectiveTime(xmlConfig.getString("effectiveTime")); 38 | runnableConfig.setExpirationTime(xmlConfig.getString("expirationTime")); 39 | runnableConfig.setOutputFolder(xmlConfig.getString("outputFolder")); 40 | 41 | Object prop = xmlConfig.getProperty("foldersBaselineLoad.folder"); 42 | if (prop instanceof Collection) { 43 | for (String loopProp : (Collection)prop) { 44 | runnableConfig.getFoldersBaselineLoad().add(loopProp); 45 | System.out.println(loopProp); 46 | } 47 | } else if (prop instanceof String) { 48 | runnableConfig.getFoldersBaselineLoad().add((String)prop); 49 | System.out.println(prop); 50 | } 51 | 52 | prop = xmlConfig.getProperty("modulesToIgnoreBaselineLoad.folder"); 53 | if (prop instanceof Collection) { 54 | for (String loopProp : (Collection)prop) { 55 | runnableConfig.getModulesToIgnoreBaselineLoad().add(loopProp); 56 | System.out.println(loopProp); 57 | } 58 | } else if (prop instanceof String) { 59 | runnableConfig.getModulesToIgnoreBaselineLoad().add((String)prop); 60 | System.out.println(prop); 61 | } 62 | 63 | prop = xmlConfig.getProperty("foldersExtensionLoad.folder"); 64 | if (prop instanceof Collection) { 65 | for (String loopProp : (Collection)prop) { 66 | runnableConfig.getFoldersExtensionLoad().add(loopProp); 67 | System.out.println(loopProp); 68 | } 69 | } else if (prop instanceof String) { 70 | runnableConfig.getFoldersExtensionLoad().add((String) prop); 71 | System.out.println(prop); 72 | } 73 | 74 | prop = xmlConfig.getProperty("modulesToIgnoreExtensionLoad.folder"); 75 | if (prop instanceof Collection) { 76 | for (String loopProp : (Collection)prop) { 77 | runnableConfig.getModulesToIgnoreExtensionLoad().add(loopProp); 78 | System.out.println(loopProp); 79 | } 80 | } else if (prop instanceof String) { 81 | runnableConfig.getModulesToIgnoreExtensionLoad().add((String)prop); 82 | System.out.println(prop); 83 | } 84 | 85 | TransformerDiskBased tr = new TransformerDiskBased(); 86 | 87 | tr.convert(runnableConfig); 88 | 89 | System.out.println("Done..."); 90 | 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/runners/EsRunner.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.runners; 2 | 3 | import org.ihtsdo.json.TransformerConfig; 4 | import org.ihtsdo.json.TransformerDiskBased; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashSet; 8 | 9 | /** 10 | * Created by alo on 7/31/14. 11 | */ 12 | public class EsRunner { 13 | 14 | public static void main(String[] args) throws Exception { 15 | TransformerConfig config = new TransformerConfig(); 16 | config.setDatabaseName("es-edition"); 17 | config.setDefaultTermDescriptionType("900000000000003001"); 18 | config.setDefaultTermLangCode("es"); 19 | config.setDefaultTermLanguageRefset("900000000000509007"); 20 | config.setEditionName("Spanish Edition"); 21 | config.setEffectiveTime("20140430"); 22 | config.setExpirationTime("20141231"); 23 | config.setNormalizeTextIndex(true); 24 | HashSet baselineFolders = new HashSet(); 25 | baselineFolders.add("/Users/alo/Downloads/Releases/SnomedCT_Release_INT_20140131/RF2Release/Snapshot"); 26 | config.setFoldersBaselineLoad(baselineFolders); 27 | config.setModulesToIgnoreBaselineLoad(new ArrayList()); 28 | HashSet extensionFolders = new HashSet(); 29 | extensionFolders.add("/Users/alo/Downloads/Releases/SnomedCT_Release-es_INT_20140430/RF2Release/Snapshot"); 30 | config.setFoldersExtensionLoad(extensionFolders); 31 | ArrayList modulesToIgnore = new ArrayList(); 32 | config.setModulesToIgnoreExtensionLoad(modulesToIgnore); 33 | 34 | config.setOutputFolder("/Users/alo/Downloads/Releases/es-json"); 35 | 36 | TransformerDiskBased tr = new TransformerDiskBased(); 37 | 38 | tr.convert(config); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/runners/GMDNRunner.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.runners; 2 | 3 | import org.ihtsdo.json.TransformerConfig; 4 | import org.ihtsdo.json.TransformerDiskBased; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashSet; 8 | 9 | /** 10 | * Created by alo on 7/31/14. 11 | */ 12 | public class GMDNRunner { 13 | 14 | public static void main(String[] args) throws Exception { 15 | TransformerConfig config = new TransformerConfig(); 16 | config.setDatabaseName("gmdn-edition"); 17 | config.setDefaultTermDescriptionType("900000000000003001"); 18 | config.setDefaultTermLangCode("en"); 19 | config.setDefaultTermLanguageRefset("900000000000509007"); 20 | config.setEditionName("GMDN Edition"); 21 | config.setEffectiveTime("20140725"); 22 | config.setExpirationTime("20150201"); 23 | config.setNormalizeTextIndex(true); 24 | HashSet baselineFolders = new HashSet(); 25 | baselineFolders.add("/Users/alo/Downloads/Releases/SnomedCT_Release_INT_20140131/RF2Release/Snapshot"); 26 | config.setFoldersBaselineLoad(baselineFolders); 27 | config.setModulesToIgnoreBaselineLoad(new ArrayList()); 28 | HashSet extensionFolders = new HashSet(); 29 | extensionFolders.add("/Users/alo/NetBeansProjects/gmdn-analyzer/output/rf2"); 30 | extensionFolders.add("/Users/alo/NetBeansProjects/gmdn-analyzer/output/SnomedCT_MedicalDevicesTechnologyPreview_INT_20140131/RF2TechnologyPreview/Snapshot"); 31 | config.setFoldersExtensionLoad(extensionFolders); 32 | ArrayList modulesToIgnore = new ArrayList(); 33 | config.setModulesToIgnoreExtensionLoad(modulesToIgnore); 34 | 35 | config.setOutputFolder("/Users/alo/Downloads/Releases/gmdn-json"); 36 | 37 | TransformerDiskBased tr = new TransformerDiskBased(); 38 | 39 | tr.convert(config); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/runners/MultiEnglishEditionRunner.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.runners; 2 | 3 | import org.ihtsdo.json.TransformerConfig; 4 | import org.ihtsdo.json.TransformerDiskBased; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashSet; 8 | 9 | /** 10 | * Created by alo on 7/31/14. 11 | */ 12 | public class MultiEnglishEditionRunner { 13 | 14 | public static void main(String[] args) throws Exception { 15 | TransformerConfig config = new TransformerConfig(); 16 | config.setDatabaseName("multi-edition"); 17 | config.setDefaultTermDescriptionType("900000000000003001"); 18 | config.setDefaultTermLangCode("en"); 19 | config.setDefaultTermLanguageRefset("900000000000509007"); 20 | config.setEditionName("Multi English Edition (Int, AU, US, UK)"); 21 | config.setEffectiveTime("20140701"); 22 | config.setExpirationTime("20150201"); 23 | config.setNormalizeTextIndex(true); 24 | 25 | HashSet baselineFolders = new HashSet(); 26 | baselineFolders.add("/Volumes/Macintosh HD2/Downloads/uk_sct2cl_17/SnomedCT_Release_INT_20140131/RF2Release/Snapshot"); 27 | config.setFoldersBaselineLoad(baselineFolders); 28 | config.setModulesToIgnoreBaselineLoad(new ArrayList()); 29 | 30 | HashSet extensionFolders = new HashSet(); 31 | extensionFolders.add("/Volumes/Macintosh HD2/Downloads/uk_sct2cl_17/SnomedCT2_GB1000000_20140401/RF2Release/Snapshot"); 32 | extensionFolders.add("/Users/termmed/Downloads/SnomedCT_Release_US1000124_20140301/RF2Release/Snapshot"); 33 | extensionFolders.add("/Users/termmed/Downloads/SnomedCT_Release_AU1000036_20140531/RF2 Release/Snapshot"); 34 | config.setFoldersExtensionLoad(extensionFolders); 35 | ArrayList modulesToIgnore = new ArrayList(); 36 | modulesToIgnore.add("900000000000207008"); 37 | modulesToIgnore.add("900000000000012004"); 38 | config.setModulesToIgnoreExtensionLoad(modulesToIgnore); 39 | 40 | config.setOutputFolder("/Volumes/Macintosh HD2/Multi-english-data"); 41 | 42 | TransformerDiskBased tr = new TransformerDiskBased(); 43 | 44 | tr.convert(config); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/utils/ArrayComparator.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.utils; 2 | 3 | import java.util.Comparator; 4 | 5 | public class ArrayComparator implements Comparator { 6 | 7 | private int[] indexes; 8 | private boolean reverse; 9 | 10 | public ArrayComparator(int[] indexes, boolean reverse) { 11 | this.indexes = indexes; 12 | this.reverse = reverse; 13 | } 14 | 15 | public int compare(String[] o1, String[] o2) { 16 | for (int i = 0; i < indexes.length; i++) { 17 | if (o1[indexes[i]].compareTo(o2[indexes[i]]) < 0) { 18 | return reverse ? 1 : -1; 19 | } else if (o1[indexes[i]].compareTo(o2[indexes[i]]) > 0) { 20 | return reverse ? -1 : 1; 21 | } 22 | } 23 | return 0; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/utils/CommonUtils.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.utils; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.BufferedWriter; 5 | import java.io.File; 6 | import java.io.FileInputStream; 7 | import java.io.FileOutputStream; 8 | import java.io.IOException; 9 | import java.io.InputStreamReader; 10 | import java.io.OutputStreamWriter; 11 | import java.io.UnsupportedEncodingException; 12 | import java.security.MessageDigest; 13 | import java.security.NoSuchAlgorithmException; 14 | import java.util.ArrayList; 15 | import java.util.Collections; 16 | import java.util.HashMap; 17 | import java.util.HashSet; 18 | import java.util.List; 19 | import java.util.UUID; 20 | 21 | public class CommonUtils { 22 | private static final String encoding = "8859_1"; 23 | 24 | public static String[] getSmallestArray(HashMap passedMap, int[] sortColumns) { 25 | 26 | List mapValues = new ArrayList(passedMap.values()); 27 | // 28 | Collections.sort(mapValues, new ArrayComparator(sortColumns, false)); 29 | 30 | return mapValues.get(0); 31 | } 32 | private static byte[] getRawBytes(UUID uid) { 33 | String id = uid.toString(); 34 | if (id.length() != 36) { 35 | throw new NumberFormatException("UUID has to be represented by the standard 36-char representation"); 36 | } 37 | byte[] rawBytes = new byte[16]; 38 | 39 | for (int i = 0, j = 0; i < 36; ++j) { 40 | // Need to bypass hyphens: 41 | switch (i) { 42 | case 8: 43 | case 13: 44 | case 18: 45 | case 23: 46 | if (id.charAt(i) != '-') { 47 | throw new NumberFormatException("UUID has to be represented by the standard 36-char representation"); 48 | } 49 | ++i; 50 | } 51 | char c = id.charAt(i); 52 | 53 | if (c >= '0' && c <= '9') { 54 | rawBytes[j] = (byte) ((c - '0') << 4); 55 | } else if (c >= 'a' && c <= 'f') { 56 | rawBytes[j] = (byte) ((c - 'a' + 10) << 4); 57 | } else if (c >= 'A' && c <= 'F') { 58 | rawBytes[j] = (byte) ((c - 'A' + 10) << 4); 59 | } else { 60 | throw new NumberFormatException("Non-hex character '" + c + "'"); 61 | } 62 | 63 | c = id.charAt(++i); 64 | 65 | if (c >= '0' && c <= '9') { 66 | rawBytes[j] |= (byte) (c - '0'); 67 | } else if (c >= 'a' && c <= 'f') { 68 | rawBytes[j] |= (byte) (c - 'a' + 10); 69 | } else if (c >= 'A' && c <= 'F') { 70 | rawBytes[j] |= (byte) (c - 'A' + 10); 71 | } else { 72 | throw new NumberFormatException("Non-hex character '" + c + "'"); 73 | } 74 | ++i; 75 | } 76 | return rawBytes; 77 | } 78 | 79 | public static UUID get(UUID namespace, String name) throws NoSuchAlgorithmException, UnsupportedEncodingException { 80 | MessageDigest sha1Algorithm = MessageDigest.getInstance("SHA-1"); 81 | 82 | // Generate the digest. 83 | sha1Algorithm.reset(); 84 | if (namespace != null) { 85 | sha1Algorithm.update(getRawBytes(namespace)); 86 | } 87 | sha1Algorithm.update(name.getBytes(encoding)); 88 | byte[] sha1digest = sha1Algorithm.digest(); 89 | 90 | sha1digest[6] &= 0x0f; /* clear version */ 91 | sha1digest[6] |= 0x50; /* set to version 5 */ 92 | sha1digest[8] &= 0x3f; /* clear variant */ 93 | sha1digest[8] |= 0x80; /* set to IETF variant */ 94 | 95 | long msb = 0; 96 | long lsb = 0; 97 | for (int i = 0; i < 8; i++) 98 | msb = (msb << 8) | (sha1digest[i] & 0xff); 99 | for (int i = 8; i < 16; i++) 100 | lsb = (lsb << 8) | (sha1digest[i] & 0xff); 101 | 102 | return new UUID(msb, lsb); 103 | } 104 | 105 | public static void MergeFile(HashSet hFile, File outputfile) { 106 | 107 | try{ 108 | if (outputfile.exists()) 109 | outputfile.delete(); 110 | 111 | outputfile.createNewFile(); 112 | 113 | String fileName=outputfile.getName(); 114 | File fTmp = new File(outputfile.getParentFile() + "/tmp_" + fileName); 115 | 116 | 117 | boolean first = true; 118 | String nextLine; 119 | for (File file:hFile){ 120 | 121 | 122 | if (fTmp.exists()) 123 | fTmp.delete(); 124 | 125 | FileOutputStream fos = new FileOutputStream( fTmp); 126 | OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8"); 127 | BufferedWriter bw = new BufferedWriter(osw); 128 | 129 | FileInputStream fis = new FileInputStream(file ); 130 | InputStreamReader isr = new InputStreamReader(fis,"UTF-8"); 131 | BufferedReader br = new BufferedReader(isr); 132 | 133 | FileInputStream ofis = new FileInputStream(outputfile ); 134 | InputStreamReader oisr = new InputStreamReader(ofis,"UTF-8"); 135 | BufferedReader obr = new BufferedReader(oisr); 136 | 137 | 138 | nextLine=br.readLine(); 139 | if (first && nextLine!=null){ 140 | bw.append(nextLine); 141 | bw.append("\r\n"); 142 | first=false; 143 | } 144 | 145 | while ((nextLine=obr.readLine())!=null){ 146 | bw.append(nextLine); 147 | bw.append("\r\n"); 148 | 149 | } 150 | while ((nextLine=br.readLine())!=null){ 151 | bw.append(nextLine); 152 | bw.append("\r\n"); 153 | 154 | } 155 | bw.close(); 156 | br.close(); 157 | 158 | 159 | if (outputfile.exists()) 160 | outputfile.delete(); 161 | fTmp.renameTo(outputfile) ; 162 | } 163 | 164 | if (fTmp.exists()) 165 | fTmp.delete(); 166 | 167 | } catch (IOException e) { 168 | e.printStackTrace(); 169 | }finally{ 170 | 171 | } 172 | } 173 | public static UUID fromSNOMED(String id) { 174 | String name = "org.snomed." + id; 175 | try { 176 | return UUID.nameUUIDFromBytes(name.getBytes(encoding)); 177 | } catch (UnsupportedEncodingException e) { 178 | throw new RuntimeException(e); 179 | } 180 | } 181 | /** 182 | * Concatenate files. 183 | * 184 | * @param hFile the set with files to concatenate 185 | * @param outputfile the outputfile 186 | */ 187 | public static void concatFile(HashSet hFile, File outputfile) { 188 | 189 | try{ 190 | 191 | String fileName=outputfile.getName(); 192 | File fTmp = new File(outputfile.getParentFile() + "/tmp_" + fileName); 193 | 194 | if (fTmp.exists()) 195 | fTmp.delete(); 196 | 197 | FileOutputStream fos = new FileOutputStream( fTmp); 198 | OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8"); 199 | BufferedWriter bw = new BufferedWriter(osw); 200 | 201 | boolean first = true; 202 | String nextLine; 203 | for (File file:hFile){ 204 | 205 | FileInputStream fis = new FileInputStream(file ); 206 | InputStreamReader isr = new InputStreamReader(fis,"UTF-8"); 207 | BufferedReader br = new BufferedReader(isr); 208 | 209 | nextLine=br.readLine(); 210 | if (first && nextLine!=null){ 211 | bw.append(nextLine); 212 | bw.append("\r\n"); 213 | first=false; 214 | } 215 | 216 | while ((nextLine=br.readLine())!=null){ 217 | bw.append(nextLine); 218 | bw.append("\r\n"); 219 | 220 | } 221 | br.close(); 222 | isr.close(); 223 | fis.close(); 224 | br=null; 225 | isr=null; 226 | fis=null; 227 | 228 | } 229 | 230 | bw.close(); 231 | 232 | if (outputfile.exists()) 233 | outputfile.delete(); 234 | fTmp.renameTo(outputfile) ; 235 | 236 | if (fTmp.exists()) 237 | fTmp.delete(); 238 | 239 | } catch (IOException e) { 240 | e.printStackTrace(); 241 | }finally{ 242 | 243 | } 244 | } 245 | } 246 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/utils/FileHelper.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.utils; 2 | 3 | import java.io.*; 4 | import java.net.URL; 5 | import java.util.ArrayList; 6 | import java.util.Collection; 7 | import java.util.Comparator; 8 | import java.util.HashSet; 9 | import java.util.List; 10 | 11 | import org.apache.commons.configuration.ConfigurationException; 12 | import org.apache.commons.configuration.XMLConfiguration; 13 | import org.apache.log4j.Logger; 14 | import org.ihtsdo.json.TransformerDiskBased; 15 | 16 | public class FileHelper { 17 | 18 | private static final Logger log = Logger.getLogger(FileHelper.class); 19 | 20 | 21 | public static int countLines(File file, boolean firstLineHeader) throws IOException { 22 | 23 | FileInputStream fis = new FileInputStream(file); 24 | InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); 25 | LineNumberReader reader = new LineNumberReader(isr); 26 | int cnt = 0; 27 | String lineRead = ""; 28 | while ((lineRead = reader.readLine()) != null) { 29 | } 30 | 31 | cnt = reader.getLineNumber(); 32 | reader.close(); 33 | isr.close(); 34 | fis.close(); 35 | if(firstLineHeader){ 36 | return cnt-1; 37 | }else{ 38 | return cnt; 39 | } 40 | } 41 | 42 | public void findSimpleRefsetFiles(File releaseFolder,String stringKey,String nocontains, HashSet< String> hashSimpleRefsetList) { 43 | String name=""; 44 | if (hashSimpleRefsetList==null){ 45 | hashSimpleRefsetList=new HashSet(); 46 | 47 | } 48 | for (File file:releaseFolder.listFiles()){ 49 | if (file.isDirectory()){ 50 | findSimpleRefsetFiles(file, stringKey,nocontains,hashSimpleRefsetList); 51 | }else{ 52 | name=file.getName().toLowerCase().trim().replaceAll("-","_"); 53 | if (name.endsWith(".txt") 54 | && name.contains(stringKey)){ 55 | 56 | if (nocontains!=null && !name.contains(nocontains) ){ 57 | hashSimpleRefsetList.add(file.getAbsolutePath()); 58 | } 59 | } 60 | } 61 | } 62 | 63 | } 64 | 65 | 66 | public void findAllFiles(File releaseFolder, HashSet< String> hashSimpleRefsetList) { 67 | String name=""; 68 | if (hashSimpleRefsetList==null){ 69 | hashSimpleRefsetList=new HashSet(); 70 | 71 | } 72 | for (File file:releaseFolder.listFiles()){ 73 | if (file.isDirectory()){ 74 | findAllFiles(file, hashSimpleRefsetList); 75 | }else{ 76 | name=file.getName(); 77 | if (name.endsWith(".txt")){ 78 | hashSimpleRefsetList.add(file.getAbsolutePath()); 79 | } 80 | } 81 | } 82 | 83 | } 84 | 85 | public static String getFileTypeByHeader(File inputFile) { 86 | String namePattern =null; 87 | try { 88 | Thread currThread = Thread.currentThread(); 89 | if (currThread.isInterrupted()) { 90 | return null; 91 | } 92 | XMLConfiguration xmlConfig = new XMLConfiguration(ClassLoader.getSystemResource("validation-rules.xml")); 93 | List namePatterns = new ArrayList(); 94 | 95 | Object prop = xmlConfig.getProperty("files.file.fileType"); 96 | if (prop instanceof Collection) { 97 | namePatterns.addAll((Collection) prop); 98 | } 99 | // System.out.println(""); 100 | boolean toCheck = false; 101 | String headerRule = null; 102 | FileInputStream fis = new FileInputStream(inputFile); 103 | InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); 104 | BufferedReader br = new BufferedReader(isr); 105 | String header = br.readLine(); 106 | for (int i = 0; i < namePatterns.size(); i++) { 107 | if (currThread.isInterrupted()) { 108 | return null; 109 | } 110 | headerRule = xmlConfig.getString("files.file(" + i + ").headerRule.regex"); 111 | namePattern = namePatterns.get(i); 112 | if( header.matches(headerRule)){ 113 | if ((inputFile.getName().toLowerCase().contains("textdefinition") 114 | && namePattern.equals("rf2-descriptions")) 115 | || (inputFile.getName().toLowerCase().contains("description") 116 | && namePattern.equals("rf2-textDefinition"))){ 117 | continue; 118 | } 119 | toCheck = true; 120 | break; 121 | } 122 | } 123 | if (toCheck) { 124 | 125 | 126 | //System.out.println( "File: " + inputFile.getAbsolutePath() + " ** match file pattern: " + namePattern); 127 | 128 | } else { 129 | 130 | //System.out.println( "Cannot found header matcher for : " + inputFile.getName()); 131 | } 132 | br.close(); 133 | } catch (FileNotFoundException e) { 134 | System.out.println( "FileAnalizer: " + e.getMessage()); 135 | } catch (UnsupportedEncodingException e) { 136 | System.out.println( "FileAnalizer: " + e.getMessage()); 137 | } catch (IOException e) { 138 | System.out.println( "FileAnalizer: " + e.getMessage()); 139 | } catch (ConfigurationException e) { 140 | System.out.println( "FileAnalizer: " + e.getMessage()); 141 | } 142 | return namePattern; 143 | } 144 | 145 | public static void emptyFolder(File folder){ 146 | if(folder.isDirectory()){ 147 | File[] files = folder.listFiles(); 148 | for (File file : files) { 149 | if(file.isDirectory()){ 150 | emptyFolder(file); 151 | }else{ 152 | file.delete(); 153 | } 154 | } 155 | } 156 | } 157 | 158 | public static void copyTo(File inputFile,File outputFile) throws IOException { 159 | 160 | FileInputStream fis = new FileInputStream(inputFile); 161 | InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); 162 | LineNumberReader reader = new LineNumberReader(isr); 163 | 164 | 165 | FileOutputStream fos = new FileOutputStream( outputFile); 166 | OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8"); 167 | BufferedWriter bw = new BufferedWriter(osw); 168 | 169 | String lineRead = ""; 170 | while ((lineRead = reader.readLine()) != null) { 171 | bw.append(lineRead); 172 | bw.append("\r\n"); 173 | } 174 | reader.close(); 175 | bw.close(); 176 | 177 | } 178 | } 179 | 180 | 181 | class FileNameComparator implements Comparator{ 182 | 183 | private static final Logger log = Logger.getLogger(FileNameComparator.class); 184 | private int fieldToCompare; 185 | private String separator; 186 | 187 | public FileNameComparator(int fieldToCompare, String separator){ 188 | this.separator = separator; 189 | this.fieldToCompare = fieldToCompare; 190 | } 191 | 192 | public int compare(String file1, String file2) { 193 | String[] file1Split = file1.split(separator); 194 | String[] file2Split = file2.split(separator); 195 | 196 | String date1 = file1Split[fieldToCompare]; 197 | String date2 = file2Split[fieldToCompare]; 198 | log.debug("First file date: " + date1); 199 | log.debug("Second file date: " + date2); 200 | 201 | return date1.compareTo(date2); 202 | } 203 | 204 | } -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/utils/FileSorter.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.utils; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.BufferedWriter; 5 | import java.io.File; 6 | import java.io.FileInputStream; 7 | import java.io.FileNotFoundException; 8 | import java.io.FileOutputStream; 9 | import java.io.IOException; 10 | import java.io.InputStreamReader; 11 | import java.io.OutputStreamWriter; 12 | import java.util.ArrayList; 13 | import java.util.Collections; 14 | import java.util.HashMap; 15 | import java.util.Iterator; 16 | import java.util.List; 17 | 18 | 19 | 20 | public class FileSorter { 21 | 22 | private File inputFile; 23 | private File outputFile; 24 | private File tempFolder; 25 | private int[] sortColumns; 26 | private final Integer SPLIT_SIZE = 150000; 27 | 28 | public void execute() { 29 | try { 30 | FileHelper.emptyFolder(tempFolder); 31 | 32 | long start1 = System.currentTimeMillis(); 33 | //int ln = countLines(file); 34 | 35 | FileInputStream fis = new FileInputStream(inputFile); 36 | InputStreamReader isr = new InputStreamReader(fis,"UTF-8"); 37 | BufferedReader br = new BufferedReader(isr); 38 | 39 | double lines = 1; 40 | List list = new ArrayList(); 41 | String nextLine; 42 | String header=br.readLine(); 43 | while ((nextLine = br.readLine()) != null) { 44 | // nextLine = new String(nextLine.getBytes(),"UTF-8"); 45 | list.add(nextLine.split("\t",-1)); 46 | if (lines % SPLIT_SIZE == 0) { 47 | FileOutputStream fos = new FileOutputStream(new File(tempFolder, "fileno" + lines / SPLIT_SIZE + ".txt")); 48 | OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8"); 49 | writeFile(list, osw, sortColumns); 50 | list = new ArrayList(); 51 | } 52 | lines++; 53 | } 54 | if (lines % SPLIT_SIZE != 0) { 55 | FileOutputStream fos = new FileOutputStream(new File(tempFolder, "fileno" + lines / SPLIT_SIZE + ".txt")); 56 | OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8"); 57 | writeFile(list, osw, sortColumns); 58 | } 59 | br.close(); 60 | sortFile(outputFile, tempFolder, header); 61 | long end1 = System.currentTimeMillis(); 62 | long elapsed1 = (end1 - start1); 63 | System.out.println("Lines in output file : " + lines); 64 | System.out.println("Completed in " + elapsed1 + " ms"); 65 | } catch (Exception e) { 66 | e.printStackTrace(); 67 | } 68 | 69 | } 70 | 71 | 72 | public FileSorter(File inputFile, File outputFile, File tempFolder, 73 | int[] sortColumns) { 74 | super(); 75 | this.inputFile = inputFile; 76 | this.outputFile = outputFile; 77 | this.tempFolder = tempFolder; 78 | this.sortColumns = sortColumns; 79 | } 80 | 81 | 82 | public void writeFile(List datos, OutputStreamWriter osw, int[] orderColumns) { 83 | try { 84 | BufferedWriter bw = new BufferedWriter(osw); 85 | Collections.sort(datos, new ArrayComparator(orderColumns, false)); 86 | 87 | for (String[] row : datos) { 88 | for (int i = 0; i < row.length; i++) { 89 | bw.append(row[i]); 90 | if (i + 1 < row.length) { 91 | bw.append('\t'); 92 | } 93 | 94 | } 95 | bw.append("\r\n"); 96 | } 97 | bw.close(); 98 | datos = null; 99 | System.gc(); 100 | 101 | } catch (IOException e) { 102 | e.printStackTrace(); 103 | } 104 | 105 | } 106 | public void sortFile( File outputFile, File tempFolder, String header) { 107 | try { 108 | 109 | if (outputFile.exists()){ 110 | outputFile.delete(); 111 | } 112 | FileOutputStream fos = new FileOutputStream(outputFile); 113 | OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); 114 | BufferedWriter sortedBw = new BufferedWriter(osw); 115 | sortedBw.append(header); 116 | sortedBw.append("\r\n"); 117 | // Merge 118 | File[] files = tempFolder.listFiles(); 119 | 120 | HashMap readers = new HashMap(); 121 | for (int i = 0; i < files.length; i++) { 122 | if (!files[i].isHidden()) { 123 | FileInputStream fis = new FileInputStream(files[i]); 124 | InputStreamReader isr = new InputStreamReader(fis,"UTF-8"); 125 | BufferedReader bufReader = new BufferedReader(isr); 126 | String row; 127 | if ((row = bufReader.readLine()) != null) { 128 | readers.put(bufReader, row.split("\t",-1)); 129 | } else { 130 | bufReader.close(); 131 | files[i].delete(); 132 | readers.remove(bufReader); 133 | } 134 | } 135 | } 136 | 137 | while (!readers.isEmpty()) { 138 | String[] smallestRow = CommonUtils.getSmallestArray(readers,sortColumns); 139 | for (int i = 0; i < smallestRow.length; i++) { 140 | sortedBw.append(smallestRow[i]); 141 | if (i + 1 < smallestRow.length) { 142 | sortedBw.append('\t'); 143 | } 144 | } 145 | sortedBw.append("\r\n"); 146 | 147 | Iterator it = readers.keySet().iterator(); 148 | BufferedReader smallest = null; 149 | while (it.hasNext()) { 150 | BufferedReader bufferedReader = (BufferedReader) it.next(); 151 | if (readers.get(bufferedReader).equals(smallestRow)) { 152 | smallest = bufferedReader; 153 | break; 154 | } 155 | } 156 | if (smallest.ready()) { 157 | readers.put(smallest, smallest.readLine().split("\t",-1)); 158 | } else { 159 | smallest.close(); 160 | readers.remove(smallest); 161 | } 162 | } 163 | 164 | sortedBw.close(); 165 | 166 | } catch (FileNotFoundException e) { 167 | e.printStackTrace(); 168 | } catch (IOException e) { 169 | e.printStackTrace(); 170 | } 171 | } 172 | 173 | } 174 | -------------------------------------------------------------------------------- /src/main/java/org/ihtsdo/json/utils/TClosure.java: -------------------------------------------------------------------------------- 1 | package org.ihtsdo.json.utils; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.FileInputStream; 5 | import java.io.FileNotFoundException; 6 | import java.io.IOException; 7 | import java.io.InputStreamReader; 8 | import java.util.ArrayList; 9 | import java.util.HashMap; 10 | import java.util.HashSet; 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | import org.ihtsdo.json.model.LightRelationship; 15 | 16 | public class TClosure { 17 | 18 | // HashMap>parentHier; 19 | HashMap>childrenHier; 20 | // private long ISARELATIONSHIPTYPEID=116680003l; 21 | private String ISA_SCTID="116680003"; 22 | private String ROOT_CONCEPT = "138875005"; 23 | String rf2Rels; 24 | private HashSet hControl; 25 | public TClosure(String rf2Rels) throws FileNotFoundException, IOException{ 26 | // parentHier=new HashMap>(); 27 | childrenHier=new HashMap>(); 28 | this.rf2Rels=rf2Rels; 29 | loadIsas(); 30 | } 31 | public TClosure(Map> relationships,String charType) throws FileNotFoundException, IOException { 32 | 33 | // parentHier=new HashMap>(); 34 | childrenHier=new HashMap>(); 35 | loadIsasFromMap(relationships, charType); 36 | } 37 | private void loadIsasFromMap(Map> relationships,String charType) { 38 | 39 | List listLR = new ArrayList(); 40 | 41 | for (String cptId:relationships.keySet()){ 42 | listLR = relationships.get(cptId); 43 | if (listLR != null) { 44 | for (LightRelationship lrel : listLR) { 45 | if (lrel.getCharType().equals(charType) && 46 | lrel.getType().equals(ISA_SCTID) && 47 | lrel.isActive()) { 48 | 49 | addRel(Long.parseLong(lrel.getTarget()),Long.parseLong(cptId)); 50 | } 51 | } 52 | } 53 | } 54 | } 55 | 56 | private void loadIsas() throws IOException, FileNotFoundException { 57 | System.out.println("Starting Isas Relationships from: " + rf2Rels); 58 | BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(rf2Rels), "UTF8")); 59 | try { 60 | String line = br.readLine(); 61 | line = br.readLine(); // Skip header 62 | int count = 0; 63 | while (line != null) { 64 | if (line.isEmpty()) { 65 | continue; 66 | } 67 | String[] columns = line.split("\\t"); 68 | if (columns[7].equals(ISA_SCTID) 69 | && columns[2].equals("1") 70 | && !columns[4].equals(ROOT_CONCEPT)){ 71 | addRel(Long.parseLong(columns[5]),Long.parseLong(columns[4])); 72 | 73 | count++; 74 | if (count % 100000 == 0) { 75 | System.out.print("."); 76 | } 77 | } 78 | line = br.readLine(); 79 | } 80 | System.out.println("."); 81 | // System.out.println("Parent isas Relationships loaded = " + parentHier.size()); 82 | System.out.println("Children isas Relationships loaded = " + childrenHier.size()); 83 | } finally { 84 | br.close(); 85 | } 86 | } 87 | public void addRel(Long parent, Long child){ 88 | if (parent==child){ 89 | System.out.println("same child and parent: " + child); 90 | return; 91 | } 92 | // HashSet parentList=parentHier.get(child); 93 | // if (parentList==null){ 94 | // parentList=new HashSet(); 95 | // } 96 | // parentList.add(parent); 97 | // parentHier.put(child, parentList); 98 | 99 | HashSet childrenList=childrenHier.get(parent); 100 | if (childrenList==null){ 101 | childrenList=new HashSet(); 102 | } 103 | childrenList.add(child); 104 | childrenHier.put(parent, childrenList); 105 | } 106 | 107 | // public boolean isAncestorOf(Long ancestor,Long descendant){ 108 | // 109 | // HashSetparent=parentHier.get(descendant); 110 | // if (parent==null){ 111 | // return false; 112 | // } 113 | // if (parent.contains(ancestor)){ 114 | // return true; 115 | // } 116 | // for(Long par:parent){ 117 | // if (isAncestorOf(ancestor,par)){ 118 | // return true; 119 | // } 120 | // } 121 | // return false; 122 | // } 123 | 124 | // public HashSet getParent(Long conceptId) { 125 | // return parentHier.get(conceptId); 126 | // } 127 | 128 | public HashSet getChildren(Long conceptId) { 129 | return childrenHier.get(conceptId); 130 | } 131 | public int getDescendantsCount(Long conceptId){ 132 | 133 | hControl = new HashSet(); 134 | int ret=getDistinctChildrenCount(conceptId); 135 | hControl=null; 136 | return ret; 137 | } 138 | private int getDistinctChildrenCount(Long conceptId){ 139 | HashSet children=childrenHier.get(conceptId); 140 | if (children==null){ 141 | return 0; 142 | } 143 | int ret=0; 144 | for(Long child:children){ 145 | if (!hControl.contains(child)){ 146 | hControl.add(child); 147 | ret++; 148 | 149 | ret+=getDistinctChildrenCount(child); 150 | } 151 | } 152 | return ret; 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/main/resources/char_conversion_table.txt: -------------------------------------------------------------------------------- 1 | COVERT TO CONVERT FROM 2 | A 00E1 00E2 00E3 00E4 00E5 0101 0103 0105 01CE 01FB 00C0 00C4 3 | AE 00E6 01FD 4 | C 00E7 0107 0109 010B 010D 5 | D 010F 0111 00F0 6 | E 00E8 00E9 00EA 00EB 0113 0115 0117 0119 011B 7 | F 0192 8 | G 011D 011F 0121 0123 9 | H 0125 0127 10 | I 00ED 00EC 00EE 00EF 0129 012B 012D 012F 0131 11 | IJ 0133 12 | J 0135 13 | K 0137 0138 14 | L 013A 013C 013E 0140 0142 15 | N 00F1 0144 0146 0148 0149 014B 16 | O 00F2 00F3 00F4 00F5 00F6 014D 014F 0151 01A1 01D2 01FF 17 | OE 0153 18 | R 0155 0157 0159 19 | S 015B 015D 015F 0161 20 | T 0163 0165 0167 21 | U 00F9 00FA 00FB 00FC 0169 016B 016B 016D 016F 0171 0173 01B0 01D4 01D6 01D8 01DA 01DC 22 | W 0175 23 | Y 00FD 00FF 0177 24 | Z 017A 017C 017E 25 | A 00C1 00C2 00C3 CC04 00C5 00E0 0100 0102 0104 01CD 01FB 26 | AE 00C6 27 | C 00C7 0106 0108 010A 010C 28 | D 010E 0110 00D0 29 | E 00C8 00C9 00CA 00CB 0112 0114 0116 0118 011A 30 | G 011C 011E 0120 0122 31 | H 0124 0126 32 | I 00CD 00CC 00CE 00CF 0128 012A 012C 012E 0049 33 | IJ 0132 34 | J 0134 35 | K 0136 36 | L 0139 013B 013D 013F 0141 37 | N 00D1 0143 0145 0147 0149 014A 38 | O 00D2 00D3 00D4 00D5 00D6 014C 014E 0150 01A0 01D1 39 | OE 0152 40 | R 0154 0156 0158 41 | S 015A 015C 015E 0160 42 | T 0162 0164 0166 43 | U 00D9 00DA 00DB 00DC 0168 016A 016C 016E 0170 0172 01AF 01D3 01D5 01D7 01D9 01DB 44 | W 0174 45 | Y 0178 0176 46 | Z 0179 017B 017D -------------------------------------------------------------------------------- /src/main/resources/greek_character_conversion_table.txt: -------------------------------------------------------------------------------- 1 | CVTTO UPPER HEX LOW HEX 2 | ALPHA char=Α 0391 char=α 03B1 3 | BETA char=Β 0392 char=β 03B2 4 | GAMMA char=Γ 0393 char=γ 03B3 5 | DELTA char=Δ 0394 char=δ 03B4 6 | EPSILON char=Ε 0395 char=ε 03B5 7 | ZETA char=Ζ 0396 char=ζ 03B6 8 | ETA char=Η 0397 char=η 03B7 9 | THETA char=Θ 0398 char=θ 03B8 10 | IOTA char=Ι 0399 char=ι 03B9 11 | KAPPA char=Κ 039A char=κ 03BA 12 | LAMBDA char=Λ 039B char=λ 03BB 13 | MU char=Μ 039C char=μ 03BC 14 | NU char=Ν 039D char=ν 03BD 15 | XI char=Ξ 039E char=ξ 03BE 16 | OMICRON char=Ο 039F char=ο 03BF 17 | PI char=Π 03A0 char=π 03C0 18 | RHO char=Ρ 03A1 char=ρ 03C1 19 | SIGMA char=Σ 03A3 char=σ 03C3 20 | TAU char=Τ 03A4 char=τ 03C4 21 | UPSILON char=Υ 03A5 char=υ 03C5 22 | PHI char=Φ 03A6 char=φ 03C6 23 | CHI char=Χ 03A7 char=χ 03C7 24 | PSI char=Ψ 03A8 char=ψ 03C8 25 | OMEGA char=Ω 03A9 char=ω 03C9 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/main/resources/validation-rules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | rf2-concepts 6 | 7 | .*Concept.* 8 | 9 | 10 | .*Concept.* 11 | 12 | 13 | id\\teffectiveTime\\tactive\\tmoduleId\\tdefinitionStatusId$ 14 | 15 | 16 | \d{3\,}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}$ 17 | 18 | 19 | 20 | rf2-descriptions 21 | 22 | .*Description.* 23 | 24 | 25 | .*Description.* 26 | 27 | 28 | id\\teffectiveTime\\tactive\\tmoduleId\\tconceptId\\tlanguageCode\\ttypeId\\tterm\\tcaseSignificanceId$ 29 | 30 | 31 | \d{3\,}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\w+\\t\d{3\,}\\t.+\\t\d{3\,}$ 32 | 33 | 34 | 35 | rf2-simplemaps 36 | 37 | .*SimpleMap.* 38 | 39 | 40 | .*SimpleMap.* 41 | 42 | 43 | id\\teffectiveTime\\tactive\\tmoduleId\\tref[sS]etId\\treferencedComponentId\\tmapTarget$ 44 | 45 | 46 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t.+$ 47 | 48 | 49 | 50 | rf2-orderRefset 51 | 52 | .*Refset_Order.* 53 | 54 | 55 | .*Refset_Order.* 56 | 57 | 58 | id\\teffectiveTime\\tactive\\tmoduleId\\tref[sS]etId\\treferencedComponentId\\torder\\tlinkedTo$ 59 | 60 | 61 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{1\,}\\t\d{1\,}$ 62 | 63 | 64 | 65 | rf2-simple 66 | 67 | .*Simple.* 68 | 69 | 70 | .*Simple.* 71 | 72 | 73 | id\\teffectiveTime\\tactive\\tmoduleId\\tref[sS]etId\\treferencedComponentId$ 74 | 75 | 76 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t.+$ 77 | 78 | 79 | 80 | rf2-language 81 | 82 | .*Language.* 83 | 84 | 85 | .*Language.* 86 | 87 | 88 | id\\teffectiveTime\\tactive\\tmoduleId\\tref[sS]etId\\treferencedComponentId\\tacceptabilityId$ 89 | 90 | 91 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}$ 92 | 93 | 94 | 95 | rf2-attributevalue 96 | 97 | .*AttributeValue.* 98 | 99 | 100 | .*AttributeValue.* 101 | 102 | 103 | id\\teffectiveTime\\tactive\\tmoduleId\\tref[sS]etId\\treferencedComponentId\\tvalueId$ 104 | 105 | 106 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}$ 107 | 108 | 109 | 110 | rf2-association 111 | 112 | .*Association.* 113 | 114 | 115 | .*Association.* 116 | 117 | 118 | id\\teffectiveTime\\tactive\\tmoduleId\\tref[sS]etId\\treferencedComponentId\\ttargetComponent$ 119 | 120 | 121 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}$ 122 | 123 | 124 | 125 | rf2-association-2 126 | 127 | .*Association.* 128 | 129 | 130 | .*Association.* 131 | 132 | 133 | id\\teffectiveTime\\tactive\\tmoduleId\\tref[sS]etId\\treferencedComponentId\\ttargetComponentId$ 134 | 135 | 136 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}$ 137 | 138 | 139 | 154 | 170 | 185 | 200 | 215 | 230 | 231 | rf2-subsets 232 | 233 | .*Subsets.* 234 | 235 | 236 | .*Subsets.* 237 | 238 | 239 | id\\teffectiveTime\\tactive\\tmoduleId\\tSUBSETID\\tSUBSETORIGINALID\\tSUBSETVERSION\\tSUBSETNAME\\tSUBSETTYPE\\tLANGUAGECODE\\tREALMID\\tCONTEXTID$ 240 | 241 | 242 | \d{3\,}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d+\\t\d+\\t\d+\\t.+\\t\d{1}\\t.+\\t.+\\t\d{1}$ 243 | 244 | 245 | 246 | rf2-crossmapsets 247 | 248 | .*Sets.* 249 | 250 | 251 | .*Sets.* 252 | 253 | 254 | id\\teffectiveTime\\tactive\\tmoduleId\\tMAPSETID\\tMAPSETNAME\\tMAPSETTYPE\\tMAPSETSCHEMEID\\tMAPSETSCHEMENAME\\tMAPSETSCHEMEVERSION\\tMAPSETREALMID\\tMAPSETSEPARATOR\\tMAPSETRULETYPE$ 255 | 256 | 257 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t.+\\t\d{1}\\t.+\\t.+\\t\d+\\t\d*\\t.{1}\\t\d*$ 258 | 259 | 260 | 261 | rf2-crossmaptargets 262 | 263 | .*Targets.* 264 | 265 | 266 | .*Targets.* 267 | 268 | 269 | id\\teffectiveTime\\tactive\\tmoduleId\\tMAPSETID\\tTARGETID\\tTARGETCODES\\tTARGETRULE\\tTARGETADVICE$ 270 | 271 | 272 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t.+\\t.*\\t.*\\t.*$ 273 | 274 | 275 | 276 | rf2-identifier 277 | 278 | .*Identifier.* 279 | 280 | 281 | .*Identifier.* 282 | 283 | 284 | identifierSchemeId\\talternateIdentifier\\teffectiveTime\\tactive\\tmoduleId\\treferencedComponentId$ 285 | 286 | 287 | .*\\t.*\\t.*\\t.*\\t.*\\t.*$ 288 | 289 | 290 | 291 | rf2-equivalencemap 292 | 293 | .*ComplexMap.* 294 | 295 | 296 | .*ComplexMap.* 297 | 298 | 299 | id\\teffectiveTime\\tactive\\tmoduleId\\tref[sS]etId\\treferencedComponentId\\tmapGroup\\tmapPriority\\tmapRule\\tmapAdvice\\tmapTarget\\tcorrelationId$ 300 | 301 | 302 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{1}\\t\d{1}\\t.*\\t.*\\t.*\\t\d{3\,}$ 303 | 304 | 305 | 306 | rf2-uktc-equivalencemap 307 | 308 | .*ComplexMap.* 309 | 310 | 311 | .*ComplexMap.* 312 | 313 | 314 | id\\teffectiveTime\\tactive\\tmoduleId\\tref[sS]etId\\treferencedComponentId\\tmapGroup\\tmapPriority\\tmapRule\\tmapAdvice\\tmapTarget\\tcorrelationId\\tmapBlock$ 315 | 316 | 317 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{1\,}\\t\d{1\,}\\t.*\\t.*\\t.*\\t\d{3\,}\\t\d{1\,}$ 318 | 319 | 320 | 321 | rf2-refsetdescriptor 322 | 323 | .*RefsetDescriptor.* 324 | 325 | 326 | .*RefsetDescriptor.* 327 | 328 | 329 | id\\teffectiveTime\\tactive\\tmoduleId\\tref[sS]etId\\treferencedComponentId\\tattributeDescription\\tattributeType\\tattributeOrder$ 330 | 331 | 332 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{1}$ 333 | 334 | 335 | 336 | rf2-descriptiontype 337 | 338 | .*DescriptionType.* 339 | 340 | 341 | .*DescriptionType.* 342 | 343 | 344 | id\\teffectiveTime\\tactive\\tmoduleId\\tref[sS]etId\\treferencedComponentId\\tdescriptionFormat\\tdescriptionLength$ 345 | 346 | 347 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d*$ 348 | 349 | 350 | 351 | rf2-moduledependency 352 | 353 | .*ModuleDependency.* 354 | 355 | 356 | .*ModuleDependency.* 357 | 358 | 359 | id\\teffectiveTime\\tactive\\tmoduleId\\tref[sS]etId\\treferencedComponentId\\tsourceEffectiveTime\\ttargetEffectiveTime$ 360 | 361 | 362 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{8}\\t\d{8}$ 363 | 364 | 365 | 366 | rf2-textDefinition 367 | 368 | .*TextDefinition.* 369 | 370 | 371 | .*TextDefinition.* 372 | 373 | 374 | id\\teffectiveTime\\tactive\\tmoduleId\\tconceptId\\tlanguageCode\\ttypeId\\tterm\\tcaseSignificanceId$ 375 | 376 | 377 | \d{3\,}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\w+\\t\d{3\,}\\t.+\\t\d{3\,}$ 378 | 379 | 380 | 395 | 396 | rf2-relationships 397 | 398 | .*Relationship.* 399 | 400 | 401 | .*Relationship.* 402 | 403 | 404 | id\\teffectiveTime\\tactive\\tmoduleId\\tsourceId\\tdestinationId\\trelationshipGroup\\ttypeId\\tcharacteristicTypeId\\tmodifierId$ 405 | 406 | 407 | \d{3\,}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{1\,3}\\t\d{3\,}\\t((\-1)|(\d{1\,}))\\t\d{3\,}$ 408 | 409 | 410 | 411 | rf2-navigation 412 | 413 | .*Navigation.* 414 | 415 | 416 | .*Navigation.* 417 | 418 | 419 | id\\teffectiveTime\\tactive\\tmoduleId\\tref[sS]etId\\treferencedComponentId\\torder\\tlinkedTo$ 420 | 421 | 422 | [\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}\\t\d{8}\\t\d{1}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{1\,}\\t\d{3\,}$ 423 | 424 | 425 | 426 | rf1-concepts 427 | 428 | .*concept.* 429 | 430 | 431 | .*concepts.* 432 | 433 | 434 | CONCEPTID\\tCONCEPTSTATUS\\tFULLYSPECIFIEDNAME\\tCTV3ID\\tSNOMEDID\\tISPRIMITIVE$ 435 | 436 | 437 | \d{3\,}\\t\d+\\t.+\\t.+\\t.+\\t\d{1}$ 438 | 439 | 440 | 441 | rf1-descriptions 442 | 443 | .*descriptions.* 444 | 445 | 446 | .*descriptions.* 447 | 448 | 449 | DESCRIPTIONID\\tDESCRIPTIONSTATUS\\tCONCEPTID\\tTERM\\tINITIALCAPITALSTATUS\\tDESCRIPTIONTYPE\\tLANGUAGECODE$ 450 | 451 | 452 | \d{3\,}\\t\d{1}\\t\d{3\,}\\t.+\\t\d{1}\\t\d{1}\\t.+$ 453 | 454 | 455 | 456 | rf1-relationships 457 | 458 | .*relationships.* 459 | 460 | 461 | .*relationships.* 462 | 463 | 464 | RELATIONSHIPID\\tCONCEPTID1\\tRELATIONSHIPTYPE\\tCONCEPTID2\\tCHARACTERISTICTYPE\\tREFINABILITY\\tRELATIONSHIPGROUP$ 465 | 466 | 467 | \d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{3\,}\\t\d{1}\\t\d{1}\\t\d{1\,2}$ 468 | 469 | 470 | 471 | rf1-subsets 472 | 473 | .*subsets.* 474 | 475 | 476 | .*subsets.* 477 | 478 | 479 | SUBSETID\\tSUBSETORIGINALID\\tSUBSETVERSION\\tSUBSETNAME\\tSUBSETTYPE\\tLANGUAGECODE\\tREALMID\\tCONTEXTID$ 480 | 481 | 482 | \d{3\,}\\t\d{3\,}\\t\d{1}\\t.+\\t\d{1}\\t.+\\t\d{1}\\t\d{1}$ 483 | 484 | 485 | 486 | rf1-subsetmembers 487 | 488 | .*members.* 489 | 490 | 491 | .*members.* 492 | 493 | 494 | SUBSETID\\tMEMBERID\\tMEMBERSTATUS\\tLINKEDID$ 495 | 496 | 497 | \d+\\t\d{3\,}\\t\d{1}\\t\d*$ 498 | 499 | 500 | 501 | rf1-crossmaps 502 | 503 | .*cross.* 504 | 505 | 506 | .*cross.* 507 | 508 | 509 | MAPSETID\\tMAPCONCEPTID\\tMAPOPTION\\tMAPPRIORITY\\tMAPTARGETID\\tMAPRULE\\tMAPADVICE$ 510 | 511 | 512 | \d{3\,}\\t\d{3\,}\\t\d*\\t\d*\\t.+\\t\d*\\t\d*$ 513 | 514 | 515 | 516 | rf1-crossmapsets 517 | 518 | .*sets.* 519 | 520 | 521 | .*sets.* 522 | 523 | 524 | MAPSETID\\tMAPSETNAME\\tMAPSETTYPE\\tMAPSETSCHEMEID\\tMAPSETSCHEMENAME\\tMAPSETSCHEMEVERSION\\tMAPSETREALMID\\tMAPSETSEPARATOR\\tMAPSETRULETYPE$ 525 | 526 | 527 | \d{3\,}\\t.+\\t\d{1}\\t.+\\t.+\\t\d+\\t\d*\\t.{1}\\t\d*$ 528 | 529 | 530 | 531 | rf1-crossmaptargets 532 | 533 | .*targets.* 534 | 535 | 536 | .*targets.* 537 | 538 | 539 | TARGETID\\tTARGETSCHEMEID\\tTARGETCODES\\tTARGETRULE\\tTARGETADVICE$ 540 | 541 | 542 | \d{3\,}\\t.*\\t.*\\t.*\\t.*$ 543 | 544 | 545 | 546 | rf1-componenthistory 547 | 548 | .*componenthistory.* 549 | 550 | 551 | .*componenthistory.* 552 | 553 | 554 | COMPONENTID\\tRELEASEVERSION\\tCHANGETYPE\\tSTATUS\\tREASON$ 555 | 556 | 557 | \d{3\,}\\t\d{3\,}\\t\d{1}\\t\d{1\,2}\\t.*$ 558 | 559 | 560 | 561 | rf1-references 562 | 563 | .*references.* 564 | 565 | 566 | .*references.* 567 | 568 | 569 | COMPONENTID\\tREFERENCETYPE\\tREFERENCEDID$ 570 | 571 | 572 | \d{3\,}\\t\d{1}\\t\d{3\,}$ 573 | 574 | 575 | 576 | rf1-textdefinitions 577 | 578 | .*TextDefinition.* 579 | 580 | 581 | .*TextDefinition.* 582 | 583 | 584 | CONCEPTID\\tSNOMEDID\\tFULLYSPECIFIEDNAME\\tDEFINITION$ 585 | 586 | 587 | \d{3\,}\\t.+\\t.+\\t.+$ 588 | 589 | 590 | 591 | --------------------------------------------------------------------------------