Permalink
Browse files

Add Altmetric J identifier, ISSNs, and quotes properties

  • Loading branch information...
1 parent 4673464 commit f30c4fd93d6041846591610bdd7acee89ac1549e @vtourraine vtourraine committed Apr 11, 2013
@@ -25,5 +25,8 @@
@end
-@interface SZNArrayToStringTransformer: NSValueTransformer
+@interface SZNArrayToStringWithCommaTransformer: NSValueTransformer
+@end
+
+@interface SZNArrayToStringWithLineBreakTransformer: NSValueTransformer
@end
@@ -43,7 +43,7 @@ - (IBAction)openDetailsURL:(id)sender
@end
-@implementation SZNArrayToStringTransformer
+@implementation SZNArrayToStringWithCommaTransformer
+ (Class)transformedValueClass
{
@@ -60,4 +60,23 @@ - (id)transformedValue:(id)value
return (value == nil) ? nil : [(NSArray *)value componentsJoinedByString:@", "];
}
+@end
+
+@implementation SZNArrayToStringWithLineBreakTransformer
+
++ (Class)transformedValueClass
+{
+ return [NSArray class];
+}
+
++ (BOOL)allowsReverseTransformation
+{
+ return NO;
+}
+
+- (id)transformedValue:(id)value
+{
+ return (value == nil) ? nil : [(NSArray *)value componentsJoinedByString:@"\n"];
+}
+
@end

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -23,6 +23,7 @@ - (void)testArticleFromRespondeDictionary
STAssertEqualObjects(article.addedOn, [NSDate dateWithTimeIntervalSince1970:1324491937], @"Added on not extracted");
STAssertEqualObjects(article.identifier, @"502878", @"Identifier not extracted");
+ STAssertEqualObjects(article.altmetricJIdentifier, @"4f6fa62f3cf058f6100082d3", @"J Identifier not extracted");
STAssertEqualObjects(article.ADSBibcode, @"2011natur.480..426v", @"ADS not extracted");
STAssertEqualObjects(article.citedByAccountsCount, @(393), @"Cited by accounts not extracted");
STAssertEqualObjects(article.citedByFacebookWallsCount, @(12), @"Cited by Facebook walls not extracted");
@@ -39,6 +40,10 @@ - (void)testArticleFromRespondeDictionary
STAssertEqualObjects(article.score, @(353.626), @"Score not extracted");
STAssertEqualObjects(article.subjects, @[@"science"], @"Subjects not extracteds");
STAssertEqualObjects(article.scopusSubjects, @[], @"Scopus subjects not extracteds");
+ NSArray *quotes = @[@"Take a look...", @"Third...", @"Nature..."];
+ STAssertEqualObjects(article.quotes, quotes, @"Quotes not extracteds");
+ NSArray *ISSNs = @[@"0028-0836", @"1744-7933"];
+ STAssertEqualObjects(article.ISSNs, ISSNs, @"ISSNs not extracteds");
STAssertEqualObjects(article.imageSmallURL.absoluteString, @"http://fastly.altmetric.com/?size=64&score=354&types=bfgttttt", @"Image small URL not extracted");
STAssertEqualObjects(article.imageMediumURL.absoluteString, @"http://fastly.altmetric.com/?size=100&score=354&types=bfgttttt", @"Image medium URL not extracted");
STAssertEqualObjects(article.imageLargeURL.absoluteString, @"http://fastly.altmetric.com/?size=180&score=354&types=bfgttttt", @"Image large URL not extracted");
@@ -4,10 +4,9 @@
"pmid":"22193080",
"nlmid":"0410462",
"tq":[
- "Take a look back at the year in science with our review of the biggest stories of 2011",
- "Third: Our round-up of the year in research and science policy +interactive timeline",
- "Nature's 'year in science' review is really rather essential @NatureNews",
- "Scientific Paper Trail 2011 #HigherEd"],
+ "Take a look...",
+ "Third...",
+ "Nature..."],
"ads_id":"2011natur.480..426v",
"arxiv_id": "arXiv-123",
"altmetric_jid":"4f6fa62f3cf058f6100082d3",
@@ -35,6 +35,11 @@
@property (copy, nonatomic) NSString *identifier;
/**
+ The Altmetric J Identifier of the article.
+ */
+@property (copy, nonatomic) NSString *altmetricJIdentifier;
+
+/**
The title of the article.
*/
@property (copy, nonatomic) NSString *title;
@@ -100,6 +105,11 @@
@property (strong, nonatomic) NSNumber *score;
/**
+ The ISSNs of the article.
+ */
+@property (strong, nonatomic) NSArray *ISSNs;
+
+/**
The Altmetric image URL of the article (large).
*/
@property (strong, nonatomic) NSURL *imageLargeURL;
@@ -160,6 +170,11 @@
@property (strong, nonatomic) NSArray *scopusSubjects;
/**
+ The quotes of the article.
+ */
+@property (strong, nonatomic) NSArray *quotes;
+
+/**
The readers count of the article.
*/
@property (strong, nonatomic) NSNumber *readersCount;
@@ -30,6 +30,7 @@ + (SZNAltmetricArticle *)articleWithAPIResponseObject:(id)responseObject
SZNAltmetricArticle *article = [SZNAltmetricArticle new];
article.addedOn = [NSDate dateWithTimeIntervalSince1970:[responseObject[@"added_on"] doubleValue]];
article.identifier = [NSString stringWithFormat:@"%@", responseObject[@"altmetric_id"]];
+ article.altmetricJIdentifier = [NSString stringWithFormat:@"%@", responseObject[@"altmetric_jid"]];
article.ADSBibcode = responseObject[@"ads_id"];
article.citedByAccountsCount = responseObject[@"cited_by_accounts_count"];
article.citedByFacebookWallsCount = responseObject[@"cited_by_fbwalls_count"];
@@ -46,6 +47,8 @@ + (SZNAltmetricArticle *)articleWithAPIResponseObject:(id)responseObject
article.score = responseObject[@"score"];
article.subjects = responseObject[@"subjects"];
article.scopusSubjects = responseObject[@"scopus_subjects"];
+ article.quotes = responseObject[@"tq"];
+ article.ISSNs = responseObject[@"issns"];
article.imageLargeURL = [NSURL URLWithString:responseObject[@"images"][@"large"]];
article.imageMediumURL = [NSURL URLWithString:responseObject[@"images"][@"medium"]];
article.imageSmallURL = [NSURL URLWithString:responseObject[@"images"][@"small"]];

0 comments on commit f30c4fd

Please sign in to comment.