本文整理汇总了Java中org.ojai.store.DocumentMutation类的典型用法代码示例。如果您正苦于以下问题:Java DocumentMutation类的具体用法?Java DocumentMutation怎么用?Java DocumentMutation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentMutation类属于org.ojai.store包,在下文中一共展示了DocumentMutation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param id identifier of document, which will be updated.
* @param artistRate artist rate.
* @return updated artist rate.
*/
@Override
public ArtistRate update(String id, ArtistRate artistRate) {
return processStore((connection, store) -> {
Stopwatch stopwatch = Stopwatch.createStarted();
// Create a DocumentMutation to update non-null fields
DocumentMutation mutation = connection.newMutation();
// Update only non-null fields
if (artistRate.getRating() != null) {
mutation.set("rating", artistRate.getRating());
}
// Update the OJAI Document with specified identifier
store.update(id, mutation);
Document updatedOjaiDoc = store.findById(id);
log.debug("Update document from table '{}' with id: '{}'. Elapsed time: {}", tablePath, id, stopwatch);
// Map Ojai document to the actual instance of model class
return mapOjaiDocument(updatedOjaiDoc);
});
}
示例2: update
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param id identifier of document, which will be updated.
* @param id identifier of document, which will be updated.
* @param statistic statistic.
* @return updated statistic.
*/
@Override
public Statistic update(String id, Statistic statistic) {
return processStore((connection, store) -> {
Stopwatch stopwatch = Stopwatch.createStarted();
// Create a DocumentMutation to update non-null fields
DocumentMutation mutation = connection.newMutation();
// Update only non-null fields
if (statistic.getDocumentNumber() != null) {
mutation.set("document_number", statistic.getDocumentNumber());
}
// Update the OJAI Document with specified identifier
store.update(id, mutation);
Document updatedOjaiDoc = store.findById(id);
log.debug("Update document from table '{}' with id: '{}'. Elapsed time: {}", tablePath, id, stopwatch);
// Map Ojai document to the actual instance of model class
return mapOjaiDocument(updatedOjaiDoc);
});
}
示例3: update
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param id identifier of document, which will be updated.
* @param albumRate album rate.
* @return updated album rate.
*/
@Override
public AlbumRate update(String id, AlbumRate albumRate) {
return processStore((connection, store) -> {
Stopwatch stopwatch = Stopwatch.createStarted();
// Create a DocumentMutation to update non-null fields
DocumentMutation mutation = connection.newMutation();
// Update only non-null fields
if (albumRate.getRating() != null) {
mutation.set("rating", albumRate.getRating());
}
// Update the OJAI Document with specified identifier
store.update(id, mutation);
Document updatedOjaiDoc = store.findById(id);
log.debug("Update document from table '{}' with id: '{}'. Elapsed time: {}", tablePath, id, stopwatch);
// Map Ojai document to the actual instance of model class
return mapOjaiDocument(updatedOjaiDoc);
});
}
示例4: update
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param id identifier of album, which will be updated.
* @param album contains album info that will be updated.
* @return updated album.
*/
@Override
@SuppressWarnings("unchecked")
public Album update(String id, Album album) {
return processStore((connection, store) -> {
Stopwatch stopwatch = Stopwatch.createStarted();
// Update basic fields
DocumentMutation albumMutation = AlbumMutationBuilder.forConnection(connection)
.setName(album.getName())
.setBarcode(album.getBarcode())
.setCountry(album.getCountry())
.setLanguage(album.getLanguage())
.setPackaging(album.getPackaging())
.setTrackList(album.getTrackList())
.setArtists(album.getArtists())
.setFormat(album.getFormat())
.setDateDay(album.getReleasedDate())
.setRating(album.getRating())
.build();
// Set update info if available
getUpdateInfo().ifPresent(updateInfo -> albumMutation.set("update_info", updateInfo));
// Update the OJAI Document with specified identifier
store.update(id, albumMutation);
Document updatedOjaiDoc = store.findById(id);
log.debug("Update document from table '{}' with id: '{}'. Elapsed time: {}", tablePath, id, stopwatch);
// Map Ojai document to the actual instance of model class
return mapOjaiDocument(updatedOjaiDoc);
});
}
示例5: deleteTrack
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
/**
* Deletes single track according to the specified album identifier and track identifier.
*
* @param albumId identifier of album, for which track will be deleted.
* @param trackId identifier of track, which will be deleted.
* @return <code>true</code> if track is successfully deleted, <code>false</code> otherwise.
*/
public boolean deleteTrack(String albumId, String trackId) {
List<Track> existingAlbumTracks = getTracksList(albumId);
if (existingAlbumTracks == null) {
return false;
}
int trackIndex = getTrackIndexById(existingAlbumTracks, trackId);
if (trackIndex < 0) {
return false;
}
return processStore((connection, store) -> {
Stopwatch stopwatch = Stopwatch.createStarted();
// Delete single track
DocumentMutation mutation = AlbumMutationBuilder.forConnection(connection)
.deleteTrack(trackIndex).build();
// Set update info if available
getUpdateInfo().ifPresent(updateInfo -> mutation.set("update_info", updateInfo));
// Update the OJAI Document with specified identifier
store.update(albumId, mutation);
log.debug("Deleting album's track with id: '{}' for albumId: '{}' took {}", trackId, albumId, stopwatch);
return true;
});
}
示例6: update
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
@Override
public User update(String id, User user) {
return processStore((connection, store) -> {
Stopwatch stopwatch = Stopwatch.createStarted();
// Create a DocumentMutation to update non-null fields
DocumentMutation mutation = connection.newMutation();
// Update only non-null fields
if (user.getFirstName() != null) {
mutation.set("first_name", user.getFirstName());
}
if (user.getLastName() != null) {
mutation.set("last_name", user.getLastName());
}
// Update the OJAI Document with specified identifier
store.update(id, mutation);
Document updatedOjaiDoc = store.findById(id);
log.debug("Update document from table '{}' with id: '{}'. Elapsed time: {}", tablePath, id, stopwatch);
// Map Ojai document to the actual instance of model class
return mapOjaiDocument(updatedOjaiDoc);
});
}
示例7: newSimulation
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
public void newSimulation(){
DocumentMutation mutation = MapRDB.newMutation().
setOrReplace("time", new Date().getTime()).
increment("simulationId", 1);
simulationTable.update(SIMULATION_KEY, mutation);
addInitialStats();
}
示例8: addNewClickToPage
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
private void addNewClickToPage(String s) {
// add clicks to the document
Document clickDetail = Json.newDocument()
.set("ip", "54.54.54.54")
.set("at", new OTimestamp(new java.util.Date()));
DocumentMutation mutation = MapRDB.newMutation()
.increment("nb_of_clicks", 1)
.append("X", "X")
.append("clicks", Arrays.asList(clickDetail));
table.update("index.html", mutation);
}
示例9: createDocumentMutationInternal
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
@Override
protected DocumentMutation createDocumentMutationInternal() {
if(connection == null) {
startConnection();
}
return connection.newMutation();
}
示例10: createDocumentMutation
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
public static DocumentMutation createDocumentMutation() {
if(isTest) {
Preconditions.checkNotNull(testDelegate);
return testDelegate.createDocumentMutationInternal();
} else {
Preconditions.checkNotNull(delegate);
return delegate.createDocumentMutationInternal();
}
}
示例11: commitMutation
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
public static void commitMutation(String tableName, String fieldPath, DocumentMutation documentMutation) throws MapRJsonDocumentLoaderException {
if(isTest) {
Preconditions.checkNotNull(testDelegate);
testDelegate.commitMutationInternal(tableName, fieldPath, documentMutation);
} else {
Preconditions.checkNotNull(delegate);
delegate.commitMutationInternal(tableName, fieldPath, documentMutation);
}
}
示例12: performUpdateOperation
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
private void performUpdateOperation(Record rec) throws StageException {
ByteArrayOutputStream os = new ByteArrayOutputStream(1024 * 1024);
createJson(os, rec);
DocumentMutation document = populateDocumentMutation(rec);
doUpdate(document, rec);
flush();
}
示例13: update
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param id identifier of document, which will be updated.
* @param artist contains artist info that will be updated.
* @return updated artist.
*/
@Override
public Artist update(String id, Artist artist) {
return processStore((connection, store) -> {
Stopwatch stopwatch = Stopwatch.createStarted();
// Create a DocumentMutation to update non-null fields
DocumentMutation mutation = connection.newMutation();
// Update only non-null fields
if (artist.getName() != null) {
mutation.set("name", artist.getName());
}
if (artist.getGender() != null) {
mutation.set("gender", artist.getGender());
}
if (artist.getBeginDate() != null) {
mutation.set("begin_date", artist.getBeginDate());
}
if (artist.getEndDate() != null) {
mutation.set("end_date", artist.getEndDate());
}
if (artist.getIpi() != null) {
mutation.set("IPI", artist.getIpi());
}
if (artist.getIsni() != null) {
mutation.set("ISNI", artist.getIsni());
}
if (artist.getArea() != null) {
mutation.set("area", artist.getArea());
}
if (artist.getAlbums() != null) {
List<Map> albumsMapList = artist.getAlbums().stream()
.map(album -> mapper.convertValue(album, Map.class))
.collect(Collectors.toList());
mutation.set("albums", albumsMapList);
}
if (artist.getProfileImageUrl() != null) {
mutation.set("profile_image_url", artist.getProfileImageUrl());
}
if (artist.getDeleted() != null) {
mutation.set("deleted", artist.getDeleted());
}
if (artist.getRating() != null) {
mutation.set("rating", artist.getRating());
}
// Set update info if available
getUpdateInfo().ifPresent(updateInfo -> mutation.set("update_info", updateInfo));
// Update the OJAI Document with specified identifier
store.update(id, mutation);
Document updatedOjaiDoc = store.findById(id);
log.debug("Update document from table '{}' with id: '{}'. Elapsed time: {}", tablePath, id, stopwatch);
// Map Ojai document to the actual instance of model class
return mapOjaiDocument(updatedOjaiDoc);
});
}
示例14: build
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
public DocumentMutation build() {
return this.mutation;
}
示例15: newMutation
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
@Override
public DocumentMutation newMutation() {
throw new UnsupportedOperationException();
}