Tabnine Logo
ObjectifyService.ofy
Code IndexAdd Tabnine to your IDE (free)

How to use
ofy
method
in
com.googlecode.objectify.ObjectifyService

Best Java code snippets using com.googlecode.objectify.ObjectifyService.ofy (Showing top 20 results out of 315)

origin: objectify/objectify

/**
 * Create a Ref based on the key
 */
public LiveRef(Key<T> key) {
  this(key, ObjectifyService.ofy());
}
origin: TEAMMATES/teammates

protected Objectify ofy() {
  return ObjectifyService.ofy();
}
origin: objectify/objectify

/**
 * Get the current objectify instance associated with this ref
 */
private Objectify ofy() {
  // If we have an expired transaction context, we need a new context
  if (ofy == null || (ofy.getTransaction() != null && !ofy.getTransaction().isActive()))
    ofy = ObjectifyService.ofy();
  return ofy;
}
origin: TEAMMATES/teammates

  @Override
  public String load(String courseId) {
    List<Instructor> instructors =
        ofy().load().type(Instructor.class).filter("courseId =", courseId).list();
    for (Instructor instructor : instructors) {
      if (StringHelper.isEmpty(instructor.getGoogleId())) {
        continue;
      }
      Account account = ofy().load().key(Key.create(Account.class, instructor.getGoogleId())).now();
      if (account != null && !StringHelper.isEmpty(account.getInstitute())) {
        return account.getInstitute();
      }
    }
    return UNKNOWN_INSTITUTE;
  }
});
origin: com.googlecode.luceneappengine/luceneappengine

  @Override
  public Void run() {
    deleteSegment(ofy(), name);
    return null;
  }
});
origin: instacount/appengine-counter

@VisibleForTesting
protected boolean isParentTransactionActive()
{
  return ObjectifyService.ofy().getTransaction() == null ? false
    : ObjectifyService.ofy().getTransaction().isActive();
}
origin: com.googlecode.luceneappengine/luceneappengine

/**
 * Returns every available indexes created into your GAE application.
 * With {@link LuceneIndex} you can build {@link GaeDirectory} 
 * using constructor {@link GaeDirectory#GaeDirectory(LuceneIndex)}.
 * @return A list of available indexes
 */
