本文整理汇总了Java中com.orientechnologies.orient.core.id.ORID类的典型用法代码示例。如果您正苦于以下问题:Java ORID类的具体用法?Java ORID怎么用?Java ORID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ORID类属于com.orientechnologies.orient.core.id包,在下文中一共展示了ORID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newComponentDoc
import com.orientechnologies.orient.core.id.ORID; //导入依赖的package包/类
private ODocument newComponentDoc(final TestData testData) {
ORID id = new ORecordId(1, clusterPosition++);
ODocument componentDoc = new ODocument(id);
componentDoc.field(P_NAME, testData.artifactId);
componentDoc.field(P_BUCKET, bucketEntityAdapter.recordIdentity(bucket));
componentDoc.field(P_FORMAT, "maven2");
Map<String, Object> mavenAttributes = new HashMap<>();
mavenAttributes.put(P_GROUP_ID, testData.groupId);
mavenAttributes.put(P_ARTIFACT_ID, testData.artifactId);
mavenAttributes.put(P_BASE_VERSION, testData.baseVersion);
Map<String, Object> map = new HashMap<>();
map.put("maven2", mavenAttributes);
componentDoc.field(P_ATTRIBUTES, map);
return componentDoc;
}
示例2: encode
import com.orientechnologies.orient.core.id.ORID; //导入依赖的package包/类
/**
* @see #doEncode(OClass, ORID)
*/
@Override
public String encode(final OClass type, final ORID rid) {
checkNotNull(type);
checkNotNull(rid);
log.trace("Encoding: {}->{}", type, rid);
try {
return doEncode(type, rid);
}
catch (Exception e) {
log.error("Failed to encode: {}->{}", type, rid);
Throwables.throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
示例3: decode
import com.orientechnologies.orient.core.id.ORID; //导入依赖的package包/类
/**
* @see #doDecode(OClass, String)
*/
@Override
public ORID decode(final OClass type, final String encoded) {
checkNotNull(type);
checkNotNull(encoded);
log.trace("Decoding: {}->{}", type, encoded);
ORID rid;
try {
rid = doDecode(type, encoded);
}
catch (Exception e) {
log.error("Failed to decode: {}->{}", type, encoded);
Throwables.throwIfUnchecked(e);
throw new RuntimeException(e);
}
// ensure rid points to the right type
checkArgument(Ints.contains(type.getClusterIds(), rid.getClusterId()),
"Invalid RID '%s' for class: %s", rid, type);
return rid;
}
示例4: recordIdEncoding
import com.orientechnologies.orient.core.id.ORID; //导入依赖的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);
}
}
示例5: verifyIdTypeMismatchFails
import com.orientechnologies.orient.core.id.ORID; //导入依赖的package包/类
@Test
public void verifyIdTypeMismatchFails() {
ORID rid = new ORecordId("#9:1");
OClass type = mock(OClass.class);
when(type.getClusterIds()).thenReturn(new int[] { 1 });
String encoded = underTest.encode(type, rid);
// this should fail since the cluster-id of the RID is not a member of the given type
try {
underTest.decode(type, encoded);
fail();
}
catch (IllegalArgumentException e) {
// expected
}
}
示例6: syncIndex
import com.orientechnologies.orient.core.id.ORID; //导入依赖的package包/类
private void syncIndex(final Map<ORID, EntityAdapter> changes) {
IndexBatchRequest batch = new IndexBatchRequest();
try (ODatabaseDocumentTx db = componentDatabase.get().acquire()) {
changes.forEach((rid, adapter) -> {
ODocument document = db.load(rid);
if (document != null) {
EntityId componentId = findComponentId(document);
if (componentId != null) {
batch.update(findRepositoryName(document), componentId);
}
}
else if (adapter instanceof ComponentEntityAdapter) {
batch.delete(null, componentId(rid));
}
});
}
indexRequestProcessor.process(batch);
}
示例7: getById
import com.orientechnologies.orient.core.id.ORID; //导入依赖的package包/类
private <T extends MetadataNode<?>> T getById(final ORID orid,
final Repository repository,
final String tableName,
final MetadataNodeEntityAdapter<T> adapter)
{
String sql = format("SELECT * FROM %s WHERE contentAuth(@this, :browsedRepository) == true AND @RID == :rid",
tableName);
Map<String, Object> params = ImmutableMap
.of("browsedRepository", repository.getName(), "rid", orid.toString());
try (StorageTx storageTx = repository.facet(StorageFacet.class).txSupplier().get()) {
storageTx.begin();
return stream(storageTx.browse(sql, params).spliterator(), false)
.map(adapter::readEntity).findFirst().orElse(null);
}
}
示例8: newEvent
import com.orientechnologies.orient.core.id.ORID; //导入依赖的package包/类
@Override
public EntityEvent newEvent(final ODocument document, final EventKind eventKind) {
EntityMetadata metadata = new AttachedEntityMetadata(this, document);
String repositoryName = ((ODocument) document.field(P_BUCKET)).field(P_REPOSITORY_NAME);
ORID rid = document.field(P_COMPONENT, ORID.class);
EntityId componentId = rid != null ? new AttachedEntityId(componentEntityAdapter, rid) : null;
switch (eventKind) {
case CREATE:
return new AssetCreatedEvent(metadata, repositoryName, componentId);
case UPDATE:
return new AssetUpdatedEvent(metadata, repositoryName, componentId);
case DELETE:
return new AssetDeletedEvent(metadata, repositoryName, componentId);
default:
return null;
}
}
示例9: readFields
import com.orientechnologies.orient.core.id.ORID; //导入依赖的package包/类
@Override
protected void readFields(final ODocument document, final BrowseNode entity) throws Exception {
String repositoryName = document.field(P_REPOSITORY_NAME, OType.STRING);
String parentPath = document.field(P_PARENT_PATH, OType.STRING);
String name = document.field(P_NAME, OType.STRING);
entity.setRepositoryName(repositoryName);
entity.setParentPath(parentPath);
entity.setName(name);
ORID componentId = document.field(P_COMPONENT_ID, ORID.class);
if (componentId != null) {
entity.setComponentId(new AttachedEntityId(componentEntityAdapter, componentId));
}
ORID assetId = document.field(P_ASSET_ID, ORID.class);
if (assetId != null) {
entity.setAssetId(new AttachedEntityId(assetEntityAdapter, assetId));
String assetNameLowercase = document.field(P_ASSET_NAME_LOWERCASE, OType.STRING);
entity.setAssetNameLowercase(assetNameLowercase);
}
}
示例10: setup
import com.orientechnologies.orient.core.id.ORID; //导入依赖的package包/类
@Before
public void setup() {
when(bucketDocument.getRecord()).thenReturn(bucketDocument);
when(bucketDocument.field("repository_name", String.class)).thenReturn(REPOSITORY_NAME);
when(bucketDocument.getIdentity()).thenReturn(mock(ORID.class));
when(assetDocument.getClassName()).thenReturn("asset");
when(assetDocument.getRecord()).thenReturn(assetDocument);
when(assetDocument.field("bucket", OIdentifiable.class)).thenReturn(bucketDocument);
when(assetDocument.field("name", String.class)).thenReturn(PATH);
when(assetDocument.field("format", String.class)).thenReturn(FORMAT);
when(componentDocument.getClassName()).thenReturn("component");
when(componentDocument.getRecord()).thenReturn(componentDocument);
when(componentDocument.field("bucket", OIdentifiable.class)).thenReturn(bucketDocument);
when(componentDocument.getDatabase()).thenReturn(database);
when(componentDocument.getIdentity()).thenReturn(mock(ORID.class));
when(commandRequest.execute(any(Map.class))).thenReturn(Collections.singletonList(assetDocument));
when(database.command(any(OCommandRequest.class))).thenReturn(commandRequest);
underTest = new ContentAuth(contentAuthHelper);
}
示例11: setup
import com.orientechnologies.orient.core.id.ORID; //导入依赖的package包/类
@Before
public void setup() {
when(variableResolverAdapterManager.get(FORMAT)).thenReturn(variableResolverAdapter);
when(variableResolverAdapter.fromDocument(assetDocument)).thenReturn(variableSource);
when(bucketDocument.getRecord()).thenReturn(bucketDocument);
when(bucketDocument.field("repository_name", String.class)).thenReturn(REPOSITORY_NAME);
when(bucketDocument.getIdentity()).thenReturn(mock(ORID.class));
when(assetDocument.getClassName()).thenReturn("asset");
when(assetDocument.getRecord()).thenReturn(assetDocument);
when(assetDocument.field("bucket", OIdentifiable.class)).thenReturn(bucketDocument);
when(assetDocument.field("name", String.class)).thenReturn(PATH);
when(assetDocument.field("format", String.class)).thenReturn(FORMAT);
when(commandRequest.execute(any(Map.class))).thenReturn(Collections.singletonList(assetDocument));
when(database.command(any(OCommandRequest.class))).thenReturn(commandRequest);
underTest = new ContentExpressionFunction(variableResolverAdapterManager, selectorManager, contentAuthHelper);
}
示例12: updateAssetBlobStoreRefs
import com.orientechnologies.orient.core.id.ORID; //导入依赖的package包/类
@VisibleForTesting
void updateAssetBlobStoreRefs(final Map<String, String> renamedBlobStores) {
try (ODatabaseDocumentTx db = componentDatabaseInstance.get().connect()) {
renamedBlobStores.forEach((originalName, newName) -> {
log.debug("Searching for BlobStoreRefs, original name: {}, new name: {} ", originalName, newName);
OSQLSynchQuery query = new OSQLSynchQuery<>("select from asset where blob_ref like ? and @rid > ? limit 100");
String nameTestValue = originalName + "@%";
List<ODocument> results = db.query(query, nameTestValue, new ORecordId());
while (!results.isEmpty()) {
log.debug("Updating set of {} Refs", results.size());
ORID last = results.get(results.size() - 1).getIdentity();
results.forEach(doc -> updateDocWithNewName(originalName, newName, doc));
results = db.query(query, nameTestValue, last);
}
});
}
}
示例13: handleGetEvents
import com.orientechnologies.orient.core.id.ORID; //导入依赖的package包/类
private void handleGetEvents(final Message<GetEvents.Request> msg) {
final GetEvents.Request request = msg.body();
final int skip = request.getSkip() <= 0 ? 0 : request.getSkip();
final int limit = request.getLimit() <= 0 ? 10 : request.getLimit();
final GetEvents.Response.Builder response = GetEvents.Response.newBuilder();
try (final ODatabaseDocumentTx db = orientDBService.getODatabaseDocumentTxSupplier(DB).get().get()) {
final EventLogRecord eventLogRecord = new EventLogRecord();
final List<ODocument> docs = db.query(new OSQLSynchQuery<ODocument>("select from EventLogRecord SKIP ? LIMIT ?"), skip, limit);
docs.stream().forEach(doc -> {
final EventLogRecord record = new EventLogRecord(doc);
final ORID orid = record.getDocument().getRecord().getIdentity();
final RecordId recordId = RecordId.newBuilder().setClusterId(orid.getClusterId()).setPosition(orid.getClusterPosition()).build();
response.addEvents(Event.newBuilder()
.setCreatedOn(record.getCreatedOn() != null ? record.getCreatedOn().getTime() : 0)
.setUpdatedOn(record.getUpdatedOn() != null ? record.getUpdatedOn().getTime() : 0)
.setEvent(record.getEvent())
.setRecordId(recordId)
.build()
);
});
reply(msg, response.build());
}
}
示例14: apply
import com.orientechnologies.orient.core.id.ORID; //导入依赖的package包/类
@Override
public ODocument apply(F input) {
if(input==null)
{
return null;
}
else if(input instanceof ODocument)
{
return (ODocument)input;
}
else if(input instanceof ORID)
{
return ((ORID)input).getRecord();
}
else if(input instanceof CharSequence)
{
return new ORecordId(input.toString()).getRecord();
}
else
{
throw new WicketRuntimeException("Object '"+input+"' of type '"+input.getClass()+"' can't be converted to ODocument");
}
}
示例15: onConfigure
import com.orientechnologies.orient.core.id.ORID; //导入依赖的package包/类
@Override
public void onConfigure(Component component) {
super.onConfigure(component);
Object object = component.getDefaultModelObject();
if(object!=null && object instanceof OIdentifiable) {
ORID rid = ((OIdentifiable)object).getIdentity();
if(rid.isPersistent()) {
component.setEnabled(true);
} else {
// Is record scheduled for creation?
OTransaction transaction = OrientDbWebSession.get().getDatabase().getTransaction();
ORecordOperation operation = transaction.getRecordEntry(rid);
component.setEnabled(operation!=null && operation.type==ORecordOperation.CREATED);
}
}
}