Example usage for java.io Serializable toString

List of usage examples for java.io Serializable toString

Introduction

In this page you can find the example usage for java.io Serializable toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.grails.datastore.mapping.cassandra.engine.CassandraEntityPersister.java

private SuperColumn getSuperColumn(Keyspace keyspace, String family, Serializable id) {
    ColumnParent parent = new ColumnParent();
    parent.setColumn_family(family);//from  w ww. ja  v  a 2  s  .c  om

    final List<SuperColumn> result;
    try {
        SlicePredicate predicate = new SlicePredicate();
        predicate.setSlice_range(new SliceRange(ZERO_LENGTH_BYTE_ARRAY, ZERO_LENGTH_BYTE_ARRAY, false, 1));
        result = keyspace.getSuperSlice(id.toString(), parent, predicate);
    } catch (HectorException e) {
        throw new DataAccessResourceFailureException("Exception occurred invoking Cassandra: " + e.getMessage(),
                e);
    }

    return !result.isEmpty() ? result.get(0) : null;
}

From source file:org.alfresco.web.ui.repo.component.UIWorkflowHistory.java

@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
    if (!isRendered())
        return;//from w  w  w .  ja v a  2s  .co m

    WorkflowInstance wi = getValue();

    if (wi != null) {
        ResponseWriter out = context.getResponseWriter();
        ResourceBundle bundle = Application.getBundle(context);

        if (logger.isDebugEnabled())
            logger.debug("Retrieving workflow history for workflow instance: " + wi);

        WorkflowTaskQuery query = new WorkflowTaskQuery();
        query.setActive(null);
        query.setProcessId(wi.id);
        query.setTaskState(WorkflowTaskState.COMPLETED);
        query.setOrderBy(new WorkflowTaskQuery.OrderBy[] { WorkflowTaskQuery.OrderBy.TaskCreated_Desc,
                WorkflowTaskQuery.OrderBy.TaskActor_Asc });
        List<WorkflowTask> tasks = Repository.getServiceRegistry(context).getWorkflowService()
                .queryTasks(query);

        if (tasks.size() == 0) {
            out.write("<div style='margin-left:18px;margin-top: 6px;'>");
            out.write(bundle.getString(MSG_NO_HISTORY));
            out.write("</div>");
        } else {
            // output surrounding table and style if necessary
            out.write("<table cellspacing='2' cellpadding='1' border='0'");
            if (this.getAttributes().get("style") != null) {
                out.write(" style=\"");
                out.write((String) this.getAttributes().get("style"));
                out.write("\"");
            }
            if (this.getAttributes().get("styleClass") != null) {
                out.write(" class=\"");
                out.write((String) this.getAttributes().get("styleClass"));
                out.write("\"");
            }
            out.write(">");

            // output a header row
            out.write("<tr align=left><th>");
            out.write(bundle.getString(MSG_DESCRIPTION));
            out.write("</th><th>");
            out.write(bundle.getString(MSG_TASK));
            out.write("</th><th>");
            out.write(bundle.getString(MSG_ID));
            out.write("</th><th>");
            out.write(bundle.getString(MSG_CREATED));
            out.write("</th><th>");
            out.write(bundle.getString(MSG_ASSIGNEE));
            out.write("</th><th>");
            out.write(bundle.getString(MSG_COMMENT));
            out.write("</th><th>");
            out.write(bundle.getString(MSG_DATE_COMPLETED));
            out.write("</th><th>");
            out.write(bundle.getString(MSG_OUTCOME));
            out.write("</th></tr>");

            // output a row for each previous completed task
            for (WorkflowTask task : tasks) {
                String id = null;
                Serializable idObject = task.properties.get(WorkflowModel.PROP_TASK_ID);
                if (idObject instanceof Long) {
                    id = ((Long) idObject).toString();
                } else {
                    id = idObject.toString();
                }

                String desc = (String) task.properties.get(WorkflowModel.PROP_DESCRIPTION);
                Date createdDate = (Date) task.properties.get(ContentModel.PROP_CREATED);
                String owner = (String) task.properties.get(ContentModel.PROP_OWNER);
                String comment = (String) task.properties.get(WorkflowModel.PROP_COMMENT);
                Date completedDate = (Date) task.properties.get(WorkflowModel.PROP_COMPLETION_DATE);
                String transition = (String) task.properties.get(WorkflowModel.PROP_OUTCOME);
                String outcome = "";
                if (transition != null) {
                    WorkflowTransition[] transitions = task.definition.node.transitions;
                    for (WorkflowTransition trans : transitions) {
                        if (trans.id.equals(transition)) {
                            outcome = trans.title;
                            break;
                        }
                    }
                }

                if ((outcome == null || outcome.equals("")) && transition != null) {
                    // it's possible in Activiti to have tasks without an outcome set,
                    // in this case default to the transition, if there is one.
                    outcome = transition;
                }
                //ACE-1154
                if (outcome.equals("")) {
                    outcome = I18NUtil.getMessage(DEFAULT_TRANSITION_TITLE);
                }

                out.write("<tr><td>");
                out.write(desc == null ? "" : Utils.encode(desc));
                out.write("</td><td>");
                out.write(Utils.encode(task.title));
                out.write("</td><td>");
                out.write(id);
                out.write("</td><td>");
                out.write(Utils.getDateTimeFormat(context).format(createdDate));
                out.write("</td><td>");
                out.write(owner == null ? "" : owner);
                out.write("</td><td>");
                out.write(comment == null ? "" : Utils.encode(comment));
                out.write("</td><td>");
                out.write(Utils.getDateTimeFormat(context).format(completedDate));
                out.write("</td><td>");
                out.write(outcome);
                out.write("</td></tr>");
            }

            // output the end of the table
            out.write("</table>");
        }
    }
}

