public void onAfterFetch(final ODocument iRootRecord) { StringBuilder buffer = typesStack.pop(); if (settings.keepTypes && buffer.length() > 0) try { jsonWriter.writeAttribute(settings.indentLevel > -1 ? settings.indentLevel : 1, true, ORecordSerializerJSON.ATTRIBUTE_FIELD_TYPES, buffer.toString()); } catch (IOException e) { throw OException.wrapException(new OFetchException("Error writing field types"), e); } }
public void onAfterCollection(final ODocument iRootRecord, final String iFieldName, final Object iUserObject) { try { jsonWriter.endCollection(settings.indentLevel--, true); collectionStack.pop(); } catch (IOException e) { throw OException.wrapException( new OFetchException("Error writing collection field " + iFieldName + " of record " + iRootRecord.getIdentity()), e); } }
public void onAfterMap(final ODocument iRootRecord, final String iFieldName, final Object iUserObject) { try { jsonWriter.endObject(--settings.indentLevel, true); if (!(iUserObject instanceof ODocument)) { collectionStack.pop(); } } catch (IOException e) { throw OException.wrapException( new OFetchException("Error writing map field " + iFieldName + " of record " + iRootRecord.getIdentity()), e); } }
public void onBeforeCollection(final ODocument iRootRecord, final String iFieldName, final Object iUserObject, final Iterable<?> iterable) { try { manageTypes(iFieldName, iterable, null); jsonWriter.beginCollection(++settings.indentLevel, true, iFieldName); collectionStack.add(iRootRecord); } catch (IOException e) { throw OException.wrapException( new OFetchException("Error writing collection field " + iFieldName + " of record " + iRootRecord.getIdentity()), e); } }
public void onAfterDocument(final ODocument iRootRecord, final ODocument iDocument, final String iFieldName, final Object iUserObject) { try { jsonWriter.endObject(settings.indentLevel--, true); } catch (IOException e) { throw OException.wrapException( new OFetchException("Error writing link field " + iFieldName + " of record " + iRootRecord.getIdentity()), e); } }
public void onBeforeMap(final ODocument iRootRecord, final String iFieldName, final Object iUserObject) { try { jsonWriter.beginObject(++settings.indentLevel, true, iFieldName); if (!(iUserObject instanceof ODocument)) { collectionStack.add(new ODocument()); // <-- sorry for this... fixes #2845 but this mess should be rewritten... } } catch (IOException e) { throw OException.wrapException( new OFetchException("Error writing map field " + iFieldName + " of record " + iRootRecord.getIdentity()), e); } }
public void onBeforeDocument(final ODocument iRootRecord, final ODocument iDocument, final String iFieldName, final Object iUserObject) { try { final String fieldName; if (!collectionStack.isEmpty() && collectionStack.peek().equals(iRootRecord)) fieldName = null; else fieldName = iFieldName; jsonWriter.beginObject(++settings.indentLevel, true, fieldName); writeSignature(jsonWriter, iDocument); } catch (IOException e) { throw OException.wrapException( new OFetchException("Error writing link field " + iFieldName + " of record " + iRootRecord.getIdentity()), e); } }
public void parseLinked(final ODocument iRootRecord, final OIdentifiable iLinked, final Object iUserObject, final String iFieldName, final OFetchContext iContext) throws OFetchException { try { ((OJSONFetchContext) iContext).writeLinkedAttribute(iLinked, iFieldName); } catch (IOException e) { throw OException.wrapException( new OFetchException("Error writing linked field " + iFieldName + " (record:" + iLinked.getIdentity() + ") of record " + iRootRecord.getIdentity()), e); } }
public void processStandardField(final ODocument iRecord, final Object iFieldValue, final String iFieldName, final OFetchContext iContext, final Object iusObject, final String iFormat, OType filedType) { try { ((OJSONFetchContext) iContext).getJsonWriter().writeAttribute(((OJSONFetchContext) iContext).getIndentLevel() + 1, true, iFieldName, iFieldValue,iFormat,filedType); } catch (IOException e) { throw OException.wrapException( new OFetchException("Error processing field '" + iFieldValue + " of record " + iRecord.getIdentity()), e); } }
public void parseLinkedCollectionValue(ODocument iRootRecord, OIdentifiable iLinked, Object iUserObject, String iFieldName, OFetchContext iContext) throws OFetchException { try { if (((OJSONFetchContext) iContext).isInCollection(iRootRecord)) { ((OJSONFetchContext) iContext).writeLinkedValue(iLinked, iFieldName); } else { ((OJSONFetchContext) iContext).writeLinkedAttribute(iLinked, iFieldName); } } catch (IOException e) { throw OException.wrapException( new OFetchException("Error writing linked field " + iFieldName + " (record:" + iLinked.getIdentity() + ") of record " + iRootRecord.getIdentity()), e); } }