本文整理了Java中org.modeshape.schematic.document.Document.edit()
方法的一些代码示例,展示了Document.edit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Document.edit()
方法的具体详情如下:
包路径:org.modeshape.schematic.document.Document
类名称:Document
方法名:edit
[英]Obtains an editor for the supplied document. The editor allows the caller to make changes to the document and to obtain these changes as a Changes that can be applied to another document.
[中]获取所提供文档的编辑器。编辑器允许调用者对文档进行更改,并将这些更改作为可应用于其他文档的更改来获取。
代码示例来源:origin: org.fcrepo/modeshape-jcr
return this.doc.edit(true);
代码示例来源:origin: ModeShape/modeshape
return this.doc.edit(true);
代码示例来源:origin: ModeShape/modeshape
protected Properties datasourceConfig() {
Properties datasourceCfg = new Properties();
EditableDocument localCopy = config.edit(true);
// remove the generic configuration fields
ALL_FIELDS.forEach(localCopy::remove);
// convert each of the properties to their Hikari names
datasourceCfg.setProperty("jdbcUrl", connectionUrl);
datasourceCfg.setProperty("driverClassName", config.getString(DRIVER, DEFAULT_DRIVER));
datasourceCfg.setProperty("username", config.getString(USERNAME, DEFAULT_USERNAME));
datasourceCfg.setProperty("password", config.getString(PASSWORD, DEFAULT_PASSWORD));
datasourceCfg.setProperty("maximumPoolSize", propertyAsString(config, POOL_SIZE, DEFAULT_MAX_POOL_SIZE));
datasourceCfg.setProperty("minimumIdle", DEFAULT_MIN_IDLE);
datasourceCfg.setProperty("idleTimeout", DEFAULT_IDLE_TIMEOUT);
// pass all the other fields as they are (this will also overwrite any of the previous values if they are explicitly configured)
localCopy.fields().forEach(field -> datasourceCfg.setProperty(field.getName(), field.getValue().toString()));
return datasourceCfg;
}
代码示例来源:origin: ModeShape/modeshape
protected Document dbPersistenceConfiguration() {
EditableDocument config = super.defaultPersistenceConfiguration().edit(false);
//use a random mem db each time, to avoid possible conflicts....
config.setString(RepositoryConfiguration.FieldName.TYPE, RelationalDbConfig.ALIAS1);
config.setString(RelationalDbConfig.CONNECTION_URL, "jdbc:h2:mem:" + UUID.randomUUID().toString() + ";DB_CLOSE_DELAY=0");
config.setBoolean(RelationalDbConfig.DROP_ON_EXIT, true);
return config;
}
}
代码示例来源:origin: ModeShape/modeshape
@Test
public void shouldGetAndPut() throws Exception {
List<SchematicEntry> dbEntries = randomEntries(3);
//simulate the start of a transaction
db.txStarted("0");
//write some entries without committing
dbEntries.forEach(dbEntry -> db.put(dbEntry.id(), dbEntry.content()));
Set<String> expectedIds = dbEntries.stream().map(SchematicEntry::id).collect(Collectors.toCollection(TreeSet::new));
// check that the same connection is used and the entries are still there
assertTrue(db.keys().containsAll(expectedIds));
// simulate a commit for the write
db.txCommitted("0");
// check that the entries are still there
assertTrue(db.keys().containsAll(expectedIds));
// check that for each entry the content is correctly stored
dbEntries.stream().forEach(entry -> assertEquals(entry.content(), db.getEntry(entry.id()).content()));
// update one of the documents and check the update is correct
SchematicEntry firstEntry = dbEntries.get(0);
String idToUpdate = firstEntry.id();
EditableDocument updatedDocument = firstEntry.content().edit(true);
updatedDocument.setNumber(VALUE_FIELD, 2);
//simulate a new transaction
db.txStarted("1");
db.get(idToUpdate);
db.put(idToUpdate, updatedDocument);
assertEquals(updatedDocument, db.getEntry(idToUpdate).content());
db.txCommitted("1");
assertEquals(updatedDocument, db.getEntry(idToUpdate).content());
}
代码示例来源:origin: ModeShape/modeshape
@Test
public void shouldPutIfAbsent() throws Exception {
SchematicEntry entry = writeSingleEntry();
EditableDocument editableDocument = entry.content().edit(true);
editableDocument.setNumber(VALUE_FIELD, 100);
SchematicEntry updatedEntry = simulateTransaction(() -> db.putIfAbsent(entry.id(), entry.content()));
assertNotNull(updatedEntry);
assertEquals(1, (int) updatedEntry.content().getInteger(VALUE_FIELD));
SchematicEntry newEntry = SchematicEntry.create(UUID.randomUUID().toString(), DEFAULT_CONTENT);
assertNull(simulateTransaction(() -> db.putIfAbsent(newEntry.id(), newEntry.content())));
updatedEntry = db.getEntry(newEntry.id());
assertNotNull(updatedEntry);
}
内容来源于网络,如有侵权,请联系作者删除!