Java Code Examples for com.orientechnologies.orient.core.record.impl.ODocument#fieldNames()
The following examples show how to use
com.orientechnologies.orient.core.record.impl.ODocument#fieldNames() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CalculablePropertiesHook.java From Orienteer with Apache License 2.0 | 6 votes |
@Override public RESULT onRecordBeforeUpdate(ODocument iDocument) { List<String> calcProperties = getCalcProperties(iDocument); if(calcProperties!=null && calcProperties.size()>0) { boolean wasChanged=false; String[] fieldNames = iDocument.fieldNames(); for (String field : fieldNames) { if(calcProperties.contains(field)) { boolean tracking = iDocument.isTrackingChanges(); if(tracking) iDocument.undo(field); // iDocument.removeField(field); wasChanged = true; } } return wasChanged?RESULT.RECORD_CHANGED:RESULT.RECORD_NOT_CHANGED; } return RESULT.RECORD_NOT_CHANGED; }
Example 2
Source File: OBlockTransformer.java From orientdb-etl with Apache License 2.0 | 5 votes |
@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); } }
Example 3
Source File: EdgesSupportDelegate.java From guice-persist-orient with MIT License | 5 votes |
@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()); }
Example 4
Source File: OrienteerETLProcessor.java From Orienteer with Apache License 2.0 | 5 votes |
public static OrienteerETLProcessor parseConfigRecord(OETLTaskSession taskSession,String config){ final OCommandContext context = createDefaultContext(); ODocument configuration = new ODocument().fromJSON("{}"); configuration.merge(new ODocument().fromJSON(config, "noMap"), true, true); // configuration = ; ODocument cfgGlobal = configuration.field("config"); if (cfgGlobal != null) { for (String f : cfgGlobal.fieldNames()) { context.setVariable(f, cfgGlobal.field(f)); } } return (OrienteerETLProcessor) new OrienteerETLProcessor(taskSession).parse(configuration, context); }
Example 5
Source File: CopyODocumentCommand.java From Orienteer with Apache License 2.0 | 5 votes |
@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)); }
Example 6
Source File: OOrientDBLoader.java From orientdb-etl with Apache License 2.0 | 4 votes |
@Override public void configure(final OETLProcessor iProcessor, final ODocument iConfiguration, final OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); if (iConfiguration.containsField("dbURL")) dbURL = (String) resolve(iConfiguration.field("dbURL")); if (iConfiguration.containsField("dbUser")) dbUser = (String) resolve(iConfiguration.field("dbUser")); if (iConfiguration.containsField("dbPassword")) dbPassword = (String) resolve(iConfiguration.field("dbPassword")); if (iConfiguration.containsField("dbType")) dbType = DB_TYPE.valueOf(iConfiguration.field("dbType").toString().toUpperCase()); if (iConfiguration.containsField("tx")) tx = (Boolean) iConfiguration.field("tx"); if (iConfiguration.containsField("wal")) wal = (Boolean) iConfiguration.field("wal"); if (iConfiguration.containsField("txUseLog")) txUseLog = (Boolean) iConfiguration.field("txUseLog"); if (iConfiguration.containsField("batchCommit")) batchCommit = (Integer) iConfiguration.field("batchCommit"); if (iConfiguration.containsField("dbAutoCreate")) dbAutoCreate = (Boolean) iConfiguration.field("dbAutoCreate"); if (iConfiguration.containsField("dbAutoDropIfExists")) dbAutoDropIfExists = (Boolean) iConfiguration.field("dbAutoDropIfExists"); if (iConfiguration.containsField("dbAutoCreateProperties")) dbAutoCreateProperties = (Boolean) iConfiguration.field("dbAutoCreateProperties"); if (iConfiguration.containsField("useLightweightEdges")) useLightweightEdges = (Boolean) iConfiguration.field("useLightweightEdges"); if (iConfiguration.containsField("standardElementConstraints")) standardElementConstraints = (Boolean) iConfiguration.field("standardElementConstraints"); clusterName = iConfiguration.field("cluster"); className = iConfiguration.field("class"); indexes = iConfiguration.field("indexes"); classes = iConfiguration.field("classes"); if (iConfiguration.containsField("settings")) { final ODocument settings = (ODocument) iConfiguration.field("settings"); settings.setAllowChainedAccess(false); for (String s : settings.fieldNames()) { final OGlobalConfiguration v = OGlobalConfiguration.findByKey(s); if (v != null) v.setValue(settings.field(s)); } } if (!wal) OGlobalConfiguration.USE_WAL.setValue(wal); switch (dbType) { case DOCUMENT: final ODatabaseDocumentTx documentDatabase = new ODatabaseDocumentTx(dbURL); if (documentDatabase.exists() && dbAutoDropIfExists) { log(OETLProcessor.LOG_LEVELS.INFO, "Dropping existent database '%s'...", dbURL); documentDatabase.open(dbUser, dbPassword); documentDatabase.drop(); } if (documentDatabase.exists()) { log(OETLProcessor.LOG_LEVELS.DEBUG, "Opening database '%s'...", dbURL); documentDatabase.open(dbUser, dbPassword); } else if (dbAutoCreate) { documentDatabase.create(); } else throw new IllegalArgumentException("Database '" + dbURL + "' not exists and 'dbAutoCreate' setting is false"); documentDatabase.close(); break; case GRAPH: final OrientGraphFactory factory = new OrientGraphFactory(dbURL, dbUser, dbPassword); if (dbAutoDropIfExists && factory.exists()) { log(OETLProcessor.LOG_LEVELS.INFO, "Dropping existent database '%s'...", dbURL); factory.drop(); } final OrientBaseGraph graphDatabase = tx ? factory.getTx() : factory.getNoTx(); graphDatabase.shutdown(); break; } }