Exemple #1
0
 private static void updateRidMap(
     final Map<String, Integer> iFetchPlan,
     final ODocument fieldValue,
     final int iCurrentLevel,
     final int iLevelFromRoot,
     final int iFieldDepthLevel,
     final Map<ORID, Integer> parsedRecords,
     final String iFieldPathFromRoot,
     final OFetchContext iContext)
     throws IOException {
   final Integer fetchedLevel = parsedRecords.get(fieldValue.getIdentity());
   int currentLevel = iCurrentLevel + 1;
   int fieldDepthLevel = iFieldDepthLevel;
   if (iFetchPlan.containsKey(iFieldPathFromRoot)) {
     currentLevel = 1;
     fieldDepthLevel = iFetchPlan.get(iFieldPathFromRoot);
   }
   if (fetchedLevel == null) {
     if (!fieldValue.isEmbedded()) {
       parsedRecords.put(fieldValue.getIdentity(), iLevelFromRoot);
     }
     processRecordRidMap(
         fieldValue,
         iFetchPlan,
         currentLevel,
         iLevelFromRoot,
         fieldDepthLevel,
         parsedRecords,
         iFieldPathFromRoot,
         iContext);
   } else if ((!fieldValue.getIdentity().isValid() && fetchedLevel < iLevelFromRoot)
       || fetchedLevel > iLevelFromRoot) {
     if (!fieldValue.isEmbedded()) {
       parsedRecords.put(fieldValue.getIdentity(), iLevelFromRoot);
     }
     processRecordRidMap(
         (ODocument) fieldValue,
         iFetchPlan,
         currentLevel,
         iLevelFromRoot,
         fieldDepthLevel,
         parsedRecords,
         iFieldPathFromRoot,
         iContext);
   }
 }
Exemple #2
0
  public static void fetch(
      final ORecordInternal<?> iRootRecord,
      final Object iUserObject,
      final Map<String, Integer> iFetchPlan,
      final OFetchListener iListener,
      final OFetchContext iContext,
      final String iFormat) {
    try {
      if (iRootRecord instanceof ORecordSchemaAware<?>) {
        // SCHEMA AWARE
        final ORecordSchemaAware<?> record = (ORecordSchemaAware<?>) iRootRecord;
        final Map<ORID, Integer> parsedRecords = new HashMap<ORID, Integer>();
        parsedRecords.put(iRootRecord.getIdentity(), 0);

        if (!iFormat.contains("shallow"))
          processRecordRidMap(record, iFetchPlan, 0, 0, -1, parsedRecords, "", iContext);

        processRecord(
            record,
            iUserObject,
            iFetchPlan,
            0,
            0,
            -1,
            parsedRecords,
            "",
            iListener,
            iContext,
            iFormat);
      }
    } catch (Exception e) {
      e.printStackTrace();
      OLogManager.instance()
          .error(null, "Fetching error on record %s", e, iRootRecord.getIdentity());
    }
  }