本文整理汇总了Java中com.orientechnologies.orient.core.record.impl.ODocument.fields方法的典型用法代码示例。如果您正苦于以下问题:Java ODocument.fields方法的具体用法?Java ODocument.fields怎么用?Java ODocument.fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orientechnologies.orient.core.record.impl.ODocument
的用法示例。
在下文中一共展示了ODocument.fields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: crawlSourceFile
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
private void crawlSourceFile(final File sourceFile, final String sha1, final String uri) {
Map<String, Object> fileContents = parser.processFile(sourceFile);
if (fileContents != null) {
fileContents.put(Attributes.ROOTPATH, getPathToRoot(sourceFile));
fileContents.put(String.valueOf(DocumentAttributes.SHA1), sha1);
fileContents.put(String.valueOf(DocumentAttributes.RENDERED), false);
if (fileContents.get(Attributes.TAGS) != null) {
// store them as a String[]
String[] tags = (String[]) fileContents.get(Attributes.TAGS);
fileContents.put(Attributes.TAGS, tags);
}
fileContents.put(Attributes.FILE, sourceFile.getPath());
fileContents.put(String.valueOf(DocumentAttributes.SOURCE_URI), uri);
fileContents.put(Attributes.URI, uri);
String documentType = (String) fileContents.get(Attributes.TYPE);
if (fileContents.get(Attributes.STATUS).equals(Status.PUBLISHED_DATE)) {
if (fileContents.get(Attributes.DATE) != null && (fileContents.get(Attributes.DATE) instanceof Date)) {
if (new Date().after((Date) fileContents.get(Attributes.DATE))) {
fileContents.put(Attributes.STATUS, Status.PUBLISHED);
}
}
}
if (config.getBoolean(Keys.URI_NO_EXTENSION)) {
fileContents.put(Attributes.NO_EXTENSION_URI, uri.replace("/index.html", "/"));
}
ODocument doc = new ODocument(documentType);
doc.fields(fileContents);
boolean cached = fileContents.get(DocumentAttributes.CACHED) != null ? Boolean.valueOf((String)fileContents.get(DocumentAttributes.CACHED)):true;
doc.field(String.valueOf(DocumentAttributes.CACHED), cached);
doc.save();
} else {
LOGGER.warn("{} has an invalid header, it has been ignored!", sourceFile);
}
}
示例2: testPagination
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@Test
public void testPagination() {
Map<String, Object> fileContents = new HashMap<String, Object>();
final int TOTAL_POSTS = 5;
final int PER_PAGE = 2;
for (int i = 1; i <= TOTAL_POSTS; i++) {
fileContents.put("name", "dummyfile" + i);
ODocument doc = new ODocument("post");
doc.fields(fileContents);
boolean cached = fileContents.get("cached") != null ? Boolean.valueOf((String) fileContents.get("cached")) : true;
doc.field("cached", cached);
doc.save();
}
int pageCount = 1;
int start = 0;
db.setLimit(PER_PAGE);
while (start < TOTAL_POSTS) {
db.setStart(start);
DocumentList posts = db.getAllContent("post");
int expectedNumber = (pageCount==1)?pageCount:((pageCount%2==0)?pageCount+1:pageCount+PER_PAGE);
Assert.assertEquals("pagcount " +pageCount,"dummyfile" + expectedNumber, posts.get(0).get("name"));
pageCount++;
start += PER_PAGE;
}
Assert.assertEquals(4, pageCount);
}
示例3: createFakeDocument
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
private void createFakeDocument(String name, Map<String, Object> fileContents) {
ODocument doc = new ODocument(name);
doc.fields(fileContents);
doc.save();
}
示例4: removeMetadata
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
public void removeMetadata(String key) {
ODocument metadata = getMetadataDocument();
metadata.removeField(key);
if (metadata.fields() == 0)
element.getRawDocument().removeField(metadataKey());
}