Examples of ORidBag


Examples of com.orientechnologies.orient.core.db.record.ridbag.ORidBag

          boolean equals = baseTs == testTs;

          if (equals) {
            Set<ORID> baseRids = new HashSet<ORID>();
            ODatabaseRecordThreadLocal.INSTANCE.set(base_db);
            ORidBag baseRidBag = baseDocument.field("ridBag");

            for (OIdentifiable baseIdentifiable : baseRidBag)
              baseRids.add(baseIdentifiable.getIdentity());

            Set<ORID> testRids = new HashSet<ORID>();
            ODatabaseRecordThreadLocal.INSTANCE.set(test_db);
            ORidBag testRidBag = testDocument.field("ridBag");

            for (OIdentifiable testIdentifiable : testRidBag)
              testRids.add(testIdentifiable.getIdentity());

            equals = baseRids.equals(testRids);
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ridbag.ORidBag

      }
    }

    private ODocument addDocument(long ts) {
      ODocument document = new ODocument();
      ORidBag ridBag = new ORidBag();
      document.field("ridBag", ridBag);
      document.field("ts", ts);
      document.save();
      return document;
    }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ridbag.ORidBag

    private void addRids(ORID docRid, ODatabaseDocumentTx db, List<ORID> ridsToAdd, long ts) {
      ODocument document = db.load(docRid);
      document.field("ts", ts);
      document.setLazyLoad(false);

      ORidBag ridBag = document.field("ridBag");
      for (ORID rid : ridsToAdd)
        ridBag.add(rid);

      document.save();
    }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ridbag.ORidBag

            ODatabaseDocumentTx base_db = ODatabaseDocumentPool.global().acquire(URL_BASE, "admin", "admin");
            final List<ORID> ridsToRemove = new ArrayList<ORID>();

            ODocument document = base_db.load(orid);
            document.setLazyLoad(false);
            ORidBag ridBag = document.field("ridBag");

            for (OIdentifiable identifiable : ridBag) {
              if (random.nextBoolean())
                ridsToRemove.add(identifiable.getIdentity());

              if (ridsToRemove.size() >= 5)
                break;
            }

            for (ORID ridToRemove : ridsToRemove)
              ridBag.remove(ridToRemove);

            document.field("ts", ts);
            document.save();

            base_db.close();

            ODatabaseDocumentTx test_db = ODatabaseDocumentPool.global().acquire(URL_TEST, "admin", "admin");
            document = test_db.load(orid);
            document.setLazyLoad(false);

            ridBag = document.field("ridBag");
            for (ORID ridToRemove : ridsToRemove)
              ridBag.remove(ridToRemove);

            document.field("ts", ts);
            document.save();

            test_db.close();
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ridbag.ORidBag

      }

    OType fieldType = deriveFieldType(iFieldName, iFieldType);

    if (oldValue instanceof ORidBag) {
      final ORidBag ridBag = (ORidBag) oldValue;
      ridBag.setOwner(null);
    } else if (oldValue instanceof ODocument) {
      ODocumentInternal.removeOwner((ODocument) oldValue, this);
    }

    if (iPropertyValue != null) {
      // CHECK FOR CONVERSION
      if (fieldType != null) {
        iPropertyValue = ODocumentHelper.convertField(this, iFieldName, fieldType.getDefaultJavaType(), iPropertyValue);
        if (fieldType.equals(OType.EMBEDDED) && iPropertyValue instanceof ODocument) {
          final ODocument embeddedDocument = (ODocument) iPropertyValue;
          ODocumentInternal.addOwner(embeddedDocument, this);
        }
      } else if (iPropertyValue instanceof Enum)
        iPropertyValue = iPropertyValue.toString();

      if (iPropertyValue instanceof ORidBag) {
        final ORidBag ridBag = (ORidBag) iPropertyValue;
        ridBag.setOwner(null); // in order to avoid IllegalStateException when ridBag changes the owner (ODocument.merge)
        ridBag.setOwner(this);
      }
    }

    removeCollectionChangeListener(iFieldName, _fieldValues.get(iFieldName));
    removeCollectionTimeLine(iFieldName);
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ridbag.ORidBag

  @Override
  public Object createValue(final List<?> params) {
    if (!(params.get(0) instanceof ORidBag))
      return null;

    final ORidBag ridBag = (ORidBag) params.get(0);
    final List<Object> values = new ArrayList<Object>();
    for (final OIdentifiable item : ridBag) {
      values.add(createSingleValue(item));
    }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ridbag.ORidBag

  @Override
  public Object createValue(final Object... params) {
    if (!(params[0] instanceof ORidBag))
      return null;

    final ORidBag ridBag = (ORidBag) params[0];
    final List<Object> values = new ArrayList<Object>();
    for (final OIdentifiable item : ridBag) {
      values.add(createSingleValue(item));
    }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ridbag.ORidBag

    }
  }

  public static boolean compareBags(ODatabaseRecordInternal iMyDb, ORidBag myFieldValue, ODatabaseRecordInternal iOtherDb,
      ORidBag otherFieldValue, RIDMapper ridMapper) {
    final ORidBag myBag = myFieldValue;
    final ORidBag otherBag = otherFieldValue;

    final int mySize = makeDbCall(iMyDb, new ODbRelatedCall<Integer>() {
      public Integer call() {
        return myBag.size();
      }
    });

    final int otherSize = makeDbCall(iOtherDb, new ODbRelatedCall<Integer>() {
      public Integer call() {
        return otherBag.size();
      }
    });

    if (mySize != otherSize)
      return false;

    boolean oldMyAutoConvert;
    boolean oldOtherAutoConvert;

    oldMyAutoConvert = myBag.isAutoConvertToRecord();
    myBag.setAutoConvertToRecord(false);

    oldOtherAutoConvert = otherBag.isAutoConvertToRecord();
    otherBag.setAutoConvertToRecord(false);

    final ORidBag otherBagCopy = makeDbCall(iOtherDb, new ODbRelatedCall<ORidBag>() {
      @Override
      public ORidBag call() {
        final ORidBag otherRidBag = new ORidBag();
        otherRidBag.setAutoConvertToRecord(false);

        for (OIdentifiable identifiable : otherBag)
          otherRidBag.add(identifiable);

        return otherRidBag;
      }
    });
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ridbag.ORidBag

   if (reference == null) {
      OLogManager.instance().warn(this, "Update of collection pointer is received but collection is not registered");
      return;
    }

    final ORidBag collection = reference.get();

    if (collection != null) {
      collection.notifySaved(pointer);
    }
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ridbag.ORidBag

  public void testCreateValueWrongParameter() {
    Assert.assertNull(propertyIndex.createValue(Collections.singletonList("tt")));
  }

  public void testCreateValueSingleParameterArrayParams() {
    ORidBag ridBag = new ORidBag();
    ridBag.setAutoConvertToRecord(false);

    ridBag.add(new ORecordId("#1:12"));
    ridBag.add(new ORecordId("#1:23"));

    final Object result = propertyIndex.createValue((Object) ridBag);

    Assert.assertTrue(result instanceof Collection);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.