@Override public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) { try (ODatabaseDocumentTx db = databasePool.acquire()) { final ODictionary<ORecord> dictionary = db.getMetadata().getIndexManager().getDictionary(); final ODocument document = dictionary.get(key); if (document != null) { if (fields != null) { for (String field : fields) { result.put(field, new StringByteIterator((String) document.field(field))); } } else { for (String field : document.fieldNames()) { result.put(field, new StringByteIterator((String) document.field(field))); } } return Status.OK; } } catch (Exception e) { e.printStackTrace(); } return Status.ERROR; }
for (String field : document.fieldNames()) { map.put(field, new StringByteIterator((String) document.field(field)));
@Override public int size() { return document.fieldNames().length; }
@Override public int size() { return document.fieldNames().length; }
public ResultSetMetaData(ODocument rowDoc) { this.rowDoc = rowDoc; fieldsNames = Arrays.asList(rowDoc.fieldNames()); }
@Override public Set<String> keySet() { return new HashSet<String>(Arrays.asList(document.fieldNames())); }
@Override public void clear() { for (String field : document.fieldNames()) { remove(field); } }
@Override public Set<String> keySet() { session.checkOpen(); return Sets.newHashSet(document.fieldNames()); }
@Override public int hashCode() { int result = 0; for (String fieldName : internal.fieldNames()) { result += fieldName.hashCode(); Object value = internal.field(fieldName); if (value != null) { result += value.hashCode(); } } return result; } }
@Override public void clear() { for (String field : document.fieldNames()) { remove(field); } }
private void detachRidbags(ORecord oldRecord) { ODocument oldDoc = (ODocument) oldRecord; for (String field : oldDoc.fieldNames()) { if (field.equalsIgnoreCase("out") || field.equalsIgnoreCase("in") || field.startsWith("out_") || field.startsWith("in_") || field.startsWith("OUT_") || field.startsWith("IN_")) { Object val = oldDoc.rawField(field); if (val instanceof ORidBag) { oldDoc.removeField(field); } } } }
@Override void removeEdgesInternal(OrientVertex vertex, ODocument iVertex, OIdentifiable iVertexToRemove, boolean iAlsoInverse, boolean useVertexFieldsForEdgeLabels, boolean autoScaleEdgeType) { for (String fieldName : iVertex.fieldNames()) { final OPair<Direction, String> connection = vertex.getConnection(Direction.BOTH, fieldName); if (connection == null) // SKIP THIS FIELD continue; removeEdges(this, iVertex, fieldName, iVertexToRemove, iAlsoInverse, useVertexFieldsForEdgeLabels, autoScaleEdgeType, false); } } }
@Override public <T> T createEdge(final Class<T> edgeClass, final Object from, final Object to, final ODocument edge) { final OrientEdge edgeImpl = createEdgeImpl(edgeClass, from, to); for (String key : edge.fieldNames()) { final Object val = edge.field(key); if (key.charAt(0) != '@' && val != null) { edgeImpl.setProperty(key, val); } } edgeImpl.save(); return objectDb.get().load(edgeImpl.getIdentity()); }
private OETLExtractor configureExtractor(ODocument cfg, OCommandContext iContext) throws IllegalAccessException, InstantiationException { // EXTRACTOR ODocument extractorConf = cfg.<ODocument>field("extractor"); String name = extractorConf.fieldNames()[0]; OETLExtractor extractor = factory.getExtractor(name); configureComponent(extractor, extractorConf.<ODocument>field(name), iContext); return extractor; }
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 public void configure(OETLProcessor iProcessor, final ODocument iConfiguration, OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); final String[] fieldNames = iConfiguration.fieldNames(); try { block = processor.getFactory().getBlock(fieldNames[0]); block.configure(processor, (ODocument) iConfiguration.field(fieldNames[0]), context); } catch (Exception e) { throw new OConfigurationException("[Block transformer] Error on configuring inner block", e); } }
@Override public void begin(ODatabaseDocument db) { super.begin(db); final String[] fieldNames = configuration.fieldNames(); try { String fieldName = fieldNames[0]; block = new OETLComponentFactory().getBlock(fieldName); block.configure(configuration.<ODocument>field(fieldName), context); } catch (Exception e) { throw OException.wrapException(new OConfigurationException("[Block transformer] Error on configuring inner block"), e); } }
private OETLLoader configureLoader(ODocument cfg, OCommandContext iContext) throws IllegalAccessException, InstantiationException { ODocument loadersConf = cfg.field("loader"); if (loadersConf != null) { // LOADER String name = loadersConf.fieldNames()[0]; OETLLoader loader = factory.getLoader(name); configureComponent(loader, loadersConf.<ODocument>field(name), iContext); return loader; } OETLLoader loader = factory.getLoader("output"); configureComponent(loader, new ODocument(), iContext); return loader; }
private OETLSource configureSource(ODocument cfg, OCommandContext iContext) throws IllegalAccessException, InstantiationException { ODocument sourceConf = cfg.field("source"); if (sourceConf != null) { // SOURCE String name = sourceConf.fieldNames()[0]; OETLSource source = factory.getSource(name); configureComponent(source, sourceConf.<ODocument>field(name), iContext); return source; } OETLSource source = factory.getSource("input"); configureComponent(source, new ODocument(), iContext); return source; }
@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)); }