mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
tidy up code, add java docs
This commit is contained in:
@@ -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;
|
||||
|
@@ -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()
|
||||
{
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -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();
|
||||
|
@@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user