Mercurial > hg > LGDataverses
comparison DVN-web/src/main/java/de/mpiwg/monographs/servlet/MonographUtils.java @ 4:9b408c9b05ab
Integration with LGServices.
author | "jurzua <jurzua@mpiwg-berlin.mpg.de>" |
---|---|
date | Thu, 07 May 2015 14:56:46 +0200 |
parents | 2ae72563a29d |
children |
comparison
equal
deleted
inserted
replaced
3:65774fc878b7 | 4:9b408c9b05ab |
---|---|
5 import org.swordapp.server.SwordServerException; | 5 import org.swordapp.server.SwordServerException; |
6 | 6 |
7 import edu.harvard.iq.dvn.core.admin.UserGroup; | 7 import edu.harvard.iq.dvn.core.admin.UserGroup; |
8 import edu.harvard.iq.dvn.core.admin.VDCUser; | 8 import edu.harvard.iq.dvn.core.admin.VDCUser; |
9 import edu.harvard.iq.dvn.core.study.FileMetadata; | 9 import edu.harvard.iq.dvn.core.study.FileMetadata; |
10 import edu.harvard.iq.dvn.core.study.Metadata; | |
10 import edu.harvard.iq.dvn.core.study.Study; | 11 import edu.harvard.iq.dvn.core.study.Study; |
11 import edu.harvard.iq.dvn.core.study.StudyVersion; | 12 import edu.harvard.iq.dvn.core.study.StudyVersion; |
12 import edu.harvard.iq.dvn.core.vdc.VDCGroup; | 13 import edu.harvard.iq.dvn.core.vdc.VDCGroup; |
14 import edu.harvard.iq.dvn.core.web.study.StudyUI; | |
15 import edu.harvard.iq.dvn.core.vdc.VDC; | |
13 | 16 |
14 public class MonographUtils { | 17 public class MonographUtils { |
18 | |
19 public static JSONObject jsonStudyUI(StudyUI studyUI){ | |
20 JSONObject json = null; | |
21 | |
22 if(studyUI != null){ | |
23 try { | |
24 json = jsonStudy(studyUI.getStudy()); | |
25 json.put("metadata", jsonMetadata(studyUI.getMetadata())); | |
26 | |
27 String status = | |
28 (studyUI.getStudy().getLatestVersion().isDraft()) ? | |
29 "Draft" : | |
30 ((studyUI.getStudy().getLatestVersion().isInReview()) ? | |
31 "In Review" :(studyUI.getStudy().getLatestVersion().isReleased()) ? | |
32 "Released" : "Deaccessioned"); | |
33 json.put("status", status); | |
34 | |
35 } catch (Exception e) { | |
36 e.printStackTrace(); | |
37 } | |
38 } | |
39 return json; | |
40 } | |
41 | |
42 public static JSONObject jsonMetadata(Metadata meta){ | |
43 JSONObject json = new JSONObject(); | |
44 | |
45 try { | |
46 | |
47 json.put("accessToSources", meta.getAccessToSources()); | |
48 json.put("actionsToMinimizeLoss", meta.getActionsToMinimizeLoss()); | |
49 json.put("authorsStr", meta.getAuthorsStr()); | |
50 json.put("availabilityStatus", meta.getAvailabilityStatus()); | |
51 json.put("citationRequirements", meta.getCitationRequirements()); | |
52 json.put("subTitle", meta.getSubTitle()); | |
53 json.put("title", meta.getTitle()); | |
54 | |
55 } catch (Exception e) { | |
56 e.printStackTrace(); | |
57 } | |
58 | |
59 | |
60 | |
61 return json; | |
62 } | |
15 | 63 |
16 public static JSONObject jsonStudy(Study study){ | 64 public static JSONObject jsonStudy(Study study){ |
17 JSONObject json = new JSONObject(); | 65 JSONObject json = new JSONObject(); |
18 | 66 |
19 if(study != null){ | 67 if(study != null){ |
24 json.put("harvestIdentifier", study.getHarvestIdentifier()); | 72 json.put("harvestIdentifier", study.getHarvestIdentifier()); |
25 json.put("persistentURL", study.getPersistentURL()); | 73 json.put("persistentURL", study.getPersistentURL()); |
26 json.put("protocol", study.getProtocol()); | 74 json.put("protocol", study.getProtocol()); |
27 json.put("version", study.getVersion()); | 75 json.put("version", study.getVersion()); |
28 json.put("studyId", study.getStudyId()); | 76 json.put("studyId", study.getStudyId()); |
77 json.put("createTime", study.getCreateTime()); | |
29 json.put("numberOfDownloads", study.getNumberOfDownloads()); | 78 json.put("numberOfDownloads", study.getNumberOfDownloads()); |
79 | |
80 JSONObject owner = jsonVDC(study.getOwner()); | |
81 json.put("owner", owner); | |
82 | |
83 JSONObject creator = jsonVDCUser(study.getCreator()); | |
84 json.put("creator", creator); | |
30 | 85 |
31 JSONArray array0 = new JSONArray(); | 86 JSONArray array0 = new JSONArray(); |
32 for(VDCUser user : study.getAllowedUsers()){ | 87 for(VDCUser user : study.getAllowedUsers()){ |
33 array0.put(jsonVDCUser(user)); | 88 array0.put(jsonVDCUser(user)); |
34 } | 89 } |
36 | 91 |
37 | 92 |
38 } catch (Exception e) { | 93 } catch (Exception e) { |
39 e.printStackTrace(); | 94 e.printStackTrace(); |
40 } | 95 } |
96 } | |
97 | |
98 return json; | |
99 } | |
100 | |
101 public static JSONObject jsonVDC(VDC vdc){ | |
102 JSONObject json = new JSONObject(); | |
103 | |
104 try { | |
105 | |
106 json.put("name", vdc.getName()); | |
107 json.put("aboutThis", vdc.getAboutThisDataverse()); | |
108 json.put("visibility", vdc.getVisibility()); | |
109 json.put("version", vdc.getVersion()); | |
110 json.put("parentSite", vdc.getParentSite()); | |
111 json.put("logo", vdc.getLogo()); | |
112 json.put("header", vdc.getHeader()); | |
113 json.put("alias", vdc.getAlias()); | |
114 | |
115 } catch (Exception e) { | |
116 e.printStackTrace(); | |
41 } | 117 } |
42 | 118 |
43 return json; | 119 return json; |
44 } | 120 } |
45 | 121 |