Source:
<code>public RyaStatement deserializeDBObject(final DBObject queryResult) { <START> final Map<?, ?> result = queryResult.toMap(); <END> final String subject = (String) result.get(SUBJECT); final String object = (String) result.get(OBJECT); final String objectType = (String) result.get(OBJECT_TYPE); final String predicate = (String) result.get(PREDICATE); final String context = (String) result.get(CONTEXT); final Object documentVisibilityObject = result.get(DOCUMENT_VISIBILITY); Object[] documentVisibilityArray = null; if (documentVisibilityObject instanceof Object[]) { documentVisibilityArray = (Object[]) documentVisibilityObject; } else if (documentVisibilityObject instanceof BasicDBList) { documentVisibilityArray = DocumentVisibilityUtil.convertBasicDBListToObjectArray((BasicDBList) documentVisibilityObject); } final Long timestamp = (Long) result.get(TIMESTAMP); RyaType objectRya = null; if (objectType.equalsIgnoreCase(ANYURI.stringValue())){ objectRya = new RyaURI(object); } else { objectRya = new RyaType(factory.createURI(objectType), object); } final RyaStatement statement; if (!context.isEmpty()){ statement = new RyaStatement(new RyaURI(subject), new RyaURI(predicate), objectRya, new RyaURI(context)); } else { statement = new RyaStatement(new RyaURI(subject), new RyaURI(predicate), objectRya); } final String documentVisibilityString = DocumentVisibilityUtil.multidimensionalArrayToBooleanString(documentVisibilityArray); final DocumentVisibility dv = documentVisibilityString == null ? MongoDbRdfConstants.EMPTY_DV : new DocumentVisibility(documentVisibilityString); statement.setColumnVisibility(dv.flatten()); if(timestamp != null) { statement.setTimestamp(timestamp); } return statement; }</code><technical_language>this dangerous, do types here</technical_language>

Target:
public RyaStatement deserializeDBObject(final DBObject queryResult) { final Map<?, ?> result = queryResult.toMap(); final String subject = (String) result.get(SUBJECT); final String object = (String) result.get(OBJECT); final String objectType = (String) result.get(OBJECT_TYPE); final String predicate = (String) result.get(PREDICATE); final String context = (String) result.get(CONTEXT); DocumentVisibility documentVisibility = null; try { documentVisibility = DocumentVisibilityAdapter.toDocumentVisibility(queryResult); } catch (final MalformedDocumentVisibilityException e) { LOG.error("Unable to convert document visibility"); } final Long timestamp = (Long) result.get(TIMESTAMP); final String statementMetadata = (String) result.get(STATEMENT_METADATA); RyaType objectRya = null; if (objectType.equalsIgnoreCase(ANYURI.stringValue())){ objectRya = new RyaURI(object); } else { objectRya = new RyaType(factory.createURI(objectType), object); } final RyaStatement statement; if (!context.isEmpty()){ statement = new RyaStatement(new RyaURI(subject), new RyaURI(predicate), objectRya, new RyaURI(context)); } else { statement = new RyaStatement(new RyaURI(subject), new RyaURI(predicate), objectRya); } statement.setColumnVisibility(documentVisibility.flatten()); if(timestamp != null) { statement.setTimestamp(timestamp); } if(statementMetadata != null) { try { final StatementMetadata metadata = new StatementMetadata(statementMetadata); statement.setStatementMetadata(metadata); } catch (final Exception ex){ LOG.debug("Error deserializing metadata for statement", ex); } } return statement; }