use of com.google.appengine.api.search.Document in project teammates by TEAMMATES.
the class DataMigrationForFeedbackResponseCommentSearchDocument method postAction.
/**
* {@inheritDoc}
*/
@Override
protected void postAction() {
if (isPreview()) {
return;
}
LoopHelper loopHelper = new LoopHelper(BATCH_SIZE, "documents processed.");
List<Document> documentsToUpdate = new ArrayList<>();
for (FeedbackResponseCommentAttributes comment : commentsToMigrate) {
loopHelper.recordLoop();
documentsToUpdate.add(new FeedbackResponseCommentSearchDocument(comment).build());
if (documentsToUpdate.size() == BATCH_SIZE) {
updateAndClearDocuments(documentsToUpdate);
}
}
updateAndClearDocuments(documentsToUpdate);
}
use of com.google.appengine.api.search.Document in project teammates by TEAMMATES.
the class DataMigrationForFeedbackResponseCommentSearchDocumentDateFormat method isMigrationNeeded.
/**
* {@inheritDoc}
*/
@Override
protected boolean isMigrationNeeded(FeedbackResponseCommentAttributes comment) {
Document document = index.get(comment.getId().toString());
if (document == null) {
return false;
}
String sampleDateString = extractSampleDateString(document);
return !isInInstantFormat(sampleDateString);
}
use of com.google.appengine.api.search.Document in project teammates by TEAMMATES.
the class DataMigrationForOrphanedCommentSearchDocuments method postAction.
@Override
protected void postAction() {
println("Number of documents in the old format that have existing parent comments: " + numOfDocumentsNotDeleted);
if (numOfDocumentsNotDeleted > 0) {
println("Warning: these documents will not be deleted. Please run the other migration script again.");
}
if (isPreview()) {
return;
}
LoopHelper loopHelper = new LoopHelper(BATCH_SIZE, "documents processed.");
List<Document> batch = new ArrayList<>(BATCH_SIZE);
for (Document document : documentsToDelete) {
loopHelper.recordLoop();
batch.add(document);
if (batch.size() == BATCH_SIZE) {
batchDeleteAndClear(batch);
}
}
batchDeleteAndClear(batch);
}
use of com.google.appengine.api.search.Document in project teammates by TEAMMATES.
the class DataMigrationForOrphanedCommentSearchDocuments method getEntities.
@Override
protected List<Document> getEntities() {
List<Document> allResults = new ArrayList<>();
Cursor cursor = Cursor.newBuilder().build();
while (cursor != null) {
cursor = getMoreResults(cursor, allResults);
}
return allResults;
}
use of com.google.appengine.api.search.Document in project java-docs-samples by GoogleCloudPlatform.
the class DocumentServlet method doGet.
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
PrintWriter out = resp.getWriter();
Document document = Document.newBuilder().addField(Field.newBuilder().setName("coverLetter").setText("CoverLetter")).addField(Field.newBuilder().setName("resume").setHTML("<html></html>")).addField(Field.newBuilder().setName("fullName").setAtom("Foo Bar")).addField(Field.newBuilder().setName("submissionDate").setDate(new Date())).build();
// [START access_document]
String coverLetter = document.getOnlyField("coverLetter").getText();
String resume = document.getOnlyField("resume").getHTML();
String fullName = document.getOnlyField("fullName").getAtom();
Date submissionDate = document.getOnlyField("submissionDate").getDate();
// [END access_document]
out.println("coverLetter: " + coverLetter);
out.println("resume: " + resume);
out.println("fullName: " + fullName);
out.println("submissionDate: " + submissionDate.toString());
}
Aggregations