fluid-api/src/main/java/com/fluidbpm/program/api/vo/form/Form.java
@Override
	@XmlTransient
	public JSONObject toJsonForElasticSearch() throws JSONException {

		JSONObject returnVal = super.toJsonObject();

		//Form Type...
		if(this.getFormType() != null)
		{
			returnVal.put(JSONMapping.FORM_TYPE, this.getFormType());
		}

		//Form Type Id...
		if(this.getFormTypeId() != null)
		{
			returnVal.put(JSONMapping.FORM_TYPE_ID, this.getFormTypeId());
		}

		//Title...
		if(this.getTitle() != null)
		{
			returnVal.put(JSONMapping.TITLE, this.getTitle());
		}

		//Form Description...
		if(this.getFormDescription() != null)
		{
			returnVal.put(JSONMapping.FORM_DESCRIPTION, this.getFormDescription());
		}

		//State...
		if(this.getState() != null)
		{
			returnVal.put(JSONMapping.STATE, this.getState());
		}

		//Flow State...
		if(this.getFlowState() != null)
		{
			returnVal.put(JSONMapping.FLOW_STATE, this.getFlowState());
		}

		//Current User...
		JSONObject currentUserJsonObj = new JSONObject();

		if(this.getCurrentUser() == null) {
			currentUserJsonObj.put(
					User.JSONMapping.Elastic.USER_ID, JSONObject.NULL);
			currentUserJsonObj.put(User.JSONMapping.USERNAME, JSONObject.NULL);
		} else{

			//Id...
			if(this.getCurrentUser().getId() == null ||
					this.getCurrentUser().getId().longValue() < 1)
			{
				currentUserJsonObj.put(
						User.JSONMapping.Elastic.USER_ID,
						JSONObject.NULL);
			} else{
				currentUserJsonObj.put(
						User.JSONMapping.Elastic.USER_ID,
						this.getCurrentUser().getId());
			}

			//Username...
			if(this.getCurrentUser().getUsername() == null ||
					this.getCurrentUser().getUsername().trim().isEmpty())
			{
				currentUserJsonObj.put(User.JSONMapping.USERNAME,
						JSONObject.NULL);
			} else {
				currentUserJsonObj.put(User.JSONMapping.USERNAME,
						this.getCurrentUser().getUsername());
			}
		}

		returnVal.put(JSONMapping.CURRENT_USER, currentUserJsonObj);

		//Date Created...
		if(this.getDateCreated() != null)
		{
			returnVal.put(JSONMapping.DATE_CREATED,
					this.getDateAsLongFromJson(this.getDateCreated()));
		}

		//Date Last Updated...
		if(this.getDateLastUpdated() != null)
		{
			returnVal.put(JSONMapping.DATE_LAST_UPDATED,
					this.getDateAsLongFromJson(this.getDateLastUpdated()));
		}

		//Form Fields...
		if(this.getFormFields() != null && !this.getFormFields().isEmpty())
		{
			for(Field toAdd : this.getFormFields())
			{
				JSONObject convertedFieldObj = toAdd.toJsonForElasticSearch();
				if(convertedFieldObj == null)
				{
					continue;
				}

				Iterator<String> iterKeys = convertedFieldObj.keys();
				while(iterKeys.hasNext())
				{
					String key = iterKeys.next();
					returnVal.put(key, convertedFieldObj.get(key));
				}
			}
		}

		//Ancestor...
		Long ancestorIdLcl = this.getAncestorId();
		if(ancestorIdLcl != null)
		{
			returnVal.put(JSONMapping.ANCESTOR_ID, ancestorIdLcl);
		}

		//Table Field Parent Id...
		if(this.getTableFieldParentId() != null)
		{
			returnVal.put(JSONMapping.TABLE_FIELD_PARENT_ID,
					this.getTableFieldParentId());
		}

		//Descendant Ids...
		if(this.getDescendantIds() != null && !this.getDescendantIds().isEmpty())
		{
			JSONArray array = new JSONArray();

			for(Long formId : this.getDescendantIds())
			{
				array.put(formId);
			}

			returnVal.put(JSONMapping.DESCENDANT_IDS, array);
		}

		return returnVal;
	}
