Example usage for com.liferay.portal.kernel.json JSONFactoryUtil deserialize

List of usage examples for com.liferay.portal.kernel.json JSONFactoryUtil deserialize

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.json JSONFactoryUtil deserialize.

Prototype

public static Object deserialize(String json) 

Source Link

Usage

From source file:com.liferay.calendar.service.impl.CalendarImporterLocalServiceImpl.java

License:Open Source License

protected void verifyCalendarBooking(CalendarBooking calendarBooking, CalEvent calEvent) {

    if (!hasDayAndPosition(calEvent.getRecurrenceObj())) {
        return;/*w  ww.ja v a 2  s.  c o  m*/
    }

    TZSRecurrence tzsRecurrence = (TZSRecurrence) JSONFactoryUtil.deserialize(calEvent.getRecurrence());

    tzsRecurrence.setByDay(null);

    String oldRecurrence = getRecurrence(tzsRecurrence);

    if (oldRecurrence.equals(calendarBooking.getRecurrence())) {
        updateCalendarBookingRecurrence(calendarBooking, calEvent.getRecurrenceObj());
    }
}

From source file:com.liferay.portlet.calendar.model.impl.CalEventImpl.java

License:Open Source License

public TZSRecurrence getRecurrenceObj() {
    if (_recurrenceObj == null) {
        String recurrence = getRecurrence();

        if (Validator.isNotNull(recurrence)) {
            _recurrenceObj = (TZSRecurrence) JSONFactoryUtil.deserialize(recurrence);
        }//w w  w  .  j a  v a  2s. c  o m
    }

    return _recurrenceObj;
}

From source file:gamification.badges.base.BaseActivityCountBadge.java

License:Open Source License

private List<Long> _deserializeDates(String json) {
    List<Long> dates = new LinkedList<Long>();

    if (Validator.isNotNull(json)) {
        dates.addAll(Arrays.asList((Long[]) JSONFactoryUtil.deserialize(json)));
    }/*from w  w w.j a  v a 2 s .c o  m*/

    return dates;
}

From source file:org.activiti.rest.api.process.StartProcessInstanceResource.java

License:Apache License

@Post
public StartProcessInstanceResponse startProcessInstance(Representation entity) {
    try {/* ww  w.  j av a  2s. co  m*/
        if (authenticate() == false)
            return null;

        String startParams = entity.getText();
        JsonNode startJSON = new ObjectMapper().readTree(startParams);
        String processDefinitionKey = startJSON.path("processDefinitionKey").getTextValue();
        String processDefinitionId = null;
        if (processDefinitionKey == null) {
            processDefinitionId = startJSON.path("processDefinitionId").getTextValue();
        }
        JsonNode businessKeyJson = startJSON.path("businessKey");
        String businessKey = null;
        if (businessKeyJson != null) {
            businessKey = businessKeyJson.getTextValue();
        }

        Map<String, Object> variables = new HashMap<String, Object>();
        Iterator<String> itName = startJSON.getFieldNames();
        while (itName.hasNext()) {
            String name = itName.next();
            JsonNode valueNode = startJSON.path(name);
            if (valueNode.isBoolean()) {
                variables.put(name, valueNode.getBooleanValue());
            } else if (valueNode.isLong()) {
                variables.put(name, valueNode.getLongValue());
            } else if (valueNode.isDouble()) {
                variables.put(name, valueNode.getDoubleValue());
            } else if (valueNode.isTextual()) {
                variables.put(name, valueNode.getTextValue());
                if (valueNode.getTextValue().contains("javaClass")) {
                    Object deserializeObj = JSONFactoryUtil.deserialize(valueNode.getTextValue());
                    variables.put(name, deserializeObj);
                } else {
                    variables.put(name, valueNode.getTextValue());
                }
            } else {
                variables.put(name, valueNode.getValueAsText());
            }
        }
        variables.remove("processDefinitionId");
        variables.remove("processDefinitionKey");
        variables.remove("businessKey");

        ProcessInstance processInstance = null;
        if (processDefinitionKey != null) {
            throw new NotImplementedException(
                    "Starting process by key is usupported due to" + "inavailability to find out company id");
            //        processInstance = ActivitiUtil.getRuntimeService().startProcessInstanceByKey(processDefinitionKey, businessKey, variables);
        } else {
            processInstance = ActivitiUtil.getRuntimeService().startProcessInstanceById(processDefinitionId,
                    businessKey, variables);
        }
        StartProcessInstanceResponse response = new StartProcessInstanceResponse(processInstance);
        return response;

    } catch (Exception e) {
        throw new ActivitiException("Failed to retrieve the process definition parameters", e);
    }
}