本文整理汇总了Java中com.orientechnologies.orient.core.record.impl.ODocument.getIdentity方法的典型用法代码示例。如果您正苦于以下问题:Java ODocument.getIdentity方法的具体用法?Java ODocument.getIdentity怎么用?Java ODocument.getIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orientechnologies.orient.core.record.impl.ODocument
的用法示例。
在下文中一共展示了ODocument.getIdentity方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: recordIdEncoding
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@Test
public void recordIdEncoding() throws Exception {
try (ODatabaseDocumentTx db = createDatabase()) {
ODocument doc = createPerson(db);
log("New Document: {}", doc);
ORID rid = doc.getIdentity();
log("RID: {}", rid);
String encoded = Hex.encode(rid.toStream());
log("Hex Encoded: {}", encoded);
ORID decoded = new ORecordId().fromStream(Hex.decode(encoded));
log("Decoded RID: {}", decoded);
assertThat(decoded, is(rid));
doc = db.getRecord(decoded);
log("Fetched Document: {}", doc);
}
}
示例3: createNode
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@Override
public OrientNode createNode(Map<String, Object> properties, String label) {
final String vertexTypeName = getVertexTypeName(label);
ensureClassExists(vertexTypeName);
ODocument newDoc = new ODocument(vertexTypeName);
if (properties != null) {
OrientNode.setProperties(newDoc, properties);
}
newDoc.save(vertexTypeName);
if (newDoc.getIdentity().isPersistent()) {
return new OrientNode(newDoc.getIdentity(), this);
} else {
return new OrientNode(newDoc, this);
}
}
示例4: getIndexStore
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
public OrientIndexStore getIndexStore() {
if (indexStore != null) {
return indexStore;
}
ODocument idIndexStore = getGraph().getDictionary().get(VCLASS);
OrientNode vIndexStore;
if (idIndexStore == null) {
final HashMap<String, Object> idxStoreProps = new HashMap<>();
vIndexStore = createNode(idxStoreProps, VCLASS);
getGraph().getDictionary().put(VCLASS, vIndexStore.getDocument());
indexStore = new OrientIndexStore(vIndexStore);
} else {
indexStore = new OrientIndexStore(new OrientNode(idIndexStore.getIdentity(), this));
}
return indexStore;
}
示例5: loadRelationsToModel
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@Override
protected void loadRelationsToModel(ODocument document) {
// for (OIdentifiable id : new OSQLSynchQuery<ODocument>("select expand( out() ) from " + vertex.getId())) {
try {
for (OIdentifiable id : new OSQLSynchQuery<ODocument>("traverse out(" + ImotEdge.class.getSimpleName() +
") from " + document.getIdentity() + " while $depth <= 1")) {
if (ImotVertex.class.getSimpleName().equals(((ODocument) id.getRecord()).getClassName())) {
ODocument doc = (ODocument) id.getRecord();
user.addImot((Imot) new ImotVertex(new Imot(null)).load(doc).model());
}
}
} catch (Throwable t) {
t.printStackTrace();
}
}
示例6: findNextPageOfUnusedSnapshots
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
/**
* Finds the next page of snapshot components that were last accessed before the specified date. The date when a
* component was last downloaded is the last time an asset of that snapshot was downloaded.
*
* Uses an iterative approach in order to handle large repositories with many hundreds of thousands or millions of
* assets. Note the current implementation is a bit hacky due to an Orient bug which prevents us from using a GROUP
* BY with LIMIT. Furthermore, because of the required use of the Orient 'script sql' approach, we must loop through
* the entire component set. Forward looking to Orient 3, it fixes the GROUP BY approach and this can be much
* simplified. See NEXUS-13130 for further details.
*/
private List<Component> findNextPageOfUnusedSnapshots(final StorageTx tx,
final LocalDate olderThan,
final ORID bucketId,
final String unusedWhereTemplate)
{
String query = format(UNUSED_QUERY, bucketId, lastComponent, findUnusedLimit, unusedWhereTemplate, olderThan,
findUnusedLimit - 1);
List<ODocument> result = tx.getDb().command(new OCommandScript("sql", query)).execute();
if (isEmpty(result)) {
return emptyList();
}
// get the last component to use in the WHERE for the next page
ODocument lastDoc = Iterables.getLast(result).field(P_COMPONENT);
lastComponent = lastDoc.getIdentity();
Date olderThanDate = java.sql.Date.valueOf(olderThan);
// filters in this stream are to check the last record as all others are filtered out in the 3rd part of the command query
return result.stream() // remove entries that don't match on last download date
.filter(entries -> {
Date lastDownloaded = entries.field("lastdownloaded");
return lastDownloaded.compareTo(olderThanDate) < 0;
})
.map(doc -> componentEntityAdapter.readEntity(doc.field(P_COMPONENT)))
// remove entries that are not snapshots
.filter(
component -> {
String baseVersion = (String) component.attributes().child(Maven2Format.NAME).get(P_BASE_VERSION);
return baseVersion != null && baseVersion.endsWith("SNAPSHOT");
})
.collect(Collectors.toList());
}
示例7: documentExistance
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@Test
public void documentExistance() throws Exception {
try (ODatabaseDocumentTx db = createDatabase()) {
ODocument doc = createPerson(db);
log("Document: {}", doc);
ORID rid = doc.getIdentity();
log("RID: {}", rid);
ORecordMetadata md = db.getRecordMetadata(rid);
log("Metadata: {}", md);
assertThat(md, notNullValue());
}
}
示例8: iterator
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@Override
public Iterator<OIdentifiable> iterator() {
final int clusterId = db.getGraph().getClusterIdByName(clusterName);
if (clusterId == -1) {
return Collections.emptyListIterator();
}
final ORecordIteratorCluster<ODocument> it = db.getGraph().browseCluster(clusterName);
return new Iterator<OIdentifiable>(){
@Override
public boolean hasNext() {
return it.hasNext();
}
@Override
public OIdentifiable next() {
final ODocument doc = it.next();
final ORID id = doc.getIdentity();
if (id.isPersistent()) {
return id;
} else {
return doc;
}
}
@Override
public void remove() {
it.remove();
}
};
}
示例9: apply
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@Override
public void apply() throws Exception {
try (ODatabaseDocumentTx db = databaseInstance.get().connect()) {
OSchema schema = db.getMetadata().getSchema();
OClass type = schema.getClass("audit_data");
if (type != null) {
// is there more than one data cluster?
int[] clusterIds = type.getClusterIds();
if (clusterIds.length > 1) {
// reset default to primary cluster
int primaryClusterId = clusterIds[0];
type.setDefaultClusterId(primaryClusterId);
log.info("Moving events to primary cluster {}", db.getClusterNameById(primaryClusterId));
int moveCount = 0;
// move all records to primary cluster
for (ODocument document : db.browseClass(type.getName())) {
ORID rid = document.getIdentity();
if (rid.getClusterId() != primaryClusterId) {
db.save(new ODocument(document.toStream()));
db.delete(rid);
moveCount++;
}
}
log.info("Moved {} events", moveCount);
// delete all secondary clusters
for (int clusterId : clusterIds) {
if (clusterId != primaryClusterId) {
log.info("Dropping secondary cluster {}", db.getClusterNameById(clusterId));
db.dropCluster(clusterId, false);
}
}
}
}
}
}
示例10: AttachedEntityMetadata
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
public AttachedEntityMetadata(final EntityAdapter owner, final ODocument document) {
this.owner = checkNotNull(owner);
this.document = checkNotNull(document);
this.id = new AttachedEntityId(owner, document.getIdentity());
this.version = new AttachedEntityVersion(owner, document.getVersion());
}
示例11: create
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
public static IGraphEdge create(OrientDatabase graph, OrientNode start, OrientNode end, String type, String edgeTypeName, Map<String, Object> props) {
if (props != null && !props.isEmpty()) {
// Has properties - heavyweight edge
ODocument newDoc = new ODocument(edgeTypeName);
newDoc.field(TYPE_PROPERTY, type);
final ODocument startDoc = start.getDocument();
final ORID startId = startDoc.getIdentity();
if (startId.isPersistent()) {
newDoc.field(FROM_PROPERTY, startId);
} else {
newDoc.field(FROM_PROPERTY, startDoc);
}
final ODocument endDoc = end.getDocument();
final ORID endId = endDoc.getIdentity();
if (endId.isPersistent()) {
newDoc.field(TO_PROPERTY, endId);
} else {
newDoc.field(TO_PROPERTY, endDoc);
}
if (props != null) {
for (Entry<String, Object> entry : props.entrySet()) {
newDoc.field(entry.getKey(), entry.getValue());
}
}
newDoc.save(edgeTypeName);
OrientEdge newEdge;
if (newDoc.getIdentity().isPersistent()) {
newEdge = new OrientEdge(newDoc.getIdentity(), graph);
} else {
newEdge = new OrientEdge(newDoc, graph);
}
start.addOutgoing(newDoc, type);
end.addIncoming(newDoc, type);
return newEdge;
} else {
// No properties - lightweight edge
start.addOutgoing(end.getDocument(), type);
end.addIncoming(start.getDocument(), type);
return new OrientLightEdge(start, end, type);
}
}
示例12: OrientNode
import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
/** Should only be used with non-persistent IDs. */
public OrientNode(ODocument doc, OrientDatabase graph) {
this.graph = graph;
this.changedVertex = doc;
this.id = doc.getIdentity();
}