All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.fd.fp.model.DraftMetadata Maven / Gradle / Ivy

/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
*  Copyright 2014 Adobe Systems Incorporated
*  All Rights Reserved.
*
* NOTICE:  All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any.  The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
package com.adobe.fd.fp.model;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;

import com.adobe.fd.fp.util.FormsPortalConstants;

public class DraftMetadata implements Serializable, Comparable{

	/**
	 * Serial Version UID
	 */
	private static final long serialVersionUID = 7192358939630523884L;
	
	public static final String GUIDE_NAME = "guideName";

	public static final String FORM_NAME = "formName";
	
	public static final String OWNER = "owner";
	
	public static final String LAST_MODIFIED = "lastModified";
	
	public static final String PATH = "path";
	
	public static final String DESCRIPTION = "description";
	
	public static final String DRAFT_ID = "draftID";
	
	public static final String USER_DATA_ID = "userdataID";
	

	/**
	 * Name of the guide.
	 */
	private String name;
	
	/**
	 * owner of this draft
	 */
	private String owner;
	
	/**
	 * Date and time when the draft was last modified
	 */
	private Date lastModified;
	
	/**
	 * Path to the draft in repository
	 */
	private String path;
	
	/**
	 * Description of the draft. 
	 */
	private String description;
	/**
	 * Reference ID of the draft
	 */
	private String draftID;
	
	
	/**
	 * Reference ID for draft user data
	 */
	private String userdataID;
	
	/**
	 * custom properties of draft (support for cutpoints)
	 */
	private Map customProperty;
	
	public DraftMetadata() {
		super();
	}

	/**
	 * @return the guideName
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the guideName to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the owner
	 */
	public String getOwner() {
		return owner;
	}

	/**
	 * @param owner the owner to set
	 */
	public void setOwner(String owner) {
		this.owner = owner;
	}

	/**
	 * @return the lastModified
	 */
	public Date getLastModified() {
		return lastModified;
	}

	/**
	 * @param lastModified the lastModified to set
	 */
	public void setLastModified(Date lastModified) {
		this.lastModified = lastModified;
	}

	/**
	 * @return the path
	 */
	public String getPath() {
		return path;
	}

	/**
	 * @param path the path to set
	 */
	public void setPath(String path) {
		this.path = path;
	}
	
	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}
	/**
	 * @return the refID
	 */
	public String getDraftID() {
		return draftID;
	}
	/**
	 * @param refID the refID to set
	 */
	public void setDraftID(String draftID) {
		this.draftID = draftID;
	}
	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	@Override
	public int compareTo(DraftMetadata that) {
			return this.lastModified.compareTo(that.getLastModified());
	}
	
	public String getUserdataID() {
		return userdataID;
	}

	public void setUserdataID(String userdataID) {
		this.userdataID = userdataID;
	}
	
	public void setCustomProperty(String propertyName, String propertyValue){
		if(this.customProperty == null){
			this.customProperty = new HashMap();
		}
		this.customProperty.put(propertyName, propertyValue);
	}
	
	public Map getCustomProperty(){
		return customProperty;
	}
		
	public JSONObject getJSONObject () throws JSONException {
		JSONObject jsonObject = new JSONObject();
		jsonObject.put(FORM_NAME, getName());
		jsonObject.put(OWNER, getOwner());
		jsonObject.put(FormsPortalConstants.STR_JCR_LAST_MODIFIED, getLastModified().getTime());
		jsonObject.put(PATH, getPath());
		jsonObject.put(DESCRIPTION, getDescription());
		jsonObject.put(DRAFT_ID, getDraftID());
		Map customPropertyObject = getCustomProperty();
		if(customPropertyObject != null){
			Iterator> entries = customPropertyObject.entrySet().iterator();
			while (entries.hasNext()) {
			    Map.Entry entry = entries.next();
			    if(!jsonObject.has(entry.getKey())){
			    	jsonObject.put(entry.getKey(), entry.getValue()!=null?entry.getValue():"");
			    }
			    if(entry.getKey().equals(GUIDE_NAME)){
			    	jsonObject.put(GUIDE_NAME, getName());
			    }
			}	
		}
		return jsonObject;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy