tidy up code, add java docs

This commit is contained in:
Rodica Sutu
2016-11-28 14:34:58 +02:00
parent 866568c806
commit 42dac04cd2
9 changed files with 87 additions and 17 deletions

View File

@@ -38,6 +38,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
* POJO for file plan component
*
* @author Tuna Aksoy
* @author Rodica Sutu
* @since 2.6
*/
public class FilePlanComponent
@@ -94,6 +95,13 @@ public class FilePlanComponent
@JsonProperty (required = true)
private FilePlanComponentUserInfo modifiedByUser;
/**Helper constructor for creating the file plan component using
*
* @param name File Plan Component name
* @param nodeType File Plan Component node type
* @param properties File Plan Component properties
*/
public FilePlanComponent(String name, String nodeType, FilePlanComponentProperties properties)
{
this.name = name;
@@ -101,14 +109,27 @@ public class FilePlanComponent
this.properties = properties;
}
public FilePlanComponent()
{
}
/**
* Helper constructor to create empty file plan component
*/
public FilePlanComponent() { }
/**
* Helper constructor for creating the file plan component using
*
* @param name File Plan Component name
*/
public FilePlanComponent(String name)
{
this.name = name;
}
/**
* Helper constructor for creating the file plan component using
*
* @param name File Plan Component name
* @param properties File Plan Component properties
*/
public FilePlanComponent(String name, FilePlanComponentProperties properties)
{
this.name = name;

View File

@@ -38,12 +38,21 @@ public class ReviewPeriod
private String periodType;
private String expression;
/**
* Helper constructor with
*
* @param periodType
* @param expression
*/
public ReviewPeriod(String periodType, String expression)
{
this.periodType = periodType;
this.expression = expression;
}
/**
* Helper constructor
*/
public ReviewPeriod()
{
}

View File

@@ -29,7 +29,6 @@ package org.alfresco.rest.rm.community.model.site;
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.COMPLIANCE;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.Gson;
import org.alfresco.rest.model.RestSiteModel;
@@ -44,6 +43,13 @@ public class RMSite extends RestSiteModel
@JsonProperty (value = COMPLIANCE,required = true)
private RMSiteCompliance compliance;
/**
* Helper constructor to create RM Site object using
*
* @param title
* @param description
* @param compliance
*/
public RMSite(String title, String description, RMSiteCompliance compliance)
{
this.title=title;
@@ -51,8 +57,16 @@ public class RMSite extends RestSiteModel
this.compliance=compliance;
}
/**
* Helper constructor for creating the RM Site
*/
public RMSite() { }
/**
* Helper constructor to create RM Site object using
*
* @param compliance RM Site Compliance
*/
public RMSite(RMSiteCompliance compliance)
{
super();

View File

@@ -42,16 +42,22 @@ import com.fasterxml.jackson.databind.ObjectMapper;
*/
public class PojoUtility
{
public static String toJson(Object rmModel) throws JsonProcessingException
/**
* Converting object to JSON string
*
* @param model The java object model to convert
* @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model
*/
public static String toJson(Object model) throws JsonProcessingException
{
ObjectMapper mapper = new ObjectMapper();
//include only values that differ from default settings to be included
mapper.setSerializationInclusion(Include.NON_DEFAULT);
try
{
String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rmModel);
System.out.println("Json object generated is :" + json);
return json;
//return the json object
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
} catch (JsonGenerationException e)
{
return e.toString();

View File

@@ -45,10 +45,18 @@ import org.alfresco.rest.rm.community.model.fileplancomponents.ReviewPeriod;
public class ReviewPeriodSerializer extends JsonSerializer<ReviewPeriod>
{
/**
* @param value The Review Period value that is being serialized.
* @param gen Jackson utility is responsible for writing JSON
* @param serializers Provider for getting access to other serializers and configurations registered with the ObjectMapper.
* @throws IOException
* @throws JsonProcessingException
*/
@Override
public void serialize(ReviewPeriod value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException
{
gen.writeString(String.valueOf(new StringBuilder().append(value.getPeriodType()).append("|").append(value.getExpression())));
//create the custom string value for the Review Period type
gen.writeString(new StringBuilder().append(value.getPeriodType()).append("|").append(value.getExpression()).toString());
}
}