private String getFetchEvent(DatabaseDocument<?> doc, String stage) { StringBuffer sb = new StringBuffer(); sb.append(df.format(doc.getFetchedTime(stage))); sb.append(" document="); sb.append(doc.getID()); sb.append(" type=fetch"); sb.append(" stage="); sb.append(stage); return sb.toString(); }
private String getInsertEvent(DatabaseDocument<?> doc) { StringBuffer sb = new StringBuffer(); String stage = getInserter(doc); sb.append(df.format(doc.getTouchedTime(stage))); sb.append(" document="); sb.append(doc.getID()); sb.append(" type=insert"); sb.append(" stage="); sb.append(stage); return sb.toString(); }
private String getTouchEvent(DatabaseDocument<?> doc, String stage) { StringBuffer sb = new StringBuffer(); sb.append(df.format(doc.getTouchedTime(stage))); sb.append(" document="); sb.append(doc.getID()); sb.append(" type=touch"); sb.append(" stage="); sb.append(stage); sb.append(" time="); sb.append(doc.getTouchedTime(stage).getTime() - doc.getFetchedTime(stage).getTime()); return sb.toString(); }
@Override public boolean deleteDocumentFile(DatabaseDocument<MemoryType> d, String fileName) { for (DocumentFile<MemoryType> f : files) { if (f.getDocumentId().equals(d.getID()) && f.getFileName().equals(fileName)) { files.remove(f); return true; } } return false; }
@Override public List<String> getDocumentFileNames(DatabaseDocument<MemoryType> d) { ArrayList<String> list = new ArrayList<String>(); for (DocumentFile<MemoryType> f : files) { if (f.getDocumentId().equals(d.getID())) { list.add(f.getFileName()); } } return list; }
@Override public void delete(DatabaseDocument<MongoType> d) { BasicDBObject dbo = new BasicDBObject(MongoDocument.MONGO_ID_KEY, d.getID().getID()); documents.remove(dbo, concern); }
@Override public void delete(DatabaseDocument<MemoryType> d) { deleteAllFiles(d); set.remove(getDocumentById(d.getID())); }
private String getDoneEvent(DatabaseDocument<?> doc) { StringBuffer sb = new StringBuffer(); sb.append(df.format(doc.getCompletedTime())); sb.append(" document="); sb.append(doc.getID()); sb.append(" type=done"); sb.append(" stage="); sb.append(doc.getCompletedBy()); sb.append(" time="); sb.append(doc.getCompletedTime().getTime()-doc.getFetchedTime(doc.getCompletedBy()).getTime()); sb.append(" totaltime="); sb.append(doc.getCompletedTime().getTime()-doc.getTouchedTime(getInserter(doc)).getTime()); return sb.toString(); }
@Override public boolean markPending(DatabaseDocument<MemoryType> d, String stage) { MemoryDocument temp = getDocumentById(d.getID()); if (temp == null) { return false; } temp.tag(Document.PENDING_METADATA_FLAG, stage); return true; }
@Override public void delete(DatabaseDocument<T> d) { cache.remove(d.getID()); writer.delete(d); }
@Override public boolean markTouched(DocumentID<T> id, String tag) { DatabaseDocument<T> inCache; synchronized (this) { inCache = getDocumentById(id); if (inCache != null) { freshen(inCache.getID()); inCache.setTouchedBy(tag, new Date()); return true; } } return false; }
private boolean markDone(DatabaseDocument<MemoryType> d, String stage, String flag) { MemoryDocument temp = getDocumentById(d.getID()); if (temp == null) { return false; } set.remove(temp); ((MemoryDocument) d).tag(flag, stage); deleteAllFiles(d); addInactive((MemoryDocument) d); return true; }
@Override public boolean markPending(DatabaseDocument<MongoType> d, String stage) { MongoQuery mq = new MongoQuery(); mq.requireID(d.getID()); DBObject update = new BasicDBObject(); update.put(MongoDocument.METADATA_KEY+"."+MongoDocument.PENDING_METADATA_FLAG+"."+MongoDocument.DATE_METADATA_SUBKEY, new Date()); update.put(MongoDocument.METADATA_KEY+"."+MongoDocument.PENDING_METADATA_FLAG+"."+MongoDocument.STAGE_METADATA_SUBKEY, stage); DBObject dbo = getUpdateObject(update); if(documents.findAndModify(mq.toDBObject(), dbo)==null) { return false; } return true; }