From source file:org.pentaho.platform.repository2.unified.jcr.JcrRepositoryFileUtils.java

public static RepositoryFile nodeIdToFile(final Session session, final PentahoJcrConstants pentahoJcrConstants,
        final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper,
        final Serializable fileId) throws RepositoryException {
    Node fileNode = session.getNodeByIdentifier(fileId.toString());
    return nodeToFile(session, pentahoJcrConstants, pathConversionHelper, lockHelper, fileNode);
}

From source file:io.cloudslang.lang.compiler.SlangCompilerImpl.java

private SystemProperty transformSystemProperty(String rawNamespace, String key, Object rawValue,
        String description) {/* w ww . j a  v a 2 s.c om*/
    String namespace = rawNamespace == null ? "" : rawNamespace;
    if (rawValue == null) {
        return new SystemProperty(namespace, key, (String) null, description);
    }
    if (rawValue instanceof Map) {
        Map rawModifiers = (Map) rawValue;
        Map<String, Serializable> modifiers = convertRawMap(rawModifiers, key);

        List<String> knownModifierKeys = Arrays.asList(SENSITIVE_KEY, VALUE_KEY);
        for (String modifierKey : modifiers.keySet()) {
            if (!knownModifierKeys.contains(modifierKey)) {
                throw new RuntimeException("Artifact {" + key + "} has unrecognized tag {" + modifierKey + "}"
                        + ". Please take a look at the supported features per versions link");
            }
        }

        Serializable valueAsSerializable = modifiers.get(VALUE_KEY);
        String value = valueAsSerializable == null ? null : valueAsSerializable.toString();
        boolean sensitive = modifiers.containsKey(SENSITIVE_KEY) && (boolean) modifiers.get(SENSITIVE_KEY);

        if (sensitive) {
            return new SystemProperty(namespace, key, ValueFactory.createEncryptedString(value), description);
        } else {
            return new SystemProperty(namespace, key, value, description);
        }
    } else {
        return new SystemProperty(namespace, key, rawValue.toString(), description);
    }
}

From source file:org.pentaho.platform.repository2.unified.jcr.JcrRepositoryFileUtils.java

public static RepositoryFile getFileById(final Session session, final PentahoJcrConstants pentahoJcrConstants,
        final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper,
        final Serializable fileId) throws RepositoryException {
    Node fileNode = session.getNodeByIdentifier(fileId.toString());
    Assert.notNull(fileNode);/* w  ww .  java 2 s.c om*/
    return nodeToFile(session, pentahoJcrConstants, pathConversionHelper, lockHelper, fileNode);
}

From source file:no.uka.findmyapp.android.rest.client.RestProcessor.java

/**
 * Send intent broadcast.//from  w  ww . j  a v  a  2 s  .c  o m
 *
 * @param intentString the intent string
 * @param obj the obj
 */
private void sendIntentBroadcast(String intentString, Serializable obj) {
    Log.v(debug, "sendIntentBroadcast: sending broadcast, object name " + obj.getClass().getName());
    Log.v(debug, "sendIntentBroadcast: broadcast sent, extradata identifier: "
            + IntentMessages.BROADCAST_RETURN_VALUE_NAME);
    Log.v(debug, "sendIntentBroadcast: Putting extra " + obj.toString());
    Intent broadcastedIntent = new Intent();
    broadcastedIntent.putExtra(IntentMessages.BROADCAST_RETURN_VALUE_NAME, obj);
    broadcastedIntent.setAction(intentString);

    mContext.sendBroadcast(broadcastedIntent);
}

From source file:org.pentaho.platform.repository2.unified.jcr.JcrRepositoryFileUtils.java

public static Serializable getParentId(final Session session, final Serializable fileId)
        throws RepositoryException {
    Node node = session.getNodeByIdentifier(fileId.toString());
    return node.getParent().getIdentifier();
}

From source file:org.pentaho.platform.repository2.unified.jcr.JcrRepositoryFileUtils.java

public static Serializable getBaseVersionId(final Session session, final Serializable fileId)
        throws RepositoryException {
    Node node = session.getNodeByIdentifier(fileId.toString());
    return session.getWorkspace().getVersionManager().getBaseVersion(node.getPath()).getName();
}

From source file:org.pentaho.platform.repository2.unified.fs.FileSystemRepositoryFileDao.java

public RepositoryFile getFile(Serializable fileId, Serializable versionId) {
    return getFile(fileId.toString());
}

From source file:org.pentaho.platform.repository2.unified.fs.FileSystemRepositoryFileDao.java

public RepositoryFile getFileById(Serializable fileId, boolean loadLocaleMaps) {
    return getFile(fileId.toString());
}