Examples of EObjectBuilder


Examples of org.eclipselabs.mongoemf.EObjectBuilder

   * @see #getObjectBuilder()
   * @generated
   */
  public void setObjectBuilder(EObjectBuilder newObjectBuilder)
  {
    EObjectBuilder oldObjectBuilder = objectBuilder;
    objectBuilder = newObjectBuilder;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MONGO_CURSOR__OBJECT_BUILDER, oldObjectBuilder, objectBuilder));
  }
View Full Code Here

Examples of org.eclipselabs.mongoemf.EObjectBuilder

      uriHandler.setBaseURI(resource.getURI().trimSegments(1).appendSegment("-1"));
    else
      uriHandler.setBaseURI(resource.getURI());

    boolean includeAttributesForProxyReferences = Boolean.TRUE.equals(options.get(Options.OPTION_PROXY_ATTRIBUTES));
    EObjectBuilder builder = builderFactory.createObjectBuilder(converterService, uriHandler, includeAttributesForProxyReferences, eClassCache);

    // If the URI contains a query string, use it to locate a collection of objects from
    // MongoDB, otherwise simply get the object from MongoDB using the id.

    EList<EObject> contents = resource.getContents();

    if (uri.query() != null)
    {
      if (queryEngine == null)
        throw new IOException("The query engine was not found");

      MongoQuery mongoQuery = queryEngine.buildDBObjectQuery(uri);
      DBCursor resultCursor = null;

      if (mongoQuery.getProjection() == null)
        resultCursor = collection.find(mongoQuery.getFilter());
      else
        resultCursor = collection.find(mongoQuery.getFilter(), mongoQuery.getProjection());

      if (mongoQuery.getSkip() != null)
        resultCursor.skip(mongoQuery.getSkip());

      if (mongoQuery.getSort() != null)
        resultCursor = resultCursor.sort(mongoQuery.getSort());

      if (mongoQuery.getLimit() != null)
        resultCursor = resultCursor.limit(mongoQuery.getLimit());

      boolean createCursor = Boolean.TRUE.equals(options.get(Options.OPTION_QUERY_CURSOR));

      if (createCursor)
      {
        MongoCursor cursor = ModelFactory.eINSTANCE.createMongoCursor();
        cursor.setDbCollection(collection);
        cursor.setDbCursor(resultCursor);
        cursor.setObjectBuilder(builder);
        contents.add(cursor);
      }
      else
      {
        EReferenceCollection eCollection = EmodelingFactory.eINSTANCE.createEReferenceCollection();
        InternalEList<EObject> values = (InternalEList<EObject>) eCollection.getValues();

        for (DBObject dbObject : resultCursor)
          values.addUnique(builder.buildEObject(collection, dbObject, resource, true));

        contents.add(eCollection);
      }
    }
    else
    {
      DBObject dbObject = collection.findOne(new BasicDBObject(Keywords.ID_KEY, MongoUtils.getID(uri)));

      if (dbObject != null)
      {
        EObject eObject = builder.buildEObject(collection, dbObject, resource, false);

        if (eObject != null)
          contents.add(eObject);

        response.put(URIConverter.RESPONSE_TIME_STAMP_PROPERTY, dbObject.get(Keywords.TIME_STAMP_KEY));
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.