@Override public Object remove(Object key) { Object ret = get(key); if(key instanceof String) document.removeField((String)key); return ret; }
@Override public void remove(final String key) { session.checkOpen(); document.removeField(key); }
@Override public Object remove(Object key) { Object ret = get(key); if(key instanceof String) document.removeField((String)key); return ret; }
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); } } } }
private Object copy(final ODocument document, final Object[] iFieldNames) { final ODocument doc = document.copy(); for (Object iFieldName : iFieldNames) { if (iFieldName != null) { final String fieldName = iFieldName.toString(); if (fieldName.endsWith("*")) { final String fieldPart = fieldName.substring(0, fieldName.length() - 1); final List<String> toExclude = new ArrayList<String>(); for (String f : doc.fieldNames()) { if (f.startsWith(fieldPart)) toExclude.add(f); } for (String f : toExclude) doc.removeField(f); } else doc.removeField(fieldName); } } doc.deserializeFields(); return doc; }
private Object copy(final Map map, final Object[] iFieldNames) { final ODocument doc = new ODocument().fields(map); for (Object iFieldName : iFieldNames) { if (iFieldName != null) { final String fieldName = iFieldName.toString(); if (fieldName.endsWith("*")) { final String fieldPart = fieldName.substring(0, fieldName.length() - 1); final List<String> toExclude = new ArrayList<String>(); for (String f : doc.fieldNames()) { if (f.startsWith(fieldPart)) toExclude.add(f); } for (String f : toExclude) doc.removeField(f); } else doc.removeField(fieldName); } } return doc; } }
@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; }
/** * (Blueprints Extension) This method does not remove connection from opposite side. * * @param iVertex vertex that holds connection * @param iFieldName name of field that holds connection * @param iVertexToRemove target of connection */ private static void removeLightweightConnection(final ODocument iVertex, final String iFieldName, final OIdentifiable iVertexToRemove) { if (iVertex == null || iVertexToRemove == null) return; final Object fieldValue = iVertex.field(iFieldName); if (fieldValue instanceof OIdentifiable) { if (fieldValue.equals(iVertexToRemove)) { iVertex.removeField(iFieldName); } } else if (fieldValue instanceof ORidBag) { ((ORidBag) fieldValue).remove(iVertexToRemove); } }
public <T> T removeProperty(final String key) { graph.autoStartTransaction(); final Object oldValue = getRecord().removeField(key); save(); return (T) oldValue; }
/** * helper for method above * @param document * @param tags * @param fieldName * @param tagRepository */ private static void populateODocumentWithToFromTagsHelper(ODocument document, String[] tags, String fieldName, TagRepository tagRepository) { if (tags != null && tags.length > 0) { // create tags if needed tagRepository.createNewTagsByTitles(tags); // get all tag ids and populate list List<ORecordId> list = new ArrayList<>(); for (String id : tagRepository.findTagIdsByTitles(tags)) { list.add(new ORecordId(id)); } document.field(fieldName, list); } else document.removeField(fieldName); }
/** * 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.removeField(P_ASSET_NAME_LOWERCASE); document.save(); } else { document.delete(); } } }
private ODocument updateOrientDocFromAvroBean(final K key, final T persistent, final ODocument result) { for (Schema.Field f : persistent.getSchema().getFields()) { if (persistent.isDirty(f.pos()) /*&& (persistent.get(f.pos()) != null)*/) { String docf = orientDBMapping.getDocumentField(f.name()); if (persistent.get(f.pos()) == null) { result.removeField(docf); continue; } Object value = persistent.get(f.pos()); OrientDBMapping.DocumentFieldType storeType = orientDBMapping.getDocumentFieldType(docf); LOG.debug("Transform value to ODocument, docField:{}, schemaType:{}, storeType:{}", new Object[]{docf, f.schema().getType(), storeType}); Object o = convertAvroFieldToOrientField(docf, f.schema(), f.schema().getType(), storeType, value); result.field(docf, o); } } return result; }
/** * Removes a Property. * * @param key Property name * @return Old value if any */ @Override public <T> T removeProperty(final String key) { if (checkDeletedInTx()) throw new IllegalStateException("The vertex " + getIdentity() + " has been deleted"); final OrientBaseGraph graph = getGraph(); if (graph != null) graph.autoStartTransaction(); final Object oldValue = getRecord().removeField(key); if (graph != null) save(); return (T) oldValue; }
public void removeMetadata(String key) { ODocument metadata = getMetadataDocument(); metadata.removeField(key); if (metadata.fields() == 0) element.getRawElement().removeProperty(metadataKey()); }
/** * Removes any {@link BrowseNode}s associated with the given component id. */ public void deleteComponentNode(final ODatabaseDocumentTx db, final EntityId componentId) { // some formats have the same component appearing on different branches of the tree Iterable<ODocument> documents = db.command(new OCommandSQL(FIND_BY_COMPONENT)).execute( ImmutableMap.of(P_COMPONENT_ID, recordIdentity(componentId))); documents.forEach(document -> { if (document.containsField(P_ASSET_ID)) { // asset still exists, just remove component details document.removeField(P_COMPONENT_ID); document.save(); } else { document.delete(); } }); }
synchronized void updateConfiguration(String type, String name, int version, OIndexDefinition indexDefinition, Set<String> clustersToIndex, String algorithm, String valueContainerAlgorithm) { document.field(OIndexInternal.CONFIG_TYPE, type); document.field(OIndexInternal.CONFIG_NAME, name); document.field(OIndexInternal.INDEX_VERSION, version); if (indexDefinition != null) { final ODocument indexDefDocument = indexDefinition.toStream(); if (!indexDefDocument.hasOwners()) ODocumentInternal.addOwner(indexDefDocument, document); document.field(OIndexInternal.INDEX_DEFINITION, indexDefDocument, OType.EMBEDDED); document.field(OIndexInternal.INDEX_DEFINITION_CLASS, indexDefinition.getClass().getName()); } else { document.removeField(OIndexInternal.INDEX_DEFINITION); document.removeField(OIndexInternal.INDEX_DEFINITION_CLASS); } document.field(CONFIG_CLUSTERS, clustersToIndex, OType.EMBEDDEDSET); document.field(ALGORITHM, algorithm); document.field(VALUE_CONTAINER_ALGORITHM, valueContainerAlgorithm); } }
private boolean handleRemoveEntries(ODocument record) { boolean updated = false; if (!removeEntries.isEmpty()) { // REMOVE FIELD IF ANY for (OPair<String, Object> entry : removeEntries) { Object value = extractValue(record, entry); if (value == EMPTY_VALUE) { record.removeField(entry.getKey()); updated = true; } else { final Object fieldValue = record.field(entry.getKey()); if (fieldValue instanceof Collection<?>) { updated = removeFromCollection(updated, value, (Collection<?>) fieldValue); } else if (fieldValue instanceof Map<?, ?>) { updated = removeFromMap(updated, value, (Map<?, ?>) fieldValue); } else if (fieldValue instanceof ORidBag) { updated = removeFromBag(record, updated, value, (ORidBag) fieldValue); } } } } return updated; }
/** * helper method to convert entity to document * @param document to be converted * @param entity converted */ protected void populateODocumentWithColored(ODocument document, SegradaColoredEntity entity) { // set color document.field("color", entity.getColor()); // set pictogram if (entity.getPictogram() != null) { document.field("pictogram", new ORecordId(entity.getPictogram().getId())); } else document.removeField("pictogram"); }
private void autoCreatePropertiesOnDocument(ODatabaseDocument db, ODocument doc) { final OClass cls; if (className != null) cls = getOrCreateClass(db, className, null); else cls = doc.getSchemaClass(); for (String f : doc.fieldNames()) { final String newName = transformFieldName(f); final String fName = newName != null ? newName : f; OProperty p = cls.getProperty(fName); if (p == null) { final Object fValue = doc.field(f); createProperty(cls, fName, fValue); if (newName != null) { // REPLACE IT doc.removeField(f); doc.field(newName, fValue); } } } }
document.field("regexp", regexp); } else { document.removeField("regexp");