public static List<LuceneIndex> getAvailableIndexes() {
  return ofy().load().type(LuceneIndex.class).list();
}
/**
origin: com.googlecode.luceneappengine/luceneappengine

public void flush() throws IOException {
  segment.lastModified = System.currentTimeMillis();
  writer.flush();
  hunk.bytes = writer.getBytes();
  ofy().save().entity(segment);
  save(hunk);
  ofy().flush();
  PendingFutures.completeAllPendingFutures();
  /* nothing to do */
}
/*
origin: com.threewks.thundr/thundr-gae

@Override
public JobStatus getJobStatus(UUID jobStatus) {
  return ofy().load().type(JobStatus.class).id(jobStatus.toString()).now();
}
origin: com.googlecode.luceneappengine/luceneappengine

  @Override
  public T run() {
    T t = ofy().load().key(key).now();
    if(t == null) {
      t = builder.newInstance(key);
      ofy().save().entity(t).now();
    }
    return t;
  }
});
origin: com.googlecode.luceneappengine/luceneappengine

@Override
public long fileLength(String name) throws IOException {
  final Segment bigTableIndexFile = ofy().load().key(newSegmentKey(name)).now();
  return bigTableIndexFile.length;
}
/*
origin: com.googlecode.luceneappengine/luceneappengine

@Override
public IndexOutput createTempOutput(String prefix, String suffix, IOContext context) throws IOException {
  final String tempName = prefix + "_" + UUID.randomUUID().toString() + "_" + suffix;
  ensureOpen();
  final Objectify begin = ofy();
  Segment segment = begin.load().key(newSegmentKey(tempName)).now();
  if(segment == null) {
    segment = newSegment(tempName);
  }
  return new SegmentIndexOutput(segment);
}
origin: com.threewks.thundr/thundr-gae

protected List<E> loadInternal(Iterable<Key<E>> keys) {
  if (Expressive.isEmpty(keys)) {
    return Collections.<E> emptyList();
  }
  Map<Key<E>, E> results = ofy().load().keys(keys);
  return Expressive.Transformers.transformAllUsing(Expressive.Transformers.usingLookup(results)).from(keys);
}
origin: com.googlecode.luceneappengine/luceneappengine

@Override
public IndexInput openInput(String name, IOContext context) throws IOException {
  ensureOpen();
  try {
    return new SegmentIndexInput(ofy().load().key(newSegmentKey(name)).safe());
  } catch (NotFoundException e) {
    throw new IOException(name, e);
  }
}
/*
origin: instacount/appengine-counter

  @Override
  public void vrun()
  {
    // Do something else as part of the TX.
    final Key<CounterShardData> counterShardDataKey = CounterShardData.key(
      CounterData.key(UUID.randomUUID().toString()), 0);
    ObjectifyService.ofy().save().entity(counterShardDataKey);
    // The actual test.
    singleShardShardedCounterService.increment(counterName, 10L);
    throw new RuntimeException("Abort the Transaction!");
  }
});
origin: instacount/appengine-counter

  @Override
  public void vrun()
  {
    // Do something else as part of the TX.
    final Key<CounterShardData> counterShardDataKey = CounterShardData.key(
      CounterData.key(UUID.randomUUID().toString()), 0);
    ObjectifyService.ofy().save().entity(counterShardDataKey);
    // The actual test.
    singleShardShardedCounterService.increment(counterName, 10L);
    throw new RuntimeException("Abort the Transaction!");
  }
});
origin: com.googlecode.luceneappengine/luceneappengine

  @Override
  public Void run() {
    Objectify objectify = ofy();
    for(String name : listAll())
      deleteSegment(objectify, name);
    objectify.delete().key(indexKey);
    objectify.delete().entities(((GaeLockFactory)lockFactory).getLocks(GaeDirectory.this));
    return null;
  }
});
origin: com.googlecode.luceneappengine/luceneappengine

@Override
public IndexOutput createOutput(String name, IOContext context) throws IOException {
  ensureOpen();
  final Objectify begin = ofy();
  Segment segment = begin.load().key(newSegmentKey(name)).now();
  if(segment == null) {
    segment = newSegment(name);
  }
  return new SegmentIndexOutput(segment);
}
origin: com.googlecode.luceneappengine/luceneappengine

@Override
public void deleteFile(String name) {
  final Objectify objectify = ofy();
  final Segment segment = objectify.load().key(newSegmentKey(name)).now();
  
  final long hunkCount = segment.hunkCount;
  for (int i = 1; i <= hunkCount; i++) {
    objectify.delete().key(newSegmentHunkKey(name, i));
  }
  objectify.delete().key(newSegmentKey(name));
}
@Override
origin: instacount/appengine-counter

@Test(expected = RuntimeException.class)
public void testDecrement_CounterIsBeingDeleted() throws InterruptedException
{
  // Store this in the Datastore to trigger the exception below...
  CounterData counterData = new CounterData(TEST_COUNTER1, 1);
  counterData.setCounterStatus(CounterStatus.DELETING);
  ObjectifyService.ofy().save().entity(counterData).now();
  shardedCounterService.decrement(TEST_COUNTER1, 1);
}
com.googlecode.objectifyObjectifyServiceofy

Javadoc

The method to call at any time to get the current Objectify, which may change depending on txn context

Popular methods of ObjectifyService

  • begin
  • factory
    Call this to get the instance
  • run
    Runs one unit of work, making the root Objectify context available. This does not start a transactio
  • register
  • init
  • reset

Popular in Java

  • Creating JSON documents from java classes using gson
  • compareTo (BigDecimal)
  • startActivity (Activity)
  • getResourceAsStream (ClassLoader)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now