本文整理汇总了Java中com.orientechnologies.orient.core.record.impl.ODocument.field方法的典型用法代码示例。如果您正苦于以下问题:Java ODocument.field方法的具体用法?Java ODocument.field怎么用?Java ODocument.field使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orientechnologies.orient.core.record.impl.ODocument
的用法示例。
在下文中一共展示了ODocument.field方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOrMakeDBResult
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private List<ODocument> getOrMakeDBResult(Object result) throws OdaException{
if (!(result instanceof List)){
throw new OdaException("OrientDB query result is not a list!");
}
List<ODocument> dbResult = (List<ODocument>) result;
if (dbResult.size()>0){
return dbResult;
}else{
List<ODocument> fakeDBResult = new ArrayList<ODocument>(1);
ODocument fakeDBResultdoc = new ODocument();
fakeDBResultdoc.field("emptyResult", "");
fakeDBResult.add(fakeDBResultdoc);
return fakeDBResult;
}
}
示例2: ResultSet
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public ResultSet(Object sqlResult, ResultSetMetaData metadata) {
if (sqlResult instanceof List && !((List)sqlResult).isEmpty() ){
this.sqlResult = (List<ODocument>)sqlResult;
}else{
this.sqlResult = new ArrayList<ODocument>(1);
if (sqlResult instanceof ODocument){
this.sqlResult.add((ODocument)sqlResult);
}else{
ODocument newDoc = new ODocument();
newDoc.field("result",sqlResult);
this.sqlResult.add(newDoc);
}
}
m_currentRowId=0;
currentRow = this.sqlResult.get(m_currentRowId);
this.metadata = metadata;
}
示例3: convertToCatalogLinkIfAble
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
private Object convertToCatalogLinkIfAble(Object value,OProperty fieldProperty,ODocument mainDoc){
String catalogsLinkNameAttribute = getOrientDBEndpoint().getCatalogsLinkAttr();//
String catalogsLinkName = getOrientDBEndpoint().getCatalogsLinkName();//
String catalogNameField = fieldProperty.getLinkedClass().getCustom(catalogsLinkNameAttribute);
if (catalogNameField==null){
catalogNameField = catalogsLinkName;
}
List<OIdentifiable> catalogLinks = curDb.query(new OSQLSynchQuery<OIdentifiable>(
"select from "+fieldProperty.getLinkedClass().getName()+" where "+catalogNameField+"=?"), value);
if (catalogLinks.size()>0){
value = catalogLinks.get(0).getIdentity();
}else{
boolean updateCatalogs = getOrientDBEndpoint().isCatalogsUpdate();//
if (updateCatalogs){
ODocument catalogRecord = new ODocument(fieldProperty.getLinkedClass());
catalogRecord.field(catalogNameField,value);
catalogRecord.save(true);
value = catalogRecord.getIdentity();
}
}
return value;
}
示例4: createItem
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
private ODocument createItem(int id, ODocument doc)
{
String itemKey = Integer.valueOf(id).toString();
doc.setClassName("Item");
doc.field("stringKey", itemKey);
doc.field("intKey", id);
String contents = "OrientDB is a deeply scalable Document-Graph DBMS with the flexibility of the Document databases and the power to manage links of the Graph databases. " + "It can work in schema-less mode, schema-full or a mix of both. Supports advanced features such as ACID Transactions, Fast Indexes, Native and SQL queries." + " It imports and exports documents in JSON." + " Graphs of hundreads of linked documents can be retrieved all in memory in few milliseconds without executing costly JOIN such as the Relational DBMSs do. " + "OrientDB uses a new indexing algorithm called MVRB-Tree, derived from the Red-Black Tree and from the B+Tree with benefits of both: fast insertion and ultra fast lookup. " + "The transactional engine can run in distributed systems supporting up to 9.223.372.036 Billions of records for the maximum capacity of 19.807.040.628.566.084 Terabytes of data distributed on multiple disks in multiple nodes. " + "OrientDB is FREE for any use. Open Source License Apache 2.0. ";
doc.field("text", contents);
doc.field("title", "orientDB");
doc.field("length", contents.length());
doc.field("published", (id % 2 > 0));
doc.field("author", "anAuthor" + id);
// doc.field("tags", asList("java", "orient", "nosql"), OType.EMBEDDEDLIST);
Calendar instance = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
instance.add(Calendar.HOUR_OF_DAY, -id);
Date time = instance.getTime();
doc.field("date", time, OType.DATE);
doc.field("time", time, OType.DATETIME);
return doc;
}
示例5: rebuildMetadata
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
/**
* Method rebuilding metadata that performs the group level processing. It uses memory conservative "async" SQL
* approach, and calls {@link #rebuildMetadataInner(String, String, Set)} method as results are arriving.
*/
public void rebuildMetadata()
{
checkCancellation();
String currentGroupId = null;
for (ODocument doc : browseGAVs()) {
checkCancellation();
final String groupId = doc.field("groupId", OType.STRING);
final String artifactId = doc.field("artifactId", OType.STRING);
final Set<String> baseVersions = doc.field("baseVersions", OType.EMBEDDEDSET);
final boolean groupChange = !Objects.equals(currentGroupId, groupId);
if (groupChange) {
if (currentGroupId != null) {
rebuildMetadataExitGroup(currentGroupId);
}
currentGroupId = groupId;
metadataBuilder.onEnterGroupId(groupId);
}
rebuildMetadataInner(groupId, artifactId, baseVersions);
}
if (currentGroupId != null) {
rebuildMetadataExitGroup(currentGroupId);
}
}
示例6: delete
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
public void delete() {
final OrientNode startNode = getStartNode();
final OrientNode endNode = getEndNode();
final ODocument doc = getDocument();
final String edgeType = (String) doc.field(TYPE_PROPERTY);
startNode.removeOutgoing(doc, edgeType);
endNode.removeIncoming(doc, edgeType);
db.markNodeAsDirty(startNode);
db.markNodeAsDirty(endNode);
db.unmarkEdgeAsDirty(this);
db.getGraph().delete(getId());
changedEdge = null;
}
示例7: updateDocumentNameWithModifier
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
private Rename updateDocumentNameWithModifier(final ODocument document,
final int modifier)
{
String name = document.field(P_NAME, String.class);
if (modifier == 0) {
log.debug("BlobStore {} name will not be updated");
return null;
}
String newName = name + "-" + Integer.toString(modifier);
log.info("BlobStore {} will be renamed to {}", name, newName);
document.field(P_NAME, newName).save();
return new Rename(newName, name);
}
示例8: afterWorkItem
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@Override
public void afterWorkItem(ODocument doc) {
if (value != null) {
// don't just overwrite existing comments, because they contain jira export history
List<Comment> comments = doc.field(FieldNames.COMMENTS);
if (comments == null) {
comments = new ArrayList<>();
}
for (IComment rtcCom : value) {
Contributor rtcCreator = fetchCompleteItem(rtcCom.getCreator());
String creatorEmail = rtcCreator.getEmailAddress();
String creatorName = rtcCreator.getName();
Date creationDate = new Date(rtcCom.getCreationDate().getTime());
String plainTextComment = rtcCom.getHTMLContent().getPlainText();
Comment comment = new Comment(creatorName, creatorEmail, creationDate, plainTextComment);
if (!comments.contains(comment)) {
comments.add(comment);
}
}
if (!comments.isEmpty()) {
doc.field(FieldNames.COMMENTS, comments);
}
}
}
示例9: 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);
}
}
示例10: 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);
}
示例11: prepare
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@Override
public void prepare(String query) throws OdaException {
queryText = query;
List<ODocument> resultList = doQuery(Query.truncateQuery(query),1);
if(resultList.isEmpty()){
ODocument newDoc = new ODocument();
newDoc.field("result",(Object)null);
curMetaData = new ResultSetMetaData(newDoc);
}else{
curMetaData = new ResultSetMetaData(resultList.get(0));
}
}
示例12: getMap
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
protected Map<String, Object> getMap(final ORecord record) {
Map<String, Object> map = null;
if (record instanceof ODocument) {
final ODocument doc = (ODocument) record;
final Set<String> syncFields = esClient.getSyncFields(doc);
if (syncFields == null)
return null;
map = new HashMap<String, Object>();
map.put("@rid", doc.getIdentity());
map.put("@class", doc.getClassName());
for (String f : doc.fieldNames()) {
if (!syncFields.isEmpty() && !syncFields.contains(f))
// SKIP FIELD
continue;
final Object value = doc.field(f);
if (value instanceof ORidBag) {
final List<OIdentifiable> list = new ArrayList<OIdentifiable>();
for (Iterator<OIdentifiable> it = ((ORidBag) value).rawIterator(); it.hasNext(); ) {
list.add(it.next());
}
map.put(f, list);
} else if (value instanceof ORecord && ((ORecord) value).getIdentity().isPersistent()) {
map.put(f, ((ORecord) value).getIdentity());
} else
map.put(f, value);
}
}
return map;
}
示例13: addPerson
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
public ODocument addPerson(String name) {
try (ODatabaseDocumentTx database = databasePool.acquire()) {
ODocument document = new ODocument("Person");
document.field("name", name);
database.commit();
return document.save();
}
}
示例14: filter
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@Override
public void filter(String type, String value) {
try (ODatabaseDocumentTx db = docDb()) {
ODocument newFilter = db.newInstance("Filter");
newFilter.field("type", type);
newFilter.field("value", value);
newFilter.save();
}
}
示例15: init
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@BeforeClass
public void init() {
initDB();
OSchema schema = databaseDocumentTx.getMetadata().getSchema();
OClass v = schema.getClass("V");
OClass oClass = schema.createClass("City");
oClass.setSuperClass(v);
oClass.createProperty("location", OType.EMBEDDED, schema.getClass("OPoint"));
oClass.createProperty("name", OType.STRING);
OClass place = schema.createClass("Place");
place.setSuperClass(v);
place.createProperty("latitude", OType.DOUBLE);
place.createProperty("longitude", OType.DOUBLE);
place.createProperty("name", OType.STRING);
databaseDocumentTx.command(new OCommandSQL("CREATE INDEX City.location ON City(location) SPATIAL ENGINE LUCENE")).execute();
databaseDocumentTx.command(new OCommandSQL("CREATE INDEX Place.l_lon ON Place(latitude,longitude) SPATIAL ENGINE LUCENE"))
.execute();
ODocument rome = newCity("Rome", 12.5, 41.9);
ODocument london = newCity("London", -0.1275, 51.507222);
ODocument rome1 = new ODocument("Place");
rome1.field("name", "Rome");
rome1.field("latitude", 41.9);
rome1.field("longitude", 12.5);
databaseDocumentTx.save(rome1);
databaseDocumentTx.save(rome);
databaseDocumentTx.save(london);
databaseDocumentTx.command(new OCommandSQL("insert into City set name = 'Test' , location = ST_GeomFromText('" + PWKT + "')"))
.execute();
}