@Override
	@XmlTransient
	public JSONObject toJsonForElasticSearch() throws JSONException {

		JSONObject returnVal = super.toJsonObject();

		//Form Type...
		if(this.getFormType() != null)
		{
			returnVal.put(JSONMapping.FORM_TYPE, this.getFormType());
		}

		//Form Type Id...
		if(this.getFormTypeId() != null)
		{
			returnVal.put(JSONMapping.FORM_TYPE_ID, this.getFormTypeId());
		}

		//Title...
		if(this.getTitle() != null)
		{
			returnVal.put(JSONMapping.TITLE, this.getTitle());
		}

		//Form Description...
		if(this.getFormDescription() != null)
		{
			returnVal.put(JSONMapping.FORM_DESCRIPTION, this.getFormDescription());
		}

		//State...
		if(this.getState() != null)
		{
			returnVal.put(JSONMapping.STATE, this.getState());
		}

		//Flow State...
		if(this.getFlowState() != null)
		{
			returnVal.put(JSONMapping.FLOW_STATE, this.getFlowState());
		}

		//Current User...
		JSONObject currentUserJsonObj = new JSONObject();

		if(this.getCurrentUser() == null) {
			currentUserJsonObj.put(
					User.JSONMapping.Elastic.USER_ID, JSONObject.NULL);
			currentUserJsonObj.put(User.JSONMapping.USERNAME, JSONObject.NULL);
		} else{

			//Id...
			if(this.getCurrentUser().getId() == null ||
					this.getCurrentUser().getId().longValue() < 1)
			{
				currentUserJsonObj.put(
						User.JSONMapping.Elastic.USER_ID,
						JSONObject.NULL);
			} else{
				currentUserJsonObj.put(
						User.JSONMapping.Elastic.USER_ID,
						this.getCurrentUser().getId());
			}

			//Username...
			if(this.getCurrentUser().getUsername() == null ||
					this.getCurrentUser().getUsername().trim().isEmpty())
			{
				currentUserJsonObj.put(User.JSONMapping.USERNAME,
						JSONObject.NULL);
			} else {
				currentUserJsonObj.put(User.JSONMapping.USERNAME,
						this.getCurrentUser().getUsername());
			}
		}

		returnVal.put(JSONMapping.CURRENT_USER, currentUserJsonObj);

		//Date Created...
		if(this.getDateCreated() != null)
		{
			returnVal.put(JSONMapping.DATE_CREATED,
					this.getDateAsLongFromJson(this.getDateCreated()));
		}

		//Date Last Updated...
		if(this.getDateLastUpdated() != null)
		{
			returnVal.put(JSONMapping.DATE_LAST_UPDATED,
					this.getDateAsLongFromJson(this.getDateLastUpdated()));
		}

		//Form Fields...
		if(this.getFormFields() != null && !this.getFormFields().isEmpty())
		{
			for(Field toAdd : this.getFormFields())
			{
				JSONObject convertedFieldObj = toAdd.toJsonForElasticSearch();
				if(convertedFieldObj == null)
				{
					continue;
				}

				Iterator<String> iterKeys = convertedFieldObj.keys();
				while(iterKeys.hasNext())
				{
					String key = iterKeys.next();
					returnVal.put(key, convertedFieldObj.get(key));
				}
			}
		}

		//Ancestor...
		Long ancestorIdLcl = this.getAncestorId();
		if(ancestorIdLcl != null)
		{
			returnVal.put(JSONMapping.ANCESTOR_ID, ancestorIdLcl);
		}

		//Table Field Parent Id...
		if(this.getTableFieldParentId() != null)
		{
			returnVal.put(JSONMapping.TABLE_FIELD_PARENT_ID,
					this.getTableFieldParentId());
		}

		//Descendant Ids...
		if(this.getDescendantIds() != null && !this.getDescendantIds().isEmpty())
		{
			JSONArray array = new JSONArray();

			for(Long formId : this.getDescendantIds())
			{
				array.put(formId);
			}

			returnVal.put(JSONMapping.DESCENDANT_IDS, array);
		}

		return returnVal;
	}
Conversion to {@code JSONObject} for storage in ElasticCache for {@code Form}.

@return {@code JSONObject} representation of {@code Form}
@throws JSONException If there is a problem with the JSON Body.

@see ABaseFluidJSONObject#toJsonObject()
@see Form