Example #1
0
            .then(function (myRemoteItemData) {
                if ((myRemoteItemData.error &&
                    myRemoteItemData.statusCode === 200) ||
                    myRemoteItemData.statusCode === 404) {

                    console.log(myRemoteItemData.statusCode, 'adding to post queue', localItem.name);

                    //if the doesn't exist post for first time
                    queues.postQueue.push(localItemPackage);

                } else if (!myRemoteItemData.error && myRemoteItemData.statusCode === 200) {
                    //so we should compare for deference before putting
                    console.log('Get Successful.. 200, comparing', localItem.name);

                    var remoteItemPackage = jxon.stringToJs(_.unescape(myRemoteItemData.body));

                    var putPackage = getDifferences(localItemPackage, remoteItemPackage);

                    if (putPackage) {
                        queues.putQueue.push(putPackage);
                    }
                } else if (myRemoteItemData.statusCode === 302) {
                    console.log('Get.. 302 ', myRemoteItemData.body);
                } else {
                    console.log('get default', myRemoteItemData.statusCode, localItem.name);
                    //console.log('got data, ',  jxon.stringToJs(_.unescape(myRemoteItemData.body)));
                }

            }).fail(function (e) {
Example #2
0
 .then(function(r) {
     output(r);
     if (r.error) {
         throw new Error('Rest API Error: ' + r.statusInfo);
     }
     var body = jxon.stringToJs(_.unescape(r.body)).import;
     if (body.level === 'ERROR') throw new Error(body.message);
     name = model.getName() + ' v' + model.getProperty('version');
     ok(r, name);
 });
Example #3
0
			fs.readFile(xmlFileName, 'utf8', function (err, xmlData) {
  			if (!err) {
					console.log('\n\n\n\jxon Test - XML ==> JSON');
					console.log('\n\n\n\XML');
  				console.log(xmlData);
					var output = jxon.stringToJs(xmlData);
					console.log('\n\n\n\Transformed JSON');
					console.log(JSON.stringify(output));
				}
				done();
			});
Example #4
0
 getFiles(_cliOpts.search || path.join(process.cwd(), '*.xml')).forEach(function (item) {
     aJXON.push(jxon.stringToJs(item));
 });
Example #5
0
		ncbi_engine.register('success', function(resp, man){
		    
		    var xml = resp.raw();
		    //console.log(xml);

		    var jx = null;
		    if( typeof xml === 'string' ){
			jx = jxon.stringToJs(xml);
		    }else{
			jx = jxon.xmlToJs(xml);
		    }
		    console.log(jx);

		    // Our operating object.
		    if( ! jx.PubmedArticleSet.PubmedArticle ){
			UnableToMakeContact('<b>No such PubMed ID</b>.');
		    }else if( ! jx.PubmedArticleSet.PubmedArticle.MedlineCitation.Article ){
			UnableToMakeContact('<b>No such Article</b>.');
		    }else{
			var op = jx.PubmedArticleSet.PubmedArticle.MedlineCitation.Article;

			// Title.
			var title = 'n/a';
			if( op.ArticleTitle ){
			    title = op.ArticleTitle;
			}

			// Date.
			var date = 'n/a';
			if( op.ArticleDate ){
			    var year = op.ArticleDate.Year || '???';
			    var month = op.ArticleDate.Month || '???';
			    var day = op.ArticleDate.Day || '???';
			    date = [year, month, day].join('-');
			}

			// Authors.
			var authors = 'n/a';
			if( op.AuthorList &&  op.AuthorList.Author ){
			    
			    var acache = [];
			    us.each(op.AuthorList.Author, function(auth){
				var name = '';
				if( auth.ForeName ){ name += auth.ForeName; }
				//if( auth.Initials ){ name+=' '+auth.Initials+'.'; }
				if( auth.LastName ){ name +=' '+auth.LastName; }
				acache.push(name);
			    });
			    if( ! us.isEmpty(acache) ){
				authors = acache.join(', ');
			    }
			}
			
			// Abstract; list or string.
			var abstract = 'n/a';
			if( op.Abstract && op.Abstract.AbstractText ){
			    if( us.isArray(op.Abstract.AbstractText) ){
			    
				var abscache = [];
				us.each(op.Abstract.AbstractText, function(abs){
				    if( abs._ ){ abscache.push(abs._); }
				});
				if( ! us.isEmpty(abscache) ){
				    abstract = abscache.join('<br />');
				}
			    }else if( us.isString(op.Abstract.AbstractText) ){
				abstract = op.Abstract.AbstractText;
			    }
			}
				
			// Render.
			jQuery('#info-area').empty();
			var info = [
			    '<dl class="dl-horizontal amigo-detail-info">',
			    // Title.
			    '<dt>Title</dt>',
			    '<dd>',
			    title,
			    '</dd>',
			    // Date.
			    '<dt>Date</dt>',
			    '<dd>',
			    date,
			    '</dd>',
			    // Author.
			    '<dt>Author(s)</dt>',
			    '<dd>',
			    authors,
			    '</dd>',
			    // Abstract.
			    '<dt>Abstract</dt>',
			    '<dd id="abstract">',
			    abstract,
			    '</dd>',
			    // 		// Related.
			    // 		'<dt id="prob_related" class="hidden">Related</dt>',
			    // 		'<dd id="prob_ann" class="hidden">',
			    // 		'<a id="prob_ann_href" href="#" class="btn btn-primary btn-xs">Link</a> to all direct and indirect <strong>annotations</strong> to ' + global_acc + '.',
			    // 		'</dd>',
			    // 		'<dd id="prob_ann_dl" class="hidden">',
			    // '<a id="prob_ann_dl_href" href="#" class="btn btn-primary btn-xs">Link</a> to all direct and indirect <strong>annotations download</strong> (limited to first 10,000) for ' + global_acc + '.',
			    // 		'</dd>',
			    // Pubmed.
			    '<dt>PubMed</dt>',
			    '<dd>',
			    '<a href="https://www.ncbi.nlm.nih.gov/pubmed/' + bbop.first_split(':', global_acc)[1] + '">' + global_acc + '</a>',
			    '</dd>',
			    // // Feedback.
			    // '<dt>Feedback</dt>',
			    // '<dd>',
			    // 'Contact the <a href="http://geneontology.org/form/contact-go" title="GO Helpdesk.">GO Helpdesk</a> if you find mistakes or have concerns about the data you find here.',
			    // '</dd>',
			    '</dl>'
			];
			jQuery('#info-area').append(info.join(' '));
			_shrink_wrap('abstract');

			// Powered by NCBI.
			jQuery('#info-area').append([
			    '<p>',
			    'Powered by NCBI\'s <a href="https://eutils.ncbi.nlm.nih.gov">E-utilities</a>.',
			    '<br />',
			    'Please read NCBI\'s <a href="https://www.ncbi.nlm.nih.gov/home/about/policies.shtml">Disclaimer and Copyright notice.',
			    '</p>',
			].join(' '));
			
			// Get feedback from viewers.
			jQuery('#info-area').append([
			    '<p>',
			    '<span class="glyphicon glyphicon-pencil"></span><b>Are you the author</b> (or have a deep understanding) of this paper? If so, <b>do these annotations look okay to you</b>? <a href="http://geneontology.org/form/contact-go">Let us know</a>!',
			    '</p>'
			].join(' '));
			
			
			
			// Start the normal GOlr services.
			ReferenceDetailsInit();
		    }		    

		});