diff --git a/app/pods/components/control/md-itis/component.js b/app/pods/components/control/md-itis/component.js index b3b8ddad3..265792869 100644 --- a/app/pods/components/control/md-itis/component.js +++ b/app/pods/components/control/md-itis/component.js @@ -119,6 +119,7 @@ export default Component.extend({ if (!system) { itisCitation.get('date').pushObject(dateObj); + itisCitation.get('date').pushObject(classifierDateObj); systems.pushObject({ citation: itisCitation, }); diff --git a/app/pods/components/control/md-itis/template.hbs b/app/pods/components/control/md-itis/template.hbs index 93ab7e6e7..dfc9e2b24 100644 --- a/app/pods/components/control/md-itis/template.hbs +++ b/app/pods/components/control/md-itis/template.hbs @@ -1,39 +1,45 @@ -{{#layout/md-card - spotlightEnabled=false - block=false -}} -
-
- - {{input/md-input - value=this.searchString - placeholder="Search ITIS using common name, scientific name, or TSN" - }} +{{#layout/md-card spotlightEnabled=false block=false}} +
+
+ + {{input/md-input + value=this.searchString + placeholder='Search ITIS using common name, scientific name, or TSN' + }}
-
- +
+ {{input/md-select - value=this.kingdom - valuePath="kingdomName" - namePath="title" - objectArray=(sort-by "title" itis.kingdoms.kingdomNames) - searchEnabled=false - tooltip=true - allowClear=true - tooltipPath="kingdomName" - disabled=(if searchString false true) - placeholder="Select a kingdom." + value=this.kingdom + valuePath='kingdomName' + namePath='title' + objectArray=(sort-by 'title' itis.kingdoms.kingdomNames) + searchEnabled=false + tooltip=true + allowClear=true + tooltipPath='kingdomName' + disabled=(if searchString false true) + placeholder='Select a kingdom.' }}
- -
-{{/liquid-if}} +{{/liquid-if}} \ No newline at end of file diff --git a/app/services/itis.js b/app/services/itis.js index 114d103fe..478bf1c32 100644 --- a/app/services/itis.js +++ b/app/services/itis.js @@ -4,7 +4,7 @@ import titleize from 'ember-cli-string-helpers/utils/titleize'; import { isAjaxError, isNotFoundError, - isForbiddenError + isForbiddenError, } from 'ember-ajax/errors'; //import moment from 'moment'; @@ -14,14 +14,13 @@ const proxy = '/itis-proxy?' + 'wt=json' + '&sort=score%20desc,nameWOInd%20asc' + - '&fl=hierarchySoFarWRanks,hierarchyTSN,kingdom,rank,vernacular,tsn,nameWOInd,usage'; + '&fl=hierarchySoFarWRanks,hierarchyTSN,kingdom,rank,vernacular,tsn,nameWOInd,usage,taxonAuthor,updateDate'; const Taxa = EmberObject.extend({ style: computed('status', function () { let status = this.status; - return status === 'valid' || status === 'accepted' ? 'success' : - 'danger'; - }) + return status === 'valid' || status === 'accepted' ? 'success' : 'danger'; + }), }); export default Service.extend({ @@ -29,82 +28,94 @@ export default Service.extend({ this._super(...arguments); this.kingdoms = { - "class": "gov.usgs.itis.itis_service.metadata.SvcKingdomNameList", - "kingdomNames": [{ - "class": "gov.usgs.itis.itis_service.metadata.SvcKingdomName", - "kingdomId": "1", - "kingdomName": "Bacteria", - "title": "Bacteria", - "tsn": "50" - }, { - "class": "gov.usgs.itis.itis_service.metadata.SvcKingdomName", - "kingdomId": "2", - "kingdomName": "Protozoa", - "title": "Protozoa", - "tsn": "630577" - }, { - "class": "gov.usgs.itis.itis_service.metadata.SvcKingdomName", - "kingdomId": "3", - "kingdomName": "Plantae", - "title": "Plant", - "tsn": "202422" - }, { - "class": "gov.usgs.itis.itis_service.metadata.SvcKingdomName", - "kingdomId": "4", - "kingdomName": "Fungi", - "title": "Fungal", - "tsn": "555705" - }, { - "class": "gov.usgs.itis.itis_service.metadata.SvcKingdomName", - "kingdomId": "5", - "kingdomName": "Animalia", - "title": "Animal", - "tsn": "202423" - }, { - "class": "gov.usgs.itis.itis_service.metadata.SvcKingdomName", - "kingdomId": "6", - "kingdomName": "Chromista", - "title": "Chromista", - "tsn": "630578" - }, { - "class": "gov.usgs.itis.itis_service.metadata.SvcKingdomName", - "kingdomId": "7", - "kingdomName": "Archaea", - "title": "Archaea", - "tsn": "935939" - }] - } + class: 'gov.usgs.itis.itis_service.metadata.SvcKingdomNameList', + kingdomNames: [ + { + class: 'gov.usgs.itis.itis_service.metadata.SvcKingdomName', + kingdomId: '1', + kingdomName: 'Bacteria', + title: 'Bacteria', + tsn: '50', + }, + { + class: 'gov.usgs.itis.itis_service.metadata.SvcKingdomName', + kingdomId: '2', + kingdomName: 'Protozoa', + title: 'Protozoa', + tsn: '630577', + }, + { + class: 'gov.usgs.itis.itis_service.metadata.SvcKingdomName', + kingdomId: '3', + kingdomName: 'Plantae', + title: 'Plant', + tsn: '202422', + }, + { + class: 'gov.usgs.itis.itis_service.metadata.SvcKingdomName', + kingdomId: '4', + kingdomName: 'Fungi', + title: 'Fungal', + tsn: '555705', + }, + { + class: 'gov.usgs.itis.itis_service.metadata.SvcKingdomName', + kingdomId: '5', + kingdomName: 'Animalia', + title: 'Animal', + tsn: '202423', + }, + { + class: 'gov.usgs.itis.itis_service.metadata.SvcKingdomName', + kingdomId: '6', + kingdomName: 'Chromista', + title: 'Chromista', + tsn: '630578', + }, + { + class: 'gov.usgs.itis.itis_service.metadata.SvcKingdomName', + kingdomId: '7', + kingdomName: 'Archaea', + title: 'Archaea', + tsn: '935939', + }, + ], + }; this.citation = EmberObject.create({ - "title": "Integrated Taxonomic Information System (ITIS)", - "date": [ + title: 'Integrated Taxonomic Information System (ITIS)', + date: [ /*{ "date": moment().format('YYYY-MM-DD'), "dateType": "transmitted" }*/ ], - "presentationForm": [ - "webService", - "webSite" + presentationForm: ['webService', 'webSite'], + otherCitationDetails: [ + 'Retrieved from the Integrated Taxonomic Information System on-line database, https://www.itis.gov.', + ], + onlineResource: [ + { + uri: 'https://www.itis.gov', + name: 'ITIS website', + protocol: 'HTTPS', + function: 'information', + description: + 'ITIS contains taxonomic information on plants, animals, fungi, and microbes of North America and the world.', + }, ], - "otherCitationDetails": [ - "Retrieved from the Integrated Taxonomic Information System on-line database, https://www.itis.gov." + graphic: [ + { + fileName: 'itis_logo.jpg', + fileType: 'JPEG', + fileUri: [ + { + uri: 'https://itis.gov/Static/images/itis_logo.jpg', + }, + ], + }, ], - "onlineResource": [{ - "uri": "https://www.itis.gov", - "name": "ITIS website", - "protocol": "HTTPS", - "function": "information", - "description": "ITIS contains taxonomic information on plants, animals, fungi, and microbes of North America and the world." - }], - "graphic": [{ - "fileName": "itis_logo.jpg", - "fileType": "JPEG", - "fileUri": [{ - "uri": "https://itis.gov/Static/images/itis_logo.jpg" - }] - }] - }) + }); }, settings: service(), @@ -114,51 +125,57 @@ export default Service.extend({ sendQuery(searchString, kingdom, limit = 50) { const formatted = searchString.replace(/(-| )/g, '*'); - const titleized = titleize(searchString.replace(/(-)/g, '#')).replace(/( |#)/g, '*'); + const titleized = titleize(searchString.replace(/(-)/g, '#')).replace( + /( |#)/g, + '*' + ); const titleized2 = titleize(searchString).replace(/( )/g, '*'); const mdTranslatorApiUrl = this.settings.data.get('itisProxyUrl'); - const url = mdTranslatorApiUrl + proxy + + const url = + mdTranslatorApiUrl + + proxy + `&rows=${limit}&q=` + `(vernacular:*${formatted}*~0.5%20OR%20vernacular:*${titleized}*~0.5%20OR%20vernacular:*${titleized2}*~0.5` + `%20OR%20nameWOInd:${formatted}*~0.5%20OR%20nameWOInd:*${titleized}*~0.5` + `%20OR%20tsn:${formatted})` + (kingdom ? `%20AND%20kingdom:${kingdom}&` : ''); - return this.ajax.request( - url, { - method: 'GET' - }).catch(error => { - if(isNotFoundError(error)) { - // handle 404 errors here - console.log(error); - this.flashMessages - .warning('No taxa object found.'); - return; - } + return this.ajax + .request(url, { + method: 'GET', + }) + .catch((error) => { + if (isNotFoundError(error)) { + // handle 404 errors here + console.log(error); + this.flashMessages.warning('No taxa object found.'); + return; + } - if(isForbiddenError(error)) { - // handle 403 errors here - console.log(error); - this.flashMessages - .danger('Access to ITIS web service was denied.'); - return; - } + if (isForbiddenError(error)) { + // handle 403 errors here + console.log(error); + this.flashMessages.danger('Access to ITIS web service was denied.'); + return; + } - if(isAjaxError(error)) { - // handle all other AjaxErrors here - console.log(error); - this.flashMessages - .danger('An error occured during the ITIS query request.'); - return; - } + if (isAjaxError(error)) { + // handle all other AjaxErrors here + console.log(error); + this.flashMessages.danger( + 'An error occured during the ITIS query request.' + ); + return; + } - // other errors are handled elsewhere - //throw error; - console.log(error); - this.flashMessages - .danger('An error occured during the ITIS query request.'); - }); + // other errors are handled elsewhere + //throw error; + console.log(error); + this.flashMessages.danger( + 'An error occured during the ITIS query request.' + ); + }); }, parseDoc(doc) { let { @@ -169,22 +186,35 @@ export default Service.extend({ rank, tsn, vernacular, - usage: status + usage: status, + taxonAuthor, + updateDate, } = doc; - const taxonomy = this.parseRanks(ranks, this.parseHierarchyTSN( - hierarchyTSN)); - const common = this.parseVernacular(vernacular); + const taxonomy = this.parseRanks( + ranks, + this.parseHierarchyTSN(hierarchyTSN) + ); + const common = this.parseVernacular(vernacular); - if(common) { - taxonomy.forEach(i => { + if (common) { + taxonomy.forEach((i) => { const taxa = i.findBy('tsn', tsn); - if(taxa) { + if (taxa) { set(taxa, 'common', common.mapBy('name')); } }); } + const formattedTaxonAuthor = taxonAuthor + ?.replace(/\(/g, '') + ?.replace(/\)/g, ''); + const classifier = formattedTaxonAuthor?.split(',')[0]; + const createdDate = formattedTaxonAuthor + ?.split(',')[1] + ?.replace(/^\s+/, ''); + const updatedDate = updateDate?.split(' ')[0]; + return Taxa.create({ kingdom: kingdom, name: name, @@ -192,14 +222,17 @@ export default Service.extend({ tsn: tsn, taxonomy: taxonomy, common: common, - status: status + status: status, + classifier: classifier, + createdDate: createdDate, + updatedDate: updatedDate, }); }, parseHierarchyTSN(tsn) { - return tsn.map(t => t.slice(1, t.length - 1).split('$')); + return tsn.map((t) => t.slice(1, t.length - 1).split('$')); }, parseVernacular(vernacular) { - if(!vernacular) { + if (!vernacular) { return null; } @@ -208,7 +241,7 @@ export default Service.extend({ return { name: v[0], - language: v[1] + language: v[1], }; }); }, @@ -227,23 +260,24 @@ export default Service.extend({ rank: rank[0], value: rank[1], order: idx, - tsn: tsnArray[idx] + tsn: tsnArray[idx], }; }); }); }, getBranch(taxon, branches) { - let branch = branches.filterBy('taxonomicLevel', taxon.rank).findBy( - 'taxonomicName', taxon.value); + let branch = branches + .filterBy('taxonomicLevel', taxon.rank) + .findBy('taxonomicName', taxon.value); - if(!branch) { + if (!branch) { return branches.pushObject({ - "taxonomicSystemId": taxon.tsn, - "taxonomicLevel": taxon.rank, - "taxonomicName": taxon.value, - "commonName": taxon.common, - "subClassification": [], - "isITIS": true + taxonomicSystemId: taxon.tsn, + taxonomicLevel: taxon.rank, + taxonomicName: taxon.value, + commonName: taxon.common, + subClassification: [], + isITIS: true, }); } @@ -254,11 +288,11 @@ export default Service.extend({ let branch = this.getBranch(taxon, tree); let sub = get(branch, 'subClassification'); - if(!sub) { + if (!sub) { set(branch, 'subClassification', []); } return get(branch, 'subClassification'); }, tree); - } + }, }); diff --git a/package.json b/package.json index ccd7b972e..a47e5046f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mdeditor", - "version": "1.5.0-beta.20", + "version": "1.5.0-beta.21", "description": "A web application for authoring and editing metadata.", "repository": { "type": "git",