-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBCAuthor.m
173 lines (138 loc) · 4.77 KB
/
BCAuthor.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//
// BCAuthor.m
// Caravan
//
// Created by Tom Houpt on 15/3/13.
// Copyright (c) 2015 Tom Houpt. All rights reserved.
//
#import "BCAuthor.h"
@implementation BCAuthor
@synthesize indexName;
@synthesize initials;
@synthesize orcid;
@synthesize contribution;
@synthesize position;
@synthesize prefix;
@synthesize fullName;
@synthesize degrees;
@synthesize informal;
@synthesize affiliation;
@synthesize address;
@synthesize phone;
@synthesize fax;
@synthesize email;
@synthesize website;
@synthesize hasBeenDeleted;
-(id)init; {
self = [super init];
if (self) {
indexName = @"Anonymous";
for (NSString *key in @[
kAuthorInitialsKey,
kAuthorOrcidKey,
kAuthorContributionKey,
kAuthorPositionKey,
kAuthorPrefixKey,
kAuthorFullNameKey,
kAuthorDegreesKey,
kAuthorInformalKey,
kAuthorAffiliationKey,
kAuthorAddressKey,
kAuthorPhoneKey,
kAuthorFaxKey,
kAuthorEmailKey,
kAuthorWebsiteKey
]) {
[self setValue:[NSString string] forKey:key];
}
}
return self;
}
-(NSDictionary *)packIntoDictionary; {
NSDictionary *theDictionary = [NSDictionary
dictionaryWithObjects:@[
indexName,
initials,
orcid,
contribution,
position,
prefix,
fullName,
degrees,
informal,
affiliation,
address,
phone,
fax,
email,
website
]
forKeys:@[
kAuthorIndexNameKey,
kAuthorInitialsKey,
kAuthorOrcidKey,
kAuthorContributionKey,
kAuthorPositionKey,
kAuthorPrefixKey,
kAuthorFullNameKey,
kAuthorDegreesKey,
kAuthorInformalKey,
kAuthorAffiliationKey,
kAuthorAddressKey,
kAuthorPhoneKey,
kAuthorFaxKey,
kAuthorEmailKey,
kAuthorWebsiteKey
]
];
return theDictionary;
}
-(void)unpackFromDictionary:(NSDictionary *)theDictionary; {
for (NSString *key in [theDictionary allKeys]) {
[self setValue:[theDictionary objectForKey:key] forKey:key];
}
}
-(NSString *)indexNameWithLeadingInitials; {
// NOTE: need to strip dots, insert spaces in initials
return [NSString stringWithFormat:@"%@ %@",
initials,indexName
];
}
-(NSString *)indexNameWithTrailingInitials; {
// NOTE: need to strip dots, insert spaces in initials
return [NSString stringWithFormat:@"%@ %@",
indexName, initials
];
}
-(NSString *)authorToken; {
return [self indexNameWithLeadingInitials];
}
-(NSString *)correspondenceString; {
NSMutableString *corr = [NSMutableString string];
[corr appendString:fullName];
[corr appendString:@", "];
if (0 < [address length]) {
[corr appendString:address];
}
else {
[corr appendString:[affiliation stringByReplacingOccurrencesOfString:@"," withString:@", "]];
}
[corr appendString:@". "];
if (0 < [phone length]) {
[corr appendString:@"Tel: "];
[corr appendString:phone];
[corr appendString:@". "];
}
if (0 < [fax length]) {
[corr appendString:@"Fax: "];
[corr appendString:fax];
[corr appendString:@". "];
}
if (0 < [email length]) {
[corr appendString:@"Email: "];
[corr appendString:email];
[corr appendString:@". "];
}
return corr;
}
@end