diff 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
line wrap: on
line diff
--- a/DVN-web/src/main/java/de/mpiwg/monographs/servlet/MonographUtils.java	Tue Mar 10 15:47:07 2015 +0100
+++ b/DVN-web/src/main/java/de/mpiwg/monographs/servlet/MonographUtils.java	Thu May 07 14:56:46 2015 +0200
@@ -7,12 +7,60 @@
 import edu.harvard.iq.dvn.core.admin.UserGroup;
 import edu.harvard.iq.dvn.core.admin.VDCUser;
 import edu.harvard.iq.dvn.core.study.FileMetadata;
+import edu.harvard.iq.dvn.core.study.Metadata;
 import edu.harvard.iq.dvn.core.study.Study;
 import edu.harvard.iq.dvn.core.study.StudyVersion;
 import edu.harvard.iq.dvn.core.vdc.VDCGroup;
+import edu.harvard.iq.dvn.core.web.study.StudyUI;
+import edu.harvard.iq.dvn.core.vdc.VDC;
 
 public class MonographUtils {
 	
+	public static JSONObject jsonStudyUI(StudyUI studyUI){
+		JSONObject json = null;
+		
+		if(studyUI != null){
+			try {
+				json = jsonStudy(studyUI.getStudy());
+				json.put("metadata", jsonMetadata(studyUI.getMetadata()));
+				
+				String status =
+						(studyUI.getStudy().getLatestVersion().isDraft()) ? 
+								"Draft" : 
+								((studyUI.getStudy().getLatestVersion().isInReview()) ? 
+										"In Review" :(studyUI.getStudy().getLatestVersion().isReleased()) ? 
+												"Released" : "Deaccessioned");
+				json.put("status", status);
+				
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+		return json;
+	}
+	
+	public static JSONObject jsonMetadata(Metadata meta){
+		JSONObject json = new JSONObject();
+		
+		try {
+			
+			json.put("accessToSources", meta.getAccessToSources());
+			json.put("actionsToMinimizeLoss", meta.getActionsToMinimizeLoss());
+			json.put("authorsStr", meta.getAuthorsStr());
+			json.put("availabilityStatus", meta.getAvailabilityStatus());
+			json.put("citationRequirements", meta.getCitationRequirements());
+			json.put("subTitle", meta.getSubTitle());
+			json.put("title", meta.getTitle());
+			
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		
+		
+		
+		return json;
+	}
+	
 	public static JSONObject jsonStudy(Study study){
 		JSONObject json = new JSONObject();
 		
@@ -26,8 +74,15 @@
 				json.put("protocol", study.getProtocol());
 				json.put("version", study.getVersion());
 				json.put("studyId", study.getStudyId());
+				json.put("createTime", study.getCreateTime());
 				json.put("numberOfDownloads", study.getNumberOfDownloads());
 				
+				JSONObject owner = jsonVDC(study.getOwner());
+				json.put("owner", owner);
+				
+				JSONObject creator = jsonVDCUser(study.getCreator());
+				json.put("creator", creator);
+				
 				JSONArray array0 = new JSONArray();
 				for(VDCUser user :  study.getAllowedUsers()){
 					array0.put(jsonVDCUser(user));
@@ -42,6 +97,27 @@
 		
 		return json;
 	}
+	
+	public static JSONObject jsonVDC(VDC vdc){
+		JSONObject json = new JSONObject();
+		
+		try {
+			
+			json.put("name", vdc.getName());
+			json.put("aboutThis", vdc.getAboutThisDataverse());
+			json.put("visibility", vdc.getVisibility());
+			json.put("version", vdc.getVersion());
+			json.put("parentSite", vdc.getParentSite());
+			json.put("logo", vdc.getLogo());
+			json.put("header", vdc.getHeader());
+			json.put("alias", vdc.getAlias());
+			
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		
+		return json;
+	}
 
 	public static JSONObject jsonVDCUser(VDCUser user){
 		JSONObject json = new JSONObject();