List of usage examples for com.mongodb BasicDBObject getString
public String getString(final String key)
From source file:com.images3.data.impl.MongoDBObjectMapper.java
License:Apache License
public ImageOS mapToImageOS(BasicDBObject source) { return new ImageOS(new ImageIdentity(source.getString("imagePlantId"), source.getString("id")), new Date(source.getLong("dateTime")), mapToImageMetadata((BasicDBObject) source.get("metadata")), mapToImageVersion((BasicDBObject) source.get("version"))); }
From source file:com.images3.data.impl.MongoDBObjectMapper.java
License:Apache License
public ImageMetadata mapToImageMetadata(BasicDBObject source) { return new ImageMetadata(mapToImageDimension((BasicDBObject) source.get("dimension")), ImageFormat.valueOf(source.getString("format")), source.getLong("size")); }
From source file:com.images3.data.impl.MongoDBObjectMapper.java
License:Apache License
public ImageVersion mapToImageVersion(BasicDBObject source) { return new ImageVersion(source.getString("templateName"), source.getString("originalImageId")); }
From source file:com.images3.data.impl.MongoDBObjectMapper.java
License:Apache License
public ImageMetricsOS mapToImageMetricsOS(BasicDBObject source) { Map<ImageMetricsType, Long> numbers = new HashMap<ImageMetricsType, Long>(); numbers.put(ImageMetricsType.COUNTS_INBOUND, (source.containsField(ImageMetricsType.COUNTS_INBOUND.toString()) ? source.getLong(ImageMetricsType.COUNTS_INBOUND.toString()) : 0L));/*from w ww.j av a 2s . co m*/ numbers.put(ImageMetricsType.COUNTS_OUTBOUND, (source.containsField(ImageMetricsType.COUNTS_OUTBOUND.toString()) ? source.getLong(ImageMetricsType.COUNTS_OUTBOUND.toString()) : 0L)); numbers.put(ImageMetricsType.SIZE_INBOUND, (source.containsField(ImageMetricsType.SIZE_INBOUND.toString()) ? source.getLong(ImageMetricsType.SIZE_INBOUND.toString()) : 0L)); numbers.put(ImageMetricsType.SIZE_OUTBOUND, (source.containsField(ImageMetricsType.SIZE_OUTBOUND.toString()) ? source.getLong(ImageMetricsType.SIZE_OUTBOUND.toString()) : 0L)); return new ImageMetricsOS(source.getString("imagePlantId"), source.getString("templateName"), source.getLong("second"), numbers); }
From source file:com.linuxbox.enkive.archiver.mongodb.MongoArchivingService.java
License:Open Source License
@Override public String storeMessage(Message message) throws CannotArchiveException, FailedToEmergencySaveException, AuditServiceException { String messageUUID = null;/*from w w w. j a v a 2 s . c o m*/ attachment_ids = new ArrayList<String>(); nested_message_ids = new ArrayList<String>(); String messageId = calculateMessageId(message); try { BasicDBObject messageObject = new BasicDBObject(); messageObject.put(MESSAGE_UUID, messageId); messageObject.put(ARCHIVE_TIME, new Date()); messageObject.put(ORIGINAL_HEADERS, message.getOriginalHeaders()); messageObject.put(MAIL_FROM, message.getMailFrom()); messageObject.put(RCPT_TO, message.getRcptTo()); messageObject.put(FROM, message.getFrom()); messageObject.put(TO, message.getTo()); messageObject.put(CC, message.getCc()); messageObject.put(DATE, message.getDate()); messageObject.put(SUBJECT, message.getSubject()); messageObject.put(MESSAGE_ID, message.getMessageId()); messageObject.put(MIME_VERSION, message.getMimeVersion()); messageObject.put(CONTENT_TYPE, message.getContentType()); messageObject.put(MESSAGE_DIFF, message.getMessageDiff()); ContentHeader contentHeader = message.getContentHeader(); if (message.getContentType().trim().toLowerCase() .equals(ContentTypeField.TYPE_MESSAGE_RFC822.toLowerCase())) { String subMessageUUID = storeNestedMessage( message.getContentHeader().getEncodedContentData().getEncodedContent(), message.getContentTransferEncoding()); if (!nested_message_ids.contains(subMessageUUID)) nested_message_ids.add(subMessageUUID); } messageObject.put(CONTENT_HEADER, archiveContentHeader(contentHeader)); messageObject.put(ATTACHMENT_ID_LIST, attachment_ids); messageObject.put(NESTED_MESSAGE_ID_LIST, nested_message_ids); messageColl.insert(messageObject); messageUUID = messageObject.getString(MESSAGE_UUID); } catch (MongoException e) { throw new CannotArchiveException(e); } catch (DocStoreException e) { throw new CannotArchiveException(e); } catch (ContentException e) { throw new CannotArchiveException(e); } if (LOGGER.isInfoEnabled()) LOGGER.info(MessageLoggingText.MESSAGE_STORED_TEXT + messageUUID); return messageUUID; }
From source file:com.linuxbox.enkive.workspace.mongo.MongoSearchQuery.java
License:Open Source License
@Override public void saveSearchQuery() throws WorkspaceException { BasicDBObject searchQueryObject = new BasicDBObject(); searchQueryObject.put(SEARCHNAME, getName()); searchQueryObject.put(SEARCHCRITERIA, getCriteria()); if (getId() != null && !getId().isEmpty()) { DBObject toUpdate = searchQueryColl.findOne(ObjectId.massageToObjectId(getId())); if (toUpdate != null) { searchQueryColl.update(toUpdate, searchQueryObject); searchQueryObject.put(UUID, toUpdate.get(UUID)); }// www .j a v a 2 s. co m } if (searchQueryObject.getString(UUID) == null) { searchQueryColl.insert(searchQueryObject); setId(searchQueryObject.getString(UUID)); } if (LOGGER.isInfoEnabled()) LOGGER.info("Saved Search Query - " + searchQueryObject.getString(UUID)); }
From source file:com.linuxbox.enkive.workspace.mongo.MongoSearchResult.java
License:Open Source License
@Override public void saveSearchResult() throws WorkspaceException { BasicDBObject searchResultObject = new BasicDBObject(); searchResultObject.put(EXECUTIONTIMESTAMP, getTimestamp()); searchResultObject.put(EXECUTEDBY, getExecutedBy()); searchResultObject.put(SEARCHRESULTS, getMessageIds()); searchResultObject.put(SEARCHSTATUS, getStatus().toString()); searchResultObject.put(SEARCHQUERYID, getSearchQueryId()); searchResultObject.put(SEARCHISSAVED, isSaved()); if (getId() != null && !getId().isEmpty()) { DBObject toUpdate = searchResultsColl.findOne(ObjectId.massageToObjectId(getId())); if (toUpdate != null) { searchResultsColl.update(toUpdate, searchResultObject); searchResultObject.put(UUID, toUpdate.get(UUID)); }/*w ww .j a v a 2 s . c o m*/ } if (searchResultObject.getString(UUID) == null) { searchResultsColl.insert(searchResultObject); setId(searchResultObject.getString(UUID)); } if (LOGGER.isInfoEnabled()) LOGGER.info("Saved Search Results - " + getId()); }
From source file:com.linuxbox.enkive.workspace.mongo.MongoWorkspace.java
License:Open Source License
@Override public void saveWorkspace() throws WorkspaceException { BasicDBObject workspaceObject = new BasicDBObject(); workspaceObject.put(MongoWorkspaceConstants.CREATIONDATE, getCreationDate()); workspaceObject.put(MongoWorkspaceConstants.MODIFIEDDATE, new Date(System.currentTimeMillis())); workspaceObject.put(MongoWorkspaceConstants.CREATOR, getCreator()); workspaceObject.put(MongoWorkspaceConstants.WORKSPACENAME, getWorkspaceName()); workspaceObject.put(MongoWorkspaceConstants.SEARCHRESULTS, getSearchResultUUIDs()); workspaceObject.put(MongoWorkspaceConstants.SEARCHFOLDERID, getSearchFolderID()); if (getWorkspaceUUID() != null && !getWorkspaceUUID().isEmpty()) { DBObject toUpdate = workspaceColl.findOne(ObjectId.massageToObjectId(getWorkspaceUUID())); if (toUpdate != null) { workspaceColl.update(toUpdate, workspaceObject); }/*from w w w . j a va2 s . c o m*/ } else { workspaceColl.insert(workspaceObject); setWorkspaceUUID(workspaceObject.getString(MongoWorkspaceConstants.UUID)); } if (LOGGER.isInfoEnabled()) LOGGER.info("Saved Workspace " + getWorkspaceName() + " - " + getWorkspaceUUID()); }
From source file:com.linuxbox.enkive.workspace.searchFolder.mongo.MongoSearchFolder.java
License:Open Source License
public void saveSearchFolder() { BasicDBObject searchFolderObject = new BasicDBObject(); Collection<String> searchResultIds = new HashSet<String>(); for (SearchFolderSearchResult result : results) { searchResultIds.add(result.getId()); }//from w ww .j a v a2 s .com searchFolderObject.put(MongoWorkspaceConstants.SEARCHRESULTSLIST, searchResultIds); if (getID() != null && !getID().isEmpty()) { searchFolderObject.put("_id", ObjectId.massageToObjectId(getID())); BasicDBObject searchFolderQueryObject = new BasicDBObject(); searchFolderQueryObject.put("_id", ObjectId.massageToObjectId(getID())); searchFolderColl.findAndModify(searchFolderQueryObject, searchFolderObject); } else { searchFolderColl.insert(searchFolderObject); setID(searchFolderObject.getString(MongoWorkspaceConstants.UUID)); } }
From source file:com.linuxbox.enkive.workspace.searchQuery.mongo.MongoSearchQuery.java
License:Open Source License
@Override public void saveSearchQuery() throws WorkspaceException { BasicDBObject searchQueryObject = new BasicDBObject(); searchQueryObject.put(SEARCHNAME, getName()); searchQueryObject.put(SEARCHRESULTID, result.getId()); searchQueryObject.put(SEARCHCRITERIA, getCriteria()); searchQueryObject.put(EXECUTIONTIMESTAMP, getTimestamp()); searchQueryObject.put(EXECUTEDBY, getExecutedBy()); searchQueryObject.put(SEARCHSTATUS, getStatus().toString()); searchQueryObject.put(SEARCHISSAVED, isSaved()); searchQueryObject.put(SEARCHISIMAP, isIMAP()); searchQueryObject.put(LASTMONOTONICID, getLastMonotonic()); searchQueryObject.put(IMAPUIDVALIDITY, getUIDValidity()); if (getId() != null && !getId().isEmpty()) { DBObject toUpdate = searchQueryColl.findOne(ObjectId.massageToObjectId(getId())); if (toUpdate != null) { searchQueryColl.update(toUpdate, searchQueryObject); searchQueryObject.put(UUID, toUpdate.get(UUID)); }//from w w w .j a va2s . c o m } if (searchQueryObject.getString(UUID) == null) { searchQueryColl.insert(searchQueryObject); setId(searchQueryObject.getString(UUID)); } result.saveSearchResult(); if (LOGGER.isInfoEnabled()) LOGGER.info("Saved Search Query - " + searchQueryObject.getString(UUID)); }