Java Code Examples for com.orientechnologies.orient.core.record.impl.ODocument#containsField()
The following examples show how to use
com.orientechnologies.orient.core.record.impl.ODocument#containsField() .
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: BrowseNodeEntityAdapter.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
/** * Removes the {@link BrowseNode} associated with the given asset id. */ public void deleteAssetNode(final ODatabaseDocumentTx db, final EntityId assetId) { // a given asset will only appear once in the tree ODocument document = getFirst( db.command(new OCommandSQL(FIND_BY_ASSET)).execute( ImmutableMap.of(P_ASSET_ID, recordIdentity(assetId))), null); if (document != null) { if (document.containsField(P_COMPONENT_ID)) { // component still exists, just remove asset details document.removeField(P_ASSET_ID); document.save(); } else { maybeDeleteParents(db, document.field(P_REPOSITORY_NAME), document.field(P_PARENT_PATH)); document.delete(); } } }
Example 2
Source File: CallbackHook.java From Orienteer with Apache License 2.0 | 6 votes |
@Override public RESULT onTrigger(TYPE iType, ORecord iRecord) { if(!(iRecord instanceof ODocument)) return RESULT.RECORD_NOT_CHANGED; ODocument doc = (ODocument) iRecord; CallbacksHolder callbacks=null; if(doc.containsField(CALLBACKS_FIELD)) callbacks = (CallbacksHolder) doc.field(CALLBACKS_FIELD); else callbacks = PRESERVED.get(); if(callbacks==null) return RESULT.RECORD_NOT_CHANGED; boolean docWasChanged = callbacks.call(iType, doc); PRESERVED.remove(); if(PRESERVE_IN_THREAD.contains(iType)) { doc.removeField(CALLBACKS_FIELD); PRESERVED.set(callbacks); } if(callbacks.isEmpty()) doc.removeField(CALLBACKS_FIELD); return docWasChanged?RESULT.RECORD_CHANGED:RESULT.RECORD_NOT_CHANGED; }
Example 3
Source File: OEdgeTransformer.java From orientdb-etl with Apache License 2.0 | 6 votes |
@Override public void configure(OETLProcessor iProcessor, final ODocument iConfiguration, final OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); edgeClass = iConfiguration.field("class"); if (iConfiguration.containsField("direction")) { final String direction = iConfiguration.field("direction"); if ("out".equalsIgnoreCase(direction)) directionOut = true; else if ("in".equalsIgnoreCase(direction)) directionOut = false; else throw new OConfigurationException("Direction can be 'in' or 'out', but found: " + direction); } if (iConfiguration.containsField("targetVertexFields")) targetVertexFields = (ODocument) iConfiguration.field("targetVertexFields"); if (iConfiguration.containsField("edgeFields")) edgeFields = (ODocument) iConfiguration.field("edgeFields"); if (iConfiguration.containsField("skipDuplicates")) skipDuplicates = (Boolean) resolve(iConfiguration.field("skipDuplicates")); }
Example 4
Source File: OLogTransformer.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); if (iConfiguration.containsField("prefix")) prefix = iConfiguration.field("prefix"); if (iConfiguration.containsField("postfix")) postfix = iConfiguration.field("postfix"); }
Example 5
Source File: IndexSyncService.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Nullable private EntityId findComponentId(final ODocument document) { if (document.containsField(P_COMPONENT)) { // get the owning component from the asset, might be null if asset is standalone return componentId(document.field(P_COMPONENT, ORID.class)); } else { // not an asset, must be a component itself return componentId(document.getIdentity()); } }
Example 6
Source File: RandomExtractor.java From orientdb-etl with Apache License 2.0 | 5 votes |
@Override public void configure(OETLProcessor iProcessor, ODocument iConfiguration, OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); if (iConfiguration.containsField("items")) items = ((Number) iConfiguration.field("items")).longValue(); if (iConfiguration.containsField("fields")) fields = iConfiguration.field("fields"); if (iConfiguration.containsField("delay")) delay = iConfiguration.field("delay"); }
Example 7
Source File: OVertexTransformer.java From orientdb-etl with Apache License 2.0 | 5 votes |
@Override public void configure(final OETLProcessor iProcessor, final ODocument iConfiguration, final OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); if (iConfiguration.containsField("class")) vertexClass = (String) resolve(iConfiguration.field("class")); if (iConfiguration.containsField("skipDuplicates")) skipDuplicates = (Boolean) resolve(iConfiguration.field("skipDuplicates")); }
Example 8
Source File: OAbstractETLComponent.java From orientdb-etl with Apache License 2.0 | 5 votes |
@Override public void configure(final OETLProcessor iProcessor, final ODocument iConfiguration, final OCommandContext iContext) { processor = iProcessor; context = iContext; ifExpression = iConfiguration.field("if"); if (iConfiguration.containsField("log")) logLevel = OETLProcessor.LOG_LEVELS.valueOf(iConfiguration.field("log").toString().toUpperCase()); else logLevel = iProcessor.getLogLevel(); if (iConfiguration.containsField("output")) output = (String) iConfiguration.field("output"); }
Example 9
Source File: OAbstractLookupTransformer.java From orientdb-etl with Apache License 2.0 | 5 votes |
@Override public void configure(final OETLProcessor iProcessor, final ODocument iConfiguration, OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); joinFieldName = iConfiguration.field("joinFieldName"); if (iConfiguration.containsField("joinValue")) joinValue = iConfiguration.field("joinValue"); if (iConfiguration.containsField("lookup")) lookup = iConfiguration.field("lookup"); if (iConfiguration.containsField("unresolvedLinkAction")) unresolvedLinkAction = ACTION.valueOf(iConfiguration.field("unresolvedLinkAction").toString().toUpperCase()); }
Example 10
Source File: OCodeTransformer.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); if (iConfiguration.containsField("language")) language = iConfiguration.field("language"); String code; if (iConfiguration.containsField("code")) code = iConfiguration.field("code"); else throw new IllegalArgumentException("'code' parameter is mandatory in Code Transformer"); cmd = new OCommandExecutorScript().parse(new OCommandScript(language, code)); }
Example 11
Source File: AbstractMethodHandler.java From Orienteer with Apache License 2.0 | 5 votes |
protected static Object prepareForJava(ODocument result, Class<?> requiredClass) { if(result==null) return null; else if(requiredClass.isInstance(result)) return result; else if(ODocumentWrapper.class.isAssignableFrom(requiredClass)) return Reflect.onClass(requiredClass).create(result).get(); else if(requiredClass.isInterface()) return DAO.provide(requiredClass, result); else if(result.containsField("value")) { Object value = result.field("value"); if(value instanceof ODocument) return prepareForJava((ODocument)value, requiredClass); return result.field("value", requiredClass); } throw new IllegalStateException("Can't case ODocument to "+requiredClass); }
Example 12
Source File: OCommandTransformer.java From orientdb-etl with Apache License 2.0 | 5 votes |
@Override public void configure(final OETLProcessor iProcessor, final ODocument iConfiguration, final OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); if (iConfiguration.containsField("language")) language = ((String) iConfiguration.field("language")).toLowerCase(); command = (String) iConfiguration.field("command"); }
Example 13
Source File: OCSVTransformer.java From orientdb-etl with Apache License 2.0 | 5 votes |
@Override public void configure(final OETLProcessor iProcessor, final ODocument iConfiguration, final OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); if (iConfiguration.containsField("separator")) separator = iConfiguration.field("separator").toString().charAt(0); if (iConfiguration.containsField("columnsOnFirstLine")) columnsOnFirstLine = (Boolean) iConfiguration.field("columnsOnFirstLine"); if (iConfiguration.containsField("columns")) { final List<String> columns = iConfiguration.field("columns"); columnNames = new ArrayList<String>(columns.size()); columnTypes = new ArrayList<OType>(columns.size()); for (String c : columns) { final String[] parts = c.split(":"); columnNames.add(parts[0]); if (parts.length > 1) columnTypes.add(OType.valueOf(parts[1].toUpperCase())); else columnTypes.add(OType.ANY); } } if (iConfiguration.containsField("skipFrom")) skipFrom = ((Number) iConfiguration.field("skipFrom")).longValue(); if (iConfiguration.containsField("skipTo")) skipTo = ((Number) iConfiguration.field("skipTo")).longValue(); if (iConfiguration.containsField("nullValue")) nullValue = iConfiguration.field("nullValue"); if (iConfiguration.containsField("unicode")) unicode = iConfiguration.field("unicode"); if (iConfiguration.containsField("stringCharacter")) { final String value = iConfiguration.field("stringCharacter").toString(); if (value.isEmpty()) stringCharacter = null; else stringCharacter = value.charAt(0); } }
Example 14
Source File: SaveODocumentCommand.java From Orienteer with Apache License 2.0 | 5 votes |
public static void realizeMandatory(ODocument doc) { OClass oClass = doc.getSchemaClass(); if(oClass!=null) { for(OProperty property : oClass.properties()) { if(property.isMandatory() && Strings.isEmpty(property.getDefaultValue()) && !doc.containsField(property.getName())) { doc.field(property.getName(), (Object) null); } } } }
Example 15
Source File: OHttpSource.java From orientdb-etl with Apache License 2.0 | 5 votes |
@Override public void configure(OETLProcessor iProcessor, ODocument iConfiguration, OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); url = iConfiguration.field("url"); if (url == null || url.isEmpty()) throw new OConfigurationException("HTTP Source missing URL"); if (iConfiguration.containsField("method")) method = iConfiguration.field("method"); if (iConfiguration.containsField("headers")) headers = iConfiguration.field("headers"); }
Example 16
Source File: OCodeBlock.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); if (iConfiguration.containsField("language")) language = iConfiguration.field("language"); if (iConfiguration.containsField("code")) code = iConfiguration.field("code"); else throw new IllegalArgumentException("'code' parameter is mandatory in Code Transformer"); cmd = new OCommandExecutorScript().parse(new OCommandScript(language, code)); }
Example 17
Source File: OLetBlock.java From orientdb-etl with Apache License 2.0 | 5 votes |
@Override public void configure(OETLProcessor iProcessor, final ODocument iConfiguration, final OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); name = iConfiguration.field("name"); if (iConfiguration.containsField("value")) { value = iConfiguration.field("value"); } else expression = new OSQLFilter((String) iConfiguration.field("expression"), iContext, null); if (value == null && expression == null) throw new IllegalArgumentException("'value' or 'expression' parameter are mandatory in Let Transformer"); }
Example 18
Source File: ORowExtractor.java From orientdb-etl with Apache License 2.0 | 5 votes |
@Override public void configure(final OETLProcessor iProcessor, final ODocument iConfiguration, final OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); if (iConfiguration.containsField("multiLine")) multiLine = (Boolean) iConfiguration.field("multiLine"); if (iConfiguration.containsField("lineFeed")) lineFeed = (String) iConfiguration.field("lineFeed"); }
Example 19
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; } }
Example 20
Source File: OFileSource.java From orientdb-etl with Apache License 2.0 | 4 votes |
@Override public void configure(OETLProcessor iProcessor, ODocument iConfiguration, OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); if (iConfiguration.containsField("lock")) lockFile = iConfiguration.<Boolean> field("lock"); if (iConfiguration.containsField("skipFirst")) skipFirst = Long.parseLong(iConfiguration.<String> field("skipFirst")); if (iConfiguration.containsField("skipLast")) skipLast = Long.parseLong(iConfiguration.<String> field("skipLast")); if (iConfiguration.containsField("encoding")) encoding = Charset.forName(iConfiguration.<String> field("encoding")); path = (String) resolve(iConfiguration.field("path")); input = new File((String) path); if (!input.exists()) throw new OSourceException("[File source] path '" + path + "' not exists"); fileName = input.getName(); }