ODocument doc = (ODocument) rec; final String className = doc.getClassName() != null ? doc.getClassName().toUpperCase() : null; if (includeClasses != null) { if (!includeClasses.contains(className)) continue; } else if (excludeClasses != null) { if (excludeClasses.contains(className)) continue; }
private String getClassName(final Object iValue) { if (iValue instanceof ODocument) return ((ODocument) iValue).getClassName(); return iValue != null ? iValue.getClass().getSimpleName() : null; }
@Override public String asText(ODocument document) { OShapeBuilder oShapeBuilder = factories.get(document.getClassName()); if (oShapeBuilder != null) { return oShapeBuilder.asText(document); } // TODO handle exception shape not found return null; }
@Override public Shape fromDoc(ODocument document) { OShapeBuilder oShapeBuilder = factories.get(document.getClassName()); if (oShapeBuilder != null) { return oShapeBuilder.fromDoc(document); } // TODO handle exception shape not found return null; }
protected Record getRecord(ODocument document) { RecordType type = schema.getType(document.getClassName()); checkArgument(type != null, "Class is not registered: %s", document.getClassName()); return new OrientRecord(this, type, document); }
@SuppressWarnings("unchecked") private <T> T tryObjectConversion(final ODocument doc, final Class<T> targetType) { // Possible case: custom result converter required. For example, targetType may be even mapped object // class but returned document does not represent this class (assumed manual conversion) if (doc.getClassName().equals(targetType.getSimpleName())) { final ODatabaseObject db = injector.getInstance(ODatabaseObject.class); if (db.getEntityManager().getRegisteredEntities().contains(targetType)) { return (T) db.getUserObjectByRecord(doc, null); } } return null; }
public OUser getUser(final ORID iRecordId) { if (iRecordId == null) return null; ODocument result; result = getDatabase().load(iRecordId, "roles:1"); if (!result.getClassName().equals(OUser.CLASS_NAME)) { result = null; } return new OUser(result); }
@Nullable private EntityEvent newEntityEvent(final ODocument document, final EventKind eventKind) { EntityAdapter adapter = recordingAdapters.get(document.getClassName()); EntityEvent event = adapter.newEvent(document, eventKind); if (event != null && eventManager.isAffinityEnabled()) { event.setAffinity(adapter.eventAffinity(document)); } return event; }
public String toString() { graph.setCurrentGraphInThreadLocal(); final String clsName = getRecord().getClassName(); if (clsName.equals(CLASS_NAME)) return StringFactory.vertexString(this); return StringFactory.V + "(" + clsName + ")" + StringFactory.L_BRACKET + getId() + StringFactory.R_BRACKET; }
public String getLabel() { graph.setCurrentGraphInThreadLocal(); if (graph.isUseClassForVertexLabel()) { final String clsName = getRecord().getClassName(); if (!CLASS_NAME.equals(clsName)) // RETURN THE CLASS NAME return clsName; } return getRecord().field(OrientElement.LABEL_FIELD_NAME); }
/** * Returns a string representation of the vertex. */ public String toString() { setCurrentGraphInThreadLocal(); final ODocument record = getRecord(); if (record == null) return "<invalid record " + rawElement.getIdentity() + ">"; final String clsName = record.getClassName(); if (OrientVertexType.CLASS_NAME.equals(clsName)) return StringFactory.vertexString(this); return StringFactory.V + "(" + clsName + ")" + StringFactory.L_BRACKET + getId() + StringFactory.R_BRACKET; }
protected OClass serializeClass(final ODocument document, final BytesContainer bytes) { final OClass clazz = ODocumentInternal.getImmutableSchemaClass(document); String name = null; if (clazz != null) name = clazz.getName(); if (name == null) name = document.getClassName(); if (name != null) writeString(bytes, name); else writeEmptyString(bytes); return clazz; }
private boolean checkSecurity(OIdentifiable value) { try { // TODO check this! execDb.checkSecurity(ORule.ResourceGeneric.CLASS, ORole.PERMISSION_READ, ((ODocument) value.getRecord()).getClassName()); } catch (OSecurityException ignore) { return false; } return ORestrictedAccessHook.isAllowed((ODatabaseDocumentInternal) execDb, (ODocument) value.getRecord(), ORestrictedOperation.ALLOW_READ, false); }
protected OClass serializeClass(final ODocument document, final BytesContainer bytes) { final OClass clazz = ODocumentInternal.getImmutableSchemaClass(document); String name = null; if (clazz != null) name = clazz.getName(); if (name == null) name = document.getClassName(); if (name != null) writeString(bytes, name); else writeEmptyString(bytes); return clazz; }
static DocumentEntity convert(ODocument document) { DocumentEntity entity = DocumentEntity.of(document.getClassName()); Stream.of(document.fieldNames()) .map(f -> Document.of(f, convert((Object) document.field(f)))) .forEach(entity::add); entity.add(Document.of(RID_FIELD, document.field(RID_FIELD).toString())); entity.add(Document.of(VERSION_FIELD, document.getVersion())); return entity; }
@Override protected void onConfigure() { super.onConfigure(); ODocument doc = getModelObject(); if(doc==null) throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND); //Support of case when metadata was changed in parallel else if(Strings.isEmpty(doc.getClassName()) && doc.getIdentity().isValid()) { getDatabase().reload(); if(Strings.isEmpty(doc.getClassName())) throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND); } }
@Override protected void onConfigure() { super.onConfigure(); ODocument doc = getDocument(); if(doc==null) throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND); //Support of case when metadata was changed in parallel else if(Strings.isEmpty(doc.getClassName()) && doc.getIdentity().isValid()) { getDatabase().reload(); if(Strings.isEmpty(doc.getClassName())) throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND); } }
private static OResultInternal calculateAfter(ODocument iDocument) { OResultInternal result = new OResultInternal(); for (String prop : iDocument.getPropertyNames()) { result.setProperty(prop, unboxRidbags(iDocument.getProperty(prop))); } result.setProperty("@rid", iDocument.getIdentity()); result.setProperty("@class", iDocument.getClassName()); result.setProperty("@version", iDocument.getVersion() + 1); return result; }
@Override protected void perfromSingleAction(AjaxRequestTarget target, ODocument object) { ODocument copy = getDatabase().newInstance(object.getClassName()); for (String fieldName : object.fieldNames()) { copy.field(fieldName, (Object) object.field(fieldName)); } setResponsePage(new ODocumentPage(new ODocumentModel(copy)).setModeObject(DisplayMode.EDIT)); }
private static OResultInternal calculateBefore(ODocument iDocument) { OResultInternal result = new OResultInternal(); for (String prop : iDocument.getPropertyNames()) { result.setProperty(prop, unboxRidbags(iDocument.getProperty(prop))); } result.setProperty("@rid", iDocument.getIdentity()); result.setProperty("@class", iDocument.getClassName()); result.setProperty("@version", iDocument.getVersion()); for (String prop : iDocument.getDirtyFields()) { result.setProperty(prop, iDocument.getOriginalValue(prop)); } return result; }