Revision 54556
Added by Miriam Baglioni over 5 years ago
CommunityMappingUtils.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.openaire.community; |
2 | 2 |
|
3 |
import java.text.ParseException; |
|
3 | 4 |
import java.util.Arrays; |
4 | 5 |
import java.util.List; |
5 | 6 |
import java.util.Map; |
... | ... | |
9 | 10 |
|
10 | 11 |
import com.google.common.escape.Escaper; |
11 | 12 |
import com.google.common.xml.XmlEscapers; |
12 |
import eu.dnetlib.openaire.common.ISClientImpl; |
|
13 | 13 |
import eu.dnetlib.openaire.context.Concept; |
14 | 14 |
import eu.dnetlib.openaire.context.Context; |
15 | 15 |
import eu.dnetlib.openaire.context.Param; |
... | ... | |
21 | 21 |
import static eu.dnetlib.openaire.community.CommunityConstants.*; |
22 | 22 |
|
23 | 23 |
public class CommunityMappingUtils { |
24 |
private final static String pattern = "yyyy-MM-dd'T'hh:mm:ss"; |
|
24 | 25 |
private static final Log log = LogFactory.getLog(CommunityMappingUtils.class); |
25 | 26 |
public static CommunitySummary asCommunitySummary(final Context c) { |
26 | 27 |
final CommunitySummary summary = new CommunitySummary(); |
... | ... | |
50 | 51 |
summary.setZenodoCommunity(asCsv(params.get(CSUMMARY_ZENODOC))); |
51 | 52 |
} |
52 | 53 |
|
54 |
|
|
53 | 55 |
return summary; |
54 | 56 |
} |
55 | 57 |
|
56 |
public static CommunityDetails asCommunityProfile(final Context c) { |
|
58 |
public static CommunityDetails asCommunityProfile(final Context c) {
|
|
57 | 59 |
|
58 | 60 |
final CommunityDetails p = new CommunityDetails(asCommunitySummary(c)); |
59 |
p.setCreationDate(c.getDateofcreation());
|
|
61 |
p.setLastUpdateDate(c.getLastUpdateDate());
|
|
60 | 62 |
final Map<String, List<Param>> params = c.getParams(); |
61 | 63 |
if (params.containsKey(CPROFILE_SUBJECT)) { |
62 | 64 |
p.setSubjects(splitValues(asValues(params.get(CPROFILE_SUBJECT)), CSV_DELIMITER)); |
63 | 65 |
} |
66 |
if (params.containsKey(CPROFILE_CREATIONDATE)){ |
|
67 |
try { |
|
68 |
p.setCreationDate(org.apache.commons.lang3.time.DateUtils.parseDate(asCsv(params.get(CPROFILE_CREATIONDATE)), pattern)); |
|
69 |
}catch(ParseException e) { |
|
70 |
e.printStackTrace(); |
|
71 |
} |
|
72 |
} |
|
64 | 73 |
|
65 | 74 |
return p; |
66 | 75 |
} |
Also available in: Unified diff
refactoring and addition of lastupdatedate field in the json.
the value for the field creationDate of the json is found in the context parameter with name creationdate